Intelligent question answering method and system based on large model

By building a vector knowledge base and adopting a hybrid search and rerank model method, the illusion and privacy problems of large models in intelligent question-and-answer are solved, and the construction accuracy of knowledge base and the accuracy of semantic matching are improved.

CN119691116APending Publication Date: 2025-03-25CHANGSHA MILITARY & CIVIL ADVANCED TECH RES CO LTD
View PDF 0 Cites 9 Cited by

Patent Information

Application Number
CN202411738444.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-29
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

The hallucination problems and privacy leaks of big models in smart Q&A, and the knowledge base is difficult to accurately construct, resulting in a decrease in semantic matching accuracy.

Method used

By obtaining the original document for data analysis, recognition, transformation and vectorization, a vector knowledge base is constructed; a mixed search method of semantic matching and keyword matching is used for preliminary recall, and reordering is used for rerank to improve matching accuracy.

Benefits of technology

It solves the problem of large-model illusion and privacy, improves the accuracy of the construction accuracy of vector knowledge base and the accuracy of semantic matching, and avoids the decrease in matching accuracy caused by the increase in knowledge base.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119691116A_ABST
    Figure CN119691116A_ABST
Patent Text Reader

Abstract

The invention discloses an intelligent question and answer method and system based on a large model, and the method comprises the steps: obtaining an original document, carrying out the data analysis, recognition, conversion and vectorization of the original document, and constructing a vector knowledge base; obtaining user questions, vectorizing the user questions, and converting the user questions into high-dimensional vector representation; based on the vectorized user question and the vector knowledge base, adopting a semantic matching and keyword matching mixed retrieval method to carry out preliminary multi-segment text recall to obtain a candidate text list; performing reordering by using a erank model, and reordering the preliminarily screened text lists to obtain more accurate text lists according to scores from high to low; and filtering the questions of the user and the text list matched with the text according to a threshold value, and sending the questions and the text list to the large model to obtain answers. The matching accuracy of the large-data-volume vector knowledge base is effectively improved, and the problems that in the prior art, the vector knowledge base is difficult to construct accurately, and the semantic matching accuracy is reduced due to the fact that the knowledge base is enlarged are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of deep learning technology, and in particular relates to an intelligent question-answering method and system based on a large model. Background Art

[0002] With the continuous development of big model technology in recent years, big models have been widely used in the field of intelligent question answering. Compared with traditional algorithms, big models can understand natural language more accurately, and the answers to users are more acceptable. However, intelligent question answering using big models also faces some challenges. Due to the inherent illusion problem of big models, the answers may occasionally be inconsistent with reality and logic; enterprises and personal privacy data are also unwilling to be trained into big models to avoid privacy leakage problems caused by this. The current mainstream approach is to reduce the illusion and privacy problems of big models by mounting a knowledge vector library outside the big model, but it will encounter the problem that the knowledge base is difficult to accurately build, and the vector matching accuracy decreases as the knowledge base becomes larger and larger. Summary of the invention

[0003] In response to the above technical problems, the present invention provides an intelligent question answering method and system based on a large model.

[0004] The technical solution adopted by the present invention to solve the technical problem is:

[0005] An intelligent question answering method based on a large model, the method comprising the following steps:

[0006] S100: obtaining the original document, performing data analysis, recognition, conversion and vectorization on the original document, and building a vector knowledge base;

[0007] S200: Obtain user questions, vectorize the user questions, and convert them into high-dimensional vector representations;

[0008] S300: Based on the vectorized user questions and vector knowledge base, a hybrid retrieval method of semantic matching and keyword matching is used to perform preliminary multi-segment text recall to obtain a list of candidate texts;

[0009] S400: reranking the text list initially screened using the rerank model to obtain a more accurate text list in descending order of scores;

[0010] S500: The user's question and the text list that matches the text are filtered according to a threshold and sent together to the big model to obtain an answer.

[0011] Preferably, S100 includes:

[0012] S110: The original document is the original data for constructing the vector knowledge base. The extension of the document is read by a program. A corresponding parsing tool is used according to different extensions to parse the document by the parsing tool.

[0013] S120: cyclically reading the content blocks of the parsed document, determining the type of the content blocks, directly reading out if the type of the content block is text, and using OCR to recognize if the type of the content block is an image, and splicing the recognized text to the end of the recognized text string;

[0014] S130: converting the entire string content after reading into a markdown format string using a tool;

[0015] S140: using a text segmentation tool for markdown format to perform a word segmentation chunk operation on the text to form a string list;

[0016] S150: Finally, the pre-trained embedding model is used to vectorize each chunk into a vector library to form a vector knowledge base, wherein the vector knowledge base uses Elasticsearch to store vector data.

[0017] Preferably, in S300, the BM25 word frequency statistics method of Elasticsearch is used to perform keyword matching, specifically:

[0018]

[0019] Where IDF(q) is the inverse document frequency of a single document, N is the total number of documents, and n is the total number of documents containing word q;

[0020]

[0021] where q i is the i-th query item; IDF(q i ) is the inverse document frequency of the i-th query term; represents the total inverse document frequency of all query items; fieldLen represents the length of the field; avgFieldLen represents the average field length; D is the document; f(q i ,D) is the number of times the i-th query term appears in the document; k1 is the degree of influence of limiting a single query term on the score of a given document, ranging from 0 to 1; b is the degree of influence of controlling the ratio of document length to average length, ranging from 0 to 1, and Score(D,q) is the total relevance score of the query document.

[0022] Preferably, in S300, cosine similarity is used for semantic matching, and the calculation process of cosine is the dot product of two vectors divided by the length of the two vectors, specifically:

[0023]

[0024] Where Q is the vector corresponding to the query question, D is the vector of the matched document, and cos is the final cosine calculation value. The value range of cos is -1 to 1.

[0025] Preferably, S300 includes:

[0026] Enhanced search is performed by combining semantic search and keyword search, and weighted scores are used to obtain the final score of text matching, specifically:

[0027] score=α*score v +(1-α)score s

[0028] Among them, score represents the final score; score v Indicates the semantic matching score; score s Indicates the keyword matching score; α indicates the weighted value, which ranges from 0 to 1;

[0029] The multiple texts are sorted according to their final scores, and the first preset number of texts are selected to obtain a candidate text list, thereby achieving preliminary recall of multiple texts.

[0030] Preferably, S400 includes:

[0031] The rerank model calculates the matching degree between the candidate text list and the user question by evaluating the correlation between the user question and each candidate document, and then sorts them from high to low according to the correlation degree. The first second preset number of data items are set to be returned to complete the second reranking.

[0032] Preferably, S500 includes:

[0033] Remove irrelevant text lists based on the score threshold, and then take the sorted text lists corresponding to the topK values ​​according to the configured topK values ​​and assemble them together with the user questions and send them to the large model for answering.

[0034] An intelligent question-answering system based on a large model, comprising a vector knowledge base construction module, a user question vectorization module, a text preliminary recall module, a reordering module and a large model answering module;

[0035] The vector knowledge base construction module is used to obtain the original document, perform data analysis, recognition, conversion and vectorization on the original document, and build a vector knowledge base;

[0036] The user question vectorization module is used to obtain user questions, vectorize them, and convert them into high-dimensional vector representations;

[0037] The text preliminary recall module is used to perform preliminary multi-segment text recall based on the vectorized user questions using a hybrid retrieval method of semantic matching and keyword matching to obtain a list of candidate texts;

[0038] The reranking module is used to rerank the text list that has been initially screened using the rerank model to obtain a more accurate text list from high to low scores;

[0039] The big model answer module is used to filter the user's question and the text list that matches the text according to the threshold and send them to the big model together to obtain the answer.

[0040] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned intelligent question-answering method based on a large model when executing the computer program.

[0041] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the above-mentioned intelligent question-answering method based on a large model.

