A named entity recognition model and method for qin dynasty bamboo slips
By collaboratively training the Qin bamboo slips basic semantic encoder and the retrieval enhancement fusion network, and using an external index database for non-parametric retrieval completion, the problems of difficulty in recognizing rare long-tail entities and insufficient robustness of damaged texts in Qin bamboo slips texts are solved, achieving high accuracy and robustness of named entity recognition.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JISHOU UNIVERSITY
- Filing Date
- 2026-05-15
- Publication Date
- 2026-07-07
AI Technical Summary
Existing technologies for named entity recognition models of Qin bamboo slips face challenges in scenarios with low-resource historical corpora, including difficulties in recognizing rare long-tailed entities, insufficient robustness to damaged texts, and limited generalization ability of parameterized models.
Using a Qin bamboo slips-based semantic encoder, an external index database, and a retrieval enhancement fusion network, the final entity label sequence is generated through collaborative training of parametric and non-parametric branches, non-parametric retrieval completion using the external index database, and weighted fusion using a confidence gating network.
It significantly improves the accuracy and robustness of named entity recognition in Qin bamboo slips, solves the difficulties in recognizing rare long-tail entities in low-resource historical corpora and the lack of context in damaged texts, and achieves deep synergy between parametric knowledge and non-parametric memory.
Smart Images

