Semantic similarity model evaluation method, device, equipment and storage medium

By combining the BERT model and the topic model, we evaluate and optimize the category tags and topic distribution of the semantic similarity model, which solves the problem of low semantic detection accuracy of existing models in complex application scenarios and achieves higher semantic detection accuracy and models. Excellent performance on multiple data sets.

CN113850336BActive Publication Date: 2024-09-27PING AN TECH (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111151445.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-29
Publication Date
2024-09-27
Estimated Expiration
2041-09-29

AI Technical Summary

Technical Problem

The existing semantic similarity models that have been trained have low semantic detection accuracy in complex application scenarios, and are difficult to meet the application needs of complex community question and answer and other applications.

Method used

An evaluation method that combines the BERT model and the topic model is used to obtain and process the category tags and topic distribution of the statements, calculate the similarity between statements, and determine whether the model meets the standard similarity. If not, the topic model is trained to improve Detection accuracy.

Benefits of technology

It achieves accurate evaluation of semantic similarity models, improves semantic detection accuracy in complex scenes, and performs better on multiple data sets than using the BERT model alone.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113850336B
    Figure CN113850336B
Patent Text Reader

Abstract

The present application is in the field of artificial intelligence technology, and provides a method, device, equipment and storage medium for evaluating a semantic similarity model, wherein the method comprises: inputting a first sentence and a second sentence into a BERT model respectively to obtain a first category tag and a second category tag; inputting the first category tag and the second category tag into a topic model to obtain a first topic distribution and a second topic distribution; inputting the first sentence and the second sentence into the topic model to obtain a first word topic distribution and a second word topic distribution; combining the first category tag, the second category tag and the two topic distributions to obtain a first topic; combining the first category tag, the second category tag and the two word topic distributions to obtain a second topic; if the similarity of the two topics is the same as the standard similarity, then the semantic similarity model is determined to meet the requirements, so that the semantic detection accuracy of the obtained semantic similarity model is higher.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology. Specifically, the present application relates to a method, device, equipment and storage medium for evaluating a semantic similarity model. Background Art

[0002] Semantic similarity detection is a basic task in natural language understanding and has many important application scenarios, such as semantic recall in retrieval systems. Similarity retrieval based on semantic similarity models can assist text classification and make up for the long update and iteration cycle of classification models. Semantic similarity models can also play a big role in intelligent question-answering systems.

[0003] However, when the existing trained semantic similarity models encounter some complex application scenarios such as community question answering, since community question answering needs to answer complex real-world questions, the semantic detection accuracy of the trained semantic similarity models is low. Therefore, there is an urgent need to accurately evaluate the trained semantic similarity models to cope with complex application scenarios. Summary of the invention

[0004] The main purpose of this application is to provide a method, device, equipment and storage medium for evaluating a semantic similarity model so as to accurately evaluate a trained semantic similarity model.

[0005] In order to achieve the above-mentioned invention object, the present application provides an evaluation method of a semantic similarity model, wherein the semantic similarity model includes a BERT model and a topic model, and the evaluation method includes:

[0006] Obtain a first sentence and a second sentence, input the first sentence and the second sentence into a BERT model respectively, and obtain a first category label for each word in the first sentence and a second category label for each word in the second sentence, wherein the first sentence and the second sentence are two sentences randomly selected from a database;

[0007] Inputting the first category label and the second category label into the topic model to obtain a first topic distribution of the first sentence and a second topic distribution of the second sentence;

[0008] Inputting the first sentence and the second sentence into the topic model, determining a first word topic distribution of the first sentence and a second word topic distribution of the second sentence;

[0009] Combining the first category mark, the second category mark, the first topic distribution and the second topic distribution to obtain a first topic;

[0010] Combining the first category label, the second category label, the first word topic distribution and the second word topic distribution to obtain a second topic;

[0011] Calculating the similarity between the first topic and the second topic, and determining whether the similarity is the same as a standard similarity;

[0012] If so, it is determined that the semantic similarity model meets the requirements.

[0013] Preferably, the step of determining a first word topic distribution of the first sentence and a second word topic distribution of the second sentence comprises:

[0014] Obtaining a topic distribution for each word in the first sentence;

[0015] Taking a weighted average of the topic distribution of each word in the first sentence, to obtain a first word topic distribution of the first sentence;

[0016] Obtaining a topic distribution for each word in the second sentence;

[0017] The topic distribution of each word in the second sentence is weighted averaged to obtain a second word topic distribution of the second sentence.

[0018] Preferably, the step of calculating the similarity between the first topic and the second topic includes:

[0019] Convert the first topic into a vector form to obtain a first topic vector;

[0020] Convert the second topic into a vector form to obtain a second topic vector;

[0021] The cosine distance between the first topic vector and the second topic vector is calculated, and the cosine distance is used to represent the similarity between the first topic and the second topic.

[0022] Preferably, the step of converting the first topic into a vector form to obtain a first topic vector includes:

[0023] Segment the first topic into words and number each word;

[0024] Generate a number vector of the first topic according to the word number; wherein the number vector has a fixed length and the insufficient position is filled with zero;

[0025] The number vector is used as the first topic vector.

[0026] Furthermore, after the step of determining whether the similarity is the same as the standard similarity, the method further includes:

[0027] When it is determined that the similarity is different from the standard similarity, a preset number of sentence pairs are obtained; wherein the sentence pairs include a first training sentence, a second training sentence, and the standard similarity between the first training sentence and the second training sentence;

[0028] Input the sentence pair into the topic model for training, and determine whether the training result meets the requirements;

[0029] If so, the training of the topic model is completed.

[0030] Preferably, the step of inputting the sentence pair into the topic model for training and judging whether the training result meets the requirements includes:

[0031] Performing normalization preprocessing on the sentence pairs, and using the normalized sentence pairs to establish a training set and a test set of the topic model;

[0032] Randomly extract K training samples from the training set of the topic model; wherein K is a positive integer;

[0033] Training the K training samples based on a decision tree algorithm to obtain K decision tree classification models;

[0034] Determine whether the training results of the K decision tree classification models meet the requirements;

[0035] If yes, the K decision tree classification models are combined to obtain a trained topic model.

[0036] Furthermore, before the step of inputting the first sentence and the second sentence into the BERT model respectively, the step further includes:

[0037] Preprocessing the first sentence and the second sentence; wherein the preprocessing includes removing low-frequency words, stop words and tag information of the first sentence and the second sentence.

[0038] The present application also provides an evaluation device for a semantic similarity model, wherein the semantic similarity model includes a BERT model and a topic model, and the evaluation device includes:

[0039] An acquisition module, used for acquiring a first sentence and a second sentence, inputting the first sentence and the second sentence into a BERT model respectively, and obtaining a first category label for each word in the first sentence and a second category label for each word in the second sentence, wherein the first sentence and the second sentence are two sentences randomly selected from a database;

[0040] A first input module, used for inputting the first category label and the second category label into the topic model to obtain a first topic distribution of the first sentence and a second topic distribution of the second sentence;

[0041] A second input module, used for inputting the first sentence and the second sentence into the topic model to determine a first word topic distribution of the first sentence and a second word topic distribution of the second sentence;

[0042] A first combining module, used for combining the first category mark, the second category mark, the first topic distribution and the second topic distribution to obtain a first topic;

[0043] A second combining module, configured to combine the first category mark, the second category mark, the first word topic distribution and the second word topic distribution to obtain a second topic;

[0044] A calculation module, used for calculating the similarity between the first topic and the second topic, and determining whether the similarity is the same as the standard similarity;

[0045] A determination module is used to determine if the semantic similarity model meets the requirements.

[0046] The present application also provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any one of the above methods when executing the computer program.

[0047] The present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above methods are implemented.

[0048] The present application provides a method, apparatus, device and storage medium for evaluating a semantic similarity model, which obtains a first sentence and a second sentence, inputs the first sentence and the second sentence into a BERT model respectively, obtains a first category tag for each word in the first sentence and a second category tag for each word in the second sentence; inputs the first category tag and the second category tag into a topic model to obtain a first topic distribution of the first sentence and a second topic distribution of the second sentence; inputs the first sentence and the second sentence into the topic model to determine a first word topic distribution of the first sentence and a second word topic distribution of the second sentence; and inputs the first category tag, the second category tag, the first topic distribution and the second topic distribution into the topic model. The first topic is obtained by combining the first category label, the second category label, the first word topic distribution and the second word topic distribution to obtain the second topic; the similarity between the first topic and the second topic is calculated to determine whether the similarity is the same as the standard similarity; if so, the semantic similarity model is determined to meet the requirements. Since the first topic and the second topic are consistent with each other through the topic distribution and the word topic distribution of the sentence, the semantic similarity model is accurately evaluated, so that the obtained semantic similarity model can accurately perform semantic detection on complex scenes; at the same time, the semantic similarity model combined with the topic model performs better than the BERT model on multiple data sets. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] Figure 1 A flowchart of a method for evaluating a semantic similarity model according to an embodiment of the present application;

