Document retrieval method, device, equipment and medium based on BM25 algorithm

By using the natural language processing model in the BM25 algorithm to predict the importance of word segmentation and combining contextual semantic information for document retrieval, the problem of low recall accuracy of the BM25 algorithm is solved and the accuracy of document retrieval is significantly improved.

CN114490949BActive Publication Date: 2024-10-29PING AN TECH (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210151143.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-14
Publication Date
2024-10-29
Estimated Expiration
2042-02-14

AI Technical Summary

Technical Problem

The document retrieval method based on the BM25 algorithm does not consider the contextual semantic information of the user input question when judging the importance of word segmentation, resulting in a low recall accuracy.

Method used

By receiving the business questions input by the user, input them into the pre-trained natural language processing model to obtain the importance prediction results of word segmentation, and based on these results and the BM25 algorithm to process the similarity score of the candidate documents, consider the contextual semantic information for recall processing .

Benefits of technology

It improves the accuracy of document recall, overcomes the limitations of the BM25 algorithm that only judges importance based on word segmentation frequency, and enhances the accuracy of retrieval results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114490949B_ABST
    Figure CN114490949B_ABST
Patent Text Reader

Abstract

The present application relates to the field of artificial intelligence technology. The embodiments of the present application provide a document retrieval method, device, electronic device and storage medium based on the BM25 algorithm. The method includes: inputting the question text into a pre-trained first natural language processing model to predict the importance of each word segment in the question text by using the ability of the first natural language processing model to perceive contextual semantic information; then processing the importance prediction results of each word segment output by the first natural language processing model based on the BM25 algorithm to obtain the similarity score between each candidate document and the question text, and obtaining the recalled document according to the similarity score, and pushing the recalled document to the user as a document retrieval result. The present application takes into account the contextual semantic information of the question text in the process of obtaining the similarity score, overcomes the limitation of the typical BM25 algorithm that only judges the importance of the word segment based on the word frequency of the word segment, and improves the accuracy of document recall.
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, and in particular to a document retrieval method, device, electronic device and storage medium based on the BM25 algorithm. Background Art

[0002] The BM25 algorithm is a classic retrieval algorithm used to evaluate the relevance between search terms (user-entered questions) and documents. It is based on a probabilistic retrieval model. The key idea behind the typical BM25 algorithm is to segment the question sentence and calculate word frequency information (i.e., the frequency of a word's occurrence in each document). This frequency is used to determine word importance, while also employing various adjustable factors for recall. This approach fails to consider the contextual semantics of the user's question. In practice, the same word may have different importance in different contexts, resulting in low recall accuracy for the BM25 algorithm. Summary of the Invention

[0003] The main purpose of the embodiments of the present application is to propose a document retrieval method, device, electronic device and storage medium based on the BM25 algorithm, aiming to improve the accuracy of document recall.

[0004] To achieve the above objectives, a first aspect of an embodiment of the present application proposes a document retrieval method based on the BM25 algorithm, the method comprising:

[0005] Receive business questions input by users and obtain question text;

[0006] Inputting the question text into a pre-trained first natural language processing model to obtain an importance prediction result of each word in the question text through the first natural language processing model;

[0007] Acquire a plurality of preset candidate documents and document parameters of each candidate document;

[0008] For each candidate document, the document parameters of the candidate document and the importance prediction results of each word in the question text are processed based on the BM25 algorithm to obtain a similarity score between the candidate document and the question text;

[0009] Recalling the candidate documents according to the similarity scores to obtain recalled documents;

[0010] The recalled document is pushed to the user as a document retrieval result.

[0011] According to the document retrieval method provided in some embodiments of the present application, the pre-training process of the first natural language processing model includes:

[0012] Constructing a first training sample set, wherein the first training sample set includes a plurality of first training samples, each of the first training samples includes a first sample question text and a first label set, the first label set includes a first label for each word in the first sample question text, the first label being used to represent the importance of the word in the sentence of the first sample question text;

[0013] Inputting the first sample question text in each of the first training samples into the first natural language processing model to obtain a set of importance prediction results of the first training samples;

[0014] Determining a first loss value of the first natural language processing model based on the importance prediction result set of each of the first training samples and the first label set;

[0015] When the first loss value satisfies a preset first training end condition, ending the pre-training process of the first natural language processing model;

[0016] When the first loss value does not meet the preset first training end condition, the model parameters of the first natural language processing model are adjusted, and the adjusted model is continued to be pre-trained based on the first training sample set.

[0017] According to the document retrieval method provided in some embodiments of the present application, the first natural language processing model includes an encoder representation-whole-word masking Bert-wwm layer and a fully connected layer, the Bert-wwm layer is used to output a word vector semantic sequence based on the first sample question text, and the fully connected layer is used to output the importance prediction results of each word segmentation based on the word vector semantic sequence.

[0018] According to the document retrieval method provided in some embodiments of the present application, the output of the fully connected layer is a sequence of importance prediction results, the importance prediction results of each word in the first sample question text are obtained according to the sequence of importance prediction results, and the importance prediction results of each word constitute the importance prediction result set.

[0019] According to the document retrieval method provided in some embodiments of the present application, for each candidate document, the document parameters of the candidate document and the importance prediction results of each word in the question text are processed based on the BM25 algorithm to obtain a similarity score between the candidate document and the question text, which is achieved by the following formula:

[0020]

[0021] in, Represents the similarity score between the dth candidate document among all candidate documents and the question text Q; Represent the i-th word in the question text Q; Characterizing the first natural language processing model for word segmentation The importance of the output prediction results; Characterize the segmentation The frequency of occurrence in all candidate documents; dl represents the length of the d-th candidate document; avgdl represents the average length of all candidate documents; and b are adjustment factors.

[0022] According to the document retrieval method provided in some embodiments of the present application, the number of candidate documents is M, where M is an integer greater than 1;

[0023] The recalling of the candidate documents according to the similarity scores to obtain the recalled documents includes:

[0024] J candidate documents with the highest similarity scores are selected from the M candidate documents as recalled documents, where J is an integer greater than 1 and less than M.

[0025] According to the document retrieval method provided in some embodiments of the present application, after selecting J candidate documents with the highest similarity scores from the M candidate documents as recalled documents, the method further includes:

[0026] Use the pre-trained second natural language processing model to predict the scores of J recalled documents respectively and obtain the score of each recalled document;

[0027] The J recalled documents are sorted based on the score of each recalled document, so as to push the sorted J recalled documents to the user as document retrieval results.

[0028] According to the document retrieval method provided in some embodiments of the present application, the pre-training process of the second natural language processing model includes:

[0029] Constructing a second training sample set, the second training sample set including a plurality of second training samples, each second training sample including a second sample question text, a plurality of sample documents, and a second label set, the second label set including a labeling score of each sample document;

[0030] The following first pre-training process is performed based on the second training sample set:

[0031] splicing the second sample question text in each second training sample with multiple sample documents, and inputting the result into the second natural language processing model to obtain a set of prediction scores for each second training sample;

[0032] Determining a second loss value of the second natural language processing model based on the prediction score set and the second label set of each second training sample;

[0033] When the second loss value satisfies a preset second training end condition, ending the first pre-training process;

[0034] When the second loss value does not meet the preset second training end condition, the model parameters of the second natural language processing model are adjusted, and the first pre-training process is continued on the adjusted model based on the second training sample set.

[0035] According to the document retrieval method provided in some embodiments of the present application, each of the second training samples further includes a third label set, wherein the third label set includes a second annotation label for each sample document, and the second annotation label is used to characterize the relevance between the sample document and the second sample question text;

[0036] Before the first pre-training process, the pre-training process of the second natural language processing model further includes performing the following second pre-training process based on the second training sample set:

[0037] splicing the second sample question text in each second training sample with multiple sample documents, and inputting the result into the second natural language processing model to obtain a set of relevance prediction results for each second training sample;

[0038] Determining a third loss value of the second natural language processing model according to the relevance prediction result set and the third label set of each second training sample;

[0039] When the third loss value satisfies a preset third training end condition, ending the second pre-training process of the second natural language processing model;

[0040] When the third loss value does not meet the preset third training end condition, the model parameters of the second natural language processing model are adjusted, and the second pre-training process is continued on the adjusted model based on the second training sample set.

[0041] According to the document retrieval method provided by some embodiments of the present application, the sample documents in each of the second training samples include a plurality of positive sample documents, and the positive sample documents have the highest annotation score;

[0042] The first pre-training process includes a forward training process, and the forward training process includes:

[0043] splicing the second sample question text in each second training sample with multiple positive sample documents, and inputting the result into the second natural language processing model to obtain a set of positive prediction scores for each second training sample;

[0044] Determining a forward loss value of the second natural language processing model based on the forward prediction score set of each second training sample and the highest annotation score;

[0045] When the forward loss value satisfies a preset forward training end condition, ending the forward training process;

[0046] When the forward loss value does not meet the preset forward training end condition, the model parameters of the second natural language processing model are adjusted, and the forward training process is continued on the adjusted model based on the second training sample set.

[0047] According to the document retrieval method provided by some embodiments of the present application, the sample documents in each of the second training samples include a plurality of negative sample documents, and the negative sample documents have the lowest annotation score;

[0048] The first pre-training process further includes a negative training process, and the negative training process includes:

[0049] splicing the second sample question text in each second training sample with a plurality of negative sample documents, and inputting the concatenated documents into the second natural language processing model to obtain a set of negative prediction scores for each second training sample;

[0050] Determining a negative loss value of the second natural language processing model based on the set of negative prediction scores of each second training sample and the lowest annotation score;

[0051] When the negative loss value meets the preset negative training end condition, end the negative training process;

[0052] When the negative loss value does not meet the preset negative training end condition, the model parameters of the second natural language processing model are adjusted, and the negative training process is continued on the adjusted model based on the second training sample set.

[0053] According to the document retrieval method provided in some embodiments of the present application, the use of the pre-trained second natural language processing model to perform score prediction on J recalled documents to obtain a score for each recalled document includes:

[0054] After the question text and J recalled documents are spliced ​​together, they are input into the second natural language processing model to obtain a set of predicted scores for the recalled documents, and the score of each recalled document is determined from the set of predicted scores.

[0055] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application proposes a document retrieval device based on the BM25 algorithm, the device comprising:

[0056] The receiving module is used to receive the business questions input by the user and obtain the question text;

[0057] A first processing module is configured to input the question text into a pre-trained first natural language processing model to obtain an importance prediction result of each word in the question text through the first natural language processing model;

[0058] A second processing module is configured to obtain a plurality of preset candidate documents and document parameters of each candidate document, and for each candidate document, process the document parameters of the candidate document and the importance prediction result of each word in the question text based on the BM25 algorithm to obtain a similarity score between the candidate document and the question text;

[0059] A recall module, configured to recall the candidate documents according to the similarity scores to obtain recalled documents;

[0060] A push module is used to push the recalled document as a document retrieval result to the user.

[0061] To achieve the above-mentioned purpose, the third aspect of an embodiment of the present application proposes an electronic device, which includes a memory, a processor, and a program stored on the memory and runnable on the processor, and when the program is executed by the processor, the method described in the first aspect above is implemented.

[0062] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes a storage medium, which is a computer-readable storage medium used for computer-readable storage. The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the method described in the first aspect above.

[0063] This application proposes a document retrieval method, device, electronic device and storage medium based on the BM25 algorithm, which obtains a question text based on a business question input by a user, and inputs the question text into a pre-trained first natural language processing model to use the ability of the first natural language processing model to perceive contextual semantic information to predict the importance of each word segment in the question text; then, based on the BM25 algorithm, the importance prediction results of each word segment output by the first natural language processing model are processed to obtain a similarity score between each candidate document and the question text, and based on the similarity score, the candidate document is recalled to obtain a recalled document, and the recalled document is pushed to the user as a document retrieval result. The similarity score obtained by the above method is obtained by taking into account the contextual semantic information of the question text, which overcomes the limitation of the typical BM25 algorithm that judges the importance of a word segment only based on the word frequency of the word segment, and greatly improves the accuracy of document recall. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] Figure 1 This is a flowchart of a document retrieval method based on the BM25 algorithm provided in an embodiment of the present application;

[0065] Figure 2 This is a schematic diagram of the pre-training process of the first natural language processing model provided by one embodiment of the present application;

[0066] Figure 3 yes Figure 1 Schematic diagram of the sub-step flow of step S140 in FIG.

[0067] Figure 4 This is a schematic diagram of the pre-training process of the second natural language processing model provided by one embodiment of the present application;

[0068] Figure 5 This is a schematic diagram of the first pre-training process provided in an embodiment of the present application;

[0069] Figure 6 Schematic diagram of the forward training process provided by the embodiment of the present application;

[0070] Figure 7 Schematic diagram of the negative training process provided by the embodiment of the present application;

[0071] Figure 8 is a schematic diagram of the pre-training process of a second natural language processing model provided in another embodiment of the present application;

[0072] Figure 9 Schematic diagram of the second pre-training process provided in an embodiment of the present application;

[0073] Figure 10It is a structural diagram of a document retrieval device provided in an embodiment of the present application;

[0074] Figure 11 This is a schematic diagram of the hardware structure of the electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0075] In order to make the purpose, technical solutions and advantages of this application more clearly understood, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.

