C ode T axo: Enhancing Taxonomy Expansion with Limited Examples via Code Language Prompts (2025)

Abstract: Taxonomies provide structural representations of knowledge and are crucial in various applications. The task of taxonomy expansion involves integrating emerging entities into existing taxonomies by identifying appropriate parent entities for these new query entities. Previous methods rely on self-supervised techniques that generate annotation data from existing taxonomies but are less effective with small taxonomies (fewer than 100 entities). In this work, we introduce CodeTaxo, a novel approach that leverages large language models through code language prompts to capture the taxonomic structure. Extensive experiments on five real-world benchmarks from different domains demonstrate that CodeTaxo consistently achieves superior performance across all evaluation metrics, significantly outperforming previous state-of-the-art methods. The code and data are available at https://github.com/QingkaiZeng/CodeTaxo-official .

## introduction taxonomies are hierarchical structures encoding hypernym-hyponym (i.e., "is-a") relations between concepts or entities. relational knowledge derived from taxonomies has been widely leveraged to identify semantic relevance for web search @xcite @xcite , personalized recommendation @xcite @xcite , and question answering @xcite . however, existing taxonomies are mainly constructed by experts or through crowd-sourcing, making the process time-consuming, labor-intensive, and restricted in coverage @xcite . as new entities emerge, continually enriching taxonomies with these additions becomes vital. to address these challenges, taxonomy expansion aims to integrate new entities into existing taxonomies automatically. ## problem definition definition 1 (taxonomy) we follow the definition of taxonomy in @xcite . a taxonomy @xmath0, h) is a tree-like structure, where each entity @xmath1, and each edge @xmath2. each entity e is associated with a set of textual description x @xmath3, x d e }, where x t e is its term and x d e is its definition. meanwhile, each directed edge @xmath4, c⟩ ∈ h represents a parent-child relationship that points to a child entity c from its most exact hypernymy entity p. definition 2 (taxonomy expansion) given a set of emerging conceptual entities e ′ , taxonomy expansion aims to incorporate these entities into an existing seed taxonomy to insert each query entity @xmath5, we identify an appropriate anchor entity @xmath6, and introduce a new edge ⟨q, a⟩. consequently, the updated edge set is h ′ = h 0 ∪ @xmath7, a⟩}. ## methodology in this section, we provide a comprehensive overview of our proposed codetaxo designed for addressing the taxonomy expansion task. specifically, codetaxo expands the existing taxonomy by prompting llms with code language. the pipeline of codetaxo is shown in figure 2 . our codetaxo consists of three parts: task instruc- from typing import list class entity: def __init__( self, name: str, description: str, parent: 'entity', child: list['entity'] ): self.@xmath8.@xmath9.@xmath10.@xmath11, parent: 'entity'): self.@xmath12.add_child(self) figure 4: python code in codetaxo defining a entity class for managing parent-child relations. ## conclusion in this paper, we introduce codetaxo, a novel approach to taxonomy expansion that leverages codebased prompts to effectively utilize the inherent knowledge within llms. our method addresses key challenges in taxonomy expansion by reformulating the task as a code completion problem and employing a semantic similarity filtering mechanism to optimize the use of llms' contextual capacity. extensive experiments on small-scale and large-scale taxonomies demonstrate that code-taxo achieves state-of-the-art performance in both one-shot settings and five-shot settings. we envision codetaxo as a powerful framework for integrating emerging entities into existing taxonomies by accurately identifying appropriate parent entities and also providing new insights for leveraging llms in structured knowledge tasks.