12 ms·
Fine-Tuning Llama-2: A Comprehensive Case Study for Tailoring Custom Models
- bugglebeetle 3y agoGlad to see the NER-like task performed the best, as I was just about to test something like this for comparison with a fine-tuned BERT model. Any idea about the training costs for this task?
- binarymax 3y agoGreat question. I wish they said how long the 10 epochs took, so we could figure out the cost (or better, just posted the time and cost together): "For the 7B and 13B models, we used 16xA10Gs, and for the 70B model, we used 32xA10Gs (across 4x g5.48xlarge instances). When using Ray, there's no need to secure A100s to perform full-parameter fine-tuning on these models! The process is simply repeated for each task. Figures below show an example run based on a context length of 512, with a total of 3.7M effective tokens per epoch on GSM8k dataset. We ran the training for a maximum of 10 epochs and selected the best checkpoint according to the minimum perplexity score on the validation set."
- kouroshh 3y agoTraining times for GSM8k are mentioned here: https://github.com/ray-project/ray/tree/master/doc/source/templates/04_finetuning_llms_with_deepspeed#launching-fine-tuning https://github.com/ray-project/ray/tree/master/doc/source/te...
- kouroshh 3y agoHey, I am one of the co-authors of the post. So the training data for ViGGO has about 5.1k rows which we trained with a block size of 512 (you can lower the block size if you want but we didn't do so because it was just easier to not change code :)). On 16xA10Gs for 7B it took ~15 min per epoch and on 13B it took ~25 min per epoch. So the on-demand cost per epoch is ~$7.2 for 7B and ~$12 for 13B. This is based on the time only spent on the training part and does not take into account the cluster startup time and shutdown time.
- bugglebeetle 3y agoGreat! Thank you!
- jawerty 3y agoJust to add to this, I run through a lot of these topics around fine-tuning Llama 2 on your own dataset (for me it's my own code :P) in a coding live stream a couple weeks ago. All on Colab single GPU Fine-tuning Llama stream: https://www.youtube.com/watch?v=TYgtG2Th6fI&t=2282s https://www.youtube.com/watch?v=TYgtG2Th6fI&t=2282s I have a couple more one where I do a QLoRa fine tuning session and explain the concepts as a personally self taught engineer (software engineer of 8 years moving into ML recently) QloRa fine-tuning stream: https://www.youtube.com/watch?v=LitybCiLhSc&t=4584s https://www.youtube.com/watch?v=LitybCiLhSc&t=4584s Overall I'm trying to breakdown how I'm approaching a lot of my personal projects and my current AI driven startup. Want to make this information as accessible as possible. Also have a series where I'm fine-tuning a model to be the smallest webdev llm as possible which seems like people are liking. Only been streaming for about a month and plenty more to come. Ask me any question about the stream and fine-tuning llama!
- SubiculumCode 3y agoone gpu? feasible with one 3060?
- nacs 3y agoAbsolutely. For QLORA / 4bit / GPTQ finetuning, you can train a 7B easily on an RTX 3060 (12GB VRAM). If you have a 24GB VRAM GPU like a RTX 3090/4090, you can Qlora finetune a 13B or even a 30B model (in a few hours).
- SOLAR_FIELDS 3y ago
- spdustin 3y agoSeeing NER examples pop up more frequently now, and wondering why folks don’t use spacy for those sorts of tasks.
- techwizrd 3y agoI use a fine-tuned BERT-like model for NER, but I'd be interested to compare how it performs.
- binarymax 3y agoMy line of thinking is using the more expensive model to label data, then use a teacher/student methodology to train the smaller model (SpaCy or BERT) for cost & speed.
- bugglebeetle 3y agoSpacy doesn’t work well for multilingual training data and I’ve found it barfs in more and somehow even odder ways than stuff in transformers.
- deleted 3y ago[deleted]
- richardliaw 3y agoI'm really glad to see a post like this come out. I've seen so many discussions online about customizing models -- this post really does cut through the noise. Really like the evaluation methodology, and seems well-written as well.
- yousif_123123 3y agoIt's weird that Lora and training with quantization is not being taken more seriously. It's way cheaper, takes less time, and a lot of evidence shows it's pretty good. I don't think it should be something brushed on the side to be tried out later..
- perplexitywiz 3y agohttps://twitter.com/Tim_Dettmers/status/1689375417189412864 https://twitter.com/Tim_Dettmers/status/1689375417189412864
- DebtDeflation 3y agoI'm not sure to whom he is responding, since no one is claiming LoRA performs as well as traditional fine tuning. If you click through to the original Tweet he shared, it says "when you have a lot of data and limited compute go for LoRA, while with limited data and ample compute go for full finetuning" which I think is absolutely correct and few would disagree. As these models get bigger and bigger though, fewer and fewer people are going to have the "ample compute" required for full fine tuning.
- scv119 3y agoThe tweet is referring to a paper that fine tunes Chinese dataset on english base model. I'm not surprised with LoRA's poor result in this setup.
- yousif_123123 3y agoI'm not sure less data should require full fine-tuning. If I had 5 pages of text, I don't see why I need to train billions of parameters that are already trained pretty well on general internet knowledge, and already know how to chat.. From a practical perspective, unless cost is really immaterial, I think most will end up starting with Lora, especially for 13b or 70b models.. you could do 10 fine-tuning runs for the cost of a few full fine-tunings. But it's still all witchcraft to me to some degree, and I'd probably try full and Lora.
- behnamoh 3y ago> Additionally, while this wasn’t an issue for GPT, the Llama chat models would often output hundreds of miscellaneous tokens that were unnecessary for the task, further slowing down their inference time (e.g. “Sure! Happy to help…”). That's the problem I've been facing with Llama 2 as well. It's almost impossible to have it just output the desired text. It will always add something before and after its response. Does anyone know if there's any prompt technique to fix this problem?
- redox99 3y agoUse a better model. airoboros supports the PLAINFORMAT token "to avoid backticks, explanations, etc. and just print the code". https://huggingface.co/TheBloke/airoboros-l2-70B-GPT4-2.0-GGML https://huggingface.co/TheBloke/airoboros-l2-70B-GPT4-2.0-GG...
- behnamoh 3y agoThanks, I'll give this a try. I wonder if LLMs will have less reasoning power if they simply return the output. AFAIK, they think by writing their thoughts. So forcing an LLM to just return the goddamn code might limit its reasoning skills, leading to poor code. Is that true?
- redox99 3y agoPotentially it could have an impact if it omits a high level description before writing the code, although obviously things like "Sure! Happy to help" do not help. In practice I haven't seen it make too much of a difference with GPT. The model can still use comments to express itself. For non coding tasks, adding "Think step by step" makes a huge difference (versus YOLOing a single word reply).
- behnamoh 3y ago> although obviously things like "Sure! Happy to help" do not help. Yes you're right. I'm mostly concerned with the text that actually "computes" something before the actual code begins. Niceties like "sure! happy to help" don't compute anything. CoT indeed works. Now I've seem people take it to the extreme by having tree of thoughts, forest of thoughts, etc. but I'm not sure how much "reasoning" we can extract from a model that is obviously limited in terms of knowledge and intelligence. CoT already gets us to 80% of the way. With some tweaks it can get even better. I've also seen simulation methods where GPT "agents" talk to each other to form better ideas about a subject. But then again, it's like trying to achieve perpetual motion in physics. One can't get more intelligence from a system than one puts in the system.
- ilaksh 3y agoOne challenge is that to get large enough custom datasets you either need a small army or a very strong existing model. Which means that you probably have to use OpenAI. And using OpenAI to generate training material for another model violates their terms. Has anyone taken them to court about this? Do we all just decide it's not fair and ignore it?
- sillysaurusx 3y agoWhy not ignore ToS? The worst that can happen is that you lose access.
- charcircuit 3y agoThe worst that can happen is you get brought into an expensive lawsuit.
- bugglebeetle 3y agoThis is not true for all tasks. For many NLP tasks, you just need to reformat existing data to match the LLM format.
- rising-sky 3y ago> ~14 min. for 7B for 1 epoch on 3.5M tokens. ~26 min for 13B for 1 epoch. > At least 1xg5.16xlarge for head-node and 15xg5.4xlarge for worker nodes for both 7B and 13B For the uninitiated, anyone have an idea how much this would cost on AWS?
- grandpayeti 3y agog5.16xlarge - $4.0960/hour g5.4xlarge - $1.6240/hour You're looking at about $30/hour to run this in us-east-1. https://instances.vantage.sh/?selected=g5.16xlarge,g5.4xlarge https://instances.vantage.sh/?selected=g5.16xlarge,g5.4xlarg...
- rising-sky 3y agothanks
- 0xDEF 3y agoHas anyone had luck with fine-tuning Llama-v2-7b using the paid (€11.00) Colab Pro?
- praveenhm 3y agoIs this possible to fine tune llama-2 locally on M1 Ultra 64GB, I would like to know or any pointer would be good. Most of them are on Cloud or using Nvidia Cuda on linux.
- aldarisbm 3y agoI don't think so. I have M1 Max 64GB and it works okay for some inference. I'm buying a few credits from RunPod. It will be a few 10's of dollars to get it trained.
- zhz_ray 3y agoDisclaimer: I work for Anyscale This blog seems to got good attention :) So we definitely plan to add it to Ray Summit https://raysummit.anyscale.com/agenda https://raysummit.anyscale.com/agenda Please comment on this thread if you have ideas of what kind of content you want to see more at Ray Summit