Text retrieval method, device, equipment and storage medium

By using the BERT model to determine the classification label vector in text retrieval and generating search results with semantic information, the problem of inaccurate search results caused by truncation is solved, and the accuracy of the search results is improved.

CN114780678BActive Publication Date: 2025-02-11SOUTH CENTRAL UNIVERSITY FOR NATIONALITIES
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210358947.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-02
Publication Date
2025-02-11
Estimated Expiration
2042-04-02

AI Technical Summary

Technical Problem

Existing text retrieval technology based on BERT processes long documents through truncation, resulting in inaccurate search results and loss of context semantic information of the document.

Method used

The classification label vector is determined through the preset BERT model, and text search results are generated based on text semantic information, sentence semantic information and context semantic information, making full use of the context information characteristics of the document and the interactivity between the query and the document.

Benefits of technology

It improves the accuracy of text search results, comprehensively considers the semantic relationship between query text and pending sentences, and focuses on the use of paragraph information in the document.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114780678B_ABST
    Figure CN114780678B_ABST
Patent Text Reader

Abstract

The present invention belongs to the field of data processing, and discloses a text retrieval method, device, equipment and storage medium. The method comprises: determining a classification label vector through a preset BERT model according to a query text and a sentence to be processed, wherein the sentence to be processed is determined based on a preset document set; determining text semantic information corresponding to the query text and sentence semantic information corresponding to the preset document set; determining context semantic information of the preset document set; and generating a text retrieval result according to the classification label vector, the text semantic information, the sentence semantic information and the context semantic information. Compared with the existing method of directly using the truncation method to process documents and then determine the retrieval results, the above method of the present invention can comprehensively consider the semantic relationship between the query text and the sentence to be processed, thereby improving the accuracy of text retrieval.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of text retrieval technology, and in particular to a text retrieval method, device, equipment and storage medium. Background Art

[0002] In computer systems, the earliest and most common form of information is text. Text retrieval has been widely used in practical applications in the Internet, business, and medical fields, such as search engines, e-commerce shopping, and electronic medical record retrieval. Existing BERT-based text retrieval technology usually uses truncation to alleviate the input problem of long documents, but the truncation method will inevitably lose the contextual semantic information of the entire document, resulting in inaccurate retrieval results.

[0003] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention

[0004] The main purpose of the present invention is to provide a text retrieval method, device, equipment and storage medium, aiming to solve the technical problem of inaccurate retrieval results caused by text retrieval through truncation method in the prior art.

[0005] To achieve the above object, the present invention provides a text retrieval method, which comprises the following steps:

[0006] Determine a classification label vector through a preset BERT model according to the query text and the sentence to be processed, wherein the sentence to be processed is determined based on a preset document set;

[0007] Determining text semantic information corresponding to the query text and sentence semantic information corresponding to the preset document set;

[0008] Determining contextual semantic information of the preset document set;

[0009] A text retrieval result is generated according to the classification label vector, the text semantic information, the sentence semantic information and the context semantic information.

[0010] Optionally, before the step of determining the classification label vector by using a preset BERT model according to the query text and the sentence to be processed, the step further includes:

[0011] Perform text preprocessing on a preset document set to obtain a processed target document;

[0012] The target document is segmented by a document classifier to obtain sentences to be processed.

[0013] Optionally, the step of determining the classification label vector by using a preset BERT model according to the query text and the sentence to be processed includes:

[0014] Determining the text length of the query text and the sentence length of the sentence to be processed;

[0015] Determining whether the sentence to be processed meets the truncation condition according to the text length and the sentence length;

[0016] If the condition is satisfied, the sentence to be processed is truncated to obtain the truncated sentence to be processed;

[0017] Generate an input embedding of a preset BERT model according to the query text and the truncated sentence to be processed;

[0018] The input is embedded into the preset BERT model to obtain a classification label vector.

[0019] Optionally, the step of determining text semantic information corresponding to the query text and sentence semantic information corresponding to the preset document set includes:

[0020] Determining the query topic distribution corresponding to the query text by using a preset latent Dirichlet distribution model;

[0021] Determining the document topic distribution corresponding to the preset document set by using a preset latent Dirichlet distribution model;

[0022] The document topic distribution and the query topic distribution are averaged respectively to obtain text semantic information and sentence semantic information.

