零一万物-1.5-9B-Chat-16K-GPTQ-Int3-量化修复

我要开发同款
匿名用户2024年07月31日
39阅读
所属分类ai、llama、Pytorch、vLLM、量化修复、int3、gptq、yi
开源地址https://modelscope.cn/models/tclf90/Yi-1.5-9B-Chat-16K-GPTQ-Int3
授权协议other

作品详情

零一万物-1.5-9B-Chat-16K-GPTQ-Int3-量化修复

原模型 01ai/Yi-1.5-9B-Chat-16K

【模型更新日期】

2024-05-25

【模型大小】

4.4GB

【量化修复】

调优了现有 AWQGPTQ 量化算法的量化策略。带有量化修复标签的Int3模型,可以比肩默认AWQGPTQ算法的Int8模型的能力。

  1. 量化修复可以极大减少模型的1.乱吐字2.无限循环3.长文能力丢失等量化损失造成的模型不可用的情况。

  2. 调优后的量化模型,AWQGPTQ模型在能力上没有表现出明显区别。同时考虑到GPTQvLLM引擎的并发推理效率最好,所以不再制作AWQ模型。

  3. 调优后的量化模型,int4int3模型在能力上没有表现出明显区别,所以也不再制作int4模型。

【同期量化修复模型】

模型名称 磁盘大小(GB)
零一万物-1.5-6B-Chat-GPTQ-Int3-量化修复 3.3
零一万物-1.5-9B-Chat-16K-GPTQ-Int3-量化修复 4.4
零一万物-1.5-34B-Chat-16K-GPTQ-Int3-量化修复 15.1
通义千问1.5-7B-Chat-GPTQ-Int3-量化修复 5.1
通义千问1.5-14B-Chat-GPTQ-Int3-量化修复 8.1
通义千问1.5-32B-Chat-GPTQ-Int3-量化修复 15.4
通义千问1.5-72B-Chat-GPTQ-Int3-量化修复 32.5
通义千问1.5-110B-Chat-GPTQ-Int3-量化修复 47.9
openbuddy-llama3-70b-v21.1-8k-GPTQ-Int3-量化修复 31.5

【模型下载】

from modelscope import snapshot_download
model_dir = snapshot_download('tclf90/模型名', cache_dir="本地路径")

vLLM推理(目前仅限Linux)】

1. Python 简易调试

from transformers import AutoTokenizer
from vllm import LLM, SamplingParams

max_model_len, tp_size = 4000, 1
model_name = "本地路径/tclf90/模型名称"   # 例:"./my_models/tclf90/Qwen1.5-32B-Chat-GPTQ-Int3"
model_name = model_name.replace('.', '___')
tokenizer = AutoTokenizer.from_pretrained(model_name)
llm = LLM(model=model_name, tensor_parallel_size=tp_size, max_model_len=max_model_len, trust_remote_code=True, enforce_eager=True)
sampling_params = SamplingParams(temperature=0.7, max_tokens=256, stop_token_ids=[tokenizer.eos_token_id])

messages_list = [
    [{"role": "user", "content": "你是谁"}],
    [{"role": "user", "content": "介绍一下你自己"}],
    [{"role": "user", "content": "用python写一个快排函数"}],
]

prompt_token_ids = [tokenizer.apply_chat_template(messages, add_generation_prompt=True) for messages in messages_list]

outputs = llm.generate(prompt_token_ids=prompt_token_ids, sampling_params=sampling_params)

generated_text = [output.outputs[0].text for output in outputs]
print(generated_text)

2. 类ChatGPT RESTFul API Server

>>> python -m vllm.entrypoints.openai.api_server --model 本地路径/tclf90/模型名称

【Transformer推理】

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig

model_name = "本地路径/tclf90/模型名称"   # 例:"./my_models/tclf90/Qwen1.5-32B-Chat-GPTQ-Int3"
model_name = model_name.replace('.', '___')
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True, torch_dtype=torch.bfloat16).cuda()
model.generation_config = GenerationConfig.from_pretrained(model_name)
model.generation_config.pad_token_id = model.generation_config.eos_token_id

messages = [
    {"role": "user", "content": "你好你是谁"}
]
input_tensor = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
outputs = model.generate(input_tensor.to(model.device), max_new_tokens=100)

result = tokenizer.decode(outputs[0][input_tensor.shape[1]:], skip_special_tokens=True)
print(result)
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论