---
title: lirongzhen-pufa-model
canonical_url: "https://www.modelscope.cn/models/admlrz/lirongzhen-pufa-model"
md_url: "https://www.modelscope.cn/models/admlrz/lirongzhen-pufa-model.md"
repository: admlrz/lirongzhen-pufa-model
chinese_name: "民法模型"
last_updated: 2024-02-02
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: 699
stars: 2
---

# lirongzhen-pufa-model

> lirongzhen-pufa-model - admlrz 在 ModelScope 开源的模型。本模型是基于InternLM-chat-7B预训练模型，通过原有大模型法律数据＋民法典问答＋维权进行FineTune，训练出来的微调模型。

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

- **Repository**: admlrz/lirongzhen-pufa-model
- **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**: 699
- **Stars**: 2
- **Last updated**: 2024-02-02

Source: https://www.modelscope.cn/models/admlrz/lirongzhen-pufa-model

---

###### 
#### Clone with HTTP
```bash
 git clone https://www.modelscope.cn/admlrz/lirongzhen-pufa-model.git
```



# <张三普法模型>介绍

本模型是基于InternLM-chat-7B预训练模型，通过原有大模型法律数据＋民法典问答＋维权进行FineTune，训练出来的微调模型。

模型通过120M的jsonl数据进行了4个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 = "your path" 

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即可。



## 训练数据介绍

        后续补充



## 模型训练流程

​       本项目 使用 xtuner0.1.9 训练，在 internlm-chat-7b 上进行微调，[模型地址](https://www.modelscope.cn/models/zhanghuiATchina/zhangxiaobai_shishen_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}
```



## 数据评估及结果

后续补充



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

后续补充