[0023] Optionally, before the step of determining the text semantic information corresponding to the query text and the sentence semantic information corresponding to the preset document set, the step further includes:

[0024] Get query set samples and document set samples;

[0025] Using the query set sample and the document set sample as training corpus, and extracting target topic information from the training corpus;

[0026] The initial latent Dirichlet distribution model is trained according to the training corpus and the target topic information to obtain a preset latent Dirichlet distribution model.

[0027] Optionally, the step of determining the contextual semantic information of the preset document set includes:

[0028] Obtaining sentences to be processed corresponding to the preset document set;

[0029] Passing the sentences to be processed to a preset topic model to obtain the sentence topic distribution corresponding to each sentence in the sentences to be processed;

[0030] The sentence topic distribution is used as contextual semantic information.

[0031] Optionally, the step of generating a text retrieval result according to the classification label vector, the text semantic information, the sentence semantic information and the context semantic information includes:

[0032] Concatenate the classification label vector, the text semantic information, the sentence semantic information and the context semantic information to obtain concatenated information;

[0033] Inputting the splicing information into a classifier to obtain a document relevance score;

[0034] A text retrieval result is generated according to the document relevance score.

[0035] In addition, to achieve the above object, the present invention also provides a text retrieval device, the device comprising:

[0036] A classification label vector determination module, used to determine a classification label vector through a preset BERT model according to a query text and a sentence to be processed, wherein the sentence to be processed is determined based on a preset document set;

[0037] A semantic information determination module, used to determine text semantic information corresponding to the query text and sentence semantic information corresponding to the preset document set;

[0038] A context semantic information determination module, used to determine the context semantic information of the preset document set;

[0039] The retrieval result determination module is used to generate a text retrieval result based on the classification label vector, the text semantic information, the sentence semantic information and the context semantic information.

[0040] In addition, to achieve the above-mentioned purpose, the present invention also proposes a text retrieval device, which includes: a memory, a processor, and a text retrieval program stored in the memory and executable on the processor, wherein the text retrieval program is configured to implement the steps of the text retrieval method described above.

[0041] In addition, to achieve the above-mentioned purpose, the present invention further proposes a storage medium, on which a text retrieval program is stored, and when the text retrieval program is executed by a processor, the steps of the text retrieval method described above are implemented.

[0042] The present invention determines a classification label vector through a preset BERT model according to a query text and a sentence to be processed, wherein the sentence to be processed is determined based on a preset document set; determines text semantic information corresponding to the query text and sentence semantic information corresponding to the preset document set; determines context semantic information of the preset document set; and generates a text retrieval result according to the classification label vector, the text semantic information, the sentence semantic information and the context semantic information. Compared with the existing method of directly using the truncation method to process documents and then determine the retrieval results, the above method of the present invention can make full use of the context information features of the document and the interactivity between the query and the document, and focuses on the use of paragraphs in the document. This improves the accuracy of the retrieval results. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 It is a structural schematic diagram of a text retrieval device in a hardware operating environment involved in an embodiment of the present invention;

[0044] Figure 2 It is a flowchart of the first embodiment of the text retrieval method of the present invention;

[0045] Figure 3 A schematic diagram of text retrieval in accordance with a first embodiment of the text retrieval method of the present invention;

[0046] Figure 4 A schematic diagram of a flow chart of a second embodiment of a text retrieval method of the present invention;

[0047] Figure 5 It is a structural block diagram of the first embodiment of the text retrieval device of the present invention.

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

[0049] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0050] Reference Figure 1 , Figure 1 The figure is a schematic diagram of the structure of a text retrieval device in the hardware operating environment involved in the embodiment of the present invention.

[0051] like Figure 1As shown, the text retrieval device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (Wireless-Fidelity, WI-FI) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM), or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk storage. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0052] Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the text retrieval device, and may include more or less components than those shown in the figure, or combine certain components, or arrange the components differently.

[0053] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating system, a network communication module, a user interface module, and a text retrieval program.

[0054] exist Figure 1 In the text retrieval device shown, the network interface 1004 is mainly used for data communication with the network server; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the text retrieval device of the present invention can be set in the text retrieval device, and the text retrieval device calls the text retrieval program stored in the memory 1005 through the processor 1001, and executes the text retrieval method provided by the embodiment of the present invention.

