optimizeqamapper
February 4, 2026 · View on GitHub
Mapper to optimize question-answer pairs.
This operator refines and enhances the quality of question-answer pairs. It uses a Hugging Face model to generate more detailed and accurate questions and answers. The input is formatted using a template, and the output is parsed using a regular expression. The system prompt, input template, and output pattern can be customized. If VLLM is enabled, the operator accelerates inference on CUDA devices.
优化问答对的映射器。
该算子改进和提高问答对的质量。它使用Hugging Face模型生成更详细和准确的问题和答案。输入使用模板格式化,输出通过正则表达式解析。可以自定义系统提示、输入模板和输出模式。如果启用了VLLM,算子将在CUDA设备上加速推理。
Type 算子类型: mapper
Tags 标签: gpu, vllm, hf, api
🔧 Parameter Configuration 参数配置
| name 参数名 | type 类型 | default 默认值 | desc 说明 |
|---|---|---|---|
api_or_hf_model | <class 'str'> | 'Qwen/Qwen2.5-7B-Instruct' | API or huggingface model name. |
is_hf_model | <class 'bool'> | True | If true, use huggingface model. Otherwise, use API. |
api_endpoint | typing.Optional[str] | None | URL endpoint for the API. |
response_path | typing.Optional[str] | None | Path to extract content from the API response. Defaults to 'choices.0.message.content'. |
system_prompt | typing.Optional[str] | None | System prompt for guiding the optimization task. |
input_template | typing.Optional[str] | None | Template for building the input for the model. Please make sure the template contains one placeholder '{}', which corresponds to the question and answer pair generated by param qa_pair_template. |
qa_pair_template | typing.Optional[str] | None | Template for formatting the question and answer pair. Please make sure the template contains two '{}' to format question and answer. |
output_pattern | typing.Optional[str] | None | Regular expression pattern to extract question and answer from model response. |
try_num | typing.Annotated[int, Gt(gt=0)] | 3 | The number of retry attempts when there is an API call error or output parsing error. |
enable_vllm | <class 'bool'> | False | Whether to use VLLM for inference acceleration. |
model_params | typing.Optional[typing.Dict] | None | Parameters for initializing the model. |
sampling_params | typing.Optional[typing.Dict] | None | Sampling parameters for text generation (e.g., {'temperature': 0.9, 'top_p': 0.95}). |
kwargs | '' | Extra keyword arguments. |