Text Generation
Transformers
Safetensors
llama
conversational
text-generation-inference
8-bit precision
bitnet
Instructions to use HF1BitLLM/Llama3-8B-1.58-100B-tokens with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HF1BitLLM/Llama3-8B-1.58-100B-tokens with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="HF1BitLLM/Llama3-8B-1.58-100B-tokens") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("HF1BitLLM/Llama3-8B-1.58-100B-tokens") model = AutoModelForCausalLM.from_pretrained("HF1BitLLM/Llama3-8B-1.58-100B-tokens", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use HF1BitLLM/Llama3-8B-1.58-100B-tokens with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "HF1BitLLM/Llama3-8B-1.58-100B-tokens" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HF1BitLLM/Llama3-8B-1.58-100B-tokens", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/HF1BitLLM/Llama3-8B-1.58-100B-tokens
- SGLang
How to use HF1BitLLM/Llama3-8B-1.58-100B-tokens with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "HF1BitLLM/Llama3-8B-1.58-100B-tokens" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HF1BitLLM/Llama3-8B-1.58-100B-tokens", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "HF1BitLLM/Llama3-8B-1.58-100B-tokens" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HF1BitLLM/Llama3-8B-1.58-100B-tokens", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use HF1BitLLM/Llama3-8B-1.58-100B-tokens with Docker Model Runner:
docker model run hf.co/HF1BitLLM/Llama3-8B-1.58-100B-tokens
Update README.md
Browse files
README.md
CHANGED
|
@@ -15,7 +15,6 @@ For a deeper dive into the methods and results, check out our [blog post](https:
|
|
| 15 |
|
| 16 |
## Model Details
|
| 17 |
|
| 18 |
-
|
| 19 |
### Model Sources
|
| 20 |
|
| 21 |
<!-- Provide the basic links for the model. -->
|
|
@@ -23,39 +22,6 @@ For a deeper dive into the methods and results, check out our [blog post](https:
|
|
| 23 |
- **Repository:** [Model](https://huggingface.co/HF1BitLLM/Llama3-8B-1.58-100B-tokens)
|
| 24 |
- **Paper:** [The Era of 1-bit LLMs: All Large Language Models are in 1.58 Bits](https://arxiv.org/abs/2402.17764)
|
| 25 |
|
| 26 |
-
## Uses
|
| 27 |
-
|
| 28 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 29 |
-
|
| 30 |
-
### Direct Use
|
| 31 |
-
|
| 32 |
-
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
| 33 |
-
|
| 34 |
-
[More Information Needed]
|
| 35 |
-
|
| 36 |
-
### Downstream Use [optional]
|
| 37 |
-
|
| 38 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
| 39 |
-
|
| 40 |
-
[More Information Needed]
|
| 41 |
-
|
| 42 |
-
### Out-of-Scope Use
|
| 43 |
-
|
| 44 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
| 45 |
-
|
| 46 |
-
[More Information Needed]
|
| 47 |
-
|
| 48 |
-
## Bias, Risks, and Limitations
|
| 49 |
-
|
| 50 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 51 |
-
|
| 52 |
-
[More Information Needed]
|
| 53 |
-
|
| 54 |
-
### Recommendations
|
| 55 |
-
|
| 56 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 57 |
-
|
| 58 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 59 |
|
| 60 |
## How to Get Started with the Model
|
| 61 |
|
|
@@ -71,7 +37,7 @@ input_ids = tokenizer.encode(input_text, return_tensors="pt").cuda()
|
|
| 71 |
output = model.generate(input_ids, max_length=10, do_sample=False)
|
| 72 |
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
| 73 |
print(generated_text)
|
| 74 |
-
|
| 75 |
|
| 76 |
## Training Details
|
| 77 |
|
|
@@ -79,112 +45,50 @@ print(generated_text)
|
|
| 79 |
|
| 80 |
The model was trained on a subset of [FineWeb-edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu)
|
| 81 |
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
### Training Hyperparameters
|
| 85 |
-
|
| 86 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 87 |
-
|
| 88 |
-
#### Speeds, Sizes, Times [optional]
|
| 89 |
-
|
| 90 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 91 |
-
|
| 92 |
-
[More Information Needed]
|
| 93 |
-
|
| 94 |
-
## Evaluation
|
| 95 |
-
|
| 96 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 97 |
-
|
| 98 |
-
### Testing Data, Factors & Metrics
|
| 99 |
-
|
| 100 |
-
#### Testing Data
|
| 101 |
-
|
| 102 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 103 |
|
| 104 |
-
|
|
|
|
| 105 |
|
| 106 |
-
|
|
|
|
|
|
|
| 107 |
|
| 108 |
-
|
|
|
|
| 109 |
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
-
|
|
|
|
| 113 |
|
| 114 |
-
|
|
|
|
|
|
|
| 115 |
|
| 116 |
-
|
|
|
|
| 117 |
|
| 118 |
-
|
| 119 |
|
| 120 |
-
[More Information Needed]
|
| 121 |
|
| 122 |
-
##
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
## Model Examination [optional]
|
| 127 |
-
|
| 128 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 129 |
-
|
| 130 |
-
[More Information Needed]
|
| 131 |
-
|
| 132 |
-
## Environmental Impact
|
| 133 |
-
|
| 134 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 135 |
-
|
| 136 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 137 |
-
|
| 138 |
-
- **Hardware Type:** [More Information Needed]
|
| 139 |
-
- **Hours used:** [More Information Needed]
|
| 140 |
-
- **Cloud Provider:** [More Information Needed]
|
| 141 |
-
- **Compute Region:** [More Information Needed]
|
| 142 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 143 |
-
|
| 144 |
-
## Technical Specifications [optional]
|
| 145 |
-
|
| 146 |
-
### Model Architecture and Objective
|
| 147 |
-
|
| 148 |
-
[More Information Needed]
|
| 149 |
-
|
| 150 |
-
### Compute Infrastructure
|
| 151 |
-
|
| 152 |
-
[More Information Needed]
|
| 153 |
-
|
| 154 |
-
#### Hardware
|
| 155 |
-
|
| 156 |
-
[More Information Needed]
|
| 157 |
-
|
| 158 |
-
#### Software
|
| 159 |
-
|
| 160 |
-
[More Information Needed]
|
| 161 |
-
|
| 162 |
-
## Citation [optional]
|
| 163 |
-
|
| 164 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 165 |
-
|
| 166 |
-
**BibTeX:**
|
| 167 |
-
|
| 168 |
-
[More Information Needed]
|
| 169 |
-
|
| 170 |
-
**APA:**
|
| 171 |
-
|
| 172 |
-
[More Information Needed]
|
| 173 |
-
|
| 174 |
-
## Glossary [optional]
|
| 175 |
-
|
| 176 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 177 |
-
|
| 178 |
-
[More Information Needed]
|
| 179 |
|
| 180 |
-
|
| 181 |
|
| 182 |
-
[
|
| 183 |
|
| 184 |
-
## Model Card Authors [optional]
|
| 185 |
|
| 186 |
-
[More Information Needed]
|
| 187 |
|
| 188 |
-
##
|
| 189 |
|
| 190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
## Model Details
|
| 17 |
|
|
|
|
| 18 |
### Model Sources
|
| 19 |
|
| 20 |
<!-- Provide the basic links for the model. -->
|
|
|
|
| 22 |
- **Repository:** [Model](https://huggingface.co/HF1BitLLM/Llama3-8B-1.58-100B-tokens)
|
| 23 |
- **Paper:** [The Era of 1-bit LLMs: All Large Language Models are in 1.58 Bits](https://arxiv.org/abs/2402.17764)
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
## How to Get Started with the Model
|
| 27 |
|
|
|
|
| 37 |
output = model.generate(input_ids, max_length=10, do_sample=False)
|
| 38 |
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
| 39 |
print(generated_text)
|
| 40 |
+
```
|
| 41 |
|
| 42 |
## Training Details
|
| 43 |
|
|
|
|
| 45 |
|
| 46 |
The model was trained on a subset of [FineWeb-edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu)
|
| 47 |
|
| 48 |
+
### Training Process
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
+
1. **Starting Point**
|
| 51 |
+
- Best-performing checkpoint from the 10 billion token runs with a linear lambda scheduler
|
| 52 |
|
| 53 |
+
2. **Training Duration**
|
| 54 |
+
- Fine-tuned for an additional 45,000 steps
|
| 55 |
+
- Reached a total of 100 billion tokens
|
| 56 |
|
| 57 |
+
3. **Dataset**
|
| 58 |
+
- FineWeb-edu dataset
|
| 59 |
|
| 60 |
+
4. **Batch Size**
|
| 61 |
+
- 2 million tokens per step
|
| 62 |
+
- Total per run: 45,000 steps * 2 million tokens = 90 billion tokens
|
| 63 |
+
- Combined with initial 10 billion tokens to reach 100 billion
|
| 64 |
|
| 65 |
+
5. **Learning Rate Experiments**
|
| 66 |
+
- Tested various learning rates to find optimal setting, according the to experiments, the best performing peak lr is 1e-5
|
| 67 |
|
| 68 |
+
6. **Performance**
|
| 69 |
+
- Close to Llama3 8B on some metrics
|
| 70 |
+
- Behind Llama3 8B in overall average performance
|
| 71 |
|
| 72 |
+
7. **Evaluation**
|
| 73 |
+
- Metrics included perplexity, MMLU scores, and other standard benchmarks
|
| 74 |
|
| 75 |
+
These extended training runs on 100 billion tokens pushed the boundaries of highly quantized models, bringing performance closer to half-precision models like Llama3.
|
| 76 |
|
|
|
|
| 77 |
|
| 78 |
+
## Evaluation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
+
The evaluation of the models is done on the nanotron checkpoints using LightEval :
|
| 81 |
|
| 82 |
+

|
| 83 |
|
|
|
|
| 84 |
|
|
|
|
| 85 |
|
| 86 |
+
## Citation
|
| 87 |
|
| 88 |
+
```bash
|
| 89 |
+
@misc{,
|
| 90 |
+
title={1.58-Bit LLM: A New Era of Extreme Quantization},
|
| 91 |
+
author={Mohamed Mekkouri and Marc Sun and Leandro von Werra and Thomas Wolf},
|
| 92 |
+
year={2024},
|
| 93 |
+
}
|
| 94 |
+
```
|