[0055] Based on the above text retrieval device, an embodiment of the present invention provides a text retrieval method, referring to Figure 2 , Figure 2 Schematic diagram of the flow chart of the first embodiment of the text retrieval method of the present invention.

[0056] In this embodiment, the text retrieval method includes the following steps:

[0057] Step S10: determining a classification label vector through a preset BERT model according to the query text and the sentence to be processed, wherein the sentence to be processed is determined based on a preset document set.

[0058] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a mobile phone, a tablet computer, a personal computer, etc., or an electronic device or a text retrieval device that can realize the above functions. The text retrieval device is taken as an example to illustrate this embodiment and the following embodiments.

[0059] It should be noted that the query text may be a word or sentence that needs to be queried, the preset document set may be a pre-stored text set, and the retrieval result corresponding to the query text is the content in the preset document set. The sentence to be processed is the sentence obtained after segmenting the text in the preset document set. The classification label vector may be a vector representation of the query text and the sentence to be processed obtained by inputting the query text and the sentence to be processed into a preset BERT model. The preset BERT model may be a pre-trained language model used to perform feature learning and extraction on the semantic relevance between the query text and the segmented sentence to be processed, mainly a BERT model.

[0060] Furthermore, in order to improve the accuracy of the text retrieval result, before step S10, it also includes: performing text preprocessing on a preset document set to obtain processed target documents; and segmenting the target documents by a document classifier to obtain sentences to be processed.

[0061] It should be noted that the text preprocessing of the preset document set may be to extract valid text from the preset document set, remove stop words, remove invalid tags, and convert all words contained therein into lowercase letters. Segmenting the target document by a document classifier to obtain sentences to be processed may be to segment the target document into sentences by a document classifier, that is, to segment the target document into individual sentences, which can be expressed as: k ={Sentence1,Sentence2...Sentence i}

[0062] Among them, d k It is used to represent the target document after segmentation. k is used to represent the kth target document, Sentence i Used to represent the i-th sentence to be processed in the target document.

[0063] Furthermore, in order to improve the accuracy of text retrieval results, the step S10 may include: determining the text length of the query text and the sentence length of the sentence to be processed; judging whether the sentence to be processed meets the truncation condition according to the text length and the sentence length; if satisfied, truncating the sentence to be processed to obtain a truncated sentence to be processed; generating an input embedding of a preset BERT model according to the query text and the truncated sentence to be processed; and inputting the input embedding into the preset BERT model to obtain a classification label vector.

[0064] It should be noted that the text length may be the number of words in the query text. For example, if the query text is "text retrieval method", the corresponding text length is 6. Similarly, the sentence length of the sentence to be processed may also be the number of words in the sentence to be processed. Judging whether the sentence to be processed meets the truncation condition based on the text length and the sentence length may be that if the sentence length plus the text length is greater than a preset number of words, the sentence to be processed is judged to meet the truncation condition. The preset number may be a pre-set number, which may be a value such as 512. For example, if the text length is 12 and the length of the sentence to be processed is 510, it is necessary to truncate the sentence to be processed with a length of 510, and truncate the text of the last 10 words in the sentence to be processed. If the length of the sentence to be processed is less than or equal to 510, it is not necessary to truncate the sentence to be processed. The input embedding of generating a preset BERT model based on the query text and the truncated sentences to be processed may be converting the query text and each of the truncated sentences to be processed into the following form: [cls]q[sep]Sentence i [sep]

[0065] Among them, q is used to represent the query text, Sentence i Used to represent the sentence to be processed after the i-th truncation process.

[0066] It should be understood that before obtaining the classification label vector through the preset BERT model, it is necessary to train the pre-trained language model BERT model according to the query set samples and the document set samples. Specifically, the query set samples and the document set samples can be subjected to text preprocessing and sentence segmentation. Specifically, the steps of preprocessing and segmenting the preset document set can be referred to above, and the step of generating the input embedding of the preset BERT model according to the query text and the truncated sentences to be processed can be referred to above. The query set samples and the document set samples after segmentation are generated into the input embedding of the preset BERT model, which can be in the following form [cls]q o [sep]Sentence p [sep]

[0067] Among them, qo Sentence is used to represent the query text in the query set sample after the oth segmentation. p Used to represent the sentences in the p-th segmented document set sample.

