Agent SkillsOpenDCAI/DataFlow-WebUI › text2multihopqa-generator

text2multihopqa-generator

GitHub

Text2MultiHopQAGenerator算子,用于从长文本列生成多跳问答对及元数据。它读取输入文本,调用LLM生成推理式QA,将结果写入指定输出列,并过滤掉未生成QA的行,适用于需要复杂推理的问答场景。

skills/canonical/core_text/generate/text2multihopqa-generator/SKILL.md OpenDCAI/DataFlow-WebUI

Trigger Scenarios

需要从长文本生成多跳推理问答对 构建数据处理流水线中的文本转换算子

Install

npx skills add OpenDCAI/DataFlow-WebUI --skill text2multihopqa-generator -g -y
More Options

Non-standard path

npx skills add https://github.com/OpenDCAI/DataFlow-WebUI/tree/main/skills/canonical/core_text/generate/text2multihopqa-generator -g -y

Use without installing

npx skills use OpenDCAI/DataFlow-WebUI@text2multihopqa-generator

指定 Agent (Claude Code)

npx skills add OpenDCAI/DataFlow-WebUI --skill text2multihopqa-generator -a claude-code -g -y

安装 repo 全部 skill

npx skills add OpenDCAI/DataFlow-WebUI --all -g -y

预览 repo 内 skill

npx skills add OpenDCAI/DataFlow-WebUI --list

SKILL.md

Frontmatter
{
    "name": "text2multihopqa-generator",
    "description": "Reference documentation for the Text2MultiHopQAGenerator operator.\n[Purpose] Generates multi-hop QA pairs from one text column and writes two output columns: one for `qa_pairs` and one for metadata.\n[When to use] Use it when you want reasoning-style QA pairs derived from longer text chunks. If only simple single-hop QA is needed, use `Text2QAGenerator` instead."
}

Text2MultiHopQAGenerator Operator Reference

Text2MultiHopQAGenerator reads one text column, generates up to num_q multi-hop QA pairs per input row, stores the per-row QA list in output_key, stores metadata in output_meta_key, then filters out rows whose generated QA list is empty.

See examples/good.md for a valid pipeline pattern and examples/bad.md for common failure cases.


1. Import

from dataflow.operators.core_text import Text2MultiHopQAGenerator

2. Constructor

Text2MultiHopQAGenerator(
    llm_serving=llm,
    seed=0,
    lang="en",
    prompt_template=None,
    num_q=5,
)
Parameter Required Default Description
llm_serving Yes None LLM backend passed through to ExampleConstructor, which later calls generate_from_input(...).
seed No 0 Used to initialize random.Random(seed).
lang No "en" Controls prompt construction and sentence splitting logic.
prompt_template No None If omitted, uses Text2MultiHopQAGeneratorPrompt(lang=self.lang).
num_q No 5 Maximum number of QA pairs kept per row after generation.

3. run() Signature

op.run(
    storage=self.storage.step(),
    input_key="cleaned_chunk",
    output_key="QA_pairs",
    output_meta_key="QA_metadata",
)
Parameter Required Default Description
storage Yes None Used as storage.read("dataframe") and storage.write(dataframe).
input_key No "cleaned_chunk" Source text column. This column must already exist.
output_key No "QA_pairs" Output column containing a list of QA dicts for each remaining row. This column must not already exist.
output_meta_key No "QA_metadata" Output column containing metadata dicts for each remaining row.

Return Value

The method returns [output_key].


4. Actual Runtime Logic

The source code behavior is:

  1. Read the DataFrame from storage.
  2. Validate that input_key exists.
  3. Validate that output_key does not already exist.
  4. Read all texts from dataframe[input_key].tolist().
  5. Generate one example record per input row via process_batch(...).
  6. Truncate each row's qa_pairs list to at most num_q.
  7. Write QA lists to output_key and metadata dicts to output_meta_key.
  8. Drop rows whose output_key is not a non-empty list.
  9. Write the filtered DataFrame back to storage.
  10. Return [output_key].

Important consequences:

  • The operator does not expand one row into multiple rows.
  • The final row count is less than or equal to the input row count.
  • Rows with empty generated QA lists are removed entirely.

5. Text Filtering Rules

Inside ExampleConstructor, a text can fail before QA generation if:

  • it is not a string,
  • its length is less than 100,
  • its length is greater than 200000,
  • it fails the basic sentence-count or special-character quality checks.

When that happens, the row gets an empty qa_pairs list first, and is then filtered out by run().


6. Important Constraints

  1. input_key must exist, otherwise run() raises ValueError.
  2. output_key must not already exist, otherwise run() raises ValueError.

Version History

  • 2e95d40 Current 2026-08-27 09:04

Same Skill Collection

skills/canonical/core_text/eval/bench-dataset-evaluator-question/SKILL.md
skills/canonical/core_text/eval/bench-dataset-evaluator/SKILL.md
skills/canonical/core_text/eval/prompted-evaluator/SKILL.md
skills/canonical/core_text/eval/text2qa-sample-evaluator/SKILL.md
skills/canonical/core_text/eval/unified-bench-dataset-evaluator/SKILL.md
skills/canonical/core_text/filter/general-filter/SKILL.md
skills/canonical/core_text/filter/kcentergreedy-filter/SKILL.md
skills/canonical/core_text/filter/prompted-filter/SKILL.md
skills/canonical/core_text/generate/bench-answer-generator/SKILL.md
skills/canonical/core_text/generate/chunked-prompted-generator/SKILL.md
skills/canonical/core_text/generate/embedding-generator/SKILL.md
skills/canonical/core_text/generate/format-str-prompted-generator/SKILL.md
skills/canonical/core_text/generate/prompted-generator/SKILL.md
skills/canonical/core_text/generate/retrieval-generator/SKILL.md
skills/canonical/core_text/refine/pandas-operator/SKILL.md
skills/canonical/core_text/refine/prompted-refiner/SKILL.md
skills/canonical/core_text/SKILL.md
skills/canonical/dataflow-dev/SKILL.md
skills/canonical/dataflow-operator-builder/SKILL.md
skills/canonical/generating-dataflow-pipeline/SKILL.md
skills/canonical/prompt-template-builder/SKILL.md
skills/canonical/core_text/generate/random-domain-knowledge-row-generator/SKILL.md

Metadata

Files
0
Version
2e95d40
Hash
e243500b
Indexed
2026-08-27 09:04

Home - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-28 01:04
浙ICP备14020137号-1 $Map of visitor$