---
title: zhangxiaobai_shishen_full_4bit
canonical_url: "https://www.modelscope.cn/models/zhanghuiATchina/zhangxiaobai_shishen_full_4bit"
md_url: "https://www.modelscope.cn/models/zhanghuiATchina/zhangxiaobai_shishen_full_4bit.md"
repository: zhanghuiATchina/zhangxiaobai_shishen_full_4bit
chinese_name: "食神（全量版）4bit"
last_updated: 2024-02-07
license: "Apache License 2.0"
pipeline_tag: question-answering
tasks:
  - question-answering
model_type:
  - internlm
architectures:
  - InternLMForCausalLM
library_name:
  - pytorch
frameworks:
  - Pytorch
inference_backends:
  - "deploy_task text/emb"
  - "lmdeploy 0.9.1"
  - "lmdeploy_turbomind 0.9.1"
  - "vllm 0.9.2"
downloads: 60
stars: 3
---

# zhangxiaobai_shishen_full_4bit

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

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

- **Repository**: zhanghuiATchina/zhangxiaobai_shishen_full_4bit
- **License**: Apache License 2.0
- **Tasks**: question-answering
- **Inference backends**: deploy_task text/emb, lmdeploy 0.9.1, lmdeploy_turbomind 0.9.1, vllm 0.9.2
- **Downloads**: 60
- **Stars**: 3
- **Last updated**: 2024-02-07

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

---

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



# <食神（全量4bit量化版）>介绍

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

模型通过1,520,327种菜谱进行了1个epoch的微调训练，并进行4bit量化。



## 模型描述

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



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

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



### 安装

#### 创建conda环境

```
conda create -n shishen4bit python=3.10 -y
conda activate shishen4bit
```

#### 安装依赖

```
conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
pip install modelscope==1.11.0 transformers==4.36.0 accelerate tiktoken einops scipy transformers_stream_generator==0.0.4 peft -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install ninja sentencepiece -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install lmdeploy==0.2.2 -i https://pypi.tuna.tsinghua.edu.cn/simple


#请确保CUDA版本跟前面pytorch的版本一致
git clone https://github.com/Dao-AILab/flash-attention -b v1.0.8
cd flash-attention
pip install .
或者
pip install flash-attention -i https://pypi.tuna.tsinghua.edu.cn/simple

```



### 如何使用

编辑download.py：

```bash
import torch
from modelscope import AutoTokenizer, AutoModelForCausalLM

model_name_or_path = "zhanghuiATchina/zhangxiaobai_shishen_full_4bit" 

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

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

执行 python download.py。

切换到下载好的模型权重目录 zhangxiaobai_shishen_full_4bit （一般是 ~/.cache/modelscope/hub/zhanghuiATchina/zhangxiaobai_shishen_full_4bit）

编辑pipeline.py

```
from lmdeploy import pipeline, TurbomindEngineConfig, ChatTemplateConfig

model_name_or_path = "./zhangxiaobai_shishen_full_4bit"
pipe = pipeline(model_name_or_path,
                backend_config=TurbomindEngineConfig(model_format='awq'),
                chat_template_config=ChatTemplateConfig(model_name='internlm-chat-7b')
                )

response = pipe(["酸菜鱼怎么做", "水煮鱼怎么做"])
print(response)
```

执行 python pipeline.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)



## 模型训练流程

后续补充



## 数据评估及结果

后续补充



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

后续补充