[0076] It should be noted that, unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0077] First, let’s analyze some of the terms used in this application:

[0078] Artificial intelligence (AI) is a new technical discipline that studies and develops theories, methods, technologies, and application systems for simulating, extending, and expanding human intelligence. A branch of computer science, AI seeks to understand the essence of intelligence and produce new intelligent machines that can respond in a manner similar to human intelligence. Research in this field includes robotics, speech recognition, image recognition, natural language processing, and expert systems. AI can simulate the information processes of human consciousness and thinking. It also encompasses the theories, methods, technologies, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, to perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results.

[0079] Natural Language Processing (NLP): Natural language processing (NLP) refers to the technology that uses the natural language used by humans to communicate with machines. Through human processing of natural language, computers can read and understand it. Research on natural language processing began with the exploration of machine translation. Although natural language processing involves operations on multiple dimensions, such as phonetics, grammar, semantics, and pragmatics, in simple terms, the basic task of natural language processing is to segment the processed corpus based on ontology dictionaries, word frequency statistics, and contextual semantic analysis, forming semantically rich word units with the smallest part of speech as the unit.

[0080] Bidirectional Encoder Representation from Transformers (BERT): The BERT model is an NLP model that further enhances the generalization capabilities of word vector models, fully describing features at the character, word, sentence, and even inter-sentence levels. It is built on the Transformer architecture. BERT uses three types of embeddings: Token Embedding, Segment Embedding, and Position Embedding. Token Embeddings are word vectors, with the first word being a CLS marker, which can be used for subsequent classification tasks. Segment Embeddings are used to distinguish between two sentences, as pre-training involves not only performing LM but also classification tasks with two sentences as input. Position Embeddings, however, use position embeddings learned by BERT during training, rather than trigonometric functions like in Transformers. BERT directly trains a position embedding to preserve position information. A vector is randomly initialized for each position and then included in model training. The resulting embedding contains position information. BERT then directly concatenates these position embeddings with the word embeddings.

