OPEA
/

Safetensors
llama
3-bit
gptq

Model Details

This model is an int3 model with group_size 64 and symmetric quantization of meta-llama/Llama-3.3-70B-Instruct generated by intel/auto-round.

How To Use

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 transformers import AutoModelForCausalLM,AutoTokenizer
quantized_model_dir = "OPEA/Llama-3.3-70B-Instruct-int3-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)
##INT3:
##That sounds like the start of an exciting story. This girl who likes adventure, what kind of adventures is she looking for? Is she interested in exploring new places, trying new activities, or perhaps solving mysteries?
##BF16:
## That sounds like the start of an exciting story. The girl who likes adventure, let's call her Alex, is probably always looking for her next thrill. She might enjoy activities like hiking, rock climbing, or exploring new places. Perhaps she's always been drawn to the unknown and loves to challenge herself to try new things.

prompt = "Which one is larger, 9.11 or 9.8"
##INT3:
## 9.11 is larger than 9.8.
##BF16:
## 9.11 is larger than 9.8.

prompt = "How many r in strawberry."
##INT3:
##There are 2 R's in the word "strawberry".

##BF16:
## There are 2 R's in the word "strawberry".

prompt = "Once upon a time,"
##INT3:
"""
The attention mask is not set and cannot be inferred from input because pad token is same as eos token. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.
...in a land far, far away, where magic was real and dreams came true, there lived a beautiful princess named Sophia. She had long, golden hair and sparkling blue eyes that shone like the stars in the night sky. Sophia lived in a magnificent castle with her parents, the king and queen, and spent her days exploring the rolling hills and lush forests that surrounded the kingdom.

One day, while out for a walk, Sophia stumbled upon a hidden path she had never seen before. The path was winding and narrow, and it seemed to be calling to her. She felt an inexplicable pull, as if something was urging her to follow it. And so, with a sense of curiosity and adventure, Sophia set off down the path, not knowing where it would lead...

Would you like me to continue the story?"""

##BF16:
##  ...in a far-off kingdom, where the sun dipped into the horizon and painted the sky with hues of crimson and gold, there lived a young adventurer named Sophia. She had hair as black as the night and eyes as blue as the clearest summer sky. Sophia was known throughout the land for her bravery, kindness, and insatiable curiosity.
## What would you like to happen next in the story? Would you like Sophia to:
## A) Embark on a quest to find a legendary treasure
## B) Encounter a mysterious stranger with a hidden agenda
## C) Discover a magical forest filled with ancient secrets
## D) Something entirely different (please specify)
## Choose your response to progress the story!

Evaluate the model

pip3 install lm-eval==0.4.7

we found lm-eval is very unstable for this model. Please set add_bos_token=True to align with the origin model.

lm-eval --model hf --model_args pretrained=OPEA/Llama-3.3-70B-Instruct-int3-sym-inc,add_bos_token=True   --tasks leaderboard_mmlu_pro,leaderboard_ifeval,lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,mmlu,gsm8k --batch_size 16
Metric BF16 INT3 INT3 wo bos
avg 0.7023 0.69675
leaderboard_mmlu_pro 5shot 0.5484 0.5155
leaderboard_ifeval+strict 0.6661=(0.7110+0.6211)/2 0.63885=(0.6954+0.5823)/2
mmlu 0.8195 0.8052
lambada_openai 0.7528 0.7617
hellaswag 0.6575 0.6491
winogrande 0.7869 0.8161
piqa 0.8303 0.8303
truthfulqa_mc1 0.4284 0.4333
openbookqa 0.3720 0.3620
boolq 0.8865 0.8911
arc_easy 0.8624 0.8523 0.2643
arc_challenge 0.6109 0.5956
gsm8k(5shot) strict match 0.9083 0.9067

Generate the model

Here is the sample command to reproduce the model.

auto-round  \
--model meta-llama/Llama-3.3-70B-Instruct \
--device 0 \
--group_size 64 \
--bits 3 \
--format 'auto_gptq' \
--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} }

arxiv github

Downloads last month
14
Safetensors
Model size
9.7B params
Tensor type
I32
·
BF16
·
Inference Providers NEW
This model is not currently available via any of the supported Inference Providers.
The model cannot be deployed to the HF Inference API: The model has no library tag.

Model tree for OPEA/Llama-3.3-70B-Instruct-int3-sym-inc

Quantized
(90)
this model

Dataset used to train OPEA/Llama-3.3-70B-Instruct-int3-sym-inc

Collection including OPEA/Llama-3.3-70B-Instruct-int3-sym-inc