Figure CN122347136A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of ancient script text processing, specifically to a named entity recognition model and method for Qin Dynasty bamboo slips. Background Technology
[0002] Named Entity Recognition (NER) is a fundamental and core task in Natural Language Processing (NLP). It aims to extract entity information from input natural language text, refining the relevant information and avoiding complexities in information comprehension. Early NER methods primarily relied on manually constructed rule templates or statistical machine learning models, such as Hidden Markov Models (HMMs) and Conditional Random Fields (CRFs). However, these methods heavily depend on manual feature engineering and have limited generalization capabilities.
[0003] With the development of deep learning technology, sequence labeling methods based on deep neural networks have gradually become mainstream. Their basic principle is to automatically extract high-dimensional feature representations of text using neural networks and establish a complex nonlinear mapping relationship between input characters and entity labels through iterative training on massive amounts of data. Currently, named entity recognition tasks mainly employ parameterized models based on deep learning, such as the BERT-CRF architecture. These methods continuously adjust the internal weight matrix during the training phase using the backpropagation algorithm, attempting to internalize and store all linguistic rules, entity boundary features, and contextual dependencies within these fixed model parameters.
[0004] However, in the specific application of Qin bamboo slips, the above-mentioned parameterization mechanism faces some irreconcilable problems. For example, Qin bamboo slips are typical low-resource historical corpora and contain a large number of obscure proper nouns with long tails. For these long-tail entities that only appear once or twice in the training set, the model cannot learn effective vector representations through limited gradient update steps, resulting in the model only being able to memorize high-frequency words and having poor generalization decoding ability for low-frequency entities. In addition, unearthed Qin bamboo slips generally have physical damage such as breaks, stains, and blurred ink, resulting in the loss of contextual information and excessive noise. The existing parameterization model is a closed computational system, and its inference relies entirely on the fitting of internal parameters to the local context. When the input context is destroyed by noise, the model lacks the external knowledge retrieval ability similar to human experts and cannot use existing external historical knowledge or similar feature distributions for explicit inference and feature completion, thus leading to a significant drop in recognition accuracy. Summary of the Invention
[0005] The purpose of this invention is to provide a named entity recognition model and method for Qin bamboo slips text, so as to solve the technical problems of existing technologies in low-resource historical corpus scenarios, such as difficulty in recognizing rare long-tail entities, insufficient robustness of damaged text, and limited generalization ability of parameterized models.
[0006] Accordingly, this invention discloses a named entity recognition model for Qin bamboo slip text, comprising:
[0007] The Qin bamboo slips basic semantic encoder is used to encode the input Qin bamboo slips text and extract semantic vectors;
[0008] An external index database is used to store key-value pairs, wherein the key-value pairs use the hidden state vector of the character as the key and the corresponding real entity label as the value;
[0009] The retrieval enhancement fusion network includes a parametric branch, a non-parametric branch, a confidence-gated network, and a weighted fusion module. The parametric branch is used to generate a parametric prediction probability distribution based on the semantic vector. The non-parametric branch is used to retrieve nearest neighbor samples from the external index database based on the semantic vector and generate a non-parametric retrieval probability distribution. The confidence-gated network is used to generate fusion weights based on the confidence features of the parametric prediction probability distribution and the semantic vector. The weighted fusion module is used to perform weighted fusion of the parametric prediction probability distribution and the non-parametric retrieval probability distribution based on the fusion weights to generate a fusion probability distribution.
[0010] A structured sequence decoder is used to perform sequence decoding on the fused probability distribution and output the entity label sequence of the Qin bamboo text.
[0011] In an optional implementation, the parameterized branch includes a third linear classification layer.
[0012] In an optional implementation, the non-parametric branch includes a FAISS searcher, a softmax kernel layer, and a distance-weighted layer connected in sequence.
[0013] In an optional implementation, the gated network module includes a feature splicing layer, a linear transformation layer, and a Sigmoid activation layer connected in sequence.
[0014] In an optional implementation, the named entity recognition model is generated based on a training process, which includes:
[0015] Construct a Qin Dynasty bamboo slips text named entity recognition dataset, which includes model input samples, including input character sequences, attention masks, and entity label sequences;
[0016] A baseline model is trained based on the input samples of the model to obtain the optimal parameter baseline model. The baseline model includes a first BERT encoding layer, a first linear classification layer and a first conditional random field decoding layer connected in sequence.
[0017] Freeze the baseline model with the optimal parameters, extract the hidden state vector of each character in the input sample of the model through the first BERT encoding layer as the key, use the real entity label corresponding to the character as the value, construct the K nearest neighbor index structure using the FAISS library, and establish an external index database;
[0018] A fusion model is trained based on the input samples of the aforementioned model. The fusion model includes a second BERT encoder, a parametric branch, a non-parametric branch, a confidence gating network, and a weighted fusion module. For each input character, the fusion network performs parametric prediction and non-parametric retrieval in parallel.
[0019] The parametric prediction generates a parametric prediction probability distribution through the linear classification layer, and the non-parametric retrieval uses the current character semantic vector as the query vector to retrieve the nearest neighbor in the external index database and generate a non-parametric retrieval probability distribution.
[0020] The adaptive fusion weights are generated through a confidence-gated network, and the two probability distributions are weighted and fused to obtain a fused probability distribution; the fused probability distribution is then input into a conditional random field layer for decoding and outputting an entity label sequence.
[0021] The training of the fusion model is optimized end-to-end using a joint loss function, which includes sequence labeling loss and distribution alignment regularization term, until the fusion model converges. The fusion model after training is the named entity recognition model.
[0022] In an optional implementation, in the model input sample, damaged and blurred characters are marked with a uniform placeholder, and positions with missing characters and uncertain number of missing characters are placed with an ellipsis.
[0023] In an optional implementation, the entity types in the named entity recognition model include personal names, place names, organization names, official titles, legal proper nouns, time periods, and book titles.
[0024] An optional implementation, based on the BIO tagging system, includes the following entity tags in the named entity recognition model:
[0025] B-PER and I-PER represent the first and middle characters of a person's name, respectively;
[0026] B-LOC and I-LOC represent the starting and middle characters of a place name, respectively;
[0027] B-ORG and I-ORG represent the first and middle characters of the organization name, respectively;
[0028] B-JOB and I-JOB represent the starting and middle characters of an official title, respectively;
[0029] B-LAW and I-LAW represent the start character and middle character of a legal proper name, respectively;
[0030] B-TIME and I-TIME represent the start and middle characters of the time sequence, respectively.
[0031] B-BOO and I-BOO represent the start and middle characters of the book title, respectively;
[0032] O represents a non-physical character.
[0033] Accordingly, this invention discloses a named entity recognition method for Qin bamboo slip texts, implemented based on the aforementioned named entity recognition model for Qin bamboo slip texts, including:
[0034] The Qin bamboo slips basic semantic encoder is used to encode the input Qin bamboo slips text and extract semantic vectors;
[0035] A retrieval enhancement fusion network is used to adaptively fuse the parameterized prediction probability distribution and the non-parametric retrieval probability distribution to generate a fused probability distribution. The parameterized prediction probability distribution is generated by the parameterized branch based on the semantic vector, and the non-parametric retrieval probability distribution is generated by the non-parametric branch after retrieving nearest neighbor samples from the external index database based on the semantic vector.
[0036] The fusion probability distribution is sequence decoded using a structured sequence decoder to output the final entity label sequence;
[0037] The adaptive fusion includes:
[0038] The confidence-gated network module calculates the fusion weights based on the confidence features of the parameterized prediction probability distribution and the semantic vector;
[0039] The weighted fusion module weights and fuses the parametric prediction probability distribution and the non-parametric retrieval probability distribution according to the fusion weight to obtain the fused probability distribution.
[0040] In summary, this invention discloses a named entity recognition model and method for Qin Dynasty bamboo slips. It constructs a two-stage training framework that combines parametric and non-parametric methods. A basic semantic encoder extracts contextual semantic features from the Qin Dynasty bamboo slips, and an external key-value index database is built using a static feature extractor to form explicit memory. A confidence-gated network in the retrieval enhancement fusion network dynamically adjusts the fusion weights of the parametric prediction distribution and the non-parametric retrieval distribution. Finally, a structured sequence decoder outputs the globally optimal entity label sequence. This framework enables the model to rely on parametric semantic understanding at high confidence levels and utilize external retrieval for completion at low confidence levels. It effectively solves the difficulties in recognizing rare long-tail entities in low-resource historical corpora and the semantic breaks caused by missing context in fragmented texts. It achieves deep synergy between parametric knowledge and non-parametric memory, significantly improving entity recognition accuracy and robustness. Attached Figure Description
[0041] Figure 1 This is a flowchart of a named entity recognition method for Qin Dynasty bamboo slips according to an embodiment of the present invention.
[0042] Figure 2 This is a schematic diagram of the named entity recognition model structure for Qin Dynasty simplified text according to an embodiment of the present invention.
[0043] Figure 3 This is a schematic diagram of the baseline model structure of an embodiment of the present invention.
[0044] Figure 4 This is a schematic diagram of the fusion model structure according to an embodiment of the present invention. Detailed Implementation
[0045] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0046] Figure 1 This is a flowchart of a named entity recognition method for Qin Dynasty bamboo slips according to an embodiment of the present invention.
[0047] This invention discloses a named entity recognition method for Qin Dynasty bamboo slips text, comprising the following steps:
[0048] S10: Encode the input Qin bamboo slip text using the Qin bamboo slip basic semantic encoder and extract semantic vectors;
[0049] S20: Adaptively fuse the parametric prediction probability distribution and the non-parametric retrieval probability distribution using a retrieval enhancement fusion network to generate a fused probability distribution;
[0050] Wherein, the parameterized prediction probability distribution is generated by the parameterized branch based on the semantic vector, and the non-parameterized retrieval probability distribution is generated by the non-parameterized branch after retrieving nearest neighbor samples from the external index database based on the semantic vector; the adaptive fusion includes:
[0051] The confidence-gated network module calculates the fusion weights based on the confidence features of the parameterized prediction probability distribution and the semantic vector;
[0052] The weighted fusion module weights and fuses the parametric prediction probability distribution and the non-parametric retrieval probability distribution according to the fusion weight to obtain the fused probability distribution.
[0053] S30: Use a structured sequence decoder to perform sequence decoding on the fusion probability distribution and output the final entity label sequence.
[0054] Specifically, the named entity recognition method for Qin bamboo slips in this embodiment of the invention relies on the actual structure and parameters of three core components: a basic semantic encoder, a retrieval enhancement fusion network, and a structured sequence decoder. The basic structural forms of the basic semantic encoder and the structured sequence decoder are similar to those in existing technologies. The retrieval enhancement fusion network includes a parametric branch, a non-parametric branch, a confidence gating network, and a weighted fusion module. The parametric branch generates a parametric prediction probability distribution based on the semantic vector. The non-parametric branch retrieves nearest neighbor samples from the external index database based on the semantic vector and generates a non-parametric retrieval probability distribution. The confidence gating network generates fusion weights based on the confidence features of the parametric prediction probability distribution and the semantic vector. The weighted fusion module performs weighted fusion of the parametric prediction probability distribution and the non-parametric retrieval probability distribution based on the fusion weights to generate a fusion probability distribution. Specifically, these three core components, based on their corresponding structures, need to be trained to achieve the named entity recognition function for Qin bamboo slips.
[0055] Figure 2 This is a schematic diagram of the named entity recognition model structure for Qin Dynasty simplified text according to an embodiment of the present invention.
[0056] Correspondingly, this invention also discloses a named entity recognition model for Qin bamboo slip text, including:
[0057] The Qin bamboo slips basic semantic encoder is used to encode the input Qin bamboo slips text and extract semantic vectors;
[0058] An external index database is used to store key-value pairs, wherein the key-value pairs use the hidden state vector of the character as the key and the corresponding real entity label as the value;
[0059] The retrieval enhancement fusion network includes a parametric branch, a non-parametric branch, a confidence-gated network, and a weighted fusion module. The parametric branch is used to generate a parametric prediction probability distribution based on the semantic vector. The non-parametric branch is used to retrieve nearest neighbor samples from the external index database based on the semantic vector and generate a non-parametric retrieval probability distribution. The confidence-gated network is used to generate fusion weights based on the confidence features of the parametric prediction probability distribution and the semantic vector. The weighted fusion module is used to perform weighted fusion of the parametric prediction probability distribution and the non-parametric retrieval probability distribution based on the fusion weights to generate a fusion probability distribution.
[0060] A structured sequence decoder is used to perform sequence decoding on the fused probability distribution and output the entity label sequence of the Qin bamboo text.
[0061] The following describes the naming entity recognition model generation process according to an embodiment of the present invention.
[0062] Specifically, the generation process of the named entity recognition model includes:
[0063] S101: Construct a Qin Dynasty bamboo slips text named entity recognition dataset.
[0064] Specifically, the Qin bamboo slips text named entity recognition dataset includes multiple model input samples (data). Specifically, it collects original Qin bamboo slips text, cleans and standardizes the original Qin bamboo slips text, performs manual entity annotation, and performs serialization processing through a word segmenter to generate model input samples containing input character sequences, attention masks, and entity label sequences.
[0065] The purpose of this step is to collect Qin bamboo slip text data and construct a dataset that meets the requirements for subsequent model training, model function verification, and model performance evaluation.
[0066] Specifically, the original Qin bamboo slip text data in the original Qin bamboo slip text dataset refers to the Qin bamboo slip text data at the time of collection (which can be image transfer materials of bamboo slips and wooden tablets), and is not limited to the restored complete corpus data. Optionally, the sources of the Qin bamboo slip text include, but are not limited to, professional corpus materials from the same or similar periods, such as the Shuihudi Qin bamboo slips, Liye Qin bamboo slips, and Yuelu Qin bamboo slips.
[0067] After the original Qin bamboo slips text data is collected, it needs to be cleaned and standardized.
[0068] Specifically, the cleaning and standardization process includes the following steps:
[0069] For damaged or ambiguous characters, a uniform placeholder is used for marking. The uniform placeholder can be "?".
[0070] For positions where the number of missing characters is uncertain, use ellipses “…” to replace them, while retaining the incomplete position information;
[0071] Delete low-quality sentences that are too damaged (the proportion of effective characters in the sentence, i.e., the proportion of non-damaged characters, needs to exceed the proportion threshold) and have too little effective information (the total number of characters in the sentence needs to exceed the word count threshold);
[0072] Preserve the original special punctuation marks in the text;
[0073] Sentence length can be extended using placeholders (such as [pad]) to ensure consistency in length between different sentences.
[0074] After cleaning, the original Qin bamboo slip text dataset will yield multiple Qin bamboo slip text samples with uniform format and specifications. A single Qin bamboo slip text sample can be represented as... , This indicates the first [item] in the Qin bamboo slip text sample. One character, .
[0075] Then, named entity annotation is performed on the Qin bamboo slip text samples. Named entity annotation can adopt an entity category tagging system based on the BIO annotation system. The entity categories include seven types: personal names, place names, organization names, official titles, legal proper names, time periods, and book titles. Each entity category has two types of tags: B tags and I tags. Specifically, in this embodiment of the invention, the BIO tagging system corresponding to the seven entity types includes:
[0076] B-PER and I-PER represent the first and middle characters of a person's name, respectively;
[0077] B-LOC and I-LOC represent the starting and middle characters of a place name, respectively;
[0078] B-ORG and I-ORG represent the first and middle characters of the organization name, respectively;
[0079] B-JOB and I-JOB represent the starting and middle characters of an official title, respectively.
[0080] B-LAW and I-LAW represent the first and middle characters of a legal proper name, respectively;
[0081] B-TIME and I-TIME represent the start and middle characters of the time, respectively;
[0082] B-BOO and I-BOO represent the starting and middle characters of the book title, respectively;
[0083] O represents a non-physical character.
[0084] Finally, the annotated text is serialized (vectorized) using a word segmenter, and the text is vectorized in the same reference vector environment.
[0085] Based on the above processing, a sequence containing feature data such as input_ids, input_mask, segment_ids, and label_ids is finally obtained, which serves as the input sample for the serialization model.
[0086] Specifically, if the Qin bamboo slip text sample (excerpt) reads "On the first day of the second month of the twenty-seventh year, Bingzi, Gengyin, the Dongting Shouli said to the county magistrate", it comes from Liye Qin bamboo slip J1(16)5.
[0087] In the entity Qin bamboo slip text of this example text, assuming that the example text is damaged, after cleaning and standardizing the example text, it becomes "Twenty-seventh year, second year, Bingzi day, Gengyin day, Dongting Shouli said county clerk? [pad][pad][pad]...".
[0088] The question mark indicates that the character at that position is damaged or blurry. If the damage is too great (the damage ratio exceeds 50% of the sentence length) or the sentence length is less than 10 characters, it will be deleted directly.
[0089] Then, the cleaned text was manually annotated using the BIO annotation system. Examples of annotations for the sample text are shown in Table 1.
[0090] character Label illustrate twenty B-TIME 27th year of Qin Shi Huang seven I-TIME years Year I-TIME years two I-TIME month ? I-TIME month C I-TIME The first day of the lunar month (lunar calendar) son I-TIME The first day of the lunar month (lunar calendar) Shuo I-TIME New Moon Marker Geng I-TIME Stem and branch of the day Yin I-TIME Stem and branch of the day , O punctuation Hole B-JOB Dongting Prefect (an official title, also known as the abbreviated form of Dongting Commandery Prefect) court I-JOB Official titles Guard I-JOB Official titles present B-PER Prefect's private name It is called O verb county B-JOB County official (county-level supervisor) stingy I-JOB official position ? I-JOB official position
[0091] Table 1
[0092] It should be noted that, due to the use of manual entity annotation, for text with few defects, population annotation (expert repair) can repair the missing content with relatively high quality and provide entity annotation types. However, in the input and output of text data, the missing characters are still treated as unknown characters in order to establish a fuzzy correspondence between fuzzy missing text and annotation types in the subsequent training process.
[0093] Then, a word segmenter (such as BERT's WordPiece segmenter) is used to serialize and vectorize the annotated text, converting the text into a vector space.
[0094] Ultimately, the following feature data were obtained:
[0095] Character ID sequence input_ids: The integer ID corresponding to each character in the vocabulary. For example, assuming the ID of "廿" in the vocabulary is 2458 and the ID of "七" is 674, the input_ids sequence of this sentence is [2458, 674, 2400, 754, ……]. The role of this character ID sequence is to translate text data. According to a predefined vocabulary file (such as the bert-base-chinese vocabulary, with a total of 21,128 tokens in the standard version), it enables the computer to define the meaning of characters and establish the relationship between characters according to unified rules;
[0096] Attention mask sequence input_mask: Used to distinguish real characters from padding characters. Real positions are marked as 1 and padding positions are marked as 0. For example, [1, 1, 1, 1, …, 1, 0, 0, …]. In practical applications, it is used to remind the model to only process real characters, reducing additional computing power consumption; In the embodiments of the present invention, [pad] is a placeholder, and the attention mask sequence follows the serialized model input sample and is input into the model. The model processes real characters based on the valid character sequence and ignores the content of the placeholder. It should be noted that the design of the attention mask sequence belongs to the prior art and can be implemented based on the prior art. The embodiments of the present invention will not be described separately, and in the subsequent description, only the content related to real characters will be further described.
[0097] Sentence fragment marker sequence segment_ids: All are 0 in the case of a single sentence. For example, [0, 0, 0, 0, …, 0]; If there are two sentences, the marker for the second sentence is 1, which is used to remind the model of the context information truncation boundary of characters and avoid obtaining context information across fragments;
[0098] Entity label sequence label_ids: Represents the entity label ID corresponding to each character , for example, B-PER = 1, I-PER = 2, B-LOC = 3, I-LOC = 4, B-ORG = 5, I-ORG = 6, B-JOB = 7, I-JOB = 8, B-LAW = 9, I-LAW = 10, B-TIME = 11, I-TIME = 12, B-BOO = 13, I-BOO = 14, O = 0. Then the entity label sequence label_ids corresponding to "廿七年二?丙子朔庚寅,洞庭守礼谓县啬?" is [11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 0, 7, 8, 8, 1, 0, 7, 8, 8].
[0099] Specifically, for a single Qin bamboo slip text, there are multiple corresponding sequence data; for multiple Qin bamboo slip texts or even the entire Qin bamboo slip text database, a large matrix is formed based on the scale of the sequence data; in the subsequent application and processing of the model, most models will also involve batch processing in actual use, that is, reading multiple Qin bamboo slip texts simultaneously to form a matrix for processing. In the following description, the embodiments of the present invention mainly use a single Qin bamboo slip text as an example for illustration. In actual applications, the matrix form can be adjusted according to the requirements, and the embodiments of the present invention do not impose additional limitations.
[0100] S102: Perform the first stage of parameter fine-tuning training on the baseline model using the input samples of the model.
[0101] Figure 3 This is a schematic diagram of the baseline model structure in an embodiment of the present invention. The training model used in step S102 is the baseline model, which includes a first BERT encoder, a first linear classification layer, and a first conditional random field (CRF) decoding layer connected in sequence. The basic architecture of the entire baseline model belongs to the prior art. The main purpose of this step is to enable the BERT encoder to learn the linguistic rules and entity boundary features of the Qin bamboo slips text, and form an implicit knowledge representation adapted to the Qin bamboo slips context.
[0102] Specifically, the first BERT encoder, acting as a feature extractor, transforms the input character sequence into a context-sensitive semantic representation. This includes a first embedding layer and multiple layers of the first Transformer encoder (12 layers in this embodiment). The first embedding layer converts input_ids into a summation of word embeddings, position embeddings, and fragment embeddings (corresponding to character ID sequences, attention mask sequences, and sentence fragment tag sequences, respectively). After processing by the 12 layers of the first Transformer encoder, the final output is a 768-dimensional vector corresponding to each character. It should be noted that the role of the embedding layer can be understood as processing the original character ID sequence input_ids using attention mask sequences and sentence fragment tag sequences, ensuring that the model can extract the effective information within it.
[0103] Specifically, the first linear classification layer is used to map the semantic vector encoded by BERT to the entity label space and generate a preliminary category discrimination signal. It includes a first linear transformation layer and a first Softmax normalization layer to generate the log odds of each category label.
[0104] Specifically, the first CRF decoding layer is used to model the transition dependencies between tags, eliminate local prediction conflicts through global optimal decoding, and output a valid BIO tag sequence.
[0105] Specifically, in this step, the serialized model input samples are divided into a training set, a validation set, and a test set according to a set ratio. The training set is used for the training phase, the validation set is used to verify the real-time training effect of the model during the training phase, and the test set is used to verify the quality of the trained model.
[0106] During the training process, the training set samples are input into the first BERT encoder batch by batch. The character-level context semantic representation is extracted through a multi-layer Transformer structure, and then mapped to the label space through a linear classification layer. The preliminary prediction probability is obtained through Softmax normalization. The preliminary prediction probability and the true label sequence are input into the conditional random field layer, and the difference between the true label path score and the normalized scores of all possible paths is calculated to obtain the negative log-likelihood loss; the AdamW optimizer is used in combination with a linear warm-up and learning rate decay strategy for parameter update. The learning rate is gradually increased linearly from zero to the base learning rate at the beginning of training, and then linearly decayed; after each training epoch, the F1 value is evaluated on the validation set. When it is detected that the F1 value of the current epoch exceeds the historical best value, the current parameters of the baseline model are saved; after the training is completed, the finally saved baseline model parameters are used as the optimal parameters of the baseline model adapted to the context of Qin bamboo slips.
[0107] In a specific implementation, the serialized model input samples are divided into a training set, a validation set, and a test set according to a ratio of 8:1:1.
[0108] The training set samples are input into the baseline model batch by batch (the batch size is set to 16). It should be noted that in order to improve the training speed, the initial model of the baseline model is the BERT-CRF benchmark model. The basic entity naming logic (parameters) has been initially learned in the BERT-CRF benchmark model. The main function of this step is to adjust to obtain a BERT encoder adapted to the Qin bamboo slip text and the corresponding linear classification layer.
[0109] Taking the character "廿" in "廿七年" as an example, its processing process in the baseline model includes:
[0110] S201: BERT encoding.
[0111] The character "廿" passes through the 12-layer Transformer encoder of the first BERT encoder and outputs its context semantic vector at the last layer (assuming the baseline model uses the BERT-base structure, that is, the general BERT-CRF model, and the corresponding defined hidden dimension ), this vector encodes the semantic information of the character "廿" in the current context "廿七年".
[0112] S202: Linear classification.
[0113] The Input the linear classification layer and calculate the logits for each category
[0114] ;
[0115] Among them, the weight matrix of the first linear classification layer (15 is the total number of BIO tags, that is, 14 BIO tags corresponding to 7 types of entities and 1 O tag), and the bias vector of the first linear classification layer .
[0116] S203: Softmax normalization.
[0117] Assume that in the calculation result the score corresponding to the B-LOC tag is the highest, and parameterize the predicted probability distribution of the B-TIME , that is, the probability that the model predicts "廿" as B-TIME is 85%. Among them, exp(⋅) is the exponential function, z is the logit output by the first linear classification layer, is the discrete set of entity labels, is the temporary variable when traversing the discrete set of entity labels, .
[0118] Correspondingly, the parameterized predicted probability distributions of multiple characters and multiple labels for each character form an emission probability matrix and are input into the first CRF decoding layer.
[0119] S204: CRF sequence decoding.
[0120] Input the parameterized predicted probabilities of all characters in the whole sentence into the first CRF layer. The label transition matrix of the first CRF decoding layer constrains the legal transition relationships between labels. For example, (the score of I-LOC following B-LOC is higher), while (B-PER cannot directly follow B-LOC, and the score is extremely low). Calculate the difference between the score of the true label path [[ID= From zero linearly increasing to :
[0124] , ;
[0125] After the warm-up period ends, the real-time learning rate Linear decay:
[0126] , .
[0127] S206: Early Stop and Model Saving.
[0128] After each training epoch, the F1 score is calculated on the validation set. The F1 score is the harmonic mean of precision and recall, where precision is the accuracy and recall is the recall.
[0129]
[0130] When the F1 score of the current round exceeds the historical best, the parameters and segmenter configuration of the current baseline model are saved. After training, the finally saved model parameters are used as the optimal base model. The parameters.
[0131] Throughout the training process described above, the first BERT encoding layer and the first linear classification layer are trained using the comparison results between the input and output of the first CRF layer. The purpose is to enable the first BERT encoder to learn the most reasonable feature extraction method for Qin bamboo slips and for the first linear classification layer to output the most reasonable emission probability matrix (i.e., the most reasonable parameterized prediction probability combination for each character).
[0132] S103: Freeze the baseline model parameters obtained from the first stage of training, put the baseline model in inference mode, traverse the training set samples, extract the hidden state vector of each effective character in the last layer of the model as the key, and use the real entity label corresponding to the character as the value to construct an external index database in the form of key-value pairs.
[0133] In this step, the optimal model parameters of the baseline model saved in step S102 are loaded, all trainable parameters in the model are frozen, the baseline model is set to inference mode, and the Dropout random deactivation mechanism is disabled.
[0134] Re-traverse all samples in the training set, for each valid character in each sample Extract its hidden state vector from the output of the last layer within the first BERT coding layer. (i.e., the output of the first BERT encoding layer), using this vector as the key in the index database; simultaneously, obtaining the real entity label corresponding to the character. As a value;
[0135] A K-nearest neighbor index structure is constructed using the FAISS library for all key vectors, with L2 distance as the similarity metric. The key-value pairs are then stored in a static external index database. ,in, This represents the total number of characters in the training set.
[0136] Taking the training samples as an example, the hidden state vector of each valid character in the last layer of BERT is extracted. The hidden state vector is shown in Table 2.
[0137] character Hidden state vector Authentic Labels twenty B-TIME seven I-TIME Year I-TIME two I-TIME …… …… ……
[0138] Table 2
[0139] Assume there are a total of If there are 1 valid character, then construct a set of key-value pairs:
[0140] ;
[0141] Use the FAISS library to construct a K-nearest neighbor index for all key vectors.
[0142] This embodiment uses the IndexFlatL2 index structure (suitable for small to medium-sized datasets) and uses L2 distance as the similarity metric. Specifically, the formula for calculating L2 distance is:
[0143] .
[0144] Once the index is built, the external index database can be represented as a function mapping:
[0145] That is, given a query vector Return the closest one Given a set of key-value pairs and their distances, the external index database can be understood as a retrieval tool that uses a given semantic vector as a query and outputs the retrieved nearest neighbors.
[0146] Specifically, in step S103, the feature extraction capabilities learned by the first BERT encoder trained in step S102 are archived in the form of explicit cases to form an external index database. In subsequent applications, when encountering uncertain characters, similar historical cases can be retrieved to assist in reasoning.
[0147] S104: Load the external index database and the model parameters saved in the first stage, and perform the second stage of fusion training.
[0148] Figure 4 This is a schematic diagram of the fusion model structure according to an embodiment of the present invention.
[0149] The model trained in the second stage is a fusion model, which includes a parameterized branch (module), a gated network module, a non-parameterized branch (module), a weighted fusion module, and a second conditional random field (CRF) decoding layer.
[0150] Specifically, the parameterization branch includes a second BERT encoder and a second linear classification layer, which are used to generate parameterized prediction distributions. It should be noted that the second BERT encoder and the second linear classification layer have the same structure, and their initial state (parameters) are inherited from the first BERT encoder and the first linear classification layer. During the training of the subsequent fusion model, they continuously update their own parameters to suit the fusion target.
[0151] Specifically, the non-parametric branch includes the FAISS retrieval unit, the softmax kernel layer, and the distance-weighted layer. The FAISS retrieval unit uses the input semantic vector as the query to retrieve multiple nearest neighbor data. The softmax kernel layer calculates the weight of each nearest neighbor data based on Euclidean distance. The distance-weighted layer generates the retrieval distribution by aggregating and normalizing the neighbor weights by label.
[0152] Specifically, the gated network module dynamically calculates the fusion weights of the parameterized and non-parameterized branches based on the model's confidence in the current prediction. This includes a feature concatenation layer, a linear transformation layer, and a sigmoid activation layer. Specifically, the feature concatenation layer concatenates the semantic vector and confidence features into a gated input, the linear transformation layer performs a linear mapping through learnable weights and learnable biases, and the sigmoid activation layer maps the output of the linear transformation layer to the fusion weights in the (0,1) interval.
[0153] Specifically, the weighted fusion module performs linear interpolation on the probability distributions of the two branches based on the weights output by the gating network to generate the final fused probability distribution (ensuring that the output bit is a valid probability distribution, each element is non-negative and the sum is 1), and uses the fusion result as the input to the emission probability matrix of the second CRF decoding layer.
[0154] Specifically, the second CRF decoding layer has the same structure as the first CRF decoding layer, except that the input data is different from that of the first CRF decoding layer (the output is changed from Softmax to fused probability output). The Viterbi algorithm is used to search for the global optimal path and output the final entity label sequence.
[0155] Specifically, during training, for each input character, the prediction probability distribution of the parameterized branch and the retrieval probability distribution of the non-parameterized branch are calculated in parallel. Adaptive fusion weights are generated through a confidence-gated network, and the two probability distributions are weighted and fused through a weighted fusion module to obtain a fused probability distribution. The fused probability distribution is used as the emission probability matrix input to the conditional random field layer, and the entity label sequence is output through sequence decoding.
[0156] Specifically, the retrieval probability distribution of the non-parametric branch is obtained in the following way:
[0157] With the semantic vector of the current character As a query vector, the external index database is used to retrieve the Euclidean distance nearest... neighboring nodes ;
[0158] Based on the distance between the query vector and each neighbor vector, the Softmax kernel function is used for distance weighting to calculate the unnormalized weights:
[0159]
[0160] in, For temperature coefficient, Represents the L2 norm;
[0161] The weights of each neighbor are aggregated by label and normalized to obtain a non-parametric retrieval probability distribution:
[0162] .
[0163] Furthermore, the confidence-gated network generates adaptive fusion weights through the following steps:
[0164] Extract the maximum probability value from the parameterized prediction probability distribution. As a confidence feature;
[0165] The semantic vector With confidence features Vector concatenation is performed to obtain the gated input features. ;
[0166] The gated input feature The input is a learnable linear transformation layer, which is then mapped to fusion weights using a Sigmoid activation function:
[0167]
[0168] in, For the gated weight matrix, These are the gating bias parameters. is the Sigmoid function, and [⋅;⋅] is the vector concatenation operation. During the training process, the semantic vector and the confidence feature form the input of the confidence gating network after concatenation. Formally, the confidence gating network needs to give the trust degree of the fusion model for parametric knowledge based on the semantic vector and the confidence feature. Its internal logic is imitation and learning during the training process, and a specific feedback (fusion weight) is given when encountering a combination of a certain semantic vector and confidence feature; the fusion weight dynamically represents the trust degree of the fusion model for parametric knowledge: Logically speaking, when the context is complete and the model confidence is high, tends to 1; when the context is incomplete or the entity is rare, resulting in low confidence, automatically decreases, increasing the dependence on non-parametric retrieval information.
[0169] Specifically, this step adopts a full-parameter fine-tuning strategy, allowing the parameters of the second BERT encoder, the second linear classification layer, the second CRF layer, and the confidence gating network to be updated synchronously during backpropagation.
[0170] Taking the character "守" in the above-mentioned Qin bamboo slips text (located in "洞庭守") as an example, demonstrate the forward propagation process of the fusion training:
[0171] S301: BERT encoding.
[0172] Input the character "守" into the second BERT encoder to obtain its context semantic vector , where parametric branch calculation and non-parametric branch calculation are involved.
[0173] S302: Parametric branch calculation.
[0174] , ,
[0175] Assume that the model has the highest prediction probability for I-JOB, and the calculation result .
[0176] S303: Non-parametric branch calculation.
[0177] Taking as the query vector, retrieve nearest neighbors in the index database.
[0178] Assume that among the returned neighbors, 20 have the label I-JOB (ending character of official position), 8 have the label I-LOC, and 4 have the label O.
[0179] Calculate the Softmax weights of each neighbor (assuming the temperature coefficient ): , where is the neighbor index, .
[0180] Assume that the average distance of 20 retrieved I-JOB neighbors is 5.2, the average distance of 8 I-LOC neighbors is 8.7, and the average distance of 4 O-label neighbors is 12.3.
[0181] Then the probability of B-JOB in the non-parametric retrieval distribution is:[[]]
[0182] , where,[[]] is the temporary index variable when summing neighbors.
[0183] S304: Confidence gating calculation.
[0184] Extract the maximum probability value in the parametric distribution:[[]] .
[0185] Concatenate the semantic vector with and input it into the gating network:[[]]
[0186] ,
[0187] .
[0188] Assume that the gating network outputs , indicating that the model's confidence in the parametric distribution is 65%.
[0189] S305: Weighted fusion.
[0190]
[0191] For the I-JOB label:[[]]
[0192] .
[0193] It should be noted that the I-JOB label of the character "守" is just a node in the path. In actual applications, during the CRF sequence decoding process, according to the Viterbi algorithm, the optimal node should be selected as the accurate label of the character "守" in combination with the entire sentence content.
[0194] S306: CRF sequence decoding.
[0195] Input the fused probability distribution matrix as the emission probability matrix into the second CRF layer. The second conditional random field layer receives the fused probability distribution as the emission probability matrix, combines the label transition matrix, searches for the global optimal path through the Viterbi algorithm, and outputs a BIO label sequence of the same length as the input sequence.
[0196] Specifically, the input for CRF sequence decoding is the emission probability of the fused probability distribution for each character and the label transition matrix (which can be external or built into the second sequence decoding layer). The output of CRF sequence decoding is the globally optimal label sequence (with the same length as the input sentence).
[0197] For example, if the input entire sentence is "Twenty-seven years, second? Bingzi first day, Dongting guard Li said to the county constable?", the output is [B-TIME, I-TIME, I-TIME, I-TIME, I-TIME, I-TIME, I-TIME, I-TIME, I-TIME, I-TIME, O, B-JOB, I-JOB, I-JOB, B-PER, O, B-JOB, I-JOB, I-JOB].
[0198] S105: Use the joint loss function to perform end-to-end training on the fusion model in the second stage.
[0199] The joint loss function includes the sequence annotation loss and the distribution alignment regularization term. The encoder parameters, classification layer parameters, and gating network parameters are synchronously updated through the backpropagation algorithm until the fusion model converges. Under the determination of the final parameters of the fusion model, the required named entity recognition model is obtained.
[0200] It should be noted that in order to distinguish the fusion model in the training stage, when the trained fusion model is used as an entity recognition model, the trained second BERT encoder is named the Qinjian basic semantic encoder, the set unit of the trained parameterized branch, confidence gating network, non-parameterized branch, and weighted fusion module is named the retrieval enhanced fusion network, and the second CRF decoder is named the structured sequence decoder. In the parameterized branch, the trained second linear classification layer is named the third linear classification layer. The non-parameterized branch of the entity recognition model includes a FAISS retriever, a softmax kernel layer, and a distance weighting layer connected in sequence.
[0201] Correspondingly, the Qin bamboo slips basic semantic encoder described in this embodiment refers to a pre-trained language model encoder based on the BERT architecture and fine-tuned with Qin bamboo slips corpus, including an embedding layer and a multi-layer Transformer encoder, used to extract contextual semantic features of the input character sequence; the static feature extractor described in this invention refers to a functional module that, under the model parameter frozen state, traverses the training set to extract hidden state vectors and constructs an external index database, including a model freezer, a feature extractor, and a FAISS indexer; the retrieval enhancement fusion network described in this invention refers to an end-to-end trainable network structure containing parametric branches, non-parametric branches, a confidence gating network, and a weighted fusion module, used to achieve dynamic collaboration between parametric knowledge and non-parametric memory; the structured sequence decoder described in this embodiment refers to a probabilistic graphical model decoder based on conditional random fields, including a label transition matrix and a Viterbi decoding algorithm, used to output the globally optimal BIO label sequence.
[0202] In subsequent applications, the Qin bamboo slip text to be recognized is input into the second BERT encoder of the named entity recognition model according to a preset format (such as "Twenty-seventh year, second? Bingzi, first month, Gengyin, Dongting Shouli Weixian Se?"). The second CRF decoding layer of the named entity recognition model will output the estimated classification label information for each character in the Qin bamboo slip text. Depending on the actual needs, intermediate data generated by the named entity model during operation can also be output, such as the output results of each character in the parameterized or non-parameterized branches, the corresponding confidence value of the confidence gating network, and other data.
[0203] Specifically, in this embodiment of the invention, the joint loss function is:
[0204]
[0205] in, The negative log-likelihood loss of the conditional random field layer is used to constrain the model output to be consistent with the true label sequence.
[0206] The KL divergence (distribution alignment regularization term) measures the difference between the parametric distribution and the non-parametric retrieval distribution. As a regularization term, it encourages the parametric distribution to approximate the retrieval distribution and prevents them from deviating from each other. To balance the hyperparameters, the strength of KL divergence regularization is controlled.
[0207] The training objective of the second stage of the fusion model is to minimize the joint loss function:
[0208]
[0209] The KL divergence term is calculated as follows:
[0210]
[0211] The role of the KL divergence loss is to constrain the parametric distribution to approach the retrieval distribution. When the difference between the two is large, the KL divergence value increases, and the loss function imposes a greater penalty on the model parameters, prompting the second BERT encoder to adjust its feature output, making the parametric prediction consistent with the non-parametric retrieval, and avoiding the distribution shift between the semantic vectors output by the encoder and the key vectors in the external index database caused by the full-scale fine-tuning in the second stage.
[0212] Suppose for the character "守", the KL divergence between the parametric distribution and the retrieval distribution is 0.23, and the balance hyperparameter , then the KL regularization loss is .
[0213] Through the backpropagation algorithm, the gradient propagates along the following path:
[0214]
[0215] Synchronously update the parameters of the BERT encoder , the parameters of the classification layer , the CRF transition matrix and the parameters of the gating network .
[0216] In an optional implementation, during the training process of step S105, every 10 training steps, the current latest second BERT encoder is used to traverse the training set again, extract the latest hidden state vectors to update the key vectors in the external index database, eliminate the feature space drift caused by the update of the second encoder parameters, and ensure that the retrieval distribution (non-parametric distribution) and the parametric distribution are always in the same semantic space. In this implementation, the index database will be dynamically updated, showing a certain difference from the external index database obtained when step S103 is first executed.
[0217] In step S105, the parametric knowledge (BERT internal weights) and the non-parametric memory (external index cases) achieve global consistency through the KL divergence, and there is deep cooperation between the two; the gating network dynamically allocates the weights of the two branches according to the sample uncertainty, and the damaged text automatically depends on the retrieval for completion, improving the robustness; the long-tail entities obtain prior support through historical case retrieval, and the recognition recall rate of rare words is significantly improved; regular index reconstruction ensures that the semantic spaces of the retrieval key vectors and the query vectors are consistent, avoiding retrieval failures.
[0218] Specifically, the named entity recognition method for Qin bamboo slips text disclosed in the embodiments of the present invention mainly has two application directions. One direction is that the input Qin bamboo slips text has serious damage, and the other direction is that the input Qin bamboo slips text belongs to low-frequency rare entities.
[0219] Assume that the input bamboo slips text of Qin Dynasty is severely damaged. The example text content is "The magistrate of Yiyang, Qiao, submits a statement. Qianling", and the actual text form is "? Yang magistrate? submits a statement. Qianling?", where "?" indicates that the characters are damaged and unidentifiable.
[0220] Due to the lack of context information, the confidence of the standard BERT-CRF model in identifying entities near the damaged positions drops significantly.
[0221] Taking the character "magistrate" as an example, due to the damage of the previous character, BERT can only see "? Yang magistrate" and lacks the complete context of the place name "Yiyang".
[0222] At this time, the content output by the parameterized branch is:
[0223]
[0224] The maximum probability indicates that the parameterized branch of the fusion model is in a low-confidence state.
[0225] Since is relatively low, the gating network outputs , indicating that the model's trust in the parameterized prediction is only 30%, and it instead relies more on external retrieval information.
[0226] Correspondingly, the content shown by the non-parameterized retrieval branch is to retrieve with the semantic vector of the character "magistrate" in the index database, find historical similar damaged context samples, and label the "magistrate" in "? Yang County magistrate? submits a statement." as B-JOB.
[0227] The retrieval distribution shows:
[0228]
[0229] Calculate the fusion result of the two branches:
[0230] After fusion, the probability of B-JOB increases from 0.45 to 0.709, and the confidence of the named entity recognition model in correctly identifying "magistrate" as the official position name B-JOB is greatly improved.
[0231] This example fully demonstrates the effectiveness of the confidence gating mechanism. When the parameterized branch lacks confidence due to incomplete context, the system automatically increases its dependence on external retrieval information, uses similar historical cases for reasoning and completion, thereby enhancing the robustness of the model on damaged texts.
[0232] Furthermore, this embodiment demonstrates the enhanced recognition effect of the present invention on low-frequency and rare entities.
[0233] Assume that the low-frequency official title "Daliang Zao" appears in the test text, such as "Daliang Zao Yang revised the field laws again", where "Daliang Zao" is a unique high-level official title in the Qin Dynasty (Shang Yang once held this position), and it only appears 2 times in the training set.
[0234] In the standard BERT-CRF model under the existing technology, due to the extremely small number of training samples, BERT fails to fully learn the effective representation of "Daliang Zao", and the prediction result for the character "大" is:
[0235]
[0236] The model tends to identify "大" as a non-entity (O), resulting in the missed detection of the official title "Daliang Zao".
[0237] When adopting the fusion model of the embodiment of the present invention, the non-parametric retrieval branch finds the only 2 "Daliang Zao" samples in the training set in the index database, and the retrieval distribution shows:
[0238]
[0239] The gating network detects that the parametric confidence is relatively low ( ) and outputs .
[0240] Correspondingly, the fusion result is .
[0241] After fusion, the probability of B-JOB exceeds the O label (the prediction probability of the O label in the parametric branch is ), and the model correctly identifies "大" as B-JOB, and then completely identifies the long-tail official title entity "Daliang Zao".
[0242] In summary, the named entity recognition method for Qin bamboo slips text disclosed in the present invention has the following beneficial effects compared with the existing technology:
[0243] First, it significantly improves the entity recognition accuracy on low-resource historical corpora.
[0244] By introducing a non-parametric retrieval mechanism, the model can explicitly utilize the historical case information in the training set, effectively compensating for the deficiencies of pure parametric models in data-sparse scenarios. Experiments show that the F1 value of the method of the present invention on the Qin bamboo slips NER dataset reaches 94.2%, which is 3.1 percentage points higher than that of the baseline BERT-CRF model, especially the recall rate of long-tail entities is increased by 8.5 percentage points.
[0245] Second, it enhances the robustness of the model on damaged texts.
[0246] The confidence gating mechanism enables the model to adaptively adjust the fusion strategy based on the dynamic uncertainty of the input samples. When the context is incomplete, the model automatically increases its reliance on external retrieval information and uses similar cases to perform reasoning completion. Experiments show that on test sets with artificially simulated character damage of different proportions, the F1 score of the method of this invention decreases by only 55% of the baseline model.
[0247] Third, it achieves deep synergy between parametric knowledge and non-parametric memory.
[0248] By using KL divergence regularization constraints and full parameter fine-tuning strategies, the BERT encoder dynamically adjusts the feature extraction method based on retrieval feedback, making the parameterized distribution consistent with the retrieval distribution. This global collaborative optimization of implicit knowledge and explicit memory effectively breaks through the generalization bottleneck of traditional models under the sparse and long-tailed distribution of Qin bamboo slips data.
[0249] Fourth, it has good scalability and domain migration capabilities.
[0250] The method framework of this invention is not only applicable to Qin bamboo slips, but can also be extended to other unearthed bamboo and silk documents (such as Han bamboo slips and Chu bamboo slips) and named entity recognition tasks of various low-resource historical corpora. By replacing the corresponding domain pre-trained model and index database, it can be quickly adapted to new target domains, and has good adaptability.
[0251] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A named entity recognition model for Qin bamboo slips text, characterized in that, include: The Qin bamboo slips basic semantic encoder is used to encode the input Qin bamboo slips text and extract semantic vectors; An external index database is used to store key-value pairs, wherein the key-value pairs use the hidden state vector of the character as the key and the corresponding real entity label as the value; The retrieval enhancement fusion network includes a parametric branch, a non-parametric branch, a confidence-gated network, and a weighted fusion module. The parametric branch is used to generate a parametric prediction probability distribution based on the semantic vector. The non-parametric branch is used to retrieve nearest neighbor samples from the external index database based on the semantic vector and generate a non-parametric retrieval probability distribution. The confidence-gated network is used to generate fusion weights based on the confidence features of the parametric prediction probability distribution and the semantic vector. The weighted fusion module is used to perform weighted fusion of the parametric prediction probability distribution and the non-parametric retrieval probability distribution based on the fusion weights to generate a fusion probability distribution. A structured sequence decoder is used to perform sequence decoding on the fused probability distribution and output the entity label sequence of the Qin bamboo text.
2. The named entity recognition model for Qin bamboo slips text as described in claim 1, characterized in that, The parameterized branch includes a third linear classification layer.
3. The named entity recognition model for Qin bamboo slips text as described in claim 1, characterized in that, The non-parametric branch includes a FAISS searcher, a softmax kernel layer, and a distance-weighted layer connected in sequence.
4. The named entity recognition model for Qin bamboo slips text as described in claim 1, characterized in that, The gated network module includes a feature splicing layer, a linear transformation layer, and a sigmoid activation layer connected in sequence.
5. The named entity recognition model for Qin bamboo slips text as described in claim 1, characterized in that, The named entity recognition model is generated based on a training process, which includes: Construct a Qin Dynasty bamboo slips text named entity recognition dataset, which includes model input samples, including input character sequences, attention masks, and entity label sequences; A baseline model is trained based on the input samples of the model to obtain the optimal parameter baseline model. The baseline model includes a first BERT encoding layer, a first linear classification layer and a first conditional random field decoding layer connected in sequence. Freeze the baseline model with the optimal parameters, extract the hidden state vector of each character in the input sample of the model through the first BERT encoding layer as the key, use the real entity label corresponding to the character as the value, construct the K nearest neighbor index structure using the FAISS library, and establish an external index database; A fusion model is trained based on the input samples of the aforementioned model. The fusion model includes a second BERT encoder, a parametric branch, a non-parametric branch, a confidence gating network, and a weighted fusion module. For each input character, the fusion network performs parametric prediction and non-parametric retrieval in parallel. The parametric prediction generates a parametric prediction probability distribution through the linear classification layer, and the non-parametric retrieval uses the current character semantic vector as the query vector to retrieve the nearest neighbor in the external index database and generate a non-parametric retrieval probability distribution. The adaptive fusion weights are generated through a confidence-gated network, and the two probability distributions are weighted and fused to obtain a fused probability distribution; the fused probability distribution is then input into a conditional random field layer for decoding and outputting an entity label sequence. The training of the fusion model is optimized end-to-end using a joint loss function, which includes sequence labeling loss and distribution alignment regularization term, until the fusion model converges. The fusion model after training is the named entity recognition model.
6. The named entity recognition model for Qin bamboo slips text as described in claim 5, characterized in that, In the model input samples, damaged and blurry characters are marked with a uniform placeholder, and positions with missing characters and uncertain number of missing characters are marked with an ellipsis.
7. The named entity recognition model for Qin bamboo slips text as described in claim 1, characterized in that, The entity types in the named entity recognition model include personal names, place names, organization names, official titles, legal proper nouns, time periods, and book titles.
8. The named entity recognition model for Qin bamboo slips text as described in claim 7, characterized in that, Based on the BIO tagging system, the entity tags in the named entity recognition model include: B-PER and I-PER represent the first and middle characters of a person's name, respectively; B-LOC and I-LOC represent the starting and middle characters of a place name, respectively; B-ORG and I-ORG represent the first and middle characters of the organization name, respectively; B-JOB and I-JOB represent the starting and middle characters of an official title, respectively; B-LAW and I-LAW represent the start character and middle character of a legal proper name, respectively; B-TIME and I-TIME represent the start and middle characters of the time sequence, respectively. B-BOO and I-BOO represent the start and middle characters of the book title, respectively; O represents a non-physical character.
9. A named entity recognition method for Qin bamboo slips text, characterized in that, The named entity recognition model for Qin bamboo slips text as described in any one of claims 1 to 8 includes: The Qin bamboo slips basic semantic encoder is used to encode the input Qin bamboo slips text and extract semantic vectors; A retrieval enhancement fusion network is used to adaptively fuse the parameterized prediction probability distribution and the non-parametric retrieval probability distribution to generate a fused probability distribution. The parameterized prediction probability distribution is generated by the parameterized branch based on the semantic vector, and the non-parametric retrieval probability distribution is generated by the non-parametric branch after retrieving nearest neighbor samples from the external index database based on the semantic vector. The fusion probability distribution is sequence decoded using a structured sequence decoder to output the final entity label sequence; The adaptive fusion includes: The confidence-gated network module calculates the fusion weights based on the confidence features of the parameterized prediction probability distribution and the semantic vector; The weighted fusion module weights and fuses the parametric prediction probability distribution and the non-parametric retrieval probability distribution according to the fusion weight to obtain the fused probability distribution.