| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- """
- FineTuneX 项目初始化脚本
- """
- import os
- import sys
- def create_directories():
- """创建必要的目录"""
- directories = [
- "outputs",
- "outputs/checkpoints",
- "data",
- "data/processed",
- "logs",
- "models",
- ]
-
- for directory in directories:
- os.makedirs(directory, exist_ok=True)
- print(f"✓ 创建目录:{directory}")
- def create_gitignore():
- """创建 .gitignore 文件"""
- gitignore_content = """# Python
- __pycache__/
- *.py[cod]
- *$py.class
- *.so
- .Python
- build/
- develop-eggs/
- dist/
- downloads/
- eggs/
- .eggs/
- lib/
- lib64/
- parts/
- sdist/
- var/
- wheels/
- *.egg-info/
- .installed.cfg
- *.egg
- # Virtual environments
- venv/
- env/
- ENV/
- .venv
- # IDE
- .vscode/
- .idea/
- *.swp
- *.swo
- *~
- # Jupyter Notebook
- .ipynb_checkpoints
- # Project specific
- outputs/
- *.pth
- *.pt
- *.bin
- *.onnx
- logs/
- *.log
- .DS_Store
- Thumbs.db
- # Secrets
- .env
- *.key
- *.pem
- """
-
- with open(".gitignore", "w", encoding="utf-8") as f:
- f.write(gitignore_content)
- print("✓ 创建 .gitignore")
- def create_env_example():
- """创建 .env.example 文件"""
- env_content = """# HuggingFace
- HF_TOKEN=your_huggingface_token_here
- HF_ENDPOINT=https://huggingface.co
- # Weights & Biases (可选)
- WANDB_API_KEY=your_wandb_key_here
- WANDB_PROJECT=finetunex
- # API Configuration
- API_HOST=0.0.0.0
- API_PORT=8000
- """
-
- with open(".env.example", "w", encoding="utf-8") as f:
- f.write(env_content)
- print("✓ 创建 .env.example")
- def create_readme():
- """创建快速开始 README"""
- readme_content = """# FineTuneX 快速开始
- ## 1. 安装依赖
- ```bash
- pip install -r requirements.txt
- ```
- ## 2. 运行示例
- ```bash
- python examples/qwen3.5_0.8b_finetune.py
- ```
- ## 3. 使用自己的数据
- 准备数据文件 `data.json`:
- ```json
- [
- {
- "instruction": "你的指令",
- "input": "输入(可选)",
- "output": "期望输出"
- }
- ]
- ```
- 修改示例脚本中的数据集路径,然后运行。
- ## 4. 推理
- ```bash
- python scripts/inference.py --model_path ./outputs/qwen3.5-0.5b-finetuned --interactive
- ```
- ## 5. API 服务
- ```bash
- python scripts/start_api.py
- ```
- 访问 http://localhost:8000/docs 查看 API 文档。
- ## 更多信息
- 查看 [完整文档](docs/usage.md)
- """
-
- with open("QUICKSTART.md", "w", encoding="utf-8") as f:
- f.write(readme_content)
- print("✓ 创建 QUICKSTART.md")
- def main():
- print("=" * 60)
- print("FineTuneX 项目初始化")
- print("=" * 60)
-
- create_directories()
- create_gitignore()
- create_env_example()
- create_readme()
-
- print("\n" + "=" * 60)
- print("项目初始化完成!")
- print("=" * 60)
- print("\n下一步:")
- print("1. 查看 QUICKSTART.md 了解快速开始")
- print("2. 查看 docs/usage.md 了解详细文档")
- print("3. 运行:python examples/qwen3.5_0.8b_finetune.py")
- print("=" * 60)
- if __name__ == "__main__":
- main()
|