跳到内容

MonolingualTripletGenerator

使用 LLM 生成单语三元组,以便稍后训练嵌入模型。

MonolingualTripletGenerator 是一个 GeneratorTask,它使用 LLM 生成单语三元组,以便稍后训练嵌入模型。该任务基于论文“Improving Text Embeddings with Large Language Models”,并且数据基于提供的属性生成,如果未提供,则随机抽样。

属性

  • language: 要生成的数据的语言,可以是 https://aclanthology.org/2020.acl-main.747.pdf 附录 A 中 XLM-R 列表中检索到的任何语言。

  • unit: 要生成的数据的单元,可以是 sentencephrasepassage。默认为 None,表示将随机抽样。

  • difficulty: 要生成的查询的难度,可以是 elementary schoolhigh schoolcollege。默认为 None,表示将随机抽样。

  • high_score: 要生成的查询的高分,可以是 44.55。默认为 None,表示将随机抽样。

  • low_score: 要生成的查询的低分,可以是 2.533.5。默认为 None,表示将随机抽样。

  • seed: 在 format_input 方法中进行任何抽样时要设置的随机种子。

输入 & 输出列

graph TD
    subgraph Dataset
        subgraph New columns
            OCOL0[S1]
            OCOL1[S2]
            OCOL2[S3]
            OCOL3[model_name]
        end
    end

    subgraph MonolingualTripletGenerator
        StepOutput[Output Columns: S1, S2, S3, model_name]
    end

    StepOutput --> OCOL0
    StepOutput --> OCOL1
    StepOutput --> OCOL2
    StepOutput --> OCOL3

输出

  • S1 (str): LLM 生成的第一个句子。

  • S2 (str): LLM 生成的第二个句子。

  • S3 (str): LLM 生成的第三个句子。

  • model_name (str): 用于生成单语三元组的模型的名称。

示例

生成单语三元组以训练嵌入模型

from distilabel.pipeline import Pipeline
from distilabel.steps.tasks import MonolingualTripletGenerator

with Pipeline("my-pipeline") as pipeline:
    task = MonolingualTripletGenerator(
        language="English",
        unit="sentence",
        difficulty="elementary school",
        high_score="4",
        low_score="2.5",
        llm=...,
    )

    ...

    task >> ...