[0042] The above-mentioned intelligent question-answering method and system based on a large model converts document knowledge into a structured markdown document through OCR and document conversion technology, and then vectorizes the paragraphs to build a high-quality knowledge vector library. In the retrieval enhancement stage, semantic retrieval and keyword matching technology are used to accurately match the text with the highest similarity to the user's question, and finally the rerank model is combined for re-matching to improve the matching accuracy of the large-scale vector knowledge base, so as to solve the problem of the difficulty in accurately constructing the vector knowledge base and the decrease in semantic matching accuracy caused by the increase of the knowledge base in the existing technology. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 This is a flow chart of an intelligent question-answering method based on a large model in one embodiment of the present invention;

[0044] Figure 2 This is a flow chart of an intelligent question-answering method based on a large model in another embodiment of the present invention;

[0045] Figure 3 FIG. 1 is a diagram of the steps for constructing a vector knowledge base in one embodiment of the present invention. DETAILED DESCRIPTION

[0046] In order to enable those skilled in the art to better understand the technical solution of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings.

[0047] In one embodiment, Figure 1 and Figure 2As shown, an intelligent question answering method based on a large model comprises the following steps:

[0048] S100: obtaining the original document, performing data analysis, recognition, conversion and vectorization on the original document, and building a vector knowledge base;

[0049] S200: Obtain user questions, vectorize the user questions, and convert them into high-dimensional vector representations;

[0050] S300: Based on the vectorized user questions and vector knowledge base, a hybrid retrieval method of semantic matching and keyword matching is used to perform preliminary multi-segment text recall to obtain a list of candidate texts;

[0051] S400: reranking the text list initially screened using the rerank model to obtain a more accurate text list in descending order of scores;

[0052] S500: The user's question and the text list that matches the text are filtered according to a threshold and sent together to the big model to obtain an answer.

[0053] The above-mentioned intelligent question-answering method based on a large model supports multiple types of original data when building a vector knowledge base, including documents and pictures in various common formats. These original methods are converted into vectors for storage through the vector embedding model through the tools in the system; the same vector embedding model is also needed to represent high-dimensional vectors when obtaining user questions; enhanced retrieval is implemented by combining semantics and keywords with the rerank model; and finally the matched text and user input are given to the large model for answering. Hybrid search combined with rerank secondary rearrangement reveals a new type of enhanced retrieval implementation based on RAG, which can maintain a high matching accuracy when dealing with large-scale knowledge base retrieval.

[0054] In one embodiment, Figure 3 As shown, S100 includes:

[0055] S110: The original document is the original data for constructing the vector knowledge base. The extension of the document is read by a program. A corresponding parsing tool is used according to different extensions to parse the document by the parsing tool.

[0056] S120: cyclically reading the content blocks of the parsed document, determining the type of the content blocks, directly reading out if the type of the content block is text, and using OCR to recognize if the type of the content block is an image, and splicing the recognized text to the end of the recognized text string;

[0057] S130: converting the entire string content after reading into a markdown format string using a tool;

[0058] S140: using a text segmentation tool for markdown format to perform a word segmentation chunk operation on the text to form a string list;

[0059] S150: Finally, the pre-trained embedding model is used to vectorize each chunk into a vector library to form a vector knowledge base, wherein the vector knowledge base uses Elasticsearch to store vector data.

[0060] Specifically, when constructing a vector knowledge base, this method supports a variety of raw data types, including documents and images in various common formats, and converts these raw data into vectors for storage through the vector embedding model using tools in the system;