[0050] Figure 2 A schematic block diagram of the structure of a semantic similarity model evaluation device according to an embodiment of the present application;

[0051] Figure 3 A schematic block diagram of the structure of a computer device according to an embodiment of the present application.

[0052] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0053] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0054] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0055] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0056] refer to Figure 1 The present application proposes a method for evaluating a semantic similarity model, with a server as the execution subject. The server can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), as well as big data and artificial intelligence platforms.

[0057] The evaluation method of the semantic similarity model is used to solve the technical problem that even if the semantic similarity model has been trained, the accuracy of semantic detection is low, and it is difficult to handle some complex application scenarios. It is urgent to accurately evaluate the trained semantic similarity model. In one embodiment, the semantic similarity model includes a BERT model and a topic model. The evaluation method of the semantic similarity model includes the following steps:

[0058] S11, obtaining a first sentence and a second sentence, inputting the first sentence and the second sentence into a BERT model respectively, obtaining a first category label for each word in the first sentence and a second category label for each word in the second sentence, wherein the first sentence and the second sentence are two sentences randomly selected from a database;

[0059] S12, inputting the first category label and the second category label into the topic model to obtain a first topic distribution of the first sentence and a second topic distribution of the second sentence;

[0060] S13, inputting the first sentence and the second sentence into the topic model, determining a first word topic distribution of the first sentence and a second word topic distribution of the second sentence;

