Method and system for distinguishing event similarity based on neural network hybrid model

CN118586381APending Publication Date: 2024-09-03INSPUR SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410706573.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-03
Publication Date
2024-09-03

AI Technical Summary

Technical Problem

In the field of natural language processing, it is difficult for existing technology to accurately determine whether two pieces of text say the same thing. Especially in urban governance, there are challenges in judging the severity and batch processing of a large number of events.

Method used

A hybrid model based on neural networks is used to construct word vectors through word segmentation encoders and event similarity calculation models, and use attention layers and feed-forward network layers to calculate word vector similarity, and output similarity scores to determine event similarity.

Benefits of technology

It achieves accurate judgment and batch processing of events in urban governance, and improves the accuracy of event similarity judgment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118586381A
    Figure CN118586381A
Patent Text Reader

Abstract

The invention discloses a method and system for distinguishing event similarity based on a neural network hybrid model, belongs to the technical field of artificial intelligence, and aims to solve the technical problem of how to judge the event similarity in urban governance. Comprising the following steps: constructing a word segmentation encoder based on a Chinese word segmentation device, and constructing an event similarity calculation model based on a neural network model; taking the word vectors and the similarities corresponding to the two events as sample data, and constructing a training set based on the sample data; performing model training on the event similarity calculation model through the training set to obtain a trained event similarity calculation model; and for two events to be distinguished, performing word segmentation and encoding processing on the event text through a word segmentation encoder, taking the word vectors corresponding to the two events as input, and calculating the word vector similarity between the two events through the trained event similarity calculation model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method and system for identifying event similarity based on a neural network hybrid model. Background Art

[0002] In the field of natural language processing, existing word vectors and other models can be used to determine the similarity between two texts, but it is difficult to accurately determine whether the two texts are talking about the same thing. Especially in the process of urban governance, for a large number of events, how to identify duplicates and process them in batches has become a big problem.

[0003] How to judge the similarity of events in urban governance is a technical problem that needs to be solved. Summary of the invention

[0004] The technical task of the present invention is to address the above shortcomings and provide a method and system for identifying event similarities based on a neural network hybrid model to solve the technical problem of how to judge event similarity in urban governance.

[0005] In a first aspect, the present invention provides a method for identifying event similarity based on a neural network hybrid model, comprising the following steps:

[0006] Model construction: A word segmentation encoder is constructed based on the Chinese word segmenter, and an event similarity calculation model is constructed based on the neural network model. The word segmentation encoder is used to perform word segmentation and encoding processing on the input text to obtain word vectors. The event similarity calculation model is used to take the word vectors corresponding to two events as input, calculate the word vector similarity between the texts, and output a similarity score;

[0007] Sample construction: Collect event texts corresponding to historical events, take the event text corresponding to each historical event as input, perform word segmentation and encoding on the event text through a word segmentation encoder, obtain the word vector corresponding to each historical event, take the word vectors and similarities corresponding to two events as sample data, and build a training set based on the sample data;

[0008] Model training: The event similarity calculation model is trained through the training set to obtain the trained event similarity calculation model;

[0009] Event identification: For two events to be identified, the event text corresponding to each event is used as input, and the event text is segmented and encoded through the word segmentation encoder to obtain the word vector corresponding to each event. The word vectors corresponding to the two events are used as input, and the word vector similarity between the two events is calculated through the trained event similarity calculation model. The predicted similarity score is output, and whether the two events are the same event is determined based on the similarity score.

[0010] Preferably, the word segmentation encoder includes a Chinese word segmentation module, an encoding module and a fine-tuning module;

[0011] The Chinese word segmentation module is used to segment the input text to obtain multiple words;

[0012] The encoding module is used to take the words output by the Chinese module as input, vectorize each word, and obtain the word vector corresponding to each word;

[0013] The fine-tuning module is used to perform positioning calculation on each word vector, fine-tune the word vector to a new high-dimensional space, and obtain a new word vector.

[0014] Preferably, the fine-tuning module is used to perform the following positioning calculation on the word vector output by the encoding module:

[0015]

[0016] Among them, PE represents, pos represents, 2i represents, d model express.

[0017] Preferably, the event similarity calculation model includes an attention layer and a feedforward network layer;

[0018] The attention layer is used to take the word vector corresponding to the text as input, predict the relationship between words in the text, and output the merged word vector. The feedforward network layer is used to take the merged word vector corresponding to two texts as input and calculate the word vector similarity of the two texts.

