Edit model card

Model Card Details

This model is an int4 model with group_size 128 of meta-llama/Meta-Llama-3.1-70B-Instruct generated by intel/auto-round, auto-round is needed to run this model

Reproduce the model

Here is the sample command to reproduce the model.

# Make sure to use the code version after the 'b2f160c260cebaebb25abea63e273e5813725346' commit.
git clone https://github.com/intel/auto-round 
cd auto-round/examples/language-modeling
pip install -r requirements.txt
python3 main.py \
--model_name  meta-llama/Meta-Llama-3.1-70B-Instruct \
--device 0 \
--group_size 128 \
--nsamples 512 \
--bits 4 \
--iter 1000 \
--disable_eval \
--low_gpu_mem_usage \
--deployment_device 'auto_round' \
--output_dir "./tmp_autoround" 

Inference on CPU/HPU/CUDA

1 git clone https://github.com/intel/auto-round && cd auto-round && pip install -vvv --no-build-isolation -e .

2 CPU only machine: pip install intel-extension-for-transformers

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.

CUDA: no extra operations

##git clone https://github.com/intel/auto-round.git
##cd auto-round && pip install -vvv --no-build-isolation -e .
from auto_round import AutoHfQuantizer ##must import
import torch
from transformers import AutoModelForCausalLM,AutoTokenizer
quantized_model_dir = "Intel/Meta-Llama-3.1-70B-Instruct-int4-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=50,  ##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 = "Which one is bigger, 9.11 or 9.8"
##9.11 is bigger than 9.8.

##prompt = "Once upon a time,"
##it seems like we're about to start a classic fairy tale. Would you like to continue the story, or would you like me to take over and spin a yarn for you?

##prompt = "There is a girl who likes adventure,"
##That sounds exciting. What kind of adventures is she interested in? Is she more into outdoor activities like hiking, rock climbing, or exploring new places, or does she enjoy indoor adventures like solving puzzles, playing escape rooms, or reading fantasy novels?

Evaluate the model

pip3 install lm-eval==0.4.2

git clone https://github.com/intel/auto-round
cd auto-round/examples/language-modeling
python3 eval_042/evluation.py --model_name "Intel/Meta-Llama-3.1-70B-Instruct-int4-inc" --eval_bs 16  --tasks lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,mmlu,gsm8k --trust_remote_code
Metric BF16 INT4(iters 200) INT4(iters1000)
avg 0.7182 0.7119 0.7165
mmlu 0.8221 0.8136 0.8145
lambada_openai 0.7566 0.7448 0.7565
hellaswag 0.6522 0.6474 0.6492
winogrande 0.7901 0.7845 0.8090
piqa 0.8308 0.8286 0.8270
truthfulqa_mc1 0.4064 0.4002 0.4051
openbookqa 0.3720 0.3720 0.3760
boolq 0.8777 0.8780 0.8768
arc_easy 0.8674 0.8590 0.8565
arc_challenge 0.6246 0.6109 0.6160
gsm8k(5shot) strict match 0.8999 0.8923 0.8954

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
  • Intel Extension for Transformers 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} }

arxiv github

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference API
Unable to determine this model's library. Check the docs .

Dataset used to train Intel/Meta-Llama-3.1-70B-Instruct-int4-inc