[0068] It should be noted that the embedding of the input into the preset BERT model to obtain the classification label vector may be embedding the input into the preset BERT model to obtain an output classification label vector in the following form: CLS j =BERT(q,Sentence j )

[0069] It should be noted that the Sentence j is used to represent the jth sentence to be processed, the q is used to represent the query text, the CLS j It can be the classification label vector corresponding to the jth sentence to be processed.

[0070] Step S20: Determine text semantic information corresponding to the query text and sentence semantic information corresponding to the preset document set.

[0071] It should be noted that the determining of the text semantic information corresponding to the query text and the sentence semantic information corresponding to the preset document set can be performed by determining the query topic distribution corresponding to the query text through a preset latent Dirichlet distribution model; determining the document topic distribution corresponding to the preset document set through a preset latent Dirichlet distribution model; and averaging the document topic distribution and the query topic distribution respectively to obtain the text semantic information and the sentence semantic information.

[0072] It should be noted that the preset latent Dirichlet allocation model may be a model obtained by training a latent Dirichlet allocation (LDA) model using query set samples and document set samples, and the preset latent Dirichlet allocation model is used to extract the query topic distribution corresponding to the query text and the document topic distribution corresponding to the preset document set. The extraction of the query topic distribution corresponding to the query text and the document topic distribution corresponding to the preset document set may refer to the following formula:

[0073] w u =TopicModel(T u )

[0074] M v,c =TopicModel(R v,c )

[0075] Among them, w u The query topic distribution used to represent the u-th word in the query text, Tu Used to represent the uth word in the query text, M v,c It is used to characterize the document topic distribution corresponding to the cth sentence to be processed in the vth document in the preset document set, R v,c Used to represent the cth sentence to be processed in the vth document in the preset document set.

[0076] It should be understood that before extracting the query topic distribution corresponding to the query text, the process also includes performing word segmentation processing on the query text to obtain each word in the query text.

[0077] It should be noted that the averaging of the document topic distribution and the query topic distribution to obtain text semantic information and sentence semantic information may be performed by averaging the document topic distribution and the query topic distribution to obtain text semantic information and sentence semantic information according to the following formula:

[0078]

[0079]

[0080] Among them, Q u It is used to represent the semantic information of the text, n is used to represent the number of words after the query text is segmented, and S c It is used to represent the semantic information of sentences, and m is used to represent the number of sentences to be processed in the vth document.

[0081] Furthermore, in order to accurately obtain the text semantic information and sentence semantic information, before the step of determining the text semantic information corresponding to the query text and the sentence semantic information corresponding to the preset document set, it also includes: obtaining query set samples and document set samples; using the query set samples and the document set samples as training corpus, and extracting target topic information from the training corpus; training an initial latent Dirichlet distribution model according to the training corpus and the target topic information to obtain a preset latent Dirichlet distribution model.

[0082] It should be noted that the target topic information may include text semantic information corresponding to the query set sample and sentence semantic information corresponding to the document set sample. The initial latent Dirichlet allocation model may be a latent Dirichlet allocation (LDA) model.

[0083] In a specific implementation, extracting target topic information based on query set samples and document set samples can be: selecting a document from the document set sample according to a prior probability; sampling from Dirichlet distribution α to generate the topic distribution of the document, and the topic distribution is generated by Dirichlet distribution with hyperparameter α; sampling from the multinomial distribution of the topic to generate the topic of the kth word in the document; sampling from Dirichlet distribution to generate the word distribution corresponding to the topic, and the word distribution is generated by Dirichlet distribution with parameter ; sampling from the multinomial distribution of words to finally generate the word topic, that is, the target topic information.

[0084] Step S30: Determine the contextual semantic information of the preset document set.

[0085] It should be noted that the contextual semantic information may be the contextual semantics of the preset document set determined by a preset topic model according to the preset document set.

[0086] Furthermore, the step of determining the contextual semantic information of the preset document set may include: obtaining the sentences to be processed corresponding to the preset document set; passing the sentences to be processed to a preset topic model to obtain the sentence topic distribution corresponding to each sentence in the sentences to be processed; and using the sentence topic distribution as the contextual semantic information.

