---
title: code_helper
canonical_url: "https://www.modelscope.cn/models/thunderFire/code_helper"
md_url: "https://www.modelscope.cn/models/thunderFire/code_helper.md"
repository: thunderFire/code_helper
chinese_name: "代码助手"
last_updated: 2024-01-24
pipeline_tag: text-generation
tasks:
  - text-generation
parameters: 6.7M
tensor_type:
  - F32
library_name:
  - safetensors
  - pytorch
frameworks:
  - pytorch
downloads: 64
stars: 3
---

# code_helper

> code_helper - thunderFire 在 ModelScope 开源的模型。大模型训练营作业

- **Repository**: thunderFire/code_helper
- **Tasks**: text-generation
- **Parameters**: 6.7M
- **Downloads**: 64
- **Stars**: 3
- **Last updated**: 2024-01-24

Source: https://www.modelscope.cn/models/thunderFire/code_helper

---

## 模型简介

- 模型名称：代码助手
- 简介：帮助使用者生成指定的算法代码，可用不同的语言，**支持多轮对话**，**有自我认知能力**。

## 实验环境

- 显存：32GB，显存带宽：24G
- 环境：ModelScope Library
- 环境详情：ubuntu22.04-cuda12.1.0-py310-torch2.1.2

## 数据集和模型

- 选择模型： "gwen-1_b8"。
- 数据集：
  - alpaca-zh
  - ai4shell-mini-zh
  - code-alpaca-cn
  - codefuse-python-en
  - leetcode-python-en
  - codefuse-evol-instruction-zh

## 超参数设置



- LoRA超参数配置：
  - LoRA秩（Rank）：8
  - LoRA的alpha：32
  - LoRA的dropout：0.05
- 训练参数：
  - 训练时batch size：5
  - 学习率（Learning Rate）：1e-5
  - 优化器（Optimizer）：adamw_torch
  - 优化器权重衰减（Weight Decay）：0.01
  - 优化器beta1：0.9
  - 优化器beta2：0.999
  - 优化器epsilon：1e-8
  - 训练数据集大小：2048
  - 训练集上限：不限制
  - 预热步数（Warmup Steps）：5
  - 最大训练步数：1
  - 梯度累积步数（Gradient Accumulation Steps）：1
- 验证参数：
  - 验证时batch size：1
  - 验证数据集大小：50
  - 验证步数：0.5
- 损失函数配置：
  - 使用交叉熵损失函数（Cross Entropy Loss）
- 优化器配置：
  - 学习率调度器（Lr Scheduler）：linear
  - 学习率Warmup比例（Lr Warmup Ratio）：0.05

## 示例代码

使用swift web_ui进行参数配置。

![image-20240124142501771](image-20240124142501771.png)

## 推理内容

使用web_ui进行推理

![image-20240124142652365](image-20240124142652365.png)

具有自我认知能力和多轮对话：

![image-20240124142722898](image-20240124142722898.png)

可以实现多种语言的代码生成：

![image-20240124142806285](image-20240124142806285.png)

## 对比实验

经过对比发现，微调后的模型在以下方面比原模型有较大提升：

- 自我认知与多轮对话
- 代码理解和生成
- 中文理解

原模型：![image-20240124143442061](image-20240124143442061.png)
