RAG response result generation method and device

Through various text segmentation methods and vectorization processing, the RAG sorting weights are calculated and the results are merged, which solves the problem of high isolation of RAG response results and improves the coverage and reference value of the results.

CN119739757APending Publication Date: 2025-04-01SHENZHEN SDMC TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411679348.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-22
Publication Date
2025-04-01

AI Technical Summary

Technical Problem

The RAG response results have high isolation and high dependence, resulting in low reference value.

Method used

By generating multiple target RAG text slicing results, vectorization and retrieval, RAG sorting weights, merging and correction results, reducing dependence on single text slicing methods and vector databases.

Benefits of technology

It improves the coverage and comprehensiveness of RAG response results, reduces isolation, and enhances the reference value of the results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119739757A_ABST
    Figure CN119739757A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an RAG response result generation method and device, and relates to the technical field of natural language processing, and the method comprises the steps: generating a plurality of target RAG text segmentation results according to a target RAG text; according to the multiple target RAG text segmentation results, multiple corresponding target vector results are generated; generating a plurality of RAG results according to the plurality of target vector results; according to the multiple RAG results, generating an RAG sorting weight result; according to the RAG sorting weight result, generating a target RAG sorting result; and generating a target RAG response result according to the target RAG sorting result. In this way, the dependency degree of the RAG response result on the text segmentation method is reduced, the isolation of the RAG response result is reduced, the coverage and comprehensiveness of the RAG response result are improved, and the reference value of the RAG response result is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present application relate to the field of natural language processing technology, and in particular, to a method and device for generating a RAG response result. Background Art

[0002] Retrieval-Augmented Generation (RAG) is mainly used to improve the performance of natural language processing models. In related technologies, RAG response results are highly dependent on text segmentation methods, resulting in high isolation and low reference value of RAG response results.

[0003] Therefore, a new technical solution is urgently needed to solve the above technical problems. Summary of the invention

[0004] According to the embodiments of the present application, a method and device for generating a RAG response result are provided, which are conducive to reducing the dependence of the RAG response result on the text segmentation method, reducing the isolation of the RAG response result, improving the coverage and comprehensiveness of the RAG response result, and improving the reference value of the RAG response result.

[0005] In a first aspect of the present application, a method for generating a RAG response result is proposed, comprising:

[0006] Generate multiple target RAG text segmentation results according to the target RAG text;

[0007] Generate corresponding multiple target vector results based on multiple target RAG text segmentation results;

[0008] Generate multiple RAG results based on multiple target vector results;

[0009] Generate RAG ranking weight results based on multiple RAG results;

[0010] Generate the target RAG sorting result according to the RAG sorting weight result;

[0011] According to the target RAG sorting result, a target RAG response result is generated.

[0012] In some feasible implementations, generating multiple target RAG text segmentation results according to the target RAG text includes:

[0013] Based on the overlapping sliding window segmentation method, a first target segmentation operation is performed on the target RAG text to generate a first target RAG text segmentation result;

[0014] Based on the large model segmentation method, performing a second target segmentation operation on the target RAG text to generate a second target RAG text segmentation result; and / or,

[0015] Based on the paragraph-sentence mixed segmentation method, a third target segmentation operation is performed on the target RAG text to generate a third target RAG text segmentation result.

[0016] In some feasible implementations, generating corresponding multiple target vector results according to multiple target RAG text segmentation results includes:

[0017] Based on the first preset model, perform a first vectorization operation on the first target RAG text segmentation result to generate a first target vector result;

[0018] Based on the second preset model, performing a second vectorization operation on the second target RAG text segmentation result to generate a second target vector result; and / or,

[0019] Based on the third preset model, a third vectorization operation is performed on the third target RAG text segmentation result to generate a third target vector result.

[0020] In some feasible implementations, generating multiple RAG results according to multiple target vector results includes:

[0021] Based on the first vector database, performing a first search operation on the first target vector result to generate a first RAG result;

[0022] Based on the second vector database, performing a second search operation on the second target vector result to generate a second RAG result; and / or,

[0023] Based on the third vector database, a third search operation is performed on the third target vector result to generate a third RAG result.

[0024] In some feasible implementations, generating a RAG ranking weight result according to multiple RAG results includes:

[0025] Generate a first similarity result according to the first RAG result;

[0026] generating a second similarity result according to the second RAG result; and / or,

[0027] Generating a third similarity result according to the third RAG result;

[0028] A RAG sorting weight result is generated according to the first similarity result, the second similarity result, and / or the third similarity result.

[0029] In some feasible implementations, generating a target RAG ranking result according to the RAG ranking weight result includes:

[0030] Determine the score information of the target RAG result according to the RAG sorting weight result, the preset constant, the first weight information corresponding to the first vector database, the second weight information corresponding to the second vector database, and / or the third weight information corresponding to the third vector database;

[0031] According to the scoring information, the target RAG result ranking result is generated.

[0032] In some feasible implementations, the above method further includes:

[0033] The first weight information, the second weight information, and / or the third weight information are modified based on the historical search result accuracy data, the contained query type data, and / or the applicable field type data of the first vector database, the second vector database, and / or the third vector database.

[0034] In some feasible implementations, as described in any of the above methods, generating a target RAG response result according to the target RAG sorting result includes:

[0035] Obtain similarity information between any two target RAG results in the target RAG response results;

