conda config --show channels
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes
conda config --set ssl_verify false
conda config --remove channels conda-forge
conda clean -i
conda config --remove-key channels
conda clean --all -y
conda create -n llama_factory python=3.10 conda activate llama_factory
mkdir project
cd project
git clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git
cd LLaMA-Factory
git fetch --tags
git checkout -b v0.9.3 tags/v0.9.3
pip install -e ".[torch,metrics,liger-kernel,bitsandbytes,vllm,modelscope]"
quickstart
llama-factory
docker build -f ./docker/docker-cuda/Dockerfile \
--build-arg PIP_INDEX=https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple \
--build-arg EXTRAS=metrics \
-t llamafactory:latest .
docker build -f ./docker/docker-cuda/Dockerfile --build-arg PIP_INDEX=https://pypi.org/simple --build-arg EXTRAS=metrics -t llamafactory:latest .
docker run -dit --ipc=host -p 7860:7860 -p 8000:8000 --name llamafactory llamafactory:latest
docker exec -it llamafactory bash
# 给如下目录赋予权限 chmod -R 777 /app/data
# 启动web服务,命令如下: nohup llamafactory-cli webui > /app/webui.log 2>&1 &
访问 http://localhost:7860/
https://zhuanlan.zhihu.com/p/695287607
docker 镜像下载
https://www.rockylinux.cn/notes/docker-image-accelerator-and-configuration-guide.html
试用资源
https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory
微调8bit量化配置
CUDA_VISIBLE_DEVICES=0 llamafactory-cli train \
--model_name_or_path meta-llama/Meta-Llama-3-8B \
--stage sft \
--dataset your_dataset \
--quantization_bit 8 \
--quantization_method bitsandbytes \
--finetuning_type lora \
--lora_target q_proj,v_proj \
--lora_rank 8 \
--lora_alpha 32 \
--per_device_train_batch_size 1 \
--max_source_length 256 \
--gradient_checkpointing \
--flash_attn \
--output_dir ./output
CUDA_VISIBLE_DEVICES=0 llamafactory-cli train \
--stage sft \
--do_train \
--model_name_or_path /root/.cache/modelscope/hub/models/LLM-Research/Meta-Llama-3-8B-Instruct \
--dataset alpaca_gpt4_zh,identity,adgen_local \
--dataset_dir ./data \
--template llama3 \
--finetuning_type lora \
--output_dir ./saves/LLaMA3-8B/lora/sft \
--quantization_bit 4 \
--overwrite_cache \
--overwrite_output_dir \
--cutoff_len 1024 \
--preprocessing_num_workers 16 \
--per_device_train_batch_size 2 \
--per_device_eval_batch_size 1 \
--gradient_accumulation_steps 8 \
--lr_scheduler_type cosine \
--logging_steps 50 \
--warmup_steps 20 \
--save_steps 100 \
--eval_steps 50 \
--fp16 True \
--use_unsloth
watch -n 1 nvidia-smi
## 清洗
python WikiExtractor.py --infn zhwiki-20250720-pages-articles-multistream.xml.bz2
浙公网安备 33010602011771号