Skip to content

Port of alpaca.cpp in Golang with embedded C/C++

License

Notifications You must be signed in to change notification settings

henomis/alpaca-go

 
 

Repository files navigation

Alpaca-go

Run a fast ChatGPT-like model locally on your device. The screencast below (from alpaca.cpp) is not sped up and running on an M2 Macbook Air with 4GB of weights.

asciicast

This combines the LLaMA foundation model with an open reproduction of Stanford Alpaca a fine-tuning of the base model to obey instructions (akin to the RLHF used to train ChatGPT) and a set of modifications to llama.cpp to add a chat interface.

Get Started (7B)

Building from Source (MacOS/Linux)

git clone https://github.com/henomis/alpaca-go
cd alpaca-go

make alpaca-go
./alpaca-go

Building from Source (Windows)

  • Download and install CMake: https://cmake.org/download/
  • Download and install git. If you've never used git before, consider a GUI client like https://desktop.github.com/
  • Clone this repo using your git client of choice (for GitHub Desktop, go to File -> Clone repository -> From URL and paste https://github.com/henomis/alpaca-go in as the URL)
  • Open a Windows Terminal inside the folder you cloned the repository to
  • Run the following commands one by one:
cmake .
cmake --build . --config Release
  • Download the weights via any of the links in "Get started" above, and save the file as ggml-alpaca-7b-q4.bin in the main Alpaca directory.
  • In the terminal window, run this command:
.\Release\alpaca-go.exe
  • (You can add other launch options like --n 8 as preferred onto the same line)
  • You can now type to the AI in the terminal and it will reply. Enjoy!

Run

Download ggml-alpaca-7b-q4.bin and place it in the same folder as the alpaca-go executable in the zip file. There are several options:

Once you've downloaded the model weights and placed them into the same directory as the alpaca-go or alpaca-go.exe executable, run:

./alpaca-go

The weights are based on the published fine-tunes from alpaca-lora, converted back into a pytorch checkpoint with a modified script and then quantized with llama.cpp the regular way.

Credit

This combines Facebook's LLaMA, Stanford Alpaca, alpaca-lora and corresponding weights by Eric Wang (which uses Jason Phang's implementation of LLaMA on top of Hugging Face Transformers), llama.cpp by Georgi Gerganov, and alpaca.cpp by antimatter15. The chat implementation is based on Matvey Soloviev's Interactive Mode for llama.cpp. Inspired by Simon Willison's getting started guide for LLaMA. Andy Matuschak's thread on adapting this to 13B, using fine tuning weights by Sam Witteveen.

Disclaimer

Note that the model weights are only to be used for research purposes, as they are derivative of LLaMA, and uses the published instruction data from the Stanford Alpaca project which is generated by OpenAI, which itself disallows the usage of its outputs to train competing models.

About

Port of alpaca.cpp in Golang with embedded C/C++

Topics

Resources

License

Stars

Watchers

Forks

Languages

  • C 77.8%
  • C++ 18.1%
  • Makefile 1.3%
  • Python 1.2%
  • CMake 1.0%
  • Go 0.5%
  • Shell 0.1%