使用默认本地模型路径启动:
python server_qwen3_32b.py --port 8000显式指定模型路径启动:
python server_qwen3_32b.py \
--model-path /data1/luxuhao/workspace/jk-infra/models/qwen/Qwen3-32B \
--port 8000带更多显式引擎参数的启动示例:
python server_qwen3_32b.py \
--model-path /data1/luxuhao/workspace/jk-infra/models/qwen/Qwen3-32B \
--devices 2,3,4,5 \
--port 8000 \
--max-num-seqs 64 \
--max-num-batched-tokens 32768 \
--gpu-memory-utilization 0.95服务启动后会暴露以下接口:
GET /healthGET /statsPOST /generatePOST /loglikelihoodPOST /loglikelihood_rolling
先用下面的命令检查服务是否正常:
curl http://127.0.0.1:8000/health健康检查接口。
返回示例:
{
"status": "ok",
"uptime": 123.45
}返回当前引擎队列状态。
返回示例:
{
"status": "ok",
"queue_stats": {
"running": {
"task_count": 2,
"decode_tokens_remaining": 128
},
"waiting": {
"task_count": 5,
"compute_tokens_remaining": 4096
}
}
}文本生成接口。
支持的请求字段:
IDprompttemperaturemax_tokens或max_gen_tokstop_ptop_kuntil或stopignore_eos
文本输入示例:
curl -sS -X POST http://127.0.0.1:8000/generate \
-H 'Content-Type: application/json' \
-d '{
"ID": 1,
"prompt": "Context: Tom has 3 apples and gets 2 more.\nQuestion: How many apples does he have now?\nAnswer:",
"temperature": 0.0,
"max_gen_toks": 64,
"top_p": 1.0,
"top_k": 1,
"until": ["\n\n"]
}'返回示例:
{
"ID": 1,
"text": " 5"
}说明:
- 这是生成接口,会生成新 token。
- 返回里只包含请求
ID和生成出的text。 until只有在生成文本中实际出现对应字符串时才会截断。
计算 log P(eval_continuation | prompt),不会生成 token。
平台请求格式:
{
"ID": 0,
"prompt": "Context text...",
"eval_request_type": "loglikelihood",
"eval_continuation": "choice A",
"eval_gen_kwargs": null
}调用示例:
curl -sS -X POST http://127.0.0.1:8000/loglikelihood \
-H 'Content-Type: application/json' \
-d '{
"ID": 0,
"prompt": "The capital of France is",
"eval_request_type": "loglikelihood",
"eval_continuation": " Paris",
"eval_gen_kwargs": null
}'返回:
{
"ID": 0,
"accuracy": -3.27
}说明:
accuracy就是当前这一个候选答案的总 logprob。- 如果一道选择题有多个候选,平台应针对每个候选分别发一次请求,再对各候选的
accuracy做argmax。 - 这个接口不会生成 token。
计算整段 prompt 的 rolling log-likelihood,不会生成 token。
请求格式:
{
"ID": 0,
"prompt": "A long document text...",
"eval_request_type": "loglikelihood_rolling",
"eval_continuation": null,
"eval_gen_kwargs": null
}调用示例:
curl -sS -X POST http://127.0.0.1:8000/loglikelihood_rolling \
-H 'Content-Type: application/json' \
-d '{
"ID": 0,
"prompt": "A long document text...",
"eval_request_type": "loglikelihood_rolling",
"eval_continuation": null,
"eval_gen_kwargs": null
}'返回:
{
"ID": 0,
"accuracy": -123.45
}说明:
accuracy是整段文本的 rolling log-likelihood 总和。- 这个接口不会生成 token。
统一三类任务的评测脚本:
benchmark_eval_jk_infra_with_service.py
支持的任务类型:
generate_untilloglikelihoodloglikelihood_rolling
运行全部支持的任务:
python benchmark_eval_jk_infra_with_service.py \
--data-file JK-infra-eval_data/data/delivery/athlete_main_800_available_protocol_close_v1/full_task_pool.jsonl \
--task-types all \
--concurrency 8 \
--output athlete_main_results.jsonl只运行生成任务:
python benchmark_eval_jk_infra_with_service.py \
--data-file JK-infra-eval_data/data/delivery/athlete_main_800_available_protocol_close_v1/full_task_pool.jsonl \
--task-types generate_until \
--output generate_results.jsonl只运行 likelihood 相关任务:
python benchmark_eval_jk_infra_with_service.py \
--data-file JK-infra-eval_data/data/delivery/athlete_main_800_available_protocol_close_v1/full_task_pool.jsonl \
--task-types loglikelihood,loglikelihood_rolling \
--output likelihood_results.jsonl