{"id":13566006,"url":"https://github.com/linyiLYi/bilibot","last_synced_at":"2025-04-03T23:30:53.097Z","repository":{"id":239277412,"uuid":"796597677","full_name":"linyiLYi/bilibot","owner":"linyiLYi","description":"A local chatbot fine-tuned by bilibili user comments.","archived":false,"fork":false,"pushed_at":"2024-05-15T15:01:13.000Z","size":3273,"stargazers_count":3181,"open_issues_count":27,"forks_count":369,"subscribers_count":21,"default_branch":"main","last_synced_at":"2025-03-30T22:06:14.434Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/linyiLYi.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":"2024-05-06T09:02:52.000Z","updated_at":"2025-03-30T07:55:53.000Z","dependencies_parsed_at":"2024-05-11T07:28:29.037Z","dependency_job_id":"8617cc2e-28d9-4804-8075-a74ff627b85d","html_url":"https://github.com/linyiLYi/bilibot","commit_stats":null,"previous_names":["linyilyi/bilibot"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linyiLYi%2Fbilibot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linyiLYi%2Fbilibot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linyiLYi%2Fbilibot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linyiLYi%2Fbilibot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linyiLYi","download_url":"https://codeload.github.com/linyiLYi/bilibot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247097633,"owners_count":20883122,"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-01T13:01:59.928Z","updated_at":"2025-04-03T23:30:50.159Z","avatar_url":"https://github.com/linyiLYi.png","language":"Python","funding_links":[],"categories":["Python","Repos"],"sub_categories":[],"readme":"# 哔哩哔哩聊天机器人\n\n由[哔哩哔哩](https://bilibili.com)用户评论微调训练而成的本地聊天机器人。支持文字聊天，也可以通过 questions.txt 生成针对给定问题的语音对话。\n\n本项目文字生成使用的基础模型为 [Qwen1.5-32B-Chat](https://huggingface.co/Qwen/Qwen1.5-32B-Chat)，借助苹果 [mlx-lm LORA 示例项目](https://github.com/ml-explore/mlx-examples/blob/main/llms/mlx_lm/LORA.md) 对基础模型进行微调训练。语音生成部分基于开源项目 [GPT-SoVITS](https://github.com/RVC-Boss/GPT-SoVITS)，问题语音来自 B 站用户[白菜工厂1145号员工](https://space.bilibili.com/518098961)训练的派蒙语音模型。\n\n### 文件结构\n\n项目主要脚本存放在 `main/` 文件夹下，模型存放于 `models/` 文件夹。提示词模板、问题列表存放在 `text/` 文件夹下。`tools/compress_model.py` 可以对完整模型进行量化压缩，大大加快模型内容生成速度。\n\n## 运行指南\n\n本项目基于 Python 编程语言，程序运行使用的 Python 版本为 3.10，建议使用 [Anaconda](https://www.anaconda.com) 配置 Python 环境。以下配置过程已在 macOS 系统测试通过。\n\n\n### 配置环境\n\n```\nconda create -n bilibot python=3.10\nconda activate bilibot\ncd bilibot\npip install -r requirements.txt\n```\n\n### 模型微调训练与推理测试\n\n使用控制台指令，借助 [mlx-lm](https://github.com/ml-explore/mlx-examples/blob/main/llms/mlx_lm/LORA.md) 对 Qwen1.5-32B-Chat 进行微调：\n\n```\npython -m mlx_lm.lora --model models/Qwen1.5-32B-Chat --data data/ --train --iters 1000 --batch-size 16 --lora-layers 12\n```\n\n将微调后的 `adapters` 文件与基础模型合并：\n\n```\npython -m mlx_lm.fuse --model models/Qwen1.5-32B-Chat --save-path models/Qwen1.5-32B-Chat-FT --adapter-path models/Qwen1.5-32B-Chat-Adapters\n```\n\n对合并后的模型进行量化加速：\npython tools/compress_model.py\n\n对微调训练后的模型进行对话测试：\npython chat.py\n\n### 语音生成\n本项目借助开源项目 [GPT-SoVITS](https://github.com/RVC-Boss/GPT-SoVITS) 进行语音生成。\n\n首先参考 [GPT-SoVITS](https://github.com/RVC-Boss/GPT-SoVITS) 的官方指南配置环境并运行语音生成程序。\n\n```\nconda create -n GPTSOVITS python=3.9\nconda activate GPTSOVITS\ncd GPT-SoVITS\npip install -r requirements.txt\npython webui.py\n```\n\n运行 api 程序，分别使用端口 9880 与 9881 提供派蒙与林亦的语音生成服务，以下请使用 GPT-SoVITS 代码库完成：\n```\npython api.py -s SoVITS_weights/paimeng2_e110_s159940.pth -g GPT_weights/paimeng2-e10.ckpt -dr samples/Paimon/疑问—哇，这个，还有这个…只是和史莱姆打了一场，就有这么多结论吗？.wav -dt \"哇，这个，还有这个…只是和史莱姆打了一场，就有这么多结论吗？\" -dl \"zh\" -a 127.0.0.1 -p 9880\npython api.py -s SoVITS_weights/linyi_e25_s1150.pth -g GPT_weights/linyi-e50.ckpt -dr \"samples/linyi/【愤怒】你这问题太弱智了，我都不知道该从哪开始骂你。.WAV\" -dt \"你这问题太弱智了，我都不知道该从哪开始骂你。\" -dl \"zh\" -a 127.0.0.1 -p 9881\n```\n\n运行问答生成程序：\n```\npython start_qa_dialogue.py\n```\n\n## 参考\n\n1. 机器学习框架 MLX，来自苹果机器学习研究组：https://github.com/ml-explore/mlx\n2. 阿里通义千问 Qwen1.5：https://qwenlm.github.io/zh/blog/qwen1.5/\n3. 开源文本转语音项目 GPT-SoVITS，作者[花儿不哭](https://space.bilibili.com/5760446)：https://github.com/RVC-Boss/GPT-SoVITS\n4. 派蒙语音模型，作者[白菜工厂1145号员工](https://space.bilibili.com/518098961)：[【GPT-SoVITS】30小时超大数据集测试，堆时长真的有用吗？](https://www.bilibili.com/video/BV1Yu4m1N79m)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FlinyiLYi%2Fbilibot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FlinyiLYi%2Fbilibot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FlinyiLYi%2Fbilibot/lists"}