[0019] Preferably, the feedforward neural network layer is a neural network model constructed based on a long short-term memory network.

[0020] In a second aspect, the present invention provides a system for distinguishing event similarity based on a neural network hybrid model, including a model construction module, a sample construction module, a model training module, and an event identification module;

[0021] The model building module is used to perform the following: construct a word segmentation encoder based on the Chinese word segmenter, and construct an event similarity calculation model based on the neural network model, wherein the word segmentation encoder is used to perform word segmentation and encoding processing on the input text to obtain a word vector, and the event similarity calculation model is used to take the word vectors corresponding to two events as input, calculate the word vector similarity between the texts, and output a similarity score;

[0022] The sample construction module is used to perform the following: collect event texts corresponding to historical events, take the event texts corresponding to each historical event as input, perform word segmentation and encoding on the event texts through a word segmentation encoder, obtain the word vectors corresponding to each historical event, take the word vectors and similarities corresponding to two events as sample data, and construct a training set based on the sample data;

[0023] The model training module is used to perform the following: perform model training on the event similarity calculation model through the training set to obtain the trained event similarity calculation model;

[0024] The event identification module is used to perform the following: for two events to be identified, the event text corresponding to each event is used as input, the event text is segmented and encoded through a word segmentation encoder to obtain the word vector corresponding to each event, and the word vectors corresponding to the two events are used as input, the word vector similarity between the two events is calculated through the trained event similarity calculation model, and the predicted similarity score is output, and whether the two events are the same event is determined based on the similarity score.

[0025] Preferably, the word segmentation encoder includes a Chinese word segmentation module, an encoding module and a fine-tuning module;

[0026] The Chinese word segmentation module is used to segment the input text to obtain multiple words;

[0027] The encoding module is used to take the words output by the Chinese module as input, vectorize each word, and obtain the word vector corresponding to each word;

[0028] The fine-tuning module is used to perform positioning calculation on each word vector, fine-tune the word vector to a new high-dimensional space, and obtain a new word vector.

[0029] Preferably, the fine-tuning module is used to perform the following positioning calculation on the word vector output by the encoding module:

[0030]

[0031] Among them, PE represents, pos represents, 2i represents, d model express.

[0032] Preferably, the event similarity calculation model includes an attention layer and a feedforward network layer;

[0033] The attention layer is used to take the word vector corresponding to the text as input, predict the relationship between words in the text, and output the merged word vector. The feedforward network layer is used to take the merged word vector corresponding to two texts as input and calculate the word vector similarity of the two texts.

[0034] Preferably, the feedforward neural network layer is a neural network model constructed based on a long short-term memory network.

[0035] The method and system for distinguishing event similarity based on a neural network hybrid model of the present invention have the following advantages: duplicate event determination is realized in urban governance and the batch processing problem of duplicate event determination is solved. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0037] The present invention is further described below in conjunction with the accompanying drawings.

[0038] Figure 1 This is a flowchart of a method for identifying event similarity based on a neural network hybrid model in Example 1;

[0039] Figure 2 This is a block diagram of the working principle of the attention layer in a method for distinguishing event similarity based on a neural network hybrid model in Example 1;

[0040] Figure 3 This is a structural block diagram of the feedforward neural network layer in a method for distinguishing event similarity based on a neural network hybrid model in Example 1. DETAILED DESCRIPTION

[0041] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it. However, the embodiments are not intended to limit the present invention. In the absence of conflict, the embodiments of the present invention and the technical features in the embodiments may be combined with each other.

[0042] The embodiments of the present invention provide a method and system for identifying event similarity based on a neural network hybrid model, which are used to solve the technical problem of how to judge event similarity in urban governance.

[0043] Embodiment 1:

[0044] The present invention discloses a method for distinguishing event similarity based on a neural network hybrid model, which comprises four steps: model construction, sample construction, model training and event identification.

[0045] Step S100: Model construction: construct a word segmentation encoder based on the Chinese word segmenter, and construct an event similarity calculation model based on the neural network model. The word segmentation encoder is used to perform word segmentation and encoding processing on the input text to obtain word vectors. The event similarity calculation model is used to take the word vectors corresponding to two events as input, calculate the word vector similarity between the texts, and output a similarity score.