[0036] When the similarity information is greater than or equal to the preset similarity threshold, a target merging operation is performed on the two target RAG results to generate the above target RAG response result.

[0037] In some feasible implementations, the above method further includes:

[0038] Obtain historical behavior data of the target retrieval user;

[0039] According to historical behavior data, the target RAG sorting results are corrected.

[0040] In a second aspect of the present application, a RAG result generating device is provided, comprising:

[0041] A first generating unit is used to generate a plurality of target RAG text segmentation results according to the target RAG text;

[0042] The second generating unit is used to generate corresponding multiple target vector results according to multiple target RAG text segmentation results;

[0043] A third generating unit is used to generate a plurality of RAG results according to the plurality of target vector results;

[0044] A fourth generating unit, used for generating a RAG ranking weight result according to the multiple RAG results;

[0045] A fifth generating unit, configured to generate a target RAG sorting result according to the RAG sorting weight result;

[0046] The sixth generating unit is used to generate a target RAG response result according to the target RAG sorting result.

[0047] The RAG result generation method and device provided by the embodiment of the present application, wherein the method includes: generating multiple target RAG text segmentation results according to the target RAG text; generating multiple corresponding target vector results according to the multiple target RAG text segmentation results; generating multiple RAG results according to the multiple target vector results; generating RAG sorting weight results according to the multiple RAG results; generating target RAG sorting results according to the RAG sorting weight results; generating target RAG response results according to the target RAG sorting results. The present application is conducive to reducing the dependence of RAG response results on text segmentation methods, reducing the isolation of RAG response results, improving the coverage and comprehensiveness of RAG response results, and improving the reference value of RAG response results.

[0048] It should be understood that the contents described in the Summary of the Invention are not intended to limit the key or important features of the embodiments of the present application, nor are they intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] The above and other features, advantages and aspects of the embodiments of the present application will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. In the accompanying drawings, the same or similar reference numerals represent the same or similar elements, wherein:

[0050] Figure 1 A schematic diagram of a process for generating a RAG response result provided in an embodiment of the present application;

[0051] Figure 2 A structural schematic diagram of a RAG response result generating device provided in an embodiment of the present application;

[0052] Figure 3 A schematic diagram of the structure of a terminal device or a server suitable for implementing an embodiment of the present application; DETAILED DESCRIPTION

[0053] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.

[0054] In addition, the term "and / or" in this article is only a description of the association relationship between the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0055] According to a first aspect of an embodiment of the present application, a method for generating a RAG response result is proposed. Figure 1 A schematic diagram of a RAG response result generation method 100 provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the method 100 includes:

[0056] Step S1: Generate multiple target RAG text segmentation results based on the target RAG text.

[0057] Exemplarily, segmentation operations can be performed on the same target RAG text based on multiple segmentation methods to generate the above multiple target RAG text segmentation results. The above multiple segmentation methods can include: recursive segmentation, character number segmentation, symbol segmentation, large model segmentation, etc.

[0058] In some feasible implementations, the above step S1: generating a plurality of target RAG text segmentation results according to the target RAG text includes:

[0059] Step S11: Based on the overlapping sliding window segmentation method, a first target segmentation operation is performed on the target RAG text to generate a first target RAG text segmentation result.

[0060] Exemplarily, the first target segmentation operation includes: performing a recursive segmentation operation on the target RAG text according to preset characters to generate the first target RAG text segmentation result. The preset characters may include: "\n\n", i.e., double line breaks, "\n", i.e., single line breaks, "" i.e., space, "" i.e., empty string, etc.

[0061] Exemplarily, the first target RAG text segmentation result includes: a plurality of blocks of preset sizes and preset structures corresponding to the target RAG text, wherein the preset sizes and preset structures can be defined by the user according to actual needs.

[0062] Specifically, the target RAG text may be segmented into blocks of preset size and preset structure in a hierarchical and / or iterative manner by performing a recursive segmentation operation based on the preset characters. There is a preset overlap between the blocks of the preset size and preset structure, so that the contextual semantics of the segmentation result of the first target RAG text is complete.

[0063] It should be noted that, when the size of the block generated by the first target segmentation operation is deviated from the preset size, and / or the structure of the block generated by the first target segmentation operation is deviated from the preset structure, then a recursive call is made to perform the first target segmentation operation twice using other preset characters that are different from the first execution of the first target segmentation operation, until the size deviation between blocks is less than the preset deviation, and the structure deviation between blocks is less than the preset deviation.

[0064] Based on this, an overlapping sliding window segmentation method can be implemented to accurately generate the above-mentioned first target RAG text segmentation result while taking into account the length of the target RAG text and overlapping characters, which is conducive to avoiding data omissions in the first target RAG text segmentation result and ensuring the coherence and completeness of the first target RAG text segmentation result.

[0065] Step S12: Based on the large model segmentation method, a second target segmentation operation is performed on the target RAG text to generate a second target RAG text segmentation result.

[0066] Exemplarily, the above-mentioned large model may include: ChatGPT.

[0067] Exemplarily, the above step S12: performing a second target segmentation operation on the target RAG text based on the large model segmentation method to generate a second target RAG text segmentation result may include:

[0068] Step S121, when the closeness between the texts is greater than the preset closeness, the second target segmentation operation is not performed to ensure the integrity of the context of the second target RAG text segmentation result. The preset closeness is negatively correlated with the user's accuracy requirement for the second target RAG text segmentation result, that is, the higher the accuracy requirement for the second target RAG text segmentation result, the lower the preset closeness.