[0081] Bidirectional Encoder Representations from Transformers - Whole Word Masking (BERT-wwm) Model: Whole Word Masking (wwm), tentatively translated as whole word masking or whole word masking, is an upgraded version of BERT released by Google on May 31, 2019. It primarily changes the training sample generation strategy during the original pre-training phase. Simply put, the original word piece-based word segmentation method splits a whole word into several subwords. When generating training samples, these subwords are randomly masked. In whole word masking, if some word piece subwords of a whole word are masked, the rest of the word is also masked, i.e., whole word masking. It is important to note that the term "mask" here refers to a broad definition (replacing with [MASK]; keeping the original word; randomly replacing with another word), and is not limited to replacing a single word with the [MASK] label. Similarly, because Google's officially released Bert-base for Chinese uses character segmentation as the granularity, it doesn't take into account the Chinese word segmentation (CWS) used in traditional NLP. We applied the full-word masking approach to Chinese, using Chinese Wikipedia (both simplified and traditional characters) for training and using Harbin Institute of Technology's LTP as the word segmentation tool. This masking approach masks all the Chinese characters that make up a word.

[0082] Batch: Batch size is a hyperparameter that defines the number of examples to process before updating internal model parameters. This means it controls the number of training examples before updating the model's internal parameters. A training dataset can be divided into one or more batches. When all training examples are used to create a single batch, the learning algorithm is called batch gradient descent; when the batch size is the size of one example, the learning algorithm is called stochastic gradient descent; and when the batch size exceeds one example and is smaller than the size of the training dataset, the learning algorithm is called mini-batch gradient descent. The batch size is the number of examples processed before updating the model.

[0083] Loss function: A loss function maps the value of a random event or its related random variables to a non-negative real number to represent the "risk" or "loss" of the random event. In applications, loss functions are often used as learning criteria in conjunction with optimization problems, that is, solving and evaluating models by minimizing the loss function.

[0084] Mean squared error (MSE) loss function: Mean squared error (MSE) is the most commonly used error in regression loss function. It is the sum of the squares of the differences between the predicted value and the target value. It is equivalent to finding the L2 norm of the error, so it is also called L2 loss function (L2 loss).

[0085] Cross-Entropy Loss (Binary Cross-Entropy Loss): The cross-entropy loss function predicts the difference between the true value and the predicted value, and the loss value is used to judge the quality of the prediction model. The cross-entropy loss function is often used in classification problems, especially when neural networks are used for classification. In addition, because cross-entropy involves calculating the probability of each class, it is almost always used together with the sigmoid (or softmax) function. In the binary classification case, the model only needs to predict two possible outcomes. For each class, the predicted probabilities are p and 1-p.

[0086] The BM25 algorithm is commonly used for search relevance scoring. Its main idea can be summarized in one sentence: the query is segmented into multiple segmentations qi. Then, for each search result (document D), the relevance score of each segmentation qi with document D is calculated. Finally, the relevance scores of qi relative to D are weighted and summed to obtain the relevance score (also known as the similarity score) between the query and D. In the typical BM25 algorithm, the weight of a segmentation qi is related to the number of times qi appears in a given document set. Generally speaking, the more documents containing qi, the lower the weight of qi. In other words, when qi is present in many documents, its discriminative power is low, and therefore its importance in determining relevance is reduced. The relevance score of qi relative to D is determined by factors such as the frequency of qi's appearance in d, the frequency of qi's appearance in the query, the length of document d, and the average length of all documents.

