Fine-tuning Alpaca 30b 4-bit on consumer hardware - background

Search for a command to run...

No comments yet. Be the first to comment.
https://github.com/withlang-dev/with/releases/latesthttps://discord.gg/f7u2MRuPSahttps://www.reddit.com/r/withlang/ I'm Eric Hartford, creator of the Dolphin and Samantha open source AI models. After
When the MI300X was launched in December 2023, there was a lot of optimism. We were desperate for an alternative to nVidia’s expensive and scarce H100s, especially one that provided 192gb of VRAM per GPU compared to the H100’s 80gb. And the MI300X wa...

How NIST Turned Open Science into a Security Scare

With the recent update to OpenAI's Terms of Use on October 23, 2024, there’s been a flurry of online discussions around what these terms mean for developers, businesses, and everyday users of AI tools like ChatGPT. Much of the conversation, especiall...

Gratitude to https://tensorwave.com/ for giving me access to their excellent servers! Few have tried this and fewer have succeeded. I've been marginally successful after a significant amount of effort, so it deserves a blog post. Know that you are in...

Quixi AI
20 posts
Applied AI Researcher I make AI models like Dolphin and Samantha https://ko-fi.com/erichartford BTC 3ENBV6zdwyqieAXzZP2i3EjeZtVwEmAuo4 ETH 0xcac74542A7fF51E2fb03229A5d9D0717cB6d70C9 https://quixi.ai
I want to write about fine-tuning Alpaca 30b 4-bit on consumer hardware, but before I can, I'll need to give a little background. My basic goal was to figure out "what's the most powerful AI I can customize and run on my shiny new 4090."
The answer right now is LLaMA 30b. Normally, fine-tuning this model is impossible on consumer hardware due to the low VRAM (clever nVidia) but there are clever new methods called LoRA and PEFT whereby the model is quantized and the VRAM requirements are dramatically decreased.
I'll also comment that, if you are currently building a consumer desktop for the purpose of training AI models, stop now and build a dual-3090 SLI instead of a 4090. This will maximize your VRAM and enable more scenarios (for example fine tuning LLaMA 65b), and the performance of dual-3090 is close enough to the performance of a 4090.
I link some academic papers and I recommend that you take the time to, if not read them, at least ask GPT4 to explain them to you like you are 12, an undergrad, or a grad student.
LLaMA is a large language model created by Meta. It is not licensed for commercial use, so you can only use it for personal or academic purposes. (there is a petition requesting Meta to re-license the model here) What makes LLaMA special is that it's designed to be efficient and high quality. This makes it an excellent base for working on consumer hardware - if you start with an efficient model then the other techniques will be even more effective.
Next, I'd like to talk about Alpaca. Alpaca is a set of weights that can be applied to LLaMA to tune it to be good at following instructions. Instruct tuning is how you get from a base language model to a chatbot you can interact with such as ChatGPT. In essence, Alpaca is an effort to train LLaMA to be like ChatGPT.
Alpaca is not just the results (the weights) it also describes the methodology used to create them. In particular, Alpaca used a method called Self-Instruct to generate a dataset that was then used to fine-tune the LLaMA model. I will talk more about instruct datasets in a separate post, because there are a number to choose from.
Finally I want to talk about LoRA and quantization, which comes in 8-bit and 4-bit flavors. You can think of this as similar to jpeg, but for large language models. You give up a bit of quality in exchange for a significant reduction of compute and memory requirements for fine-tuning and inference.
In my next post the rubber hits the road, and I will discuss the nitty gritty of making it happen.