axolotl微调Qwen2
ollama部署Qwen2
ollama下载地址https://www.ollama.com/
ollama run qwen2:7b
ollama run qwen2:72b
为ollama开启公网ip
sudo mkdir -p /etc/systemd/system/ollama.service.d/
sudo nano /etc/systemd/system/ollama.service.d/override.conf
sudo nano /etc/systemd/system/ollama.service
输入
[Service]
Environment="OLLAMA_HOST=0.0.0.0"
然后Ctrl+O 按回车 再按Ctrl+X
sudo systemctl daemon-reload
sudo systemctl restart ollama.service
在浏览器访问 http://64.247.196.27:11434/v1
vLLM部署Qwen 7b
conda create -n myenv python=3.9 -y
conda activate myenv
pip install vllm
开启API
通用模型localhost
python -m vllm.entrypoints.openai.api_server --model Qwen/Qwen2-7B --dtype auto --api-key token-abc123
通用模型公网访问
python -m vllm.entrypoints.openai.api_server --model Qwen/Qwen2-7B --dtype auto --api-key token-abc123 --host 0.0.0.0
glm-4-9b的公网访问
需要将 trust_remote_code 选项设置为 True
python -m vllm.entrypoints.openai.api_server --model Qwen/Qwen2-7B --dtype auto --api-key token-abc123 --host 0.0.0.0 --trust-remote-code
接口信息
{
"model": "Qwen/Qwen2-7B",
"base_url": "http://64.247.196.36:8000/v1",
"api_key": "token-abc123",
},
autogen studio 安装和启动
pip install autogenstudio
autogenstudio ui --port 8081 --host 0.0.0.0
colab脚本https://colab.research.google.com/drive/1Vq_4i2AEaYqXVWdLt6HpGL-1hVdfWxQh#scrollTo=at5ei-2J8VZt
pdf处理
https://pypi.org/project/marker-pdf/
pip install marker-pdf
marker_single GPT.pdf ./folder --batch_multiplier 2 --max_pages 52 --langs English
配置
Axolotl 是一种旨在简化各种 AI 模型微调的工具,为多种配置和架构提供支持。
Python >=3.10 and Pytorch >=2.1.1
从 GitHub 克隆 axolotl 仓库
git clone https://github.com/OpenAccess-AI-Collective/axolotl
切换到 axolotl 目录
cd axolotl
将当前用户添加到 docker 组,以便在没有 sudo 的情况下运行 docker 命令
sudo usermod -aG docker $USER
更新组信息,使更改生效
newgrp docker
运行 axolotl docker 容器,使用所有可用的 GPU,并在退出时自动删除容器
docker hub https://hub.docker.com/r/winglian/axolotl/tags
docker run --gpus '"all"' --rm -it winglian/axolotl:main-latest
使用 Accelerate 库启动 axolotl 训练脚本,使用 examples/openllama-3b/qlora.yml 配置文件
accelerate launch -m axolotl.cli.train examples/qwen2/qlora-fsdp.yaml
数据集配置文件:
https://github.com/OpenAccess-AI-Collective/axolotl/blob/main/examples/qwen2/qlora-fsdp.yaml