该模型当前使用的是默认介绍模版,处于“预发布”阶段,页面仅限所有者可见。
请根据模型贡献文档说明,及时完善模型卡片内容。ModelScope平台将在模型卡片完善后展示。谢谢您的理解。
Clone with HTTP
git clone https://www.modelscope.cn/huahua321123/coder.git
Training procedure
Framework versions
- SWIFT 1.5.3
Base model information
- BaseModel Class QWenLMHeadModel
system 字段:你是一个代码编写小助手 数据集:leetcode-python-en codefuse-python-en code-alpaca-en 训练方式:lora 秩:8 自我认知:模型名称:coder 作者:hua 微调示例: import os
设置CUDA环境变量,指定使用的GPU
os.environ['CUDAVISIBLEDEVICES'] = '0'
from swift.llm import DatasetName, ModelType, SftArguments, sft_main
设置微调参数
sftargs = SftArguments( modeltype=ModelType.qwen7bchat, # 指定模型类型 dataset=[ DatasetName.alpacazh, DatasetName.alpacaen, DatasetName.codealpacaen, DatasetName.leetcodepythonen, DatasetName.codefusepythonen, DatasetName.codefuseevolinstructionzh ], # 使用的数据集列表 traindatasetsample=500, # 训练样本数量 evalsteps=20, # 评估步数 loggingsteps=5, # 日志记录步数 outputdir='output', # 输出目录 loratargetmodules='ALL', # LoRA目标模块 selfcognitionsample=500, # 自我认知样本数 modelname=['miovo的代码助手', 'codingassistantofLiu Wenjie'], # 模型名称 model_author=['moiovo', 'Li Jiaxin'] # 模型作者 )
执行微调
output = sftmain(sftargs) bestmodelcheckpoint = output['bestmodelcheckpoint'] print(f'bestmodelcheckpoint: {bestmodelcheckpoint}') 推理示例: import os
设置CUDA环境变量,指定使用的GPU
os.environ['CUDAVISIBLEDEVICES'] = '0'
from swift.llm import InferArguments, infer_main
设置推理模型的检查点路径
bestmodelcheckpoint = '/mnt/workspace/later/output/qwen-7b-chat/v0-20240127-195908/checkpoint-40'
设置推理参数
inferargs = InferArguments( ckptdir=bestmodelcheckpoint, # 模型检查点路径 eval_human=True # 设置为人类评估模式 )
执行推理
result = infermain(inferargs) 测试: 请用python编写快排代码 这是一个使用Python编写的快速排序算法:
def quicksort(arr):
if len(arr) <= 1:
return arr
pivot = arr[len(arr) // 2]
left = [x for x in arr if x < pivot]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]
return quicksort(left) + middle + quicksort(right)
# 测试
arr = [3,6,8,10,1,2,1]
print(quicksort(arr))
评论