[0087] As can be seen, the main idea of ​​the typical BM25 algorithm is to calculate word frequency information (i.e., the frequency of word occurrence in each document) after tokenizing the question sentence, thereby determining word importance based on word frequency and setting various adjustable factors for recall. This approach does not take into account the contextual semantics of the user's input question. In practice, the same word has different importance in different contexts, resulting in low recall accuracy based on the BM25 algorithm.

[0088] Based on this, the embodiments of the present application provide a document retrieval method, device, electronic device and storage medium based on the BM25 algorithm, aiming to improve the accuracy of document recall.

[0089] The document retrieval method provided in the embodiments of this application can acquire and process relevant data based on artificial intelligence (AI) technology. For example, the importance of each word segment in a question text can be determined by calling a pre-trained natural language processing model. 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 this knowledge to achieve optimal results. With the research and advancement of artificial intelligence technology, it has been widely studied and applied in many fields. It is believed that as technology develops, artificial intelligence technology will be applied in even more fields and play an increasingly important role.

[0090] The document retrieval method based on the BM25 algorithm provided in the embodiment of the present application relates to the field of artificial intelligence and intelligent question-answering technology. The document retrieval method provided in the embodiment of the present application can be applied to a terminal, can be applied to a server side, or can be software running in a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or as a server cluster or distributed system composed of multiple physical servers, or as 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, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the document retrieval method, etc., but is not limited to the above forms.

[0091] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, and the like. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments in which tasks are performed by remote processing devices connected via a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media, including storage devices.

[0092] See Figure 1 , Figure 1FIG2 shows a flow chart of a document retrieval method based on the BM25 algorithm provided in an embodiment of the present application. Figure 1 As shown, the document retrieval method based on the BM25 algorithm provided in the embodiment of the present application includes but is not limited to the following method steps S110 to S150. Optionally, the method can be executed by a server.

[0093] S110, receiving a business question input by a user and obtaining the question text.

[0094] It is understood that the user enters the actual business question on the client side, and the client sends the business question entered by the user to the server. After receiving the business question entered by the user from the client, the server extracts the question text from the question. Here, the question text can be understood as a question sentence containing multiple words.

[0095] S120: Input the question text into a pre-trained first natural language processing model to obtain an importance prediction result of each word in the question text through the first natural language processing model.

[0096] It is understood that the first natural language processing model is used to output the importance prediction results of each word segment in the question text. The word segment here can be understood as the words obtained after segmenting the question text (sentence).

[0097] As an optional implementation method, the first natural language processing model can be specifically the Bert-wwm model. The Bert-wwm model introduces whole word masking on the basis of the original Bert-base, that is, masking an entire word. Compared with the Bert model, the performance of language tasks (especially Chinese tasks) has been greatly improved.

[0098] In an embodiment of the present application, the ability of the first natural language processing model to perceive contextual semantic information is utilized to output the importance prediction results of each word segment through the first natural language processing model. This importance prediction result represents the importance of the word segment in the overall content of the question text.

[0099] S130, obtain a plurality of pre-set candidate documents and the document parameters of each candidate document, and for each candidate document, process the document parameters of the candidate document and the importance prediction results of each word in the question text based on the BM25 algorithm to obtain a similarity score between the candidate document and the question text.

[0100] As an example, in step S130, the document parameters of the candidate document and the importance prediction results of each word in the question text are processed based on the BM25 algorithm to obtain the similarity score between the candidate document and the question text, which can be achieved by the following formula:

[0101]

[0102] in, Represents the similarity score between the dth candidate document among all candidate documents and the question text Q; Represent the i-th word in the question text Q; Characterizing the first natural language processing model for word segmentation The importance of the output prediction results; Characterize the segmentation The frequency of occurrence in all candidate documents; dl represents the length of the d-th candidate document; avgdl represents the average length of all candidate documents; , b are adjustment factors, The value of can be 2, and the value of b can be 0.75.

