A method, apparatus, device and storage medium for entity classification

By inserting boundary-aligned data into the text for context encoding and semantic similarity matching, the closed nature of entity type recognition in existing technologies is solved, enabling flexible and highly accurate entity classification that adapts to complex text scenarios and improves the accuracy of semantic understanding and contextual association recognition.

CN122489756APending Publication Date: 2026-07-31GUIZHOU UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GUIZHOU UNIV
Filing Date
2026-05-07
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Existing named entity recognition methods rely on predefined sets of entity category labels, which are difficult to handle in emerging fields and dynamically changing entity types, resulting in insufficient coverage and weak generalization ability.

Method used

By inserting boundary alignment data into the text to be labeled, context encoding is performed to generate entity representations to be classified. Entity classification is then performed based on the semantic similarity between the entity representation and the pre-classified prototype representation, reducing the reliance on large-scale manually labeled data. A target-generative language model is used to identify potential entities and dynamically measure semantic fit.

Benefits of technology

It achieves highly accurate, flexible, and robust entity classification, adapts to more complex text scenarios, improves the accuracy of semantic understanding and contextual association recognition, and reduces the reliance on large-scale manually labeled data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122489756A_ABST
    Figure CN122489756A_ABST
Patent Text Reader

Abstract

This invention relates to an entity classification method, apparatus, device, and storage medium. The method includes: inserting boundary alignment data into the target start and end positions of the entity to be classified in the text to be labeled, obtaining the text to be encoded; performing context encoding on the text to be encoded, obtaining a context-encoded representation of the boundary alignment data; generating a representation of the entity to be classified based on the context-encoded representation of the boundary alignment data; and obtaining the entity classification result of the entity to be classified based on the semantic similarity between the representation of the entity to be classified and each pre-classified prototype representation. The technical solution of this invention can achieve a highly accurate, flexible, and robust entity classification method, adapting it to entity classification needs in more complex text scenarios and expanding its applicability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and in particular to an entity classification method, apparatus, device, and storage medium. Background Technology

[0002] Information extraction is a core technology in the field of natural language processing. In the overall process of information extraction, named entity recognition occupies the most fundamental and crucial position, responsible for automatically detecting named entities with specific semantic meanings from the raw text and classifying their entity types.

[0003] Currently, mainstream named entity recognition methods generally adopt an "encoder-classifier" architecture. The encoder is responsible for converting each word in the input text into a context-aware dense vector representation; the classifier acts as a discriminative classifier, mapping the semantic vector of each word or text span to a predefined set of entity labels to complete the named entity recognition task. However, these traditional named entity recognition systems usually rely on predefined entity category label sets, making it difficult to cope with emerging fields, dynamically changing or unlabeled entity types, resulting in obvious problems of insufficient coverage and weak generalization ability in practical applications.

[0004] With the development of large language models, researchers have attempted to perform named entity recognition tasks in low-sample scenarios through cue engineering. However, these methods essentially continue the logic of the traditional supervised paradigm, relying on manually constructed "input-labeled output" examples to guide the model to imitate sequence labeling behavior, resulting in results that are still limited to the reproduction of known label forms. Summary of the Invention

[0005] This invention provides an entity classification method, apparatus, device, and storage medium, with the aim of achieving a highly accurate, flexible, and robust entity classification method that can adapt to entity classification needs in more complex text scenarios and expand its scope of application.

[0006] In a first aspect, embodiments of the present invention provide an entity classification method, including:

[0007] Insert boundary alignment data at the target start and end positions of the entities to be classified in the text to be labeled to obtain the text to be encoded.

[0008] Context encoding is performed on the text to be encoded to obtain the context-encoded representation of the boundary-aligned data;

[0009] Based on the context encoding representation of the boundary alignment data, generate the entity representation to be classified of the entity to be classified;

[0010] The entity classification result of the entity to be classified is obtained based on the semantic similarity between the entity representation to be classified and each pre-classified prototype representation.

[0011] Optionally, before obtaining the entity classification result of the entity to be classified based on the representation similarity between the entity representation to be classified and each pre-classified prototype representation, the method further includes:

[0012] Obtain the entity type label and pre-classified entity representation for each pre-classified entity;

[0013] The prototype representation model is trained based on the entity type labels and the pre-classified entity representation, so that the prototype representation model learns to obtain the type metric space matched by each entity type label and the pre-classified prototype representation.

[0014] Optionally, training the prototype representation model based on the entity type labels and the pre-classified entity representation, so that the prototype representation model learns to obtain the type metric space matching each entity type label and the pre-classified prototype representation, includes:

[0015] Initial prototype representations are randomly generated in the semantic space of each entity;

[0016] Based on the prototype representation model, the semantic similarity between each pre-classified entity representation and each initial prototype representation is calculated;

[0017] Based on the semantic similarity, the correspondence between each initial prototype representation and each pre-classified entity representation is determined;

[0018] Based on the correspondence between the entity type labels and the pre-classified entity representations, the type metric space is obtained through iterative learning, and based on the correspondence between the initial prototype representation and the pre-classified entity representations, the pre-classified prototype representation is obtained through iterative learning.

