Small sample named entity recognition enhancement method based on large language model and related device
By reconstructing the original dataset and designing precise prompt words, and combining entity span extraction model and prototype representation network model for iterative training, high-quality augmented data is generated, which solves the problems of low accuracy and poor robustness of named entity recognition in low-resource scenarios, and achieves named entity recognition with high recall and high accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XIDIAN UNIV
- Filing Date
- 2026-01-06
- Publication Date
- 2026-05-01
AI Technical Summary
Existing technologies suffer from low accuracy and poor robustness in named entity recognition under low-resource scenarios. Traditional data augmentation methods destroy semantics, and the rigidity of prototype networks makes them difficult to adapt to different domains.
By reconstructing the original dataset, sample datasets suitable for large language models are generated. Precise prompt words are designed, and the entity span extraction model and prototype representation network model are combined for iterative training to dynamically correct the prototype representation and generate high-quality augmented data.
Achieving high recall and high accuracy in named entity recognition under low-resource environments improves the model's generalization ability and robustness, and solves the semantic destruction and cross-domain adaptability problems of traditional methods.
Smart Images

Figure CN121960468A_ABST
Abstract
Description
A method and related apparatus for enhancing few-shot named entity recognition based on a large language model Technical Field
[0001] This invention belongs to the field of natural language processing technology, and relates to a method and related apparatus for enhancing small-sample named entity recognition based on a large language model. Background Technology
[0002] Named Entity Recognition (NER) is a fundamental core task in Natural Language Processing (NLP). Its goal is to automatically identify and classify predefined categories of entities, such as names of people, places, organizations, times, and dates, from unstructured text. As a key technology for downstream applications such as information extraction, knowledge graph construction, intelligent question answering, and machine translation, NER transforms raw text into structured information, serving as a crucial bridge between natural language and machine intelligence, and is essential for improving the intelligence level of the entire NLP ecosystem. Although existing NER technologies have achieved significant results in resource-rich general domains (such as news text), in practical industrial applications, most scenarios belong to specific domains (such as healthcare, finance, law, and vertical industries), characterized by a lack of large-scale, high-quality labeled data, i.e., facing the challenge of "low resources" or "small samples." To address this challenge, existing technologies mainly seek breakthroughs in two directions: text data augmentation and prototype network representation learning, but both directions have significant limitations.
[0003] First, in text data augmentation, traditional methods such as synonym replacement, random insertion, and back translation, while increasing data diversity to some extent, typically involve simple perturbations at the surface lexical level. These methods struggle to maintain deep semantic coherence and syntactic rationality, easily introducing noise and errors, resulting in low-quality augmented data and even negatively impacting model training. In recent years, the powerful generative capabilities of Large Language Models (LLMs) have provided new avenues for data augmentation. Existing methods have begun to utilize LLMs as data augmentation tools, generating new training samples through prompting. However, these methods often treat LLMs as simple text rewriters, focusing solely on enhancing surface diversity, such as increasing sentence structure diversity or vocabulary richness. This approach has a fundamental flaw: it fails to fully explore and utilize LLMs' ability to understand deep semantics, interlexitic dependencies, and contextual logic. Simply pursuing formal diversity while ignoring semantic fidelity and domain relevance leads to a deviation between the generated augmented data and the original data distribution, resulting in inaccurate features learned by the model.
[0004] Secondly, regarding model learning paradigms, few-shot learning methods based on prototype networks offer another important path to address the low-resource problem. The core idea is to learn a "prototype representation" (i.e., the center point of all instances of that class in the vector space) for each entity category. During prediction, the category is determined by calculating the similarity between the entity to be identified and the prototypes of each category. Prototype representation simplifies the classification decision-making process and improves efficiency by compressing complex categories into a single reference point. However, traditional prototype representation methods suffer from inherent rigidity. First, prototype representations struggle to adapt to the characteristics of different domains. A prototype of an "organization name" (ORG) learned on a general corpus (such as news) may have significantly different vector features than an "organization name" in the financial domain (such as a specific bank or fund). Traditional methods directly transfer prototypes learned on general data to specific domains, but due to the mismatch in domain distribution, their recognition performance drops drastically. Second, to build accurate prototypes for a specific domain, a sufficient amount of domain-labeled data is needed as a "support set" to recalculate the prototypes, which contradicts the reality of low resources. Furthermore, prototype theory struggles to handle atypical entities and situations with ambiguous category boundaries, and lacks the ability to adaptively adjust to specific contextual situations.
[0005] In summary, there is an urgent need in this field for a new technical solution that can synergistically optimize the data augmentation and model learning process. That is, while using LLM to generate high-quality, high-fidelity augmented data, a smart prototype correction mechanism that can dynamically adapt to domain characteristics should be designed to achieve high-performance named entity recognition in truly small sample environments. Summary of the Invention
[0006] The purpose of this invention is to provide a method and apparatus for enhancing named entity recognition based on a large language model in small samples, so as to solve the technical problems of low accuracy and poor robustness of named entity recognition in low-resource scenarios in the prior art.
[0007] To achieve the above objectives, the present invention employs the following technical solution: Firstly, the present invention provides a small-sample named entity recognition enhancement method based on a large language model, comprising the following steps: reconstructing the original dataset samples to generate example dataset samples suitable for large language model prompts; constructing prompt words based on the example dataset samples, and generating an enhanced dataset using the large language model based on the prompt words; constructing an entity span extraction model and a prototype representation network model; and iteratively training the entity span extraction model and the prototype representation network model in conjunction with the enhanced dataset to obtain an entity recognition model for predicting named entities.
[0008] Furthermore, the step of reconstructing the original dataset samples to generate example dataset samples suitable for large language model prompts specifically includes: setting a rewriting threshold θ for original dataset samples of different sizes; processing the original dataset samples according to the relationship between the size of the original dataset samples and the rewriting threshold θ; if the sample size is small, directly using the original dataset samples as example dataset samples; if the sample size is large, dividing the original dataset samples into multiple smaller datasets as example dataset samples.
[0009] Furthermore, the step of constructing system prompt words based on the example dataset samples and generating an augmented dataset using a large language model based on the prompt words specifically includes: designing prompt words, wherein the design content of the prompt words includes: defining the style of the dataset, defining the structure and field requirements of the data, providing example entries from the example dataset samples, and defining the range of data content; using the prompt words to drive the large language model to generate an initial augmented dataset; and validating the initial augmented dataset, including format checking, feature distribution checking, and class balance analysis, discarding unqualified samples, and merging qualified samples to obtain the augmented dataset.
[0010] Furthermore, the feature distribution check specifically includes: using the encoder part of the Bert deep learning model to obtain the average word embedding representation of the original dataset sample and the synthetic sample respectively, and then calculating the cosine similarity of the average word embedding representation of the original dataset sample and the synthetic sample. If the cosine similarity reaches or exceeds 95%, the synthetic sample is retained; otherwise, it is discarded.
[0011] Furthermore, the steps of constructing the entity span extraction model and the prototype representation network model, and iteratively training the entity span extraction model and the prototype representation network model using the augmented dataset to obtain the entity recognition model for predicting named entities, specifically include: setting up the training dataset and test data using the OntoNotes dataset W; initializing all parameters of the named entity recognition model; and using the OntoNotes dataset W... i Transform into the form of an embedded vector X i A cross-entropy L is used as the loss function to train an entity span extraction model; a general prototype representation network model is pre-trained on the OntoNotes dataset; and the OntoNotes dataset W is then used again. i Transform into the form of an embedded vector X i Design positive and negative comparison samples Comparative learning loss function The entity prototype vector V is obtained. entity The entity span extraction model and prototype representation network model were fine-tuned using the augmented dataset, and the entity prototype vector V was adjusted based on sentence features. entity V is obtained by performing dynamic prototype modification. prototype ; For V entity and V prototype Perform matrix multiplication and pass the model through a Softmax layer to obtain the classification probability. Design a loss function to train the model and iterate multiple times until the loss function of the entity recognition model converges to the preset range.
[0012] Furthermore, the entity prototype vector V based on sentence features... entity V is obtained by performing dynamic prototype modification. prototype The steps specifically include: obtaining sentence embeddings from the low-resource dataset through the Encoder part, training multiple rounds using the cross-entropy function as the loss function until the loss function exceeds a set threshold; and then processing the sentences V obtained from the augmented dataset. sen The average embedding representation of the last four layers is used to obtain the global feature through a feedforward neural network (FNN). G , make sentence V sen The embedding representation is passed through a multi-head attention layer and a feedforward neural network layer (FNN) to obtain local features.L The obtained global features G and Feature L The summation yields the overall feature representation. An MLP layer is used to obtain the prototype correction parameters w, and the entity prototype vector V is then processed. entity After correction, V is obtained. prototype .
[0013] Furthermore, the method also includes: using the trained entity recognition model to predict entities in different datasets, comparing the entity classification results with the labels, extracting the named entity recognition results of the prediction results and the labels respectively, and calculating precision and recall; calculating the F1 score based on precision and recall to test model performance; the formula for calculating the F1 score is:
[0014] In the formula, Precision represents precision and Recall represents recall.
[0015] Secondly, this invention provides a small-sample named entity recognition enhancement system based on a large language model, comprising: a dataset reconstruction module for reconstructing original dataset samples to generate example dataset samples suitable for large language model prompts; a prompt word construction module for constructing prompt words based on the example dataset samples and generating an enhanced dataset using the large language model based on the prompt words; a model training module for constructing an entity span extraction model and a prototype representation network model; and iteratively training the entity span extraction model and the prototype representation network model in conjunction with the enhanced dataset to obtain an entity recognition model for predicting named entities.
[0016] Thirdly, the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the small-sample named entity recognition enhancement method based on a large language model as described above.
[0017] Fourthly, the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the described method for enhancing few-sample named entity recognition based on a large language model.
[0018] Compared with existing technologies, this invention has the following advantages: This invention discloses a small-sample named entity recognition enhancement method and related apparatus based on a large language model. By specifically reconstructing the original dataset and designing precise prompt words, it can guide the large language model to generate high-quality enhanced data that maintains semantic authenticity and possesses stylistic diversity. This fundamentally solves the problems of semantic destruction, noise introduction, and lack of training samples in low-resource scenarios caused by traditional data augmentation methods, providing a rich and reliable learning foundation for the model. Secondly, by constructing an entity span extraction model and a prototype representation network model, and combining and iteratively training these two models, a mutually reinforcing optimization loop is formed: the entity span extraction model provides more accurate candidate entities for the prototype representation network, while the dynamically corrected prototype representation network provides more accurate classification feedback for the span extraction model, thereby continuously improving the overall model performance in the iteration. This invention effectively overcomes the rigidity of traditional prototype networks in cross-domain applications, achieving adaptive dynamic correction of prototype representation for specific domains. This allows the finally trained entity recognition model to maintain both high recall and high accuracy even in low-resource environments, significantly improving the model's generalization ability and robustness. Attached Figure Description
[0019] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 is a flowchart of the method of the present invention; Figure 2 is a schematic diagram of the system of the present invention; Figure 3 is a simulation experiment result diagram of an embodiment of the present invention. Detailed Implementation
[0021] The present invention will now be described in detail with reference to the accompanying drawings and embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other.
[0022] The following detailed description is exemplary and intended to provide further detailed explanation of the invention. Unless otherwise specified, all technical terms used in this invention have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. The terminology used in this invention is for the purpose of describing particular embodiments only and is not intended to limit the scope of exemplary embodiments according to the invention.
[0023] Referring to Figure 1, this embodiment of the invention discloses a small sample named entity recognition enhancement method based on a large language model, including the following steps: S1, reconstructing the original dataset samples to generate example dataset samples suitable for large language model prompts; S101, setting a rewriting threshold θ (default setting is 20 words) for original dataset samples of different sizes.
[0024] S102. Considering the context processing capabilities of generative large language models and the quality of the generated datasets, we adopt different approaches. In the case of low resources, the sample size is small and can be directly used as example dataset samples. In the case of high resources, the sample size is relatively rich, but it cannot be directly used as a training dataset. The complete original dataset can be divided into multiple smaller datasets and used as example dataset samples.
[0025] S2, construct prompt words based on the sample dataset, and generate an augmented dataset using a large language model based on the prompt words; S201, design prompt words, the design content of which includes: defining the style of the dataset, defining the structure and field requirements of the data, providing sample entries from the sample dataset, and defining the scope of the data content; for generative large language models, prompt words are a key part, and the design of specific prompt words should be related to the text background, recognition type, etc. of the dataset. The following are the principles that should be followed when designing prompts: S211, Dataset style: such as news topics, medical related, social media, etc., to ensure that the content generated by the model conforms to the expected subject and style; S212, Data structure and field requirements: The prompts should clearly indicate the specific structure of the dataset, such as the field names and formats included in the dataset; for example, in Named Entity Recognition (NER) tasks, the dataset is generally composed of tokens and labels, separated by spaces; S213, Provide example entries: To help the large model better understand, 1-2 example data can be provided, and the model will generate based on these examples; this refers to dataset examples; S214, Define the scope of data content: Since the named entity categories of the dataset are predefined, the dataset categories need to be aligned to ensure that they are within the defined scope. For example, in the CoNLL2003 dataset, the categories are PER, LOC, ORG, The four MISC categories are invalid and need to be discarded if they exceed this definition range; S202, the prompt words are used to drive the large language model to generate the initial augmented dataset; S203, the initial augmented dataset is tested, including format check, feature distribution check and category balance analysis, unqualified samples are discarded, and qualified samples are merged to obtain the augmented dataset samples.
[0026] Check the format of the generated dataset: Verify that the format of the generated dataset matches the required format. For example, in NER tasks, text-based datasets typically need to include two parts: token and label, usually separated by a space. Samples that do not meet the requirements should be discarded. Check the feature distribution of the generated dataset: Using the encoder part of the BERT deep learning model, obtain the average word embedding representations of the original dataset samples and the synthesized samples respectively. Then, perform cosine similarity processing on the word embeddings of the two datasets to obtain the cosine similarity result. If the similarity reaches 95% or higher, it means that semantically, the enhanced synthesized sample is similar to the real sample in the original dataset to a certain extent, and the sample can be used. Otherwise, discard the sample. Cosine similarity formula:
[0027] Class balance analysis of the generated dataset: Analyze the number of labels between different categories in the generated dataset. If a category is missing a certain number of labels, discard the sample. Continue until the required number of samples is obtained, then merge the above texts as augmented dataset samples. Mix the original dataset with the obtained augmented dataset samples to obtain merged samples, and use the merged samples as the training set. S3, Using the OntoNotes dataset, construct an entity span extraction model and a prototype representation network model. Iteratively train the entity span extraction model and the prototype representation network model using the augmented dataset to obtain an entity recognition model to predict named entities.
[0028] S301, set up the training and test datasets based on the OntoNotes dataset, a multi-training resource dataset for common scenarios; initialize all parameters of the named entity recognition model, including the input and output dimensions of the BERT Encoder layer (model_dim) and the MLP (Multi-Layer Perceptron) layer (mlpinput_dim, mlpoutput_dim), the output dimension of the prototype representation network (output_dim), the model's learning rate (learning_rate), and the number of heads for multi-head attention (attention_num).
[0029] S302 uses the Encoder part of BERT to transform the multi-training resource dataset OntoNotes in a common scenario, denoted as Wi, into the form of embedding vectors Xi. Using cross-entropy L as the loss function, a general entity span extraction model is trained.
[0030]
[0031] S303, a general prototype representation network model is pre-trained on the OntoNotes dataset, a multi-training resource dataset for general scenarios, to obtain a general prototype representation network model; then, the Encoder part of BERT is used to train the OntoNotes dataset W, a multi-training resource dataset for general scenarios. i Transform into the form of an embedded vector X i Design positive and negative comparison samples Comparative learning loss function This yields the entity prototype vector.
[0032]
[0033]
[0034] S304 will augment the dataset W i Transform into the form of an embedded vector X i The entity span extraction model obtained in S302 is fine-tuned using cross-entropy L as the loss function; the general prototype representation network model obtained in S303 is fine-tuned using an augmented dataset, that is, the augmented low-resource dataset is processed through the Encoder part to obtain sentence embedding representations. After multiple rounds of training, the cross-entropy function is used as the loss function until the loss function exceeds a set threshold to adapt to low-resource scenarios.
[0035]
[0036] S305, augment the sentence V obtained from the dataset sen The average embedding representation of the last four layers is used to obtain the global feature through a feedforward neural network (FNN). G , make sentence V sen The embedding representation is passed through a multi-head attention layer and a feedforward neural network layer (FNN) to obtain local features. L ;
[0037]
[0038] S306, the obtained global feature G and Feature L The summation yields the overall feature representation. An MLP layer is used to obtain the prototype correction parameters w, and the entity prototype vector V is then processed. entity The modified entity prototype representation vector V is obtained by making corrections.prototype ;w
[0039]
[0040] S307, using matrix multiplication on V entity and V prototype The model is trained by passing the model through a Softmax layer to obtain the classification probability and designing a loss function.
[0041]
[0042] S308, repeat S304~S307, train the prototype representation network until... Once the preset acceptable range is reached, the fully trained prototype representation network model is used to predict the similarity between the network model and the entity to be classified, thereby obtaining the classification probability and completing the entity classification part.
[0043] It should be noted that the OntoNotes dataset in this method is used to train a general entity span extraction model and a prototype representation network model; the augmented dataset obtained in S2 is used as a low-resource dataset to fine-tune the general entity span extraction model and the prototype representation network model.
[0044] S4, use the trained entity recognition model to predict entities on different datasets to test model performance; S401, compare the entity classification results with the labels, extract the predicted results and the named entity recognition results of the labels respectively, and calculate Precision and Recall; S402, test datasets in 1-shot and 5-shot scenarios respectively, using the F1 score of the datasets as the metric, and the relevant metric calculation formulas are as follows:
[0045] in: , TP represents True Positives, FP represents False Positives, and FN represents False Negatives. The higher the F1 score, the better the model's overall entity recognition performance.
[0046] The following simulation experiments further illustrate the present invention: The present invention was validated by training the model and using data augmentation methods to improve model performance on small sample datasets CoNLL2003, WNUT17, GUM, and I2B2 in different fields. The baseline model used employed 1-shot and 5-shot few-shot learning methods, and the classification ability of the model was evaluated using the common classification metric F1 score. At the same time, the original dataset was compared with the combined augmented dataset and prototype correction network, with the F1 score used as a performance metric for comparison.
[0047] The proposed augmentation method for text-based datasets based on Generative Large Language Models (LLM) and the simulation results of the baseline model on four datasets are shown in Figure 3. The original text metrics are derived from the original text data. As can be seen from Figure 3, the results of the augmented data and the merged samples, compared to the four different domain datasets used in the original text, demonstrate that the evaluation metrics of this invention achieve better performance on all datasets, showing varying degrees of improvement. Therefore, to a certain extent, it can be concluded that the method proposed in this invention performs better than the original datasets. The simulation results verify that the method of this invention can complete classification and inference tasks involving text-based datasets with good performance.
[0048] Referring to Figure 2, this embodiment of the invention discloses a few-sample named entity recognition enhancement system based on a large language model, including a dataset reconstruction module, a prompt word construction module, and a model training module. The dataset reconstruction module reconstructs the original dataset samples to generate example dataset samples suitable for prompts from the large language model. The prompt word construction module constructs prompt words based on the example dataset samples and uses the large language model to generate an enhanced dataset based on the prompt words. The model training module constructs an entity span extraction model and a prototype representation network model. Iterative training of the entity span extraction model and the prototype representation network model is performed using the enhanced dataset to obtain an entity recognition model for predicting named entities. This invention addresses the problems of scarce text datasets, class imbalance, and semantic corruption in existing text dataset enhancement methods, which affect model prediction performance in natural language processing tasks under low-resource conditions. It also proposes a domain-specific entity prototype correction to address the problem that domain-specific entity prototype representations cannot accurately represent specific domains. This method preprocesses the original dataset to obtain example dataset samples. Requirements are set for the style, structure, example dataset sample descriptions, and semantic aspects of the generated dataset, thus constructing the core prompt words for a Generative Language Model (LLM) to generate an augmented dataset. The augmented dataset is embedded and processed through a cross-attention layer network and a dynamic weight adjustment network to correct inaccurate entity prototypes. A baseline model is used to evaluate the quality of the augmented dataset and the prototype correction network, demonstrating the effectiveness of the merged sample augmentation and the prototype correction network. This technique uses a small amount of the original dataset as example samples, combined with carefully designed LLM prompt words for multiple rounds and batches of prompts. Multiple filtering principles are employed to obtain a large number of text-based datasets with high relevance and diversity to the original text-based dataset, thereby increasing the features learned by the model. Simultaneously, an entity prototype correction network is proposed to dynamically adjust the contribution of entities in the support set, thereby improving the model's recognition accuracy. Finally, the merged samples of the original and augmented datasets are used as training sets, and the prototype correction network and classification model are used to obtain the F1 score for the named entity recognition task as a performance indicator.
[0049] In one embodiment of the present invention, a computer device is provided, comprising a processor and a memory. The memory stores a computer program, which includes program instructions. The processor executes the program instructions stored in the computer storage medium. The processor may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. It is the computing and control core of the terminal, suitable for implementing one or more instructions, specifically suitable for loading and executing one or more instructions from the computer storage medium to achieve a corresponding method flow or corresponding function. The processor described in this embodiment of the present invention can be used for the operation of a small-sample named entity recognition enhancement method based on a large language model.
[0050] This invention also provides a storage medium, specifically a computer-readable storage medium (Memory), which is a memory device in a computer device used to store programs and data. It is understood that the computer-readable storage medium here can include both the built-in storage medium in the computer device and extended storage media supported by the computer device. The computer-readable storage medium provides storage space that stores the terminal's operating system. Furthermore, this storage space also stores one or more instructions suitable for loading and execution by a processor. These instructions can be one or more computer programs (including program code). It should be noted that the computer-readable storage medium here can be high-speed RAM or non-volatile memory, such as at least one disk storage device. The processor can load and execute one or more instructions stored in the computer-readable storage medium to implement the corresponding steps of the small-sample named entity recognition enhancement method based on a large language model in the above embodiments.
[0051] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0052] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in one or more blocks of the flowchart illustrations and / or one or more blocks of the block diagrams.
[0053] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means that implement the functions specified in one or more flowcharts and / or one or more block diagrams.
[0054] These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, such that the instructions, which execute on the computer or other programmable apparatus, provide steps for implementing the functions specified in one or more flowcharts and / or one or more block diagrams.
[0055] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the specific implementation of the present invention. Any modifications or equivalent substitutions that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A few-sample named entity recognition enhancement method based on a large language model, characterized in that, Includes the following steps: The original dataset samples are reconstructed to generate example dataset samples suitable for large language model prompts; Based on the sample dataset, prompt words are constructed, and an augmented dataset is generated using a large language model based on the prompt words; an entity span extraction model and a prototype representation network model are constructed; the entity span extraction model and the prototype representation network model are iteratively trained in combination with the augmented dataset to obtain an entity recognition model for predicting named entities.
2. The method for enhancing few-sample named entity recognition based on a large language model according to claim 1, characterized in that, The step of reconstructing the original dataset samples to generate example dataset samples suitable for large language model prompts specifically includes: setting a rewriting threshold θ for original dataset samples of different sizes; processing the original dataset samples according to the relationship between the size of the original dataset samples and the rewriting threshold θ; if the sample size is small, directly using the original dataset samples as example dataset samples; if the sample size is large, dividing the original dataset samples into multiple smaller datasets as example dataset samples.
3. The method for enhancing few-sample named entity recognition based on a large language model according to claim 1, characterized in that, The steps of constructing system prompt words based on the example dataset samples and generating an augmented dataset using a large language model based on the prompt words specifically include: designing prompt words, wherein the design content of the prompt words includes: defining the style of the dataset, defining the structure and field requirements of the data, providing example entries from the example dataset samples, and defining the range of data content; using the prompt words to drive the large language model to generate an initial augmented dataset; and validating the initial augmented dataset, including format checking, feature distribution checking, and class balance analysis, discarding unqualified samples, and merging qualified samples to obtain the augmented dataset.
4. The method for enhancing few-sample named entity recognition based on a large language model according to claim 3, characterized in that, The feature distribution check specifically includes: using the encoder part of the Bert deep learning model to obtain the average word embedding representation of the original dataset sample and the synthetic sample respectively, and then calculating the cosine similarity of the average word embedding representation of the original dataset sample and the synthetic sample. If the cosine similarity reaches or exceeds 95%, the synthetic sample is retained; otherwise, it is discarded.
5. The method for enhancing few-sample named entity recognition based on a large language model according to claim 1, characterized in that, The steps of constructing an entity span extraction model and a prototype representation network model, and iteratively training the entity span extraction model and the prototype representation network model using the augmented dataset to obtain an entity recognition model for predicting named entities, specifically include: setting up the training dataset and test data using the OntoNotes dataset W; initializing all parameters of the named entity recognition model; and setting the OntoNotes dataset W... i Transform into the form of an embedded vector X i A cross-entropy L is used as the loss function to train an entity span extraction model; a general prototype representation network model is pre-trained on the OntoNotes dataset; and the OntoNotes dataset W is then used again. i Transform into the form of an embedded vector X i Design positive and negative comparison samples Comparative learning loss function The entity prototype vector V is obtained. entity The entity span extraction model and prototype representation network model were fine-tuned using the augmented dataset, and the entity prototype vector V was adjusted based on sentence features. entity V is obtained by performing dynamic prototype modification. prototype ; For V entity and V prototype Perform matrix multiplication and pass the model through a Softmax layer to obtain the classification probability. Design a loss function to train the model and iterate multiple times until the loss function of the entity recognition model converges to the preset range.
6. The method for enhancing few-sample named entity recognition based on a large language model according to claim 1, characterized in that, The entity prototype vector V based on sentence features entity V is obtained by performing dynamic prototype modification. prototype The steps specifically include: obtaining sentence embeddings from the low-resource dataset through the Encoder part, training multiple rounds using the cross-entropy function as the loss function until the loss function exceeds a set threshold; and then processing the sentences V obtained from the augmented dataset. sen The average embedding representation of the last four layers is used to obtain the global feature through a feedforward neural network (FNN). G , make sentence V sen The embedding representation is passed through a multi-head attention layer and a feedforward neural network layer (FNN) to obtain local features. L The obtained global features G and Feature L The summation yields the overall feature representation. An MLP layer is used to obtain the prototype correction parameters w, and the entity prototype vector V is then processed. entity After correction, V is obtained. prototype .
7. The method for enhancing few-sample named entity recognition based on a large language model according to claim 1, characterized in that, Also includes: The trained entity recognition model is used to predict entities in different datasets. The entity classification results are compared with the labels, and the named entity recognition results of the prediction results and labels are extracted separately. Precision and recall are calculated. Based on precision and recall, an F1 score is calculated to test the model performance. The formula for calculating the F1 score is as follows: In the formula, Precision represents precision and Recall represents recall.
8. A few-sample named entity recognition enhancement system based on a large language model, characterized in that, include: The dataset reconstruction module is used to reconstruct the original dataset samples and generate example dataset samples suitable for large language model prompts. The prompt word construction module is used to construct prompt words based on the sample dataset, and generate an enhanced dataset using a large language model based on the prompt words; The model training module is used to construct an entity span extraction model and a prototype representation network model; the entity span extraction model and the prototype representation network model are iteratively trained using the augmented dataset to obtain an entity recognition model for predicting named entities.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the small-sample named entity recognition enhancement method based on a large language model as described in any one of claims 1-7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the small-sample named entity recognition enhancement method based on a large language model as described in any one of claims 1-7.