[0046] In step S100 of this embodiment, the word segmentation encoder includes a Chinese word segmentation module, an encoding module and a fine-tuning module.

[0047] The Chinese word segmentation module is used to segment the input text to obtain multiple words. As a specific implementation of the Chinese word segmentation module, this embodiment uses the jieba word segmenter to segment the text.

[0048] The encoding module is used to take the words output by the Chinese module as input, vectorize each word, and obtain the word vector corresponding to each word.

[0049] The fine-tuning module is used to perform positioning calculations on each word vector, fine-tuning the word vector to a new high-dimensional space to obtain a new word vector. As a specific implementation, the fine-tuning module is used to perform the following positioning calculations on the word vector output by the encoding module:

[0050]

[0051] Among them, PE represents, pos represents, 2i represents, d model express.

[0052] As a specific implementation of the event similarity calculation model, it includes an attention layer and a feedforward network layer.

[0053] The attention layer is used to take the word vector corresponding to the text as input, predict the relationship between words in the text, and output the merged word vector. The feedforward network layer is used to take the merged word vector corresponding to the two texts as input and calculate the word vector similarity of the two texts.

[0054] In this embodiment, an Attention (Q, K, V) algorithm is used to put the text into a new spatial information. This new vector contains not only the meaning of each word itself and the position information in the sentence, but also the relationship and value information between the meanings of each word in the sentence. In addition, the Attention (Q, K, V) algorithm does not perform calculations around a word, but calculates this word with all the words in the sentence. The position of the word in the space is adjusted through calculation. The barrier of the time series is broken. Finally, each Self Attention accepts the input of n word vectors and outputs n Aggregated vectors.

[0055] Q=XW Q

[0056] K=XW K

[0057] V=XW V

[0058]

[0059] Among them, Q represents, K represents, V represents, W represents Q Indicates that W K Indicates that WV Indicates that d k express.

[0060] The feedforward neural network layer is a neural network model built on top of the long short-term memory network. After the attention head transfers information between word vectors, the meaningful output of the attention layer is compared through the feedforward network layer to obtain a matching score. At this stage, no information is exchanged between words, and the feedforward layer analyzes each word independently. However, the feedforward layer has access to any information previously copied by the attention head. Figure 3 It is a feed-forward layer structure.

[0061] Step S200: Sample construction: Collect event texts corresponding to historical events, take the event text corresponding to each historical event as input, perform word segmentation and encoding on the event text through a word segmentation encoder, obtain the word vector corresponding to each historical event, take the word vectors and similarities corresponding to two events as sample data, and construct a training set based on the sample data.

[0062] In step S200 of this embodiment, when constructing samples to calculate event similarity, the word vector similarity between two events can be calculated by cosine similarity as the true similarity.

[0063] Step S300: Model training: The event similarity calculation model is trained using a training set to obtain a trained event similarity calculation model.

[0064] During model training in this implementation, the word vector similarity output by the event similarity calculation model is used as the predicted similarity, a loss function is constructed based on the real similarity and the predicted similarity, and the event similarity calculation model is trained by minimizing the loss function.

[0065] Step S400 event identification: For the two events to be identified, the event text corresponding to each event is used as input, and the event text is segmented and encoded through a word segmentation encoder to obtain the word vector corresponding to each event, and the word vectors corresponding to the two events are used as input, and the word vector similarity between the two events is calculated through the trained event similarity calculation model, and the predicted similarity score is output, and whether the two events are the same event is determined based on the similarity score.

[0066] When an event is submitted to the system, the method of this embodiment is used to analyze which events are the same event, so as to merge them.

[0067] Embodiment 2:

[0068] The present invention discloses a system for distinguishing event similarity based on a neural network hybrid model, comprising a model construction module, a sample construction module, a model training module and an event distinguishing module.

[0069] The model building module is used to perform the following: construct a word segmentation encoder based on the Chinese word segmenter, and construct an event similarity calculation model based on the neural network model. The word segmentation encoder is used to perform word segmentation and encoding processing on the input text to obtain word vectors. The event similarity calculation model is used to take the word vectors corresponding to two events as input, calculate the word vector similarity between the texts, and output a similarity score.

[0070] In this embodiment, the word segmentation encoder includes a Chinese word segmentation module, an encoding module and a fine-tuning module.