[0019] Optionally, before inserting boundary alignment data at the target start and end positions of the entities to be classified in the text to be labeled to obtain the text to be encoded, the method further includes:

[0020] The text to be labeled and the preset prompt text are input into the target generative language model to identify at least one target entity in the text to be labeled through the target generative language model;

[0021] One of the at least one target identification entities is determined as the entity to be classified.

[0022] Optionally, obtaining the entity classification result of the entity to be classified based on the semantic similarity between the entity representation to be classified and each pre-classified prototype representation includes:

[0023] Calculate the cosine similarity between the entity representation to be classified and each pre-classified prototype representation, and use it as the semantic similarity;

[0024] The pre-classified prototype representation whose cosine similarity with the entity to be classified reaches a preset similarity threshold is determined as the target matching prototype representation;

[0025] The target entity type corresponding to the target matching prototype is determined as the entity classification result of the entity to be classified.

[0026] Optionally, after calculating the cosine similarity between the entity representation to be classified and each pre-classified prototype representation as the semantic similarity, the method further includes:

[0027] If all the cosine similarities are lower than the preset similarity threshold, it is determined that the entity to be classified belongs to the current unknown entity type, and the entity classification result of the entity to be classified is generated according to the semantic representation features represented by the entity to be classified.

[0028] The entity classification result of the entity to be classified is different from the pre-classified entity type represented by each pre-classification prototype.

[0029] Optionally, generating the entity classification result of the entity to be classified based on the semantic representation features of the entity to be classified includes:

[0030] Unsupervised semantic clustering is performed on the representations of all unclassified entities that are currently identified as belonging to the currently unknown entity type to obtain at least one target entity category cluster.

[0031] Based on the semantic features of each target entity category cluster, generate self-discovered entity types corresponding to each target entity category cluster;

[0032] The self-discovered entity type corresponding to the target entity category cluster of the entity to be classified is determined as the entity classification result of the entity to be classified.

[0033] Secondly, embodiments of the present invention provide an entity classification device, comprising:

[0034] The boundary alignment module is used to insert boundary alignment data at the target start and end positions of the entities to be classified in the text to be labeled, so as to obtain the text to be encoded.

[0035] A context encoding module is used to perform context encoding on the text to be encoded to obtain a context-encoded representation of the boundary alignment data;

[0036] The representation generation module is used to generate a representation of the entity to be classified based on the context encoding representation of the boundary alignment data;

[0037] The result acquisition module is used to obtain the entity classification result of the entity to be classified based on the semantic similarity between the entity representation to be classified and each pre-classified prototype representation.

[0038] Thirdly, embodiments of the present invention provide an entity classification device, comprising:

[0039] One or more processors;

[0040] Memory, used to store one or more programs;

[0041] When the one or more programs are executed by the one or more processors, the one or more processors implement the entity classification method provided in any embodiment of the present invention.

[0042] Fourthly, embodiments of the present invention provide a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform an entity classification method as provided in any embodiment of the present invention.

[0043] This invention provides an entity classification method, apparatus, device, and storage medium. By inserting boundary alignment data into the target start and end positions of the entities to be classified in the text to be labeled, a text to be encoded is obtained. Context encoding is then performed on the text to be encoded to obtain a context-coded representation of the boundary alignment data. Based on this context-coded representation, a representation of the entity to be classified is generated. The entity classification result is then obtained based on the semantic similarity between the entity representation and each pre-classified prototype representation. This solves the problem that existing technologies, relying on predefined and closed labeling systems, cannot flexibly and effectively identify entity types. It reduces the dependence on large-scale manually labeled data and improves the accuracy of semantic understanding and contextual association recognition of the entities to be classified. This achieves a highly accurate, flexible, and robust entity classification method, making it adaptable to entity classification needs in more complex text scenarios and expanding its applicability. Attached Figure Description

[0044] Figure 1 This is a flowchart of an entity classification method provided in Embodiment 1 of the present invention;

[0045] Figure 2 This is a flowchart of an entity classification method provided in Embodiment 2 of the present invention;

[0046] Figure 3 This is a flowchart of an entity classification method provided in Embodiment 2 of the present invention;

[0047] Figure 4 This is a schematic diagram of the structure of an entity classification device provided in Embodiment 3 of the present invention;

[0048] Figure 5 This is a schematic diagram of the structure of an entity classification device provided in Embodiment 4 of the present invention. Detailed Implementation

[0049] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present invention, and not all of the structures.

[0050] Example 1

[0051] Figure 1 This is a flowchart of an entity classification method provided in Embodiment 1 of the present invention. This embodiment is applicable to the case of classifying entities of unknown type in text. The method can be executed by an entity classification device, which can be implemented by hardware and / or software and is generally integrated into an electronic device, such as a computer device. The method specifically includes:

[0052] Step 110: Insert boundary alignment data at the target start and end positions of the entities to be classified in the text to be labeled to obtain the text to be encoded.

