150 points · by amaiya · 3y ago · 33 comments
This resulted in Python package I call OnPrem.LLM.
In the documentation, there are examples for how to use it for information extraction, text generation, retrieval-augmented generation (i.e., chatting with documents on your computer), and text-to-code generation: https://amaiya.github.io/onprem/
Enjoy!
And... If you'd like a more hands on approach, here is a manual approach to get llama running locally
- https://github.com/ggerganov/llama.cpp
- follow instructions to build it (note the `METAL` flag)
- https://huggingface.co/models?sort=trending&search=gguf
- pick any `gguf` model that tickles your fancy, download instructions will be there
and a little script like this will get it running swimmingly ./main -m ./models/<file>.gguf --color --keep -1 -n -1 -ngl 32 --repeat_penalty 1.1 -i -ins
Enjoy the next hours of digging through flags and the wonderful pit of time ahead of you.NOTE: I'm new at this stuff, feedback welcome.
Here is the starting output of running Llama 65B in a gist
https://gist.github.com/zitterbewegung/4787e42617aa0be6019c3...
GGUF is a new format introduced by the llama.cpp team on August 21st 2023. It is a replacement for GGML, which is no longer supported by llama.cpp. The key benefit of GGUF is that it is a extensible, future-proof format which stores more information about the model as metadata.
https://github.com/ggerganov/llama.cpp/releases/tag/master-6...
By chance, have you checked out Ollama (https://github.com/jmorganca/ollama) as a way to run the models like Llama 2 under the hood?
One of the goals of the project is to make it easy to download and run GPU-accelerated models, ideally with everything pre-compiled so it's easy to get up and running. It's API that can be used by tools like this – would love to know if it would be helpful (or not!)
There's a LangChain model integration for it and a PrivateGPT example as well that might be a good pointer on using the LangChain integration: https://github.com/jmorganca/ollama/tree/main/examples/priva.... There's also a LangChain PR open to add support for generating embeddings, although there's a bit more work to do to support the major embedding models.
Best of luck with the project!
There's also plenty of other local LLM type tools like GPT4All, LMStudio, Simon Wilsons LLM, privateGPT, and about a million other setups.
Lol but for real today for the first time when browsing new laptops I was looking for high vram because of llm.
Is there a library that offers a layer on top of local models that simulates the OpenAI API?
Seems like all of these open source wrappers, just as the closed sourced ones, are a race to the bottom.
The focus for Ollama is to make downloading and serving a model easy – there's an included `ollama` CLI but it's all powered by a REST API. Hopefully, it's a way to support really cool applications of LLMs like OP's onprem tool.
OP's tool is more focused on ingesting and analyzing data. There seems to be quite a bit of interesting opportunity as an application of LLMs – e.g. analyzing not only local docs but data in a remote data store.
You can see the actual size from hugging face. For example, https://huggingface.co/WizardLM/WizardLM-7B-V1.0/tree/main
Size with quantization, https://github.com/ggerganov/llama.cpp#quantization
7B = 7 Billions parameters.
If 1 parameter takes 1 byte then a 7B model would be about 7GB in size.
Usually 1 parameter takes 4 bytes tho (a 32-bit float), so it would be aboult 28GB.
You can use 16-bit, 8-bit or even 4-bit float.
What sold me on ChatGPT was its efficacy combined with its ease of use. As the owner of a consultancy, I find time to do technical exploration to be more and more scarce - stuff like this that makes it super easy for me to run an LLM is most welcome.
from onprem import LLM
url = 'https://huggingface.co/TheBloke/CodeUp-Llama.....'
llm = LLM(url, n_gpu_layers=43) # see below for GPU information
Anyway looks like a great little project, nice work!Training your own from nothing is a monumental task, I don't think many of us can realistically do it from scratch.