This document describes how to prepare models and serve them through a local OpenAI-compatible vLLM endpoint.
No model weights are committed to git. Downloads should go under the ignored
models/ directory on the machine that runs the experiment.
The first-stage base model configs are:
configs/models/qwen25_math_7b_instruct.yaml
configs/models/qwen25_05b_instruct.yaml
They define:
- Hugging Face repo id
- ModelScope repo id fallback
- local model directory
- served model name
- vLLM host, port, dtype, tensor parallel size, memory utilization, and max model length
The default port is 8000 for all configs. The first version assumes one model
is served at a time. If concurrent services are needed, override --port
manually.
The default vLLM max model length is 4096, matching the Qwen2.5-Math context
limit. EvalScope uses max_tokens: 2560, so prompts must stay short enough to
leave completion room.
Teacher:
PYTHONPATH=src python scripts/model/download_model.py \
--config configs/models/qwen25_math_7b_instruct.yamlStudent:
PYTHONPATH=src python scripts/model/download_model.py \
--config configs/models/qwen25_05b_instruct.yamlThe default source is auto, which tries Hugging Face first and falls back to
ModelScope if the Hugging Face command fails.
Use Hugging Face explicitly:
PYTHONPATH=src python scripts/model/download_model.py \
--config configs/models/qwen25_math_7b_instruct.yaml \
--source hfUse ModelScope explicitly:
PYTHONPATH=src python scripts/model/download_model.py \
--config configs/models/qwen25_math_7b_instruct.yaml \
--source modelscopeServe the teacher model:
PYTHONPATH=src python scripts/model/serve_vllm.py \
--config configs/models/qwen25_math_7b_instruct.yamlServe the base student model:
PYTHONPATH=src python scripts/model/serve_vllm.py \
--config configs/models/qwen25_05b_instruct.yamlThe script starts:
vllm serve <model_path> ... --generation-config vllm
Using --generation-config vllm keeps repository generation defaults from
silently changing experiment behavior.
To inspect the command without starting vLLM:
PYTHONPATH=src python scripts/model/serve_vllm.py \
--config configs/models/qwen25_05b_instruct.yaml \
--print-commandAfter starting vLLM, check the OpenAI-compatible endpoint:
PYTHONPATH=src python scripts/model/check_openai_server.py \
--base-url http://127.0.0.1:8000/v1 \
--model Qwen2.5-0.5B-InstructThe check calls /v1/models, chooses the first returned model unless --model
is provided, and sends one minimal chat completion request.
Teacher distillation uses the same OpenAI-compatible endpoint configured in:
configs/data/teacher_distill.yaml
Default teacher API settings:
api_base: http://127.0.0.1:8000/v1
api_key: EMPTY
api_type: chat_completions
Typical server-side sequence:
PYTHONPATH=src python scripts/model/download_model.py \
--config configs/models/qwen25_math_7b_instruct.yaml
PYTHONPATH=src python scripts/model/serve_vllm.py \
--config configs/models/qwen25_math_7b_instruct.yaml
PYTHONPATH=src python scripts/model/check_openai_server.py \
--base-url http://127.0.0.1:8000/v1 \
--model Qwen2.5-Math-7B-Instruct
PYTHONPATH=src python scripts/data/distill_with_teacher.py \
--config configs/data/teacher_distill.yamlRun the health check and distillation commands in another shell after vLLM is started.
Later SFT or GRPO checkpoints do not need dedicated model config files. Serve them directly:
PYTHONPATH=src python scripts/model/serve_vllm.py \
--model-path outputs/sft/sft_full/checkpoint-xxx \
--served-model-name sft_fullOverride vLLM settings when needed:
PYTHONPATH=src python scripts/model/serve_vllm.py \
--model-path outputs/sft/sft_full/checkpoint-xxx \
--served-model-name sft_full \
--port 8001 \
--max-model-len 32000Only use extra ports when running multiple model services concurrently.