Lurker News
I've been playing around with https://github.com/zphang/minimal-llama/ and https://github.com/tloen/alpaca-lora/blob/main/finetune.py, and wanted to create a simple UI where you can just paste text, tweak the parameters, and finetune the model quickly using a modern GPU.

To prepare the data, simply separate your text with two blank lines.
There's an inference tab, so you can test how the tuned model behaves.
This is my first foray into the world of LLM finetuning, Python, Torch, Transformers, LoRA, PEFT, and Gradio.
Enjoy!

Comments (98) 20 threads

syntaxing1 reply#
Is there any library that allows you to train with a Mac M1/M2? I know it will be slower but I rather spend money on a Mac Studio rather multiple graphic cards to get around the VRAM limitation.
speedgoose3 replies#
For training you could rent a GPU server for a short period.
te_chris1 reply#
Or use something like google vertex to run a docker job on gpus
tysam_and7 replies#
Personally I would recommend Colab or another notebook environment like a Lambda machine.

Much cheaper, and simpler than a bare metal machine, data ingress/egress is hard though for Colab you can just mount a Gdrive.
Unfortunately the API for training on M* chips (via MPS) is apparently still extremely buggy, so we have a ways to go before that is fully mainstream. And yes, I know that PyTorch just mainlined their mps support last week too...but from what I've heard the low level interface itself still needs some work. D:

Continue this thread — 7 replies

tempaccount4201 reply#
Renting is always less economical than owning. You can always sell your Apple Studio and still pay less.
qeternity#
Perhaps on a per unit basis. But there's a reason I buy steaks and not cows.
flemhans#
Data will transmit to a third party, which may be a problem in some usecases
spunker5403 replies#
Is there a consensus yet on when you should fine-tune vs when you should use prompt engineering?

It seems not that hard to include in your prompt “here is some examples, please write like this and follow the style set here”. While that may make every completion request more expensive (more tokens), it also seems like fine tuning these models can also be quite expensive.
I’m curious if there are other trade offs besides cost— maybe quality achieved is better with fine tuning? Very interested to see how it all plays out. On the one hand a massive model like gpt4 can probably be prompted to match any style quite well, albeit costly, vs fine tuning a cheap model may get exactly what you want.

wazer51 reply#
Even GPT-4 can only handle a few pages of text as prompt for examples. In most cases you'd want to fine tune.
spunker5401 reply#
I guess I’m just curious what the killer use-cases are for fine tuning. For example it seems like overkill to fine tune a Shakespeare model, because you can just say “write like Shakespeare” and it already knows what you want.
ttoinou2 replies#
I guess you'd want to fine tune for content that wasn't already parsed before

Continue this thread — 2 replies

stu2b50#
Empirically, while the ability for LLMs to zero shot learn is impressive, it’s significantly worse than fine tuning. An obvious example is LLaMA itself, from which it’s quite hard to get useful instructional behavior out, and requires a significant amount of prompt engineering, and is still brittle at that.

Fine tuning it in just 52k examples (alpaca) makes a night and day difference in usability for instruction following.

lxe#
If there's context limitations (your document cant' fit in the context, or your session quickly loses the context), fine-tuning is a great option.
callesgg5 replies#
Now, use this library to "bootstrapp the smarts of LLaMA from its own smartness" like this:

1. Ask it things. Let it answer.
2. Ask it to find errors in the answer it outputted and for it to correct the answer.
3. Use the original prompt and the corrected output as training data.
This should, with each iteration make the model less and less likely to output statements that are self contradictions or obviously wrong, until the model can no longer spot its own faults.

jointpdf#
Or it will twist itself into a giant hairball of contorted logic, like GPT3.5 does when I (a human) encourage it to explain its errors.
Drakim3 replies#
I recall reading that when training AlphaZero they would start pitching it against itself doing millions of games in a few days, which worked great because there is an external metric (who wins the chess game) that would objectively be a good measure to train towards.

But if you let an AI's approval be the metric, things turn a lot more fussy and subjective. The goal is not actually "to write a good answer without error" but actually "to write an answer that is approved by the AI". Those are very different goals, and as you keep using it you'll get a bigger and bigger divergence, until eventually the AI is just answering complete garbage nonsense that precisely hits certain sweet spots in the grading AI.
This divergence of the target vs the actual human goal is a pretty interesting problem in AI safety research. I love the example where an AI trained to stay alive as long as possible in Tetris realized that pausing the game was the best strategy.

Dwedit1 reply#
That wasn't an AI, that was a "Make the numbers go up" (lexagraphic ordering) system with TAS rewinding for short term bruteforcing.
MattPalmer1086#
Interesting, but the core point remains true. The algorithm optimises for something which may not entirely coincide with the creators intentions.
newswasboring1 reply#
I honestly think I might do this experiment, just to see what comes out. I know it will be utter garbage, but it will probably be interesting utter garbage.
callesgg#
Please do :)

The correction prompt is very important, it will definitely determine the outcome of the process, a bad correction prompt will obviously lead to a garbage result.
Training in steps with different prompts might be of value. First step might be to fix contradictions, then factual errors if that is an issue. This is an idea that I got when viewing the he output of LLaMA, it often contains contradictions (eg. an example I have seen is "Peter is a boy and he is part of the Gama sorority"). Asking it to fix those types of issues should be a first good step.
But I suspect that this type of training would need to be mixed with original training data. Otherwise the restructuring in the model caused by the new training would most likely garble the rest of the model.

aqme28#
You’re describing a GAN basically.

But yeah, you’re going to need an objective metric or human input otherwise the system is going to diverge in strange ways.

tysam_and#
This is a cool idea in theory and I think could be useful in certain kinds of circumstances, but this particular instantiation would likely go into a bad bias spiral.

This is somewhat similar to how GANs try to learn the density of the underlying data, but here you do not have the underlying data as a reference, if that makes sense. It's sort of like filling a mattress with helium instead of air. Sure, the mattress will be lighter, but that does not mean you will float on it, if that makes any sense at all.
Hope that helps as a cogent answer to this question.

8jy89hui#
You should try using a larger model like llama-35b or even GPT-3 for the feedback. That way you might be able to condense knowledge from these really big models into a smaller model
jkeisling#
For those skeptical of the above comment, this technique absolutely works and powers production-grade models like Anthropic’s Claude. There’s plenty of literature on this, but here are a couple papers that might be helpful for people doing their own training: - Constitutional AI: by Anthropic, an “RLAIF” technique that creates the preference model for “finding errors” based on a set of around 70 “principles” the AI uses to check its own output, not human feedback like in ChatGPT. This technique taught the Claude bot to avoid harmful output with few to no manual harmfulness labels! https://arxiv.org/abs/2212.08073. Not sure if there’s a HuggingFace implementation with LoRA / PEFT yet like there is for regular RLHF, so somebody may need to implement this for Llama still

- Self-Instruct: Creates artificial training data on instruction tuning from an untuned base model, from a tiny seed of prompts, and filters out the bad ones before fine-tuning. Manages to approach Instruct-GPT performance with only ~100 human labels. https://arxiv.org/abs/2212.10560

reissbaker1 reply#
This is awesome! I noticed it said a prereq is >16GB VRAM — is that >= 16GB, or is it really explicitly greater than 16? Would be sweet to be able to finetune locally on, say, a 3080.
capableweb1 reply#
I gave this a try and it seems to max out using about 12GB of VRAM on a RTX 3090 Ti.
capableweb#
Tried the 30b-hf set too, but was too much (24GB available). 13b-hf works fine, maxing out at 17GB.

Load more comments