Meta Llama 3.3 70B Instruct AWQ INT4
Llama 3.3 70B Instruct AWQ INT4 是 Meta Llama 3.3 70B Instruct 模型的 4 位量化版本,適用於多語言對話用例,優化了文本生成任務。
下載量 6,410
發布時間 : 12/7/2024
模型概述
這是一個預訓練並經過指令調優的 700 億參數生成模型,針對多語言對話用例進行了優化,支持多種語言,性能優於許多開源和閉源聊天模型。
模型特點
高效量化
使用 AutoAWQ 從 FP16 量化至 INT4,採用 GEMM 內核、零點量化和 128 的分組大小,顯著減少顯存佔用。
多語言支持
支持多種語言,包括英語、法語、意大利語、葡萄牙語、印地語、西班牙語、泰語和德語。
高性能
在常見的行業基準測試中表現優於許多開源和閉源聊天模型。
模型能力
多語言文本生成
對話系統
指令調優
使用案例
對話系統
多語言客服助手
用於構建支持多種語言的客服助手,提供高效、準確的回答。
優化了對話體驗,支持多語言交互。
內容生成
多語言內容創作
生成多語言的文章、報告或其他文本內容。
提高內容創作的效率和質量。
🚀 Llama 3.3 70B Instruct AWQ INT4量化模型
本項目提供了Llama 3.3 70B Instruct模型的AWQ 4位量化版本,可在不同框架下快速進行推理,同時介紹了量化過程的復現方法。
🚀 快速開始
本量化模型支持在transformers
、autoawq
、text-generation-inference
和vLLM
等不同解決方案中使用。在運行Llama 3.3 70B Instruct AWQ的INT4推理時,加載模型檢查點大約需要35 GiB的VRAM,且不包括KV緩存或CUDA圖,因此需要確保有足夠的VRAM可用。
✨ 主要特性
- 多語言支持:支持英語、法語、意大利語、葡萄牙語、印地語、西班牙語、泰語和德語等多種語言。
- 量化優化:使用AutoAWQ將模型從FP16量化到INT4,減少內存佔用,提高推理速度。
- 多框架兼容:可在
transformers
、autoawq
、text-generation-inference
和vLLM
等框架中使用。
📦 安裝指南
使用transformers
或autoawq
運行推理
pip install -q --upgrade transformers autoawq accelerate
使用text-generation-inference
運行推理
pip install -q --upgrade huggingface_hub
huggingface-cli login
使用vLLM
運行推理
需安裝Docker,參考安裝說明。
💻 使用示例
基礎用法
使用transformers
運行推理
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, AwqConfig
model_id = "ibnzterrell/Meta-Llama-3.3-70B-Instruct-AWQ-INT4"
quantization_config = AwqConfig(
bits=4,
fuse_max_seq_len=512, # Note: Update this as per your use-case
do_fuse=True,
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16,
low_cpu_mem_usage=True,
device_map="auto",
quantization_config=quantization_config
)
prompt = [
{"role": "system", "content": "You are a helpful assistant, that responds as a pirate."},
{"role": "user", "content": "What's Deep Learning?"},
]
inputs = tokenizer.apply_chat_template(
prompt,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt",
return_dict=True,
).to("cuda")
outputs = model.generate(**inputs, do_sample=True, max_new_tokens=256)
print(tokenizer.batch_decode(outputs[:, inputs['input_ids'].shape[1]:], skip_special_tokens=True)[0])
使用autoawq
運行推理
import torch
from awq import AutoAWQForCausalLM
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "ibnzterrell/Meta-Llama-3.3-70B-Instruct-AWQ-INT4"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoAWQForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.float16,
low_cpu_mem_usage=True,
device_map="auto",
)
prompt = [
{"role": "system", "content": "You are a helpful assistant, that responds as a pirate."},
{"role": "user", "content": "What's Deep Learning?"},
]
inputs = tokenizer.apply_chat_template(
prompt,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt",
return_dict=True,
).to("cuda")
outputs = model.generate(**inputs, do_sample=True, max_new_tokens=256)
print(tokenizer.batch_decode(outputs[:, inputs['input_ids'].shape[1]:], skip_special_tokens=True)[0])
高級用法
使用text-generation-inference
運行推理
docker run --gpus all --shm-size 1g -ti -p 8080:80 \
-v hf_cache:/data \
-e MODEL_ID=ibnzterrell/Meta-Llama-3.3-70B-Instruct-AWQ-INT4 \
-e NUM_SHARD=4 \
-e QUANTIZE=awq \
-e HF_TOKEN=$(cat ~/.cache/huggingface/token) \
-e MAX_INPUT_LENGTH=4000 \
-e MAX_TOTAL_TOKENS=4096 \
ghcr.io/huggingface/text-generation-inference:2.2.0
發送請求到部署的TGI端點:
curl 0.0.0.0:8080/v1/chat/completions \
-X POST \
-H 'Content-Type: application/json' \
-d '{
"model": "tgi",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is Deep Learning?"
}
],
"max_tokens": 128
}'
使用vLLM
運行推理
docker run --runtime nvidia --gpus all --ipc=host -p 8000:8000 \
-v hf_cache:/root/.cache/huggingface \
vllm/vllm-openai:latest \
--model ibnzterrell/Meta-Llama-3.3-70B-Instruct-AWQ-INT4 \
--tensor-parallel-size 4 \
--max-model-len 4096
發送請求到部署的vLLM端點:
curl 0.0.0.0:8000/v1/chat/completions \
-X POST \
-H 'Content-Type: application/json' \
-d '{
"model": "ibnzterrell/Meta-Llama-3.3-70B-Instruct-AWQ-INT4",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is Deep Learning?"
}
],
"max_tokens": 128
}'
📚 詳細文檔
原始模型信息
Meta Llama 3.3是一個70B參數的多語言大語言模型(LLM),經過預訓練和指令調優,適用於多語言對話場景,在常見行業基準測試中表現優於許多開源和閉源聊天模型。
量化復現信息
要使用AutoAWQ對Llama 3.3 70B Instruct進行量化,需要使用至少有足夠CPU RAM(約140GiB)來容納整個模型的實例,以及具有40GiB VRAM的NVIDIA GPU。
pip install -q --upgrade transformers autoawq accelerate
量化代碼示例:
from awq import AutoAWQForCausalLM
from transformers import AutoTokenizer
import torch
# Empty Cache
torch.cuda.empty_cache()
# Memory Limits - Set this according to your hardware limits
max_memory = {0: "22GiB", 1: "22GiB", "cpu": "160GiB"}
model_path = "meta-llama/Llama-3.3-70B-Instruct"
quant_path = "ibnzterrell/Meta-Llama-3.3-70B-Instruct-AWQ-INT4"
quant_config = {
"zero_point": True,
"q_group_size": 128,
"w_bit": 4,
"version": "GEMM"
}
# Load model - Note: while this loads the layers into the CPU, the GPUs (and the VRAM) are still required for quantization! (Verified with nvida-smi)
model = AutoAWQForCausalLM.from_pretrained(
model_path,
use_cache=False,
max_memory=max_memory,
device_map="cpu"
)
tokenizer = AutoTokenizer.from_pretrained(model_path)
# Quantize
model.quantize(
tokenizer,
quant_config=quant_config
)
# Save quantized model
model.save_quantized(quant_path)
tokenizer.save_pretrained(quant_path)
print(f'Model is quantized and saved at "{quant_path}"')
🔧 技術細節
本模型使用AutoAWQ將Llama 3.3 70B Instruct模型從FP16量化到INT4,採用GEMM內核,零點位量化,組大小為128。量化過程在單個節點上進行,該節點配備了Intel Xeon CPU E5 - 2699A v4 @ 2.40GHz、256GB的RAM和2塊NVIDIA RTX 3090(每塊24GB VRAM,總共48GB VRAM)。
📄 許可證
本項目使用的模型遵循llama3.3許可證。
Phi 2 GGUF
其他
Phi-2是微軟開發的一個小型但強大的語言模型,具有27億參數,專注於高效推理和高質量文本生成。
大型語言模型 支持多種語言
P
TheBloke
41.5M
205
Roberta Large
MIT
基於掩碼語言建模目標預訓練的大型英語語言模型,採用改進的BERT訓練方法
大型語言模型 英語
R
FacebookAI
19.4M
212
Distilbert Base Uncased
Apache-2.0
DistilBERT是BERT基礎模型的蒸餾版本,在保持相近性能的同時更輕量高效,適用於序列分類、標記分類等自然語言處理任務。
大型語言模型 英語
D
distilbert
11.1M
669
Llama 3.1 8B Instruct GGUF
Meta Llama 3.1 8B Instruct 是一個多語言大語言模型,針對多語言對話用例進行了優化,在常見的行業基準測試中表現優異。
大型語言模型 英語
L
modularai
9.7M
4
Xlm Roberta Base
MIT
XLM-RoBERTa是基於100種語言的2.5TB過濾CommonCrawl數據預訓練的多語言模型,採用掩碼語言建模目標進行訓練。
大型語言模型 支持多種語言
X
FacebookAI
9.6M
664
Roberta Base
MIT
基於Transformer架構的英語預訓練模型,通過掩碼語言建模目標在海量文本上訓練,支持文本特徵提取和下游任務微調
大型語言模型 英語
R
FacebookAI
9.3M
488
Opt 125m
其他
OPT是由Meta AI發佈的開放預訓練Transformer語言模型套件,參數量從1.25億到1750億,旨在對標GPT-3系列性能,同時促進大規模語言模型的開放研究。
大型語言模型 英語
O
facebook
6.3M
198
1
基於transformers庫的預訓練模型,適用於多種NLP任務
大型語言模型
Transformers

1
unslothai
6.2M
1
Llama 3.1 8B Instruct
Llama 3.1是Meta推出的多語言大語言模型系列,包含8B、70B和405B參數規模,支持8種語言和代碼生成,優化了多語言對話場景。
大型語言模型
Transformers 支持多種語言

L
meta-llama
5.7M
3,898
T5 Base
Apache-2.0
T5基礎版是由Google開發的文本到文本轉換Transformer模型,參數規模2.2億,支持多語言NLP任務。
大型語言模型 支持多種語言
T
google-t5
5.4M
702
精選推薦AI模型
Llama 3 Typhoon V1.5x 8b Instruct
專為泰語設計的80億參數指令模型,性能媲美GPT-3.5-turbo,優化了應用場景、檢索增強生成、受限生成和推理任務
大型語言模型
Transformers 支持多種語言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一個基於SODA數據集訓練的超小型對話模型,專為邊緣設備推理設計,體積僅為Cosmo-3B模型的2%左右。
對話系統
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基於RoBERTa架構的中文抽取式問答模型,適用於從給定文本中提取答案的任務。
問答系統 中文
R
uer
2,694
98