[0069] Step S122, when the repetition rate between texts is greater than the preset repetition rate, a deduplication operation is performed to reduce the repeated data in the second target RAG text segmentation result. The preset repetition rate is negatively correlated with the user's precision requirement for the second target RAG text segmentation result, that is, the higher the user's precision requirement for the second target RAG text segmentation result, the lower the preset repetition rate.

[0070] Step S123, when the clarity of the second target RAG text segmentation result is less than the preset clarity, and / or the ambiguity is greater than the preset ambiguity, the second target segmentation operation is re-executed on the target RAG text until the clarity of the second target RAG text segmentation result is greater than or equal to the preset clarity, and the ambiguity is less than the preset ambiguity. The preset clarity is negatively correlated with the user's accuracy requirement for the second target RAG text segmentation result, that is, the higher the user's accuracy requirement for the second target RAG text segmentation result, the lower the preset clarity. The preset ambiguity is negatively correlated with the user's accuracy requirement for the second target RAG text segmentation result, that is, the higher the user's accuracy requirement for the second target RAG text segmentation result, the lower the preset ambiguity.

[0071] Step S124, when the contradiction feature rate of the second target RAG text segmentation result is greater than the preset contradiction feature rate, based on the above ChatGPT, combined with the context of the target RAG text, the second target segmentation operation is re-performed on the target RAG text until the contradiction feature rate of the second target RAG text segmentation result is less than or equal to the preset contradiction feature rate. Among them, the above preset contradiction feature rate is negatively correlated with the user's accuracy requirement for the second target RAG text segmentation result, that is, the higher the accuracy requirement of the above user's second target RAG text segmentation result, the lower the preset contradiction feature rate. Among them, the contradiction feature rate of the above second target RAG text segmentation result can be determined based on the BERT model.

[0072] Step S125, when there are pictures, formulas, and / or tables in the target RAG text, perform a conversion operation on the above pictures, formulas, and / or tables to generate text corresponding to the above pictures, text corresponding to the above formulas, and / or text corresponding to the above tables; perform a second target segmentation operation on the text corresponding to the above pictures, text corresponding to the above formulas, and / or text corresponding to the above tables to generate the above second target RAG text segmentation result.

[0073] Based on this, according to the large model segmentation method, the second target segmentation operation is performed on the target RAG text, which can achieve the accurate generation of the second target RAG text segmentation result containing: pictures, formulas, and / or, text corresponding to the table segmentation results, which is conducive to improving the completeness of the second target RAG text segmentation results. Based on the above steps S121 to S125, it is conducive to improving the accuracy of the second target RAG text segmentation results.

[0074] and / or,

[0075] Step S13: Based on the paragraph-sentence mixed segmentation method, a third target segmentation operation is performed on the target RAG text to generate a third target RAG text segmentation result.

[0076] Exemplarily, the above step S13: performing a third target segmentation operation on the target RAG text based on the paragraph-sentence mixed segmentation method to generate a third target RAG text segmentation result may include:

[0077] Step S131: Perform segmentation operation on the target RAG text based on paragraphs to generate a third target RAG text segmentation preliminary result, wherein the third target RAG text segmentation preliminary result includes: numbering information corresponding to the paragraphs.

[0078] The above step S131: performing segmentation operation on the target RAG text in paragraph units to generate a third target RAG text segmentation preliminary result includes:

[0079] Step S1311: When the target paragraph length included in the third target RAG text segmentation pre-result is greater than the first preset length, a secondary segmentation operation is performed on the target paragraph to make the target paragraph length less than or equal to the first preset length. The first preset length is negatively correlated with the accuracy requirement of the third target RAG text segmentation pre-result, that is, the higher the accuracy requirement of the third target RAG text segmentation pre-result, the smaller the first preset length.

[0080] Step S1312: When the target paragraph length included in the third target RAG text segmentation pre-result is less than the second preset length, a merging operation is performed on the target paragraph so that the target paragraph length is greater than or equal to the second preset length. The second preset length is positively correlated with the accuracy requirement of the third target RAG text segmentation pre-result, that is, the higher the accuracy requirement of the third target RAG text segmentation pre-result, the higher the second preset length.

[0081] It should be noted that the first preset length is greater than the second preset length.

[0082] Step S132: Perform segmentation operation on the third target RAG text segmentation pre-result in units of sentences to generate the above-mentioned third target RAG text segmentation result, wherein the above-mentioned third target RAG text segmentation result includes: numbering information corresponding to paragraphs, numbering information of sentences, and mapping relationship information between paragraphs and sentences.

[0083] It should be noted that the blocks in the above-mentioned third target RAG text segmentation pre-results can be used as parent blocks, and the blocks in the third target RAG text segmentation pre-results can be used as child blocks. Based on the numbering information corresponding to the above-mentioned paragraphs, the numbering information of the sentences, and the mapping relationship information between paragraphs and sentences, the child block data can be returned and associated with the parent block data.

[0084] The above step S132: performing segmentation operation on the third target RAG text segmentation pre-result in units of sentences includes:

[0085] Step S1321: When the length of the target sentence included in the third target RAG text segmentation result is greater than the third preset length, a secondary segmentation operation is performed on the target sentence so that the length of the target sentence is less than or equal to the third preset length. The third preset length is negatively correlated with the accuracy requirement of the third target RAG text segmentation result, that is, the higher the accuracy requirement of the third target RAG text segmentation result, the smaller the third preset length.

[0086] Step S1321: When the length of the target sentence included in the third target RAG text segmentation result is greater than the fourth preset length, a merge operation is performed on the target sentence so that the length of the target sentence is greater than or equal to the fourth preset length. The fourth preset length is positively correlated with the precision requirement of the third target RAG text segmentation pre-result, that is, the higher the precision requirement of the third target RAG text segmentation pre-result, the higher the fourth preset length.

[0087] It should be noted that the third preset length is greater than the fourth preset length.

[0088] Based on this, the above method can implement segmentation operations on the target RAG text based on the overlapping sliding window segmentation method, the large model segmentation method, and / or the paragraph and sentence mixed segmentation method, accurately generate the first target RAG text segmentation result, the second target RAG text segmentation result, and / or the third target RAG text segmentation result, and perform segmentation operations on the target RAG text in multiple dimensions, which is conducive to reducing the dependence of the RAG text segmentation results on the text segmentation method, thereby reducing the isolation of the vector results, and improving the coverage and comprehensiveness of the vector results to provide a data basis.

[0089] Step S2: Generate corresponding multiple target vector results based on multiple target RAG text segmentation results.

[0090] Exemplarily, multiple target vector results can be generated based on multiple vector models according to the multiple target RAG text segmentation results. The multiple vector models may include: OpenAI, MistralAI, Ollama, Text Embeddings, Inference, etc.

[0091] In some feasible implementations, step S2: generating corresponding multiple target vector results according to multiple target RAG text segmentation results includes:

[0092] Step S21: Based on a first preset model, a first vectorization operation is performed on a first target RAG text segmentation result to generate a first target vector result.

[0093] Exemplarily, the first preset model may be one of OpenAI, MistralAI, Ollama, TextEmbeddings and Inference.

[0094] Specifically, based on the first preset model, a first vectorization operation can be performed on the first target RAG text segmentation result to generate a first target vector result, and the first target vector result is stored in a corresponding first preset vector database. The first preset vector database can be one of the databases such as FAISS, Chroma and dqrant.

[0095] Step S22: Based on the second preset model, perform a second vectorization operation on the second target RAG text segmentation result to generate a second target vector result.

[0096] Exemplarily, the second preset model may be one of OpenAI, MistralAI, Ollama, TextEmbeddings and Inference.

[0097] Specifically, based on the second preset model, a second vectorization operation can be performed on the second target RAG text segmentation result to generate a second target vector result, and the second target vector result is stored in a corresponding second preset vector database. The second preset vector database can be one of the databases such as FAISS, Chroma and dqrant.

[0098] and / or,

[0099] Step S23: Based on the third preset model, perform a third vectorization operation on the third target RAG text segmentation result to generate a third target vector result.

[0100] Exemplarily, the third preset model may be one of OpenAI, MistralAI, Ollama, TextEmbeddings and Inference.

[0101] Specifically, based on the third preset model, a third vectorization operation can be performed on the third target RAG text segmentation result to generate a third target vector result, and the third target vector result is stored in a corresponding third preset vector database. The third preset vector database can be one of the databases such as FAISS, Chroma and dqrant.

[0102] It should be noted that the first preset model, the second preset model, and / or the third preset model are different from each other. The first preset vector database, the second preset vector database, and / or the third preset vector database are different from each other.

[0103] Based on this, the above method can realize the vectorization operation of multiple target RAG text segmentation results based on multiple preset models to generate multiple vector results based on multiple semantic levels, improve the comprehensiveness and accuracy of data vectorization, and provide a data basis for performing multi-dimensional retrieval operations and improving the diversity, reliability and accuracy of RAG results. Among them, the isolated storage of multiple vector results is conducive to improving the efficiency of data query reference and improving the security of data storage.

[0104] Step S3: Generate multiple RAG results based on multiple target vector results.

[0105] Exemplarily, a search operation may be performed on a plurality of target vector results based on a plurality of vector databases to generate a plurality of RAG results, wherein the plurality of vector databases include: FAISS, Chroma, dqrant, and the like.

[0106] In some feasible implementations, step S3: generating multiple RAG results according to multiple target vector results includes:

[0107] Step S31: Based on the first vector database, perform a first search operation on the first target vector result to generate a first RAG result.

[0108] Exemplarily, when the first target vector result is stored in the FAISS database, a corresponding first search operation is performed on the first target vector result based on the FAISS database to generate a first RAG result.

[0109] Step S32: Based on the second vector database, perform a second search operation on the second target vector result to generate a second RAG result.

[0110] Exemplarily, when the second target vector result is stored in the Chroma database, a corresponding second search operation is performed on the second target vector result based on the Chroma database to generate a second RAG result.

[0111] and / or,

[0112] Step S33: Based on the third vector database, perform a third search operation on the third target vector result to generate a third RAG result.

[0113] Exemplarily, when the third target vector result is stored in the dqrant database, a corresponding third search operation is performed on the third target vector result based on the dqrant database to generate a third RAG result.

[0114] Based on this, the above method can realize retrieval operations on multiple vector results based on multiple vector databases to improve the coverage and comprehensiveness of RAG results, thereby providing a data basis for reducing the isolation of RAG response results, improving the coverage and comprehensiveness of RAG response results, and improving the reference value of RAG response results.

