---
title: zhangxiaobai_shishen2_full
canonical_url: "https://www.modelscope.cn/models/zhanghuiATchina/zhangxiaobai_shishen2_full"
md_url: "https://www.modelscope.cn/models/zhanghuiATchina/zhangxiaobai_shishen2_full.md"
repository: zhanghuiATchina/zhangxiaobai_shishen2_full
chinese_name: "食神2（全量版）"
last_updated: 2024-02-01
license: "Apache License 2.0"
pipeline_tag: question-answering
tasks:
  - question-answering
model_type:
  - internlm2
architectures:
  - InternLM2ForCausalLM
library_name:
  - pytorch
frameworks:
  - Pytorch
inference_backends:
  - "deploy_task text/emb"
  - "lmdeploy 0.9.1"
  - "lmdeploy_turbomind 0.9.1"
  - "sglang 0.5.2"
  - "vllm 0.9.2"
downloads: 2951
stars: 4
---

# zhangxiaobai_shishen2_full

> zhangxiaobai_shishen2_full - zhanghuiATchina 在 ModelScope 开源的模型。本模型是基于InternLM2-chat-7B预训练模型，通过 XiaChuFang Recipe Corpus食谱语料库进行FineTune，训练出来的微调模型。模型通过1,520,327种菜谱进行了1个epoch的微调训练生成。

zhanghuiATchina/zhangxiaobai_shishen2_full 是 ModelScope 魔搭社区上的question-answering模型，采用 Apache License 2.0 许可，可用 deploy_task text/emb、lmdeploy 0.9.1、lmdeploy_turbomind 0.9.1 部署。

- **Repository**: zhanghuiATchina/zhangxiaobai_shishen2_full
- **License**: Apache License 2.0
- **Tasks**: question-answering
- **Inference backends**: deploy_task text/emb, lmdeploy 0.9.1, lmdeploy_turbomind 0.9.1, sglang 0.5.2, vllm 0.9.2
- **Downloads**: 2951
- **Stars**: 4
- **Last updated**: 2024-02-01

Source: https://www.modelscope.cn/models/zhanghuiATchina/zhangxiaobai_shishen2_full

---

###### 
#### Clone with HTTP
```bash
 git clone https://www.modelscope.cn/zhanghuiATchina/zhangxiaobai_shishen2_full.git
```



# <张小白的菜谱（全量升级版）>介绍

本模型是基于InternLM2-chat-7B预训练模型，通过 XiaChuFang Recipe Corpus食谱语料库进行FineTune，训练出来的微调模型。

使用了150万个菜谱进行了1个epoch的训练。



## 模型描述

本模型是用于实现咨询菜谱的对话。



## 期望模型使用方式以及适用范围

使用gradio或者streamlit调用就行了。本地也可以直接使用命令行方式调用。



### 如何使用

命令行一个典型的方式就是编辑一个cli_demo.py的文件：

```bash
import torch
from modelscope import AutoTokenizer, AutoModelForCausalLM
from tools.transformers.interface import GenerationConfig, generate_interactive

model_name_or_path = "zhanghuiATchina/zhangxiaobai_shishen2_full" 

tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_name_or_path, trust_remote_code=True, torch_dtype=torch.bfloat16, device_map='auto')
model = model.eval()

messages = []
generation_config = GenerationConfig(max_length=max_length, top_p=0.8, temperature=0.8, repetition_penalty=1.002)

response, history = model.chat(tokenizer, "你好", history=[])
print(response)
response, history = model.chat(tokenizer, "酸菜鱼怎么做", history=history)
print(response)
```



然后 python cli_demo.py即可。



## 训练数据介绍

## XiaChuFang Recipe Corpus

**● 发布方**：清华大学,百度,北京通用人工智能研究院

**● 发布时间**：2020

**● 简介**： 完整的食谱语料库包含1,520,327种中国食谱。其中，1,242,206食谱属于30,060菜肴。一道菜平均有41.3个食谱。食谱的平均长度是224个字符。最大长度为62,722个字符，最小长度为10个字符。食谱由415,272位作者贡献。其中，最有生产力的作者上传5,394食谱。我们提供脱敏的作者信息。

**● 下载地址**： [https://opendatalab.org.cn/XiaChuFang_Recipe_Corpus](https://link.zhihu.com/?target=https%3A//opendatalab.org.cn/XiaChuFang_Recipe_Corpus%3Fsource%3DJUU3JTlGJUE1JUU0JUI5JThF)

**● 论文地址**： [https://arxiv.org//pdf/2210.114](http://arxiv.org//pdf/2210.11431.pdf)



## 模型训练流程

​		本项目使用 xtuner0.1.13 训练，在 internlm2-chat-7b 上进行微调，[模型地址](https://www.modelscope.cn/models/zhanghuiATchina/zhangxiaobai_shishen2_full/summary)

1. 微调方法如下

   ```shell
   xtuner train ${YOUR_CONFIG} --deepspeed deepspeed_zero2
   ```

   - `--deepspeed` 表示使用 [DeepSpeed](https://github.com/microsoft/DeepSpeed) 🚀 来优化训练过程。XTuner 内置了多种策略，包括 ZeRO-1、ZeRO-2、ZeRO-3 等。如果用户期望关闭此功能，请直接移除此参数。

2. 将保存的 `.pth` 模型（如果使用的DeepSpeed，则将会是一个文件夹）转换为 LoRA 模型：

   ```shell
   export MKL_SERVICE_FORCE_INTEL=1
   xtuner convert pth_to_hf ${YOUR_CONFIG} ${PTH} ${LoRA_PATH}
   ```

   3.将LoRA模型合并入 HuggingFace 模型：

```shell
xtuner convert merge ${Base_PATH} ${LoRA_PATH} ${SAVE_PATH}
```



## 数据评估及结果

后续补充



### 相关论文以及引用信息

后续补充
