Text Generation
Transformers
Safetensors
PyTorch
llama
autoround
intel
gptq
woq
meta
llama-3
conversational
text-generation-inference
4-bit precision
intel/auto-round
Instructions to use fbaldassarri/meta-llama_Llama-3.1-8B-Instruct-auto_round-int4-gs128-sym with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use fbaldassarri/meta-llama_Llama-3.1-8B-Instruct-auto_round-int4-gs128-sym with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="fbaldassarri/meta-llama_Llama-3.1-8B-Instruct-auto_round-int4-gs128-sym") 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("fbaldassarri/meta-llama_Llama-3.1-8B-Instruct-auto_round-int4-gs128-sym") model = AutoModelForCausalLM.from_pretrained("fbaldassarri/meta-llama_Llama-3.1-8B-Instruct-auto_round-int4-gs128-sym", 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 fbaldassarri/meta-llama_Llama-3.1-8B-Instruct-auto_round-int4-gs128-sym with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "fbaldassarri/meta-llama_Llama-3.1-8B-Instruct-auto_round-int4-gs128-sym" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "fbaldassarri/meta-llama_Llama-3.1-8B-Instruct-auto_round-int4-gs128-sym", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/fbaldassarri/meta-llama_Llama-3.1-8B-Instruct-auto_round-int4-gs128-sym
- SGLang
How to use fbaldassarri/meta-llama_Llama-3.1-8B-Instruct-auto_round-int4-gs128-sym 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 "fbaldassarri/meta-llama_Llama-3.1-8B-Instruct-auto_round-int4-gs128-sym" \ --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": "fbaldassarri/meta-llama_Llama-3.1-8B-Instruct-auto_round-int4-gs128-sym", "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 "fbaldassarri/meta-llama_Llama-3.1-8B-Instruct-auto_round-int4-gs128-sym" \ --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": "fbaldassarri/meta-llama_Llama-3.1-8B-Instruct-auto_round-int4-gs128-sym", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use fbaldassarri/meta-llama_Llama-3.1-8B-Instruct-auto_round-int4-gs128-sym with Docker Model Runner:
docker model run hf.co/fbaldassarri/meta-llama_Llama-3.1-8B-Instruct-auto_round-int4-gs128-sym
Upload README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,91 @@
|
|
| 1 |
-
---
|
| 2 |
-
|
| 3 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
- de
|
| 5 |
+
- fr
|
| 6 |
+
- it
|
| 7 |
+
- pt
|
| 8 |
+
- hi
|
| 9 |
+
- es
|
| 10 |
+
- th
|
| 11 |
+
license: llama3.1
|
| 12 |
+
library_name: transformers
|
| 13 |
+
tags:
|
| 14 |
+
- autoround
|
| 15 |
+
- intel
|
| 16 |
+
- gptq
|
| 17 |
+
- woq
|
| 18 |
+
- meta
|
| 19 |
+
- pytorch
|
| 20 |
+
- llama
|
| 21 |
+
- llama-3
|
| 22 |
+
model_name: Llama 3.1 8B Instruct
|
| 23 |
+
base_model: meta-llama/Llama-3.1-8B-Instruct
|
| 24 |
+
inference: false
|
| 25 |
+
model_creator: meta-llama
|
| 26 |
+
pipeline_tag: text-generation
|
| 27 |
+
prompt_template: '{prompt}
|
| 28 |
+
'
|
| 29 |
+
quantized_by: fbaldassarri
|
| 30 |
+
---
|
| 31 |
+
|
| 32 |
+
## Model Information
|
| 33 |
+
|
| 34 |
+
Quantized version of [meta-llama/Llama-3.1-8B-Instruct](meta-llama/Llama-3.1-8B-Instruct) using torch.float32 for quantization tuning.
|
| 35 |
+
- 4 bits (INT4)
|
| 36 |
+
- group size = 128
|
| 37 |
+
- symmetrical Quantization
|
| 38 |
+
|
| 39 |
+
Fast and low memory, 2-3X speedup (slight accuracy drop at W4G128)
|
| 40 |
+
|
| 41 |
+
Quantization framework: [Intel AutoRound](https://github.com/intel/auto-round)
|
| 42 |
+
|
| 43 |
+
Note: this INT4 version of Llama-3.1-8B-Instruct has been quantized to run inference through CPU.
|
| 44 |
+
|
| 45 |
+
## Replication Recipe
|
| 46 |
+
|
| 47 |
+
### Step 1 Install Requirements
|
| 48 |
+
|
| 49 |
+
I suggest to install requirements into a dedicated python-virtualenv or a conda enviroment.
|
| 50 |
+
|
| 51 |
+
```
|
| 52 |
+
python -m pip install <package> --upgrade
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
- accelerate==1.0.1
|
| 56 |
+
- auto_gptq==0.7.1
|
| 57 |
+
- neural_compressor==3.1
|
| 58 |
+
- torch==2.3.0+cpu
|
| 59 |
+
- torchaudio==2.5.0+cpu
|
| 60 |
+
- torchvision==0.18.0+cpu
|
| 61 |
+
- transformers==4.45.2
|
| 62 |
+
|
| 63 |
+
### Step 2 Build Intel Autoround wheel from sources
|
| 64 |
+
|
| 65 |
+
```
|
| 66 |
+
python -m pip install git+https://github.com/intel/auto-round.git
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
### Step 3 Script for Quantization
|
| 70 |
+
|
| 71 |
+
```
|
| 72 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 73 |
+
model_name = "meta-llama/Llama-3.1-8B-Instruct"
|
| 74 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
| 75 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 76 |
+
from auto_round import AutoRound
|
| 77 |
+
bits, group_size, sym = 4, 128, True
|
| 78 |
+
autoround = AutoRound(model, tokenizer, nsamples=128, iters=200, seqlen=512, batch_size=4, bits=bits, group_size=group_size, sym=sym)
|
| 79 |
+
autoround.quantize()
|
| 80 |
+
output_dir = "./AutoRound/meta-llama_Llama-3.1-8B-Instruct-auto_round-int4-gs128-sym"
|
| 81 |
+
autoround.save_quantized(output_dir, format='auto_round', inplace=True)
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
## License
|
| 85 |
+
|
| 86 |
+
[Llama 3.1 Community License](https://github.com/meta-llama/llama-models/blob/main/models/llama3_1/LICENSE)
|
| 87 |
+
|
| 88 |
+
## Disclaimer
|
| 89 |
+
|
| 90 |
+
This quantized model comes with no warrenty. It has been developed only for research purposes.
|
| 91 |
+
|