[0115] Step S4: Generate RAG ranking weight results based on multiple RAG results.

[0116] It should be noted that, based on the similarity algorithm preset in each vector database, the RAG sorting result corresponding to each vector database can be generated according to the multiple RAG results, and the corresponding RAG sorting weight result can be generated according to the RAG sorting result corresponding to each vector database. Among them, the similarity algorithm preset in the vector database may include: Euclidean distance, Manhattan distance, cosine similarity, etc.

[0117] In some feasible implementations, step S4: generating RAG ranking weight results according to multiple RAG results includes:

[0118] Step S41: Generate a first similarity result according to the first RAG result.

[0119] Exemplarily, the above vector database can be used with V ec The above RAG result contains multiple RAG result elements. The above RAG result elements can be represented by R, where the i-th RAG result element can be represented by R i express.

[0120] For example, based on the first vector database An internally preset similarity algorithm generates a first similarity result according to the first RAG result.

[0121] Specifically, the first similarity result may include: R 1 The corresponding similarity is 1, R 2 The corresponding similarity is R 3 The corresponding similarity is R 4 The corresponding similarity is R 5 The corresponding similarity is

[0122] Step S42: Generate a second similarity result according to the second RAG result.

[0123] For example, based on the second vector database An internally preset similarity algorithm generates a second similarity result according to the second RAG result.

[0124] Specifically, the second similarity result may include: R 2 The corresponding similarity is 1, R 1 The corresponding similarity is R 3 The corresponding similarity is R 5 The corresponding similarity is R 4 The corresponding similarity is

[0125] and / or,

[0126] Step S43: Generate a third similarity result according to the third RAG result.

[0127] For example, based on the third vector database An internally preset similarity algorithm generates a second similarity result according to the third RAG result.

[0128] Specifically, the third similarity result may include: R 2 The corresponding similarity is 1, R 1 The corresponding similarity is R 4 The corresponding similarity is R 5 The corresponding similarity is R 3 The corresponding similarity is

[0129] Step S44: Generate a RAG sorting weight result according to the first similarity result, the second similarity result, and / or the third similarity result.

[0130] Specifically, the ranking weight result of each RAG result element in the above-mentioned first RAG result can be determined according to the following formula.

[0131]

[0132] in, Used to represent the first vector database The weight of the i-th RAG result element in Similar(R i ) 1 Used to represent the first vector database The similarity of the i-th RAG result element in .

[0133] Specifically, the ranking weight result of each RAG result element in the second RAG result can be determined according to the following formula.

[0134]

[0135] in, Used to represent the second vector database The weight of the i-th RAG result element in Similar(R i ) 2 Used to represent the second vector database The similarity of the i-th RAG result element in .

[0136] Specifically, the sorting result of each RAG result element in the third RAG result may be determined according to the following formula.

[0137]

[0138] in, Used to represent the third vector database The weight of the i-th RAG result element in Similar(R i ) 3 Used to represent the third vector database The similarity of the i-th RAG result element in .

[0139] For example, based on the first vector database Second vector database and / or, a second vector database According to the first similarity result, the second similarity result, and / or the third similarity result, determining the RAG result elements included in the primary RAG result includes: R 1 , R 2 , R 3 , R 4 and R 5 , then the RAG ranking weight results can be determined according to the above formulas (1)-(3) including: The corresponding weight is 1. The corresponding weight is 2. The corresponding weight is 3, The corresponding weight is 4, The corresponding weight is 5. Among them, The corresponding weight is 1. The corresponding weight is 2. The corresponding weight is 3, The corresponding weight is 4, The corresponding weight is 5. Among them, The corresponding weight is 1. The corresponding weight is 2. The corresponding weight is 3, The corresponding weight is 4, The corresponding weight is 5.

[0140] Based on this, the above method can achieve accurate generation of RAG sorting weight results based on the first similarity result, the second similarity result, and / or the third similarity result, and provide accurate data support for generating target RAG sorting results based on the RAG sorting weight results.

[0141] Step S5: Generate a target RAG sorting result according to the RAG sorting weight result.

[0142] In some feasible implementations, the i-th RAG result element may be used to generate the result in each vector database V ec The corresponding weight results in generate the target ranking result of the i-th RAG result element.

[0143] For example, it can be based on The corresponding weight is 1. The corresponding weight is 2. The corresponding weight is 2, determining R 1 Target sorting results.

[0144] In some feasible implementations, step S5: generating a target RAG sorting result according to the RAG sorting weight result includes:

[0145] Step S51: Determine the scoring information of the target RAG result based on the RAG sorting weight result, the preset constant, the first weight information corresponding to the first vector database, the second weight information corresponding to the second vector database, and / or the third weight information corresponding to the third vector database.

[0146] Exemplarily, the preset constant may be represented by k to reduce the influence of outliers on the scoring information. Specifically, the value of k may be 60.

[0147] Exemplarily, the first weight information can be expressed as w 1 Indicates that the second weight information can be expressed as w 2 Indicates that the third weight information can be expressed as w 3 express.

[0148] Exemplarily, the score information of the above target RAG result can be determined according to the following formula:

[0149]

