微软开源的 推理 LLM 代理工具集

天问 3539c4fe7c Update 'README.md' 6 months ago
README.md 3539c4fe7c Update 'README.md' 6 months ago

README.md

ToRA

微软开源的 推理 LLM 代理工具集,解决数学推理问题,一个数学问题,给出答案,python代码实现。

Usage

git clone https://github.com/microsoft/ToRA.git && cd ToRA/src

conda create -n tora python=3.10
conda activate tora
pip install torch==2.0.1 --index-url https://download.pytorch.org/whl/cu118 # CUDA 11.8 for example
pip install -r requirements.txt

# 训练
bash scritps/train.sh codellama 7b

# 评估
python -m eval.evaluate \
    --data_name "math" \
    --prompt_type "tora" \
    --file_path "outputs/llm-agents/tora-code-34b-v1.0/math/test_tora_-1_seed0_t0.0_s0_e5000.jsonl" \
    --execute
    

模型下载: https://huggingface.co/llm-agents

源码分析

requirements.txt

flask + gradio 构建接口和用户界面。 pebble 多线程 accelerate PyTorch transformers

训练数据

设置GPU核心数,哪个模型:7B/34b,模型位置

accelerate launch \
    --main_process_port 18200 \
    --mixed_precision bf16 \
    --num_machines 1 \
    --num_processes $NUM_GPUS \
    --use_deepspeed \
    --deepspeed_config_file $DEEPSPEED \
    train/finetune.py \
    --model_name_or_path ${MODEL_PATH} \
    --use_slow_tokenizer \
    --gradient_checkpointing \
    --train_file $TRAIN_FILE \
    --max_seq_length 2048 \
    --preprocessing_num_workers 16 \
    --per_device_train_batch_size $BATCH_SIZE_PER_GPU \
    --gradient_accumulation_steps $GRADIENT_ACC_STEPS \
    --learning_rate $LEARNING_RATE \
    --lr_scheduler_type linear \
    --warmup_ratio 0.03 \
    --weight_decay 0. \
    --num_train_epochs $NUM_TRAIN_EPOCHS \
    --output_dir $OUTPUT_DIR \
    --with_tracking \
    --report_to tensorboard \
    --logging_steps 1 \
    --use_flash_attn \
    --mask_prompt \
    | tee $OUTPUT_DIR/logs.txt

执行 microsoft/ToRA/src/train/finetune.py main 函数开始训练。