[0053] The text to be labeled can be any text in which entities and their types need to be labeled. The entities to be classified can be entities in the text that have been identified but whose types are unknown. The target start and end positions can be the positions before and after the start of the entities to be classified in the text, determined according to the natural language order. Boundary alignment data can be data used to mark the front and back boundaries of the entities to be classified in the text according to the natural language order. The text to be encoded can be the text formed by inserting boundary alignment data at the target start and end positions of the entities to be classified in the text to be labeled, and can be used for subsequent context encoding.

[0054] Specifically, the text to be labeled can typically be the initially acquired raw text content, which may include one or more entities of arbitrary length. Then, according to the natural language order of the text to be labeled, the position before the first character and the position after the last character of each entity can be determined as the target start and end positions, and boundary alignment data can be inserted.

[0055] It should be noted that when the text to be labeled contains multiple entities of unknown type, if any one of the entities needs to be classified, it is identified as the entity to be classified, while the other entities can be used as the context of that entity and are not considered as entities to be classified. By classifying each entity as an entity to be classified in turn, the type of all entities in the text to be labeled can be obtained.

[0056] For example, the text to be tagged can be a sentence. The entity span containing the entity to be classified is Then, boundary alignment data is inserted at the target start and end positions of the entities to be classified in the text to be labeled, resulting in the text to be encoded. ,in, and For boundary alignment data, such as boundary attention cues [S] and [E], if a sentence contains L entities, then each entity is treated as an entity to be classified and processed as described above, resulting in L texts to be encoded. .

[0057] Step 120: Perform context encoding on the text to be encoded to obtain a context-encoded representation of the boundary-aligned data.

[0058] Context encoding can be an operation that extracts the independent semantic features of the entity to be classified, its boundary alignment data, and the context, as well as the associated features between them, to form a context-aware dense vector. Optionally, it can be achieved by embedding tokens to map the text to be encoded into a distributed word representation and then encoding it using an encoder. Context encoding can obtain the context-encoded representation of the entity to be classified, its boundary alignment data, and the context, which is used to characterize their respective semantic features and contextual semantic environment.

[0059] Specifically, when the text to be encoded is globally context-encoded, the context-encoded representation of the boundary-aligned data can simultaneously characterize the semantic features of the entity to be classified as a fusion of contextual environments, the semantic features of the context of the entity to be classified, and the co-occurrence features of the entity to be classified and its context.

[0060] For example, treating encoded text Context encoding can be used to embed lexical units and map them to a distributed word representation. Further encoding yields the context-encoded representation. ,in, and The context encoding representation of boundary-aligned data.

[0061] Step 130: Generate the entity representation of the entity to be classified based on the context encoding representation of the boundary-aligned data.

[0062] The entity to be classified can be data used to characterize the semantic features of the entity to be classified.

[0063] Specifically, by using the context encoding representation of boundary-aligned data to generate the entity representation of the entity to be classified, the entity representation of the entity to be classified can contain the semantic features of the entity to be classified, the semantic features of the entity's context, and the co-occurrence features of the entity and its context, as represented by the context encoding representation of boundary-aligned data, thereby providing a multi-dimensional and refined representation of the semantic features of the entity to be classified.

[0064] Optionally, generating a representation of the entity to be classified based on the context encoding representation of the boundary-aligned data may include: concatenating and mapping the context encoding representation of the boundary-aligned data to obtain a representation of the entity to be classified.

[0065] For example, context encoding representation of boundary-aligned data and spliced ​​together The MLP (Multilayer Perceptron) can be used to map to a suitable dimension to obtain the entity representation of the entity to be classified. .in, , and Represents the weight matrix. and This indicates the bias term.

[0066] For example, this embodiment also provides encoding... and It not only integrates semantic representations related to entity context, but also serves as a proof for modeling the co-occurrence of entities and their context. Specifically, for sentences with embedded boundary attention cues, i.e. ,set up yes In the context, then The conditional distribution is represented as:

[0067]

[0068] in, and These are vectors in distributed word representation and context-dependent representation, where... It can be approximated as ,in, ,represent and The point-to-point mutual information between entities measures the probability of co-occurrence between entities and context. These are parameters related to contextual information. Therefore, the joint probability... It can be decomposed into:

[0069]

[0070] Finally, we can obtain the final approximate representation of the joint probability:

[0071]

[0072] The first six terms of the formula illustrate the co-occurrence of attention cues and entity context. The last three terms indicate the relationship between attention cues and global context, aiding in modeling global semantic relationships. According to the principle of semantic co-occurrence, two contexts co-occurring with the same lexical units or text fragments are likely to have similar semantics. Therefore, the encoded result... and It is not only a semantic representation that integrates entity context, but also used to model the co-occurrence of entities and context.

[0073] Step 140: Obtain the entity classification result of the entity to be classified based on the semantic similarity between the entity representation to be classified and each pre-classified prototype representation.

[0074] Among them, the pre-classification prototype representation can be data that characterizes the overall semantic features of each known entity type.

[0075] Specifically, for sample entities whose entity types have been pre-labeled, entity representations are generated using the same boundary marking and encoding methods as the entities to be classified. Then, based on the entity representations of all sample entities labeled with the same entity type, the pre-classification prototype representation of the corresponding type is learned.

