Skip to main content

snorkelflow_extensions.taxonomy_distillation.models.huggingface.HuggingFaceTeacherZeroShotCOTHTC

class snorkelflow_extensions.taxonomy_distillation.models.huggingface.HuggingFaceTeacherZeroShotCOTHTC(taxonomy: Taxonomy, config: Dict[str, Any])

Bases: TeacherHTC

The huggingface model teacher hierarchical text classifier with zero-shot COT reasoning.

__init__

__init__(taxonomy: Taxonomy, config: Dict[str, Any])

Initialize the teacher model. Huggingface teacher models require an API key to be set in the HUGGINGFACE_API_KEY environment variable. :param taxonomy: The taxonomy data class instance to use. :param config: The configuration dictionary. The configuration dictionary should contain the following keys:

  • teacher_model: The teacher model configuration dictionary. The teacher model configuration dictionary should contain the following keys:

    -name: The name of the teacher model. -params: The keyword arguments to pass to the teacher model.

Methods

__init__(taxonomy, config)Initialize the teacher model. Huggingface teacher models require an API key to be set in the HUGGINGFACE_API_KEY environment variable. :param taxonomy: The taxonomy data class instance to use. :param config: The configuration dictionary. The configuration dictionary should contain the following keys: - teacher_model: The teacher model configuration dictionary. The teacher model configuration dictionary should contain the following keys: -name: The name of the teacher model. -params: The keyword arguments to pass to the teacher model.
classify_text(text)Classify the text.
classify_texts(texts)Classify a list of texts.
create_few_shot_classification_prompt(...[, ...])Create a prompt for few-shot classification using the provided taxonomy and classes.
create_zero_shot_cot_answer_extraction_prompt(...)Create a prompt for zero-shot cot answer extraction.
create_zero_shot_cot_reasoning_extraction_prompt(text)Create a prompt for zero-shot cot reasoning extraction.
fill_system_prompt_template(...)Fill the system prompt template with the property and classes.
internal_classify_text(text, ...)Internal method to classify the text.

internal_classify_text

internal_classify_text(text: str, current_property: Property, classes: List[str]) Tuple[str, str]

Internal method to classify the text. :param text: The text to classify. :param current_property: The current property to classify the text under. :param classes: The classes to classify the text under.

Returns: The classification result and raw response.