Model Card Details
This model is an int4 model with group_size -1 and symmetric quantization of meta-llama/Llama-3.1-405B-Instruct generated by intel/auto-round.
Inference on CPU/HPU/CUDA
HPU: docker image with Gaudi Software Stack is recommended, please refer to following script for environment setup. More details can be found in Gaudi Guide.
from auto_round import AutoHfQuantizer ##must import for auto-round format
import torch
from transformers import AutoModelForCausalLM,AutoTokenizer
quantized_model_dir = "OPEA/Meta-Llama-3.1-405B-Instruct-int4-sym-inc"
tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
model = AutoModelForCausalLM.from_pretrained(
quantized_model_dir,
torch_dtype='auto',
device_map="auto",
)
##import habana_frameworks.torch.core as htcore ## uncommnet it for HPU
##import habana_frameworks.torch.hpu as hthpu ## uncommnet it for HPU
##model = model.to(torch.bfloat16).to("hpu") ## uncommnet it for HPU
prompt = "There is a girl who likes adventure,"
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": prompt}
]
tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
generated_ids = model.generate(
model_inputs.input_ids,
max_new_tokens=200, ##change this to align with the official usage
do_sample=False ##change this to align with the official usage
)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(response)
##prompt = "There is a girl who likes adventure,"
##INT4
"""That sounds exciting! Does she have a specific type of adventure in mind, such as traveling to new places, trying new activities, or exploring the outdoors? Or is she more of a spontaneous, "see where the day takes me" kind of person?
"""
##prompt = "Which one is larger, 9.11 or 9.8"
## INT4
"""9.11 is larger than 9.8."""
prompt = "How many r in strawberry."
## INT4
"""There are 2 Rs in the word "strawberry".""
##prompt = "Once upon a time,"
## INT4
"""
...in a land far, far away... Would you like me to continue the story, or do you have a specific direction in mind?
"""
Evaluate the model
pip3 install lm-eval==0.4.5. We have no enough resource to evaluate the bf16 model.
auto-round --eval --model_name "OPEA/Meta-Llama-3.1-405B-Instruct-int4-sym-inc" --device 0,1,2,3 --eval_bs 16 --tasks leaderboard_mmlu_pro,leaderboard_ifeval,lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,mmlu,gsm8k
Metric | INT4 |
---|---|
avg | |
leaderboard_mmlu_pro 5shot | |
leaderboard_ifeval | |
mmlu | 0.8551 |
lambada_openai | |
hellaswag | |
winogrande | 0.8303 |
piqa | |
truthfulqa_mc1 | |
openbookqa | |
boolq | |
arc_easy | |
arc_challenge | 0.6451 |
gsm8k(5shot) strict match |
Generate the model
Here is the sample command to generate the model. Torch 2.6 and add torch._dynamo.config.cache_size_limit = 130
to the code, otherwise, OOM will occur on 80GB gpu device, ~800G CPU memory
auto-round \
--model meta-llama/Llama-3.1-405B-Instruct \
--device 0 \
--group_size -1 \
--batch_size 1 \
--gradient_accumulate_steps 4 \
--bits 4 \
--disable_eval \
--low_gpu_mem_usage \
--format 'auto_round' \
--output_dir "./tmp_autoround"
Ethical Considerations and Limitations
The model can produce factually incorrect output, and should not be relied on to produce factually accurate information. Because of the limitations of the pretrained model and the finetuning datasets, it is possible that this model could generate lewd, biased or otherwise offensive outputs.
Therefore, before deploying any applications of the model, developers should perform safety testing.
Caveats and Recommendations
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
Here are a couple of useful links to learn more about Intel's AI software:
- Intel Neural Compressor link
Disclaimer
The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model. Please consult an attorney before using this model for commercial purposes.
Cite
@article{cheng2023optimize, title={Optimize weight rounding via signed gradient descent for the quantization of llms}, author={Cheng, Wenhua and Zhang, Weiwei and Shen, Haihao and Cai, Yiyang and He, Xin and Lv, Kaokao and Liu, Yi}, journal={arXiv preprint arXiv:2309.05516}, year={2023} }
- Downloads last month
- 10
Model tree for OPEA/Meta-Llama-3.1-405B-Instruct-int4-sym-inc
Base model
meta-llama/Llama-3.1-405B