GithubHelp home page GithubHelp logo

michel34343 / alpaca.cpp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rupeshs/alpaca.cpp

0.0 0.0 0.0 1.48 MB

Locally run an Instruction-Tuned Chat-Style LLM (Android/Linux/Windows/Mac)

License: MIT License

Shell 0.07% C++ 16.92% Python 1.23% C 79.60% Makefile 1.16% CMake 1.01%

alpaca.cpp's Introduction

Alpaca.cpp

Run a fast ChatGPT-like model locally on your device. The screencast below is not sped up and running on an M2 Macbook Air with 4GB of weights. Build instructions for MaC,Windows,Linux,Android are available.

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

git clone https://github.com/rupeshs/alpaca.cpp
cd alpaca.cpp

make chat
./chat

Download ggml-alpaca-7b-q4.bin and place it in the same folder as the chat executable in the zip file.

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.

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/rupeshs/alpaca.cpp in as the URL)
  • Install Visual Studio 2019 or later with C++ support or install Visual C++ build tools 2019.
  • Open a Windows Terminal inside the folder you cloned the repository to
  • Run the following commands one by one:
mkdir build
cmake -B build .
cd build
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 the commands:

  • (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!

Linux

Install the build-essentials and cmake.

To build run the following commands one by one:

mkdir build
cmake -B build .
cd build
cmake --build . --config Release

Android

You can easily run alpaca.cpp on Android device with termux. First, obtain the Android NDK and then build with CMake:

$ mkdir build-android
$ cd build-android
$ export NDK=<your_ndk_directory>
$ cmake -DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-23 -DCMAKE_C_FLAGS=-march=armv8.4a+dotprod ..
$ make

Install termux on your device and run termux-setup-storage to get access to your SD card. Finally, copy the llama binary and the model files to your device storage. Here is a screenshot of an interactive session running on Pixel 7 Pro phone:

Alpaca running on Pixel 7 pro

Credit

This combines alpaca.cpp by Kevin Kwok 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), and llama.cpp by Georgi Gerganov. 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.

alpaca.cpp's People

Contributors

ggerganov avatar antimatter15 avatar rupeshs avatar anzz1 avatar blackhole89 avatar prusnak avatar etra0 avatar razelighter777 avatar ronsor avatar beiller avatar hoangmit avatar mcmonkey4eva avatar bengarney avatar jcelerier avatar jooray avatar marckohlbrugge avatar bigattichouse avatar musabgultekin avatar nebulatgs avatar wizzard0 avatar rgerganov avatar bitrake avatar simonw avatar 0-wiz-0 avatar kharvd avatar jxy avatar deepdiffuser avatar moritzbrantner avatar thement avatar maekawatoshiki avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.