{"id":13498393,"url":"https://github.com/ssbuild/chatglm_finetuning","last_synced_at":"2025-05-14T15:05:23.742Z","repository":{"id":142852742,"uuid":"613657823","full_name":"ssbuild/chatglm_finetuning","owner":"ssbuild","description":"chatglm 6b finetuning and alpaca finetuning","archived":false,"fork":false,"pushed_at":"2025-03-09T17:16:11.000Z","size":7603,"stargazers_count":1542,"open_issues_count":38,"forks_count":178,"subscribers_count":20,"default_branch":"glm4.0","last_synced_at":"2025-04-08T02:38:27.160Z","etag":null,"topics":["adalora","chatglm","deep-learning","freeze","ia3","lora","p-tuning-v2","pytorch","qlora","sft"],"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/ssbuild.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-14T02:18:44.000Z","updated_at":"2025-04-06T03:55:01.000Z","dependencies_parsed_at":"2024-06-26T12:40:18.306Z","dependency_job_id":"d4d1f091-2b47-4656-a66f-8f14bc52554b","html_url":"https://github.com/ssbuild/chatglm_finetuning","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbuild%2Fchatglm_finetuning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbuild%2Fchatglm_finetuning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbuild%2Fchatglm_finetuning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbuild%2Fchatglm_finetuning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ssbuild","download_url":"https://codeload.github.com/ssbuild/chatglm_finetuning/tar.gz/refs/heads/glm4.0","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254168753,"owners_count":22026206,"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":["adalora","chatglm","deep-learning","freeze","ia3","lora","p-tuning-v2","pytorch","qlora","sft"],"created_at":"2024-07-31T21:00:26.832Z","updated_at":"2025-05-14T15:05:23.695Z","avatar_url":"https://github.com/ssbuild.png","language":"Python","funding_links":[],"categories":["参考-开源项目","A01_文本生成_文本对话","Python","Chinese models"],"sub_categories":["0. 通用","大语言对话模型及数据","glm 6b"],"readme":"### \r\n```text\r\n    2024-06-10 initial glm4\r\n```\r\n   \r\n##  statement\r\n- [deep_training](https://github.com/ssbuild/deep_training)\r\n\r\n## install\r\n  - pip install -U -r requirements.txt\r\n  - 如果无法安装 , 可以切换官方源 pip install -i https://pypi.org/simple -U -r requirements.txt  \r\n\r\n```text\r\ndev 通过一下方式安装\r\npip install -U git+https://github.com/ssbuild/deep_training.git\r\npip install -U transformers\u003e=4.30 deepspeed xformers bitsandbytes\u003e=0.39 accelerate\u003e=0.20\r\n```\r\n\r\n\r\n## weight\r\n\r\n- [glm-4-9b-chat](https://huggingface.co/THUDM/glm-4-9b-chat)   \r\n- [glm-4-9b-chat-1m](https://huggingface.co/THUDM/glm-4-9b-chat-1m)  \r\n- [glm-4-9b](https://huggingface.co/THUDM/glm-4-9b)  \r\n\r\n\r\n## data sample\r\n- open_data 不定时开放新数据 https://github.com/ssbuild/open_data\r\n\r\n\r\n```json\r\n{\"id\": 1, \"conversations\": [{\"from\": \"system\", \"value\": \"You are ChatGLM4, a large language model trained by Zhipu.AI. Follow the user's instructions carefully. Respond using markdown.\"}, {\"from\": \"user\", \"value\": \"Hello\"}, {\"from\": \"assistant\", \"value\": \"Hello, I'm ChatGLM4. What can I assist you today?\"}]}\r\n{\"id\": 2, \"conversations\": [{\"from\": \"system\", \"value\": \"你是一个名为 GLM-4 的人工智能助手。你是基于智谱AI训练的语言模型 GLM-4 模型开发的，你的任务是针对用户的问题和要求提供适当的答复和支持。\", \"tools\": \"[\\n  {\\n    \\\"type\\\": \\\"function\\\",\\n    \\\"function\\\": {\\n      \\\"name\\\": \\\"get_current_weather\\\",\\n      \\\"description\\\": \\\"Get the current weather in a given location\\\",\\n      \\\"parameters\\\": {\\n        \\\"type\\\": \\\"object\\\",\\n        \\\"properties\\\": {\\n          \\\"location\\\": {\\n            \\\"type\\\": \\\"string\\\",\\n            \\\"description\\\": \\\"The city and state, e.g. San Francisco, CA\\\"\\n          },\\n          \\\"unit\\\": {\\n            \\\"type\\\": \\\"string\\\"\\n          }\\n        },\\n        \\\"required\\\": [\\n          \\\"location\\\"\\n        ]\\n      }\\n    }\\n  }\\n]\"}, {\"from\": \"user\", \"value\": \"今天北京的天气怎么样？\"}, {\"from\": \"assistant\", \"value\": \"{\\\"name\\\": \\\"get_current_weather\\\", \\\"arguments\\\": {\\\"location\\\": \\\"beijing\\\", unit=\\\"celsius\\\"}}\\n\"}, {\"from\": \"observation\", \"value\": \"{\\\"temperature\\\": 22}\"}, {\"from\": \"assistant\", \"value\": \"根据查询结果，今天北京的气温为 22 摄氏度。\"}]}\r\n{\"id\": 3, \"conversations\": [{\"from\": \"system\", \"value\": \"你是一个名为 GLM-4 的人工智能助手。你是基于智谱AI训练的语言模型 GLM-4 模型开发的，你的任务是针对用户的问题和要求提供适当的答复和支持。\", \"tools\": \"[\\n  {\\n    \\\"type\\\": \\\"function\\\",\\n    \\\"function\\\": {\\n      \\\"name\\\": \\\"get_recommended_books\\\",\\n      \\\"description\\\": \\\"Get recommended books based on user's interests\\\",\\n      \\\"parameters\\\": {\\n        \\\"type\\\": \\\"object\\\",\\n        \\\"properties\\\": {\\n          \\\"interests\\\": {\\n            \\\"type\\\": \\\"array\\\",\\n            \\\"items\\\": {\\n              \\\"type\\\": \\\"string\\\"\\n            },\\n            \\\"description\\\": \\\"The interests to recommend books for\\\"\\n          }\\n        },\\n        \\\"required\\\": [\\n          \\\"interests\\\"\\n        ]\\n      }\\n    }\\n  }\\n]\"}, {\"from\": \"user\", \"value\": \"Hi, I am looking for some book recommendations. I am interested in history and science fiction.\"}, {\"from\": \"assistant\", \"value\": \"{\\\"name\\\": \\\"get_recommended_books\\\", \\\"arguments\\\": {\\\"interests\\\": [\\\"history\\\", \\\"science fiction\\\"]}}\\n\"}, {\"from\": \"observation\", \"value\": \"{\\\"books\\\": [\\\"Sapiens: A Brief History of Humankind by Yuval Noah Harari\\\", \\\"A Brief History of Time by Stephen Hawking\\\", \\\"Dune by Frank Herbert\\\", \\\"The Martian by Andy Weir\\\"]}\"}, {\"from\": \"assistant\", \"value\": \"Based on your interests in history and science fiction, I would recommend the following books: \\\"Sapiens: A Brief History of Humankind\\\" by Yuval Noah Harari, \\\"A Brief History of Time\\\" by Stephen Hawking, \\\"Dune\\\" by Frank Herbert, and \\\"The Martian\\\" by Andy Weir.\"}]}\r\n{\"id\": 4, \"conversations\": [{\"from\": \"user\", \"value\": \"写一个诗歌，关于冬天\"}, {\"from\": \"assistant\", \"value\": \"冬夜寂静冷，\\n云在天边飘，\\n冰封白雪上， \\n寒冷像一场雪。\\n \\n雪花融化成冰，\\n像那雪花飘洒，\\n在寒冷的冬天，\\n感受春天的喜悦。\\n 冬日里，\\n风雪渐消，\\n一片寂静，\\n把快乐和温暖带回家。\"}]}\r\n{\"id\": 5, \"conversations\": [{\"from\": \"user\", \"value\": \"晚上睡不着应该怎么办\"}, {\"from\": \"assistant\", \"value\": \"晚上睡不着可能会让你感到焦虑或不舒服,但以下是一些可以帮助你入睡的方法:\\n\\n1. 制定规律的睡眠时间表:保持规律的睡眠时间表可以帮助你建立健康的睡眠习惯,使你更容易入睡。尽量在每天的相同时间上床,并在同一时间起床。\\n2. 创造一个舒适的睡眠环境:确保睡眠环境舒适,安静,黑暗且温度适宜。可以使用舒适的床上用品,并保持房间通风。\\n3. 放松身心:在睡前做些放松的活动,例如泡个热水澡,听些轻柔的音乐,阅读一些有趣的书籍等,有助于缓解紧张和焦虑,使你更容易入睡。\\n4. 避免饮用含有咖啡因的饮料:咖啡因是一种刺激性物质,会影响你的睡眠质量。尽量避免在睡前饮用含有咖啡因的饮料,例如咖啡,茶和可乐。\\n5. 避免在床上做与睡眠无关的事情:在床上做些与睡眠无关的事情,例如看电影,玩游戏或工作等,可能会干扰你的睡眠。\\n6. 尝试呼吸技巧:深呼吸是一种放松技巧,可以帮助你缓解紧张和焦虑,使你更容易入睡。试着慢慢吸气,保持几秒钟,然后缓慢呼气。\\n\\n如果这些方法无法帮助你入睡,你可以考虑咨询医生或睡眠专家,寻求进一步的建议。\"}]}\r\n```\r\n\r\n\r\n\r\n\r\n\r\n## infer\r\n    # infer.py 推理预训练模型\r\n    # infer_finetuning.py 推理微调模型\r\n    # infer_lora_finetuning.py 推理lora微调模型\r\n     python infer.py\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n## training\r\n```text\r\n# 制作数据\r\ncd scripts\r\nbash train_full.sh -m dataset \r\nor\r\nbash train_lora.sh -m dataset \r\nor\r\nbash train_ptv2.sh -m dataset \r\n\r\n注: num_process_worker 为多进程制作数据 ， 如果数据量较大 ， 适当调大至cpu数量\r\ndataHelper.make_dataset_with_args(data_args.train_file,mixed_data=False, shuffle=True,mode='train',num_process_worker=0)\r\n\r\n# 全参数训练 \r\n    bash train_full.sh -m train \r\n    \r\n# lora adalora ia3 \r\n    bash train_lora.sh -m train \r\n    \r\n# ptv2\r\n    bash train_ptv2.sh -m train \r\n```\r\n\r\n## 训练参数\r\n[训练参数](assets/args.MD)\r\n\r\n\r\n\r\n\r\n## 友情链接\r\n\r\n- [pytorch-task-example](https://github.com/ssbuild/pytorch-task-example)\r\n- [moss_finetuning](https://github.com/ssbuild/chatmoss_finetuning)\r\n- [chatglm_finetuning](https://github.com/ssbuild/chatglm_finetuning)\r\n- [chatglm2_finetuning](https://github.com/ssbuild/chatglm2_finetuning)\r\n- [chatglm3_finetuning](https://github.com/ssbuild/chatglm3_finetuning)\r\n- [t5_finetuning](https://github.com/ssbuild/t5_finetuning)\r\n- [llm_finetuning](https://github.com/ssbuild/llm_finetuning)\r\n- [llm_rlhf](https://github.com/ssbuild/llm_rlhf)\r\n- [chatglm_rlhf](https://github.com/ssbuild/chatglm_rlhf)\r\n- [t5_rlhf](https://github.com/ssbuild/t5_rlhf)\r\n- [rwkv_finetuning](https://github.com/ssbuild/rwkv_finetuning)\r\n- [baichuan_finetuning](https://github.com/ssbuild/baichuan_finetuning)\r\n- [xverse_finetuning](https://github.com/ssbuild/xverse_finetuning)\r\n- [internlm_finetuning](https://github.com/ssbuild/internlm_finetuning)\r\n- [qwen_finetuning](https://github.com/ssbuild/qwen_finetuning)\r\n- [skywork_finetuning](https://github.com/ssbuild/skywork_finetuning)\r\n- [bluelm_finetuning](https://github.com/ssbuild/bluelm_finetuning)\r\n- [yi_finetuning](https://github.com/ssbuild/yi_finetuning)\r\n- [glm4_finetuning](https://github.com/ssbuild/glm4_finetuning)\r\n- [aigc_evals](https://github.com/ssbuild/aigc_evals)\r\n- [aigc_serving](https://github.com/ssbuild/aigc_serving)\r\n\r\n\r\n## \r\n    纯粹而干净的代码\r\n\r\n\r\n    \r\n\r\n## Reference\r\n    https://huggingface.co/THUDM/glm4\r\n\r\n\r\n\r\n\r\n## Star History\r\n\r\n[![Star History Chart](https://api.star-history.com/svg?repos=ssbuild/glm4_finetuning\u0026type=Date)](https://star-history.com/#ssbuild/glm4_finetuning\u0026Date)\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssbuild%2Fchatglm_finetuning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fssbuild%2Fchatglm_finetuning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssbuild%2Fchatglm_finetuning/lists"}