universal
Classes:
Name | Description |
---|---|
ChatRoleStrings |
Role strings of a chat prompt. |
ChatSchemaMapper |
Maps samples from an arbitrary dataset to a universal schema for building an LLM chat prompt. |
SchemaMapper |
Maps samples from an arbitrary dataset to a universal schema for building an LLM prompt. |
ChatRoleStrings
dataclass
¶
Role strings of a chat prompt.
Added in version 0.77.0.
Attributes:
Name | Type | Description |
---|---|---|
ASSISTANT_ROLE |
Final[str]
|
The assistant role. |
SYSTEM_ROLE |
Final[str]
|
The system role. |
USER_ROLE |
Final[str]
|
The user role. |
ChatSchemaMapper
dataclass
¶
Bases: SchemaMapper
Maps samples from an arbitrary dataset to a universal schema for building an LLM chat prompt.
Either define a subclass for easier reuse, or use this directly.
Examples:
>>> sample = {
... "question": "What is the capital of France?",
... "response": "Paris",
... "system_prompt": "Answer the following question:",
... }
>>> mapper = ChatSchemaMapper(
... instruction_key="question",
... response_key="response",
... system_prompt_key="system_prompt",
... )
>>> mapped_sample = mapper(sample)
>>> mapped_sample
[{'role': 'system', 'content': 'Answer the following question:'}, {'role': 'user', 'content': 'What is the capital of France?'}, {'role': 'assistant', 'content': 'Paris'}]
Added in version 0.77.0.
Classes:
Name | Description |
---|---|
Schema |
Universal schema for building an LLM chat prompt. |
Attributes:
Name | Type | Description |
---|---|---|
instruction_key |
str
|
The dataset key/column corresponding to the input. |
response_key |
str | None
|
An optional dataset key/column corresponding to the expected model response to the instruction. |
system_prompt_key |
str | None
|
An optional dataset key/column corresponding to the system prompt for the model. |
instruction_key
instance-attribute
¶
instruction_key: str
The dataset key/column corresponding to the input.
response_key
instance-attribute
¶
response_key: str | None
An optional dataset key/column corresponding to the expected model response to the instruction.
system_prompt_key
instance-attribute
¶
system_prompt_key: str | None
An optional dataset key/column corresponding to the system prompt for the model.
SchemaMapper
dataclass
¶
Bases: ABC
Maps samples from an arbitrary dataset to a universal schema for building an LLM prompt.
Added in version 0.77.0. Base class for `InstructionSchemaMapper` and `ChatSchemaMapper`.
Classes:
Name | Description |
---|---|
Schema |
Base schema for building an LLM prompt. |
Attributes:
Name | Type | Description |
---|---|---|
instruction_key |
str
|
The dataset key/column corresponding to the input. |