Skip to main content

snorkelflow_extensions.taxonomy_distillation.generation.MessageBuilder

class snorkelflow_extensions.taxonomy_distillation.generation.MessageBuilder(root_taxonomy: Taxonomy)

Bases: object

Builder for creating structured conversation messages in taxonomy workflows.

MessageBuilder generates formatted prompts and message sequences for language model interactions during taxonomy creation and refinement. It transforms taxonomy data into conversation-ready formats suitable for various prompting strategies and workflow phases.

The builder supports multiple message generation patterns including:

  • Initial taxonomy creation prompts

  • Property refinement conversations

  • Data-driven taxonomy improvement workflows

  • Continuation messages for iterative development

All generated messages follow consistent formatting patterns optimized for language model comprehension and taxonomy generation tasks.

__init__

__init__(root_taxonomy: Taxonomy) None

Initialize the message builder. :param root_taxonomy: Root taxonomy instance that defines the classification hierarchy

and serves as the foundation for all generated messages.

Methods

__init__(root_taxonomy)Initialize the message builder. :param root_taxonomy: Root taxonomy instance that defines the classification hierarchy and serves as the foundation for all generated messages. :type root_taxonomy: Taxonomy.
build_data_driven_taxonomy_refinement_messages(...)Build conversation messages for data-driven taxonomy refinement.
build_initial_creation_messages()Build initial conversation messages for taxonomy creation.
build_taxonomy_property_brainstorming_continuation_messages(...)Use the provided taxonomy root prompt and accepted properties string to construct the continuation messages for taxonomy creation.
build_taxonomy_property_refinement_messages(...)Construct the messages for taxonomy refinement.

build_data_driven_taxonomy_refinement_messages

build_data_driven_taxonomy_refinement_messages(refinement_property: Property, in_domain_examples: list) List[Message]

Build conversation messages for data-driven taxonomy refinement.

Creates messages that include property refinement context and in-domain examples to guide iterative taxonomy improvement.

Parameters

NameTypeDefaultInfo
refinement_property (Property) – Property object to be refined using the provided examples.
in_domain_exampleslistList of domain-specific text examples to inform refinement.

Returns

Messages for data-driven taxonomy refinement conversation.

Return type

list of Message

build_initial_creation_messages

build_initial_creation_messages() List[Message]

Build initial conversation messages for taxonomy creation.

Constructs system and user messages containing the brainstorm prompt and taxonomy root information to initiate taxonomy creation workflow.

Returns

List containing system and user messages for taxonomy creation.

Return type

list of Message

build_taxonomy_property_brainstorming_continuation_messages

build_taxonomy_property_brainstorming_continuation_messages(accepted_properties: List[Property]) List[Message]

Use the provided taxonomy root prompt and accepted properties string to construct the continuation messages for taxonomy creation. :param accepted_properties: The accepted Property objects.

Returns: The continuation messages for taxonomy creation.

build_taxonomy_property_refinement_messages

build_taxonomy_property_refinement_messages(refinement_property: Property) List[Message]

Construct the messages for taxonomy refinement. :param refinement_property: The refinement property.

Returns: The messages for taxonomy refinement.