[0071] The Chinese word segmentation module is used to segment the input text to obtain multiple words. As a specific implementation of the Chinese word segmentation module, this embodiment uses the jieba word segmenter to segment the text.

[0072] The encoding module is used to take the words output by the Chinese module as input, vectorize each word, and obtain the word vector corresponding to each word.

[0073] The fine-tuning module is used to perform positioning calculations on each word vector, fine-tuning the word vector to a new high-dimensional space to obtain a new word vector. As a specific implementation, the fine-tuning module is used to perform the following positioning calculations on the word vector output by the encoding module:

[0074]

[0075] Among them, PE represents, pos represents, 2i represents, d model express.

[0076] As a specific implementation of the event similarity calculation model, it includes an attention layer and a feedforward network layer.

[0077] The attention layer is used to take the word vector corresponding to the text as input, predict the relationship between words in the text, and output the merged word vector. The feedforward network layer is used to take the merged word vector corresponding to the two texts as input and calculate the word vector similarity of the two texts.

[0078] In this embodiment, an Attention (Q, K, V) algorithm is used to put the text into a new spatial information. This new vector contains not only the meaning of each word itself and the position information in the sentence, but also the relationship and value information between the meanings of each word in the sentence. In addition, the Attention (Q, K, V) algorithm does not perform calculations around a word, but calculates this word with all the words in the sentence. The position of the word in the space is adjusted through calculation. The barrier of the time series is broken. Finally, each Self Attention accepts the input of n word vectors and outputs n Aggregated vectors.

[0079] Q=XWQ

[0080] K=XW K

[0081] V=XW V

[0082]

[0083] Among them, Q represents, K represents, V represents, W represents Q Indicates that W K Indicates that W V Indicates that d k express.

[0084] The feedforward neural network layer is a neural network model built on top of the long short-term memory network. After the attention head transfers information between word vectors, the meaningful output of the attention layer is compared through the feedforward network layer to obtain a matching score. At this stage, no information is exchanged between words, and the feedforward layer analyzes each word independently. However, the feedforward layer has access to any information previously copied by the attention head.

[0085] The sample construction module is used to perform the following: collect event texts corresponding to historical events, take the event text corresponding to each historical event as input, segment and encode the event text through a word segmentation encoder, obtain the word vector corresponding to each historical event, take the word vectors and similarities corresponding to two events as sample data, and build a training set based on the sample data.

[0086] When the sample construction module of this embodiment constructs samples to calculate event similarity, the word vector similarity between two events can be calculated by cosine similarity as the true similarity.

[0087] The model training module is used to perform the following: perform model training on the event similarity calculation model through the training set to obtain the trained event similarity calculation model.

[0088] In this implementation, when the model training module is used for model training, the word vector similarity output by the event similarity calculation model is used as the predicted similarity, a loss function is constructed based on the real similarity and the predicted similarity, and the event similarity calculation model is trained by minimizing the loss function.

[0089] The event identification module is used to perform the following: for two events to be identified, the event text corresponding to each event is used as input, the event text is segmented and encoded through a word segmentation encoder to obtain the word vector corresponding to each event, and the word vectors corresponding to the two events are used as input, the word vector similarity between the two events is calculated through the trained event similarity calculation model, and the predicted similarity score is output, and whether the two events are the same event is determined based on the similarity score.

[0090] The present invention has been shown and described in detail above through the accompanying drawings and preferred embodiments. However, the present invention is not limited to these disclosed embodiments. Based on the above multiple embodiments, those skilled in the art can know that the means in the above different embodiments can be combined to obtain more embodiments of the present invention, and these embodiments are also within the protection scope of the present invention.

Claims

1. A method for identifying event similarity based on a neural network hybrid model, characterized in that: The steps include: Model construction: A word segmentation encoder is constructed based on the Chinese word segmenter, and an event similarity calculation model is constructed based on the neural network model. The word segmentation encoder is used to perform word segmentation and encoding processing on the input text to obtain word vectors. The event similarity calculation model is used to take the word vectors corresponding to two events as input, calculate the word vector similarity between the texts, and output a similarity score; Sample construction: Collect event texts corresponding to historical events, take the event text corresponding to each historical event as input, perform word segmentation and encoding on the event text through a word segmentation encoder, obtain the word vector corresponding to each historical event, take the word vectors and similarities corresponding to two events as sample data, and build a training set based on the sample data; Model training: The event similarity calculation model is trained through the training set to obtain the trained event similarity calculation model; Event identification: For two events to be identified, the event text corresponding to each event is used as input, and the event text is segmented and encoded through the word segmentation encoder to obtain the word vector corresponding to each event. The word vectors corresponding to the two events are used as input, and the word vector similarity between the two events is calculated through the trained event similarity calculation model. The predicted similarity score is output, and whether the two events are the same event is determined based on the similarity score.

