usersimcrs.nlg.llm.nlg_generative_llm
Generative natural language generation using a large language model.
Note that the large language model is expected to be hosted externally. Also, the prompt used to generate utterances is expected to have the following placeholders: - “dialogue_acts”: to be replaced by the stringified dialogue acts. - “annotations”: to be replaced by the stringified annotations (if provided).
Classes
Initializes the generative NLG. |
Module Contents
- class usersimcrs.nlg.llm.nlg_generative_llm.LLMGenerativeNLG(llm_interface: usersimcrs.llm_interfaces.llm_interface.LLMInterface, prompt_file: str, prompt_prefix: str | None = None)
Bases:
dialoguekit.nlg.nlg_abstract.AbstractNLGInitializes the generative NLG.
- Parameters:
llm_interface – Interface to the large language model.
prompt_file – Path to the prompt file.
prompt_prefix – Prefix to be remove from generated utterances. Defaults to None.
- Raises:
FileNotFoundError – If the prompt file is not found.
- llm_interface
- prompt
- prompt_prefix = None
- generate_utterance_text(dialogue_acts: List[dialoguekit.core.dialogue_act.DialogueAct], annotations: List[dialoguekit.core.annotation.Annotation] | None | None = None, force_annotation: bool = False) dialoguekit.core.annotated_utterance.AnnotatedUtterance | bool
Turns a structured utterance into a textual one.
- Parameters:
dialogue_acts – Dialogue acts of the utterance to be generated.
annotations – If provided, these annotations should be considered during generation.
force_annotation – A flag to indicate whether annotations should be forced or not. Not used in this NLG.
- Raises:
RuntimeError – If generation fails.
- Returns:
Natural language utterance.