Personal Learnings← Interconnects  Library

Interconnects · Tech & AI

Llama 2 follow-up: too much RLHF, GPU sizing, technical details

TIER 4   2023-07-21

Following all of the Llama 2 news in the last few days would've been beyond a full-time job. The information networks truly were overflowing with takes, experiments, and updates. It'll still be like this for another week at least, but there are already some crucial points. In this post, I will clarify a couple of corrections I made to the original post on all things Llama 2, and then I will continue my analysis. The first half of the post will be the controversial and/or questioned parts of the model so far and at the end, I will include the rest of my technical notes (on further reinforcement learning details and the new context management method, Ghost Attention).

First, two quick corrections:

I also was on an emergency podcast covering Llama 2, if you're interested in audio.

Evasiveness through harmlessness

Llama-2-chat has been found to exhibit trigger-happy behaviors with respect to its safety filter. Asking for something innocent, such as how to make spicy mayo or how to kill a process, results in the model wildly capitulating about how it cannot do it. Here's an example from Anton, a leading open-source AI engineer these days:

Image.tiff

I don't need to beat a dead horse about how this is annoying. This is very annoying to use.

There are popular theories as to why this is the case — most of them point to using the RLHF hammer for too long. The causes of this shortcoming are illustrative to bigger-picture trends in large language models these days. With RLHF, the primary performance metric used during training is monotonic increases in the reward from the preference model. This encounters two immediate issues: a) the reward models we're using are incomplete and b) we're missing out on useful evaluation techniques for intermediate training techniques.

So long as the reward models we train only are able to achieve 65-75% accuracy on the validation sets (because the training data is a noisy aggregate of diverse human preferences, which are hard to model), it will be the case that you can RLHF your model too long. When a model takes too many optimization steps with respect to the reward model, it is going to over-index on behaviors that that model likes, even if more holistic evaluations of the model would indicate otherwise. I’ve written a | lot | more about reward models of human preferences, if you’re interested.

There is not an immediate and thorough solution to this, but what my team is doing is trying to dispatch runs on MT Bench and other automatic NLP evals for every epoch of RL training. LLM training right now, at least in the chat space, is extremely uncalibrated with user expectations.

As always, there are hidden details about this in the appendix. Ultimately, Meta's evaluations indicated that the chat models may have two potential Achilles' heels in evaluation:

  1. The model is found to refuse to answer up to 27% of borderline asks! This follows closely with Anthropic's line of work where they suggest developing a helpful language model first and then a harmless language model, as doing them at once results in evasive behavior. The fact that this is in the paper and known, means Meta is surely working on it.

    This helpful-vs-harmful tradeoff is a fundamental issue facing the open-source community. Training and releasing a helpful-only model plays to negative actors looking to use these models in a way Meta does not intend, and cannot really enforce. If we can’t release those, we end up stuck in the middle like some people view Llama 2. Expect to keep following how this plays out.

    Below is the figure showing the crazy increase in model refusal with “borderline datasets.”

Screenshot 2023-07-20 at 5.27.12 PM.png
  1. The reward model ensemble technique has an issue where there are regions of high disagreement -- i.e. what to do when there is a high helpfulness and low safety score, and vice versa. Their method for utilizing this ensemble clearly needs a bit of work, even if I find it to be an awesome technological innovation.

    Below is the figure showing this. I mostly include it because it is one of the coolest visualizations I’ve seen in ML in a few months!

Screenshot 2023-07-20 at 5.26.51 PM.png

While it is tough that these models have rough edges, it is pretty expected that a gigantic company err on the side of caution. We also have seen this in the lack of training data details in the paper. The paper, while almost 40 pages, is missing a large set of crucial details. This is in light of Meta being sued for the data in the original LLaMA, but it would have been nice if Meta said something other than ‘publicly available data’. Today, the notion of the public in AI is extremely abused. There is too much discourse on the public square for information and the data on the internet being public. Meta cannot say explicitly if they committed shady copyright or terms-of-service violations, like many of their closed source partners, but Meta can do much better on the taxonomy they use around data access and documentation.

A final point on safety that maybe I missed. Is it true that Meta did not do as substantial of human and model evals on its base models for safety? I find this odd, as those models will now be the starting point for tons of fine-tuning experiments. They’re almost more important, now that the RLHF’d models didn’t pass many people’s sniff test.

Subscribe now

Inference and Llamas

One of the hardest things to build intuitions for without actually doing it is knowing GPU requirements for various model sizes and throughput requirements. There are lots of great people out there sharing what the minimal viable computer is for different use cases.