[0076] Furthermore, semantic similarity can refer to the similarity of the semantics represented by the entity representation to be classified and the pre-classified prototype representation. The entity classification result of the entity to be classified can be data describing the entity type to which the entity to be classified belongs. Based on the semantic similarity between the entity representation to be classified and each pre-classified prototype representation, the entity type corresponding to the pre-classified prototype representation with the highest semantic similarity and meeting the preset threshold condition can be determined as the entity classification result of the entity to be classified.

[0077] In an optional implementation, before obtaining the entity classification result of the entity to be classified based on the representation similarity between the entity representation to be classified and each pre-classified prototype representation, the method further includes: obtaining the entity type label and pre-classified entity representation of each pre-classified entity; training the prototype representation model based on the entity type label and pre-classified entity representation, so that the prototype representation model learns to obtain the type metric space and pre-classified prototype representation matched by each entity type label.

[0078] In this context, a pre-classified entity can refer to a sample entity that has been manually labeled and has a definite entity type label. The entity type label can be marker data used to uniquely identify the entity type to which the entity belongs. The pre-classified entity representation can be data representing the semantic features of the pre-classified entity, obtained using the same acquisition method as the entity representation to be classified. The prototype representation model can be an artificial intelligence model with a pre-defined model structure and some parameters, used to simultaneously learn the type metric space and the entity type prototype representation. The type metric space can refer to a semantic metric space that makes representations of entities of the same type more similar and representations of entities of different types more distinguishable.

[0079] Specifically, pre-classified entities obtained through classification and labeling can carry corresponding entity type labels, and there can be a correspondence between their entity type labels and their pre-classified entity representations. By training the prototype representation model based on the entity type labels and pre-classified entity representations, the model can learn this correspondence, thereby iteratively updating the model parameters. This enables the model to map entity representations to a unified metric space and simultaneously output the optimal prototype representation for each type.

[0080] In one optional implementation, the prototype representation model is trained based on entity type labels and pre-classified entity representations, so that the prototype representation model learns to obtain the type metric space and pre-classified prototype representations matched by each entity type label, including: randomly generating initial prototype representations in each entity semantic space; calculating the semantic similarity between each pre-classified entity representation and each initial prototype representation based on the prototype representation model; and determining the correspondence between each initial prototype representation and each pre-classified entity representation based on the semantic similarity.

[0081] Based on the correspondence between entity type labels and pre-classified entity representations, a type metric space is obtained through iterative learning, and based on the correspondence between the initial prototype representation and the pre-classified entity representation, a pre-classified prototype representation is obtained through iterative learning.

[0082] The entity semantic space can be a continuous vector space composed of entity representations used to measure the semantic similarity between entities. The initial prototype representation is randomly selected from the entity semantic space as the initial pre-classified entity representation of the entity type corresponding to the entity semantic space. During model training, it is iteratively adjusted to be the pre-classified entity representation that can optimally represent all semantic features of the corresponding type of entities.

[0083] Since the pre-classified entity representations and initial prototype representations of the same type belong to the same entity semantic space and have high semantic similarity, the prototype representation model can determine the correspondence between each initial prototype representation and each pre-classified entity representation by calculating the semantic similarity between each pre-classified entity representation and each initial prototype representation. Usually, it is preferable to establish a correspondence between any pre-classified entity representation and the initial prototype representation with the highest semantic similarity, until each pre-classified entity representation establishes a correspondence with an initial prototype representation.

[0084] Furthermore, there is also a correspondence between the entity type label corresponding to each pre-classified entity representation and its corresponding pre-classified entity representation. Therefore, the model can iteratively learn the type metric space with the goal of aggregating similar entity representations and maximizing the distinguishability of dissimilar entity representations, thus obtaining a satisfactory type metric space. Similarly, there is a correspondence between the initial prototype representation and the pre-classified entity representation corresponding to the same entity type. Therefore, the model can iteratively learn the pre-classified prototype representation with the goal of best approximating the overall semantic distribution of all entity representations of the same type, thus obtaining a satisfactory pre-classified prototype representation.

[0085] The technical solution of this embodiment obtains the text to be encoded by inserting boundary alignment data at the target start and end positions of the entities to be classified in the text to be labeled. Contextual encoding is then performed on the text to be encoded to obtain the contextual encoding representation of the boundary alignment data. Based on the contextual encoding representation of the boundary alignment data, a representation of the entity to be classified is generated. Thus, based on the semantic similarity between the representation of the entity to be classified and each pre-classified prototype representation, the entity classification result of the entity to be classified is obtained. This solves the problem that existing technologies cannot flexibly and effectively identify entity types due to their reliance on predefined and closed labeling systems. It reduces the dependence on large-scale manually labeled data and improves the accuracy of semantic understanding and contextual association recognition of entities to be classified. This achieves a highly accurate, flexible, and robust entity classification method, making it adaptable to entity classification needs in more complex text scenarios and expanding its scope of application.

[0086] Example 2

