OPEA
/

Safetensors
llama
4-bit precision
intel/auto-round

Model Card Details

This model is an int4 model with group_size 128 and symmetric quantization of nvidia/Llama-3.1-Nemotron-70B-Instruct-HF generated by intel/auto-round. Load the model with revision 77e8fae to use AutoGPTQ format

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/Llama-3.1-Nemotron-70B-Instruct-HF-int4-sym-inc"
tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)

model = AutoModelForCausalLM.from_pretrained(
    quantized_model_dir,
    torch_dtype='auto',
    device_map="auto",
    ##revision="77e8fae", ##AutoGPTQ format
)

##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
"""
Sounds like an exciting starting point! Let's build upon this. Here are a few potential directions to take this character and scenario, along with some questions to help narrow down the kind of assistance you might need. Please pick any that interest you, or feel free to add your own direction:

### Directions and Questions:

#### 1. **Character Development**
- **Goal:** Enhance the character's profile.
- **Questions:**
  - What is her age?
  - What kind of adventures is she drawn to (e.g., outdoor, fantasy quests, solving mysteries, space exploration)?
  - Are there any specific skills or traits you'd like her to have (e.g., bravery, intelligence, agility)?
  - Does she have any fears or weaknesses that could make her adventures more challenging?

#### 2. **Story Outline**
- **Goal:** Create a basic story outline featuring this adventurous girl.
- **Questions:**
  - What's the setting for her adventure (e.g
"""

##BF16 
"""
Sounds like an exciting start! Let's build upon this. Here are a few potential directions to take this character and scenario, along with some questions to help narrow down the kind of assistance you might need. Please pick any that interest you, or feel free to add your own direction:

### Directions and Questions:

#### 1. **Fantasy Adventure**
- **Setting:** Perhaps in a mystical realm, a futuristic world, or a historical era.
- **Quest:** Is she on a quest for a legendary artifact, to save a kingdom, or to uncover a hidden truth?
- **Special Abilities:** Does she possess any unique skills or magical powers that aid her in her adventures?

#### 2. **Real-World Expedition**
- **Location:** Is her adventure set in the wilderness, a foreign country, or perhaps an urban jungle?
- **Challenge:** Is she facing a survival challenge, a cultural immersion, or a mystery to solve?
- **Companions:** Does she embark on
"""

##prompt = "Which one is larger, 9.11 or 9.8"
## INT4
"""
A simple comparison!

Let's break it down:

* **9.11**
    + Whole number part: 9
    + Decimal part: 0.11
* **9.8**
    + Whole number part: 9
    + Decimal part: 0.8

Since the whole number part is the same for both (9), we compare the decimal parts:

* **0.11** (from 9.11) is **less than** **0.8** (from 9.8)

Therefore, the answer is:

**9.8 is larger than 9.11**
"""

## BF16
"""A simple comparison!

Let's break it down:

* **9.11**
    + Whole number part: 9
    + Decimal part: 0.11
* **9.8**
    + Whole number part: 9
    + Decimal part: 0.8

Since the whole number part is the same for both (9), we compare the decimal parts:

* **0.11** (eleven hundredths)
* **0.8** (eight tenths, which is equivalent to 80 hundredths)

**Comparison:**
0.11 (11 hundredths) < 0.8 (80 hundredths)

**Result:**
**9.8 is larger than 9.11** """

prompt = "How many r in strawberry."
## INT4
"""
A simple but sweet question!

Let's count the "R"s in the word "strawberry":

1. S
2. T
3. R
4. A
5. W
6. B
7. E
8. R
9. R
10. Y

There are **3** "R"s in the word "strawberry".
"""
## BF16
"""
A simple but sweet question!

Let's count the "R"s in "strawberry":

1. S
2. T
3. R
4. A
5. W
6. B
7. E
8. R
9. R
10. Y

There are **3** "R"s in the word "strawberry".
"""

##prompt = "Once upon a time,"
## INT4
"""
It seems like we're about to embark on a delightful journey into the realm of storytelling! "Once upon a time" is a classic opening phrase that invites us into a world of fantasy, adventure, or perhaps a timeless tale. Let's see where this story might go! Here are a few directions we could take, and you can choose which one sparks your interest the most, or feel free to guide the story in a completely different direction:

### 1. **The Mysterious Forest**
- **Story Start**: Once upon a time, in a land far, far away, there was a mysterious forest that appeared only under the light of a full moon. The forest was said to be inhabited by magical creatures and hidden wonders. One brave adventurer, named [**Your Choice of Name**], decided to explore its secrets.

### 2. **The Lost Kingdom**
- **Story Start**: Once upon a time, beneath the waves of the ocean, there lay a lost kingdom hidden from the
"""
## BF16 
"""
It seems like we're about to embark on a delightful adventure! "Once upon a time" is a classic opening to many a tale. Let's see where the story takes us. Here are a few ways we can proceed:

1. **You Continue the Story**: Please go ahead and add the next sentence or paragraph to our tale. I'll respond with the next part, and so on.
   
2. **Choose a Theme**: If you'd like, you can give me a theme or genre for our story (e.g., fantasy, mystery, sci-fi, romance, etc.), and I'll start adding to "Once upon a time" accordingly.

3. **Provide Story Elements**: Share some elements you'd like to see in the story (e.g., specific characters, locations, magical objects, etc.), and I'll weave them into our narrative.

4. **I'll Take the Lead**: If you're feeling adventurous, I can simply continue the story in a surprise direction.
"""

Evaluate the model

pip3 install lm-eval==0.4.5

 auto-round --eval --model "OPEA/Llama-3.1-Nemotron-70B-Instruct-HF-int4-sym-inc" --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 BF16 INT4
avg 0.6918 0.6948
leaderboard_mmlu_pro 5shot 0.5381 0.5324
leaderboard_ifeval 0.7146=(0.7638+0.6654)/2 0.7491=(0.7938+0.7043)/2
lambada_openai 0.7520 0.7535
hellaswag 0.6580 0.6530
winogrande 0.7853 0.7916
piqa 0.8351 0.8297
truthfulqa_mc1 0.4517 0.4517
openbookqa 0.3700 0.3620
boolq 0.8768 0.8768
arc_easy 0.8611 0.8586
arc_challenge 0.6271 0.6143
gsm8k(5shot) strict match 0.8317 0.8643

Generate the model

Here is the sample command to reproduce the model. We found auto-round is not stable for this model, please do NOT use --model_dtype "fp16"

auto-round  \
--model nvidia/Llama-3.1-Nemotron-70B-Instruct-HF \
--device 0 \
--group_size 128 \
--nsamples 512 \
--bits 4 \
--iter 1000 \
--disable_eval \
--low_gpu_mem_usage \
--format 'auto_gptq,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} }

arxiv github

Downloads last month
9
Safetensors
Model size
11.3B params
Tensor type
BF16
·
I32
·
FP16
·
Inference API
Unable to determine this model's library. Check the docs .

Dataset used to train OPEA/Llama-3.1-Nemotron-70B-Instruct-HF-int4-sym-inc

Collection including OPEA/Llama-3.1-Nemotron-70B-Instruct-HF-int4-sym-inc