[0061] S14, combining the first category mark, the second category mark, the first topic distribution and the second topic distribution to obtain a first topic;

[0062] S15, combining the first category mark, the second category mark, the first word topic distribution and the second word topic distribution to obtain a second topic;

[0063] S16, calculating the similarity between the first topic and the second topic, and determining whether the similarity is the same as the standard similarity;

[0064] S17: If yes, determine that the semantic similarity model meets the requirements.

[0065] As described in step S11 above, the first sentence and the second sentence are two sentences that need to be tested for semantic similarity. The first sentence and the second sentence can be sentences with a field length greater than a preset length and composed of multiple words. This step uses the BERT model to test the first sentence. (length N), the second statement (length is M) to encode, obtain the first category tag of each word in the first sentence and the second category tag of each word in the second sentence, and the encoded result is expressed as:

[0066] ;

[0067] Among them, the is the output of the BERT model corresponding to the CLS tag in the input of the vector corresponding to the first sentence and the second sentence, Indicates the internal hidden layer size of the BERT model, which is generally 768. It is a constant and can be customized.

[0068] The first category mark may be the part-of-speech category of each word in the first sentence to distinguish the words in the first sentence, and may also include a category mark for marking the first word and the last word in the first sentence. Similarly, the second category mark may be the part-of-speech category of each word in the second sentence to distinguish the words in the second sentence, and may also include a category mark for marking the first word and the last word in the second sentence.

[0069] Specifically, the words corresponding to the entity information in the first sentence or the second sentence may be marked as entity tags; the words corresponding to the virtual information in the first sentence or the second sentence may be marked as virtual tags, and the virtual information may include modal particles, auxiliary words, etc. In addition, the entity tags and the virtual tags are separated by a preset symbol.

[0070] Among them, the BERT model is a bidirectional encoder representation based on Transformer, that is, the foundation of the BERT model is Transformer. When processing a word, the BERT model can take into account the information of the words before and after the word, thereby obtaining the semantics of the context.

[0071] The topic model is a statistical model that clusters the implicit semantic structure of sentences in an unsupervised learning manner. The topic model believes that there is no direct connection between words and sentences, and they should have a dimension to connect them in series. The topic model calls this dimension a topic. In addition, each sentence should correspond to one or more topics, and each topic will have a corresponding word distribution. Through the topic model, the word distribution of each sentence can be obtained.

[0072] As described in step S12 above, all first category tags in the first sentence and all second category tags in the second sentence are passed to the topic model to infer the topic distribution of the first sentence and the second sentence respectively, and obtain the first topic distribution of the first sentence and the second topic distribution of the second sentence. Wherein, the first topic distribution is the position distribution of the topic information in the first sentence, and the topic information can be a subject, a predicate, a verb, and some words used in a specific scene; when the topic information is an entity word with substantial meaning, the first category tag can be used to mark the position of the topic information in the first sentence, for example, when the first word of the first sentence has topic information, it is marked with the CLS tag of the first word. Similarly, the second topic distribution is the position distribution of the topic information in the second sentence, and the topic information can also be a subject, a predicate, a verb, and some words used in a specific scene; when the topic information is an entity word with substantial meaning, the second category tag can be used to mark the position of the topic information in the second sentence.

[0073] Furthermore, this step specifically includes the following formula:

[0074] ;

[0075] ;

[0076] Among them, the For the first sentence The first topic distribution, the For the second statement The second topic distribution is is the first category marker for the first sentence, is the second category marker for the second sentence, Indicates the number of topics.

[0077] As described in step S13 above, in this step, the first sentence and the second sentence can be input into the topic model to determine the first word topic distribution of the first sentence and the second word topic distribution of the second sentence; wherein the first word topic distribution is the position distribution of the words representing the topic in the first sentence, and the second word topic distribution is the position distribution of the words representing the topic in the second sentence. In addition, the words representing the topic in the first sentence can be marked with the first category mark to obtain the first word topic distribution of the first sentence; the words representing the topic in the second sentence can be marked with the second category mark to obtain the second word topic distribution of the second sentence, which is specifically calculated by the following formula:

[0078] ;

[0079] in, is the word topic distribution, represents the number of topics, It is a constant and can be customized.