Here are a collection of resources for understanding inference and fine-tuning (mostly parameter-efficient instruction tuning).

Inference considerations

It seems like there are a lot of paths for fitting 7b or 13b models on most GPUs. These will be running on iPhones soon. The 70b variant is a little bit trickier. For example, one discussion shows how a 70b variant uses 36-38GB VRAM when loading in 4-bit quantization. If you double the quantization to 8bit (float16), you can expect the memory to change proportionally. Using the full, non-quantized model, on any single GPU will be really hard.

HuggingFace's recommendations for a few downstream users consistently in text-generation-inference are as follows (which are not as focused on quantization):

As another example, a community member re-wrote part of HuggingFace Transformers to be more memory efficient just for Llama models. You can check out ExLlama here or a summary of its speed here. The results are pretty fast (and support extended context lengths with RoPE scaling):

Getting 10.5~ tokens/sec for llama-2 70b seq length 4096. Doesn't go oom, also tried seq length 8192, didn't go oom timing was 8 tokens/sec. The output from the 70b raw model is excellent, the best output I have seen from a raw pretrained model

Fine-tuning considerations

The fine-tuning examples are coming quickly — I didn’t have an easy job finding them in my writing block, but I had seen more. TRL can already run supervised fine-tuning very easily, where you can train "Llama 2 7B on a T4 GPU which you get for free on Google Colab or even train the 70B model on a single A100". This is obviously a biased HuggingFace perspective, but it goes to show it's pretty accessible. Most consumer GPUs can fine-tune the 7B or 13B variant.

RLHF is a different story, where you need to store a lot more gradient calculations in memory. Those numbers will trickle out next week probably.

For more on efficiently deploying large models, I liked this article from Finbarr.

Other things to watch

There are a lot more things to cover here. I'll do a rapid-fire section, and expect to hear more about these in the future:

natolambert\_a\_herd\_of\_varried\_and\_overly\_colorful\_llamas\_cloggi\_79db0f5c-07b3-4927-bfb3-63f2566f93b4.png
midj

Additional technical notes

I had these from my original article, but they've also been improved by more internal discussions with 🤗 colleagues in the last couple of days.

Ghost Attention chat trick

The model has a cool trick that helps it be useful at following multi-turn directions. Many language models have a problem where if you tell them to do something on the first turn, like "respond in the style of a pirate," they forget after one or two turns. This is a pretty advanced feature that Meta decided to tackle (even if it wasn't the biggest issue facing open source). This type of stuff makes me excited to have Meta as a player in this space -- they're going after everything, a great sign for open source.

Meta sets the stage for the problem in the paper, explaining this style of multi-turn instruction:

In a dialogue setup, some instructions should apply for all the conversation turns, e.g., to respond succinctly, or to “act as” some public figure. When we provided such instructions to Llama 2-Chat, the subsequent response should always respect the constraint. However, our initial RLHF models tended to forget the initial instruction after a few turns of dialogue.

To solve this, the authors propose Ghost Attention (GAtt), a technique similar to context distillation (training a model on a long prompt, then running supervised learning onto the output with a shorter system prompt. Roughly, the method works as follows:

Essentially, they're adding more prompting at inference time for training, then using that data and removing the prompt in the future. They comment that it makes long conversations much more consistent in terms of instruction-following:

We applied GAtt after RLHF V3. We report a quantitative analysis indicating that GAtt is consistent up to 20+ turns, until the maximum context length is reached (see Appendix A.3.5). We tried to set constraints not present in the training of GAtt at inference time, for instance “Always answer with Haiku,” for which the model remained consistent as illustrated in Appendix Figure 28.

Ultimately, GAtt is not an important thing to implement. It's a great exercise for learning new topics in the space.

Additional RL things

The authors include a lot of additional details about the RLHF processes. I covered the high-level last time. Here are some of my additional notes.

Rejection sampling details

Rejection sampling (similar to best-of-n sampling, with a loss update) is likely the simpler starting point for RLHF, as it is a much gentler way to extract information from a reward model.

PPO details

The PPO implementation picks up some rare things from the literature and continues to streamline the popular RLHF formula.


Thanks for reading. Let me know if I should do this type of analysis for more models. I probably will, but there will be only 1-3 models a year that are so obvious to cover like GPT4 and Llama 2.

Due to the popularity of this subject matter, I unlocked this extra post to be free for everyone (except for comments). In the future, if you want to support me by having the time to cover more models in the future and have access to all my content and comments/chat for questions, consider upgrading. These special Llama 2 posts cost me about 4 burritos in lost cooking time, for reference.

Interconnects is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.

Have a great weekend!