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

Earlier comments
Taek5 replies#
Looks like you need about 120 GB to fine-tune the 65B model with this code at a sequence length of 512. How does the memory usage scale as the sequence length grows?
lxe1 reply#
> How does the memory usage scale as the sequence length grows?

That's a good question. I was under the assumption it's linearly proportional, but I can test it out I guess.

Taek#
I suspect its linear with a small constant factor.
arpowers1 reply#
Really takes that much vram??
ioedward#
Normally people split up the model across multiple GPUs, i.e. model/tensor parallelism.
albertzeyer#
The attention implementation is in a way that the memory scales quadratically with sequence lengths. Overall, this is still a small factor compared to just the model weights, but at some seq lengths, this would dominate.

By using flash attention, you can get memory requirement down to scale linearly with sequence lengths.

joshxyz#
man i hope there are online calculators that lets people visualize the costs of training these things.
Hedepig4 replies#
Slightly tangential, is there some kind of crowdsourced effort to build training data for fine tuning? Alpaca used the training data built from gpt-3.5, so there are terms of use restrictions
Phemist1 reply#
IANAL, but wouldnt feeding the training data into alpaca and then having it output similar text not construe new data that is not copyrighted by stanford/openai/facebook? (It would be a significantly creative and novel worm to get the prompts working correctly..) Obviously you are also not bound by the openai terms of use, and Im not sure if stanford's terms of use are as broad and well-defined...
Hedepig2 replies#
The terms of ChatGPT/GPT-3.5 explicitly state that one cannot use their data to construct competitive models
NavinF4 replies#
Not enforceable. All they can do is ban your ChatGPT account.

Continue this thread — 4 replies

Phemist#
Yes, but 1) you would not be using their data, and 2) you are not bound by their ToS if you never signed up to their service right..
Hedepig#
This looks good. Is the training data in the repo itself?
lxe#
OpenChatKit is great tbh
holoduke2 replies#
I am really an AI noob. But lets say i tried the 7b model for translations purposes with below acceptable results. Can i train the model with 1 million of translated sentences to improve the quality of the translation output?
Method-X1 reply#
Can you give an example on how you prompted the model? Your issue is probably related to that, but I would need an example to be sure. I've found the 7b Alpaca model [1] to work surprisingly well! Here's how you're supposed to prompt it:

Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction: {instruction}
### Response:
or
Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
### Instruction: {instruction}
### Input: {input}
### Response:
[1] https://github.com/cocktailpeanut/dalai

lxe#
Barebones llama is just a text completion model. You can give it a prompt like

    A conversation between a human and assistant

    Human: How old is the sun?
    Assistant:
And it will complete it.

Alpaca/Dalai are finetuned on a dataset that's formatted as this:

    ### Instruction: {instruction}

    ### Input: {input}

    ### Response:
So even without pre-prompting in this format it's going to be heavily biased towards performing completions in this format anyways.

It's always helpful to finetune on a preformatted prompt depending on what your task is.

benob2 replies#
Yes you can finetune the model with reference output for any kind of language task. For translation, you are better off starting from a model specifically trained for that purpose such as facebook/nllb-200-distilled-1.3B. It will be faster and more accurate.
wsgeorge2 replies#
> For translation, you are better off starting from a model specifically trained for that purpose

Yes, but wasn't the whole point of the recent LLM research to show that you didn't need to fine-tine for a specific task?

inportb#
You could just use a much bigger model to perform arbitrary tasks without fine-tuning.
Closi#
Sure, but you will get better results at a smaller number of parameters from a specifically trained model right now if you are trying to train/host it yourself.

Remember that GPT3 is 175 billion parameters so many times bigger than both the above models (and gpt4 is rumoured to be bigger still), which also allows it to be more generalisable.
If GPT3 was trained at 7 billion parameters it might also lose it's language translation capabilities.

holoduke#
Do you know any guide on how to train these models? Any thoughts on the hardware requirements?
antman2 replies#
What do the training screenshot examples try to accomplish? In what way would the model be different after the example fine-tuning?
rafaguin#
Same question here!

Load more comments