usersimcrs.nlu.llm.llm_dialogue_act_extractor
Dialogue act extractor based on a large language model.
Note that the large language model is expected to be hosted externally. Also, the prompt used to extract dialogue acts is expected to have a placeholder “utterance” that will be replaced by the utterance text.
Classes
Initializes the dialogue act extractor. |
Module Contents
- class usersimcrs.nlu.llm.llm_dialogue_act_extractor.LLMDialogueActsExtractor(llm_interface: usersimcrs.llm_interfaces.llm_interface.LLMInterface, config_file: str)
Bases:
dialoguekit.nlu.dialogue_acts_extractor.DialogueActsExtractorInitializes the dialogue act extractor.
- Parameters:
llm_interface – Interface to the large language model.
config_file – Path to the configuration file.
- Raises:
FileNotFoundError – If the configuration or prompt file is not found.
- intent_labels
- slot_labels
- llm_interface
- filter_invalid_dialogue_acts(utterance: str, dialogue_acts: List[dialoguekit.core.dialogue_act.DialogueAct]) List[dialoguekit.core.dialogue_act.DialogueAct]
Filters out invalid dialogue acts.
This method should be used after inference to filter out dialogue acts with invalid intents, slots, or values.
- Parameters:
utterance – Input utterance.
dialogue_acts – List of dialogue acts.
- Returns:
List of valid dialogue acts.
- extract_dialogue_acts(utterance: dialoguekit.core.utterance.Utterance) List[dialoguekit.core.dialogue_act.DialogueAct]
Extracts dialogue acts from an utterance.
- Parameters:
utterance – Utterance.
- Returns:
List of dialogue acts.
- save(path: str) None
Saves the dialogue act extractor to a given path.
This method is not implemented for this dialogue act extractor as the model is externally hosted.
- Parameters:
path – Path to save the dialogue act extractor.
- classmethod load(path: str) LLMDialogueActsExtractor
Loads the dialogue act extractor from a path.
This method is not implemented for this dialogue act extractor as the model is externally hosted.
- Parameters:
path – Path to the dialogue act extractor.
- Returns:
LMDialogueActsExtractor.