[0080] As described in the above steps S14-S15, the first category tag and the second category tag output by the BERT model are respectively combined with the first topic distribution and the second topic distribution to obtain the first topic. When combining, the first category tag, the second category tag, the first topic distribution and the second topic distribution can be spliced ​​randomly or in a preset splicing order to obtain the first topic; at the same time, the first category tag and the second category tag output by the BERT model are respectively combined with the first word topic distribution and the second word topic distribution to obtain the second topic.

[0081] Among them, steps S14-S15 specifically include the following formula:

[0082] ;

[0083] ;

[0084] in, Indicates the first topic, represents the second topic, and C is the output of the BERT model and , represents the first category mark, Indicates the second category mark, For the first sentence The first topic distribution, the For the second statement The second topic distribution, For the first sentence The first word topic distribution of For the second statement The second word topic distribution of, “;” indicates a connection, such as Indicates the number of topics.

[0085] As described in the above steps S16-S17, this step can extract the keywords of the first topic and the keywords of the second topic, and calculate the similarity between the first topic and the second topic based on the keywords of the first topic and the keywords of the second topic; in addition, the first topic and the second topic can be directly converted into vector form using a vector tool, and the similarity between the first topic and the second topic can be calculated through the vector, and then it can be determined whether the similarity is the same as the standard similarity, where the standard similarity is the similarity that has been manually determined between the first sentence and the second sentence.

[0086] The present application provides an evaluation method for a semantic similarity model, which comprises obtaining a first sentence and a second sentence, inputting the first sentence and the second sentence into a BERT model respectively, obtaining a first category tag for each word in the first sentence and a second category tag for each word in the second sentence; inputting the first category tag and the second category tag into a topic model, obtaining a first topic distribution of the first sentence and a second topic distribution of the second sentence; inputting the first sentence and the second sentence into the topic model, determining a first word topic distribution of the first sentence and a second word topic distribution of the second sentence; and summarizing the first category tag, the second category tag, the first topic distribution and the second topic distribution. Combine to obtain the first topic; combine the first category label, the second category label, the first word topic distribution and the second word topic distribution to obtain the second topic; calculate the similarity between the first topic and the second topic, and determine whether the similarity is the same as the standard similarity; if so, determine that the semantic similarity model meets the requirements. Since the first topic and the second topic are consistent by judging whether the topic distribution and the word topic distribution of the sentence are consistent, the semantic similarity model can be accurately evaluated, so that the obtained semantic similarity model can accurately perform semantic detection on complex scenes; at the same time, the semantic similarity model combined with the topic model performs better than the BERT model on multiple data sets.

[0087] In one embodiment, in step S13, the step of determining the first word topic distribution of the first sentence and the second word topic distribution of the second sentence may specifically include:

[0088] S131, obtaining the topic distribution of each word in the first sentence;

[0089] S132, performing weighted averaging on the topic distribution of each word in the first sentence to obtain a first word topic distribution of the first sentence;

[0090] S133, obtaining the topic distribution of each word in the second sentence;

[0091] S134. Perform weighted averaging on the topic distribution of each word in the second sentence to obtain a second word topic distribution of the second sentence.

[0092] In this embodiment, the topic distribution of each word in the first sentence can be obtained, the topic distribution of each word in the second sentence can be obtained, and then the obtained Perform weighted averaging respectively to obtain the topic representation of a fixed-length sentence, which can be obtained by the following formula:

[0093] ;

[0094] ;

[0095] in, For the first sentence The first word topic distribution of For the second statement The second word topic distribution of For the first sentence The topic distribution of each word in For the second statement The topic distribution of each word in, N is the first sentence M is the first statement , t is the number of topics.

[0096] In one embodiment, in step S16, the step of calculating the similarity between the first topic and the second topic may specifically include:

[0097] S161, converting the first topic into a vector form to obtain a first topic vector;

[0098] S162, converting the second topic into a vector form to obtain a second topic vector;

[0099] S163. Calculate the cosine distance between the first topic vector and the second topic vector, and use the cosine distance to represent the similarity between the first topic and the second topic.

[0100] In this embodiment, a vector tool may be used to convert the first topic and the second topic into vector form to obtain a first topic vector of the first topic and a second topic vector of the second topic, and then the cosine distance between the first topic vector and the second topic vector is calculated to determine the similarity between the first topic and the second topic.

[0101] In addition, when the first topic and the second topic are both sentences, the first topic and the second topic can be converted into sentence vectors for similarity calculation, which is not specifically limited here.

[0102] In one embodiment, in step S161, the step of converting the first topic into a vector form to obtain a first topic vector may specifically include:

[0103] Segment the first topic into words and number each word;

[0104] Generate a number vector of the first topic according to the word number; wherein the number vector has a fixed length and the insufficient position is filled with zero;

[0105] The number vector is used as the first topic vector.

