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,
processor=None,
max_length=2048,
message_property_mappings=None,
message_field_training=None,
message_field_training_detail=None,
field_messages='messages',
field_system='system',
roles=None,
drop_system_message=False,
)Prompter for HF chat templates
ChatTemplateStrategy
prompt_strategies.chat_template.ChatTemplateStrategy(
self,
prompter,
tokenizer,
train_on_inputs,
sequence_len,
roles_to_train=None,
train_on_eos=None,
train_on_eot=None,
eot_tokens=None,
)Tokenizing strategy for instruction-based prompts.
Methods
| Name | Description |
|---|---|
| find_first_eot_token | Find the first EOT token in the input_ids starting from start_idx. |
| 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_first_eot_token
prompt_strategies.chat_template.ChatTemplateStrategy.find_first_eot_token(
input_ids,
start_idx,
)Find the first EOT token in the input_ids starting from start_idx.
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.