[0087] It should be noted that the preset topic model can be a model obtained by training the implicit Dirichlet distribution model through query set samples and document set samples. The passing of the sentence to be processed to the preset topic model can be passing all the words in the sentence to be processed to the preset topic model to obtain the sentence topic distribution corresponding to each sentence in the sentence to be processed. Passing all the words in the sentence to be processed to the preset topic model to obtain the sentence topic distribution corresponding to each sentence in the sentence to be processed can be referred to the following formula:

[0088] D t =TopicModel([T1,T2...T h ])

[0089] Among them, D t The sentence topic distribution used to represent the t-th sentence, T h It is used to represent the hth word in the tth sentence, and h is used to represent the number of words in the tth sentence.

[0090] It should be understood that the preset topic model obtained by training the latent Dirichlet distribution model through the query set sample and the document set sample can be to select a document according to the prior probability; sample from the Dirichlet distribution α to generate the topic distribution θ of the document a , topic distribution θa Generated by Dirichlet distribution with hyperparameter α; from the topic distribution θ a The sampling finally generates the word topic, that is, the contextual semantic information corresponding to the query set sample and the document set sample. a The word topics finally generated by sampling in the above method can refer to the existing implicit Dirichlet distribution model, which is not limited in this embodiment.

[0091] Step S40: Generate a text retrieval result according to the classification label vector, the text semantic information, the sentence semantic information and the context semantic information.

[0092] It should be noted that generating the text retrieval result based on the classification label vector, the text semantic information, the sentence semantic information and the context semantic information may be inputting the classification label vector, the text semantic information, the sentence semantic information and the context semantic information into a preset classifier, obtaining the output result of the classifier, and determining the text retrieval result based on the output result of the classifier.

[0093] In the specific implementation, please refer to Figure 3 , Figure 3 Schematic diagram of text retrieval in the first embodiment of the text retrieval method of the present invention. Figure 3 , Figure 3 01 is a preset classifier, which is used to receive the classification label vector output by the BERT model module 08, the sentence semantic information output by the query and sentence semantic information extraction topic model shallow module 02, and the context semantic information output by the context semantic information extraction topic model shallow module 03. 07 is used to represent the query text, 04 is used to represent the sentences to be processed after the preset document is segmented, 05 is a document input processing module, which is used to preprocess and segment the preset document and / or query text, and 06 is the input preset document and query text.

[0094] This embodiment determines a classification label vector through a preset BERT model based on the query text and the sentence to be processed, the sentence to be processed is determined based on a preset document set; determines the text semantic information corresponding to the query text and the sentence semantic information corresponding to the preset document set; determines the context semantic information of the preset document set; generates a text retrieval result based on the classification label vector, the text semantic information, the sentence semantic information and the context semantic information. Compared with the existing method of directly using the truncation method to process documents and then determine the retrieval results, the above method of this embodiment can comprehensively consider the semantic relationship between the query text and the sentence to be processed, thereby improving the accuracy of text retrieval.

[0095] refer to Figure 4 , Figure 4FIG. 4 is a flow chart of the second embodiment of the text retrieval method of the present invention.

[0096] Based on the above first embodiment, in this embodiment, step S40 includes:

[0097] Step S401: concatenate the classification label vector, the text semantic information, the sentence semantic information and the context semantic information to obtain concatenation information.

[0098] It should be noted that the classification label vector, the text semantic information, the sentence semantic information and the context semantic information are concatenated to obtain the concatenated information, which may be concatenating the classification label vector, the text semantic information, the sentence semantic information and the context semantic information in sequence. The concatenation result may be in the following form: [CLS j ,Q u ,S c ,D t ], where CLS j Used to represent the classification label vector, Q u Used to represent text semantic information, S c Used to represent the semantic information of sentences, D t Used to represent contextual semantic information.

[0099] Step S402: input the splicing information into a classifier to obtain a document relevance score.

[0100] It should be noted that the step of inputting the concatenated information into a classifier to obtain a document relevance score may be to use the concatenated information as an input of a classifier to obtain a document relevance score output by the classifier.

[0101] Step S403: Generate text retrieval results according to the document relevance score.

[0102] It should be noted that the generation of the text search result according to the document relevance score may be to sort the documents in the preset document set according to the document relevance score, and select the documents in the sorted result whose document relevance score is greater than a preset threshold as the text search result. The preset threshold may be a pre-set threshold, which is not limited in this embodiment. As an implementation method, the documents in the preset document set may also be directly displayed according to the sorted result as the text search result.