[0106] In this embodiment, when the first topic is a sentence, the first topic can be segmented to obtain multiple words, and each word can be numbered in sequence according to the order of each word in the sentence, and a number vector of the first topic is generated according to the word numbering, wherein when numbering, a unique hot encoding method can be used, for example, the words with substantial meaning in the first topic are numbered as 1, and the remaining words without substantial meaning are numbered as 0, thereby generating a number vector of the first topic. In addition, the length of the number vector of this embodiment is a fixed length, so when the length of the number vector is less than the fixed length, a method of padding the end of the number vector with zeros is adopted to make the length of the number vector consistent with the fixed length.

[0107] Similarly, the transformation method of the second theme vector can also be properly achieved through the above method, which will not be described in detail here.

[0108] In one embodiment, after the step of determining whether the similarity is the same as the standard similarity, the following steps may also be performed:

[0109] When it is determined that the similarity is different from the standard similarity, a preset number of sentence pairs are obtained; wherein the sentence pairs include a first training sentence, a second training sentence, and the standard similarity between the first training sentence and the second training sentence;

[0110] Input the sentence pair into the topic model for training, and determine whether the training result meets the requirements;

[0111] If so, the training of the topic model is completed.

[0112] In this embodiment, when it is determined that the similarity between the first topic and the second topic is different from the standard similarity, the semantic similarity model needs to be retrained. During the training, a preset number of sentence pairs are obtained, and the sentence pairs include the first training sentence, the second training sentence, and the standard similarity between the first training sentence and the second training sentence. The standard similarity is the similarity determined manually. Then the sentence pairs are input into the topic model for N rounds of training, and the loss value of the topic model after each training is calculated to determine whether the loss value is lower than the preset value. If so, it is determined that the training result meets the requirements. At this time, the topic model that has completed the training is obtained, so that the semantic similarity model obtained by training has a higher semantic detection accuracy.

[0113] In one embodiment, the step of inputting the sentence pair into the topic model for training and determining whether the training result meets the requirements may specifically include:

[0114] Performing normalization preprocessing on the sentence pairs, and using the normalized sentence pairs to establish a training set and a test set of the topic model;

[0115] Randomly extract K training samples from the training set of the topic model; wherein K is a positive integer;

[0116] Training the K training samples based on a decision tree algorithm to obtain K decision tree classification models;

[0117] Determine whether the training results of the K decision tree classification models meet the requirements;

[0118] If yes, the K decision tree classification models are combined to obtain a trained topic model.

[0119] In this embodiment, training samples are randomly pulled from the training set at regular intervals, and a part of the newly added decision tree classification models are trained based on the training samples. For example, the trained topic model is composed of 300 decision tree classification models. Then, 150 new decision tree classification models can be trained each time it is updated. Then, all the decision tree classification models (i.e., 450 decision tree classification models) are verified to obtain the classification effect of each decision tree classification model. Then, 300 decision tree classification models are selected from all the decision tree classification models, and the 300 decision tree classification models are combined to obtain a new topic model, so as to update the topic model in real time, so that the updated topic model has higher accuracy in semantic detection.

[0120] Furthermore, before the step of inputting the first sentence and the second sentence into the BERT model respectively, the step further includes:

[0121] Preprocessing the first sentence and the second sentence; wherein the preprocessing includes removing low-frequency words, stop words and tag information of the first sentence and the second sentence.

[0122] Among them, preprocessing is the basis of text processing. The preprocessing can adopt one or more of the word segmentation methods based on string matching, the word segmentation method based on understanding and the word segmentation method based on statistics to remove low-frequency words, stop words and marking information of the first sentence and the second sentence, thereby reducing the processing of meaningless words and improving processing efficiency. Stop words mainly include function words, which can be conjunctions, prepositions, auxiliary words, modal particles, etc., and sometimes pronouns, several times, etc. These function words usually have no clear meaning by themselves, and only have a certain effect when they are placed in a complete sentence, such as "oh", "um", "of", "ah", "this", etc. Low-frequency words are words that appear less frequently in the first sentence or the second sentence, and the marking information is a mark for the first sentence, such as annotation information.

[0123] Reference Figure 2 In an embodiment of the present application, a device for evaluating a semantic similarity model is also provided, wherein the semantic similarity model includes a BERT model and a topic model, and the evaluation device includes:

[0124] An acquisition module 11 is used to acquire a first sentence and a second sentence, and input the first sentence and the second sentence into a BERT model respectively to obtain a first category label for each word in the first sentence and a second category label for each word in the second sentence, wherein the first sentence and the second sentence are two sentences randomly selected from a database;

[0125] A first input module 12, used for inputting the first category label and the second category label into the topic model to obtain a first topic distribution of the first sentence and a second topic distribution of the second sentence;

[0126] A second input module 13, used for inputting the first sentence and the second sentence into the topic model to determine a first word topic distribution of the first sentence and a second word topic distribution of the second sentence;

[0127] A first combining module 14 is used to combine the first category mark, the second category mark, the first topic distribution and the second topic distribution to obtain a first topic;