[0150] Among them, Score (R i ) is used to represent the score of the i-th RAG result element, k is used to represent a preset constant, Used to represent the j-th vector database The weight of the i-th RAG result element in , w j Used to represent the weight corresponding to the j-th vector database.

[0151] Specifically, R 1 For example, based on the above formula (4), the score of the first RAG result element can be determined based on the following formula:

[0152]

[0153] Among them, Score (R 1 ) is used to represent the score of the first RAG result element, k is used to represent a preset constant, Used to represent the first vector database The weight of the first RAG result element in, Used to represent the second vector database The weight of the first RAG result element in, Used to represent the third vector database The weight of the first RAG result element in 1 Used to represent the first weight information, w 2 Used to represent the second weight information, w 3 Used to represent the third weight information.

[0154] Specifically, the preset constant k is 60, and the first weight information w 1 is 0.4, the second weight information w 2 is 0.3, the third weight information w 3 The results of the above RAG ranking weights are 0.3 and include: The corresponding weight is 1. The corresponding weight is 2. The corresponding weight is 3, The corresponding weight is 4, The corresponding weight is 5. Among them, The corresponding weight is 1. The corresponding weight is 2. The corresponding weight is 3, The corresponding weight is 4, The corresponding weight is 5. Among them, The corresponding weight is 1. The corresponding weight is 2. The corresponding weight is 3, The corresponding weight is 4, When the corresponding weight is 5, based on the above formula (4), it can be deduced that:

[0155]

[0156]

[0157] Among them, Score (R 1 ) is the score of the first RAG result element, Score(R 2 ) is the score of the second RAG result element, Score(R 3 ) is the score of the third RAG result element, Score(R 4 ) is the score of the fourth RAG result element, Score(R 5 ) is the score of the 5th RAG result element.

[0158] Step S52: Generate a target RAG result sorting result based on the scoring information.

[0159] It should be noted that the above-mentioned target RAG result sorting results can be displayed in descending order according to the above-mentioned scoring information.

[0160] Specifically, based on the above formulas (6)-(10), the target RAG result ranking result can be determined as: 2 , R 1 , R 3 , R 4 and R 5 .

[0161] Based on this, the above method can realize the accurate determination of the scoring information of the target RAG result according to the RAG sorting weight result, the preset constant, the first weight information corresponding to the first vector database, the second weight information corresponding to the second vector database, and / or the third weight information corresponding to the third vector database, and accurately generate the target RAG result sorting result according to the above scoring information, which is conducive to improving the accuracy of the target RAG response result.

[0162] In some feasible implementations, the method 100 further includes:

[0163] Step S53: Modify the first weight information, the second weight information, and / or the third weight information according to the historical retrieval result accuracy data, the contained query type data, and / or the applicable field type data of the first vector database, the second vector database, and / or the third vector database.

[0164] Exemplarily, when it is determined that the target vector database has a high degree of match with the target RAG text based on the historical retrieval result accuracy data, the query type data contained, and / or the applicable field type data of the first vector database, the second vector database, and / or the third vector database, the first weight information corresponding to the first vector database, the second weight information corresponding to the second vector database, and / or the third weight information corresponding to the third vector database are increased.

[0165] Exemplarily, when it is determined that the target vector database has a low degree of match with the target RAG text based on the historical retrieval result accuracy data, the query type data contained therein, and / or the applicable field type data of the first vector database, the second vector database, and / or the third vector database, the first weight information corresponding to the first vector database, the second weight information corresponding to the second vector database, and / or the third weight information corresponding to the third vector database are reduced.

[0166] Based on this, the above method can realize accurate and dynamic correction of the first weight information, the second weight information, and / or the third weight information according to the historical retrieval result accuracy data, the query type data contained, and / or the applicable field type data of the first vector database, the second vector database, and / or the third vector database, so as to further improve the accuracy of the target RAG sorting results, thereby improving the reference value of the target RAG response results.

[0167] Step S6: Generate a target RAG response result according to the target RAG sorting result.

[0168] For example, the search results with a relatively high ranking can be determined based on the target RAG sorting results. The search results with a relatively high ranking are refined and integrated based on the large model to generate the target RAG response results that conform to the contextual dialogue text.

[0169] Based on this, the RAG result generation method provided by the present application includes: generating a plurality of target RAG text segmentation results according to the target RAG text; generating a plurality of corresponding target vector results according to the plurality of target RAG text segmentation results; generating a plurality of RAG results according to the plurality of target vector results; generating a plurality of RAG results according to the plurality of RAG results, generating RAG sorting weight results; generating a target RAG sorting result according to the RAG sorting weight results; generating a target RAG response result according to the target RAG sorting result. The present application is based on a plurality of text segmentation methods, a plurality of vectorization methods, and a plurality of vector storage and retrieval methods, which is conducive to reducing the dependence of the RAG response results on a single text segmentation method, a single vectorization method, and a single vector storage and retrieval method, improving the data dimensions contained in the RAG response results, improving the coverage and comprehensiveness of the RAG response results, and performing multi-level sorting on the RAG results, which is conducive to improving the accuracy of the RAG response results, thereby improving the reference value of the RAG response results.

[0170] In some feasible implementations, as described in any of the above methods, the above step S6: generating a target RAG response result according to the target RAG sorting result includes:

[0171] Step S61: Obtain similarity information between any two target RAG results in the target RAG response results.

