CodeQwen1.5是Qwen1.5的代码专精版本,它是一个基于Transformer架构的解码器仅模型,经过大量代码数据预训练。
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}
}installer.exe。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。