[0128] A second combining module 15 is used to combine the first category mark, the second category mark, the first word topic distribution and the second word topic distribution to obtain a second topic;

[0129] A calculation module 16, used to calculate the similarity between the first theme and the second theme, and determine whether the similarity is the same as the standard similarity;

[0130] The determination module 17 is used to determine that if yes, the semantic similarity model meets the requirements. The first sentence and the second sentence are two sentences that need to be tested for semantic similarity. The first sentence and the second sentence can be sentences with a field length greater than a preset length and composed of multiple words. This step uses the BERT model to test the first sentence. (length N), the second statement (length is M) to encode, obtain the first category tag of each word in the first sentence and the second category tag of each word in the second sentence, and the encoded result is expressed as:

[0131] ;

[0132] Among them, the is the output of the BERT model corresponding to the CLS tag in the input of the vector corresponding to the first sentence and the second sentence, Indicates the internal hidden layer size of the BERT model, which is generally 768. It is a constant and can be customized.

[0133] The first category mark may be the part-of-speech category of each word in the first sentence to distinguish the words in the first sentence, and may also include a category mark for marking the first word and the last word in the first sentence. Similarly, the second category mark may be the part-of-speech category of each word in the second sentence to distinguish the words in the second sentence, and may also include a category mark for marking the first word and the last word in the second sentence.

[0134] Specifically, the words corresponding to the entity information in the first sentence or the second sentence may be marked as entity tags; the words corresponding to the virtual information in the first sentence or the second sentence may be marked as virtual tags, and the virtual information may include modal particles, auxiliary words, etc. In addition, the entity tags and the virtual tags are separated by a preset symbol.

[0135] Among them, the BERT model is a bidirectional encoder representation based on Transformer, that is, the foundation of the BERT model is Transformer. When processing a word, the BERT model can take into account the information of the words before and after the word, thereby obtaining the semantics of the context.

[0136] The topic model is a statistical model that clusters the implicit semantic structure of sentences in an unsupervised learning manner. The topic model believes that there is no direct connection between words and sentences, and they should have a dimension to connect them in series. The topic model calls this dimension a topic. In addition, each sentence should correspond to one or more topics, and each topic will have a corresponding word distribution. Through the topic model, the word distribution of each sentence can be obtained.

[0137] The device also passes all first category tags in the first sentence and all second category tags in the second sentence to the topic model to infer the topic distribution of the first sentence and the second sentence respectively, and obtains the first topic distribution of the first sentence and the second topic distribution of the second sentence. The first topic distribution is the position distribution of the topic information in the first sentence, and the topic information can be a subject, a predicate, a verb, and some words used in a specific scene; when the topic information is an entity word with substantial meaning, the first category tag can be used to mark the position of the topic information in the first sentence, for example, when the first word of the first sentence has topic information, it is marked with the CLS tag of the first word. Similarly, the second topic distribution is the position distribution of the topic information in the second sentence, and the topic information can also be a subject, a predicate, a verb, and some words used in a specific scene; when the topic information is an entity word with substantial meaning, the second category tag can be used to mark the position of the topic information in the second sentence.

[0138] Furthermore, the specific formula includes the following:

[0139] ;

[0140] ;

[0141] Among them, the For the first sentence The first topic distribution, the For the second statement The second topic distribution is is the first category marker for the first sentence, is the second category marker for the second sentence, Indicates the number of topics.

[0142] In addition, the first sentence and the second sentence can also be input into the topic model to determine the first word topic distribution of the first sentence and the second word topic distribution of the second sentence; wherein the first word topic distribution is the position distribution of the words representing the topic in the first sentence, and the second word topic distribution is the position distribution of the words representing the topic in the second sentence. In addition, the words representing the topic in the first sentence can be marked with the first category tag to obtain the first word topic distribution of the first sentence; the words representing the topic in the second sentence can be marked with the second category tag to obtain the second word topic distribution of the second sentence, which is specifically calculated by the following formula:

[0143] ;

[0144] in, is the word topic distribution, represents the number of topics, It is a constant and can be customized.

[0145] Furthermore, the first category tag and the second category tag output by the BERT model are respectively combined with the first topic distribution and the second topic distribution to obtain the first topic. When combining, the first category tag, the second category tag, the first topic distribution and the second topic distribution can be spliced ​​randomly or in a preset splicing order to obtain the first topic; at the same time, the first category tag and the second category tag output by the BERT model are respectively combined with the first word topic distribution and the second word topic distribution to obtain the second topic.

[0146] Among them, steps S14-S15 specifically include the following formula:

[0147] ;

[0148] ;

[0149] in, Indicates the first topic, represents the second topic, and C is the output of the BERT model represents the first category mark, Indicates the second category mark, For the first sentence The first topic distribution, the For the second statement The second topic distribution, For the first sentence The first word topic distribution of For the second statement The second word topic distribution of, “;” indicates a connection, such as Indicates the number of topics.