[0172] Exemplarily, the similarity information between any two target RAG results in the target RAG response results may be determined based on Euclidean distance, Manhattan distance, and / or cosine similarity.

[0173] Step S62: When the similarity information is greater than or equal to the preset similarity threshold, a target merging operation is performed on the two target RAG results to generate the above-mentioned target RAG response result.

[0174] Exemplarily, when it is determined that the similarity information between any two target RAG results is greater than or equal to a preset similarity threshold, a merge operation is performed on the two target RAG results to generate the target RAG response result. The preset similarity threshold can be defined by the user according to the accuracy requirement of the target RAG response result.

[0175] Based on this, the above method can accurately reduce the redundancy of the target RAG response results, and improve the efficiency of the target search user in consulting the target RAG response results while ensuring the reference value of the target RAG response results.

[0176] In some feasible implementations, the above step S6: generating a target RAG response result according to the target RAG sorting result further includes:

[0177] Step S63: Obtain the fusion degree information between any two target RAG results in the target RAG response result.

[0178] Exemplarily, the fusion degree information between any two target RAG results mentioned above may be determined according to the conflict degree and / or contradiction degree between any two target RAG results mentioned above.

[0179] Step S64: When the fusion degree information is less than the preset fusion degree threshold, based on the context information of the target RAG text and / or the credibility information of the two target RAG results, determine the target reference RAG result to generate the above-mentioned target RAG response result.

[0180] Exemplarily, when the degree of fusion between any two target RAG results mentioned above is less than a preset fusion degree threshold based on the degree of conflict and / or the degree of contradiction between the above-mentioned any two target RAG results, then according to the context information of the target RAG text and / or the credibility information of the two target RAG results, the target RAG result with a higher correlation with the context information of the target RAG text and / or a higher credibility is selected as the target reference RAG result to generate the above-mentioned target RAG response result.

[0181] Based on this, the above method can accurately reduce the conflict and / or contradiction of the target RAG response results, improve the integration of the target RAG response results, and thus accurately improve the reference value of the target RAG response results.

[0182] In some feasible implementations, the method 100 further includes:

[0183] Step S7: Obtain the historical behavior data of the target search user.

[0184] Exemplarily, the above historical behavior data may include: click data, stay data, rating data, etc.

[0185] Specifically, the click data may correspond to link data or document data clicked by the target retrieval user within a preset time in the past.

[0186] Specifically, the above-mentioned dwelling data may correspond to the page dwelling time data or document dwelling time data of the above-mentioned target retrieval user within a preset time in the past.

[0187] Specifically, the above-mentioned rating data may correspond to the rating data of the above-mentioned target retrieval user for the historical browsing content within the past preset time.

[0188] It should be noted that the above preset time is positively correlated with the user's requirement for the correction accuracy of the target RAG sorting result, that is, the higher the user's requirement for the correction accuracy of the target RAG sorting result, the longer the above preset time.

[0189] Step S8: Modify the target RAG sorting result according to the historical behavior data.

[0190] In some feasible implementations, based on a reinforcement learning mechanism, the data retrieval preference data of the target retrieval user can be determined according to the historical behavior data, and the target RAG ranking result can be corrected according to the data retrieval preference data, wherein the RAG result with a higher degree of consistency with the data retrieval preference of the target retrieval user will be ranked higher in the target RAG ranking result.

[0191] Based on this, the above method can realize personalized modification of the target RAG sorting results according to the historical behavior data of the target retrieval user, which is conducive to improving the consistency of the target RAG response results and the data retrieval preferences of the target retrieval user, thereby improving the retrieval experience of the target retrieval user.

[0192] It should be noted that, in some feasible implementations, the target RAG response result may be optimized based on multiple rounds of interactive dialogues with the target search user to further improve the accuracy of the target RAG response result.

[0193] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.

[0194] The above is an introduction to the method embodiment. The following is a further explanation of the scheme described in this application through an apparatus embodiment.

[0195] According to a second aspect of an embodiment of the present application, a RAG response result generating device is provided. Figure 2 Schematic diagram of the structure of a RAG response result generating device 200 provided in an embodiment of the present application. Figure 2 The device 200 shown includes: a first generating unit 210 , a second generating unit 220 , a third generating unit 230 , a fourth generating unit 240 , a fifth generating unit 250 and a sixth generating unit 260 .

[0196] A first generating unit 210 is used to generate a plurality of target RAG text segmentation results according to the target RAG text;

[0197] A second generating unit 220, configured to generate corresponding multiple target vector results according to multiple target RAG text segmentation results;

[0198] A third generating unit 230, configured to generate a plurality of RAG results according to the plurality of target vector results;

[0199] The fourth generating unit 240 is used to generate a RAG ranking weight result according to the multiple RAG results;

[0200] A fifth generating unit 250, configured to generate a target RAG sorting result according to the RAG sorting weight result;

[0201] The sixth generating unit 260 is configured to generate a target RAG response result according to the target RAG sorting result.

[0202] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the described method can refer to the corresponding process in the aforementioned system embodiment, and will not be repeated here.

[0203] Figure 3 A schematic diagram of the structure of a terminal device or server suitable for implementing an embodiment of the present application is shown.

[0204] like Figure 3 As shown, the electronic device 300 includes a central processing unit (CPU) 301, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 302 or the program loaded from the storage part 508 into the random access memory (RAM) 303. In the RAM 303, various programs and data required for the operation of the terminal device or the server are also stored. The CPU 301, the ROM 302, and the RAM 303 are connected to each other through the bus 304. The input / output (I / O) interface 305 is also connected to the bus 304.