[0061] First, prepare documents in the knowledge areas that users may ask questions about, including but not limited to TXT, PDF, Word, PPT and Excel, and upload these documents to the system to carry out the vector knowledge base construction process; the parsing tool in the system will first identify the extension of the document and obtain the corresponding parsing tool based on the extension. For example, for a PDF document, the corresponding PDF parsing tool will be obtained, and for a Word document, the corresponding Word parsing tool will be obtained; then the system will read the parsed documents in a loop and determine the type of content block. If it is text, it will be read directly; if it is a picture, OCR will be started for text extraction. All the read text contents are concatenated to form the string format corresponding to the original document or image; the entire string is converted into a string in markdown format using a markdown conversion tool for subsequent text processing; a text segmentation tool specifically for markdown format is used to segment the markdown string text (chunk operation) to form a string list after segmentation. When performing segmentation, the level of segmentation can be customized according to the document content. For example, it can be configured to segment according to level 3 or level 4 titles. The larger the level of segmentation, the finer the content of each segmentation list; the string list after segmentation is then vectorized using a pre-trained embedding model to form a vector knowledge base. The vector knowledge base is stored in Elasticsearch for subsequent retrieval and matching.

[0062] Furthermore, the user inputs questions in the system's interactive interface, and the backend service obtains the user's input content and uses the same embedding model as the previous step for vectorization to convert the user's input content into a high-dimensional vector.

[0063] In one embodiment, S300 uses the BM25 word frequency statistics method of Elasticsearch to perform keyword matching, specifically:

[0064]

[0065] Where IDF(q) is the inverse document frequency of a single document, N is the total number of documents, and n is the total number of documents containing word q;

[0066]

[0067] where q i is the i-th query item; IDF(q i ) is the inverse document frequency of the i-th query term; represents the total inverse document frequency of all query items; fieldLen represents the length of the field; avgFieldLen represents the average field length; D is the document; f(q i ,D) is the number of times the i-th query term appears in the document; k1 is the degree of influence of limiting a single query term on the score of a given document, ranging from 0 to 1; b is the degree of influence of controlling the ratio of document length to average length, ranging from 0 to 1, and Score(D,q) is the total relevance score of the query document.

[0068] In one embodiment, cosine similarity is used in S300 to perform semantic matching. The calculation process of cosine is the dot product of two vectors divided by the length of the two vectors, specifically:

[0069]

[0070] Where Q is the vector corresponding to the query question, D is the vector of the matched document, and cos is the final cosine calculation value. The value range of cos is -1 to 1.

[0071] In one embodiment, S300 includes:

[0072] Enhanced search is performed by combining semantic search and keyword search, and weighted scores are used to obtain the final score of text matching, specifically:

[0073] score=α*score v +(1-α)score s

[0074] Among them, score represents the final score; score v Indicates the semantic matching score, corresponding to the final cosine calculation value; score s It represents the keyword matching score, which corresponds to the total relevance score of the query document; α represents the weighted value, which ranges from 0 to 1;

[0075] The multiple texts are sorted according to their final scores, and the first preset number of texts are selected to obtain a candidate text list, thereby achieving preliminary recall of multiple texts.

[0076] In one embodiment, S400 includes:

[0077] The rerank model calculates the matching degree between the candidate text list and the user question by evaluating the correlation between the user question and each candidate document, and then sorts them from high to low according to the correlation degree. The first second preset number of data items are set to be returned to complete the second reranking.

[0078] Specifically, after building the knowledge vector library, the user's input needs to be matched in the index stored in Elasticsearch. The matching process is to use the DSL syntax provided by Elasticsearch to set the matching method, adopt a hybrid retrieval method of semantic matching and keyword matching, configure the filtering score threshold, the weight coefficient of semantic retrieval and keyword retrieval, and the first number of data to be taken. The score threshold is generally set low to ensure that all texts with some relationship are matched; the first number of data to be taken is also generally set relatively large, for example, set to 100, which means taking the first 100 matching data, and finally entering the matching text list in descending order of scores.

[0079] After the first mixed search, the number of matching text lists is generally large, such as the first 100. At this time, the rerank model is used for the second re-ranking. The user's input text and the text list matching the first search are passed into the rerank model as input, and the number of data to be returned is set (for example, set to 20). The model will return the top 20 most matching texts in the user input and the provided text list.

