Skip to content

Distribute and run LLMs with a single file.

Add "Build Instructions" section to README.md

Justine Tunney9152eb21ba38
diff --git a/.gitignore b/.gitignore
index cd114075..4a5bde3c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
/o
/TAGS
/HTAGS
+/cosmocc
/perf.data
/perf.data.old
diff --git a/README.md b/README.md
index b57b654b..2d6d18b1 100644
--- a/README.md
+++ b/README.md
@@ -29,3 +29,57 @@ weights be mapped directly into memory, similar to a self-extracting
archive. It enables quantized weights distributed online to be prefixed
with a compatible version of the llama.cpp software, thereby ensuring
its originally observed behaviors can be reproduced indefinitely.
+
+## Build Instructions
+
+First, you need the cosmocc toolchain, which is a fat portable binary
+version of GCC. Here's how you can download the latest release and add
+it to your path.
+
+```sh
+mkdir -p cosmocc
+cd cosmocc
+curl https://cosmo.zip/pub/cosmocc/cosmocc.zip >cosmocc.zip
+unzip cosmocc.zip
+cd ..
+export PATH="$PWD/cosmocc/bin:$PATH"
+```
+
+You can now build the llamafile repository by running make:
+
+```sh
+make -j8
+```
+
+Here's an example of how to generate code for a libc function using the
+llama.cpp command line interface using WizardCoder weights from Hugging
+Face.
+
+```sh
+make -j8 o//llama.cpp/main/main
+o//llama.cpp/main/main \
+ -m ~/weights/wizardcoder-python-13b-v1.0.Q8_0.gguf \
+ --temp 0 \
+ -r $'```\n' \
+ -p $'```c\nvoid *memcpy_sse2(char *dst, const char *src, size_t size) {\n'
+```
+
+Here's an example of how to run the HTTP server. This example includes
+its own `.args` file which, by default, assumes
+`llava-v1.5-7b-Q8_0.gguf` and `llava-v1.5-7b-mmproj-Q8_0.gguf` have been
+added to either (1) the current directory, or (2) placed inside the
+PKZIP file structure of the executable. It's important that weights be
+stored without compression, so they can be mapped directly from the
+executable into memory, without delay.
+
+```sh
+make -j8 o//llama.cpp/server/server
+zip -0 o//llama.cpp/server/server \
+ llava-v1.5-7b-Q8_0.gguf \
+ llava-v1.5-7b-mmproj-Q8_0.gguf
+o//llama.cpp/server/server
+```
+
+The above command will launch a browser tab on your personal computer to
+display a web interface that lets you chat with your LLM and upload
+images to it.