Retrieval method and retrieval equipment
By semantic enhancement and core word extraction of problem information, combining vectorized models and full-text search technology, paragraph information is obtained from multiple dimensions, and the problem of searching answers in the existing technology deviating from user needs and low accuracy is achieved, and the problem of searching answers in the existing technology is solved. Efficient and accurate search results.
Patent Information
- Application Number
- CN202411560813.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-02-11
AI Technical Summary
The existing search enhancement generation technology does not pay attention to the correlation between document content when converting background knowledge document content into vector data, resulting in the vector search answers that may deviate from user needs, and a single search method can easily lead to false detection and missed detection, which reduces the The accuracy of the search.
By semantic enhancement of problem information, the target core words are extracted and searched in the vector database, combining vector model and full-text search technology, paragraph information is obtained from multiple dimensions, deduplication and reordering are spliced to generate the final question and answer tips to improve search accuracy.
The multi-dimensional search method accurately reflects problem information, improves the accuracy of search, reduces false detection and missed detection, and ensures the completeness and multi-dimensionality of search results.
Smart Images

Figure CN119415657A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of retrieval technology, and in particular to a retrieval method and a retrieval device. Background Art
[0002] Retrieval Augmented Generation (RAG) is a technology that generates accurate answers based on question retrieval information and a large language model (LLM). Here, RAG combines vector encoding and information retrieval technology, uses a vectorized model to convert the content in the background knowledge document into a vector, then uses the vector to retrieve the context content corresponding to the question, and then integrates it into complete prompt word information through LLM, which is submitted to LLM to generate the final answer. However, this retrieval method has the following problems: when converting the content in the background knowledge document into vector data, the correlation between the document contents is not taken into account; moreover, the similarity in the vector space is not completely equivalent to the semantic correlation between the question information and the answer, so the answer retrieved by the vector is likely to deviate from the user's needs; furthermore, a single retrieval method can lead to false detection and missed detection, which will lead to poor accuracy of vector retrieval.
[0003] Therefore, how to improve the accuracy of retrieval is a technical problem that needs to be solved urgently. Summary of the invention
[0004] The main technical problem solved by the present invention is to improve the accuracy of retrieval.
[0005] According to the first aspect, an embodiment provides a retrieval method, the method comprising:
[0006] Get problem information;
[0007] Performing semantic enhancement on the question information to obtain question enhancement information;
[0008] Parsing the question information, extracting a target core word from the question information using a preset core word database; searching a preset vector database using the target core word to obtain a first search result, the first search result including: one or more paragraph information containing the target core word;
[0009] The question enhancement information is vectorized using a preset vectorization model to obtain question vector data; target vector data similar to the question vector data is retrieved from the preset vector database to obtain a second search result, wherein the second search result includes: one or more paragraph information;
[0010] Using the question enhancement information to search in a preset ES database, a third search result is obtained, wherein the third search result includes: one or more paragraph information;
[0011] De-duplicate and re-arrange the paragraph information in the first search result, the second search result, and the third search result, and select one or more target paragraph information therefrom;
[0012] Input the spliced one or more target paragraph information into a preset prompt word framework to construct a question and answer prompt word;
[0013] The question and answer prompt words are input into a preset language model to obtain the answer to the question information.
[0014] According to the second aspect, an embodiment provides a retrieval device, the retrieval device comprising:
[0015] An acquisition unit, used for acquiring question information;
[0016] A processing unit, used for performing semantic enhancement on the question information to obtain question enhancement information;
[0017] The processing unit is further configured to parse the question information, extract a target core word from the question information using a preset core word database, and use the target core word to search in a preset vector database to obtain a first search result, wherein the first search result includes: one or more paragraph information containing the target core word;
[0018] The processing unit is further configured to vectorize the question enhancement information using a preset vectorization model to obtain question vector data; retrieve target vector data similar to the question vector data from the preset vector database to obtain a second search result, wherein the second search result includes: one or more paragraph information;
[0019] The processing unit is further configured to use the question enhancement information to search in a preset ES database to obtain a third search result, wherein the third search result includes: one or more paragraph information;
[0020] The processing unit is further used to remove duplicates and rearrange the paragraph information in the first search result, the second search result and the third search result, and select one or more target paragraph information therefrom;
[0021] A construction unit, used for inputting the spliced one or more target paragraph information into a preset prompt word framework to construct a question and answer prompt word;
[0022] The input unit is used to input the question and answer prompt words into a preset language model to obtain an answer to the question information.
[0023] According to the retrieval method / device of the above-mentioned embodiment, since the target core words, question vector data, and question enhancement information accurately reflect the question information from multiple dimensions, the question information can be accurately retrieved in combination with the corresponding retrieval method. After the multiple search results are deduplicated and rearranged, they are spliced with the related paragraphs corresponding to the target paragraph information to obtain the answer closest to the question information, thereby improving the accuracy of the retrieval. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 A schematic diagram of a flow chart of a search method provided in this embodiment;
[0025] Figure 2 A schematic diagram of a process for constructing a vector database provided in this embodiment;
[0026] Figure 3 A schematic diagram of a flow chart of another retrieval method provided in this embodiment;
[0027] Figure 4 A schematic diagram of data preprocessing provided in this embodiment;
[0028] Figure 5 This is a structural block diagram of a retrieval device provided in this embodiment. DETAILED DESCRIPTION
[0029] The present invention is further described in detail below by specific embodiments in conjunction with the accompanying drawings. Wherein similar elements in different embodiments adopt associated similar element numbers. In the following embodiments, many detailed descriptions are for making the present application better understood. However, those skilled in the art can easily recognize that some features can be omitted in different situations, or can be replaced by other elements, materials, methods. In some cases, some operations related to the present application are not shown or described in the specification, this is to avoid the core part of the present application being overwhelmed by too much description, and for those skilled in the art, it is not necessary to describe these related operations in detail, and they can fully understand the related operations according to the description in the specification and the general technical knowledge in the art.
[0030] In addition, the features, operations or characteristics described in the specification can be combined in any appropriate manner to form various implementations. At the same time, the steps or actions in the method description can also be interchanged or adjusted in a manner that is obvious to those skilled in the art. Therefore, the various sequences in the specification and the drawings are only for the purpose of clearly describing a certain embodiment and are not meant to be a required sequence, unless otherwise specified that a certain sequence must be followed.
[0031] The serial numbers of the components in this document, such as "first", "second", etc., are only used to distinguish the objects described and do not have any order or technical meaning. The "connection" and "coupling" mentioned in this application, unless otherwise specified, include direct and indirect connections (couplings).
[0032] At present, RAG combines vector encoding and information retrieval technology, using a vectorization model to convert the content in professional documents into vectors, and then retrieve the context content corresponding to the question through the vector, and then integrate it into complete prompt word information, submit it to LLM to generate the final answer. However, this retrieval method has the following problems: when converting the content in the background knowledge document into vector data, the correlation between the document contents is not taken into account; moreover, the similarity in the vector space is not completely equivalent to the semantic correlation between the question information and the answer, so the answer retrieved by the vector is likely to deviate from the user's needs; furthermore, a single retrieval method will lead to false detection and missed detection, which will lead to poor accuracy of vector retrieval.
[0033] Based on this, the solution of the present invention is proposed. Before searching in the embodiment of the present invention, the background knowledge document is first parsed, split into natural paragraphs and numbered, the association relationship of the natural paragraphs is identified, and the associated paragraph numbers are marked accordingly; then the core words of the paragraphs are extracted using a large language model, and all the core words are sorted into a preset core word database; after adding synonyms to the core words, they are sorted into a preset synonym database; after summarizing the longer paragraphs, the summaries and shorter paragraphs are sorted into a preset ES database; the shorter paragraphs or summaries are vectorized using a preset vectorization model, and they are sorted into a preset vector database.
[0034] The present application uses a preset core word database to extract core words from questions raised by users, and then searches for paragraph content corresponding to the core words in a preset vector database to obtain paragraphs with high similarity rankings; after semantic enhancement of the question using a preset synonym database, vector retrieval and full-text retrieval are performed on the question respectively to obtain paragraphs with high similarity rankings; then the paragraphs retrieved by the three retrieval methods are merged and deduplicated, and then rearranged using the BCE rearrangement technology to obtain a unified similarity; after calculating the comprehensive similarity, retrieval paragraphs that do not exceed the set number of documents and paragraphs are selected according to the comprehensive similarity; paragraphs and related paragraphs of paragraphs are spliced to form the final retrieval results; the set prompt word framework is input through the final retrieval results to generate question and answer prompt words, and the question and answer prompt words are submitted to the large model to generate the answer corresponding to the question information, thereby effectively improving the accuracy of the retrieval.
[0035] Example 1, please refer to Figure 1 , Figure 1is a flowchart of a retrieval method provided in this embodiment, such as Figure 1 As shown, the method specifically includes the following steps 101-108:
[0036] Step 101: Get problem information.
[0037] It should be noted that the question information can be information currently input by the user, or information previously input by the user, and this application does not impose any limitation on this.
[0038] Step 102: semantically enhance the question information to obtain enhanced question information.
[0039] It should be noted that before semantic enhancement of the question information, professional field documents related to the question information input by the user can be collected and used as background knowledge documents. Here, the professional field documents can be standard documents in environmental protection knowledge, such as national standard documents, industry standard documents, and local standard documents.
[0040] In practical applications, the professional document can be converted into a parsable PDF document, and then each professional document can be numbered. i , split the parsed professional field document into multiple paragraphs (P1, P2, ...P i ) and number each paragraph (B1, B2, ...B i ).
[0041] In actual application, after numbering each paragraph, the associated paragraphs corresponding to each paragraph are identified, and then the numbers of the associated paragraphs are matched with the paragraphs. For example, paragraph P3 is an associated paragraph of paragraph P4, and the paragraph number B3 of paragraph P3 can be carried on the paragraph number B4 of paragraph P4, thus strengthening the association between paragraphs and ensuring the integrity of semantics.
[0042] Here, when semantically enhancing the question information, a large language model can be used to semantically supplement the question information to obtain supplementary question information; the question supplementary information can be segmented to obtain question segmentation information; the question segmentation information can be searched in a preset synonym database to select synonyms corresponding to the question segmentation information; the question segmentation information can be semantically enhanced based on the synonyms to obtain enhanced question information.
[0043] In actual applications, when semantic enhancement is performed on question information, the user's recent multiple (for example, three) question and answer records can be obtained to extract the question and answer content; the large language model is used to improve the question Q input by the user. For example, the question body, context-related content, etc. are completed to generate a new question Q1. Figure 3 shown.
[0044] In practical applications, the above question Q1 can be segmented to obtain segmented vocabulary; then the segmented vocabulary is compared and searched in the preset synonym database (business vocabulary W2) to query whether there is a synonym for the segmented vocabulary in the preset synonym database. If so, the synonym is used to enhance the semantics of the segmented vocabulary to generate a new question Q2. Figure 3 As shown. For example, question Q1 is the emission limit of TSS, and the result after word segmentation is TSS / of / emission / limit. This TSS / of / emission / limit is used to perform a comparison search in the preset synonym database (business vocabulary W2), and it is found that the synonym of TSS is suspended solids. After the emission limit of TSS is semantically enhanced using suspended solids, the resulting question Q2 is the emission limit of TSS (suspended solids). In this way, the semantic relevance of the search content can be enhanced, and the efficiency of the search can be effectively improved.
[0045] Here, when using the large language model to semantically supplement the question information, the large language model can be used to supplement the question body corresponding to the question information, and / or the large language model can be used to supplement the context-related content corresponding to the question information to obtain supplementary question information.
[0046] Step 103, parse the question information, and extract the target core word from the question information using the preset core word database; use the target core word to search in the preset vector database to obtain a first search result, the first search result includes: one or more paragraph information containing the target core word.
[0047] In actual applications, the preset core word database is constructed as follows: a large language model is used to extract the core words K corresponding to each paragraph from multiple paragraphs split from professional field documents. i / Topic Object T i , extract all the core words K i / Topic Object T i Stored in the preset core word database.
[0048] In practical applications, the preset vector database is constructed as follows: i When the length of the text is greater than a preset first number (such as 500 words), a large language model is used to extract the text from paragraph P. i The abstract is extracted from the text of the abstract, the text length of which is less than or equal to a preset second number (such as 100) words, and contains all the core words, where the preset second number is less than the preset first number; when the segmented paragraph P i When the length of the text is less than or equal to the preset first number (such as 500 words), directly add the paragraph P iThe original text is used as the summary. The preset vectorization model is selected to vectorize the above summary to obtain paragraph P i Vector data of. Paragraph P i The corresponding paragraph content includes: document name, document number, paragraph number, paragraph original text / summary, core words, and a list of related paragraph numbers. i The vector data and paragraph P i The corresponding paragraph content generates paragraph P i After the corresponding attribute field, it is stored in the preset vector database (vector database V1) as the data source for vector retrieval. Compared with directly vectorizing the content of a paragraph with too much text, the vector data obtained by this application is more accurate. It not only contains the key information of the original paragraph, accurately reflects the semantic content of the original paragraph, but also reduces the time and computing resources required for the vectorization operation, making the vectorization operation more efficient and improving the efficiency and accuracy of retrieval.
[0049] In actual applications, when selecting a preset vectorization model, 100 questions about professional documents are designed, and the paragraphs corresponding to the standard answers to the questions in the professional documents are marked; multiple vectorization models (such as text2veclarge, text2vecbase, and text2vecbgelarge) are selected, and these vectorization models are used to vectorize the paragraphs P in the professional documents. i Vectorization processing is performed to obtain vectorized data of different models; the paragraphs corresponding to the standard answers to 100 questions are retrieved from the vectorized data of different models to obtain the top 20 paragraphs with the highest similarity; the model corresponding to the paragraph with the best similarity ranking is selected according to the similarity ranking of the top 20 paragraphs, and it is used as the preset vectorized model.
[0050] Here, when obtaining the first search result, the preset core word database can be added to the preset word segmentation dictionary, and after parsing the question information based on the preset word segmentation dictionary, the target core word is extracted from the question information; the target core word is used to search in the preset vector database to obtain multiple candidate paragraphs containing the target core word; the first number corresponding to the target core word contained in each candidate paragraph and the second number corresponding to all the words contained in each candidate paragraph are counted; according to the ratio of the first number to the second number, the corresponding first search result is determined from the multiple candidate paragraphs.
[0051] It should be noted that the preset word segmentation dictionary can be any type of dictionary. For example, the preset word segmentation dictionary can be the Jieba word segmentation dictionary, or can be any set dictionary library.
[0052] It should be noted that the second quantity corresponding to all the words included in each candidate paragraph can be the quantity corresponding to all the words after removing the stop words in each candidate paragraph. Exemplarily, the stop words can be modal particles, prepositions or transitional words. Here, the modal particles can be: li, lie, luo, luo, lou, ma, ma, etc.; the prepositions can be: when, by, at, in, for, etc.; the transitional words can be: although... but..., if... then..., even if... also..., while... while..., not only... but also..., etc.
[0053] In practical applications, add the words in the preset core word database (professional word library W1) to the user word segmentation dictionary of Jieba word segmentation, parse the question Q proposed by the user, perform word segmentation extraction on the question Q, and obtain the core words included therein; then retrieve at least one paragraph containing the core word from the preset vector database. Then, according to the calculation method of the core word quantity / total paragraph word quantity, sort the paragraphs, select the paragraph numbers and paragraph contents of the first n paragraphs, and determine the corresponding first retrieval result. As Figure 3 shown.
[0054] For example, there are existing paragraphs P1, P2, P3, P4, P5, P6; the number of core words included in P1 is 2, and the total word quantity is 10; the number of core words included in P2 is 2, and the total word quantity is 20, the number of core words included in P3 is 2, and the total word quantity is 30, the number of core words included in P4 is 2, and the total word quantity is 40, the number of core words included in P5 is 2, and the total word quantity is 50, the number of core words included in P6 is 2, and the total word quantity is 60; since 2 / 10 > 2 / 20 > 2 / 30 > 2 / 40 > 2 / 50 > 2 / 60, so, the paragraph sorting is P1, P2, P3, P4, P5, P6, select the paragraph numbers and paragraph contents of the first 5 paragraphs, that is, the first retrieval result is: R1((B1,P1),...,(B5,P5)).
[0055] Step 104: Use a preset vectorization model to vectorize the question enhancement information to obtain question vector data; retrieve target vector data similar to the question vector data from the preset vector database to obtain a second retrieval result, and the second retrieval result includes: one or more paragraph information.
[0056] It should be noted that when retrieving the target vector data similar to the question vector data from the preset vector database, the cosine value of the question vector data and the candidate vector data in the preset vector database can be calculated; then, according to the cosine value, select the target vector data similar to the question vector data from the candidate vector data.
[0057] In practical applications, the preset vectorization model is used to vectorize question Q2 to obtain question vector data (question vector v), and the question vector data and the paragraph vector data are searched by cosine similarity in the preset vector database. The retrieved paragraphs are sorted, and the paragraph numbers and paragraph contents of the first n paragraphs in similarity sorting are obtained, and the corresponding second search results are determined. For example, the paragraph numbers and paragraph contents of the first 10 paragraphs in similarity sorting are obtained, that is, the second search result is: R2((B6,P6),...,(B 15 ,P 15 )).like Figure 3 shown.
[0058] Step 105: Use the question enhancement information to search in the preset ES database to obtain a third search result, which includes: one or more paragraph information.
[0059] It should be noted that the default ES database is constructed as follows: for the above multiple paragraphs (P1, P2, ...P i ) in each paragraph original text / each paragraph corresponding to the abstract to establish an index, establish a preset ES database (search index library S1), as the data source for full-text search. Here, the full-text search method can also be replaced by a search engine method.
[0060] In actual application, full-text search is performed in the preset ES database using question Q2 to obtain paragraphs similar to question Q2, obtain the paragraph numbers and paragraph contents of the first n paragraphs in similarity ranking, and determine the corresponding third search results. For example, the paragraph numbers and paragraph contents of the first 10 paragraphs in similarity ranking are obtained, that is, the third search result is: R3((B 16 ,P 16 ),...,(B 25 ,P 25 )).like Figure 3 shown.
[0061] Step 106: remove duplicates and re-arrange the paragraph information in the first search result, the second search result, and the third search result, and select one or more target paragraph information therefrom.
[0062] In practical applications, for R1((B1,P1),...,(B5,P5)), R2((B6,P6),...,(B 15 ,P 15 ))、R3((B 16 ,P 16 ),...,(B 25 ,P 25 )) to remove duplicates and re-arrange, and obtain new search results: R((B1,P1),...,(Bm ,P m )), where m is the number of search results after deduplication.
[0063] It should be noted that the similarity calculation methods of the first search result, the second search result and the third search result are different, which makes it impossible to directly compare the similarity results. When the three search results are rearranged after deduplication, the BCE rearrangement technology / BGE rearrangement technology can be used to rearrange them. The rearranged similarity search results are: R rerank ((B i ,P i ,s i ),...,(B n ,P n ,s n )), where s i is the rearranged paragraph P i The corresponding similarity, i and n are the sorting numbers after rearrangement.
[0064] It should be noted that the formula for calculating the comprehensive similarity S of the rearranged similarity search results is as follows: S = s i *(1+0.1*(k-1)), where k is the number of search methods corresponding to the search results. The comprehensive similarity is calculated based on the rearranged similarity and one or more target paragraph information is screened out. The advantage is that the more search results contain the same paragraph, the greater the comprehensive similarity of this paragraph, and the easier it is to be selected, thereby improving the accuracy of the hybrid search. The hybrid search method in this application can cover a wider range of information sources, which not only avoids information omissions and ensures the integrity of the search results, but also achieves the purpose of mutual complementation, avoids false detections, and provides users with more comprehensive and multi-dimensional search results.
[0065] Here, after selecting one or more target paragraph information, a preset number of target paragraph information can be selected from the one or more target paragraph information according to the rearrangement similarity contained in the target paragraph information; the associated paragraphs corresponding to the preset number of target paragraphs are obtained according to the associated paragraph parameters contained in the preset number of target paragraph information; the preset number of target paragraphs and their corresponding associated paragraphs are spliced one by one, and sorted according to the rearrangement similarity to obtain the spliced one or more target paragraph information.
[0066] In practical applications, a preset third number (e.g., 3) of documents may be selected based on the comprehensive similarity, and a preset fourth number (e.g., 8) of paragraphs with the highest similarity may be selected as the screening result: R((B i ,P i ,s i ),...,(B n ,Pn ,s n )), wherein the length of R is a preset fourth number (e.g., 8).
[0067] In actual application, according to the paragraph number in the screening result R, the associated paragraph corresponding to each paragraph is searched, and then the associated paragraph is spliced with the paragraph one by one according to the paragraph order, and the spliced search result is obtained as follows:
[0068] R(((B i-j ,P i-j ),...(B i ,P i ),...(B i+l ,P i+l )),...,((B n-j ,P n-j ),...(B n ,P n ),..(B n+l ,P n+l ))), where P i-j , P i+l All paragraphs P i The relevant paragraphs of n-j , P n+l All paragraphs P n Related paragraphs.
[0069] Step 107: input the spliced one or more target paragraph information into a preset prompt word framework to construct a question and answer prompt word.
[0070] Here, when constructing question and answer prompt words, the spliced one or more target paragraph information can be divided into a preset number of text blocks according to the document name corresponding to the spliced one or more target paragraph information; the preset number of text blocks are integrated and input into the preset prompt word framework to construct the question and answer prompt words.
[0071] In actual application, the paragraph content of the spliced search result R is divided into a preset third number (for example, 3) of text blocks T (t1, t2, t3) according to a preset third number (for example, 3) of documents, and the names of the preset third number (for example, 3) of documents are used as the beginning of the corresponding text block and input into the preset prompt word framework to construct a complete question and answer prompt word. Figure 3 shown.
[0072] Step 108: input the question and answer prompt words into a preset language model to obtain an answer to the question information.
[0073] It should be noted that the preset language model may be any type of language model. Exemplarily, the preset language model may be a large language model.
[0074] In this embodiment, a retrieval method includes: obtaining question information; semantically enhancing the question information to obtain question enhancement information; parsing the question information and extracting target core words from the question information using a preset core word database; using the target core words to search in a preset vector database to obtain a first retrieval result, the first retrieval result includes: one or more paragraph information containing the target core words; using a preset vectorization model to vectorize the question enhancement information to obtain question vector data; retrieving target vector data similar to the question vector data from the preset vector database to obtain a second retrieval result, the second retrieval result includes: one or more paragraph information; using the question enhancement information to search in a preset ES database to obtain a third retrieval result, the third retrieval result includes: one or more paragraph information; deduplicating and re-arranging the paragraph information in the first retrieval result, the second retrieval result, and the third retrieval result, and selecting one or more target paragraph information therefrom; inputting the spliced one or more target paragraph information into a preset prompt word framework to construct a question and answer prompt word; inputting the question and answer prompt word into a preset language model to obtain an answer to the question information. Since the target core words, question vector data, and question enhancement information accurately reflect the question information from multiple dimensions, the question information can be accurately retrieved in combination with the corresponding retrieval method. After the multiple search results are deduplicated and rearranged, they are spliced with the related paragraphs corresponding to the target paragraph information to obtain the answer closest to the question information, thereby improving the accuracy of the retrieval.
[0075] Example 2, please refer to Figure 2 , Figure 2 FIG. 1 is a flow chart of constructing a vector database provided by this embodiment. Figure 2 As shown, the construction method includes the following steps 201-204:
[0076] Step 201: split the preset standard document into paragraphs to obtain the content of each paragraph.
[0077] It should be noted that the preset standard document may be any professional field document related to the problem information.
[0078] In practical applications, professional documents can be converted into parseable PDF documents, and then each professional document can be numbered. i , split the parsed professional field document into multiple paragraphs (P1, P2, ...P i ) and number each paragraph (B1, B2, ...B i ).
[0079] Here, a large language model can be used to extract core words from the content of each paragraph; after all core words are deduplicated, a preset core word database is constructed; after all core words are added with corresponding synonyms, a preset synonym database is constructed.
[0080] In practical applications, a large language model can be used to extract multiple paragraphs (P1, P2, ...P i ) in the database; after removing duplicates from all core words, store them in a preset core word database (professional word library W1).
[0081] In actual applications, synonyms can be added to the core words in the preset core word database (professional word library W1), for example, the synonym "solar panel" of "photovoltaic panel" is added to "photovoltaic panel" and stored in the preset synonym database (business word library W2). Figure 4 shown.
[0082] Step 202: Generate summary content of the paragraph according to the paragraph content of the paragraph, vectorize the summary content of the paragraph based on a preset vectorization model to obtain vector data of the paragraph; or, vectorize the paragraph content of the paragraph based on a preset vectorization model to obtain vector data of the paragraph.
[0083] In practical applications, when paragraph P i When the length of the text is greater than a preset first number (such as 500 words), a large language model is used to extract the text from paragraph P. i The abstract is extracted from the text of the abstract, the text length of which is less than or equal to a preset second number (such as 100) words, and contains all the core words, where the preset second number is less than the preset first number; when the segmented paragraph P i When the length of the text is less than or equal to the preset first number (such as 500 words), directly add the paragraph P i The original text is used as the summary. The preset vectorization model is selected to vectorize the above summary to obtain paragraph P i Vector data of .
[0084] Step 203: Generate an attribute field corresponding to the paragraph according to the vector data and the paragraph content of the paragraph.
[0085] It should be noted that the vector data of a paragraph may represent the corresponding data after the paragraph content or the paragraph summary is vectorized using a preset vectorization model.
[0086] Here, the attribute fields of the paragraph include: the document name corresponding to the paragraph content, the document number corresponding to the paragraph content, the paragraph number corresponding to the paragraph content, the paragraph content / the abstract content corresponding to the paragraph content, the core words corresponding to the paragraph content, the vector data corresponding to the paragraph content, and the associated paragraph parameters.
[0087] In practical applications, paragraph P i The corresponding paragraph content includes: document name, document number, paragraph number, paragraph original text / abstract, core words, and a list of related paragraph numbers.
[0088] Here, when generating associated paragraph parameters, associated paragraphs corresponding to each paragraph can be selected from a preset standard document based on the paragraph content of each paragraph; the paragraph number corresponding to the associated paragraph and the paragraph number corresponding to the paragraph are matched to generate associated paragraph parameters.
[0089] In actual application, after numbering each paragraph, the associated paragraphs corresponding to each paragraph are identified, and then the numbers of the associated paragraphs are matched with the paragraphs. For example, paragraph P3 is the associated paragraph of paragraph P4, and the paragraph number B3 of paragraph P3 can be carried on the paragraph number B4 of paragraph P4, thus strengthening the association between paragraphs.
[0090] Step 204: construct a vector database based on the attribute fields of each paragraph.
[0091] In practical applications, paragraph P i The vector data and paragraph P i The corresponding paragraph content generates paragraph P i After the corresponding attribute field is obtained, it is stored in the preset vector database (vector database V1) as the data source for vector retrieval.
[0092] In this embodiment, the preset standard document is segmented into paragraphs to obtain the paragraph content of each paragraph; the summary content of the paragraph is generated according to the paragraph content, and the summary content of the paragraph is vectorized based on the preset vectorization model to obtain the vector data of the paragraph; or, the paragraph content of the paragraph is vectorized based on the preset vectorization model to obtain the vector data of the paragraph; the attribute field corresponding to the paragraph is generated according to the vector data and the paragraph content of the paragraph; and a vector database is constructed based on the attribute fields of each paragraph. Since the attribute fields of the paragraphs contain the associated paragraph parameters, the vector database constructed by the present application enhances the correlation between paragraphs to retrieve answers that are closer to the questions.
[0093] The present invention also provides a retrieval device, such as Figure 5 The structural block diagram of a retrieval device shown in FIG. The retrieval device 30 includes an acquisition unit 301, a processing unit 302, a construction unit 303 and an input unit 304:
[0094] The acquisition unit 301 is used to acquire the problem information; that is, it is used to execute the above step 101, which will not be described in detail here.
[0095] Processing unit 302 is used to semantically enhance the question information to obtain question enhancement information; parse the question information and extract target core words from the question information using a preset core word database; use the target core words to search in a preset vector database to obtain a first search result, the first search result includes: one or more paragraph information containing the target core words; use a preset vectorization model to vectorize the question enhancement information to obtain question vector data; retrieve target vector data similar to the question vector data from the preset vector database to obtain a second search result, the second search result includes: one or more paragraph information; use the question enhancement information to search in a preset ES database to obtain a third search result, the third search result includes: one or more paragraph information; deduplicate and re-arrange the paragraph information in the first search result, the second search result and the third search result, and select one or more target paragraph information therefrom; that is, it is used to execute the above steps 102 and 106. The specific process is shown in the above steps 102 and 106, which will not be repeated here.
[0096] The construction unit 303 is used to input the spliced one or more target paragraph information into a preset prompt word framework to construct a question and answer prompt word; that is, it is used to execute the above step 107, which will not be described in detail here.
[0097] The input unit 304 is used to input the question and answer prompt words into the preset language model to obtain the answer to the question information; the input unit 304 can be connected to the display to display the answer information of the question information on the display. The specific process is shown in the above step 108 and will not be repeated here.
[0098] In this embodiment, a retrieval device includes: an acquisition unit, which is used to acquire question information; a processing unit, which is used to semantically enhance the question information to obtain question enhancement information; parsing the question information, and extracting target core words from the question information using a preset core word database; using the target core words to search in a preset vector database to obtain a first search result, the first search result includes: one or more paragraph information containing the target core words; using a preset vectorization model to vectorize the question enhancement information to obtain question vector data; retrieving target vector data similar to the question vector data from the preset vector database to obtain a second search result, the second search result includes: one or more paragraph information; using the question enhancement information to search in a preset ES database to obtain a third search result, the third search result includes: one or more paragraph information; deduplicating and re-arranging the paragraph information in the first search result, the second search result, and the third search result, and selecting one or more target paragraph information therefrom; a construction unit, which is used to input the spliced one or more target paragraph information into a preset prompt word framework to construct a question and answer prompt word; an input unit, which is used to input the question and answer prompt word into a preset language model to obtain an answer to the question information. Since the target core words, question vector data, and question enhancement information accurately reflect the question information from multiple dimensions, the question information can be accurately retrieved in combination with the corresponding retrieval method. After the multiple search results are deduplicated and rearranged, they are spliced with the related paragraphs corresponding to the target paragraph information to obtain the answer closest to the question information, thereby improving the accuracy of the retrieval.
[0099] Those skilled in the art will appreciate that all or part of the functions of the various methods in the above-mentioned embodiments can be implemented by hardware or by computer programs. When all or part of the functions in the above-mentioned embodiments are implemented by computer programs, the program can be stored in a computer-readable storage medium, and the storage medium can include: read-only memory, random access memory, disk, optical disk, hard disk, etc., and the program is executed by a computer to implement the above-mentioned functions. For example, the program is stored in the memory of the device, and when the program in the memory is executed by the processor, all or part of the above-mentioned functions can be implemented. In addition, when all or part of the functions in the above-mentioned embodiments are implemented by computer programs, the program can also be stored in a storage medium such as a server, another computer, disk, optical disk, flash disk or mobile hard disk, and can be downloaded or copied and saved in the memory of the local device, or the system of the local device is updated, and when the program in the memory is executed by the processor, all or part of the functions in the above-mentioned embodiments can be implemented.
[0100] The above specific examples are used to illustrate the present invention, which is only used to help understand the present invention and is not intended to limit the present invention. For those skilled in the art, according to the concept of the present invention, some simple deductions, modifications or substitutions can be made.
Claims
1. A search method, characterized in that: The method comprises: Get problem information; Performing semantic enhancement on the question information to obtain question enhancement information; Parsing the question information, extracting a target core word from the question information using a preset core word database; searching a preset vector database using the target core word to obtain a first search result, the first search result including: one or more paragraph information containing the target core word; The question enhancement information is vectorized using a preset vectorization model to obtain question vector data; target vector data similar to the question vector data is retrieved from the preset vector database to obtain a second search result, wherein the second search result includes: one or more paragraph information; Using the question enhancement information to search in a preset ES database, a third search result is obtained, wherein the third search result includes: one or more paragraph information; De-duplicate and re-arrange the paragraph information in the first search result, the second search result, and the third search result, and select one or more target paragraph information therefrom; Input the spliced one or more target paragraph information into a preset prompt word framework to construct a question and answer prompt word; The question and answer prompt words are input into a preset language model to obtain the answer to the question information.
2. The method according to claim 1, characterized in that The question information is parsed, and target core words are extracted from the question information using a preset core word database; The target core word is used to search in a preset vector database to obtain a first search result, including: Adding the preset core word database to a preset word segmentation dictionary, parsing the question information based on the preset word segmentation dictionary, and extracting the target core word from the question information; Using the target core word to search in the preset vector database, a plurality of candidate paragraphs containing the target core word are obtained; Counting a first number of the target core words contained in each of the to-be-selected paragraphs, and a second number of all the words contained in each of the to-be-selected paragraphs; According to the ratio of the first number to the second number, the corresponding first search result is determined from the multiple candidate paragraphs.
3. The method according to claim 1 or 2, characterized in that After removing duplicates and rearranging the paragraph information in the first search result, the second search result, and the third search result and selecting one or more target paragraph information therefrom, the method further includes: Selecting a preset number of target paragraph information from the one or more target paragraph information according to the rearrangement similarity contained in the target paragraph information; According to the associated paragraph parameters contained in the preset number of target paragraph information, acquiring associated paragraphs corresponding to the preset number of target paragraphs; The preset number of target paragraphs and their corresponding associated paragraphs are spliced one by one, and are sorted according to the rearrangement similarity to obtain one or more spliced target paragraph information.
4. The method according to claim 3, characterized in that The step of inputting the spliced one or more target paragraph information into a preset prompt word framework to construct a question and answer prompt word includes: According to the document names corresponding to the one or more target paragraph information after splicing, the one or more target paragraph information after splicing is divided into a preset number of text blocks; The preset number of text blocks are integrated and input into the preset prompt word framework to construct the question and answer prompt words.
5. The method according to claim 1, characterized in that The semantic enhancement of the question information to obtain enhanced question information includes: Using a large language model to semantically supplement the question information to obtain supplementary question information; Performing word segmentation processing on the supplementary information of the question to obtain question word segmentation information; Using the question segmentation information to search in a preset synonym database, and selecting synonyms corresponding to the question segmentation information; The question segmentation information is semantically enhanced based on the synonyms to obtain the question enhanced information.
6. The method according to claim 5, characterized in that The using of the large language model to semantically supplement the question information to obtain supplementary question information includes: The large language model is used to supplement the question body corresponding to the question information, and / or the large language model is used to supplement the context-related content corresponding to the question information to obtain the question supplement information.
7. The method according to claim 1, characterized in that The preset vector database is obtained by the following method: Split the preset standard document into paragraphs to obtain the content of each paragraph; Generate summary content of the paragraph according to the paragraph content of the paragraph, and vectorize the summary content of the paragraph based on the preset vectorization model to obtain vector data of the paragraph; or vectorize the paragraph content of the paragraph based on the preset vectorization model to obtain vector data of the paragraph; Generate an attribute field corresponding to the paragraph according to the vector data of the paragraph and the paragraph content; The preset vector database is constructed based on the attribute fields of each paragraph.
8. The method according to claim 7, characterized in that The attribute fields of the paragraph include: the document name corresponding to the paragraph content, the document number corresponding to the paragraph content, the paragraph number corresponding to the paragraph content, the paragraph content / the abstract content corresponding to the paragraph content, the core words corresponding to the paragraph content, the vector data corresponding to the paragraph content, and the associated paragraph parameters.
9. The method according to claim 7 or 8, characterized in that The preset core word database and the preset synonym database are obtained by the following method: Using a large language model to extract core words from the paragraph content of each paragraph; After removing duplicates from all the core words, constructing the preset core word database; After adding corresponding synonyms to all the core words, the preset synonym database is constructed; The method for obtaining the preset vector database also includes: Based on the paragraph contents of each paragraph, selecting associated paragraphs corresponding to each paragraph from the preset standard document; The paragraph number corresponding to the associated paragraph is matched with the paragraph number corresponding to the paragraph to generate the associated paragraph parameter.
10. A retrieval device, characterized in that: The retrieval device comprises: An acquisition unit, used for acquiring question information; A processing unit, used for performing semantic enhancement on the question information to obtain question enhancement information; The processing unit is further configured to parse the question information, extract a target core word from the question information using a preset core word database, and use the target core word to search in a preset vector database to obtain a first search result, wherein the first search result includes: one or more paragraph information containing the target core word; The processing unit is further configured to vectorize the question enhancement information using a preset vectorization model to obtain question vector data; retrieve target vector data similar to the question vector data from the preset vector database to obtain a second search result, wherein the second search result includes: one or more paragraph information; The processing unit is further configured to use the question enhancement information to search in a preset ES database to obtain a third search result, wherein the third search result includes: one or more paragraph information; The processing unit is further used to remove duplicates and rearrange the paragraph information in the first search result, the second search result and the third search result, and select one or more target paragraph information therefrom; A construction unit, used for inputting the spliced one or more target paragraph information into a preset prompt word framework to construct a question and answer prompt word; The input unit is used to input the question and answer prompt words into a preset language model to obtain an answer to the question information.
Citation Information
Cited By
Data retrieval method and device, electronic equipment and medium
CN119621944A
Question and answer method and device based on large language model, electronic equipment and medium
CN119782492A
Data retrieval method and device based on index platform, electronic equipment and medium
CN119848099A