Skip to content

Commit

Permalink
AI : New Apps! (akash-network#373)
Browse files Browse the repository at this point in the history
* Add AI section

Add ai-chat-app to run self-hosted chatgpt.

* Add stable diffusion and ai-chat-app update

* Update README and deploy.yaml on ai-chat-app and sd

* Add ChatGPT screenshots

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Initial commit serge

* Add daila

* Add alpaca and gpt4all

* Fix image name

* Fix alpaca.cpp

* README updates

* Fix StableDiffusion
  • Loading branch information
88plug authored Apr 8, 2023
1 parent cc25120 commit ffdbbef
Show file tree
Hide file tree
Showing 17 changed files with 1,440 additions and 61 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ Also, follow [@akashnet\_](https://twitter.com/akashnet_) to stay in the loop wi

### AI

- [Alpaca.cpp](alpaca-cpp)
- [ChatGPT Self-Hosted Chat](ai-chat-app)
- [Daila](daila)
- [GPT4ALL](gpt4all)
- [Serge](serge)
- [Stable Diffusion](stable-diffusion-ui)

### Blogging
Expand Down
26 changes: 26 additions & 0 deletions alpaca-cpp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Use a Linux base image
FROM ubuntu:latest

# Set the working directory to /app
WORKDIR /app

# Install dependencies
RUN apt-get update && \
apt-get install -y g++ git cmake wget aria2 && \
apt-get clean

# Clone the alpaca.cpp repository
RUN git clone https://github.com/antimatter15/alpaca.cpp && \
cd alpaca.cpp && \
make chat && \
cp chat ../ && \
cd .. && \
rm -rf alpaca.cpp

# Download the weights
RUN aria2c --out=ggml-alpaca-7b-q4.bin --summary-interval 15 --check-certificate=false --max-tries=99 --retry-wait=5 --always-resume=true --max-file-not-found=99 --conditional-get=true -s 16 -x 16 -k 1M -j 1 https://huggingface.co/Sosaka/Alpaca-native-4bit-ggml/resolve/main/ggml-alpaca-7b-q4.bin
RUN aria2c --out=gotty.tar.gz https://github.com/yudai/gotty/releases/download/v2.0.0-alpha.3/gotty_2.0.0-alpha.3_linux_amd64.tar.gz
RUN tar -zxvf gotty.tar.gz ; rm -rf gotty.tar.gz

# Set the entrypoint command
ENTRYPOINT ["./gotty", "-w", "./chat","-t","15"]
64 changes: 64 additions & 0 deletions alpaca-cpp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# 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.

[![asciicast](screencast.gif)](https://asciinema.org/a/dfJ8QXZ4u978Ona59LPEldtKK)


This combines the [LLaMA foundation model](https://github.com/facebookresearch/llama) with an [open reproduction](https://github.com/tloen/alpaca-lora) of [Stanford Alpaca](https://github.com/tatsu-lab/stanford_alpaca) a fine-tuning of the base model to obey instructions (akin to the [RLHF](https://huggingface.co/blog/rlhf) used to train ChatGPT) and a set of modifications to [llama.cpp](https://github.com/ggerganov/llama.cpp) to add a chat interface.

## Get Started (7B)

Download the zip file corresponding to your operating system from the [latest release](https://github.com/antimatter15/alpaca.cpp/releases/latest). On Windows, download `alpaca-win.zip`, on Mac (both Intel or ARM) download `alpaca-mac.zip`, and on Linux (x64) download `alpaca-linux.zip`.

Download `ggml-alpaca-7b-q4.bin` and place it in the same folder as the `chat` 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 `chat` or `chat.exe` executable, run:

```
./chat
```

The weights are based on the published fine-tunes from `alpaca-lora`, converted back into a pytorch checkpoint with a [modified script](https://github.com/tloen/alpaca-lora/pull/19) and then quantized with llama.cpp the regular way.

## Building from Source (MacOS/Linux)


```sh
git clone https://github.com/antimatter15/alpaca.cpp
cd alpaca.cpp

make chat
./chat
```


## 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/antimatter15/alpaca.cpp` in as the URL)
- Open a Windows Terminal inside the folder you cloned the repository to
- Run the following commands one by one:

```ps1
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:
```ps1
.\Release\chat.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!

## Credit

This combines [Facebook's LLaMA](https://github.com/facebookresearch/llama), [Stanford Alpaca](https://crfm.stanford.edu/2023/03/13/alpaca.html), [alpaca-lora](https://github.com/tloen/alpaca-lora) and [corresponding weights](https://huggingface.co/tloen/alpaca-lora-7b/tree/main) by Eric Wang (which uses [Jason Phang's implementation of LLaMA](https://github.com/huggingface/transformers/pull/21955) on top of Hugging Face Transformers), and [llama.cpp](https://github.com/ggerganov/llama.cpp) by Georgi Gerganov. The chat implementation is based on Matvey Soloviev's [Interactive Mode](https://github.com/ggerganov/llama.cpp/pull/61) for llama.cpp. Inspired by [Simon Willison's](https://til.simonwillison.net/llms/llama-7b-m2) getting started guide for LLaMA. [Andy Matuschak](https://twitter.com/andy_matuschak/status/1636769182066053120)'s thread on adapting this to 13B, using fine tuning weights by [Sam Witteveen](https://huggingface.co/samwit/alpaca13B-lora).


## 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.
45 changes: 45 additions & 0 deletions alpaca-cpp/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
version: "2.0"

services:
alpaca-cpp:
image: cryptoandcoffee/akash-alpaca-cpp:1
expose:
- port: 8080
as: 80
to:
- global: true
command:
- "./gotty"
- "-w"
- "./chat"
- "-t"
- "15"
profiles:
compute:
alpaca-cpp:
resources:
cpu:
units: 16.0
memory:
size: 16Gi #Need to increase for larger models
storage:
size: 8Gi #Need to increase for larger models
placement:
akash:
attributes:
host: akash
signedBy:
anyOf:
- "akash1365yvmc4s7awdyj3n2sav7xfx76adc6dnmlx63"
- "akash18qa2a2ltfyvkyj0ggj3hkvuj6twzyumuaru9s4"
pricing:
alpaca-cpp:
denom: uakt
amount: 10000

deployment:
alpaca-cpp:
akash:
profile: alpaca-cpp
count: 1
36 changes: 36 additions & 0 deletions daila/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM python:3.10-slim-buster

# The dalai server runs on port 3000
EXPOSE 3000

# Install dependencies
RUN apt-get update \
&& apt-get install -y \
build-essential \
curl \
g++ \
git \
make \
python3-venv \
software-properties-common

# Add NodeSource PPA to get Node.js 18.x
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -

# Install Node.js 18.x
RUN apt-get update \
&& apt-get install -y nodejs

WORKDIR /root/dalai

# Install dalai and its dependencies
RUN npm install [email protected]

ENV MODEL_SIZE=7B
ENV LLAMA=false
ENV ALPACA=true

COPY startup.sh .

# Run the dalai server
CMD [ "bash", "startup.sh" ]
Loading

0 comments on commit ffdbbef

Please sign in to comment.