[0080] In one embodiment, S500 includes:

[0081] Remove irrelevant text lists based on the score threshold, and then take the sorted text lists corresponding to the topK values ​​according to the configured topK values ​​and assemble them together with the user questions and send them to the large model for answering.

[0082] Specifically, the secondarily reordered text list obtained in the previous step and the user input are assembled through prompts and input into the large model together to obtain the answer to the question.

[0083] The above-mentioned intelligent question answering based on a large model has the following technical effects:

[0084] (1) Efficiency: By providing common document types and image parsing and recognition tools, text and images can be quickly recognized as text and stored in vector form. At the same time, based on the distributed function of Elasticsearch, the system can also provide fast retrieval capabilities for large amounts of data.

[0085] (2) Scalability: The present invention abstractly designs text parsing and recognition, text matching, and large model answers, making the present invention highly versatile and applicable in many scenarios with only minor modifications.

[0086] (3) Accuracy: The present invention uses semantic search and keyword search to perform the first mixed search, and then performs a second re-ranking through the rerank model, avoiding the problem of decreased matching accuracy as the database becomes larger.

[0087] An intelligent question-answering system based on a large model, comprising a vector knowledge base construction module, a user question vectorization module, a text preliminary recall module, a reordering module and a large model answering module;

[0088] The vector knowledge base construction module is used to obtain the original document, perform data analysis, recognition, conversion and vectorization on the original document, and build a vector knowledge base;

[0089] The user question vectorization module is used to obtain user questions, vectorize them, and convert them into high-dimensional vector representations;

[0090] The text preliminary recall module is used to perform preliminary multi-segment text recall based on the vectorized user questions using a hybrid retrieval method of semantic matching and keyword matching to obtain a list of candidate texts;

[0091] The reranking module is used to rerank the text list that has been initially screened using the rerank model to obtain a more accurate text list from high to low scores;

[0092] The big model answer module is used to filter the user's question and the text list that matches the text according to the threshold and send them to the big model together to obtain the answer.

[0093] For the specific definition of an intelligent question-answering system based on a large model, please refer to the definition of an intelligent question-answering method based on a large model above, which will not be repeated here. Each module in the above-mentioned intelligent question-answering system based on a large model can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0094] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned intelligent question-answering method based on a large model when executing the computer program.

[0095] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the above-mentioned intelligent question-answering method based on a large model.

[0096] Specifically, the electronic device may include: a processor, a memory and a communication unit. These components interact through one or more buses. The processor is the control center of the electronic device and can connect the entire electronic device through interfaces and lines. Programs stored in the memory can be run and data in the memory can be called. The memory is used to store the execution instructions of the processor, and the memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof. When the execution instructions of the memory are executed by the processor, the electronic device is able to execute some or all steps of an intelligent question-answering method based on a large model.

[0097] The above is a detailed introduction to the intelligent question-answering method based on a large model provided by the present invention. This article uses specific examples to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the core idea of ​​the present invention. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, the present invention can also be improved and modified, and these improvements and modifications also fall within the scope of protection of the claims of the present invention.

Claims

1. An intelligent question answering method based on a large model, characterized in that: The method comprises the following steps: S100: obtaining the original document, performing data analysis, recognition, conversion and vectorization on the original document, and building a vector knowledge base; S200: Obtain user questions, vectorize the user questions, and convert them into high-dimensional vector representations; S300: Based on the vectorized user questions and vector knowledge base, a hybrid retrieval method of semantic matching and keyword matching is used to perform preliminary multi-segment text recall to obtain a list of candidate texts; S400: reranking the text list initially screened using the rerank model to obtain a more accurate text list in descending order of scores; S500: The user's question and the text list that matches the text are filtered according to a threshold and sent together to the big model to obtain an answer.

