dialogy.plugins.text.slot_filler package

Submodules

dialogy.plugins.text.slot_filler.rule_slot_filler module

Slot Filling

While we describe slots in the linked doc. The slot filling is part of an intent’s role. This plugin orchestrates the execution of slot filling via methods available on intents.

  1. We eagerly apply slot placeholders using the apply method.

  2. Once entities are found, we check if the slots can fill them using the fill method.

  3. If no slots were filled, we remove the placeholders using cleanup method.

class RuleBasedSlotFillerPlugin(rules, dest=None, guards=None, replace_output=True, fill_multiple=True, debug=False)[source]

Bases: dialogy.base.plugin.Plugin

A utility plugin for slot filling <https://nlpprogress.com/english/intent_detection_slot_filling.html>._ An Intent may have a few slots that need to be filled.

This plugin can assist filling pertaining to certain intent:entity:slot-name association rules.

Schema for rules

Let’s run through a practical example. We will create a workflow and preset the output to have expected intent and entities.

Parameters
  • rules (Rule) – A mapping that defines relationship between an intent, its slots and the entities that fill them.

  • fill_multiple (bool) – More than one item be allowed to fill a single slot.

  • access (Optional[PluginFn]) – Signature for workflow access is access(workflow) -> (Intent, List[BaseEntity])

  • mutate (Optional[PluginFn]) – Not needed, pass None.

Irrespective of the entities that are found, only the listed type in the slot shall be present in values.

fill(intents, entities, expected_slots=None)[source]
Return type

List[Intent]

utility(input_, output)[source]

An abstract method that describes the plugin’s functionality.

Parameters
  • input (Input) – The workflow’s input.

  • output (Output) – The workflow’s output.

Returns

The value returned by the plugin.

Return type

Any

Module contents

To handle a single dialog we need a system that can:

  1. Classify inputs into categories.

  2. Extract tokens of additional significance.

  3. Check for associations between the two.

A slot-filler does the third bit. Once an Intent and a set of Entity are identified, there needs to be an arrangement that tells us if any of these are related to each other.

As per the current design, an Intent can contain a number of Slot. A Slot fills an entity of a pre-defined type.

  • A Slot configured to fill a TimeEntity will not fill a KeywordEntity.

  • A Slot will not fill more than one entity even if the type matches, unless fill_multiple is provided.