CN-121981120-A - Named entity identification method and device based on context and electronic equipment
Abstract
The invention discloses a method, a device and an electronic device for identifying a named entity based on a context, which are characterized in that an original text is firstly obtained, then a text prompt word is obtained according to the original text, then the text prompt word is processed through a first preset model to obtain the context text, then the context text is processed through a second preset model to obtain attention weight, correlation calculation is carried out based on the attention weight to obtain the relevant text, finally the relevant text is processed through a third preset model to obtain an entity tag, and named entity identification is carried out based on the entity tag, namely, after the context text is obtained, the attention weight is obtained based on the second preset model and the context text, and then the entity tag is obtained based on the third preset model and the attention weight, so that the named entity identification is avoided.
Inventors
- WU SIQI
- WAN HAITAO
- YANG XI
Assignees
- 中移(苏州)软件技术有限公司
- 中国移动通信集团有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20260122
Claims (10)
- 1. A method for identifying a named entity based on context, the method comprising: Acquiring an original text; obtaining text prompt words according to the original text; processing the text prompt word through a first preset model to obtain a context text; processing the context text through a second preset model to obtain attention weight; Performing correlation calculation based on the attention weight to obtain a correlation text; And processing the related text through a third preset model to obtain an entity tag, and naming entity recognition based on the entity tag.
- 2. The method of claim 1, wherein obtaining text prompt words from the original text comprises: performing similarity matching on the original text based on RAG retrieval to obtain a related example; and constructing the prompt word based on the related examples to obtain the text prompt word.
- 3. The method according to claim 2, wherein the processing the text prompt word by the first preset model, before obtaining the context text, comprises: acquiring history log data; Obtaining an initial data set according to the history log data; Performing data labeling on the initial data set based on BiLSTM-CRF model to obtain an entity training data set; And learning in the entity training data set based on a large language model to obtain the first preset model.
- 4. A method according to claim 3, wherein processing the context text through a second pre-set model to obtain an attention weight comprises: word segmentation is carried out on the context text, and a preset format text is obtained; Processing the text in the preset format through a second preset model to obtain the attention weight; wherein the second preset model is a BERT model.
- 5. The method of claim 4, wherein the attention weight is obtained by processing the pre-formatted text through a second pre-defined model, further comprising: performing data conversion on the text with the preset format to obtain time sequence data; Based on the time series data, the attention weight is obtained.
- 6. The method of claim 5, wherein performing a correlation calculation based on the attention weight to obtain a related text comprises: performing correlation calculation based on the attention weight to obtain a similarity score; judging whether the similarity score is larger than a first threshold value or not, and obtaining a first judgment result; And if the first judgment result is yes, obtaining the related text.
- 7. The method of claim 5, wherein converting the data of the text in the preset format to obtain time-series data, comprises: The formula is: ; ; ; ; ; Wherein the method comprises the steps of ,K,V Q, k and v are obtained by linear mapping, Returning K low frequency components with maximum amplitude, K is a predefined super parameter, 、 、 ( ) Respectively represent k low-frequency Fourier components with maximum amplitude extracted after FFT conversion and decomposition of the input characteristics, Then the attention weight value before the inverse fast fourier transform is performed is represented and then Zero filling to ,Y Representing the final attention weight value converted from the frequency domain back to the time domain by IFFT and calculated.
- 8. The method of claim 1, wherein processing the related text through a third preset model to obtain an entity tag comprises: Extracting the characteristics of the related text to obtain related characteristics; predicting the related features through the third preset model to obtain an entity tag; the third preset model is a sequence annotation model.
- 9. An identification device is characterized by comprising an acquisition unit, an analysis unit and a processing unit: the acquisition unit is used for acquiring the original text; The analysis unit is used for obtaining text prompt words according to the original text, processing the text prompt words through a first preset model to obtain a context text, processing the context text through a second preset model to obtain attention weight, and performing correlation calculation based on the attention weight to obtain a related text; and the processing unit is used for processing the related text through a third preset model to obtain an entity tag, and naming entity recognition is performed based on the entity tag.
- 10. An electronic device, comprising: a memory for storing at least one set of instructions; The processor is used for acquiring the original text; obtaining text prompt words according to the original text; processing the text prompt word through a first preset model to obtain a context text; processing the context text through a second preset model to obtain attention weight; Performing correlation calculation based on the attention weight to obtain a correlation text; And processing the related text through a third preset model to obtain an entity tag, and naming entity recognition based on the entity tag.
Description
Named entity identification method and device based on context and electronic equipment Technical Field The embodiment of the application relates to artificial intelligence, and relates to a method and a device for identifying a named entity based on context and electronic equipment. Background Named Entity Recognition (NER) is an important task in the field of Natural Language Processing (NLP). Its goal is to identify entities in text that have a particular meaning and classify them into predefined categories such as person name, place name, organization name, time expression, quantity expression, monetary value, etc. In the traditional method, a large model is adopted to directly generate a recognition result, and when ambiguous words or conditions with ambiguous contexts are processed, an error recognition result can be generated, and meanwhile, the problem of low accuracy is caused. Disclosure of Invention In view of this, the embodiment of the application provides a method, a device and an electronic device for identifying a named entity based on a context. The technical scheme of the embodiment of the application is realized as follows: The embodiment of the application provides a named entity recognition method based on a context, which comprises the steps of obtaining an original text, obtaining a text prompt word according to the original text, processing the text prompt word through a first preset model to obtain a context text, processing the context text through a second preset model to obtain attention weight, performing correlation calculation based on the attention weight to obtain a related text, processing the related text through a third preset model to obtain an entity tag, and recognizing a named entity based on the entity tag. Optionally, obtaining text prompt words according to the original text comprises performing similarity matching on the original text based on RAG retrieval to obtain related examples, and performing prompt word construction based on the related examples to obtain the text prompt words. Optionally, before the text prompt word is processed through a first preset model to obtain the context text, the method comprises the steps of obtaining historical log data, obtaining an initial data set according to the historical log data, carrying out data labeling on the initial data set based on BiLSTM-CRF model to obtain an entity training data set, and learning in the entity training data set based on a large language model to obtain the first preset model. Optionally, the context text is processed through a second preset model to obtain the attention weight, the method comprises the steps of word segmentation processing of the context text to obtain a preset format text, and processing of the preset format text through the second preset model to obtain the attention weight, wherein the second preset model is a BERT model. Optionally, the attention weight is obtained by processing the text in the preset format through a second preset model, and the method further comprises the steps of performing data conversion on the text in the preset format to obtain time sequence data, and obtaining the attention weight based on the time sequence data. Optionally, performing correlation calculation based on the attention weight to obtain a related text, wherein the method comprises the steps of performing correlation calculation based on the attention weight to obtain a similarity score, judging whether the similarity score is larger than a first threshold value to obtain a first judgment result, and obtaining the related text if the first judgment result is yes. Optionally, the data conversion is performed on the text with the preset format to obtain time sequence data, which comprises the following formulas: ; ; ; ; ; Wherein the method comprises the steps of ,K,VQ, k and v are obtained by linear mapping,Returning K low frequency components with maximum amplitude, K is a predefined super parameter,、、() Respectively represent k low-frequency Fourier components with maximum amplitude extracted after FFT conversion and decomposition of the input characteristics,Then the attention weight value before the inverse fast fourier transform is performed is represented and thenZero filling to,YRepresenting the final attention weight value converted from the frequency domain back to the time domain by IFFT and calculated. Optionally, the related text is processed through a third preset model to obtain an entity tag, wherein the method comprises the steps of extracting features of the related text to obtain related features, and predicting the related features through the third preset model to obtain the entity tag, wherein the third preset model is a sequence labeling model. The recognition device comprises an acquisition unit, an analysis unit and a processing unit, wherein the acquisition unit is used for acquiring an original text, the analysis unit is used for acquiring a text prompt word acc