prompt_strategies.chat_template
prompt_strategies.chat_template
HF Chat Templates prompt strategy
Classes
Name | Description |
---|---|
ChatTemplatePrompter | Prompter for HF chat templates |
ChatTemplateStrategy | Tokenizing strategy for instruction-based prompts. |
StrategyLoader | Load chat template strategy based on configuration. |
ChatTemplatePrompter
prompt_strategies.chat_template.ChatTemplatePrompter(self,
tokenizer,
chat_template,=None,
processor=2048,
max_length=None,
message_property_mappings=None,
message_field_training=None,
message_field_training_detail='messages',
field_messages=None,
roles=False,
drop_system_message )
Prompter for HF chat templates
ChatTemplateStrategy
prompt_strategies.chat_template.ChatTemplateStrategy(self,
prompter,
tokenizer,
train_on_inputs,
sequence_len,=None,
roles_to_train=None,
train_on_eos )
Tokenizing strategy for instruction-based prompts.
Methods
Name | Description |
---|---|
find_turn | Locate the starting and ending indices of the specified turn in a conversation. |
tokenize_prompt | Public method that can handle either a single prompt or a batch of prompts. |
find_turn
prompt_strategies.chat_template.ChatTemplateStrategy.find_turn(turns, turn_idx)
Locate the starting and ending indices of the specified turn in a conversation.
tokenize_prompt
prompt_strategies.chat_template.ChatTemplateStrategy.tokenize_prompt(prompt)
Public method that can handle either a single prompt or a batch of prompts.
StrategyLoader
prompt_strategies.chat_template.StrategyLoader()
Load chat template strategy based on configuration.