# train-tools-for-mega **Repository Path**: awko/train-tools-for-mega ## Basic Information - **Project Name**: train-tools-for-mega - **Description**: 一个用于 mega平台训练的脚本工具 - **Primary Language**: Python - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-04-26 - **Last Updated**: 2024-05-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # train-tools-for-mega #### 介绍 一个用于 mega平台训练的脚本工具 ### 使用说明 ```bash git clone https://gitee.com/awko/train-tools-for-mega.git cd train-tools-for-mega sh init.sh # [可选]启动 文件管理服务 ,mega 示例需要开通 7890端口 # nohup python app.sh > app.log 2>&1 & # export TRANSFORMERS_CACHE=/openbayes/home/models # 可选 指定模型下载缓存 # 执行文件开始训练 python train.py # 测试对话 python test.py ``` 使用训练框架: https://github.com/unslothai/unsloth ### 如果使用 llama-factory 训练 https://github.com/hiyouga/LLaMA-Factory/blob/main/examples/README_zh.md ```shell git clone https://github.com/hiyouga/LLaMA-Factory.git cd LLaMA-Factory pip install -e .[metrics] # export TRANSFORMERS_CACHE=/openbayes/home/models # 可选 指定模型下载缓存 # 训练 CUDA_VISIBLE_DEVICES=0 llamafactory-cli train examples/lora_single_gpu/llama3_lora_sft.yaml # 推理测试 CUDA_VISIBLE_DEVICES=0 llamafactory-cli chat examples/inference/llama3_lora_sft.yaml # 合并导出 CUDA_VISIBLE_DEVICES=0 llamafactory-cli export examples/merge_lora/llama3_lora_sft.yaml ``` ### 通过 ollama 来量化模型 ```shell # First, clone the ollama/ollama repo: git clone git@github.com:ollama/ollama.git ollama cd ollama # and then fetch its llama.cpp submodule: git submodule init git submodule update llm/llama.cpp # Next, install the Python dependencies: python3 -m venv llm/llama.cpp/.venv source llm/llama.cpp/.venv/bin/activate pip install -r llm/llama.cpp/requirements.txt # 然后构建量化工具: make -C llm/llama.cpp quantize # Convert the model # 注意:一些模型体系结构需要使用特定的转换脚本。例如,Qwen模型需要运行convert-hf-to-gguf.py而不是convert.py python llm/llama.cpp/convert.py ./model --outtype f16 --outfile converted.bin # 如果是 llama3 模型 需制定:--vocab-type bpe # python llm/llama.cpp/convert.py ./model --outtype f16 --vocab-type bpe --outfile converted.gguf ``` ### ollama挂载本地模型 ```shell # 创建文件 Modelfile 内容如下 FROM quantized.bin TEMPLATE "[INST] {{ .Prompt }} [/INST]" # Create the Ollama model ollama create example -f Modelfile # Run your model ollama run example ```