[0205] The following components are connected to the I / O interface 305: an input section 306 including a keyboard, a mouse, etc.; an output section 307 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 308 including a hard disk, etc.; and a communication section 309 including a network interface card such as a LAN card, a modem, etc. The communication section 309 performs communication processing via a network such as the Internet. A drive 310 is also connected to the I / O interface 305 as needed. A removable medium 311, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 310 as needed, so that a computer program read therefrom is installed into the storage section 308 as needed.

[0206] In particular, according to an embodiment of the present application, the above method flow steps can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a machine-readable medium, and the computer program includes a program code for executing the method shown in the flow chart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 309, and / or installed from the removable medium 311. When the computer program is executed by the central processing unit (CPU) 301, the above-mentioned functions defined in the system of the present application are executed.

[0207] It should be noted that the computer-readable medium shown in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0208] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of the code, and the aforementioned module, program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0209] The units or modules involved in the embodiments described in the present application may be implemented by software or hardware. The units or modules described may also be arranged in a processor. The names of these units or modules do not, in some cases, constitute limitations on the units or modules themselves.

[0210] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of application involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the aforementioned application concept. For example, the above features are replaced with (but not limited to) technical features with similar functions applied in the present application.

Claims

1. A method for generating a RAG response result, characterized in that: include: Generate multiple target RAG text segmentation results according to the target RAG text; Generate corresponding multiple target vector results according to the multiple target RAG text segmentation results; generating a plurality of RAG results according to the plurality of target vector results; Generate RAG ranking weight results according to the multiple RAG results; Generate a target RAG sorting result according to the RAG sorting weight result; A target RAG response result is generated according to the target RAG sorting result.

2. The method according to claim 1, characterized in that The generating of a plurality of target RAG text segmentation results according to the target RAG text includes: Based on the overlapping sliding window segmentation method, performing a first target segmentation operation on the target RAG text to generate a first target RAG text segmentation result; Based on the large model segmentation method, performing a second target segmentation operation on the target RAG text to generate a second target RAG text segmentation result; and / or, Based on the paragraph-sentence mixed segmentation method, a third target segmentation operation is performed on the target RAG text to generate a third target RAG text segmentation result.

3. The method according to claim 2, characterized in that The generating corresponding multiple target vector results according to the multiple target RAG text segmentation results includes: Based on a first preset model, performing a first vectorization operation on the first target RAG text segmentation result to generate a first target vector result; Based on a second preset model, performing a second vectorization operation on the second target RAG text segmentation result to generate a second target vector result; and / or, Based on the third preset model, a third vectorization operation is performed on the third target RAG text segmentation result to generate a third target vector result.

4. The method according to claim 3, characterized in that The generating a plurality of RAG results according to the plurality of target vector results comprises: Based on the first vector database, performing a first search operation on the first target vector result to generate a first RAG result; Based on the second vector database, performing a second search operation on the second target vector result to generate a second RAG result; and / or, Based on the third vector database, a third search operation is performed on the third target vector result to generate a third RAG result.

5. The method according to claim 4, characterized in that The generating RAG sorting weight results according to the multiple RAG results includes: Generate a first similarity result according to the first RAG result; generating a second similarity result according to the second RAG result; and / or, Generating a third similarity result according to the third RAG result; The RAG sorting weight result is generated according to the first similarity result, the second similarity result, and / or the third similarity result.

6. The method according to claim 5, characterized in that Generating a target RAG sorting result according to the RAG sorting weight result includes: Determine the score information of the target RAG result according to the RAG sorting weight result, a preset constant, the first weight information corresponding to the first vector database, the second weight information corresponding to the second vector database, and / or the third weight information corresponding to the third vector database; According to the scoring information, a target RAG result ranking result is generated.

7. The method according to claim 6, characterized in that Also includes: The first weight information, the second weight information, and / or the third weight information are modified based on the historical retrieval result accuracy data, the contained query type data, and / or the applicable field type data of the first vector database, the second vector database, and / or the third vector database.

8. The method according to any one of claims 1 to 7, characterized in that The generating a target RAG response result according to the target RAG sorting result includes: Obtaining similarity information between any two target RAG results in the target RAG response results; In a case where the similarity information is greater than or equal to a preset similarity threshold, a target merging operation is performed on the two target RAG results to generate the target RAG response result.

9. The method according to claim 8, characterized in that Also includes: Obtain historical behavior data of the target retrieval user; According to the historical behavior data, the target RAG sorting result is modified.

10. A RAG response result generating device, characterized in that: include: A first generating unit is used to generate a plurality of target RAG text segmentation results according to the target RAG text; A second generating unit, configured to generate corresponding multiple target vector results according to the multiple target RAG text segmentation results; A third generating unit, configured to generate a plurality of RAG results according to the plurality of target vector results; A fourth generating unit, configured to generate a RAG ranking weight result according to the multiple RAG results; A fifth generating unit, configured to generate a target RAG sorting result according to the RAG sorting weight result; The sixth generating unit is used to generate a target RAG response result according to the target RAG sorting result.

Citation Information

Cited By

  • Dynamic collaborative scheduling method and system for question-answering system based on MCP

    CN121543703A