[0150] Finally, the keywords of the first topic and the keywords of the second topic can be extracted, and the similarity between the first topic and the second topic can be calculated based on the keywords of the first topic and the keywords of the second topic; in addition, the first topic and the second topic can be directly converted into vector form using a vector tool, and the similarity between the first topic and the second topic can be calculated through the vector, and then it can be determined whether the similarity is the same as the standard similarity, where the standard similarity is the manually determined similarity between the first sentence and the second sentence.

[0151] As described above, it can be understood that the various components of the semantic similarity model evaluation device proposed in the present application can realize the functions of any one of the semantic similarity model evaluation methods described above, and the specific structure will not be repeated.

[0152] Reference Figure 3 In the embodiment of the present application, a computer device is also provided, whose internal structure can be as follows Figure 3 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor designed by the computer is used to provide computing and control capabilities. The memory of the computer device includes a storage medium and an internal memory. The storage medium stores an operating system, a computer program and a database. The memory provides an environment for the operation of the operating system and the computer program in the storage medium. The database of the computer device is used to store data such as resumes and historical company names. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for evaluating a semantic similarity model is implemented.

[0153] The processor executes the evaluation method of the semantic similarity model, wherein the semantic similarity model includes a BERT model and a topic model. The evaluation method includes:

[0154] Obtain a first sentence and a second sentence, input the first sentence and the second sentence into a BERT model respectively, and obtain a first category label for each word in the first sentence and a second category label for each word in the second sentence, wherein the first sentence and the second sentence are two sentences randomly selected from a database;

[0155] Inputting the first category label and the second category label into the topic model to obtain a first topic distribution of the first sentence and a second topic distribution of the second sentence;

[0156] Inputting the first sentence and the second sentence into the topic model, determining a first word topic distribution of the first sentence and a second word topic distribution of the second sentence;

[0157] Combining the first category mark, the second category mark, the first topic distribution and the second topic distribution to obtain a first topic;

[0158] Combining the first category label, the second category label, the first word topic distribution and the second word topic distribution to obtain a second topic;

[0159] Calculating the similarity between the first topic and the second topic, and determining whether the similarity is the same as a standard similarity;

[0160] If so, it is determined that the semantic similarity model meets the requirements.

[0161] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, a method for evaluating a semantic similarity model is implemented. The semantic similarity model includes a BERT model and a topic model. The evaluation method includes the steps of:

[0162] Obtain a first sentence and a second sentence, input the first sentence and the second sentence into a BERT model respectively, and obtain a first category label for each word in the first sentence and a second category label for each word in the second sentence, wherein the first sentence and the second sentence are two sentences randomly selected from a database;

[0163] Inputting the first category label and the second category label into the topic model to obtain a first topic distribution of the first sentence and a second topic distribution of the second sentence;

[0164] Inputting the first sentence and the second sentence into the topic model, determining a first word topic distribution of the first sentence and a second word topic distribution of the second sentence;

[0165] Combining the first category mark, the second category mark, the first topic distribution and the second topic distribution to obtain a first topic;

[0166] Combining the first category label, the second category label, the first word topic distribution and the second word topic distribution to obtain a second topic;

[0167] Calculating the similarity between the first topic and the second topic, and determining whether the similarity is the same as a standard similarity;

[0168] If so, it is determined that the semantic similarity model meets the requirements.

[0169] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media provided in this application and used in the embodiments may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double-speed data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0170] In summary, the greatest beneficial effects of this application are:

[0171] The present application provides a method, apparatus, device and storage medium for evaluating a semantic similarity model, which obtains a first sentence and a second sentence, inputs the first sentence and the second sentence into a BERT model respectively, obtains a first category tag for each word in the first sentence and a second category tag for each word in the second sentence; inputs the first category tag and the second category tag into a topic model to obtain a first topic distribution of the first sentence and a second topic distribution of the second sentence; inputs the first sentence and the second sentence into the topic model to determine a first word topic distribution of the first sentence and a second word topic distribution of the second sentence; inputs the first category tag, the second category tag, the first topic distribution and the second topic distribution into the topic model to obtain a first topic distribution of the first sentence and a second word topic distribution of the second sentence; The first topic distribution is combined to obtain the first topic; the first category label, the second category label, the first word topic distribution and the second word topic distribution are combined to obtain the second topic; the similarity between the first topic and the second topic is calculated, and it is determined whether the similarity is the same as the standard similarity; if so, it is determined that the semantic similarity model meets the requirements. Since the first topic and the second topic are judged to be consistent through the topic distribution of the sentence and the word topic distribution, the semantic similarity model is accurately evaluated, so that the obtained semantic similarity model can accurately perform semantic detection on complex scenes; at the same time, the semantic similarity model combined with the topic model performs better than the BERT model on multiple data sets.

[0172] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, device, article or method including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, device, article or method. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the existence of other identical elements in the process, device, article or method including the element.

