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
mattfrommars1 reply#
Great job OP. Yesterday after managing to run local instance of alpaca.cpp and reading more about what alpaca is and how it got fine tuned on LLaMA, I began to wonder what will it take to fine tune with own set of data.

With no real knowledge of LLM and only recently started to understand what LLM terms mean, such as 'model, inference, LLM model, intruction set, fine tuning' whatelse do you think is required to make a took like yours?
This is for education purposes and love to take a jab on creating something like this and and write an inference - such as the dev behind LLaMa inference in Rush.
>I am not familiar with HuggingFace libaries at all, why were they important in your implementaiton? > Gradio - I believe is the UI that allows to plugin different lLM models, I am familiar with text-generation-ui on GitHub that uses Gradio. >LORA I think further fines tines an model -- just like how LLaMa got fine tuned on instruciton set to produce Alpaca model.

lxe#
> With no real knowledge of LLM and only recently started to understand what LLM terms mean, such as 'model, inference, LLM model, intruction set, fine tuning' whatelse do you think is required to make a took like yours?

This was mee a few weeks ago. I got interested in all this when FlexGen (https://github.com/FMInference/FlexGen) was announced, which allowed to run inference using OPT model on consumer hardware. I'm an avid user of Stable Diffusion, and I wanted to see if I can have an SD equivalent of ChatGPT.
Not understanding the details of hyperparameters or terminology, I basically asked ChatGPT to explain to me what these things are:

   Explain to someone who is a software engineer with limited knowledge of ML terms or linear algebra, what is "feed forward" and "self-attention" in the context of ML and large language models. Provide examples when possible.
I did the same with all the other terms I didn't understand, like "ADAM optimizer", "gradient", etc. I relied on it very heavily and cross-referenced the answers.

Looking at other people's code and just tinkering with things on my own really helped.
Through the FlexGen discord I've discovered https://github.com/oobabooga/text-generation-webui where I spent days just playing around with models. This got me into the huggingface ecosystem -- their transformers library is an easy way to get started. I joined a few other discords, like LLaMA Unofficial, RWKV, Eleuther AI, Together, Hivemind and Petals.
I bookmarked a bunch of resources but it's very sporadic. Here are some:
- https://github.com/zphang/minimal-llama/#peft-fine-tuning-wi...
- https://github.com/togethercomputer/OpenChatKit
- https://www.cstroik.com/index.php/2023/02/18/finetuning-an-a...
- https://github.com/huggingface/peft
- https://github.com/kingoflolz/mesh-transformer-jax/blob/mast...
- https://github.com/oobabooga/text-generation-webui
- https://github.com/hizkifw/WebChatRWKVstic
- https://github.com/ggerganov/whisper.cpp
- https://github.com/qwopqwop200/GPTQ-for-LLaMa
- https://github.com/oobabooga/text-generation-webui/issues/14...
- https://github.com/bigscience-workshop/petals
- https://github.com/alpa-projects/alpa

Tepix1 reply#
Very interesting project, thanks. I see that DeepSpeed is on your TODO list. I wonder what the biggest LLaMA model is that can be fine-tuned on 2x RTX 3090 & 128GB RAM.
meghan_rain1 reply#
what if i want to finetune with long documents? say AI papers that are ~10 pages long on average? how would they be tokenized given that max_seq_length is 512?

Continue this thread — 2 replies

larodi2 replies#
hmm...I would think of PROLOG or other rule-based system as doing inference, but not of neural-network (which is essentially a mesh of matrix multiplications and functions).

this statement that NNs do inference is not entirely correct IMHO.

selfhoster112 replies#
I think you are unfairly downvoted for this, probably because I have just as strong opinion in the other direction: I see GPT (especially -4) as a kind of "killer Prolog-style inference engine".

How does Prolog work? You:
* pass it some predicates * specify rules about what the relationships mean and how various things are computed from the data in predicates * query a variable * answer pops out.
How can GPT do this task? You:
* pass it some predicates (structured machine-readable syntax or natural-language sentences) * specify rules (in natural-language sentences, though it helps to iterate on the wording a bit to make the rules more rigid, and more likely to provide the correct output ~every time) - you don't normally need to specify relationships explicitly because GPT can usually figure it out * include some additional "massaging" wording to get it reproducibly outputting the kind of result you want * query a variable (tell it what to find out/infer from the data) * answer pops out (in human-readable language or structured syntax).
In some ways, they are very much alike. And GPT is much more natural to program with than Prolog.

happycube1 reply#
They get there in completely different ways though. If there's no answer Prolog will fail out, and GPT* will usually make (stuff) up.
larodi#
exactly. PROLOG fails with the non-true inference, and this is why it's inference. otherwise we'd be calling all the high-school made up nonsense inference.

it is absolutely not fair, established or not, to call non-linear regression inference. may be prognosis, maybe prediction, maybe just approximation. but inference is something that actually does logic, based on facts... and probabilistic theory infers only probability, not facts.

larodi#
GPT is not being programmed, and so is not Prolog. Prolog is being set to follow rules, and infer logical consequences. Prolog is grammar, GPT3 is algebraic structure, which perhaps is also ... differential, so non-discrete.
6gvONxR4sf7o#
Inference is a very established term in the field for a variety of things, not just the kind of inference you’re referring to.
ALittleLight#
Really interesting, thanks for sharing, I'm excited to try this out.

Would it also be possible to just train the model from scratch on commodity hardware and how big of a difference in training time would that be?

Load more comments