HuggingFace镜像/CodeQwen1.5-7B-Chat
模型介绍文件和版本分析
下载使用量0

CodeQwen1.5-7B-Chat

简介

CodeQwen1.5是Qwen1.5的代码专精版本,它是一个基于Transformer架构的解码器仅模型,经过大量代码数据预训练。

  • 拥有强大的代码生成能力,并在一系列基准测试中展现出竞争性的表现;
  • 支持长达64K令牌的上下文理解与生成;
  • 支持92种编程语言;
  • 在文本到SQL转换、错误修复等方面表现出色。

更多详情,请参考我们的博客文章和GitHub仓库。

模型详细信息

CodeQwen1.5源于Qwen1.5系列,该系列包括不同规模的解码器语言模型。它基于3万亿个代码标记的数据训练而成,集成了组查询注意力(GQA)以实现高效推理。

系统需求

Qwen1.5的代码已集成至最新的Hugging Face Transformers库。建议安装transformers>=4.37.0,以免遇到以下错误:

KeyError: 'qwen2'.

快速入门

这里提供了一个包含 apply_chat_template 的代码片段,展示了如何加载分词器和模型,以及如何生成内容。

from transformers import AutoModelForCausalLM, AutoTokenizer
device = "cuda" # the device to load the model onto

model = AutoModelForCausalLM.from_pretrained(
    "Qwen/CodeQwen1.5-7B-Chat",
    torch_dtype="auto",
    device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("Qwen/CodeQwen1.5-7B-Chat")

prompt = "Write a quicksort algorithm in python."
messages = [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(device)

generated_ids = model.generate(
    model_inputs.input_ids,
    max_new_tokens=512
)
generated_ids = [
    output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]

response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]

提示

  • 如果您遇到代码切换或其他不良情况,建议您使用我们在 generation_config.json 中提供的超参数。

引用

如果您觉得我们的工作对您有帮助,欢迎引用我们的成果。

@article{qwen,
  title={Qwen Technical Report},
  author={Jinze Bai and Shuai Bai and Yunfei Chu and Zeyu Cui and Kai Dang and Xiaodong Deng and Yang Fan and Wenbin Ge and Yu Han and Fei Huang and Binyuan Hui and Luo Ji and Mei Li and Junyang Lin and Runji Lin and Dayiheng Liu and Gao Liu and Chengqiang Lu and Keming Lu and Jianxin Ma and Rui Men and Xingzhang Ren and Xuancheng Ren and Chuanqi Tan and Sinan Tan and Jianhong Tu and Peng Wang and Shijie Wang and Wei Wang and Shengguang Wu and Benfeng Xu and Jin Xu and An Yang and Hao Yang and Jian Yang and Shusheng Yang and Yang Yao and Bowen Yu and Hongyi Yuan and Zheng Yuan and Jianwei Zhang and Xingxuan Zhang and Yichang Zhang and Zhenru Zhang and Chang Zhou and Jingren Zhou and Xiaohuan Zhou and Tianhang Zhu},
  journal={arXiv preprint arXiv:2309.16609},
  year={2023}
}

使用指南

安装

  1. 下载:从 官方网站 下载最新版本的 installer.exe。
  2. 运行:双击 installer.exe 并按照屏幕上的指示完成安装。

配置

环境变量

在 PATH 中添加以下路径:

C:\Program Files\MyApp\bin

配置文件

编辑 config.yaml 文件以设置应用程序参数:

api_key: "your_api_key_here"
log_level: "INFO"

运行

启动应用程序

在命令行中运行以下命令:

myapp start

停止应用程序

使用以下命令停止应用程序:

myapp stop

常见问题

无法启动

确保 config.yaml 文件中的 api_key 是正确的。

性能问题

尝试增加 config.yaml 中的 log_level 为 DEBUG 以获取更多调试信息。

支持

如有任何问题,请联系我们的支持团队:support@example.com。