[0087] Figure 2 This is a flowchart of an entity classification method provided in Embodiment 2 of the present invention. This embodiment further refines the above technical solution, and before inserting boundary alignment data at the target start and end positions of the entity to be classified in the text to be labeled to obtain the text to be encoded, it further includes: inputting the text to be labeled and preset prompt words into a target generative language model to identify at least one target entity in the text to be labeled through the target generative language model; and determining one of the at least one target entity as the entity to be classified. Specifically, the method includes:

[0088] Step 210: Input the text to be labeled and the preset prompt text into the target generative language model so as to identify at least one target entity in the text to be labeled through the target generative language model.

[0089] The preset prompt text can be a pre-designed prompt message text used to guide the target generative language model to identify entities in the input natural language text. The target generative language model can be any generative language model that can be invoked, such as a GLM (General Language Model). The target entities to be identified can include all entities in the text to be labeled identified by the target generative language model under the guidance of the preset prompt text.

[0090] Specifically, for unlabeled text to be labeled, pre-designed prompt text guides the target generative language model to automatically identify target entities. Optionally, the pre-designed prompt text can reconstruct the entity recognition task into a natural language instruction or question-and-answer format, explicitly requiring the target generative language model to "find text fragments that may constitute named entities" from the input sentence, with particular emphasis on semantically complete and reasonably long continuous substrings. The core idea of ​​this step is to fully utilize the contextual understanding and common-sense knowledge learned by the generative language model during large-scale pre-training to achieve preliminary discovery of potential entities in the text without any manual annotation. Unlike traditional sequence labeling methods that rely on fixed label sets for word-by-word classification, this approach stimulates the model's generalization reasoning ability through open-ended prompts, not limited to known predefined entity types, but also encouraging it to judge whether any phrase that may have referential or proper meaning constitutes a valid entity based on semantic reasonableness. It is worth noting that although the task format appears open, in practice, the model actually performs an implicit binary classification task. For each text segment that "meets the length constraint", it determines whether it "possesses the semantic features to become a named entity". This process integrates the language model's comprehensive understanding of lexical collocation, syntactic roles, pragmatic functions and external knowledge, thereby efficiently selecting a high-quality candidate set and laying the foundation for subsequent semantic matching and type classification.

[0091] Step 220: Determine one target identification entity from at least one target identification entity as the entity to be classified.

[0092] Specifically, although the text to be labeled may contain multiple target recognition entities, in this embodiment only one target recognition entity is identified as the entity to be classified at a time. Other target recognition entities besides the entity to be classified are used as the context information of the entity to be classified, which can avoid mutual interference when multiple entities to be classified are encoded at the same time.

[0093] Step 230: Insert boundary alignment data at the target start and end positions of the entities to be classified in the text to be labeled to obtain the text to be encoded.

[0094] Step 240: Perform context encoding on the text to be encoded to obtain a context-encoded representation of the boundary-aligned data.

[0095] Step 250: Generate the entity representation of the entity to be classified based on the context encoding representation of the boundary-aligned data.

[0096] Step 260: Obtain the entity classification result of the entity to be classified based on the semantic similarity between the entity representation to be classified and each pre-classified prototype representation.

[0097] In an optional implementation, the entity classification result of the entity to be classified is obtained based on the semantic similarity between the representation of the entity to be classified and each pre-classified prototype representation, including:

[0098] Calculate the cosine similarity between the entity representation to be classified and each pre-classified prototype representation, and use it as semantic similarity;

[0099] The pre-classification prototype representation that achieves a cosine similarity of 1 / 2 with the entity representation to be classified at a preset similarity threshold is determined as the target matching prototype representation.

[0100] The target entity type corresponding to the target matching prototype is determined as the entity classification result of the entity to be classified.

[0101] Cosine similarity can be a similarity metric used to measure the directional consistency of two vectors in a high-dimensional semantic space, typically used to calculate the semantic similarity of semantic feature vector representations. The preset similarity threshold can be a pre-defined critical value used to determine whether the cosine similarity between the entity representation to be classified and the pre-classified prototype representation is high enough to indicate that they semantically belong to the same entity type. If the cosine similarity between the entity representation to be classified and any pre-classified prototype representation reaches the preset similarity threshold, then the semantic similarity between them can be determined to be high enough to determine that the entity to be classified belongs to the known target entity type corresponding to that pre-classified prototype representation.

[0102] Optionally, the cosine similarity between the entity representation to be classified and each pre-classified prototype representation can be calculated using the following formula:

[0103]

[0104] in, This represents the j-th pre-classification prototype representation out of a total of n pre-classification prototype representations. The i-th component is represented. This represents the entity to be classified. This represents the i-th component of the entity to be classified.

[0105] In an optional implementation, after calculating the cosine similarity between the entity representation to be classified and each pre-classified prototype representation as semantic similarity, the method further includes: if all cosine similarities are lower than a preset similarity threshold, determining that the entity to be classified belongs to the current unknown entity type, and generating an entity classification result for the entity to be classified based on the semantic representation features of the entity representation to be classified, wherein the entity classification result for the entity to be classified is different from the pre-classified entity type corresponding to each pre-classified prototype representation.

[0106] Here, the currently unknown entity type can be a new entity type that is not included in the existing pre-classified entity types and cannot be identified by matching with known pre-classified prototype representations. If the cosine similarity between the entity representation to be classified and each pre-classified prototype representation is lower than the preset similarity threshold, it indicates that the semantic matching degree between the entity representation to be classified and each pre-classified prototype representation is not high enough, and the entity to be classified does not match any known entity type. Therefore, the entity to be classified belongs to the currently unknown entity type.

[0107] Furthermore, semantic representation features can refer to the vector features contained in the representation of the entity to be classified, which can reflect the entity type corresponding to the entity's semantics and contextual association. When the entity to be classified belongs to an unknown entity type, a new type that is different from the known type needs to be generated based on its semantic representation features as its entity classification result.

[0108] In an optional implementation, generating an entity classification result for the entity to be classified based on the semantic representation features of the entity representation to be classified includes: performing unsupervised semantic clustering on the entity representations of all entities to be classified that are currently identified as belonging to the currently unknown entity type to obtain at least one target entity category cluster; generating self-discovered entity types corresponding to each target entity category cluster based on the category cluster semantic features of each target entity category cluster; and determining the self-discovered entity type corresponding to the target entity category cluster of the entity to be classified as the entity classification result of the entity to be classified.

[0109] Unsupervised semantic clustering typically refers to a clustering method that automatically groups semantically similar entities into a single class based on the semantic distance between entity representations without requiring manual annotation. This results in each target entity category cluster being a set of entity representations of unknown types that are highly semantically similar and belong to the same new category. Based on the semantic features of each target entity category cluster, a corresponding self-discovered entity type can be generated. This self-discovered entity type, distinct from the pre-classified entity types corresponding to each pre-classified prototype representation, represents the entity classification result of each entity to be classified within the corresponding target entity category cluster.

[0110] For example, Figure 3 This is a flowchart illustrating an entity classification method provided in Embodiment 2 of the present invention. Figure 3 As shown, through pre-labeling, some labeled data and unlabeled data are obtained. DLM encoding is performed on each entity identified by the labeled data and the GLM model in the unlabeled data to construct the entity representation to be classified and the prototype representation of the known entity type. Semantic similarity matching is performed between the two. When the similarity is higher than the threshold, the entity to be classified is assigned to the corresponding known type. When the similarity is lower than the threshold, the new type to which the entity to be classified belongs is discovered through semantic clustering.

[0111] The technical solution of this embodiment obtains the text to be encoded by inserting boundary alignment data at the target start and end positions of the entities to be classified in the text to be labeled. Contextual encoding is then performed on the text to be encoded to obtain the contextual encoding representation of the boundary alignment data. Based on this contextual encoding representation, a representation of the entity to be classified is generated. Finally, based on the semantic similarity between the entity representation and each pre-classified prototype representation, the entity classification result is obtained. This solves the problem that existing technologies, relying on predefined and closed labeling systems, cannot flexibly and effectively identify entity types. It reduces the dependence on large-scale manually labeled data and improves the accuracy of semantic understanding and contextual association recognition of the entities to be classified. This achieves a highly accurate, flexible, and robust entity classification method, making it adaptable to a wider range of applications. To address the entity classification needs in complex text scenarios and expand its applicability, this embodiment abandons the traditional approach that relies on explicit "input-output" annotation examples. Instead, it introduces entity types into the semantic space in the form of natural language definitions and deeply aligns them with context-aware text representations. Examples are provided through two model task-oriented retrieval methods, and a unified semantic representation framework is constructed. This allows the model to dynamically measure the semantic fit between input fragments and category labels during inference, thereby transforming the named entity recognition task into a semantic matching problem between text and labels. This not only significantly reduces the dependence on large-scale labeled data but also enhances the model's generalization ability to unseen entities or open-domain scenarios, making it particularly suitable for practical application environments with low resources, few samples, or dynamically changing label systems.

[0112] Example 3

[0113] Figure 4 This is a schematic diagram of the structure of an entity classification device provided in Embodiment 3 of the present invention, as shown below. Figure 4 As shown, the entity classification device includes: a boundary alignment module 410, a context encoding module 420, a representation generation module 430, and a result acquisition module 440, wherein,

[0114] The boundary alignment module 410 is used to insert boundary alignment data at the target start and end positions of the entities to be classified in the text to be labeled, so as to obtain the text to be encoded.

[0115] Context encoding module 420 is used to perform context encoding on the text to be encoded to obtain the context encoded representation of the boundary alignment data;

[0116] The generation module 430 is used to generate a representation of the entity to be classified based on the context encoding representation of the boundary alignment data.

[0117] The result acquisition module 440 is used to obtain the entity classification result of the entity to be classified based on the semantic similarity between the entity representation to be classified and each pre-classified prototype representation.

[0118] The technical solution of this embodiment obtains the text to be encoded by inserting boundary alignment data at the target start and end positions of the entities to be classified in the text to be labeled. Contextual encoding is then performed on the text to be encoded to obtain the contextual encoding representation of the boundary alignment data. Based on the contextual encoding representation of the boundary alignment data, a representation of the entity to be classified is generated. Thus, based on the semantic similarity between the representation of the entity to be classified and each pre-classified prototype representation, the entity classification result of the entity to be classified is obtained. This solves the problem that existing technologies cannot flexibly and effectively identify entity types due to their reliance on predefined and closed labeling systems. It reduces the dependence on large-scale manually labeled data and improves the accuracy of semantic understanding and contextual association recognition of entities to be classified. This achieves a highly accurate, flexible, and robust entity classification method, making it adaptable to entity classification needs in more complex text scenarios and expanding its scope of application.

[0119] Optionally, the apparatus further includes: a pre-classification module, used to obtain entity type labels and pre-classified entity representations for each pre-classified entity; and a prototype acquisition module, used to train a prototype representation model based on the entity type labels and the pre-classified entity representations, so that the prototype representation model learns to obtain the type metric space matched by each entity type label and the pre-classified prototype representation.

[0120] Optionally, the prototype acquisition module can be used to: randomly generate initial prototype representations in each entity semantic space; calculate the semantic similarity between each pre-classified entity representation and each initial prototype representation based on the prototype representation model; determine the correspondence between each initial prototype representation and each pre-classified entity representation based on the semantic similarity; iteratively learn the type metric space based on the correspondence between the entity type label and the pre-classified entity representation, and iteratively learn the pre-classified prototype representation based on the correspondence between the initial prototype representation and the pre-classified entity representation.

[0121] Optionally, the device further includes: an entity recognition module, used to input the text to be labeled and the preset prompt word text into a target generative language model, so as to identify at least one target recognition entity in the text to be labeled through the target generative language model; and to determine one of the target recognition entities as the entity to be classified.

[0122] Optionally, the result acquisition module 440 includes: a similarity calculation unit, used to calculate the cosine similarity between the entity representation to be classified and each pre-classified prototype representation, as the semantic similarity; a similarity matching unit, used to determine the pre-classified prototype representation whose cosine similarity with the entity representation to be classified reaches a preset similarity threshold as the target matching prototype representation; and a classification determination unit, used to determine the target entity type corresponding to the target matching prototype representation as the entity classification result of the entity to be classified.

[0123] Optionally, the result acquisition module 440 further includes: an unknown type identification unit, used to determine that the entity to be classified belongs to the current unknown entity type when all the cosine similarities are lower than the preset similarity threshold, and to generate the entity classification result of the entity to be classified based on the semantic representation features of the entity to be classified; wherein the entity classification result of the entity to be classified is different from the pre-classified entity type corresponding to each pre-classified prototype representation.

[0124] Optionally, the unknown type identification unit can be specifically used to: perform unsupervised semantic clustering on the representations of all unclassified entities that are currently determined to belong to the current unknown entity type, to obtain at least one target entity category cluster; generate self-discovered entity types corresponding to each target entity category cluster according to the category cluster semantic features of each target entity category cluster; and determine the self-discovered entity type corresponding to the target entity category cluster of the unclassified entity as the entity classification result of the unclassified entity.

[0125] The entity classification device provided in the embodiments of the present invention can execute the entity classification method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of executing the method.

[0126] Example 4

[0127] Figure 5 This is a schematic diagram of the structure of an entity classification device provided in Embodiment 4 of the present invention, as shown below. Figure 5 As shown, the entity sorting device includes a processor 510, a memory 520, an input device 530, and an output device 540; the number of processors 510 in the entity sorting device can be one or more. Figure 5 Taking a processor 510 as an example; the processor 510, memory 520, input device 530, and output device 540 in the entity sorting device can be connected via a bus or other means. Figure 5 Taking the example of a connection between China and Israel via a bus.

[0128] The memory 520, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as program instructions / modules corresponding to the entity classification method in this embodiment of the invention (e.g., the boundary alignment module 410, context encoding module 420, representation generation module 430, and result acquisition module 440 in the entity classification device). The processor 510 executes various functional applications and data processing of the entity classification device by running the software programs, instructions, and modules stored in the memory 520, thereby implementing the aforementioned entity classification method.

[0129] The memory 520 may primarily include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a given function; the data storage area may store data created based on terminal usage. Furthermore, the memory 520 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory, or other non-volatile solid-state storage device. In some instances, the memory 520 may further include memory remotely located relative to the processor 510, which can be connected to the physical sorting device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0130] Input device 530 can be used to receive input digital or character information, and to generate key signal inputs related to user settings and function control of the entity sorting device. Output device 540 may include display devices such as a display screen.

[0131] Example 5

[0132] Embodiment 5 of the present invention also provides a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform an entity classification method, including:

[0133] Insert boundary alignment data at the target start and end positions of the entities to be classified in the text to be labeled to obtain the text to be encoded.

[0134] Context encoding is performed on the text to be encoded to obtain the context-encoded representation of the boundary-aligned data;

[0135] Based on the context encoding representation of the boundary alignment data, generate the entity representation to be classified of the entity to be classified;

[0136] The entity classification result of the entity to be classified is obtained based on the semantic similarity between the entity representation to be classified and each pre-classified prototype representation.

[0137] Of course, the computer-executable instructions provided in the embodiments of the present invention are not limited to the method operations described above, but can also perform related operations in the entity classification method provided in any embodiment of the present invention.

[0138] Based on the above description of the implementation methods, those skilled in the art can clearly understand that the present invention can be implemented using software and necessary general-purpose hardware, and of course, it can also be implemented using hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk, or optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0139] It is worth noting that in the embodiments of the above-mentioned entity classification device, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be realized; in addition, the specific names of each functional unit are only for easy distinction between each other and are not used to limit the scope of protection of the present invention.

[0140] Although the present invention has been described in detail above with general descriptions, specific embodiments, and experiments, modifications or improvements can be made to it, which will be obvious to those skilled in the art. Therefore, all such modifications or improvements made without departing from the spirit of the present invention fall within the scope of protection claimed by the present invention.

Claims

1. An entity classification method, characterized by, include: Insert boundary alignment data at the target start and end positions of the entities to be classified in the text to be labeled to obtain the text to be encoded. Context encoding is performed on the text to be encoded to obtain the context-encoded representation of the boundary-aligned data; Based on the context encoding representation of the boundary alignment data, generate the entity representation to be classified of the entity to be classified; The entity classification result of the entity to be classified is obtained based on the semantic similarity between the entity representation to be classified and each pre-classified prototype representation.

2. The method of claim 1, wherein, Before obtaining the entity classification result of the entity to be classified based on the representation similarity between the entity representation to be classified and each pre-classified prototype representation, the method further includes: Obtain the entity type label and pre-classified entity representation for each pre-classified entity; The prototype representation model is trained based on the entity type labels and the pre-classified entity representation, so that the prototype representation model learns to obtain the type metric space matched by each entity type label and the pre-classified prototype representation.

3. The method of claim 2, wherein, The step of training the prototype representation model based on the entity type labels and the pre-classified entity representation, so that the prototype representation model learns to obtain the type metric space matched by each entity type label and the pre-classified prototype representation, includes: Initial prototype representations are randomly generated in the semantic space of each entity; Based on the prototype representation model, the semantic similarity between each pre-classified entity representation and each initial prototype representation is calculated; Based on the semantic similarity, the correspondence between each initial prototype representation and each pre-classified entity representation is determined; Based on the correspondence between the entity type labels and the pre-classified entity representations, the type metric space is obtained through iterative learning, and based on the correspondence between the initial prototype representation and the pre-classified entity representations, the pre-classified prototype representation is obtained through iterative learning.

4. The method of claim 1, wherein, Before inserting boundary alignment data at the target start and end positions of the entities to be classified in the text to be labeled to obtain the text to be encoded, the method further includes: The text to be labeled and the preset prompt text are input into the target generative language model to identify at least one target entity in the text to be labeled through the target generative language model; One of the at least one target identification entities is determined as the entity to be classified.

5. The method of claim 1, wherein, The step of obtaining the entity classification result of the entity to be classified based on the semantic similarity between the entity representation to be classified and each pre-classified prototype representation includes: Calculate the cosine similarity between the entity representation to be classified and each pre-classified prototype representation, and use it as the semantic similarity; The pre-classified prototype representation whose cosine similarity with the entity to be classified reaches a preset similarity threshold is determined as the target matching prototype representation; The target entity type corresponding to the target matching prototype is determined as the entity classification result of the entity to be classified.

6. The method of claim 5, wherein, After calculating the cosine similarity between the entity representation to be classified and each pre-classified prototype representation as the semantic similarity, the method further includes: If all the cosine similarities are lower than the preset similarity threshold, it is determined that the entity to be classified belongs to the current unknown entity type, and the entity classification result of the entity to be classified is generated according to the semantic representation features represented by the entity to be classified. The entity classification result of the entity to be classified is different from the pre-classified entity type represented by each pre-classification prototype.

7. The method according to claim 6, characterized in that, The step of generating the entity classification result based on the semantic representation features of the entity to be classified includes: Unsupervised semantic clustering is performed on the representations of all unclassified entities that are currently identified as belonging to the currently unknown entity type to obtain at least one target entity category cluster. Based on the semantic features of each target entity category cluster, generate self-discovered entity types corresponding to each target entity category cluster; The self-discovered entity type corresponding to the target entity category cluster of the entity to be classified is determined as the entity classification result of the entity to be classified.

8. A physical sorting device, characterized in that, include: The boundary alignment module is used to insert boundary alignment data at the target start and end positions of the entities to be classified in the text to be labeled, so as to obtain the text to be encoded. A context encoding module is used to perform context encoding on the text to be encoded to obtain a context-encoded representation of the boundary alignment data; The representation generation module is used to generate a representation of the entity to be classified based on the context encoding representation of the boundary alignment data; The result acquisition module is used to obtain the entity classification result of the entity to be classified based on the semantic similarity between the entity representation to be classified and each pre-classified prototype representation.

9. A physical sorting device, characterized in that, include: One or more processors; Memory, used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the entity classification method as described in any one of claims 1-7.

10. A storage medium containing computer-executable instructions, characterized in that, The computer-executable instructions, when executed by a computer processor, are used to perform the entity classification method as described in any one of claims 1-7.