[0103] This embodiment concatenates the classification label vector, the text semantic information, the sentence semantic information and the context semantic information to obtain concatenated information; inputs the concatenated information into a classifier to obtain a document relevance score; and generates a text retrieval result according to the document relevance score. This embodiment obtains a document relevance score according to a classifier, and generates a text retrieval result according to the document relevance score. A text retrieval result can be obtained more accurately.

[0104] Reference Figure 5 , Figure 5 It is a structural block diagram of the first embodiment of the text retrieval device of the present invention.

[0105] like Figure 5 As shown, the text retrieval device proposed in the embodiment of the present invention includes:

[0106] A classification label vector determination module 10, configured to determine a classification label vector through a preset BERT model according to a query text and a sentence to be processed, wherein the sentence to be processed is determined based on a preset document set;

[0107] A semantic information determination module 20, used to determine text semantic information corresponding to the query text and sentence semantic information corresponding to the preset document set;

[0108] A context semantic information determination module 30, used to determine the context semantic information of the preset document set;

[0109] The retrieval result determination module 40 is used to generate a text retrieval result according to the classification label vector, the text semantic information, the sentence semantic information and the context semantic information.

[0110] This embodiment determines a classification label vector through a preset BERT model based on the query text and the sentence to be processed, the sentence to be processed is determined based on a preset document set; determines the text semantic information corresponding to the query text and the sentence semantic information corresponding to the preset document set; determines the context semantic information of the preset document set; generates a text retrieval result based on the classification label vector, the text semantic information, the sentence semantic information and the context semantic information. Compared with the existing method of directly using the truncation method to process documents and then determine the retrieval results, the above method of this embodiment can comprehensively consider the semantic relationship between the query text and the sentence to be processed, thereby improving the accuracy of text retrieval.

[0111] It should be noted that the workflow described above is merely illustrative and does not limit the scope of protection of the present invention. In practical applications, technicians in this field can select part or all of them according to actual needs to achieve the purpose of the present embodiment, and no limitation is made here.

[0112] In addition, for technical details not fully described in this embodiment, reference can be made to the text retrieval method provided in any embodiment of the present invention, and will not be repeated here.

[0113] Based on the above-mentioned first embodiment of the text search device of the present invention, a second embodiment of the text search device of the present invention is proposed.

[0114] In this embodiment, the classification label vector determination module 10 is further used to perform text preprocessing on a preset document set to obtain processed target documents; and segment the target documents through a document classifier to obtain sentences to be processed.

[0115] Furthermore, the classification label vector determination module 10 is also used to determine the text length of the query text and the sentence length of the sentence to be processed; judge whether the sentence to be processed meets the truncation condition according to the text length and the sentence length; if satisfied, truncate the sentence to be processed to obtain a truncated sentence to be processed; generate an input embedding of a preset BERT model according to the query text and the truncated sentence to be processed; input the input embedding into the preset BERT model to obtain a classification label vector.

[0116] Furthermore, the semantic information determination module 20 is also used to determine the query topic distribution corresponding to the query text through a preset latent Dirichlet distribution model; determine the document topic distribution corresponding to the preset document set through a preset latent Dirichlet distribution model; and average the document topic distribution and the query topic distribution respectively to obtain text semantic information and sentence semantic information.

[0117] Furthermore, the semantic information determination module 20 is also used to obtain query set samples and document set samples; use the query set samples and the document set samples as training corpus, and extract target topic information from the training corpus; train the initial latent Dirichlet distribution model according to the training corpus and the target topic information to obtain a preset latent Dirichlet distribution model.

[0118] Furthermore, the contextual semantic information determination module 30 is also used to obtain the sentences to be processed corresponding to the preset document set; pass the sentences to be processed to a preset topic model to obtain the sentence topic distribution corresponding to each sentence in the sentences to be processed; and use the sentence topic distribution as contextual semantic information.

[0119] Furthermore, the retrieval result determination module 40 is also used to splice the classification label vector, the text semantic information, the sentence semantic information and the context semantic information to obtain splicing information; input the splicing information into a classifier to obtain a document relevance score; and generate a text retrieval result based on the document relevance score.

