eta.transducers.base

Contains abstract base transducer classes for each supported transducer.

A transducer is an object that maps some set of arguments to some value; multiple abstract transducers are supported for various types of mappings with different function signatures.

The abstract transducers defined in this module do not actually implement any behavior; it is expected that they will be extended with transducers that use various techniques to perform a mapping (e.g., rule-based tree transduction, statistical models, large language models, etc.).

Note that each transducer type should return a list; this allows multiple transducer implementations to be “stacked” in practice, e.g., using both a tree transduction and an LLM transducer and collating the results.

Classes

AffectTransducer

Maps the word content of an utterance to an appropriate affect, given a conversation history.

AnswerTransducer

Maps a conversation history and relevant knowledge to an answer utterance.

AskTransducer

Maps a conversation history and relevant knowledge to a question utterance.

GistTransducer

Maps an utterance to a list of gist clauses, given a conversation history.

ParaphraseTransducer

Maps a gist clause, given a conversation history and relevant knowledge, to a paraphrased response.

PragmaticTransducer

Maps a gist clause to a list of ULF formulas capturing its pragmatic meaning.

ReactionTransducer

Maps an observed event to a formula for an action that an agent can take.

ReasonBottomUpTransducer

Maps from a list of facts to a list of new facts inferred from those.

ReasonTopDownTransducer

Maps from a plan step event and a list of facts to a list of new facts inferred from those.

ResponseTransducer

Maps a conversation history and relevant knowledge to a response utterance.

SemanticTransducer

Maps a gist clause to a list of ULF formulas capturing its semantic meaning.

SubplanTransducer

Maps a plan step event to a list of subplans, i.e., sequences of events that are substeps of the given step.

Transducer

The base transducer class.

class Transducer[source]

Bases: object

The base transducer class.

cost()[source]

Report cumulative costs of applying this transducer.

class ReasonTopDownTransducer[source]

Bases: Transducer

Maps from a plan step event and a list of facts to a list of new facts inferred from those.

Parameters:
  • step (Eventuality) – The event corresponding to the plan step to use as context for inference.

  • facts (list[Eventuality]) – The list of facts to make inferences from.

Returns:

A list of new facts inferred from the plan step and given facts.

Return type:

list[Eventuality]

class ReasonBottomUpTransducer[source]

Bases: Transducer

Maps from a list of facts to a list of new facts inferred from those.

Parameters:

facts (list[Eventuality]) – The list of facts to make inferences from.

Returns:

A list of new facts inferred from the given facts.

Return type:

list[Eventuality]

class GistTransducer[source]

Bases: Transducer

Maps an utterance to a list of gist clauses, given a conversation history.

Parameters:
  • utt (Utterance) – The utterance to interpret as a gist clause.

  • conversation_log (list[DialogueTurn]) – The conversation history to use as context for interpretation.

Returns:

A list of gist clauses.

Return type:

list[str]

class SemanticTransducer[source]

Bases: Transducer

Maps a gist clause to a list of ULF formulas capturing its semantic meaning.

Parameters:

gist (str) – The gist clause to parse to a logical form.

Returns:

A list of ULF S-expressions.

Return type:

list[s-expr]

class PragmaticTransducer[source]

Bases: Transducer

Maps a gist clause to a list of ULF formulas capturing its pragmatic meaning.

Parameters:

gist (str) – The gist clause to parse to a logical form.

Returns:

A list of ULF S-expressions.

Return type:

list[s-expr]

class ReactionTransducer[source]

Bases: Transducer

Maps an observed event to a formula for an action that an agent can take.

Parameters:

observation (Eventuality) – The observed event for the agent to react to.

Returns:

A list of action formulas that the agent can take in reaction to the observation.

Return type:

list[s-expr]

Notes

TODO: this should likely be expanded to support a list of observed events rather than a single event, since in general a reaction may be contingent on multiple combined observations.

class SubplanTransducer[source]

Bases: Transducer

Maps a plan step event to a list of subplans, i.e., sequences of events that are substeps of the given step.

Parameters:

step (Eventuality) – The event corresponding to a plan step to expand.

Returns:

A list of subplans, where each subplan is a sequence of substep events.

Return type:

list[list[Eventuality]]

class ParaphraseTransducer[source]

Bases: Transducer

Maps a gist clause, given a conversation history and relevant knowledge, to a paraphrased response.

Parameters:
  • gist (str) – The gist clause to paraphrase.

  • conversation_log (list[DialogueTurn]) – The conversation history to use as context for paraphrasing.

  • facts_bg (list[Eventuality]) – A list of “background” knowledge to use for paraphrasing, i.e., knowledge that may impact the resulting paraphrase, but may not be directly included in the paraphrased response.

  • facts_fg (list[Eventuality]) – A list of “foreground” knowledge to use for paraphrasing, i.e., knowledge that should be directly included in the paraphrased response.

Returns:

A list of paraphrased responses.

Return type:

list[str]

class ResponseTransducer[source]

Bases: Transducer

Maps a conversation history and relevant knowledge to a response utterance.

Parameters:
  • conversation_log (list[DialogueTurn]) – The conversation history to use as context for the response.

  • facts_bg (list[Eventuality]) – A list of “background” knowledge to use for the response, i.e., knowledge that may impact the resulting response, but may not be directly included in the response.

  • facts_fg (list[Eventuality]) – A list of “foreground” knowledge to use for the response, i.e., knowledge that should be directly included in the response.

Returns:

A list of responses.

Return type:

list[str]

class AnswerTransducer[source]

Bases: Transducer

Maps a conversation history and relevant knowledge to an answer utterance.

Parameters:
  • conversation_log (list[DialogueTurn]) – The conversation history to use as context for the answer.

  • facts_bg (list[Eventuality]) – A list of “background” knowledge to use for the answer, i.e., knowledge that may impact the resulting answer, but may not be directly included in the answer.

  • facts_fg (list[Eventuality]) – A list of “foreground” knowledge to use for the answer, i.e., knowledge that should be directly included in the answer.

Returns:

A list of answers.

Return type:

list[str]

class AskTransducer[source]

Bases: Transducer

Maps a conversation history and relevant knowledge to a question utterance.

Parameters:
  • conversation_log (list[DialogueTurn]) – The conversation history to use as context for the question.

  • facts_bg (list[Eventuality]) – A list of “background” knowledge to use for the question, i.e., knowledge that may impact the resulting question, but may not be directly included in the question.

  • facts_fg (list[Eventuality]) – A list of “foreground” knowledge to use for the question, i.e., knowledge that should be directly included in the question.

Returns:

A list of questions.

Return type:

list[str]

class AffectTransducer[source]

Bases: Transducer

Maps the word content of an utterance to an appropriate affect, given a conversation history.

Parameters:
  • words (str) – The words to match to an appropriate affect.

  • conversation_log (list[DialogueTurn]) – The conversation history to use as context for affect detection.

Returns:

A list of affects.

Return type:

list[str]