{"id":13525414,"url":"https://github.com/siat-nlp/HanFei","last_synced_at":"2025-04-01T04:32:01.631Z","repository":{"id":174630125,"uuid":"647322598","full_name":"siat-nlp/HanFei","owner":"siat-nlp","description":"国内首个全参数训练的法律大模型 HanFei-1.0 (韩非)","archived":false,"fork":false,"pushed_at":"2023-10-28T12:55:07.000Z","size":1262,"stargazers_count":95,"open_issues_count":5,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-02T09:33:46.957Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/siat-nlp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-05-30T14:28:06.000Z","updated_at":"2024-10-27T13:31:07.000Z","dependencies_parsed_at":"2024-01-13T22:55:01.633Z","dependency_job_id":"89f4003b-667b-45af-beb2-5f83d487af1b","html_url":"https://github.com/siat-nlp/HanFei","commit_stats":null,"previous_names":["siat-nlp/hanfei"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siat-nlp%2FHanFei","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siat-nlp%2FHanFei/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siat-nlp%2FHanFei/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siat-nlp%2FHanFei/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/siat-nlp","download_url":"https://codeload.github.com/siat-nlp/HanFei/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246586087,"owners_count":20801025,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T06:01:18.516Z","updated_at":"2025-04-01T04:32:01.255Z","avatar_url":"https://github.com/siat-nlp.png","language":"Python","funding_links":[],"categories":["🤖 模型","Instruction Fine-tuning Datasets","A01_文本生成_文本对话"],"sub_categories":["🧩 领域模型","Domain-specific Instruction Fine-tuning Datasets","大语言对话模型及数据"],"readme":"# HanFei\n## 介绍\nHanFei-1.0(韩非)是国内首个**全参数**训练的法律大模型，参数量7b，主要功能包括：法律问答、多轮对话、撰写文章、检索（敬请期待）等。\n\n[beta版本](http://siat.yang42.com:10185/)\n\n例子1\n\n![example 1](./assets/images/Snipaste_2023-05-09_12-17-42.png)\n\n例子2\n\n![example 2](./assets/images/Snipaste_2023-05-09_00-00-35.png)\n\n## 数据\n`注：目前只开源hanfei-1.0微调数据，不开源预训练数据。`\n\n### 数据处理\n\nsrc/data_processing/gen_pretrain_data.py    生成预训练数据\n\nsrc/data_processing/gen_instruction_multi.py    生成指令数据、合并微调数据\n\n### 预训练数据\n\n数据组成：案例、法规、起诉状、法律新闻等。\n\n数据量：约60G数据，每条2048个token。\n\n### 微调数据\n\n#### hanfei 1.0\n第一版使用规则筛选\n\n| 数据类型             | 文件名称                    |  数据量 | \n| :------------------- | :-------------------------  |  :----- | \n| 中文通用指令         |zh_general_instruction.json  |   5.3w  |\n| 中文法律指令         | zh_law_instruction.json     |  4.1w   |     \n| 中文通用对话         |zh_general_conversation.json | 5.5w    |    \n| 中文法律对话         | zh_law_conversation.json    | 5.6w    |  \n| 中文法律问答数据     | zh_law_qa.json              | 5w      | \n\n\n#### 数据、模型下载链接\n百度网盘：\n\n链接：https://pan.baidu.com/s/1PkRXUo9sNRQmoXHcW7Aeeg?pwd=d6t5 \n\n提取码：d6t5 \n\n#### hanfei 2.0（开发中）\n第二版使用人工筛选\n\n\n### 模型评估数据\n\n| 数据类型 | 数据路径           | 数据说明                | 数据量                | \n| :------- | :----------------- | :---------------------- | :-------------------- | \n| 法律问题 | data/evaluation_dataset | 包含劳动、婚姻等9个板块 | 150条   | \n\n\n## 评估指标\n本次采用人工评估的方法，针对每一个法律咨询问题，Hanfei、BLOOMz、ChatGPT 3 个语言模型分别生成回答，我们聘请了专业的律师，为各个语言模型生成的回答打分。\n\n+ 评估指标 1：（0-10 分）0 分最差，10分最好\n\n    本次总共评估了150个问题，我们将每个模型的得分求和，用总得分衡量模型回答的质量，评估结果如下图所示：\n\n    ![total_score](./assets/images/total_score.png)\n\n## 训练\n\n### 环境要求\n\nA100/A800 * 8\n\n### 训练命令\n```sh\n# Step 1：法律领域预训练\nsh scripts/pre_training/run_train.sh\n\n# Step 2: 指令微调\nsh scripts/instruction_tuning/run_train.sh\n\n```\n## 部署\n\n### 环境要求\n\n40G显存，只需1张A100/A800 或者 2张TITAN RTX...\n\n### 部署命令\n\n```sh\n# Gradio 界面\npython src/web/hanfei_app.py\n\n# RESTful api\npython src/serve/hanfei_serve.py\n```\n\n## 项目参与者\n本项目由来自于中科院深圳先进院得理法律人工智能联合实验室的何万伟、温嘉宝、张磊、程浩、秦博文、李云水、李之健，深圳市大数据研究院、港中文深圳的蒋峰、陈俊颖同学合作开发，指导教师为深圳市大数据研究院、港中文深圳的**王本友**助理教授和中科院深圳先进院的**杨敏**副研究员。\n\n## 免责声明\n本项目相关资源仅供学术研究之用，严禁用于商业用途。使用涉及第三方代码的部分时，请严格遵循相应的开源协议。模型生成的内容受模型计算、随机性和量化精度损失等因素影响，本项目无法对其准确性作出保证，本项目不承担任何法律责任，亦不对因使用相关资源和输出结果而可能产生的任何损失承担责任。\n\n## 致谢\n\n本项目参考了以下开源项目，在此对相关项目和研究开发人员表示感谢。\n\nBloom: https://huggingface.co/bigscience/bloom\n\nFacebook LLaMA: https://github.com/facebookresearch/llama\n\nStanford Alpaca: https://github.com/tatsu-lab/stanford_alpaca\n\nSelf-instruct: https://github.com/yizhongw/self-instruct\n\n## 引用\n\n如果您使用了本项目的内容，或者认为本项目对您的研究有帮助，请引用本项目。\n\n```\n@misc{HanFei,\n  author={Wanwei He and Jiabao Wen and Lei Zhang and Hao Cheng and Bowen Qin and Yunshui Li and Feng Jiang and Junying Chen and Benyou Wang and Min Yang},\n  title={HanFei-1.0},\n  year={2023},\n  publisher={GitHub},\n  journal={GitHub repository},\n  howpublished={\\url{https://github.com/siat-nlp/HanFei}},\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiat-nlp%2FHanFei","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiat-nlp%2FHanFei","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiat-nlp%2FHanFei/lists"}