hf_mirrors/CodeQwen1.5-7B-Chat
Model Introduction
Files & versions
Analysis

CodeQwen1.5-7B-Chat

Introduction

CodeQwen1.5 is the Code-Specific version of Qwen1.5. It is a transformer-based decoder-only language model pretrained on a large amount of data of codes.

  • Strong code generation capabilities and competitve performance across a series of benchmarks;
  • Supporting long context understanding and generation with the context length of 64K tokens;
  • Supporting 92 coding languages
  • Excellent performance on text-to-SQL, bug fix, etc.

Model Details

CodeQwen1.5 is based on Qwen1.5, a language model series including decoder language models of different model sizes. It is trained on 3 trillion tokens of data of codes, and it includes group query attention (GQA) for efficient inference.

import torch
from torch import nn
from openmind import AutoTokenizer, AutoModelForCausalLM
model_id = "/home/ma-user/work/model/Qwen/CodeQwen1___5-7B-Chat"

tokenizer = AutoTokenizer.from_pretrained(model_id)

# 加载预训练模型
model = AutoModelForCausalLM.from_pretrained(
    model_id
).to('npu')  # 将模型移动到NPU上

# 文本输入
input_text = "Write a quicksort algorithm in python."

# 对输入文本进行编码
input_ids = tokenizer.encode(input_text, return_tensors='pt').to('npu')

# 生成文本
output = model.generate(input_ids, max_length=200)

# 解码输出
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
print(generated_text)