[0103] It is understandable that the main idea of ​​the BM25 algorithm provided in the embodiment of the present application is based on word segmentation. ( The importance of the i-th word among the n word segments of the question text Q in the question text Q determines the segmentation The weight value of The weight value and word segmentation The degree of relevance to the candidate document d determines the word segmentation The similarity score with the candidate document d; finally, the similarity scores of the n word segmentations are weighted and summed to obtain the similarity score between the candidate document d and the question text Q.

[0104] It is understandable that in the BM25 algorithm provided in the embodiment of this application, the word segmentation The weight value of is determined by the importance prediction result output by the first natural language processing model, and the importance prediction result output by the first natural language processing model is predicted based on the contextual semantic information of the question text Q, that is, the similarity score obtained in step S130 , which is obtained by considering the contextual semantic information of the question text. It overcomes the limitation of the typical BM25 algorithm that judges the importance of word segmentation only based on the word frequency, and greatly improves the accuracy of document recall.

[0105] It can be understood that the candidate documents described in the embodiment of the present application are pre-given. In specific implementation, the candidate documents can be pre-stored in a database. When executing the document retrieval method of the embodiment of the present application, the relevant candidate documents can be obtained by calling the database.

[0106] S140: Perform recall processing on the candidate documents according to the similarity scores to obtain recalled documents.

[0107] See Figure 3 As an example, assuming that the number of candidate documents is M (M is an integer greater than 1), in step S140, the candidate documents are recalled according to the similarity scores to obtain recalled documents, which may specifically include the following steps:

[0108] S141 , selecting J candidate documents with the highest similarity scores from the M candidate documents as recalled documents, where J is an integer greater than 1 and less than M.

[0109] It can be understood that based on step S130, the similarity scores of M candidate documents corresponding to the question text can be obtained, and then J candidate documents with the highest similarity scores can be selected from the M candidate documents as recalled documents.

[0110] S150: Push the recalled document to the user as a document retrieval result.

[0111] It is understandable that after obtaining the J recalled documents in step S140 , the J recalled documents are returned to the client as document retrieval results, so as to feed back the document retrieval results to the user.

[0112] See Figure 2 , Figure 2 FIG. 1 shows a schematic diagram of the pre-training process of the first natural language processing model provided by an embodiment of the present application. Figure 2 As shown, the pre-training process of the first natural language processing model provided in the embodiment of the present application may include the following steps S210 to S250.

[0113] S210: Construct a first training sample set, wherein the first training sample set includes multiple first training samples, each of the first training samples includes a first sample question text and a first label set, the first label set includes a first annotation label for each word in the first sample question text, and the first annotation label is used to represent the importance of the word in the first sample question text sentence.

[0114] In a specific implementation, a first training sample set can be constructed based on industry. For example, based on the insurance industry, first training samples related to the insurance industry are collected. Each first training sample includes a first sample question text related to the insurance industry and a corresponding first label set. This enables the trained first natural language processing model to have a better processing effect on question text related to a specific industry.

[0115] S220: Input the first sample question text in each of the first training samples into the first natural language processing model to obtain a set of importance prediction results of the first training samples.

[0116] As an example, assuming that there are R first training samples, the first sample question text in each first training sample is input into the first natural language processing model to obtain a set of importance prediction results corresponding to the R first training samples one by one.

[0117] S230: Determine a first loss value of the first natural language processing model based on the importance prediction result set of each of the first training samples and the first label set.

[0118] It is understood that the value of the first loss function is determined based on the set of importance prediction results of each of the first training samples and the first set of labels, in combination with a preset first loss function, and the first loss value of the first natural language processing model is determined based on the value of the first loss function. Here, the first loss function can be a binary cross-entropy loss function. Of course, the first loss function can also be other forms of loss functions. This embodiment of the application does not specifically require the form of the first loss function.

[0119] S240: When the first loss value satisfies a preset first training end condition, end the pre-training process of the first natural language processing model.

[0120] S250: When the first loss value does not meet the preset first training end condition, adjust the model parameters of the first natural language processing model, and continue pre-training the adjusted model based on the first training sample set.

[0121] It can be understood that after obtaining the first loss value, the first loss value is compared with the preset first training end condition. When the first loss value meets the preset first training end condition, it means that the first natural language processing model has achieved the expected training effect and the training can be terminated; when the first loss value does not meet the preset first training end condition, the model parameters of the first natural language processing model are adjusted, and the adjusted model continues to be pre-trained based on the first training sample set.

[0122] In one possible implementation, the first natural language processing model adopts the Bert-wwm model. Specifically, the Bert-wwm model may include a Bert-wwm layer and a fully connected layer, wherein the Bert-wwm layer is used to output a word vector semantic sequence based on the first sample question text, and the fully connected layer is used to output the importance prediction results of each word segment in the first sample question text based on the word vector semantic sequence. Here, the Bert-wwm layer is used to segment the input first sample question text, divide the first sample question text into multiple word segments, and then learn the contextual semantic information of the first sample question text based on the word segmentation, generate semantic vectors corresponding to each word segmentation, and output the semantic vectors of each word segmentation after forming a word vector semantic sequence. It can be understood that the semantic vector corresponding to a word segmentation contains the contextual semantic information of the word in the overall content of the question text. The fully connected layer learns the semantic vectors of each contextual semantic information in the word vector semantic sequence based on the word vector semantic sequence output by the Bert-wwm layer, and predicts the importance probability of each word based on the semantic vector of each word. The importance probability of each semantic vector constitutes the importance prediction result of each word in the first sample question text.

[0123] In one possible implementation, the output of the fully connected layer is an importance prediction result sequence, the importance prediction results of each word in the first sample question text are obtained according to the importance prediction result sequence, and the importance prediction results of each word constitute the importance prediction result set.

[0124] See Figure 3 As an optional implementation, after step S141, in which J candidate documents with the highest similarity scores are selected from the M candidate documents as recalled documents, the method may further include the following steps S142 and S143.

[0125] S142, using the pre-trained second natural language processing model to predict scores for each of the J recalled documents to obtain a score for each recalled document;

[0126] S143 , sorting the J recalled documents based on the score of each recalled document, and pushing the sorted J recalled documents as document retrieval results to the user.

[0127] As an example, the second natural language processing model in step S142 may adopt the Bert model.

[0128] See Figure 4 , Figure 4 FIG. 1 shows a schematic diagram of the pre-training process of the second natural language processing model provided by one embodiment of the present application. Figure 4As shown, the pre-training process of the second natural language processing model may include the following steps S310 and S320.

[0129] S310: Construct a second training sample set, wherein the second training sample set includes multiple second training samples, each of which includes a second sample question text, multiple sample documents, and a second label set, wherein the second label set includes a labeling score of each sample document.

[0130] In a specific implementation, a second training sample set can be constructed based on industry. For example, based on the insurance industry, second training samples related to the insurance industry can be collected. Each second training sample includes a second sample question text related to the insurance industry and a corresponding second label set. This allows the trained second natural language processing model to have better processing effects on question text related to a specific industry.

[0131] S320: Execute a first pre-training process based on the second training sample set. Figure 5 , the first pre-training process includes the following steps: Figure 5 Steps S321 to S324 are shown.

[0132] S321, concatenating the second sample question text in each second training sample with a plurality of sample documents, and inputting the concatenated concatenation into the second natural language processing model to obtain a set of prediction scores for each second training sample;

[0133] S322: Determine a second loss value of the second natural language processing model based on the prediction score set and the second label set of each second training sample;

[0134] S323: If the second loss value satisfies a preset second training end condition, end the first pre-training process;

[0135] S324: When the second loss value does not meet the preset second training end condition, the model parameters of the second natural language processing model are adjusted, and the first pre-training process is continued on the adjusted model based on the second training sample set.

[0136] It is understandable that, in the first pre-training process, the second sample question text is first concatenated with multiple sample documents. For example, the concatenation is in the following form: Xi = [ <cls>+ Question + <s>+ Di + <s>< / s> ]. Where Xi represents the connection between the second sample question text and the i-th sample document; Question represents the second sample question text; Di represents the i-th sample document in the dataset.

[0137] It is understood that during the first pre-training process, the concatenated formula formed by concatenating the second sample question text and the sample document is input into the second natural language processing model. Based on the concatenated formula, the second natural language processing model outputs predicted scores for the sample documents in the concatenated formula with respect to the second sample question text in the concatenated formula. Assuming there are K sample documents, the set of predicted scores for each second sample question text consists of K predicted scores corresponding to the K sample documents. Based on the K predicted scores, the ranking relationship of the K sample documents can be determined.

[0138] It is understood that during the first pre-training process, after obtaining the predicted score set and second label set for each of the second training samples, a value of the second loss function can be determined in combination with a preset second loss function, and the second loss value of the second natural language processing model can be determined based on the value of the second loss function. This second loss function can be a mean squared error (MSE) loss function, but of course, the second loss function can also be other forms of loss functions. This embodiment of the present application does not specifically require the form of the second loss function.

[0139] In some specific embodiments, each sample document in the second training sample includes multiple positive sample documents, each of which has the highest annotation score (e.g., "1"); and the first pre-training process includes a forward training process. Figure 6 The forward training process includes the following steps S3211, S3221, S3231 and S3241. It can be understood that steps S3211, S3221, S3231 and S3241 are specific steps corresponding to the above steps S321, S322, S323 and S324 one by one.

[0140] S3211: concatenate the second sample question text in each second training sample with a plurality of positive sample documents, and input the concatenated data into the second natural language processing model to obtain a set of positive prediction scores for each second training sample.

[0141] S3221: Determine a forward loss value of the second natural language processing model based on the forward prediction score set of each second training sample and the highest annotation score;

[0142] S3231, when the forward loss value satisfies a preset forward training end condition, ending the forward training process;

[0143] S3241: When the forward loss value does not meet the preset forward training end condition, the model parameters of the second natural language processing model are adjusted, and the forward training process is continued on the adjusted model based on the second training sample set.

[0144] In some specific embodiments, each sample document in the second training sample also includes multiple negative sample documents, each of which has the lowest annotation score (e.g., "0"); and the first pre-training process also includes a negative training process. Figure 7 The negative training process includes the following steps S3212, S3222, S3232 and S3242. It can be understood that steps S3212, S3222, S3232 and S3242 are specific steps corresponding to the above steps S321, S322, S323 and S324 one by one.

[0145] S3212: Concatenate the second sample question text in each second training sample with a plurality of negative sample documents, and input the concatenated concatenation into the second natural language processing model to obtain a set of negative prediction scores for each second training sample.

[0146] S3222: Determine a negative loss value of the second natural language processing model based on the set of negative prediction scores and the lowest annotation score of each of the second training samples;

[0147] S3232, when the negative loss value satisfies a preset negative training end condition, ending the negative training process;

[0148] S3242: When the negative loss value does not meet the preset negative training end condition, the model parameters of the second natural language processing model are adjusted, and the negative training process is continued on the adjusted model based on the second training sample set.

[0149] During the first pre-training process, each second training sample can be configured with r positive sample documents and r negative sample documents, resulting in a batch size of 2r. During the first pre-training process, the model parameters of the second natural language processing model being trained are adjusted based on the second loss value to maximize the score of the positive sample documents and minimize the score of the negative sample documents (positive document samples are assigned a score of 1, negative document samples are assigned a score of 0).

[0150] Through the first pre-training process, the second natural language processing model can output the predicted score results of each document based on multiple input splicing formulas (the splicing formulas of the question sample and each document).

[0151] See Figure 8 , Figure 8 FIG2 shows a schematic diagram of the pre-training process of the second natural language processing model provided by another embodiment of the present application. Figure 8 As shown, the pre-training process of the second natural language processing model may include the following steps S410 to S430.

[0152] S410: Construct a second training sample set.

[0153] The second training sample set includes multiple second training samples, each second training sample includes a second sample question text, multiple sample documents, a second label set and a third label set, the second label set includes the labeling score of each sample document, the third label set includes the second labeling label of each sample document, and the second labeling label is used to characterize the relevance between the sample document and the second sample question text.

[0154] S420: Perform a second pre-training process based on the second training sample set. Figure 9 The second pre-training process specifically includes the following steps S421 to S424.

[0155] S421, concatenating the second sample question text in each second training sample with a plurality of sample documents, and inputting the concatenated concatenation into the second natural language processing model to obtain a set of relevance prediction results for each second training sample;

[0156] S422: Determine a third loss value of the second natural language processing model based on the relevance prediction result set of each second training sample and the third label set;

[0157] S423: When the third loss value satisfies a preset third training end condition, end the second pre-training process of the second natural language processing model;

[0158] S424: When the third loss value does not meet the preset third training end condition, the model parameters of the second natural language processing model are adjusted, and the second pre-training process is continued on the adjusted model based on the second training sample set.

[0159] S430: Execute a first pre-training process based on the second training sample set. The specific implementation of the first pre-training process described in step S430 can refer to the relevant description of the above step S320, which will not be repeated here.

[0160] Figure 8 In the example shown, before the first pre-training process, a second pre-training process is performed based on the second training sample set. The primary purpose of this second pre-training process is to train the second natural language processing model to perceive the relevance between the second sample question text and each sample document. Thus, through two stages of training, the model focuses on learning the relevance between questions and documents in the first stage, and on learning the ranking relationships between documents in the second stage.

[0161] It is understood that during the second pre-training process, after obtaining the set of correlation prediction results and the second label set for each of the second training samples, a value of the third loss function can be determined in combination with a preset third loss function, and the third loss value of the second natural language processing model can be determined based on the value of the third loss function. The third loss function can be a binary cross entropy loss function. Of course, the third loss function can also be other forms of loss functions. This embodiment of the application does not specifically require the form of the third loss function.

[0162] As an optional implementation, in step S142, the use of a pre-trained second natural language processing model to predict scores for the J recalled documents respectively to obtain a score for each recalled document may specifically include: concatenating the question text with the J recalled documents, inputting the concatenated data into the second natural language processing model to obtain a set of predicted scores for the recalled documents, and determining the score of each recalled document from the set of predicted scores.

[0163] See Figure 10 , an embodiment of the present application further provides a document retrieval device based on the BM25 algorithm, the device comprising:

[0164] Receiving module 801, for receiving a business question input by a user and obtaining a question text;

[0165] A first processing module 802 is configured to input the question text into a pre-trained first natural language processing model to obtain an importance prediction result of each word in the question text through the first natural language processing model;

[0166] The second processing module 803 is configured to obtain a plurality of preset candidate documents and document parameters of each candidate document, and for each candidate document, process the document parameters of the candidate document and the importance prediction result of each word in the question text based on the BM25 algorithm to obtain a similarity score between the candidate document and the question text;

[0167] A recall module 804 is configured to recall the candidate documents according to the similarity scores to obtain recalled documents;

[0168] The push module 805 is configured to push the recalled document as a document retrieval result to the user.

[0169] It can be understood that, in some embodiments, the document retrieval device based on the BM25 algorithm of the present application also includes a third processing module and a sorting module, wherein the third processing module is used to use a pre-trained second natural language processing model to predict the scores of the recalled documents respectively to obtain the score of each recalled document; the sorting module is used to sort the recalled documents based on the score of each recalled document, so as to push the sorted recalled documents as document retrieval results to the user.

[0170] It should be noted that the information interaction, execution process, etc. between the modules of the above-mentioned device are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0171] See Figure 11 , Figure 11 The hardware structure of an electronic device provided in one embodiment of the present application is shown. The electronic device includes:

[0172] The processor 901 can be implemented using a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application.

[0173] The memory 902 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 902 can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 902 and is called by the processor 901 to execute the document retrieval method of the embodiments of this application.

[0174] Input / output interface 903, used to implement information input and output;

[0175] Communication interface 904, used to implement communication interaction between this device and other devices, which can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WiFi, Bluetooth, etc.); and

[0176] Bus 905 , which transmits information between each component of the device (e.g., processor 901 , memory 902 , input / output interface 903 , and communication interface 904 );

[0177] The processor 901 , the memory 902 , the input / output interface 903 and the communication interface 904 are connected to each other in communication within the device via a bus 905 .

[0178] An embodiment of the present application also provides a storage medium, which is a computer-readable storage medium used for computer-readable storage. The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the above-mentioned document retrieval method.

[0179] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0180] The embodiments described in the embodiments of this application are intended to more clearly illustrate the technical solutions of the embodiments of this application and do not constitute a limitation on the technical solutions provided by the embodiments of this application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.

[0181] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, i.e., they may be located in one place or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of this embodiment.

[0182] Those skilled in the art will appreciate that all or some of the steps in the methods, systems, and functional modules / units in the devices disclosed above may be implemented as software, firmware, hardware, or appropriate combinations thereof.

[0183] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0184] It should be understood that in this application, "at least one (item)" means one or more, and "more" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or plural.

