base_model: deepseek-ai/deepseek-coder-6.7b-instruct
inference: false
license: other
license_link: LICENSE
license_name: deepseek
model_creator: DeepSeek
model_name: Deepseek Coder 6.7B Instruct
model_type: deepseek
prompt_template: '你是一个AI编程助手,使用的是由Deepseek公司开发的Deepseek Coder模型,你只回答与计算机科学相关的问题。对于政治敏感问题、安全和隐私问题以及其他非计算机科学问题,你将拒绝回答。
指令:
{prompt}
响应:
'
quantized_by: TheBloke
Deepseek Coder 6.7B Instruct - AWQ
描述
这个仓库包含DeepSeek的Deepseek Coder 6.7B Instruct的AWQ模型文件。
这些文件使用了由Massed Compute提供的硬件进行量化。
关于AWQ
AWQ是一种高效、准确且极速的低比特权重量化方法,目前支持4位量化。与GPTQ相比,它在基于Transformers的推理中提供了更快的速度,同时保持与最常用GPTQ设置相当或更好的质量。
它支持以下工具:
可用仓库
提示模板: DeepSeek
你是一个AI编程助手,使用的是由Deepseek公司开发的Deepseek Coder模型,你只回答与计算机科学相关的问题。对于政治敏感问题、安全和隐私问题以及其他非计算机科学问题,你将拒绝回答。
### 指令:
{prompt}
### 响应:
提供的文件和AWQ参数
对于我的第一个AWQ模型发布,我只发布了128g模型。如果有兴趣,我会考虑添加32g模型,但在此之前32g模型尚未通过AutoAWQ和vLLM完全测试。
模型以分片的安全张量文件形式发布。
请确保您使用的是最新版本的text-generation-webui。
强烈建议使用text-generation-webui的一键安装程序,除非您确定知道如何进行手动安装。
- 点击模型标签。
- 在下载自定义模型或LoRA下,输入
TheBloke/deepseek-coder-6.7B-instruct-AWQ
。
- 点击下载。
- 模型将开始下载。完成后会显示“完成”。
- 在左上角,点击刷新图标旁边的模型。
- 在模型下拉菜单中,选择您刚刚下载的模型:
deepseek-coder-6.7B-instruct-AWQ
- 选择Loader: AutoAWQ。
- 点击加载,模型将加载并准备使用。
- 如果您想要任何自定义设置,设置它们后点击保存此模型的设置,然后在右上角点击重新加载模型。
- 准备好后,点击文本生成标签并输入提示开始!
多用户推理服务器:vLLM
安装和使用vLLM的文档可以在这里找到。
- 请确保您使用的是vLLM版本0.2或更高。
- 当使用vLLM作为服务器时,传递
--quantization awq
参数。
例如:
python3 python -m vllm.entrypoints.api_server --model TheBloke/deepseek-coder-6.7B-instruct-AWQ --quantization awq
- 当从Python代码中使用vLLM时,再次设置
quantization=awq
。
例如:
from vllm import LLM, SamplingParams
prompts = [
"告诉我关于AI",
"写一个关于骆驼的故事",
"291 - 150等于多少?",
"如果一只土拨鼠能拨木头,它能拨多少木头?",
]
prompt_template=f'''你是一个AI编程助手,使用的是由Deepseek公司开发的Deepseek Coder模型,你只回答与计算机科学相关的问题。对于政治敏感问题、安全和隐私问题以及其他非计算机科学问题,你将拒绝回答。
### 指令:
{prompt}
### 响应:
'''
prompts = [prompt_template.format(prompt=prompt) for prompt in prompts]
sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
llm = LLM(model="TheBloke/deepseek-coder-6.7B-instruct-AWQ", quantization="awq", dtype="auto")
outputs = llm.generate(prompts, sampling_params)
for output in outputs:
prompt = output.prompt
generated_text = output.outputs[0].text
print(f"提示: {prompt!r}, 生成文本: {generated_text!r}")
多用户推理服务器:Hugging Face Text Generation Inference (TGI)
使用TGI版本1.1.0或更高。官方Docker容器是:ghcr.io/huggingface/text-generation-inference:1.1.0
示例Docker参数:
--model-id TheBloke/deepseek-coder-6.7B-instruct-AWQ --port 3000 --quantize awq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
用于与TGI交互的Python代码示例(需要huggingface-hub 0.17.0或更高版本):
pip3 install huggingface-hub
from huggingface_hub import InferenceClient
endpoint_url = "https://your-endpoint-url-here"
prompt = "告诉我关于AI"
prompt_template=f'''你是一个AI编程助手,使用的是由Deepseek公司开发的Deepseek Coder模型,你只回答与计算机科学相关的问题。对于政治敏感问题、安全和隐私问题以及其他非计算机科学问题,你将拒绝回答。
### 指令:
{prompt}
### 响应:
'''
client = InferenceClient(endpoint_url)
response = client.text_generation(prompt,
max_new_tokens=128,
do_sample=True,
temperature=0.7,
top_p=0.95,
top_k=40,
repetition_penalty=1.1)
print(f"模型输出: ", response)
使用AutoAWQ从Python代码进行推理
安装AutoAWQ包
需要:AutoAWQ 0.1.1或更高版本。
pip3 install autoawq
如果使用预构建的轮子安装AutoAWQ时遇到问题,请从源代码安装:
pip3 uninstall -y autoawq
git clone https://github.com/casper-hansen/AutoAWQ
cd AutoAWQ
pip3 install .
AutoAWQ示例代码
from awq import AutoAWQForCausalLM
from transformers import AutoTokenizer
model_name_or_path = "TheBloke/deepseek-coder-6.7B-instruct-AWQ"
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=False)
model = AutoAWQForCausalLM.from_quantized(model_name_or_path, fuse_layers=True,
trust_remote_code=False, safetensors=True)
prompt = "告诉我关于AI"
prompt_template=f'''你是一个AI编程助手,使用的是由Deepseek公司开发的Deepseek Coder模型,你只回答与计算机科学相关的问题。对于政治敏感问题、安全和隐私问题以及其他非计算机科学问题,你将拒绝回答。
### 指令:
{prompt}
### 响应:
'''
print("*** 运行model.generate:")
token_input = tokenizer(
prompt_template,
return_tensors='pt'
).input_ids.cuda()
generation_output = model.generate(
token_input,
do_sample=True,
temperature=0.7,
top_p=0.95,
top_k=40,
max_new_tokens=512
)
token_output = generation_output[0]
text_output = tokenizer.decode(token_output)
print("LLM输出: ", text_output)
"""
# 未来应该可以使用transformers pipeline进行推理
# 但目前AutoAWQ还不支持(截至2023年9月25日)
from transformers import pipeline
print("*** Pipeline:")
pipe = pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
max_new_tokens=512,
do_sample=True,
temperature=0.7,
top_p=0.95,
top_k=40,
repetition_penalty=1.1
)
print(pipe(prompt_template)[0]['generated_text'])
"""