jartine's LLM work is generously supported by a grant from mozilla
Rocket 3B - llamafile
Description
This repo contains llamafile format model files for pansophic's Rocket 3B.
These files were quantised using hardware kindly provided by Massed Compute.
WARNING: This README may contain inaccuracies. It was generated automatically by forking TheBloke/rocket-3B-GGUF and piping the README through sed. Errors should be reported to jartine, and do not reflect TheBloke. You can also support his work on Patreon.
About llamafile
llamafile is a new format introduced by Mozilla Ocho on Nov 20th 2023. It uses Cosmopolitan Libc to turn LLM weights into runnable llama.cpp binaries that run on the stock installs of six OSes for both ARM64 and AMD64.
Here is an incomplete list of clients and libraries that are known to support llamafile:
- llama.cpp. The source project for llamafile. Offers a CLI and a server option.
- text-generation-webui, the most widely used web UI, with many features and powerful extensions. Supports GPU acceleration.
- KoboldCpp, a fully featured web UI, with GPU accel across all platforms and GPU architectures. Especially good for story telling.
- LM Studio, an easy-to-use and powerful local GUI for Windows and macOS (Silicon), with GPU acceleration.
- LoLLMS Web UI, a great web UI with many interesting and unique features, including a full model library for easy model selection.
- Faraday.dev, an attractive and easy to use character-based chat GUI for Windows and macOS (both Silicon and Intel), with GPU acceleration.
- ctransformers, a Python library with GPU accel, LangChain support, and OpenAI-compatible AI server.
- llama-cpp-python, a Python library with GPU accel, LangChain support, and OpenAI-compatible API server.
- candle, a Rust ML framework with a focus on performance, including GPU support, and ease of use.
Repositories available
- GPTQ models for GPU inference, with multiple quantisation parameter options.
- 2, 3, 4, 5, 6 and 8-bit llamafile models for CPU+GPU inference
- pansophic's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions
Prompt template: ChatML
<|im_start|>system
{system_message}<|im_end|>
<|im_start|>user
{prompt}<|im_end|>
<|im_start|>assistant
Compatibility
These quantised llamafilev2 files are compatible with llama.cpp from August 27th onwards, as of commit d0cee0d
They are also compatible with many third party UIs and libraries - please see the list at the top of this README.
Explanation of quantisation methods
Click to see details
The new methods available are:
- GGML_TYPE_Q2_K - "type-1" 2-bit quantization in super-blocks containing 16 blocks, each block having 16 weight. Block scales and mins are quantized with 4 bits. This ends up effectively using 2.5625 bits per weight (bpw)
- GGML_TYPE_Q3_K - "type-0" 3-bit quantization in super-blocks containing 16 blocks, each block having 16 weights. Scales are quantized with 6 bits. This end up using 3.4375 bpw.
- GGML_TYPE_Q4_K - "type-1" 4-bit quantization in super-blocks containing 8 blocks, each block having 32 weights. Scales and mins are quantized with 6 bits. This ends up using 4.5 bpw.
- GGML_TYPE_Q5_K - "type-1" 5-bit quantization. Same super-block structure as GGML_TYPE_Q4_K resulting in 5.5 bpw
- GGML_TYPE_Q6_K - "type-0" 6-bit quantization. Super-blocks with 16 blocks, each block having 16 weights. Scales are quantized with 8 bits. This ends up using 6.5625 bpw
Refer to the Provided Files table below to see what files use which methods, and how.
Provided files
Name | Quant method | Bits | Size | Max RAM required | Use case |
---|---|---|---|---|---|
rocket-3b.Q2_K.llamafile | Q2_K | 2 | 1.20 GB | 3.70 GB | smallest, significant quality loss - not recommended for most purposes |
rocket-3b.Q3_K_S.llamafile | Q3_K_S | 3 | 1.25 GB | 3.75 GB | very small, high quality loss |
rocket-3b.Q3_K_M.llamafile | Q3_K_M | 3 | 1.39 GB | 3.89 GB | very small, high quality loss |
rocket-3b.Q3_K_L.llamafile | Q3_K_L | 3 | 1.51 GB | 4.01 GB | small, substantial quality loss |
rocket-3b.Q4_0.llamafile | Q4_0 | 4 | 1.61 GB | 4.11 GB | legacy; small, very high quality loss - prefer using Q3_K_M |
rocket-3b.Q4_K_S.llamafile | Q4_K_S | 4 | 1.62 GB | 4.12 GB | small, greater quality loss |
rocket-3b.Q4_K_M.llamafile | Q4_K_M | 4 | 1.71 GB | 4.21 GB | medium, balanced quality - recommended |
rocket-3b.Q5_0.llamafile | Q5_0 | 5 | 1.94 GB | 4.44 GB | legacy; medium, balanced quality - prefer using Q4_K_M |
rocket-3b.Q5_K_S.llamafile | Q5_K_S | 5 | 1.94 GB | 4.44 GB | large, low quality loss - recommended |
rocket-3b.Q5_K_M.llamafile | Q5_K_M | 5 | 1.99 GB | 4.49 GB | large, very low quality loss - recommended |
rocket-3b.Q6_K.llamafile | Q6_K | 6 | 2.30 GB | 4.80 GB | very large, extremely low quality loss |
rocket-3b.Q8_0.llamafile | Q8_0 | 8 | 2.97 GB | 5.47 GB | very large, extremely low quality loss - not recommended |
Note: the above RAM figures assume no GPU offloading. If layers are offloaded to the GPU, this will reduce RAM usage and use VRAM instead.
How to download llamafile files
Note for manual downloaders: You almost never want to clone the entire repo! Multiple different quantisation formats are provided, and most users only want to pick and download a single file.
The following clients/libraries will automatically download models for you, providing a list of available models to choose from:
- LM Studio
- LoLLMS Web UI
- Faraday.dev
In text-generation-webui
Under Download Model, you can enter the model repo: jartine/rocket-3B-llamafile and below it, a specific filename to download, such as: rocket-3b.Q4_K_M.llamafile.
Then click Download.
On the command line, including multiple files at once
I recommend using the huggingface-hub
Python library:
pip3 install huggingface-hub
Then you can download any individual model file to the current directory, at high speed, with a command like this:
huggingface-cli download jartine/rocket-3B-llamafile rocket-3b.Q4_K_M.llamafile --local-dir . --local-dir-use-symlinks False
More advanced huggingface-cli download usage
You can also download multiple files at once with a pattern:
huggingface-cli download jartine/rocket-3B-llamafile --local-dir . --local-dir-use-symlinks False --include='*Q4_K*llamafile'
For more documentation on downloading with huggingface-cli
, please see: HF -> Hub Python Library -> Download files -> Download from the CLI.
To accelerate downloads on fast connections (1Gbit/s or higher), install hf_transfer
:
pip3 install hf_transfer
And set environment variable HF_HUB_ENABLE_HF_TRANSFER
to 1
:
HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download jartine/rocket-3B-llamafile rocket-3b.Q4_K_M.llamafile --local-dir . --local-dir-use-symlinks False
Windows Command Line users: You can set the environment variable by running set HF_HUB_ENABLE_HF_TRANSFER=1
before the download command.
Example llama.cpp
command
Make sure you are using llama.cpp
from commit d0cee0d or later.
./main -ngl 32 -m rocket-3b.Q4_K_M.llamafile --color -c 2048 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "<|im_start|>system\n{system_message}<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant"
Change -ngl 32
to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
Change -c 2048
to the desired sequence length. For extended sequence models - eg 8K, 16K, 32K - the necessary RoPE scaling parameters are read from the llamafile file and set by llama.cpp automatically.
If you want to have a chat-style conversation, replace the -p <PROMPT>
argument with -i -ins
For other parameters and how to use them, please refer to the llama.cpp documentation
How to run in text-generation-webui
Further instructions can be found in the text-generation-webui documentation, here: text-generation-webui/docs/04 β Model Tab.md.
How to run from Python code
You can use llamafile models from Python using the llama-cpp-python or ctransformers libraries.
How to load this model in Python code, using ctransformers
First install the package
Run one of the following commands, according to your system:
# Base ctransformers with no GPU acceleration
pip install ctransformers
# Or with CUDA GPU acceleration
pip install ctransformers[cuda]
# Or with AMD ROCm GPU acceleration (Linux only)
CT_HIPBLAS=1 pip install ctransformers --no-binary ctransformers
# Or with Metal GPU acceleration for macOS systems only
CT_METAL=1 pip install ctransformers --no-binary ctransformers
Simple ctransformers example code
from ctransformers import AutoModelForCausalLM
# Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
llm = AutoModelForCausalLM.from_pretrained("jartine/rocket-3B-llamafile", model_file="rocket-3b.Q4_K_M.llamafile", model_type="stablelm", gpu_layers=50)
print(llm("AI is going to"))
How to use with LangChain
Here are guides on using llama-cpp-python and ctransformers with LangChain:
Discord
For further support, and discussions on these models and AI in general, join us at:
Thanks, and how to contribute
I've had a lot of people ask if they can contribute. I enjoy providing models and helping people, and would love to be able to spend even more time doing it, as well as expanding into new projects like fine tuning/training.
If you're able and willing to contribute it will be most gratefully received and will help me to keep providing more models, and to start work on new AI projects.
And thank you again to mozilla for their generous grant.
Original model card: pansophic's Rocket 3B
Rocket-3B π¦
Rocket π¦ is a 3 billion large language model that was trained on a mix of publicly available datasets using Direct Preference Optimization (DPO). The prompt format used is ChatML.
Model description
- Model type: A 3B parameter GPT-like model fine-tuned on a mix of publicly available datasets using DPO.
- Language(s) (NLP): Primarily English
- License: CC-BY-SA-4.0
- Finetuned from model: Stability AI
Performance
Despite its compact dimensions, the model achieves outstanding scores in both MT-Bench MT-Bench and AlpacaEval benchmarks, surpassing the performance of considerably larger models.
Model | Size | Alignment | MT-Bench (score) | AlpacaEval (win rate %) |
---|---|---|---|---|
StableLM-Tuned-Ξ± π¦ | 7B | SFT | 2.75 | - |
MPT-Chat | 7B | SFT | 5.42 | - |
Falcon-Instruct π¦ | 40B | SFT | 5.17 | 45.71 |
Orca-2 | 13B | SFT | 6.15 | - |
Xwin-LMv0.1 | 7B | PPO | 6.19 | 87.83 |
Llama2-Chat π¦ | 7B | RLHF | 6.26 | 71.37 |
TΓLU 2 π« | 7B | DPO | 6.27 | 85.1 |
Guanaco π¦ | 65B | SFT | 6.41 | 71.80 |
Rocket π¦ | 3B | DPO | 6.56 | 79.75 |
Llama2-Chat π¦ | 13B | RLHF | 6.65 | 81.09 |
Zephyr-7b-Ξ± πͺ | 7B | DPO | 6.88 | - |
Vicuna v1.3 π¦ | 33B | SFT | 7.12 | 88.99 |
Zephyr-7b-Ξ² πͺ | 7B | DPO | 7.34 | 90.60 |
WizardLM v1.0 π¦ | 70B | SFT | 7.71 | - |
GPT-3.5-turbo | - | RLHF | 7.94 | 89.37 |
Specifically, across various categories within the MT-Bench evaluation, Rocket-3B demonstrates impressive performance when compared to larger open models such as Llama2-Chat-7B, Falcon-40B-Instruct, and Guanaco-65B.
MT-Bench detailed score for first and second turn
In MT-Bench, Rocket π¦ scores 6.99 in the first turn and 6.13 in the second turn, with an average score of 6.56. These scores reflect the model's performance in understanding and generating text during different parts of a conversation.
Model | First turn | Second turn | Average |
---|---|---|---|
Rocket π¦ | 6.99 | 6.13 | 6.56 |
AlpacaEval detailed scores
In AlpacaEval, Rocket π¦ achieves a near 80% win rate, coupled with an average response length of 1,242 tokens, indicating its effectiveness in producing detailed responses.
Model | Win rate | Std error | Average length |
---|---|---|---|
Rocket π¦ | 79.75 | 1.42 | 1242 |
Other benchmarks
Metric | Value |
---|---|
Average | 51.00 |
ARC (25-shot) | 50.51 |
HellaSwag (10-shot) | 76.45 |
MMLU (5-shot) | 45.51 |
TruthfulQA (0-shot) | 54.38 |
Winogrande (5-shot) | 67.8 |
GSM8K (5-shot) | 37.91 |
DROP (3-shot) | 24.49 |
Intended uses & limitations
Initially, we fine-tuned the model using a dataset created by merging and curating multiple datasets, available on the HuggingFace Hub. This dataset will be released to the public soon. We further enhanced the model's performance using DPO, selecting samples from the openbmb/UltraFeedback and BAAI/JudgeLM-100K datasets. The outcome is a highly effective chat model with a 3 billion parameter scale.
Input Format
The model is trained with the ChatML format:
<|im_start|>system
System message here.<|im_end|>
<|im_start|>user
Your message here!<|im_end|>
<|im_start|>assistant
Here's how you can run the model using π€ Transformers:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
model = AutoModelForCausalLM.from_pretrained("pansophic/rocket-3B", trust_remote_code=True, torch_dtype=torch.bfloat16).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("pansophic/rocket-3B", trust_remote_code=True, torch_dtype=torch.bfloat16)
streamer = TextStreamer(tokenizer)
prompt = """<|im_start|>system
{system}<|im_end|>
<|im_start|>user
{user}<|im_end|>
<|im_start|>assistant
"""
system = "You are a helpful assistant."
user = "How are you?"
# Apply the ChatML format
prompt = prompt.format(system=system, user=user)
# Tokenize the prompt
inputs = tokenizer(prompt, return_tensors="pt", return_attention_mask=False).to("cuda")
generated_text = model.generate(**inputs, max_length=3084, top_p=0.95, do_sample=True, temperature=0.7, use_cache=True, streamer=streamer)
# <|im_start|>system
# You are a chef who makes everything sound like a secret culinary masterpiece, even everyday meals.<|im_end|>
# <|im_start|>user
# How to cook an omelette?<|im_end|>
# <|im_start|>assistant
# Ah, the art of crafting the perfect omelette, a secret culinary masterpiece indeed.
# Begin by gently whisking two to three eggs in a mixing bowl, and then pour the silky liquid into a non-stick pan.
# Allow the eggs to dance and sizzle as you swiftly tilt the pan to spread the joy throughout the entire omelette universe.
# As the edges begin to set, fold the omelette in half with a gentle flourish, and you'll witness a stunning display of culinary prowess.
# Enjoy this enchanting creation, and you'll be transported to a world of secret culinary mastery.<|im_end|>
Bias, Risks, and Limitations
Unlike ChatGPT, which incorporates in-the-loop filtering of responses and is aligned during the RLHF phase for safe completions, our model lacks these features. Consequently, it may generate problematic outputs, particularly when prompted in certain ways. Below is the score of the model on Toxigen benchmark.
The pretraining dataset is comprised of a filtered mixture of open-source large-scale datasets available on the HuggingFace Hub: Falcon RefinedWeb extract (Penedo et al., 2023), RedPajama-Data (Together Computer., 2023) and The Pile (Gao et al., 2020) both without the Books3 subset, and StarCoder (Li et al., 2023).
Metric | Value |
---|---|
Toxigen (0-shot) | 43.40 |
*The model name is inspired by the small but formidable character from 'Guardians of the Galaxy'. Similar to its namesake, this model, with its 3 billion parameters, showcases remarkable efficiency and effectiveness, challenging larger models despite its smaller size."
Model card adapted from Zephyr Beta and Tulu-2-7B
- Downloads last month
- 2,780