BitextRetrievalGenerator¶
使用 LLM
生成双语文本检索数据,以便稍后训练嵌入模型。
BitextRetrievalGenerator
是一个 GeneratorTask
,它使用 LLM
生成双语文本检索数据,以便稍后训练嵌入模型。此任务基于论文 “Improving Text Embeddings with Large Language Models”,数据基于提供的属性生成,如果未提供,则随机采样。
属性¶
-
source_language: 要生成的数据的源语言,可以是 https://aclanthology.org/2020.acl-main.747.pdf 附录 A 中 XLM-R 列表中检索到的任何语言。
-
target_language: 要生成的数据的目标语言,可以是 https://aclanthology.org/2020.acl-main.747.pdf 附录 A 中 XLM-R 列表中检索到的任何语言。
-
unit: 要生成的数据的单元,可以是
sentence
、phrase
或passage
。默认为None
,表示将随机采样。 -
difficulty: 要生成的查询的难度,可以是
elementary school
、high school
或college
。默认为None
,表示将随机采样。 -
high_score: 要生成的查询的高分,可以是
4
、4.5
或5
。默认为None
,表示将随机采样。 -
low_score: 要生成的查询的低分,可以是
2.5
、3
或3.5
。默认为None
,表示将随机采样。 -
seed: 随机种子,用于在
format_input
方法中进行任何采样的情况。
输入 & 输出列¶
graph TD
subgraph Dataset
subgraph New columns
OCOL0[S1]
OCOL1[S2]
OCOL2[S3]
OCOL3[model_name]
end
end
subgraph BitextRetrievalGenerator
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 BitextRetrievalGenerator
with Pipeline("my-pipeline") as pipeline:
task = BitextRetrievalGenerator(
source_language="English",
target_language="Spanish",
unit="sentence",
difficulty="elementary school",
high_score="4",
low_score="2.5",
llm=...,
)
...
task >> ...