---
title: baichuan_sft_lora
canonical_url: "https://www.modelscope.cn/models/AI-ModelScope/baichuan_sft_lora"
md_url: "https://www.modelscope.cn/models/AI-ModelScope/baichuan_sft_lora.md"
repository: AI-ModelScope/baichuan_sft_lora
chinese_name: "百川sft微调模型"
last_updated: 2023-06-21
license: other
pipeline_tag: text-generation
tasks:
  - text-generation
library_name:
  - transformer
  - pytorch
frameworks:
  - pytorch
language:
  - en
  - zh
downloads: 95
stars: 1
---

# baichuan_sft_lora

> baichuan_sft_lora - AI-ModelScope 在 ModelScope 开源的模型。基于多语数据集微调的百川sft模型，持续更新中

AI-ModelScope/baichuan_sft_lora 是 ModelScope 魔搭社区上的text-generation模型，采用 other 许可。

- **Repository**: AI-ModelScope/baichuan_sft_lora
- **License**: other
- **Tasks**: text-generation
- **Downloads**: 95
- **Stars**: 1
- **Last updated**: 2023-06-21

Source: https://www.modelscope.cn/models/AI-ModelScope/baichuan_sft_lora

---

# baichuan_sft_lora
百川sft微调模型，是在百川-7B预训练模型的基础上微调的模型，本模型会持续update在不同的数据集上sft的百川的模型和方法。

## Uses

<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->

### 示例代码
安装依赖：
```
pip install peft
```
使用代码
```python 
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
from peft import PeftModel
from modelscope.hub.snapshot_download import snapshot_download
model_dir = snapshot_download('baichuan-inc/baichuan-7B', cache_dir='baichuan-7B', revision='v1.0.2')
model_dir_sft = snapshot_download('AI-ModelScope/baichuan_sft_lora', cache_dir='baichuan-sft',revision='v1.0.0')
import sys
sys.path.append("/mnt/workspace/baichuan-7B/baichuan-inc/baichuan-7B")
tokenizer = AutoTokenizer.from_pretrained("/mnt/workspace/baichuan-7B/baichuan-inc/baichuan-7B", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("/mnt/workspace/baichuan-7B/baichuan-inc/baichuan-7B",device_map="auto", trust_remote_code=True)
model = PeftModel.from_pretrained(model, "/mnt/workspace/baichuan-sft/AI-ModelScope/baichuan_sft_lora")
streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
query = "晚上睡不着怎么办？"
prompt="Below is an instruction that describes a task. Write a response that appropriately completes the request."
prompt+="### Instruction:\n{}\n\n### Response:\n".format(query)
inputs = tokenizer([prompt], return_tensors="pt")
inputs = inputs.to("cuda")
generate_ids = model.generate(**inputs, max_new_tokens=256,streamer=streamer)
```
#您可以尝试以下方法来帮助您入睡：
1. 保持卧室黑暗，并关闭所有光源。
2. 保持安静，避免噪音。
3. 保持温度适宜，避免过热或过冷。
4. 保持舒适的床垫和枕头。
5. 睡前避免喝咖啡或茶，因为它们会使您更清醒。
6. 尝试冥想或瑜伽，这有助于放松身心。
7. 睡前进行适量的运动，但不要过度。
8. 睡前阅读或听轻音乐，这有助于放松心情。
9. 尝试放松技巧，如深呼吸或肌肉放松。
10. 保持规律的睡眠时间，避免熬夜。

如果您尝试这些方法后仍然无法入睡，建议您咨询医生或寻求专业帮助。

# 效果
Loss curve on training set:


Loss curve on evaluation set:
