A context learning-based generative knowledge object extraction method and system

By using a context-based generative knowledge object extraction method, the optimal context example is dynamically selected, which solves the problem of insufficient example selection mechanism in the existing technology and improves the adaptability and accuracy of the generative named entity recognition model in cross-domain scenarios.

CN120930750BActive Publication Date: 2026-03-17DOCUMENT & INFORMATION CENT OF CHINESE ACAD OF SCI
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202511056711.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-30
Publication Date
2026-03-17
Estimated Expiration
2045-07-30

AI Technical Summary

Technical Problem

Existing generative named entity recognition methods lack a dynamic example selection mechanism based on the semantic features of the input text. This results in examples failing to accurately align with the text context and task requirements, affecting the model's adaptability and accuracy in complex and diverse text environments, leading to large fluctuations in entity recognition results and weak generalization ability.

Method used

We employ a context-based generative knowledge object extraction method. The target text is preprocessed by encoding using a Transformer encoder in a dual-tower structure. The target examples are then matched with a pre-stored vector library to form a structured input prompt. The generative knowledge object extraction model is used for extraction analysis to dynamically select the optimal context example to enhance the prompt's adaptability.

Benefits of technology

It improves the stability, accuracy, and robustness of generative named entity recognition models in cross-domain scenarios, thereby enhancing the stability and accuracy of entity recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120930750B_ABST
    Figure CN120930750B_ABST
Patent Text Reader

Abstract

This application provides a generative knowledge object extraction method and system based on context learning, relating to the field of generative artificial intelligence technology. The method includes: preprocessing the target text by encoding it using a first Transformer encoder in a dual-tower structure to obtain a target vector; traversing and matching the target vector in a pre-stored vector library to obtain a target matching vector, where the target matching vector corresponds to a target example; combining the target text and the target example to form a target structured input prompt; and under the constraint of the target structured input prompt, a generative knowledge object extraction model extracts and analyzes the target text to obtain the target extraction result. This application can solve the technical problem of poor accuracy in entity recognition results of existing generative entity recognition models, achieving the technical effect of improving the accuracy of generative named entity recognition models.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of generative artificial intelligence technology, and in particular to a generative knowledge object extraction method and system based on context learning. Background Technology

[0002] In natural language processing tasks, named entity recognition (NER) is a crucial step in information extraction and is widely used in various scenarios such as patent text processing, public opinion analysis, and medical literature analysis, playing a particularly central role in understanding unstructured text. In recent years, with the development of large-scale pre-trained language models, few-shot and zero-shot generative NER based on context learning has become a research hotspot. By adding several labeled examples to the prompts, the large model is guided to imitate the examples to generate entity recognition results, which not only improves generalization ability but also simplifies the deployment process.

[0003] Currently, existing generative named entity recognition methods generally use fixed or static examples in their example selection, lacking the ability to dynamically adapt to the semantic features of the input text. They cannot flexibly adjust the prompts based on differences in task domain, text structure, or entity distribution. This static example strategy may perform well in the initial design stage, but when faced with cross-domain, cross-language, or low-resource scenarios, it often fails to provide representative contextual references, leading to decreased prompt effectiveness, model comprehension bias, and unstable entity recognition accuracy.

[0004] In summary, existing technologies suffer from the technical problem of lacking a dynamic example selection mechanism based on the semantic features of the input text. This results in examples failing to accurately align with the text context and task requirements, further affecting the adaptability and accuracy of generative entity recognition models in complex and diverse text environments, leading to large fluctuations in entity recognition results and weak generalization ability. Summary of the Invention

[0005] The purpose of this application is to provide a generative knowledge object extraction method and system based on context learning, in order to solve the technical problem in the prior art that the lack of a dynamic example selection mechanism oriented towards the semantic features of the input text leads to the example not being able to accurately align with the text context and task requirements, which further affects the adaptability and accuracy of the generative entity recognition model in complex and diverse text environments, resulting in large fluctuations in entity recognition results and weak generalization ability.

[0006] In view of the above problems, this application provides a generative knowledge object extraction method and system based on context learning.

[0007] Firstly, this application provides a context-based generative knowledge object extraction method, implemented through a context-based generative knowledge object extraction system, comprising: preprocessing the target text by encoding it using a first Transformer encoder in a dual-tower structure to obtain a target vector; traversing and matching the target vector in a pre-stored vector library to obtain a target matching vector, wherein the target matching vector corresponds to a target example; combining the target text and the target example to form a target structured input prompt; and under the constraints of the target structured input prompt, performing extraction analysis on the target text using a generative knowledge object extraction model to obtain a target extraction result.

[0008] Preferably, the generative knowledge object extraction method based on context learning further includes: constructing an example library based on big data; introducing an example selection strategy to perform selection analysis on the example library to obtain a candidate example list; performing encoding preprocessing on the first candidate example in the candidate example list through the second Transformer encoder in the dual-tower structure to obtain a first vector; and forming the pre-stored vector library based on the correspondence between the first candidate example and the first vector.

[0009] Preferably, the generative knowledge object extraction method based on context learning further includes: extracting any example from the example library; evaluating and analyzing the arbitrary example according to the first-level evaluation plan in the example selection strategy to obtain an arbitrary task adaptability index; evaluating and analyzing the arbitrary example according to the second-level evaluation plan in the example selection strategy to obtain an arbitrary feature matching degree index; evaluating and analyzing the arbitrary example according to the third-level evaluation plan in the example selection strategy to obtain an arbitrary generation quality index; obtaining an arbitrary fitness based on the arbitrary task adaptability index, the arbitrary feature matching degree index, and the arbitrary generation quality index; and adding the arbitrary example to the candidate example list if the arbitrary fitness reaches a predetermined fitness limit.

[0010] Preferably, the generative knowledge object extraction method based on context learning further includes: the first-level evaluation plan refers to a plan for evaluating the consistency between the arbitrary example and the target text in terms of domain and type.

[0011] Preferably, the generative knowledge object extraction method based on context learning further includes: the secondary evaluation plan refers to a plan for evaluating the feature matching of the arbitrary example and the target text in a first predetermined dimension, wherein the first predetermined dimension includes at least a semantic dimension, a syntactic structure dimension, a lexical distribution dimension, and a contextual dimension; wherein, according to the secondary evaluation plan in the example selection strategy, the arbitrary example is evaluated and analyzed to obtain an arbitrary feature matching degree index, including: constructing an arbitrary keyword group of the arbitrary example; constructing a target keyword group of the target text; taking the first intersection keyword of the arbitrary keyword group and the target keyword group; sequentially calculating the distribution density of the first intersection keyword in the arbitrary example and the target text, respectively denoted as the first arbitrary density and the first target density; taking the first density difference between the first arbitrary density and the first target density as the feature matching degree of the arbitrary example and the target text in the lexical distribution dimension; and normalizing and weighting the feature matching degree to obtain the arbitrary feature matching degree index.

[0012] Preferably, the generative knowledge object extraction method based on context learning further includes: the three-level evaluation plan refers to a plan for evaluating the generation quality of the arbitrary example and the target text in a second predetermined dimension, and the second predetermined dimension includes at least accuracy and recall.

[0013] Preferably, the generative knowledge object extraction method based on context learning further includes: the second Transformer encoder and the first Transformer encoder sharing encoding parameters.

[0014] Preferably, the generative knowledge object extraction method based on context learning further includes: calculating the first cosine similarity between the target vector and the first vector; sorting the first candidate examples in descending order based on the first cosine similarity to obtain a descending list of candidate examples; taking the first example in the descending list of candidate examples as the target example, and taking the first vector corresponding to the first example as the target matching vector.

[0015] Preferably, the generative knowledge object extraction method based on context learning further includes: extracting the last example from the candidate example descending list as the second target example; constructing a triplet based on the target text, the target example, and the second target example; activating the example validation model to perform validation analysis on the triplet to obtain a validation result; if the validation result meets a predetermined validation constraint, then combining the target text and the target example to form the target structured input prompt; wherein, the predetermined validation constraint means that the extraction result after combining the target example and the target text is significantly better than the extraction result after combining the second target example and the target text.

[0016] Secondly, this application also provides a context-based generative knowledge object extraction system for executing a context-based generative knowledge object extraction method as described in the first aspect, comprising: an encoding preprocessing module for encoding preprocessing the target text using a first Transformer encoder in a dual-tower structure to obtain a target vector; a traversal matching module for traversing and matching the target vector in a pre-stored vector library to obtain a target matching vector, wherein the target matching vector corresponds to a target example; a prompting formation module for combining the target text and the target example to form a target structured input prompt; and an extraction analysis module for performing extraction analysis on the target text under the constraints of the target structured input prompt to obtain a target extraction result.

[0017] The technical solution provided in this application has at least the following technical effects or advantages: by realizing the technical goal of dynamically selecting the optimal context example based on the task text to enhance the adaptability of the prompt, the technical effect of improving the stability, accuracy and robustness of the generative named entity recognition model in cross-domain scenarios is achieved.

[0018] The above description is merely an overview of the technical solution of this application. To better understand the technical means of this application and to facilitate its implementation according to the description, and to make the above and other objects, features, and advantages of this application more apparent, specific embodiments of this application are described below. It should be understood that the content described in this section is not intended to identify key or important features of the embodiments of this application, nor is it intended to limit the scope of this application. Other features of this application will become readily apparent through the following description. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are merely exemplary. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0020] Figure 1 This is a flowchart illustrating a generative knowledge object extraction method based on context learning, as described in this application.

[0021] Figure 2 This is a schematic diagram of the structure of a generative knowledge object extraction system based on context learning, as proposed in this application.

[0022] Figure labeling: Encoding preprocessing module 11, Traversal matching module 12, Prompt generation module 13, Extraction and analysis module 14. Detailed Implementation

[0023] This application provides a context-based generative knowledge object extraction method and system, addressing the technical problem in existing technologies where the lack of a dynamic example selection mechanism based on the semantic features of the input text leads to examples failing to accurately align with the text context and task requirements. This further affects the adaptability and accuracy of generative entity recognition models in complex and diverse text environments, resulting in large fluctuations in entity recognition results and weak generalization ability. The method achieves the technical goal of dynamically selecting the optimal contextual examples based on the task text to enhance the adaptability of prompts, thereby improving the stability, accuracy, and robustness of generative named entity recognition models in cross-domain scenarios.

[0024] The technical solutions of this application will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. It should be understood that this application is not limited to the exemplary embodiments described herein. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application. It should also be noted that, for ease of description, only the parts related to this application are shown in the accompanying drawings, not all of them.

[0025] Example 1, please refer to the appendix. Figure 1 This application provides a context-based generative knowledge object extraction method, applied to a context-based generative knowledge object extraction system, specifically including the following steps:

[0026] The target text is preprocessed by encoding the first Transformer encoder in the dual-tower structure to obtain the target vector.

[0027] Specifically, the dual-tower structure is a model architecture consisting of two independent encoders that process different input data, thereby achieving efficient matching and fast retrieval. The first encoder in the dual-tower structure, the Transformer encoder, is a deep neural network structure based on a self-attention mechanism, used to process the target text and capture the contextual relationships between words within it. The target text refers to the input text from which knowledge object extraction is performed; it could be a patent abstract, product description, or other natural language passage. Encoding preprocessing transforms the target text into a fixed-dimensional vector representation, compressing the original linguistic information into a mathematical structure that can be understood and compared by a computer, serving as the target vector.

[0028] The target vector is traversed and matched in a pre-stored vector library to obtain a target matching vector, wherein the target matching vector corresponds to a target example.

[0029] Specifically, the pre-stored vector library is a collection of vectors formed by encoding multiple candidate examples. The target vector is iterated through and matched against all the example vectors already stored in the pre-stored vector library, and similarity calculations are performed. Based on methods such as cosine similarity, one or more vectors that are closest to the target vector are selected from the candidate vectors to obtain the target matching vector. The target matching vector is the vector with the highest similarity to the target vector, and the corresponding text example is called the target example, representing the reference case that is most relevant to the current task semantically or structurally.

[0030] S3: Combine the target text with the target example to form a target structured input prompt.

[0031] Specifically, the target text and target examples are combined. The target text for entity recognition is concatenated with the best reference example selected after vector matching. The target text is the actual content to be processed, while the target example is highly relevant annotated text selected from the candidate set, containing entity annotation information with similar structure or semantics. The concatenated content is organized into a clearly formatted input according to a preset prompt template, forming a structured input prompt to guide the large language model to perform the named entity recognition task more accurately. This prompt includes task description, output format description, several examples, and the current input text.

[0032] S4: Under the constraints of the target structured input prompt, the generative knowledge object extraction model extracts and analyzes the target text to obtain the target extraction result.

[0033] Specifically, structured input prompts define the model's understanding scope and generative behavior, enabling it to more accurately identify target information. Under the constraint of structured input prompts, the organized input prompts serve as the input conditions for the generative model. The generative knowledge object extraction model is a system based on a large language model architecture. It completes the named entity recognition task through natural language generation, directly generating entities and their types based on the input content. The generative knowledge object extraction model extracts and analyzes target text, performs semantic understanding on input text paragraphs or sentences, identifies entities or terms with specific meanings, and outputs structured results, thus obtaining the target extraction results.

[0034] Furthermore, this application also includes: constructing an example library based on big data; introducing an example selection strategy to perform selection analysis on the example library to obtain a candidate example list; performing encoding preprocessing on the first candidate example in the candidate example list through the second Transformer encoder in the dual-tower structure to obtain a first vector; and forming the pre-stored vector library based on the correspondence between the first candidate example and the first vector.

[0035] Specifically, an example library is built based on big data. This involves using large-scale text datasets, such as those from patent documents, news corpora, encyclopedia content, or social media texts, and extracting information examples with entity labels through preprocessing, manual annotation, or automatic annotation. This forms a basic dataset for generative entity recognition tasks. Each example includes text and its corresponding entity annotation information for subsequent model learning and selection.

[0036] An example selection strategy is introduced to select and analyze the example library to obtain a candidate example list. After the example library is built, all examples are analyzed according to predefined selection criteria, including indicators such as task adaptability, semantic similarity and prediction performance. Each example is evaluated and scored to select several examples that are more relevant and representative to the current text to be processed, which are then used as a candidate list for subsequent matching.

[0037] The second Transformer encoder processes the candidate example data and outputs a vector representation for subsequent similarity matching. The second Transformer encoder in the dual-tower structure preprocesses the first candidate example in the candidate example list by encoding each candidate example in the list into the second Transformer encoder, resulting in a first vector, which is a dense representation of the first candidate example in the semantic space. Based on the correspondence generated by storing the first candidate example and the first vector in a one-to-one relationship, a pre-stored vector library is formed for vector retrieval and input prompts.

[0038] Furthermore, this application also includes: extracting any example from the example library; evaluating and analyzing the arbitrary example according to the first-level evaluation plan in the example selection strategy to obtain an arbitrary task adaptability index; evaluating and analyzing the arbitrary example according to the second-level evaluation plan in the example selection strategy to obtain an arbitrary feature matching degree index; evaluating and analyzing the arbitrary example according to the third-level evaluation plan in the example selection strategy to obtain an arbitrary generation quality index; obtaining an arbitrary fitness based on the arbitrary task adaptability index, the arbitrary feature matching degree index, and the arbitrary generation quality index; and adding the arbitrary example to the candidate example list if the arbitrary fitness reaches a predetermined fitness limit.

[0039] Specifically, any example is extracted from the example library. From a pre-built dataset containing a large number of text samples with entity annotations, a sample is randomly selected for subsequent evaluation. This sample includes the original text, the corresponding entity name and type, and may come from diverse corpora such as patent documents, policies and regulations, or product descriptions. It serves as a contextual example that can be referenced during training and inference.

[0040] The first-level evaluation plan refers to analyzing whether any example is suitable for the current task objective from a macro perspective. For example, it assesses whether any example is in the same domain as the target text and whether it contains similar entity types. If the target text is from the medical field, examples with medical terminology have higher task adaptability and a higher corresponding task adaptability index. Then, based on the first-level evaluation plan in the example selection strategy, any example is evaluated and analyzed to obtain an arbitrary task adaptability index.

[0041] The secondary evaluation plan refers to comparing the multi-dimensional linguistic features between any example and the target text at a detailed level, including semantics, syntactic structure, vocabulary distribution, and contextual similarity. For example, if two texts use similar keyword structures or have similar sentence arrangements, the feature matching index will be higher, which helps improve the generalization and recognition ability of the generative model. Then, based on the secondary evaluation plan in the example selection strategy, any example is evaluated and analyzed to obtain an arbitrary feature matching index.

[0042] The three-level evaluation plan is used to simulate or review the entity recognition performance after using arbitrary examples in the Prompt construction, such as the evaluation score calculated based on the precision and recall of the historical model inference output. If an arbitrary example can prompt the generative model to output more correct entities, its generation quality index will increase accordingly, reflecting its direct positive impact on model performance. Furthermore, based on the three-level evaluation plan in the example selection strategy, arbitrary examples are evaluated and analyzed to obtain the arbitrary generation quality index.

[0043] Based on an arbitrary task adaptability index, an arbitrary feature matching degree index, and an arbitrary generation quality index, the scores of the three dimensions are uniformly weighted or fused to form a comprehensive evaluation index, resulting in arbitrary fitness, which reflects whether any example is suitable as a whole for constructing contextual hints for the current task. The weighting may be dynamically adjusted according to task characteristics.

[0044] If any fitness score reaches a predetermined fitness limit, the example is added to the candidate example list. This means that any example with a comprehensive score not lower than the predetermined fitness limit is included in the subsequent similarity matching and prompt construction process. This ensures that the example quality and relevance to the target task meet an acceptable standard, thereby improving the final entity recognition performance. Table 1 shows the evaluation records of the candidate example list.

[0045] Table 1: Evaluation Records of the Candidate Example List

[0046]

[0047]

[0048] Furthermore, this application also includes: the first-level assessment plan refers to a plan for assessing the consistency of the domain and type between the arbitrary example and the target text.

[0049] Specifically, the first-level assessment plan refers to the first-layer analysis scheme set in the example selection strategy, used to determine the consistency between any example and the target text in terms of domain and entity type. Any example refers to any annotated text fragment selected from the example library, containing entity information and its corresponding context; while the target text is the input text for the current entity recognition operation. Domain refers to the professional topic or knowledge category involved in the text, such as medical, financial, legal, or technological; type refers to the entity's classification label, such as name, organization, product, drug, contract number, etc.

[0050] When conducting consistency assessments, it's crucial to compare whether the target text and any examples in the corpus belong to the same industry sector. For instance, a target text in the legal field, with examples derived from contracts or court judgments, is more likely to provide instructive contextual templates. It's also essential to compare whether the target text and any examples in the corpus belong to the same entity type. For example, if the target text primarily contains place names, while the examples are labeled with product names, this type inconsistency reduces the reference value of the examples and affects the accuracy of the generative model.

[0051] Furthermore, this application also includes: the secondary evaluation plan refers to a plan for evaluating the feature matching of the arbitrary example and the target text in a first predetermined dimension, wherein the first predetermined dimension includes at least a semantic dimension, a syntactic structure dimension, a lexical distribution dimension, and a contextual dimension; wherein, according to the secondary evaluation plan in the example selection strategy, the arbitrary example is evaluated and analyzed to obtain an arbitrary feature matching index, including: constructing an arbitrary keyword group of the arbitrary example; constructing a target keyword group of the target text; taking the first intersection keyword of the arbitrary keyword group and the target keyword group; sequentially calculating the distribution density of the first intersection keyword in the arbitrary example and the target text, respectively denoted as the first arbitrary density and the first target density; taking the first density difference between the first arbitrary density and the first target density as the feature matching degree of the arbitrary example and the target text in the lexical distribution dimension; and normalizing and weighting the feature matching degree to obtain the arbitrary feature matching index.

[0052] Specifically, the secondary evaluation plan refers to the method used in the example selection strategy to analyze the similarity between texts. It is used to conduct multi-dimensional matching evaluations of any example and the target text from the perspective of linguistic features. The first predetermined dimension refers to a set of pre-defined linguistic feature dimensions used for matching analysis, including four categories: semantic dimension, syntactic structure dimension, lexical distribution dimension, and contextual dimension. The semantic dimension focuses on the degree of semantic closeness between two texts; the syntactic structure dimension analyzes whether the sentence structures of the texts are similar; the lexical distribution dimension assesses whether the frequency and position of keywords in the text are similar; and the contextual dimension observes whether the position and logical connection of key entities in the context are consistent.

[0053] The secondary assessment plan evaluates and analyzes any example to calculate a specific arbitrary feature matching index. This involves constructing an arbitrary keyword group for any example, that is, extracting representative keywords that reflect the theme from any example, such as "contract number," "applicant name," and "application date." The same process is then applied to the target text to construct a set of target keywords representing important information features within the target text.

[0054] Subsequently, the intersection of the semantic keyword group and the target keyword group is extracted, that is, the keywords contained in both, as the first intersection keyword. The distribution density of the first intersection keyword in the example text and the target text is calculated in turn. The distribution density is the frequency and position distribution of the keyword, such as high frequency of appearance at the beginning of the text, concentration in technical description paragraphs, etc., and is denoted as the first arbitrary density and the first target density, respectively.

[0055] Next, the density values ​​of the first arbitrary density and the first target density are subtracted to obtain the first density difference. This first density difference is used to measure whether the usage patterns of the first intersection keywords in the two texts are consistent, thus indirectly reflecting whether the contextual expressions of the two texts are similar. The first density difference is the feature matching degree under the word distribution dimension. The smaller the first density difference, the closer the matching degree, indicating that any example is more consistent with the target text in the use of the first intersection keywords.

[0056] Finally, based on the method used to calculate the feature matching degree of the first intersection keywords, the feature matching degrees of other intersection keywords are obtained. Then, the feature matching degrees under different dimensions are normalized, that is, mapped to a unified dimensional range (such as 0 to 1), and then weighted and merged to obtain the final feature matching degree index. The weighting ratio can be adjusted according to the task requirements. For example, in technical texts, the weight of word distribution can be increased, and in spoken texts, the influence of semantic dimension can be enhanced.

[0057] Furthermore, this application also includes: the three-level evaluation plan refers to a plan for evaluating the generation quality of the arbitrary example and the target text in a second predetermined dimension, and the second predetermined dimension includes at least accuracy and recall.

[0058] Specifically, the three-level evaluation plan refers to the third type of evaluation scheme used to evaluate the impact of arbitrary examples on the actual output of the generative model in entity recognition tasks. By comparing and analyzing the generated results after using arbitrary examples with the real entity labels, it is determined whether arbitrary examples have truly improved the recognition quality.

[0059] The second predetermined dimension is used for quality assessment and includes at least two key metrics: precision and recall. Precision is calculated by dividing the number of correct entities by the total number of output entities; it represents the proportion of generated entities that match the true labels. Recall reflects the ability to identify true entities, i.e., the proportion of correctly identified entities out of all true entities. Precision and recall are used to measure the performance of the information extraction system; high precision means fewer false positives, and high recall means fewer false negatives.

[0060] Furthermore, this application also includes: the second Transformer encoder and the first Transformer encoder share encoding parameters.

[0061] Specifically, the second Transformer encoder is the neural network module used to encode candidate examples. In the dual-tower structure, it handles the example-side input, mapping each candidate example text to a fixed-dimensional semantic vector representation. The first Transformer encoder, on the other hand, is responsible for encoding the target text, converting the input text to be recognized into a corresponding vector form for matching or similarity calculation with example vectors. Shared encoding parameters mean that the first and second Transformer encoders use the same weights, employ the same word vector initialization method, attention mechanism parameters, layer structure, and positional encoding scheme. This reduces the number of parameters while maintaining modeling consistency, thereby improving overall training and inference efficiency.

[0062] Furthermore, this application also includes: calculating the first cosine similarity between the target vector and the first vector; sorting the first candidate examples in descending order based on the first cosine similarity to obtain a descending list of candidate examples; taking the first example in the descending list of candidate examples as the target example, and taking the first vector corresponding to the first example as the target matching vector.

[0063] Specifically, the cosine similarity vector similarity metric is used to calculate the closeness between the target vector and the first vector, resulting in the first cosine similarity. The cosine similarity value ranges from -1 to 1. The closer the value is to 1, the more consistent the target vector and the first vector are, indicating that the two texts are semantically similar.

[0064] The candidate examples are sorted in descending order based on the first cosine similarity score. This involves ranking all candidate examples and the target text according to their similarity scores, resulting in a descending list of candidate examples. Sort by score from highest to lowest, this helps to quickly identify the most relevant examples for the current task, thus avoiding invalid or misleading prompts that could interfere with the output.

[0065] The first example in the descending list of candidate examples is selected as the target example. That is, the candidate example with the highest cosine similarity score is selected from the sorted list, and the first vector corresponding to the first example is used as the target matching vector, which serves as representative semantic information for localization and analysis in subsequent modeling.

[0066] Furthermore, this application also includes: extracting the last example from the candidate example descending list as the second target example; constructing a triplet based on the target text, the target example, and the second target example; activating the example validation model to perform validation analysis on the triplet to obtain a validation result; if the validation result meets a predetermined validation constraint, then combining the target text and the target example to form the target structured input prompt; wherein, the predetermined validation constraint means that the extraction result after combining the target example and the target text is significantly better than the extraction result after combining the second target example and the target text.

[0067] Specifically, the last example in the descending list of candidate examples is extracted as the second target example. That is, the last candidate example in the list of candidate examples sorted by cosine similarity is selected as the control sample. The second target example has the lowest similarity score and the weakest semantic match with the target text, and is therefore regarded as a negative reference sample.

[0068] The model constructs a triplet based on the target text, the target example, and the second target example. This triplet combines the target text to be identified, the best example selected from the example list (the target example), and the worst example (the second target example) into a structural unit containing three elements. This unit is used for comparative task learning. By introducing both good and bad examples into the model simultaneously, the model's ability to identify effective examples is enhanced.

[0069] The example validation model is activated to perform validation analysis on the triples. It combines the target example and the second target example in the triple with the target text respectively, evaluating their performance on the named entity recognition task and obtaining the validation result. The example validation model can employ reinforcement learning, score regression, or discriminant networks, outputting a quantitative result to evaluate the quality of the examples.

[0070] If the validation result meets the predetermined validation constraints, the target text and the target example are combined to form a target structured input prompt. That is, the target example will only be used to construct the final input prompt if the validation result determines that the extraction effect of the target example is significantly better than that of the second target example. The structured input prompt refers to a complete prompt that includes a task description, output format, and example content, used to guide the generative model in named entity recognition.

[0071] Among them, the pre-defined validation constraint is that the extraction result of the target example combined with the target text is significantly better than the extraction result of the second target example combined with the target text. The pre-defined validation constraint means a pre-set benchmark standard, such as an accuracy of at least 10% higher or stronger completeness of the identified key entities. It will only be adopted when the target example meets the obvious advantage.

[0072] In summary, the context-based generative knowledge object extraction method provided in this application has the following technical effects: by achieving the technical goal of dynamically selecting the optimal context example based on the task text to enhance the adaptability of prompts, the stability, accuracy and robustness of the generative named entity recognition model in cross-domain scenarios are improved.

[0073] Example 2: Based on the same inventive concept as the context-learning-based generative knowledge object extraction method in the foregoing examples, this application also provides a context-learning-based generative knowledge object extraction system. Please refer to the appendix. Figure 2 The system includes: an encoding preprocessing module 11, used to encode and preprocess the target text using a first Transformer encoder in a dual-tower structure to obtain a target vector; a traversal matching module 12, used to traverse and match the target vector in a pre-stored vector library to obtain a target matching vector, wherein the target matching vector corresponds to a target example; a prompting module 13, used to combine the target text and the target example to form a target structured input prompt; and an extraction and analysis module 14, used to extract and analyze the target text using a generative knowledge object extraction model under the constraints of the target structured input prompt to obtain a target extraction result.

[0074] Furthermore, the generative knowledge object extraction system based on context learning is also used for: building an example library based on big data; introducing an example selection strategy to perform selection analysis on the example library to obtain a candidate example list; performing encoding preprocessing on the first candidate example in the candidate example list through the second Transformer encoder in the dual-tower structure to obtain a first vector; and forming the pre-stored vector library based on the correspondence between the first candidate example and the first vector.

[0075] Furthermore, the context-based generative knowledge object extraction system is further configured to: extract any example from the example library; evaluate and analyze the arbitrary example according to the first-level evaluation plan in the example selection strategy to obtain an arbitrary task adaptability index; evaluate and analyze the arbitrary example according to the second-level evaluation plan in the example selection strategy to obtain an arbitrary feature matching degree index; evaluate and analyze the arbitrary example according to the third-level evaluation plan in the example selection strategy to obtain an arbitrary generation quality index; obtain an arbitrary fitness based on the arbitrary task adaptability index, the arbitrary feature matching degree index, and the arbitrary generation quality index; and if the arbitrary fitness reaches a predetermined fitness limit, add the arbitrary example to the candidate example list.

[0076] Furthermore, the generative knowledge object extraction system based on context learning is also used for: the first-level evaluation plan refers to the plan for evaluating the consistency of the domain and type between the arbitrary example and the target text.

[0077] Furthermore, the generative knowledge object extraction system based on context learning is also used for: the secondary evaluation plan refers to a plan for evaluating the feature matching of the arbitrary example and the target text in a first predetermined dimension, wherein the first predetermined dimension includes at least a semantic dimension, a syntactic structure dimension, a lexical distribution dimension, and a contextual dimension; wherein, according to the secondary evaluation plan in the example selection strategy, the arbitrary example is evaluated and analyzed to obtain an arbitrary feature matching degree index, including: constructing an arbitrary keyword group of the arbitrary example; constructing a target keyword group of the target text; taking the first intersection keyword of the arbitrary keyword group and the target keyword group; sequentially calculating the distribution density of the first intersection keyword in the arbitrary example and the target text, respectively denoted as the first arbitrary density and the first target density; taking the first density difference between the first arbitrary density and the first target density as the feature matching degree of the arbitrary example and the target text in the lexical distribution dimension; and normalizing and weighting the feature matching degree to obtain the arbitrary feature matching degree index.

[0078] Furthermore, the generative knowledge object extraction system based on context learning is also used in the following way: the three-level evaluation plan refers to the plan for evaluating the generation quality of the arbitrary example and the target text in a second predetermined dimension, and the second predetermined dimension includes at least the accuracy and recall rate.

[0079] Furthermore, the generative knowledge object extraction system based on context learning is also used for: sharing encoding parameters between the second Transformer encoder and the first Transformer encoder.

[0080] Furthermore, the generative knowledge object extraction system based on context learning is also used for: calculating the first cosine similarity between the target vector and the first vector; sorting the first candidate examples in descending order based on the first cosine similarity to obtain a descending list of candidate examples; taking the first example in the descending list of candidate examples as the target example, and taking the first vector corresponding to the first example as the target matching vector.

[0081] Furthermore, the generative knowledge object extraction system based on context learning is also used for: extracting the last example from the descending list of candidate examples as the second target example; constructing a triplet based on the target text, the target example, and the second target example; activating the example verification model to perform verification analysis on the triplet to obtain a verification result; if the verification result meets the predetermined verification constraints, then combining the target text and the target example to form the target structured input prompt; wherein, the predetermined verification constraints refer to the extraction result after combining the target example and the target text being significantly better than the extraction result after combining the second target example and the target text.

[0082] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The context-based generative knowledge object extraction method and specific examples in the aforementioned Embodiment 1 are also applicable to the context-based generative knowledge object extraction system in this embodiment. Through the foregoing detailed description of the context-based generative knowledge object extraction method, those skilled in the art can clearly understand the context-based generative knowledge object extraction system in this embodiment. Therefore, for the sake of brevity, it will not be described in detail here.

[0083] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

[0084] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of this application and its equivalents, this application also intends to include such modifications and variations.

Claims

1. A context learning based generative knowledge object extraction method, characterized in that, The method comprises the following steps: encoding preprocessing of the target text by a first Transformer encoder in a double-tower structure to obtain a target vector; traversing and matching the target vector in a pre-stored vector library to obtain a target matching vector, wherein the target matching vector corresponds to a target example; combining the target text and the target example to form a target structured input prompt; generating a formula knowledge object extraction model to perform extraction analysis on the target text under the constraint of the target structured input prompt to obtain a target extraction result; before traversing and matching the target vector in the pre-stored vector library, the method comprises the following steps: building an example library based on big data; introducing an example selection strategy to perform selection analysis on the example library to obtain a candidate example list; encoding preprocessing of a first candidate example in the candidate example list by a second Transformer encoder in the double-tower structure to obtain a first vector, wherein the second Transformer encoder shares encoding parameters with the first Transformer encoder; forming the pre-stored vector library based on the correspondence between the first candidate example and the first vector; introducing an example selection strategy to perform selection analysis on the example library to obtain a candidate example list, comprising the following steps: extracting any example in the example library; performing evaluation analysis on the any example according to a first-level evaluation plan in the example selection strategy to obtain an any task adaptability index; performing evaluation analysis on the any example according to a second-level evaluation plan in the example selection strategy to obtain an any feature matching degree index; performing evaluation analysis on the any example according to a third-level evaluation plan in the example selection strategy to obtain an any generation quality force index; obtaining an any fitness degree based on the any task adaptability index, the any feature matching degree index and the any generation quality force index; if the any fitness degree reaches a predetermined fitness limit value, the any example is added to the candidate example list. 2.The context learning based generative knowledge object extraction method of claim 1, wherein, The first-level evaluation plan refers to a plan for evaluating the consistency of the any example and the target text in terms of domain and type. 3.The context learning based generative knowledge object extraction method of claim 1, wherein, The second-level evaluation plan refers to a plan for evaluating the feature matching of the any example and the target text in a first predetermined dimension, and the first predetermined dimension at least includes semantic dimension, syntactic structure dimension, vocabulary distribution dimension and context dimension. Wherein, performing evaluation analysis on the any example according to the second-level evaluation plan in the example selection strategy to obtain an any feature matching degree index, comprising the following steps: building an any keyword group of the any example; building a target keyword group of the target text; taking a first intersection keyword of the any keyword group and the target keyword group; sequentially calculating the distribution density of the first intersection keyword in the any example and the target text, respectively denoted as a first any density and a first target density; taking a first density difference between the first any density and the first target density as a feature matching degree of the any example and the target text in the vocabulary distribution dimension. The feature matching degree is normalized and weighted to obtain the arbitrary feature matching degree index. 4.The method of claim 1, wherein, The third evaluation plan refers to a plan for performing generation quality evaluation of the arbitrary example and the target text in a second predetermined dimension, and the second predetermined dimension at least includes accuracy and recall rate.

5. The method of claim 1, wherein the method is based on a context learning generative knowledge object extraction method. The target vector is matched in a pre-stored vector library to obtain a target matching vector, wherein the target matching vector corresponds to a target example and includes: A first cosine similarity between the target vector and the first vector is calculated. The first candidate example is arranged in descending order based on the first cosine similarity to obtain a descending order list of candidate examples. The first example in the descending order list of candidate examples is taken as the target example, and a first vector corresponding to the first example is taken as the target matching vector.

6. The context learning based generative knowledge object extraction method of claim 5, wherein, Before the target text and the target example are combined to form a target structured input prompt, the method further includes: The last example in the descending order list of candidate examples is taken as a second target example. A triple is formed based on the target text, the target example, and the second target example. A sample verification model is activated to perform verification analysis on the triple to obtain a verification result. If the verification result meets a predetermined verification constraint, the target text and the target example are combined to form the target structured input prompt. The predetermined verification constraint refers to an extraction result obtained by combining the target example and the target text being significantly better than an extraction result obtained by combining the second target example and the target text.

7. A context learning based generative knowledge object extraction system, characterized by, The steps of the method for implementing the context learning-based generative knowledge object extraction method of any one of claims 1-6 include: An encoding preprocessing module is configured to perform encoding preprocessing on the target text by a first Transformer encoder in a double-tower structure to obtain a target vector. An iterative matching module is configured to iteratively match the target vector in a pre-stored vector library to obtain a target matching vector, wherein the target matching vector corresponds to a target example. A prompt forming module is configured to combine the target text and the target example to form a target structured input prompt. An extraction analysis module is configured to perform extraction analysis on the target text by a generative knowledge object extraction model under the constraint of the target structured input prompt to obtain a target extraction result.

Citation Information

Patent Citations

  • Information extraction method and device based on large model and electronic equipment

    CN120353879A