Skip to main content

snorkelflow_extensions.taxonomy_distillation.models.databricks.DataBricksTeacherFewShotHTC

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

Bases: TeacherHTC

Databricks-based teacher model using few-shot prompting for hierarchical text classification.

This implementation leverages Databricks’ language model serving infrastructure with few-shot learning to generate classification labels for training student models. The model provides examples from each taxonomy category to guide classification decisions and improve consistency across the hierarchy.

Integrates with Databricks’ model serving endpoints to provide scalable language model inference for large-scale taxonomy distillation workflows.

__init__

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

Initialize the teacher model. :param taxonomy: The taxonomy data class instance to use. :param config: The configuration dictionary.

Methods

__init__(taxonomy, config)Initialize 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.