2. The method for identifying event similarity based on a neural network hybrid model according to claim 1, characterized in that: The word segmentation encoder includes a Chinese word segmentation module, an encoding module and a fine-tuning module; The Chinese word segmentation module is used to segment the input text to obtain multiple words; The encoding module is used to take the words output by the Chinese module as input, vectorize each word, and obtain the word vector corresponding to each word; The fine-tuning module is used to perform positioning calculation on each word vector, fine-tune the word vector to a new high-dimensional space, and obtain a new word vector.

3. The method for identifying event similarity based on a neural network hybrid model according to claim 2, characterized in that: The fine-tuning module is used to perform the following positioning calculation on the word vector output by the encoding module: Among them, PE represents, pos represents, 2i represents, d model express.

4. The method for identifying event similarity based on a neural network hybrid model according to claim 1, characterized in that: The event similarity calculation model includes an attention layer and a feedforward network layer; The attention layer is used to take the word vector corresponding to the text as input, predict the relationship between words in the text, and output the merged word vector. The feedforward network layer is used to take the merged word vector corresponding to two texts as input and calculate the word vector similarity of the two texts.

5. The method for identifying event similarity based on a neural network hybrid model according to claim 4 is characterized in that: The feedforward neural network layer is a neural network model constructed based on a long short-term memory network.

6. A system for identifying event similarity based on a neural network hybrid model, characterized in that: It includes a model building module, a sample building module, a model training module and an event identification module; The model building module is used to perform the following: construct a word segmentation encoder based on the Chinese word segmenter, and construct an event similarity calculation model based on the neural network model, wherein the word segmentation encoder is used to perform word segmentation and encoding processing on the input text to obtain a word vector, and the event similarity calculation model is used to take the word vectors corresponding to two events as input, calculate the word vector similarity between the texts, and output a similarity score; The sample construction module is used to perform the following: collect event texts corresponding to historical events, take the event texts corresponding to each historical event as input, perform word segmentation and encoding on the event texts through a word segmentation encoder, obtain the word vectors corresponding to each historical event, take the word vectors and similarities corresponding to two events as sample data, and construct a training set based on the sample data; The model training module is used to perform the following: perform model training on the event similarity calculation model through the training set to obtain the trained event similarity calculation model; The event identification module is used to perform the following: for two events to be identified, the event text corresponding to each event is used as input, the event text is segmented and encoded through a word segmentation encoder to obtain the word vector corresponding to each event, and the word vectors corresponding to the two events are used as input, the word vector similarity between the two events is calculated through the trained event similarity calculation model, and the predicted similarity score is output, and whether the two events are the same event is determined based on the similarity score.

7. The system for identifying event similarity based on a neural network hybrid model according to claim 6, characterized in that: The word segmentation encoder includes a Chinese word segmentation module, an encoding module and a fine-tuning module; The Chinese word segmentation module is used to segment the input text to obtain multiple words; The encoding module is used to take the words output by the Chinese module as input, vectorize each word, and obtain the word vector corresponding to each word; The fine-tuning module is used to perform positioning calculation on each word vector, fine-tune the word vector to a new high-dimensional space, and obtain a new word vector.

8. The system for identifying event similarity based on a neural network hybrid model according to claim 7, characterized in that: The fine-tuning module is used to perform the following positioning calculation on the word vector output by the encoding module: Among them, PE represents, pos represents, 2i represents, d model express.

9. The system for identifying event similarity based on a neural network hybrid model according to claim 6, characterized in that: The event similarity calculation model includes an attention layer and a feedforward network layer; The attention layer is used to take the word vector corresponding to the text as input, predict the relationship between words in the text, and output the merged word vector. The feedforward network layer is used to take the merged word vector corresponding to two texts as input and calculate the word vector similarity of the two texts.

10. The system for identifying event similarity based on a neural network hybrid model according to claim 6, characterized in that: The feedforward neural network layer is a neural network model constructed based on a long short-term memory network.