nlg_generative_lm

Generative natural language generation using a language model.

Classes

LMGenerativeNLG

Initializes the generative NLG.

Module Contents

class nlg_generative_lm.LMGenerativeNLG(ollama_config_file: str, prompt_file: str, prompt_prefix: str | None = None)

Bases: dialoguekit.nlg.nlg_abstract.AbstractNLG

Initializes the generative NLG.

Parameters:
  • ollama_config_file – Path to the Ollama configuration file.

  • prompt_file – Path to the prompt file.

  • prompt_prefix – Prefix to be remove from generated utterances. Defaults to None.

Raises:

FileNotFoundError – If the Ollama configuration file or the prompt file is not found.

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.