类型¶
本节包含 distilabel 代码库中使用的不同类型。
base
¶
ChatType = List[ChatItem]
module-attribute
¶
ChatType 是 dict
列表的类型别名,遵循 OpenAI 对话格式。
ImageUrl
¶
ImageContent
¶
基类: TypedDict
用户在对话中可以包含文本或图像的消息的类型别名。它是视觉语言模型的标准类型:https://platform.openai.com/docs/guides/vision
源代码在 src/distilabel/typing/base.py
steps
¶
StepOutput = Iterator[List[Dict[str, Any]]]
module-attribute
¶
StepOutput
是类型 Iterator[List[Dict[str, Any]]]
的别名
GeneratorStepOutput = Iterator[Tuple[List[Dict[str, Any]], bool]]
module-attribute
¶
GeneratorStepOutput
是类型 Iterator[Tuple[List[Dict[str, Any]], bool]]
的别名
StepColumns = Union[List[str], Dict[str, bool]]
module-attribute
¶
StepColumns
是类型 Union[List[str], Dict[str, bool]]
的别名,由 Step
的 inputs
和 outputs
属性使用。对于 List[str]
的情况,它是一个包含所需列的列表。对于 Dict[str, bool]
的情况,它是一个字典,其中键是列,值是布尔值,指示列是否是必需的。
models
¶
LLMLogprobs = List[List[List[Logprob]]]
module-attribute
¶
一种类型别名,表示 LLM
输出的概率分布。
结构
- 最外层列表:包含采样时的多个生成选择(
n
个序列) - 中间列表:表示生成序列中的每个位置
- 最内层列表:包含词汇表中每个 token 在该位置的对数概率
LLMStatistics = Union[TokenCount, Dict[str, Any]]
module-attribute
¶
最初,LLMStatistics 将包含 token 计数,但可以有更多变量。一旦我们为每个 LLM 定义了它们,就可以添加它们。
StructuredOutputType = Union[OutlinesStructuredOutputType, InstructorStructuredOutputType]
module-attribute
¶
StructuredOutputType 是 OutlinesStructuredOutputType
和 InstructorStructuredOutputType
的联合类型的别名。
StandardInput = ChatType
module-attribute
¶
StandardInput 是 ChatType 的别名,它定义了 format_input
生成的默认/标准输入。
StructuredInput = Tuple[StandardInput, Union[StructuredOutputType, None]]
module-attribute
¶
StructuredInput 定义了当使用 StructuredGeneration
或其子类时,format_input
生成的类型。
FormattedInput = Union[StandardInput, StructuredInput, str]
module-attribute
¶
FormattedInput 是 StandardInput
和 StructuredInput
的联合类型的别名,由 format_input
生成并由 LLM
期望,以及视觉语言模型的 ConversationType
。
OutlinesStructuredOutputType
¶
基类: TypedDict
TypedDict 用于表示来自 outlines
的结构化输出配置。
源代码在 src/distilabel/typing/models.py
format
instance-attribute
¶
“json” 或 “regex” 之一。
schema
instance-attribute
¶
用于结构化输出的 schema。如果为 “json”,则可以是 pydantic.BaseModel 类,或者作为字符串的 schema,从 model_to_schema(BaseModel)
获取;如果为 “regex”,则应为作为字符串的正则表达式模式。
whitespace_pattern
instance-attribute
¶
如果 “json” 对应于带有模式的字符串或字符串列表(不影响字符串字面量)。例如,要仅允许单个空格或换行符,使用 whitespace_pattern=r"[ ]?"
InstructorStructuredOutputType
¶
基类: TypedDict
TypedDict 用于表示来自 instructor
的结构化输出配置。
源代码在 src/distilabel/typing/models.py
pipeline
¶
DownstreamConnectable = Union['Step', 'GlobalStep']
module-attribute
¶
可以作为下游 steps 连接的 Step
类型的别名。
UpstreamConnectableSteps = TypeVar('UpstreamConnectableSteps', bound=Union['Step', 'GlobalStep', 'GeneratorStep'])
module-attribute
¶
可以作为上游 steps 连接的 Step
类型的类型。
DownstreamConnectableSteps = TypeVar('DownstreamConnectableSteps', bound=DownstreamConnectable, covariant=True)
module-attribute
¶
可以作为下游 steps 连接的 Step
类型的类型。
PipelineRuntimeParametersInfo = Dict[str, Union[List['RuntimeParameterInfo'], Dict[str, 'RuntimeParameterInfo']]]
module-attribute
¶
Pipeline
的运行时参数信息的别名。
InputDataset = Union['Dataset', 'pd.DataFrame', List[Dict[str, str]]]
module-attribute
¶
我们可以作为输入数据集处理的类型的别名。
LoadGroups = Union[List[List[Any]], Literal['sequential_step_execution']]
module-attribute
¶
可以用作加载组的类型的别名。
- 如果
List[List[Any]]
,则它是一个列表,其中包含必须隔离加载的 steps 列表。 - 如果 “sequential_step_execution”,则每个 step 将在不同的阶段加载,即一次只执行一个 step。