[0185] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the above-mentioned units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or can be integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0186] The units described above as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0187] In addition, the functional units in each embodiment of the present application may be integrated into a processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The above-mentioned integrated units may be implemented in the form of hardware or software functional units.

[0188] If the assembled units are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes multiple instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method of each embodiment of the present application. The aforementioned storage medium includes various media that can store programs, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0189] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but are not intended to limit the scope of the present invention. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and essence of the present invention should be within the scope of the present invention.< / s> < / cls>

Claims

1. A document retrieval method based on the BM25 algorithm, characterized in that: The method comprises: Receive business questions input by users and obtain question text; Inputting the question text into a pre-trained first natural language processing model to obtain an importance prediction result of each word in the question text through the first natural language processing model; Acquire a plurality of preset candidate documents and document parameters of each of the candidate documents; For each candidate document, the document parameters of the candidate document and the importance prediction result of each word in the question text are processed based on the BM25 algorithm to obtain a similarity score between the candidate document and the question text, wherein the document parameters include the frequency of occurrence of the word in all candidate documents, the length of the candidate document and the average length of all candidate documents; According to the similarity score, recall processing is performed on the candidate document to obtain a recalled document; Pushing the recalled document as a document retrieval result to the user; The first natural language processing model includes an encoder representation-full word masking Bert-wwm layer and a fully connected layer, the Bert-wwm layer is used to output a word vector semantic sequence based on the first sample question text, and the fully connected layer is used to output the importance prediction result of each word in the first sample question text based on the word vector semantic sequence; The pre-training process of the first natural language processing model includes: Constructing a first training sample set, wherein the first training sample set includes a plurality of first training samples, each of the first training samples includes a first sample question text and a first label set, the first label set includes a first label of each word in the first sample question text, and the first label is used to represent the importance of the word in the sentence of the first sample question text; Inputting the first sample question text in each of the first training samples into the first natural language processing model to obtain a set of importance prediction results of the first training samples; Determining a first loss value of the first natural language processing model according to a set of importance prediction results of each of the first training samples and the first label set; When the first loss value satisfies a preset first training end condition, ending the pre-training process of the first natural language processing model; When the first loss value does not meet the preset first training end condition, the model parameters of the first natural language processing model are adjusted, and the adjusted model is continued to be pre-trained based on the first training sample set.

2. The method according to claim 1, characterized in that The output of the fully connected layer is an importance prediction result sequence, the importance prediction results of each word in the first sample question text are obtained according to the importance prediction result sequence, and the importance prediction results of each word constitute the importance prediction result set.

3. The method according to claim 1, characterized in that For each candidate document, the document parameters of the candidate document and the importance prediction results of each word in the question text are processed based on the BM25 algorithm to obtain the similarity score between the candidate document and the question text, which is implemented by the following formula: in, Representing the similarity score between the dth candidate document among all candidate documents and the question text Q; Representing the i-th word in the question text Q; Characterizing the first natural language processing model for word segmentation The importance of the output prediction results; Characterize the word The frequency of occurrence in all candidate documents; dl represents the length of the dth candidate document; avgdl represents the average length of all candidate documents; , b are adjustment factors.

4. The method according to claim 1, characterized in that: The number of candidate documents is M, where M is an integer greater than 1; The step of performing recall processing on the candidate documents according to the similarity scores to obtain recalled documents includes: Select J candidate documents with the highest similarity scores from M candidate documents as recalled documents, where J is an integer greater than 1 and less than M.

5. The method according to claim 4, characterized in that After selecting J candidate documents with the highest similarity scores from the M candidate documents as recalled documents, the method further includes: Use the pre-trained second natural language processing model to predict the scores of J recalled documents respectively, and obtain the score of each recalled document; The J recalled documents are sorted based on the score of each recalled document, so as to push the sorted J recalled documents to the user as the document retrieval result.

