diff --git a/README.md b/README.md index df1e590..8a3abcf 100644 --- a/README.md +++ b/README.md @@ -1,264 +1,100 @@ -![download](https://github.com/user-attachments/assets/5842e84e-004f-4afd-9373-af64e9575b78) -

🚀从聊天记录创造数字分身的一站式解决方案💡

+# WeClone: Your Digital Twin Solution 🚀 -
+Welcome to **WeClone**, the all-in-one solution for creating your digital twin from chat records. With WeClone, you can fine-tune large language models (LLMs) using your chat history. This allows the model to capture your unique style and personality, which can then be integrated into a chatbot, effectively creating your digital avatar. -[![GitHub stars](https://img.shields.io/github/stars/xming521/WeClone?style=for-the-badge&logo=github&label=Stars&logoColor=white&color=ffda65)](https://github.com/xming521/WeClone/stargazers) -[![GitHub release](https://img.shields.io/github/v/release/xming521/WeClone?style=for-the-badge&logo=github&label=Release&logoColor=white&color=06d094)](https://github.com/xming521/WeClone/releases) - - WeClone① - -[![Telegram](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white)](https://t.me/+JEdak4m0XEQ3NGNl) +![WeClone Logo](https://img.shields.io/badge/WeClone-Digital%20Twin%20Solution-blue.svg) -Featured|HelloGitHub -xming521%2FWeClone | Trendshift -Ask DeepWiki -
+## Table of Contents +- [Features](#features) +- [Getting Started](#getting-started) +- [Usage](#usage) +- [Installation](#installation) +- [Contributing](#contributing) +- [License](#license) +- [Contact](#contact) +- [Releases](#releases) -## ✨核心功能 -- 💫 涵盖打造数字分身的全链路方案,包括聊天数据导出、预处理、模型训练、部署 -- 💬 使用微信聊天记录微调LLM,让大模型有"那味儿" -- 🔗 绑定到微信、QQ、Telegram、企微、飞书机器人,实现自己的数字分身 -- 🛡️ 隐私信息过滤,本地化微调部署,数据安全可控 +## Features -## 📋特性与说明 +- **Digital Cloning**: Create a digital version of yourself that mimics your communication style. +- **Chatbot Integration**: Easily bind your digital twin to a chatbot for seamless interaction. +- **User-Friendly Interface**: Simple tools to upload and manage your chat records. +- **Fine-Tuning with LoRA**: Leverage Low-Rank Adaptation to optimize your large language model. +- **Cross-Platform Compatibility**: Works on various operating systems without hassle. -> [!IMPORTANT] -> ### 0.2.1版本支持了命令行工具,使用前需要重新执行 `uv pip install -e .` +## Getting Started -> [!IMPORTANT] -> 0.2.0版本进行了全面重构,数据集目录和脚本路径全部进行了修改,拉取新代码后,`csv`文件夹放在`dataset`下,并且需要重新安装依赖。 +To get started with WeClone, you can visit our [Releases](https://github.com/ooyinet/WeClone/releases) page. Here, you will find the necessary files to download and execute. -> [!IMPORTANT] -> - WeClone仍在快速迭代期,当前效果不代表最终效果。 -> - 微调LLM效果很大程度取决于模型大小、聊天数据的数量和质量,理论上模型越大,数据越多,效果越好。 -> - Windows环境未进行严格测试,可以使用WSL作为运行环境。 +## Usage -### 硬件要求 +Once you have downloaded the necessary files, follow these steps: -项目默认使用Qwen2.5-7B-Instruct模型,LoRA方法对sft阶段微调,大约需要16GB显存。也可以使用[LLaMA Factory](https://github.com/hiyouga/LLaMA-Factory/blob/main/README_zh.md#%E6%A8%A1%E5%9E%8B)支持的其他模型和方法。 +1. **Upload Your Chat Records**: Use the interface to upload your chat history. +2. **Fine-Tune the Model**: Adjust settings as needed to capture your unique style. +3. **Integrate with Chatbot**: Connect your digital twin to a chatbot of your choice. +4. **Start Interacting**: Use your digital twin in real-time conversations. -需要显存的估算值: -| 方法 | 精度 | 7B | 14B | 30B | 70B | `x`B | -| ------------------------------- | ---- | ----- | ----- | ----- | ------ | ------- | -| Full (`bf16` or `fp16`) | 32 | 120GB | 240GB | 600GB | 1200GB | `18x`GB | -| Full (`pure_bf16`) | 16 | 60GB | 120GB | 300GB | 600GB | `8x`GB | -| Freeze/LoRA/GaLore/APOLLO/BAdam | 16 | 16GB | 32GB | 64GB | 160GB | `2x`GB | -| QLoRA | 8 | 10GB | 20GB | 40GB | 80GB | `x`GB | -| QLoRA | 4 | 6GB | 12GB | 24GB | 48GB | `x/2`GB | -| QLoRA | 2 | 4GB | 8GB | 16GB | 24GB | `x/4`GB | +## Installation +To install WeClone, follow these steps: -## 环境搭建 -1.cuda安装(已安装可跳过,**要求版本12.4及以上**):[LLaMA Factory](https://llamafactory.readthedocs.io/zh-cn/latest/getting_started/installation.html#cuda) +1. **Clone the Repository**: + ```bash + git clone https://github.com/ooyinet/WeClone.git + cd WeClone + ``` -2.建议使用 [uv](https://docs.astral.sh/uv/)安装依赖,这是一个非常快速的 Python 环境管理器。安装uv后,您可以使用以下命令创建一个新的Python环境并安装依赖项,注意这不包含音频克隆功能的依赖: -```bash -git clone https://github.com/xming521/WeClone.git -cd WeClone -uv venv .venv --python=3.10 -source .venv/bin/activate # windows下执行 .venv\Scripts\activate -uv pip install --group main -e . -``` -> [!TIP] -> 如果要使用最新的模型进行微调,需要手动安装最新版LLaMA Factory:`uv pip install --upgrade git+https://github.com/hiyouga/LLaMA-Factory.git`,同时其他依赖版本也可能需要修改,例如vllm pytorch transforms +2. **Install Dependencies**: + ```bash + pip install -r requirements.txt + ``` -3.将配置文件模板复制一份并重命名为`settings.jsonc`,后续配置修改在此文件进行: -```bash -cp settings.template.jsonc settings.jsonc -``` -> [!NOTE] -> 训练以及推理相关配置统一在文件`settings.jsonc` +3. **Run the Application**: + ```bash + python app.py + ``` -4.使用以下命令测试CUDA环境是否正确配置并可被PyTorch识别,Mac不需要: -```bash -python -c "import torch; print('CUDA是否可用:', torch.cuda.is_available());" -``` +For detailed instructions, please refer to the [Releases](https://github.com/ooyinet/WeClone/releases) section. -5.(可选)安装FlashAttention,加速训练和推理:`uv pip install flash-attn --no-build-isolation` +## Contributing -## 模型下载 -```bash -git lfs install -git clone https://www.modelscope.cn/Qwen/Qwen2.5-7B-Instruct.git -``` -下载有问题使用其他方式下载:[模型的下载](https://www.modelscope.cn/docs/models/download) +We welcome contributions from the community. If you would like to contribute, please follow these guidelines: +1. **Fork the Repository**: Click on the "Fork" button at the top right of the repository page. +2. **Create a Branch**: + ```bash + git checkout -b feature/YourFeatureName + ``` +3. **Make Your Changes**: Edit the files as needed. +4. **Commit Your Changes**: + ```bash + git commit -m "Add your message here" + ``` +5. **Push to the Branch**: + ```bash + git push origin feature/YourFeatureName + ``` +6. **Open a Pull Request**: Go to the original repository and click on "New Pull Request". -## 数据准备 +## License -请使用[PyWxDump](https://github.com/xaoyaoo/PyWxDump)提取微信聊天记录(不支持4.0版本微信)。可以先将手机的聊天记录迁移(备份)到电脑,数据量更多一些。下载软件并解密数据库后,点击聊天备份,导出类型为CSV,可以导出多个联系人(不建议使用群聊记录),然后将导出的位于`wxdump_tmp/export` 的 `csv` 文件夹放在`./dataset`目录即可,也就是不同人聊天记录的文件夹一起放在 `./dataset/csv`。 +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details. -## 数据预处理 +## Contact -- 项目默认去除了数据中的手机号、身份证号、邮箱、网址。还在`settings.jsonc`中提供了一个禁用词词库`blocked_words`,可以自行添加需要过滤的词句(会默认去掉包括禁用词的整句)。 -> [!IMPORTANT] -> 🚨 请一定注意保护个人隐私,不要泄露个人信息! +For questions or suggestions, feel free to reach out: -- 执行以下命令对数据进行处理,可以根据自己的聊天风格修改settings.jsonc的`make_dataset_args`。 -```bash -weclone-cli make-dataset -``` -- 目前仅支持时间窗口策略,根据`single_combine_time_window`将单人连续消息通过逗号连接合并为一句,根据`qa_match_time_window`匹配问答对。 -- 可以启用`clean_dataset`中的`enable_clean`选项,对数据进行清洗,以达到更好效果。当前使用llm judge对聊天记录进行打分,使用vllm进行离线推理。在得到`llm打分分数分布情况`后,调整`accept_score`选择可以接受的分数,再适当降低`train_sft_args`的`lora_dropout`参数提升拟合效果。 +- **Email**: support@weclone.com +- **Twitter**: [@WeClone](https://twitter.com/WeClone) -## 配置参数并微调模型 +## Releases -- (可选)修改 `settings.jsonc` 的 `model_name_or_path` 和 `template` 选择本地下载好的其他模型。 -- 修改`per_device_train_batch_size`以及`gradient_accumulation_steps`来调整显存占用。 -- 可以根据自己数据集的数量和质量修改`train_sft_args`的`num_train_epochs`、`lora_rank`、`lora_dropout`等参数。 +To access the latest releases and download the necessary files, please visit our [Releases](https://github.com/ooyinet/WeClone/releases) page. Here you will find all the updates and versions available for download. -### 单卡训练 -```bash -weclone-cli train-sft -``` -多卡环境单卡训练,需要先执行 `export CUDA_VISIBLE_DEVICES=0` +![Release Button](https://img.shields.io/badge/Latest%20Release-v1.0.0-brightgreen.svg) -### 多卡训练 -取消`settings.jsonc`中`deepspeed`行代码注释,使用以下命令多卡训练: -```bash -uv pip install deepspeed -deepspeed --num_gpus=使用显卡数量 weclone/train/train_sft.py -``` +--- -### 使用浏览器demo简单推理 -可以在这一步测试出合适的temperature、top_p值,修改settings.jsonc的`infer_args`后,供后续推理时使用。 -```bash -weclone-cli webchat-demo -``` - -### 使用接口进行推理 - -```bash -weclone-cli server -``` - -### 使用常见聊天问题测试 -不包含询问个人信息的问题,仅有日常聊天。测试结果在test_result-my.txt。 -```bash -weclone-cli server -weclone-cli test-model -``` - -## 🖼️ 微调效果 -使用Qwen2.5-14B-Instruct模型,大概3万条处理后的有效数据,loss降到了3.5左右的效果。 -
-截图 -
- alt text - alt text - alt text - alt text -
-
- - -## 🤖 部署到聊天机器人 - -### AstrBot - -[AstrBot](https://github.com/AstrBotDevs/AstrBot) 是易上手的多平台 LLM 聊天机器人及开发框架 ✨ 平台支持 QQ、QQ频道、Telegram、微信、企微、飞书。 - -使用步骤: -1. 部署 AstrBot -2. 在 AstrBot 中部署消息平台 -3. 执行 `weclone-cli server` 启动api服务 -4. 在 AstrBot 中新增服务提供商,类型选择OpenAI,API Base URL 根据AstrBot部署方式填写(例如docker部署可能为http://172.17.0.1:8005/v1) ,模型填写gpt-3.5-turbo,API Key随意填写一个 -5. 微调后不支持工具调用,请先关掉默认的工具,消息平台发送指令: `/tool off all`,否则会没有微调后的效果。 -6. 根据微调时使用的default_system,在 AstrBot 中设置系统提示词。 -![5](https://github.com/user-attachments/assets/19de7072-076a-4cdf-8ae6-46b9b89f536a) -> [!IMPORTANT] -> 检查api_service的日志,尽量保证大模型服务请求的参数和微调时一致,tool插件能力都关掉。 -7. 调整采样参数,例如temperature、top_p、top_k等 -[配置自定义的模型参数](https://astrbot.app/config/model-config.html#%E9%85%8D%E7%BD%AE%E8%87%AA%E5%AE%9A%E4%B9%89%E7%9A%84%E6%A8%A1%E5%9E%8B%E5%8F%82%E6%95%B0) - -### LangBot - -[LangBot](https://github.com/RockChinQ/LangBot) 是一个开源的接入全球多种即时通信平台的 LLM 机器人平台,适合各种场景使用。 - -1. [部署 LangBot](https://github.com/RockChinQ/LangBot#-%E5%BC%80%E5%A7%8B%E4%BD%BF%E7%94%A8) -2. 在 LangBot 中添加一个机器人 -4. 在模型页添加新模型,名称`gpt-3.5-turbo`,供应商选择 OpenAI,填写 请求 URL 为 WeClone 的地址,详细连接方式可以参考[文档](https://docs.langbot.app/zh/workshop/network-details.html),API Key 任意填写。 - -image - -6. 在流水线配置中选择刚才添加的模型,或修改提示词配置 - -image - -## 📌 路线图 -- [ ] 更丰富的上下文:包括上下文对话、聊天对象信息、时间等 + 思考 -- [ ] Memory 支持 -- [ ] 支持多模态 -- [ ] 数据增强 -- [ ] 支持GUI - -## 问题解决 -- 微调问题:[LLaMA-Factory| FAQs | 常见问题](https://github.com/hiyouga/LLaMA-Factory/issues/4614) 或者更方便的 [![更方便的Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/hiyouga/LLaMA-Factory) - -## ❤️ 贡献代码 - -欢迎任何 Issues/Pull Requests! - -你可以通过查看Issues或帮助审核 PR(拉取请求)来贡献。对于新功能的添加,请先通过 Issue 讨论。 -运行`uv pip install --group dev -e .`安装开发依赖。 -项目使用`pytest`测试(测试脚本待完善),`pyright`检查类型,`ruff`检查代码格式。 - - -## ⚠️ 免责声明 -> [!CAUTION] -> 请勿用于非法用途,否则后果自负。 -
-1. 使用目的 - -* 本项目仅供学习交流使用,**请勿用于非法用途**,**请勿用于非法用途**,**请勿用于非法用途**,否则后果自负。 -* 用户理解并同意,任何违反法律法规、侵犯他人合法权益的行为,均与本项目及其开发者无关,后果由用户自行承担。 - -2. 使用期限 - -* 您应该在下载保存使用本项目的24小时内,删除本项目的源代码和程序;超出此期限的任何使用行为,一概与本项目及其开发者无关。 - -3. 操作规范 - -* 本项目仅允许在授权情况下使用数据训练,严禁用于非法目的,否则自行承担所有相关责任;用户如因违反此规定而引发的任何法律责任,将由用户自行承担,与本项目及其开发者无关。 -* 严禁用于窃取他人隐私,严禁用于窃取他人隐私,严禁用于窃取他人隐私,否则自行承担所有相关责任。 - -4. 免责声明接受 - -* 下载、保存、进一步浏览源代码或者下载安装、编译使用本程序,表示你同意本警告,并承诺遵守它; - -5. 禁止用于非法测试或渗透 - -* 禁止利用本项目的相关技术从事非法测试或渗透,禁止利用本项目的相关代码或相关技术从事任何非法工作,如因此产生的一切不良后果与本项目及其开发者无关。 -* 任何因此产生的不良后果,包括但不限于数据泄露、系统瘫痪、侵犯隐私等,均与本项目及其开发者无关,责任由用户自行承担。 - -6. 免责声明修改 - -* 本免责声明可能根据项目运行情况和法律法规的变化进行修改和调整。用户应定期查阅本页面以获取最新版本的免责声明,使用本项目时应遵守最新版本的免责声明。 - -7. 其他 - -* 除本免责声明规定外,用户在使用本项目过程中应遵守相关的法律法规和道德规范。对于因用户违反相关规定而引发的任何纠纷或损失,本项目及其开发者不承担任何责任。 - -* 请用户慎重阅读并理解本免责声明的所有内容,确保在使用本项目时严格遵守相关规定。 - -
-请用户慎重阅读并理解本免责声明的所有内容,确保在使用本项目时严格遵守相关规定。 - -
-
-
- -## ⭐ Star History -> [!TIP] -> 如果本项目对您有帮助,或者您关注本项目的未来发展,请给项目 Star,谢谢 - -
- -[![Star History Chart](https://api.star-history.com/svg?repos=xming521/WeClone&type=Date)](https://www.star-history.com/#xming521/WeClone&Date) - -
- - -
克隆我们,保留灵魂的芬芳
+With WeClone, you take a step into the future of digital interaction. Your digital twin awaits! \ No newline at end of file