[0120] Other embodiments or specific implementations of the text retrieval device of the present invention can refer to the above-mentioned method embodiments, which will not be described in detail here.

[0121] In addition, an embodiment of the present invention further provides a storage medium, on which a text retrieval program is stored. When the text retrieval program is executed by a processor, the steps of the text retrieval method described above are implemented.

[0122] 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, method, article or system 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, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.

[0123] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0124] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory / random access memory, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0125] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A text retrieval method, characterized in that: The text retrieval method comprises the following steps: Determine a classification label vector through a preset BERT model according to the query text and the sentence to be processed, wherein the sentence to be processed is determined based on a preset document set; Determining text semantic information corresponding to the query text and sentence semantic information corresponding to the preset document set; Determining contextual semantic information of the preset document set; Generate a text retrieval result according to the classification label vector, the text semantic information, the sentence semantic information and the context semantic information; The step of determining the classification label vector by using a preset BERT model according to the query text and the sentence to be processed includes: Determining the text length of the query text and the sentence length of the sentence to be processed; Determining whether the sentence to be processed meets the truncation condition according to the text length and the sentence length; If the condition is satisfied, the sentence to be processed is truncated to obtain the truncated sentence to be processed; Generate an input embedding of a preset BERT model according to the query text and the truncated sentence to be processed; Embed the input into a preset BERT model to obtain a classification label vector; The step of determining text semantic information corresponding to the query text and sentence semantic information corresponding to the preset document set includes: Determining the query topic distribution corresponding to the query text by using a preset latent Dirichlet distribution model; Determining the document topic distribution corresponding to the preset document set by using a preset latent Dirichlet distribution model; averaging the document topic distribution and the query topic distribution respectively to obtain text semantic information and sentence semantic information; The step of determining the contextual semantic information of the preset document set includes: Obtaining sentences to be processed corresponding to the preset document set; Passing the sentences to be processed to a preset topic model to obtain the sentence topic distribution corresponding to each sentence in the sentences to be processed; Using the sentence topic distribution as contextual semantic information; The step of generating a text retrieval result according to the classification label vector, the text semantic information, the sentence semantic information and the context semantic information comprises: Concatenate the classification label vector, the text semantic information, the sentence semantic information and the context semantic information to obtain concatenated information; Inputting the splicing information into a classifier to obtain a document relevance score; A text retrieval result is generated according to the document relevance score.

2. The text retrieval method according to claim 1, characterized in that: Before the step of determining the classification label vector by using a preset BERT model according to the query text and the sentence to be processed, the method further includes: Perform text preprocessing on a preset document set to obtain a processed target document; The target document is segmented by a document classifier to obtain sentences to be processed.

3. The text retrieval method according to claim 1, characterized in that: Before the step of determining the text semantic information corresponding to the query text and the sentence semantic information corresponding to the preset document set, the method further includes: Get query set samples and document set samples; Using the query set sample and the document set sample as training corpus, and extracting target topic information from the training corpus; The initial latent Dirichlet distribution model is trained according to the training corpus and the target topic information to obtain a preset latent Dirichlet distribution model.

4. A text retrieval device, characterized in that: The text search device is applied to the text search method according to any one of claims 1 to 3, and the text search device comprises: A classification label vector determination module, used to determine a classification label vector through a preset BERT model according to a query text and a sentence to be processed, wherein the sentence to be processed is determined based on a preset document set; A semantic information determination module, used to determine text semantic information corresponding to the query text and sentence semantic information corresponding to the preset document set; A context semantic information determination module, used to determine the context semantic information of the preset document set; The retrieval result determination module is used to generate a text retrieval result based on the classification label vector, the text semantic information, the sentence semantic information and the context semantic information.

5. A text retrieval device, characterized in that: The device comprises: a memory, a processor, and a text retrieval program stored in the memory and executable on the processor, wherein the text retrieval program is configured to implement the steps of the text retrieval method according to any one of claims 1 to 3.

6. A storage medium, characterized in that: The storage medium stores a text retrieval program, which, when executed by a processor, implements the steps of the text retrieval method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Document retrieval method and device and computer readable storage medium

    CN112347223A

  • Multilevel semantic information retrieval method based on BERT context awareness

    CN113761890A