6. The method according to claim 5, characterized in that The pre-training process of the second natural language processing model includes: Constructing a second training sample set, wherein the second training sample set includes a plurality of second training samples, each of which includes a second sample question text, a plurality of sample documents, and a second label set, wherein the second label set includes a labeling score of each sample document; The following first pre-training process is performed based on the second training sample set: splicing the second sample question text in each of the second training samples with a plurality of sample documents, and inputting the resultant text into the second natural language processing model to obtain a set of prediction scores for each of the second training samples; Determining a second loss value of the second natural language processing model according to the prediction score set and the second label set of each of the second training samples; When the second loss value satisfies a preset second training end condition, ending the first pre-training process; When the second loss value does not meet the preset second training end condition, the model parameters of the second natural language processing model are adjusted, and the first pre-training process is continued on the adjusted model based on the second training sample set.

7. The method according to claim 6, characterized in that Each of the second training samples further includes a third label set, wherein the third label set includes a second label label of each sample document, and the second label label is used to characterize the relevance between the sample document and the second sample question text; Before the first pre-training process, the pre-training process of the second natural language processing model further includes performing the following second pre-training process based on the second training sample set: After splicing the second sample question text in each of the second training samples with a plurality of sample documents, the spliced ​​text is input into the second natural language processing model to obtain a set of relevance prediction results of each of the second training samples; Determine a third loss value of the second natural language processing model according to the relevance prediction result set of each of the second training samples and the third label set; When the third loss value satisfies a preset third training end condition, ending the second pre-training process of the second natural language processing model; When the third loss value does not satisfy the preset third training termination condition, the model parameters of the second natural language processing model are adjusted, and the second pre-training process is continued on the adjusted model based on the second training sample set.

8. The method according to claim 6 or 7, characterized in that: The sample documents in each of the second training samples include a plurality of positive sample documents, and the positive sample documents have the highest annotation score; The first pre-training process includes a forward training process, and the forward training process includes: After splicing the second sample question text in each of the second training samples with a plurality of positive sample documents, the second sample question text and the positive sample documents are input into the second natural language processing model to obtain a positive prediction score set of each of the second training samples; Determining a forward loss value of the second natural language processing model according to a set of forward prediction scores of each of the second training samples and a highest annotation score; When the forward loss value satisfies a preset forward training end condition, the forward training process is ended; When the forward loss value does not satisfy the preset forward training termination condition, the model parameters of the second natural language processing model are adjusted, and the forward training process is continued on the adjusted model based on the second training sample set.

9. The method according to claim 8, characterized in that The sample documents in each of the second training samples include a plurality of negative sample documents, and the negative sample documents have the lowest annotation score; The first pre-training process also includes a negative training process, and the negative training process includes: After concatenating the second sample question text in each of the second training samples with a plurality of negative sample documents, the concatenated documents are input into the second natural language processing model to obtain a set of negative prediction scores for each of the second training samples; Determining a negative loss value of the second natural language processing model according to a set of negative prediction scores of each of the second training samples and a lowest annotation score; When the negative loss value satisfies a preset negative training end condition, ending the negative training process; When the negative loss value does not meet the preset negative training end condition, the model parameters of the second natural language processing model are adjusted, and the negative training process is continued on the adjusted model based on the second training sample set.

10. The method according to claim 9, characterized in that The pre-trained second natural language processing model is used to predict the scores of the J recalled documents respectively to obtain the score of each recalled document, including: After the question text and the J recalled documents are concatenated, they are input into the second natural language processing model to obtain a set of predicted scores for the recalled documents, and the score of each recalled document is determined from the set of predicted scores.

11. A document retrieval device based on the BM25 algorithm, characterized in that: include: A receiving module is used to receive business questions input by users and obtain question text; A first processing module, used for inputting the question text into a pre-trained first natural language processing model, so as to obtain the importance prediction result of each word in the question text through the first natural language processing model; A second processing module is used to obtain a plurality of preset candidate documents and document parameters of each candidate document, and for each candidate document, process the document parameters of the candidate document and the importance prediction result of each word in the question text based on the BM25 algorithm to obtain a similarity score between the candidate document and the question text, wherein the document parameters include the frequency of occurrence of the word in all candidate documents, the length of the candidate document and the average length of all candidate documents; A recall module, used to recall the candidate documents according to the similarity scores to obtain recalled documents; A push module, used for pushing the recalled document as a document retrieval result to the user; The first natural language processing model includes an encoder representation-full word masking Bert-wwm layer and a fully connected layer, the Bert-wwm layer is used to output a word vector semantic sequence based on the first sample question text, and the fully connected layer is used to output the importance prediction result of each word in the first sample question text based on the word vector semantic sequence; The pre-training process of the first natural language processing model includes: Constructing a first training sample set, wherein the first training sample set includes a plurality of first training samples, each of the first training samples includes a first sample question text and a first label set, the first label set includes a first label of each word in the first sample question text, and the first label is used to represent the importance of the word in the sentence of the first sample question text; Inputting the first sample question text in each of the first training samples into the first natural language processing model to obtain a set of importance prediction results of the first training samples; Determining a first loss value of the first natural language processing model according to a set of importance prediction results of each of the first training samples and the first label set; When the first loss value satisfies a preset first training end condition, ending the pre-training process of the first natural language processing model; When the first loss value does not meet the preset first training end condition, the model parameters of the first natural language processing model are adjusted, and the adjusted model is continued to be pre-trained based on the first training sample set.

12. An electronic device, characterized in that: The electronic device includes a memory, a processor, and a program stored in the memory and executable on the processor. When the program is executed by the processor, the steps of the document retrieval method based on the BM25 algorithm as described in any one of claims 1 to 10 are implemented.

13. A storage medium, the storage medium being a computer-readable storage medium, used for computer-readable storage, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the document retrieval method based on the BM25 algorithm described in any one of claims 1 to 10.

Citation Information

Patent Citations

  • Opinion retrieval method based on emotional relevancy

    CN103049470A

  • Rehabilitation aid recommendation method and device, computer equipment and storage medium

    CN113297489A