2. The method according to claim 1, characterized in that S100 includes: S110: The original document is the original data for constructing the vector knowledge base. The extension of the document is read by a program. A corresponding parsing tool is used according to different extensions to parse the document by the parsing tool. S120: cyclically reading the content blocks of the parsed document, determining the type of the content blocks, directly reading out if the type of the content block is text, and using OCR to recognize if the type of the content block is an image, and splicing the recognized text to the end of the recognized text string; S130: converting the entire string content after reading into a markdown format string using a tool; S140: using a text segmentation tool for markdown format to perform a word segmentation chunk operation on the text to form a string list; S150: Finally, the pre-trained embedding model is used to vectorize each chunk into a vector library to form a vector knowledge base, wherein the vector knowledge base uses Elasticsearch to store vector data.

3. The method according to claim 2, characterized in that S300 uses Elasticsearch's BM25 word frequency statistics method to perform keyword matching, specifically: Where IDF(q) is the inverse document frequency of a single document, N is the total number of documents, and n is the total number of documents containing word q; where q i is the i-th query item; IDF(q i ) is the inverse document frequency of the i-th query term; represents the total inverse document frequency of all query items; fieldLen represents the length of the field; avgFieldLen represents the average field length; D is the document; f(q i ,D) is the number of times the i-th query item appears in the document; k1 is the degree of influence of limiting a single query item on the score of a given document, and its value ranges from 0 to 1; b is the degree of influence of controlling the ratio of document length to average length, and its value ranges from 0 to 1. Score(D,q) is the total relevance score of the query document.

4. The method according to claim 3, characterized in that S300 uses cosine similarity for semantic matching. The cosine calculation process is the dot product of two vectors divided by the length of the two vectors, specifically: Where Q is the vector corresponding to the query question, D is the vector of the matched document, and cos is the final cosine calculation value. The value range of cos is -1 to 1.

5. The method according to claim 4, characterized in that S300 includes: Enhanced search is performed by combining semantic search and keyword search, and weighted scores are used to obtain the final score of text matching, specifically: score=α*score v +(1-α)score s Among them, score represents the final score; score v Indicates the semantic matching score; score s Indicates the keyword matching score; α indicates the weighted value, which ranges from 0 to 1; The multiple texts are sorted according to their final scores, and the first preset number of texts are selected to obtain a candidate text list, thereby achieving preliminary recall of multiple texts.

6. The method according to claim 5, characterized in that S400 includes: The rerank model calculates the matching degree between the candidate text list and the user question by evaluating the correlation between the user question and each candidate document, and then sorts them from high to low according to the correlation degree. The first second preset number of data items are set to be returned to complete the second reranking.

7. The method according to claim 6, characterized in that S500 includes: Remove irrelevant text lists based on the score threshold, and then take the sorted text lists corresponding to the topK values ​​according to the configured topK values ​​and assemble them together with the user questions and send them to the large model for answering.

8. An intelligent question-answering system based on a large model, characterized in that: It includes vector knowledge base construction module, user question vectorization module, text preliminary recall module, re-ranking module and large model answering module; The vector knowledge base construction module is used to obtain the original document, perform data analysis, recognition, conversion and vectorization on the original document, and build a vector knowledge base; The user question vectorization module is used to obtain user questions, vectorize them, and convert them into high-dimensional vector representations; The text preliminary recall module is used to perform preliminary multi-segment text recall based on the vectorized user questions using a hybrid retrieval method of semantic matching and keyword matching to obtain a list of candidate texts; The reranking module is used to rerank the text list that has been initially screened using the rerank model to obtain a more accurate text list from high to low scores; The big model answer module is used to filter the user's question and the text list that matches the text according to the threshold and send them to the big model together to obtain the answer.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Large model retrieval enhancement generation method oriented to policies in electricity price field

    CN119940512A

  • Large model question and answer method and device based on multi-party private domain long text information

    CN120030131A

  • Visual language large model-based knowledge retrieval method, system, equipment and product

    CN120744097A

  • Knowledge retrieval method, system, device and product based on visual language large model

    CN120744097B

  • Industrial knowledge query method and device, equipment and medium

    CN120849554A