Skip to content

Distribute and run LLMs with a single file.

Write man pages for all commands

Justine Tunney7a3e55786f80
diff --git a/Makefile b/Makefile
index 14f9296d..e4d6db73 100644
--- a/Makefile
+++ b/Makefile
@@ -21,7 +21,14 @@ o/$(MODE)/: o/$(MODE)/llama.cpp o/$(MODE)/llamafile
# for installing to `make PREFIX=/usr/local`
.PHONY: install
-install: o/$(MODE)/llamafile/zipalign \
+install: llamafile/zipalign.1 \
+ llama.cpp/main/main.1 \
+ llama.cpp/server/server.1 \
+ llama.cpp/quantize/quantize.1 \
+ llama.cpp/perplexity/perplexity.1 \
+ llama.cpp/llava/llava-cli.1 \
+ llama.cpp/llava/llava-quantize.1 \
+ o/$(MODE)/llamafile/zipalign \
o/$(MODE)/llama.cpp/main/main \
o/$(MODE)/llama.cpp/server/server \
o/$(MODE)/llama.cpp/quantize/quantize \
@@ -33,8 +40,15 @@ install: o/$(MODE)/llamafile/zipalign \
$(INSTALL) o/$(MODE)/llama.cpp/server/server $(PREFIX)/bin/llamafile-server
$(INSTALL) o/$(MODE)/llama.cpp/quantize/quantize $(PREFIX)/bin/llamafile-quantize
$(INSTALL) o/$(MODE)/llama.cpp/perplexity/perplexity $(PREFIX)/bin/llamafile-perplexity
- $(INSTALL) o/$(MODE)/llama.cpp/llava/llava-cli $(PREFIX)/bin/llamafile-llava-cli
- $(INSTALL) o/$(MODE)/llama.cpp/llava/llava-quantize $(PREFIX)/bin/llamafile-llava-quantize
+ $(INSTALL) o/$(MODE)/llama.cpp/llava/llava-cli $(PREFIX)/bin/llava-cli
+ $(INSTALL) o/$(MODE)/llama.cpp/llava/llava-quantize $(PREFIX)/bin/llava-quantize
+ $(INSTALL) -m 0644 llamafile/zipalign.1 $(PREFIX)/share/man/man1/zipalign.1
+ $(INSTALL) -m 0644 llama.cpp/main/main.1 $(PREFIX)/share/man/man1/llamafile.1
+ $(INSTALL) -m 0644 llama.cpp/server/server.1 $(PREFIX)/share/man/man1/llamafile-server.1
+ $(INSTALL) -m 0644 llama.cpp/quantize/quantize.1 $(PREFIX)/share/man/man1/llamafile-quantize.1
+ $(INSTALL) -m 0644 llama.cpp/perplexity/perplexity.1 $(PREFIX)/share/man/man1/llamafile-perplexity.1
+ $(INSTALL) -m 0644 llama.cpp/llava/llava-cli.1 $(PREFIX)/share/man/man1/llava-cli.1
+ $(INSTALL) -m 0644 llama.cpp/llava/llava-quantize.1 $(PREFIX)/share/man/man1/llava-quantize.1
include build/deps.mk
include build/tags.mk
diff --git a/llama.cpp/llava/llava-cli.1 b/llama.cpp/llava/llava-cli.1
new file mode 100644
index 00000000..83cc04cc
--- /dev/null
+++ b/llama.cpp/llava/llava-cli.1
@@ -0,0 +1,89 @@
+.Dd December 5, 2023
+.Dt llava-cli 1
+.Os
+.Sh NAME
+.Nm llava-cli
+.Nd CLIP model command line interface
+.Sh SYNOPSIS
+.Nm
+.Op flags...
+.Sh DESCRIPTION
+.Nm
+is a command-line tool for LLaVA.
+.Sh OPTIONS
+The following options are available:
+.Bl -tag -width indent
+.It Fl h , Fl Fl help
+Show help message and exit.
+.It Fl Fl temp Ar N
+Temperature (default: 0.8)
+.It Fl Fl top-k Ar N
+Top-k sampling (default: 40, 0 = disabled)
+.It Fl Fl top-p Ar N
+Top-p sampling (default: 0.9, 1.0 = disabled)
+.It Fl Fl tfs Ar N
+Tail free sampling, parameter z (default: 1.0, 1.0 = disabled)
+.It Fl Fl typical Ar N
+Locally typical sampling, parameter p (default: 1.0, 1.0 = disabled)
+.It Fl Fl mirostat Ar N
+Use Mirostat sampling. Top K, Nucleus, Tail Free and Locally Typical samplers are ignored if used. (default: 0, 0 = disabled, 1 = Mirostat, 2 = Mirostat 2.0)
+.It Fl Fl mirostat-lr Ar N
+Mirostat learning rate, parameter eta (default: 0.1)
+.It Fl Fl mirostat-ent Ar N
+Mirostat target entropy, parameter tau (default: 5.0)
+.Fl Fl logit-bias Ar 15043+1
+to increase likelihood of token
+.Ar ' Hello' ,
+or
+.Fl Fl logit-bias Ar 15043-1
+to decrease likelihood of token
+.Ar ' Hello' .
+.It Fl p Ar PROMPT , Fl Fl prompt Ar PROMPT
+Prompt to start generation with (default: empty)
+.It Fl t Ar N , Fl Fl threads Ar N
+Number of threads to use during generation (default: nproc/2)
+.It Fl tb Ar N , Fl Fl threads-batch Ar N
+Number of threads to use during batch and prompt processing (default:
+same as
+.Fl Fl threads )
+.It Fl Fl image Ar IMAGE_FILE
+Path to an image file. use with multimodal models.
+.It Fl n Ar N , Fl Fl n-predict Ar N
+Number of tokens to predict (default: -1, -1 = infinity, -2 = until context filled)
+.It Fl b Ar N , Fl Fl batch-size Ar N
+Batch size for prompt processing (default: 512)
+.It Fl m Ar FNAME , Fl Fl model Ar FNAME
+Model path (default: models/7B/ggml-model-f16.gguf)
+.It Fl Fl mmproj Ar MMPROJ_FILE
+Path to a multimodal projector file for LLaVA. See llama.cpp/llava/README.md
+.It Fl Fl numa
+Attempt optimizations that help on some NUMA systems if run without this previously, it is recommended to drop the system page cache before using this. See https://github.com/ggerganov/llama.cpp/issues/1437.
+.It Fl c Ar N , Fl Fl ctx-size Ar N
+Size of the prompt context (default: 512, 0 = loaded from model)
+.It Fl Fl rope-scaling Ar {none,linear,yarn}
+RoPE frequency scaling method, defaults to linear unless specified by the model
+.It Fl Fl rope-scale Ar N
+RoPE context scaling factor, expands context by a factor of N
+.It Fl Fl rope-freq-base Ar N
+RoPE base frequency, used by NTK-aware scaling (default: loaded from model)
+.It Fl Fl rope-freq-scale Ar N
+RoPE frequency scaling factor, expands context by a factor of 1/N
+.It Fl Fl yarn-orig-ctx Ar N
+YaRN: original context size of model (default: 0 = model training context size)
+.It Fl Fl yarn-ext-factor Ar N
+YaRN: extrapolation mix factor (default: 1.0, 0.0 = full interpolation)
+.It Fl Fl yarn-attn-factor Ar N
+YaRN: scale sqrt(t) or attention magnitude (default: 1.0)
+.It Fl Fl yarn-beta-slow Ar N
+YaRN: high correction dim or alpha (default: 1.0)
+.It Fl Fl yarn-beta-fast Ar N
+YaRN: low correction dim or beta (default: 32.0)
+.It Fl s Ar SEED , Fl Fl seed Ar SEED
+Random Number Generator (RNG) seed (default: -1, use random seed for < 0)
+.It Fl Fl memory-f32
+Use f32 instead of f16 for memory key+value (default: disabled) Not recommended: doubles context memory required and no measurable increase in quality.
+.It Fl Fl logits-all
+Return logits for all tokens in the batch (default: disabled).El
+.Sh SEE ALSO
+.Xr llava-quantize 1 ,
+.Xr llamafile 1
diff --git a/llama.cpp/llava/llava-quantize.1 b/llama.cpp/llava/llava-quantize.1
new file mode 100644
index 00000000..28fd7b98
--- /dev/null
+++ b/llama.cpp/llava/llava-quantize.1
@@ -0,0 +1,42 @@
+.Dd December 5, 2023
+.Dt llava-quantize 1
+.Os
+.Sh NAME
+.Nm llava-quantize
+.Nd CLIP model quantizer
+.Sh SYNOPSIS
+.Nm
+.Ar INPUT
+.Ar OUTPUT
+.Ar FORMAT
+.Sh DESCRIPTION
+.Nm
+makes LLaVA mmproj files smaller.
+.Sh ARGUMENTS
+The following positional arguments are accepted:
+.Bl -tag -width indent
+.It Ev Ar INPUT
+Is the input file, which should be a CLIP model in the GGUF format using float16 values.
+.It Ev Ar OUTPUT
+Is the output file, which will be a CLIP model in the GGUF format using the desired number type.
+.It Ev Ar FORMAT
+Is the desired quantization format, which may be the integer id of a supported quantization type. See the quantization types section below for acceptable formats.
+.El
+.Sh QUANTIZATION TYPES
+The following quantization types are available:
+.Pp
+.Bl -dash -compact
+.It
+2 is Q4_0
+.It
+3 is Q4_1
+.It
+6 is Q5_0
+.It
+7 is Q5_1
+.It
+8 is Q8_0
+.El
+.Sh SEE ALSO
+.Xr llava-cli 1 ,
+.Xr llamafile 1
diff --git a/llama.cpp/main/main.1 b/llama.cpp/main/main.1
new file mode 100644
index 00000000..1090f95b
--- /dev/null
+++ b/llama.cpp/main/main.1
@@ -0,0 +1,242 @@
+.Dd December 5, 2023
+.Dt llamafile 1
+.Os
+.Sh NAME
+.Nm llamafile
+.Nd large language model runner
+.Sh SYNOPSIS
+.Nm
+.Op flags...
+.Op Fl m Ar weights.gguf
+.Op Fl p Ar prompt
+.Sh DESCRIPTION
+.Nm
+is a command-line tool for running large language models. It has use
+cases such as:
+.Pp
+.Bl -dash -compact
+.It
+Code completion
+.It
+Prose composition
+.It
+Text summarization
+.It
+Interactive chat bot
+.El
+.Sh OPTIONS
+The following options are available:
+.Bl -tag -width indent
+.It Fl h , Fl Fl help
+Show help message and exit.
+.It Fl i , Fl Fl interactive
+Run in interactive mode.
+.It Fl Fl interactive-first
+Run in interactive mode and wait for input right away.
+.It Fl ins , Fl Fl instruct
+Run in instruction mode (use with Alpaca models).
+.It Fl Fl multiline-input
+Allows you to write or paste multiple lines without ending each in '\[rs]'.
+.It Fl r Ar PROMPT , Fl Fl reverse-prompt Ar PROMPT
+Halt generation at
+.Ar PROMPT
+and return control in interactive mode (can be specified more than once for multiple prompts).
+.It Fl Fl color
+colorise output to distinguish prompt and user input from generations
+.It Fl s Ar SEED , Fl Fl seed Ar SEED
+Random Number Generator (RNG) seed (default: -1, use random seed for < 0)
+.It Fl t Ar N , Fl Fl threads Ar N
+Number of threads to use during generation (default: nproc/2)
+.It Fl tb Ar N , Fl Fl threads-batch Ar N
+Number of threads to use during batch and prompt processing (default:
+same as
+.Fl Fl threads )
+.It Fl p Ar PROMPT , Fl Fl prompt Ar PROMPT
+Prompt to start generation with (default: empty)
+.It Fl e , Fl Fl escape
+.\" Process prompt escapes sequences (\[rs]n, \[rs]r, \[rs]t, \[rs]\[aa], \[rs]", \[rs]\[rs])
+.It Fl Fl prompt-cache Ar FNAME
+File to cache prompt state for faster startup (default: none)
+.It Fl Fl prompt-cache-all
+If specified, saves user input and generations to cache as well. Not supported with
+.Fl Fl interactive
+or other interactive options.
+.It Fl Fl prompt-cache-ro
+If specified, uses the prompt cache but does not update it.
+.It Fl Fl random-prompt
+Start with a randomized prompt.
+.It Fl Fl in-prefix-bos
+Prefix BOS to user inputs, preceding the
+.Fl Fl in-prefix
+string.
+.It Fl Fl in-prefix Ar STRING
+String to prefix user inputs with (default: empty)
+.It Fl Fl in-suffix Ar STRING
+String to suffix after user inputs with (default: empty)
+.It Fl f Ar FNAME , Fl Fl file Ar FNAME
+Prompt file to start generation.
+.It Fl n Ar N , Fl Fl n-predict Ar N
+Number of tokens to predict (default: -1, -1 = infinity, -2 = until context filled)
+.It Fl c Ar N , Fl Fl ctx-size Ar N
+Size of the prompt context (default: 512, 0 = loaded from model)
+.It Fl b Ar N , Fl Fl batch-size Ar N
+Batch size for prompt processing (default: 512)
+.It Fl Fl top-k Ar N
+Top-k sampling (default: 40, 0 = disabled)
+.It Fl Fl top-p Ar N
+Top-p sampling (default: 0.9, 1.0 = disabled)
+.It Fl Fl min-p Ar N
+Min-p sampling (default: 0.1, 0.0 = disabled)
+.It Fl Fl tfs Ar N
+Tail free sampling, parameter z (default: 1.0, 1.0 = disabled)
+.It Fl Fl typical Ar N
+Locally typical sampling, parameter p (default: 1.0, 1.0 = disabled)
+.It Fl Fl repeat-last-n Ar N
+Last n tokens to consider for penalize (default: 64, 0 = disabled, -1 = ctx_size)
+.It Fl Fl repeat-penalty Ar N
+Penalize repeat sequence of tokens (default: 1.1, 1.0 = disabled)
+.It Fl Fl presence-penalty Ar N
+Repeat alpha presence penalty (default: 0.0, 0.0 = disabled)
+.It Fl Fl frequency-penalty Ar N
+Repeat alpha frequency penalty (default: 0.0, 0.0 = disabled)
+.It Fl Fl mirostat Ar N
+Use Mirostat sampling. Top K, Nucleus, Tail Free and Locally Typical samplers are ignored if used. (default: 0, 0 = disabled, 1 = Mirostat, 2 = Mirostat 2.0)
+.It Fl Fl mirostat-lr Ar N
+Mirostat learning rate, parameter eta (default: 0.1)
+.It Fl Fl mirostat-ent Ar N
+Mirostat target entropy, parameter tau (default: 5.0)
+.It Fl l Ar TOKEN_ID(+/-)BIAS , Fl Fl logit-bias Ar TOKEN_ID(+/-)BIAS
+Modifies the likelihood of token appearing in the completion, i.e.
+.Fl Fl logit-bias Ar 15043+1
+to increase likelihood of token
+.Ar ' Hello' ,
+or
+.Fl Fl logit-bias Ar 15043-1
+to decrease likelihood of token
+.Ar ' Hello' .
+.It Fl Fl grammar Ar GRAMMAR
+BNF-like grammar to constrain generations (see samples in grammars/ dir)
+.It Fl Fl grammar-file Ar FNAME
+File to read grammar from.
+.It Fl Fl cfg-negative-prompt Ar PROMPT
+Negative prompt to use for guidance. (default: empty)
+.It Fl Fl cfg-negative-prompt-file Ar FNAME
+Negative prompt file to use for guidance. (default: empty)
+.It Fl Fl cfg-scale Ar N
+Strength of guidance (default: 1.000000, 1.0 = disable)
+.It Fl Fl rope-scaling Ar {none,linear,yarn}
+RoPE frequency scaling method, defaults to linear unless specified by the model
+.It Fl Fl rope-scale Ar N
+RoPE context scaling factor, expands context by a factor of N
+.It Fl Fl rope-freq-base Ar N
+RoPE base frequency, used by NTK-aware scaling (default: loaded from model)
+.It Fl Fl rope-freq-scale Ar N
+RoPE frequency scaling factor, expands context by a factor of 1/N
+.It Fl Fl yarn-orig-ctx Ar N
+YaRN: original context size of model (default: 0 = model training context size)
+.It Fl Fl yarn-ext-factor Ar N
+YaRN: extrapolation mix factor (default: 1.0, 0.0 = full interpolation)
+.It Fl Fl yarn-attn-factor Ar N
+YaRN: scale sqrt(t) or attention magnitude (default: 1.0)
+.It Fl Fl yarn-beta-slow Ar N
+YaRN: high correction dim or alpha (default: 1.0)
+.It Fl Fl yarn-beta-fast Ar N
+YaRN: low correction dim or beta (default: 32.0)
+.It Fl Fl ignore-eos
+Ignore end of stream token and continue generating (implies
+.Fl Fl logit-bias Ar 2-inf )
+.It Fl Fl no-penalize-nl
+Do not penalize newline token.
+.It Fl Fl memory-f32
+Use f32 instead of f16 for memory key+value (default: disabled) Not recommended: doubles context memory required and no measurable increase in quality.
+.It Fl Fl temp Ar N
+Temperature (default: 0.8)
+.It Fl Fl logits-all
+Return logits for all tokens in the batch (default: disabled)
+.It Fl Fl hellaswag
+Compute HellaSwag score over random tasks from datafile supplied with -f
+.It Fl Fl hellaswag-tasks Ar N
+Number of tasks to use when computing the HellaSwag score (default: 400)
+.It Fl Fl keep Ar N
+Number of tokens to keep from the initial prompt (default: 0, -1 = all)
+.It Fl Fl draft Ar N
+Number of tokens to draft for speculative decoding (default: 16)
+.It Fl Fl chunks Ar N
+Max number of chunks to process (default: -1, -1 = all)
+.It Fl np Ar N , Fl Fl parallel Ar N
+Number of parallel sequences to decode (default: 1)
+.It Fl ns Ar N , Fl Fl sequences Ar N
+Number of sequences to decode (default: 1)
+.It Fl pa Ar N , Fl Fl p-accept Ar N
+speculative decoding accept probability (default: 0.5)
+.It Fl ps Ar N , Fl Fl p-split Ar N
+Speculative decoding split probability (default: 0.1)
+.It Fl cb , Fl Fl cont-batching
+Enable continuous batching (a.k.a dynamic batching) (default: disabled)
+.It Fl Fl mmproj Ar MMPROJ_FILE
+Path to a multimodal projector file for LLaVA. See llama.cpp/llava/README.md
+.It Fl Fl image Ar IMAGE_FILE
+Path to an image file. use with multimodal models.
+.It Fl Fl mlock
+Force system to keep model in RAM rather than swapping or compressing.
+.It Fl Fl no-mmap
+Do not memory-map model (slower load but may reduce pageouts if not using mlock).
+.It Fl Fl numa
+Attempt optimizations that help on some NUMA systems if run without this previously, it is recommended to drop the system page cache before using this. See https://github.com/ggerganov/llama.cpp/issues/1437.
+.It Fl ngl Ar N , Fl Fl n-gpu-layers Ar N
+Number of layers to store in VRAM.
+.It Fl ngld Ar N , Fl Fl n-gpu-layers-draft Ar N
+Number of layers to store in VRAM for the draft model.
+.It Fl ts Ar SPLIT , Fl Fl tensor-split Ar SPLIT
+How to split tensors across multiple GPUs, comma-separated list of proportions, e.g. 3,1
+.It Fl mg Ar i , Fl Fl main-gpu Ar i
+The GPU to use for scratch and small tensors.
+.It Fl nommq , Fl Fl no-mul-mat-q
+Use cuBLAS instead of custom mul_mat_q CUDA kernels. Not recommended since this is both slower and uses more VRAM.
+.It Fl Fl verbose-prompt
+Print prompt before generation.
+.It Fl Fl silent-prompt
+Don't echo the prompt itself to standard output.
+.It Fl Fl simple-io
+Use basic IO for better compatibility in subprocesses and limited consoles.
+.It Fl Fl lora Ar FNAME
+Apply LoRA adapter (implies
+.Fl Fl no-mmap )
+.It Fl Fl lora-scaled Ar FNAME Ar S
+Apply LoRA adapter with user defined scaling S (implies
+.Fl Fl no-mmap )
+.It Fl Fl lora-base Ar FNAME
+Optional model to use as a base for the layers modified by the LoRA adapter
+.It Fl m Ar FNAME , Fl Fl model Ar FNAME
+Model path (default: models/7B/ggml-model-f16.gguf)
+.It Fl md Ar FNAME , Fl Fl model-draft Ar FNAME
+Draft model for speculative decoding (default: models/7B/ggml-model-f16.gguf)
+.It Fl Fl unsecure
+Disables pledge() sandboxing on Linux and OpenBSD.
+.El
+.Sh LOG OPTIONS
+The following log options are available:
+.Bl -tag -width indent
+.It Fl ld Ar LOGDIR , Fl Fl logdir Ar LOGDIR
+Path under which to save YAML logs (no logging if unset)
+.It Fl Fl log-test
+Run simple logging test
+.It Fl Fl log-disable
+Disable trace logs
+.It Fl Fl log-enable
+Enable trace logs
+.It Fl Fl log-file
+Specify a log filename (without extension)
+.It Fl Fl log-new
+Create a separate new log file on start. Each log file will have unique name: "<name>.<ID>.log"
+.It Fl Fl log-append
+Don't truncate the old log file.
+.El
+.Sh SEE ALSO
+.Xr llamafile-server 1 ,
+.Xr llamafile-quantize 1 ,
+.Xr llamafile-perplexity 1 ,
+.Xr llava-cli 1 ,
+.Xr llava-quantize 1 ,
+.Xr zipalign 1 ,
+.Xr unzip 1
diff --git a/llama.cpp/perplexity/BUILD.mk b/llama.cpp/perplexity/BUILD.mk
index ea40e0b4..e83f8d18 100644
--- a/llama.cpp/perplexity/BUILD.mk
+++ b/llama.cpp/perplexity/BUILD.mk
@@ -5,8 +5,8 @@ PKGS += LLAMA_CPP_PERPLEXITY
LLAMA_CPP_PERPLEXITY_FILES := $(wildcard llama.cpp/perplexity/*)
LLAMA_CPP_PERPLEXITY_HDRS = $(filter %.h,$(LLAMA_CPP_PERPLEXITY_FILES))
-LLAMA_CPP_PERPLEXITY_SRCS = $(filter %.cc,$(LLAMA_CPP_PERPLEXITY_FILES))
-LLAMA_CPP_PERPLEXITY_OBJS = $(LLAMA_CPP_PERPLEXITY_SRCS:%.cc=o/$(MODE)/%.o)
+LLAMA_CPP_PERPLEXITY_SRCS = $(filter %.cpp,$(LLAMA_CPP_PERPLEXITY_FILES))
+LLAMA_CPP_PERPLEXITY_OBJS = $(LLAMA_CPP_PERPLEXITY_SRCS:%.cpp=o/$(MODE)/%.o)
.PHONY: o/$(MODE)/llama.cpp/perplexity
o/$(MODE)/llama.cpp/perplexity: \
diff --git a/llama.cpp/perplexity/perplexity.1 b/llama.cpp/perplexity/perplexity.1
new file mode 100644
index 00000000..68fcdf47
--- /dev/null
+++ b/llama.cpp/perplexity/perplexity.1
@@ -0,0 +1,27 @@
+.Dd December 5, 2023
+.Dt llamafile-perplexity 1
+.Os
+.Sh NAME
+.Nm llamafile-perplexity
+.Nd LLM benchmarking tool
+.Sh SYNOPSIS
+.Nm
+.Op flags...
+.Sh DESCRIPTION
+.Nm
+can be used to gauge the quality of an LLM implementation.
+.Sh OPTIONS
+The following options are available:
+.Bl -tag -width indent
+.It Fl h , Fl Fl help
+Show help message and exit.
+.It Fl m Ar FNAME , Fl Fl model Ar FNAME
+Model path (default: models/7B/ggml-model-f16.gguf)
+.It Fl f Ar FNAME , Fl Fl file Ar FNAME
+Raw data input file.
+.It Fl t Ar N , Fl Fl threads Ar N
+Number of threads to use during generation (default: nproc/2)
+.It Fl s Ar SEED , Fl Fl seed Ar SEED
+Random Number Generator (RNG) seed (default: -1, use random seed for < 0)
+.Sh SEE ALSO
+.Xr llamafile 1
diff --git a/llama.cpp/perplexity/perplexity.cc b/llama.cpp/perplexity/perplexity.cpp
similarity index 100%
rename from llama.cpp/perplexity/perplexity.cc
rename to llama.cpp/perplexity/perplexity.cpp
diff --git a/llama.cpp/quantize/quantize.1 b/llama.cpp/quantize/quantize.1
new file mode 100644
index 00000000..485e2257
--- /dev/null
+++ b/llama.cpp/quantize/quantize.1
@@ -0,0 +1,92 @@
+.Dd December 5, 2023
+.Dt llamafile-quantize 1
+.Os
+.Sh NAME
+.Nm llamafile-quantize
+.Nd large language model quantizer
+.Sh SYNOPSIS
+.Nm
+.Op flags...
+.Ar model-f32.gguf
+.Op Ar model-quant.gguf
+.Ar type
+.Op Ar nthreads
+.Sh DESCRIPTION
+.Nm
+converts large language model weights from the float32 or float16
+formats into smaller data types from 2 to 8 bits in size.
+.Sh OPTIONS
+The following flags are available:
+.Bl -tag -width indent
+.It Fl Fl allow-requantize
+Allows requantizing tensors that have already been quantized. Warning: This can severely reduce quality compared to quantizing from 16bit or 32bit
+.It Fl Fl leave-output-tensor
+Will leave output.weight un(re)quantized. Increases model size but may also increase quality, especially when requantizing
+.It Fl Fl pure
+Disable k-quant mixtures and quantize all tensors to the same type
+.El
+.Sh ARGUMENTS
+The following positional arguments are accepted:
+.Bl -tag -width indent
+.It Ev Ar model-f32.gguf
+Is the input file, which contains the unquantized model weights in either the float32 or float16 format.
+.It Ev Ar model-quant.gguf
+Is the output file, which will contain quantized weights in the desired format. If this path isn't specified, it'll default to [inp path]/ggml-model-[ftype].gguf.
+.It Ev Ar type
+Is the desired quantization format, which may be the integer id of a supported quantization type, or its name. See the quantization types section below for acceptable formats.
+.It Ev Ar nthreads
+Number of threads to use during computation (default: nproc/2)
+.El
+.Sh QUANTIZATION TYPES
+The following quantization types are available:
+.Pp
+.Bl -dash -compact
+.It
+   2 Q4_0 3.56G +0.2166 ppl @ LLaMA-v1-7B
+.It
+   3 Q4_1 3.90G +0.1585 ppl @ LLaMA-v1-7B
+.It
+   8 Q5_0 4.33G +0.0683 ppl @ LLaMA-v1-7B
+.It
+   9 Q5_1 4.70G +0.0349 ppl @ LLaMA-v1-7B
+.It
+  10 Q2_K 2.63G +0.6717 ppl @ LLaMA-v1-7B
+.It
+  12 Q3_K alias for Q3_K_M
+.It
+  11 Q3_K_S 2.75G +0.5551 ppl @ LLaMA-v1-7B
+.It
+  12 Q3_K_M 3.07G +0.2496 ppl @ LLaMA-v1-7B
+.It
+  13 Q3_K_L 3.35G +0.1764 ppl @ LLaMA-v1-7B
+.It
+  15 Q4_K alias for Q4_K_M
+.It
+  14 Q4_K_S 3.59G +0.0992 ppl @ LLaMA-v1-7B
+.It
+  15 Q4_K_M 3.80G +0.0532 ppl @ LLaMA-v1-7B
+.It
+  17 Q5_K alias for Q5_K_M
+.It
+  16 Q5_K_S 4.33G +0.0400 ppl @ LLaMA-v1-7B
+.It
+  17 Q5_K_M 4.45G +0.0122 ppl @ LLaMA-v1-7B
+.It
+  18 Q6_K 5.15G -0.0008 ppl @ LLaMA-v1-7B
+.It
+   7 Q8_0 6.70G +0.0004 ppl @ LLaMA-v1-7B
+.It
+   1 F16 13.00G @ 7B
+.It
+   0 F32 26.00G @ 7B
+.It
+COPY Only copy tensors, no quantizing.
+.El
+.Sh SEE ALSO
+.Xr llamafile 1 ,
+.Xr llamafile-server 1 ,
+.Xr llamafile-perplexity 1 ,
+.Xr llava-cli 1 ,
+.Xr llava-quantize 1 ,
+.Xr zipalign 1 ,
+.Xr unzip 1
diff --git a/llama.cpp/server/server.1 b/llama.cpp/server/server.1
new file mode 100644
index 00000000..28f5e3b6
--- /dev/null
+++ b/llama.cpp/server/server.1
@@ -0,0 +1,109 @@
+.Dd December 5, 2023
+.Dt llamafile-server 1
+.Os
+.Sh NAME
+.Nm llamafile-server
+.Nd large language model server
+.Sh SYNOPSIS
+.Nm
+.Op flags...
+.Op Fl m Ar weights.gguf
+.Sh DESCRIPTION
+.Nm
+launches an HTTP server and browser tab with a web user interface for
+the llama.cpp software. The UI lets you chat with your LLM and upload
+images it can analyze. Furthermore, this server provides an OpenAI API
+compatible completions endpoint.
+.Sh OPTIONS
+The following options are available:
+.Bl -tag -width indent
+.It Fl h , Fl Fl help
+Show this help message and exit.
+.It Fl v , Fl Fl verbose
+Verbose output (default: disabled)
+.It Fl t Ar N , Fl Fl threads Ar N
+Number of threads to use during computation (default: nproc/2)
+.It Fl tb Ar N , Fl Fl threads-batch Ar N
+Number of threads to use during batch and prompt processing (default:
+same as
+.Fl Fl threads )
+.It Fl c Ar N , Fl Fl ctx-size Ar N
+Size of the prompt context (default: 512, 0 = loaded from model)
+.It Fl Fl rope-scaling Ar {none,linear,yarn}
+RoPE frequency scaling method, defaults to linear unless specified by the model
+.It Fl Fl rope-scale Ar N
+RoPE context scaling factor, expands context by a factor of N
+.It Fl Fl rope-freq-base Ar N
+RoPE base frequency, used by NTK-aware scaling (default: loaded from model)
+.It Fl Fl rope-freq-scale Ar N
+RoPE frequency scaling factor, expands context by a factor of 1/N
+.It Fl Fl yarn-orig-ctx Ar N
+YaRN: original context size of model (default: 0 = model training context size)
+.It Fl Fl yarn-ext-factor Ar N
+YaRN: extrapolation mix factor (default: 1.0, 0.0 = full interpolation)
+.It Fl Fl yarn-attn-factor Ar N
+YaRN: scale sqrt(t) or attention magnitude (default: 1.0)
+.It Fl Fl yarn-beta-slow Ar N
+YaRN: high correction dim or alpha (default: 1.0)
+.It Fl Fl yarn-beta-fast Ar N
+YaRN: low correction dim or beta (default: 32.0)
+.It Fl b Ar N , Fl Fl batch-size Ar N
+Batch size for prompt processing (default: 512)
+.It Fl Fl memory-f32
+Use f32 instead of f16 for memory key+value (default: disabled) Not recommended: doubles context memory required and no measurable increase in quality.
+.It Fl Fl mlock
+Force system to keep model in RAM rather than swapping or compressing.
+.It Fl Fl no-mmap
+Do not memory-map model (slower load but may reduce pageouts if not using mlock).
+.It Fl Fl numa
+Attempt optimizations that help on some NUMA systems if run without this previously, it is recommended to drop the system page cache before using this. See https://github.com/ggerganov/llama.cpp/issues/1437.
+.It Fl ngl Ar N , Fl Fl n-gpu-layers Ar N
+Number of layers to store in VRAM.
+.It Fl ts Ar SPLIT , Fl Fl tensor-split Ar SPLIT
+How to split tensors across multiple GPUs, comma-separated list of proportions, e.g. 3,1
+.It Fl mg Ar i , Fl Fl main-gpu Ar i
+The GPU to use for scratch and small tensors.
+.It Fl nommq , Fl Fl no-mul-mat-q
+Use cuBLAS instead of custom mul_mat_q CUDA kernels. Not recommended since this is both slower and uses more VRAM.
+.It Fl m Ar FNAME , Fl Fl model Ar FNAME
+Model path (default: models/7B/ggml-model-f16.gguf)
+.It Fl a Ar ALIAS , Fl Fl alias Ar ALIAS
+Set an alias for the model, will be added as `model` field in completion response.
+.It Fl Fl lora Ar FNAME
+Apply LoRA adapter (implies
+.Fl Fl no-mmap )
+.It Fl Fl lora-base Ar FNAME
+Optional model to use as a base for the layers modified by the LoRA adapter
+.It Fl Fl host Ar IPADDR
+IP address to listen (default: 127.0.0.1)
+.It Fl Fl port Ar PORT
+Port to listen (default (default: 8080)
+.It Fl Fl path Ar PUBLIC_PATH
+Path from which to serve static files (default /zip/llama.cpp/server/public)
+.It Fl to Ar N , Fl Fl timeout Ar N
+Server read/write timeout in seconds (default: 600)
+.It Fl Fl embedding
+Enable embedding vector output (default: disabled)
+.It Fl np Ar N , Fl Fl parallel Ar N
+Number of slots for process requests (default: 1)
+.It Fl cb , Fl Fl cont-batching
+Enable continuous batching (a.k.a dynamic batching) (default: disabled)
+.It Fl spf Ar FNAME , Fl Fl system-prompt-file Ar FNAME
+Set a file to load a system prompt (initial prompt of all slots), this is useful for chat applications.
+.It Fl Fl mmproj Ar MMPROJ_FILE
+Path to a multimodal projector file for LLaVA.
+.It Fl Fl log-disable
+Disables logging to a file.
+.It Fl Fl nobrowser
+Do not attempt to open a web browser tab at startup.
+.It Fl Fl unsecure
+Disables pledge() sandboxing on Linux and OpenBSD
+.El
+.Sh SEE ALSO
+.Xr llamafile 1 ,
+.Xr llamafile-quantize 1 ,
+.Xr llamafile-perplexity 1 ,
+.Xr llava-cli 1 ,
+.Xr llava-quantize 1 ,
+.Xr zipalign 1 ,
+.Xr unzip 1
diff --git a/llamafile/zipalign.1 b/llamafile/zipalign.1
new file mode 100644
index 00000000..0c0070b8
--- /dev/null
+++ b/llamafile/zipalign.1
@@ -0,0 +1,39 @@
+.Dd December 5, 2023
+.Dt zipalign 1
+.Os
+.Sh NAME
+.Nm zipalign
+.Nd PKZIP for LLMs
+.Sh SYNOPSIS
+.Nm
+.Op FLAG...
+.Ar ZIP
+.Ar FILE...
+.Sh DESCRIPTION
+.Nm
+adds aligned uncompressed files to a PKZIP archive.
+.Pp
+This tool is designed to concatenate gigabytes of LLM weights to an
+executable. This command goes 10x faster than `zip -j0`. Unlike zip
+you are not required to use the .com file extension for it to work.
+But most importantly, this tool has a flag that lets you insert zip
+files that are aligned on a specific boundary. The result is things
+like GPUs that have specific memory alignment requirements will now
+be able to perform math directly on the zip file's mmap()'d weights
+.Sh OPTIONS
+The following options are available:
+.Bl -tag -width indent
+.It Fl h
+Show help.
+.It Fl N
+Run in nondeterministic mode. This will cause the date/time of inserted assets to reflect the current time.
+.It Fl a Ar INT
+Byte alignment for inserted zip assets. This must be a two power. It defaults to 65536.
+.It Fl j
+Strip directory components. The filename of each input path will be used as the ZIP asset name.
+.It Fl 0
+Store zip assets without compression.
+.El
+.Sh SEE ALSO
+.Xr unzip 1 ,
+.Xr llamafile 1