Llama 3.1 Nemotron 70B Instruct AWQ INT4
模型简介
模型特点
模型能力
使用案例
🚀 Llama-3.1-Nemotron-70B-Instruct模型
本项目是对Llama-3.1-Nemotron-70B-Instruct模型进行的AWQ Int4量化,该模型由NVIDIA定制,能有效提升大语言模型对用户查询响应的有效性。
🚀 快速开始
复现量化结果
若要复现此模型,请运行以下代码:
from awq import AutoAWQForCausalLM
from transformers import AutoTokenizer
model_path = "nvidia/Llama-3.1-Nemotron-70B-Instruct/"
quant_path = "./quantized/Llama-3.1-Nemotron-70B-Instruct-AWQ-INT4"
quant_config = {
"zero_point": True,
"q_group_size": 128,
"w_bit": 4,
"version": "GEMM",
}
# 加载模型
model = AutoAWQForCausalLM.from_pretrained(
model_path, low_cpu_mem_usage=True, use_cache=False,
)
tokenizer = AutoTokenizer.from_pretrained(model_path)
# 量化模型
model.quantize(tokenizer, quant_config=quant_config)
# 保存量化后的模型
model.save_quantized(quant_path)
tokenizer.save_pretrained(quant_path)
print(f'Model is quantized and saved at "{quant_path}"')
故障排除
若在多GPU机器上运行时遇到错误,可尝试设置CUDA_VISIBLE_DEVICES=0
。
使用模型
你可以使用HuggingFace Transformers库来使用该模型,需要2块或更多80GB的GPU(NVIDIA Ampere或更新版本),并至少有150GB的可用磁盘空间以完成下载。
此代码已在Transformers v4.44.0、torch v2.4.0和2块A100 80GB GPU上进行测试,但任何支持meta-llama/Llama-3.1-70B-Instruct
的设置也应支持此模型。若遇到问题,可考虑执行pip install -U transformers
。
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "nvidia/Llama-3.1-Nemotron-70B-Instruct-HF"
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(model_name)
prompt = "How many r in strawberry?"
messages = [{"role": "user", "content": prompt}]
tokenized_message = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt", return_dict=True)
response_token_ids = model.generate(tokenized_message['input_ids'].cuda(),attention_mask=tokenized_message['attention_mask'].cuda(), max_new_tokens=4096, pad_token_id = tokenizer.eos_token_id)
generated_tokens =response_token_ids[:, len(tokenized_message['input_ids'][0]):]
generated_text = tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)[0]
print(generated_text)
# 查看模型卡片顶部的响应
✨ 主要特性
- 高性能表现:在多个自动对齐基准测试中表现出色,截至2024年10月1日,在Arena Hard、AlpacaEval 2 LC(验证标签)和MT Bench(GPT-4-Turbo)中表现最佳。
- 提升响应质量:由NVIDIA定制,可提高大语言模型生成的响应对用户查询的有效性。
- 支持多语言:支持英语、德语、法语、意大利语、葡萄牙语、印地语、西班牙语和泰语等多种语言。
📦 安装指南
使用该模型需要安装HuggingFace Transformers库,若遇到问题,可执行pip install -U transformers
。
💻 使用示例
基础用法
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "nvidia/Llama-3.1-Nemotron-70B-Instruct-HF"
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(model_name)
prompt = "How many r in strawberry?"
messages = [{"role": "user", "content": prompt}]
tokenized_message = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt", return_dict=True)
response_token_ids = model.generate(tokenized_message['input_ids'].cuda(),attention_mask=tokenized_message['attention_mask'].cuda(), max_new_tokens=4096, pad_token_id = tokenizer.eos_token_id)
generated_tokens =response_token_ids[:, len(tokenized_message['input_ids'][0]):]
generated_text = tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)[0]
print(generated_text)
📚 详细文档
模型描述
Llama-3.1-Nemotron-70B-Instruct是NVIDIA定制的大语言模型,旨在提高大语言模型生成的响应对用户查询的有效性。该模型在多个自动对齐基准测试中表现出色,截至2024年10月1日,在Arena Hard、AlpacaEval 2 LC(验证标签)和MT Bench(GPT-4-Turbo)中排名第一,超过了GPT-4o和Claude 3.5 Sonnet等强大的前沿模型。
评估指标
模型 | Arena Hard(95% CI) | AlpacaEval 2 LC(SE) | MT-Bench(GPT-4-Turbo) | 平均响应长度(MT-Bench字符数) |
---|---|---|---|---|
Llama-3.1-Nemotron-70B-Instruct | 85.0 (-1.5, 1.5) | 57.6 (1.65) | 8.98 | 2199.8 |
Llama-3.1-70B-Instruct | 55.7 (-2.9, 2.7) | 38.1 (0.90) | 8.22 | 1728.6 |
Llama-3.1-405B-Instruct | 69.3 (-2.4, 2.2) | 39.3 (1.43) | 8.49 | 1664.7 |
Claude-3-5-Sonnet-20240620 | 79.2 (-1.9, 1.7) | 52.4 (1.47) | 8.81 | 1619.9 |
GPT-4o-2024-05-13 | 79.3 (-2.1, 2.0) | 57.5 (1.47) | 8.74 | 1752.2 |
术语使用
访问此模型即表示你同意许可证、可接受使用政策和Meta的隐私政策的LLama 3.1条款和条件。
引用
若你发现此模型有用,请引用以下作品:
@misc{wang2024helpsteer2preferencecomplementingratingspreferences,
title={HelpSteer2-Preference: Complementing Ratings with Preferences},
author={Zhilin Wang and Alexander Bukharin and Olivier Delalleau and Daniel Egert and Gerald Shen and Jiaqi Zeng and Oleksii Kuchaiev and Yi Dong},
year={2024},
eprint={2410.01257},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2410.01257},
}
🔧 技术细节
模型架构
属性 | 详情 |
---|---|
架构类型 | Transformer |
网络架构 | Llama 3.1 |
输入
属性 | 详情 |
---|---|
输入类型 | 文本 |
输入格式 | 字符串 |
输入参数 | 一维(1D) |
其他输入相关属性 | 最大128k个令牌 |
输出
属性 | 详情 |
---|---|
输出类型 | 文本 |
输出格式 | 字符串 |
输出参数 | 一维(1D) |
其他输出相关属性 | 最大4k个令牌 |
软件集成
属性 | 详情 |
---|---|
支持的硬件微架构兼容性 | NVIDIA Ampere、NVIDIA Hopper、NVIDIA Turing |
支持的操作系统 | Linux |
模型版本
v1.0
训练与评估
对齐方法
在NeMo Aligner中实现的REINFORCE算法。
数据集
属性 | 详情 |
---|---|
数据收集方法 | 混合:人工、合成 |
标注方法 | 人工 |
链接 | HelpSteer2 |
属性(数量、数据集描述、传感器) | 21,362个提示-响应,用于使更多模型更符合人类偏好,特别是更有帮助、事实准确、连贯,并可根据复杂性和详细程度进行定制。其中20,324个提示-响应用于训练,1,038个用于验证。 |
推理
属性 | 详情 |
---|---|
推理引擎 | Triton |
测试硬件 | H100、A100 80GB、A100 40GB |
📄 许可证
使用此模型需遵循LLama 3.1的相关条款和条件,包括许可证、可接受使用政策和Meta的隐私政策。
⚠️ 重要提示
本模型是我们改进通用领域指令遵循的有用性技术的演示,尚未针对数学等专业领域的性能进行调整。
💡 使用建议
开发者在下载或使用此模型时,应与支持的模型团队合作,确保该模型满足相关行业和用例的要求,并解决不可预见的产品滥用问题。若发现安全漏洞或NVIDIA AI相关问题,请在此报告。



