diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000000000000000000000000000000000000..0207de13ac93a534815364784ce3fa97447f87cf --- /dev/null +++ b/README.en.md @@ -0,0 +1,85 @@ + + +# ZhiQing Language Model Project + +ZhiQing is a Chinese language model based on the Transformer architecture, supporting multiple training modes including pre-training, instruction fine-tuning (SFT), reinforcement learning with human feedback (RLHF), and direct preference optimization (DPO). This project aims to develop a model capable of understanding and generating high-quality Chinese text. + +## Features + +- Supports multiple training modes: pre-training, SFT, RLHF, DPO +- Efficient distributed training and memory monitoring +- Custom Chinese tokenizer and model architecture +- Mixed precision training support + +## Components + +- **Model Architecture**: Transformer-based decoder structure +- **Tokenizer**: Supports special processing for Chinese characters +- **Dataset**: Supports data formats for pre-training, SFT, DPO, and RLHF +- **Training Tools**: Includes learning rate scheduling, mixed precision training, distributed training, etc. +- **Evaluation Tools**: Includes GPU memory monitoring and distributed memory monitoring + +## Installation + +1. Clone the repository: +```bash +git clone https://gitee.com/starboot/ai.git +``` + +2. Install dependencies: +```bash +pip install -r requirements.txt +``` + +## Usage + +### Initialize Model and Tokenizer + +```python +from starboot.model_starboot import ZhiQingModel, ZhiQingConfig +from starboot.token.starboot_tokenizer import ZhiQingTokenizer + +config = ZhiQingConfig() +model = ZhiQingModel(config) +tokenizer = ZhiQingTokenizer('path/to/vocab.txt') +``` + +### Train the Model + +```python +from train import train + +train(num_epochs=10, batch_size=32) +``` + +### Inference + +```python +input_text = "这是一个示例输入" +input_ids = tokenizer.encode(input_text, return_tensors='pt') +output = model.generate(input_ids, max_new_tokens=50) +print(tokenizer.decode(output[0])) +``` + +### Supported Training Modes + +- Pre-training: `pretrain(num_epochs, batch_size)` +- Instruction Fine-Tuning: `sft_tuning(num_epochs, batch_size)` +- DPO Training: `dpo_tuning(num_epochs, batch_size)` + +## Datasets + +The following dataset formats are supported: + +- Pre-training dataset: `ZhiQingPretrainDataset` +- Instruction Fine-Tuning dataset: `ZhiQingSftDataset` +- DPO dataset: `ZhiQingDpoDataset` +- RLHF dataset: `ZhiQingRlhfDataset` + +## Contribution + +Contributions of code and suggestions are welcome. Please submit a Pull Request or open an Issue. + +## License + +This project is licensed under the MIT License. Please refer to the LICENSE file for details. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..99b28ec4b1110995487a9c0b6f7f5bd0307651d0 --- /dev/null +++ b/README.md @@ -0,0 +1,83 @@ +# ZhiQing 语言模型项目 + +ZhiQing 是一个基于Transformer架构的中文语言模型,支持多种训练模式,包括预训练、指令微调(SFT)、基于人类反馈的强化学习(RLHF)和直接偏好优化(DPO)。该项目旨在开发一个能够理解和生成高质量中文文本的模型。 + +## 特性 + +- 支持多种训练模式:预训练、SFT、RLHF、DPO +- 高效的分布式训练和内存监控 +- 自定义的中文分词器和模型架构 +- 混合精度训练支持 + +## 组件 + +- **模型架构**: 基于Transformer的解码器结构 +- **分词器**: 支持中文字符的特殊处理 +- **数据集**: 支持预训练、SFT、DPO和RLHF数据格式 +- **训练工具**: 包括学习率调度、混合精度训练、分布式训练等 +- **评估工具**: 包括GPU内存监控和分布式内存监控 + +## 安装 + +1. 克隆仓库: +```bash +git clone https://gitee.com/starboot/ai.git +``` + +2. 安装依赖: +```bash +pip install -r requirements.txt +``` + +## 使用 + +### 初始化模型和分词器 + +```python +from starboot.model_starboot import ZhiQingModel, ZhiQingConfig +from starboot.token.starboot_tokenizer import ZhiQingTokenizer + +config = ZhiQingConfig() +model = ZhiQingModel(config) +tokenizer = ZhiQingTokenizer('path/to/vocab.txt') +``` + +### 训练模型 + +```python +from train import train + +train(num_epochs=10, batch_size=32) +``` + +### 推理 + +```python +input_text = "这是一个示例输入" +input_ids = tokenizer.encode(input_text, return_tensors='pt') +output = model.generate(input_ids, max_new_tokens=50) +print(tokenizer.decode(output[0])) +``` + +### 支持的训练模式 + +- 预训练: `pretrain(num_epochs, batch_size)` +- 指令微调: `sft_truning(num_epochs, batch_size)` +- DPO训练: `dpo_truning(num_epochs, batch_size)` + +## 数据集 + +支持以下数据集格式: + +- 预训练数据集: `ZhiQingPretrainDataset` +- 指令微调数据集: `ZhiQingSftDataset` +- DPO数据集: `ZhiQingDpoDataset` +- RLHF数据集: `ZhiQingRlhfDataset` + +## 贡献 + +欢迎贡献代码和建议。请提交Pull Request或Issue。 + +## 许可证 + +该项目使用MIT许可证。详情请查看LICENSE文件。 \ No newline at end of file