[0173] The above description is only a preferred embodiment of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A method for evaluating a semantic similarity model, characterized in that: The semantic similarity model includes a BERT model and a topic model; the evaluation method includes: Obtain a first sentence and a second sentence, input the first sentence and the second sentence into a BERT model respectively, and obtain a first category label for each word in the first sentence and a second category label for each word in the second sentence, wherein the first sentence and the second sentence are two sentences randomly selected from a database; Inputting the first category label and the second category label into the topic model to obtain a first topic distribution of the first sentence and a second topic distribution of the second sentence; Inputting the first sentence and the second sentence into the topic model, determining a first word topic distribution of the first sentence and a second word topic distribution of the second sentence; Combining the first category mark, the second category mark, the first topic distribution and the second topic distribution to obtain a first topic; Combining the first category label, the second category label, the first word topic distribution and the second word topic distribution to obtain a second topic; Calculating the similarity between the first topic and the second topic, and determining whether the similarity is the same as a standard similarity, where the standard similarity is a manually determined similarity between the first sentence and the second sentence; If so, it is determined that the semantic similarity model meets the requirements.

2. The method according to claim 1, characterized in that The step of determining a first word topic distribution of the first sentence and a second word topic distribution of the second sentence comprises: Obtaining a topic distribution for each word in the first sentence; Taking a weighted average of the topic distribution of each word in the first sentence, to obtain a first word topic distribution of the first sentence; Obtaining a topic distribution for each word in the second sentence; The topic distribution of each word in the second sentence is weighted averaged to obtain a second word topic distribution of the second sentence.

3. The method according to claim 1, characterized in that The step of calculating the similarity between the first topic and the second topic includes: Convert the first topic into a vector form to obtain a first topic vector; Convert the second topic into a vector form to obtain a second topic vector; The cosine distance between the first topic vector and the second topic vector is calculated, and the cosine distance is used to represent the similarity between the first topic and the second topic.

4. The method according to claim 3, characterized in that The step of converting the first topic into a vector form to obtain a first topic vector includes: Segment the first topic into words and number each word; Generate a number vector of the first topic according to the word number; wherein the number vector has a fixed length and the insufficient position is filled with zero; The number vector is used as the first topic vector.

5. The method according to claim 1, characterized in that After the step of determining whether the similarity is the same as the standard similarity, the method further includes: When it is determined that the similarity is different from the standard similarity, a preset number of sentence pairs are obtained; wherein the sentence pairs include a first training sentence, a second training sentence, and the standard similarity between the first training sentence and the second training sentence; Input the sentence pair into the topic model for training, and determine whether the training result meets the requirements; If so, the training of the topic model is completed.

6. The method according to claim 5, characterized in that The step of inputting the sentence pair into the topic model for training and judging whether the training result meets the requirements includes: Performing normalization preprocessing on the sentence pairs, and using the normalized sentence pairs to establish a training set and a test set of the topic model; Randomly extract K training samples from the training set of the topic model; wherein K is a positive integer; Training the K training samples based on a decision tree algorithm to obtain K decision tree classification models; Determine whether the training results of the K decision tree classification models meet the requirements; If yes, the K decision tree classification models are combined to obtain a trained topic model.

7. The method according to claim 1, characterized in that Before the step of inputting the first sentence and the second sentence into the BERT model respectively, the method further includes: Preprocessing the first sentence and the second sentence; wherein the preprocessing includes removing low-frequency words, stop words and tag information of the first sentence and the second sentence.

8. An evaluation device for a semantic similarity model, wherein the semantic similarity model comprises a BERT model and a topic model, characterized in that: The evaluation device comprises: An acquisition module, used for acquiring a first sentence and a second sentence, inputting the first sentence and the second sentence into a BERT model respectively, and obtaining a first category label for each word in the first sentence and a second category label for each word in the second sentence, wherein the first sentence and the second sentence are two sentences randomly selected from a database; A first input module, used for inputting the first category label and the second category label into the topic model to obtain a first topic distribution of the first sentence and a second topic distribution of the second sentence; A second input module, used for inputting the first sentence and the second sentence into the topic model to determine a first word topic distribution of the first sentence and a second word topic distribution of the second sentence; A first combining module, used for combining the first category mark, the second category mark, the first topic distribution and the second topic distribution to obtain a first topic; A second combining module, configured to combine the first category mark, the second category mark, the first word topic distribution and the second word topic distribution to obtain a second topic; A calculation module, used to calculate the similarity between the first topic and the second topic, and determine whether the similarity is the same as a standard similarity, where the standard similarity is a manually determined similarity between the first sentence and the second sentence; A determination module is used to determine if the semantic similarity model meets the requirements.

9. A computer device, characterized in that: include: processor; Memory; A computer program, wherein the computer program is stored in the memory and configured to be executed by the processor, and the computer program is configured to execute the method for evaluating the semantic similarity model according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the method for evaluating the semantic similarity model according to any one of claims 1 to 7.