DeepSeek-V2-Chat-0628-gptq-4bit

我要开发同款
匿名用户2024年07月31日
19阅读
开发技术deepseek_v2、pytorch
所属分类ai
开源地址https://modelscope.cn/models/LLM-Research/DeepSeek-V2-Chat-0628-gptq-4bit

作品详情

This model has been quantized using GPTQModel.

  • bits: 4
  • group_size: 128
  • desc_act: true
  • static_groups: false
  • sym: true
  • lm_head: false
  • damp_percent: 0.01
  • true_sequential: true
  • modelnameor_path: ""
  • modelfilebase_name: "model"
  • quant_method: "gptq"
  • checkpoint_format: "gptq"
  • meta
  • quantizer: "gptqmodel:0.9.9-dev0"

You can use GPTQModel for model inference.

import torch
from transformers import AutoTokenizer, GenerationConfig
from gptqmodel import GPTQModel
model_name = "ModelCloud/DeepSeek-V2-Chat-0628-gptq-4bit"
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
# `max_memory` should be set based on your devices
max_memory = {i: "75GB" for i in range(2)}
# `device_map` cannot be set to `auto`
model = GPTQModel.from_quantized(model_name, trust_remote_code=True, device_map="sequential", max_memory=max_memory, torch_dtype=torch.float16, attn_implementation="eager")

model.generation_config = GenerationConfig.from_pretrained(model_name)
model.generation_config.pad_token_id = model.generation_config.eos_token_id

messages = [
    {"role": "user", "content": "Write a piece of quicksort code in C++"}
]
input_tensor = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
outputs = model.generate(input_ids=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
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论