Document type response method based on large language model and question and answer robot
By dividing the document into document blocks and constructing prompt templates for large language model logical reasoning analysis, it solves the problem of lack of logic in the answers of existing question and answer robots, improves the accuracy of question and answer and user experience, and is suitable for low-cost private data scenarios. deal with.
Patent Information
- Application Number
- CN202410775740.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-14
- Publication Date
- 2024-08-23
AI Technical Summary
When existing question and answer robots obtain answers from documents, the answers usually lack logic and organization, resulting in poor user experience. Especially when processing private data, the knowledge update of large language models is slow, making it difficult to effectively fine-tune on small samples. .
Using a document-based response method based on a large language model, the document uploaded by the user is divided into document blocks, a text vector is constructed and matched with the question, and a prompt template is generated for logical reasoning analysis to obtain a logical answer.
It improves the accuracy and rationality of question and answer in private data scenarios, provides a more user-friendly answer experience, reduces the need for fine-tuning of large language models, and enables low-cost processing of private data.
Smart Images

Figure CN118535709A
Abstract
Description
Technical Field
[0001] One or more embodiments of the present specification relate to the field of natural language processing technology, and in particular, to a document-based answering method and a question-answering robot based on a large language model. Background Art
[0002] A question-answering robot is an artificial intelligence system that can communicate with humans and answer questions. It uses natural language processing, machine learning, and big data technologies to analyze questions raised by users, find relevant information from the knowledge base, and give accurate and practical answers. The question-answering robot can also answer user questions based on the content of the document. The process of answering user questions needs to protect user privacy. At present, it is hoped that there will be an improved solution that can get more logical answers to user questions from the document. Summary of the invention
[0003] One or more embodiments of this specification describe a document-based answering method and a question-answering robot based on a large language model to obtain more logical answers to user questions from documents. The specific technical solution is as follows.
[0004] In a first aspect, the embodiment provides a document-based answering method based on a large language model, including:
[0005] Obtaining the answer-related document uploaded by the first user, dividing the answer-related document into a plurality of document blocks, and determining the block vectors corresponding to the plurality of document blocks;
[0006] receiving a question input by a first user, and determining a text vector of the question;
[0007] Based on the matching results between the text vector and the plurality of block vectors, determining a document block related to the answer to the question from the plurality of document blocks;
[0008] constructing a prompt template based on the question and the identified document chunks;
[0009] The prompt template is input into a large language model, and logical reasoning analysis is performed based on the document block of the prompt template through the large language model to obtain an answer to the question.
[0010] In one embodiment, after receiving the question input by the first user, the method further includes:
[0011] Feedback a preset response to the first user, wherein the preset response indicates that an answer is being determined;
[0012] After determining the answer to the question, the method further comprises:
[0013] The answer is fed back to the first user.
[0014] In one implementation, the answer-related document is stored in a designated knowledge base; and the step of obtaining the answer-related document uploaded by the first user includes:
[0015] Obtain answer-related documents uploaded by the first user from the designated knowledge base.
[0016] In one implementation, the step of obtaining the answer-related document uploaded by the first user includes:
[0017] When the answer-related document contains table data, obtaining original data of the answer-related document from the designated knowledge base;
[0018] The header fields in the original data are concatenated with the corresponding table values to obtain the answer-related document.
[0019] In one embodiment, the prompt template includes a known information part, a user question part and an analysis logic part; the step of constructing the prompt template based on the question and the determined document block includes:
[0020] Filling the determined document block into the known information portion;
[0021] Fill the question text of the question into the user question part;
[0022] Determine a reasoning question that instructs the large language model to perform analytical reasoning, and fill the reasoning question into the analysis logic part; the reasoning question is composed based on the known information part and the user question part.
[0023] In one embodiment, the step of determining the reasoning question that instructs the large language model to perform analytical reasoning includes determining the reasoning question based on a question type of the question.
[0024] In one embodiment, the step of performing logical reasoning analysis based on the document block of the prompt template using the large language model to determine the answer to the question includes:
[0025] Through the large language model, the text of the known information part and the user question part is used as the analysis basis, and under the guidance of the reasoning question, the answer to the question is inferred.
[0026] In a second aspect, an embodiment provides a question-answering robot, including:
[0027] a document acquisition module, configured to acquire the answer-related document uploaded by the first user, divide the answer-related document into a plurality of document blocks, and determine the block vectors corresponding to the plurality of document blocks;
[0028] a question receiving module, configured to receive a question input by a first user and determine a text vector of the question;
[0029] A document matching module, configured to determine a document block related to the answer to the question from among the plurality of document blocks based on a matching result between the text vector and the plurality of block vectors;
[0030] A template building module, configured to build a prompt template based on the question and the determined document block;
[0031] The model prediction module is configured to input the prompt template into a large language model, and perform logical reasoning analysis based on the document block of the prompt template through the large language model to obtain an answer to the question.
[0032] In a third aspect, an embodiment provides a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute any one of the methods described in the first aspect.
[0033] In a fourth aspect, an embodiment provides a computing device, comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method described in any one of the first aspects is implemented.
[0034] In the method and device provided in the embodiments of this specification, when the answer-related documents and the questions to be answered uploaded by the first user are obtained, the answer-related documents can be divided into document blocks, and the document blocks related to the answer to the question can be matched from the document blocks through vector matching, and a prompt template can be constructed. Through the large language model, logical reasoning analysis is performed based on the document blocks in the prompt template to obtain the answer to the question. The document blocks obtained through vector matching are scattered, disorganized and relatively stiff, but by using the logical reasoning analysis ability of the large language model, more logical answers to user questions can be obtained from the relevant document blocks. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0036] Figure 1A schematic diagram of an implementation scenario of an embodiment disclosed in this specification;
[0037] Figure 2 A schematic diagram of a flow chart of a document-based response method provided in an embodiment;
[0038] Figure 3 A schematic diagram of another process of the document-based response method provided in the embodiment;
[0039] Figure 4 A schematic block diagram of a question-answering robot provided in an embodiment. DETAILED DESCRIPTION
[0040] The solution provided in this specification is described below in conjunction with the accompanying drawings.
[0041] As mentioned above, the Q&A robot analyzes the questions raised by the user and finds relevant information from the knowledge base to answer the user's questions. In the scenario of answering questions based on private data, the user uploads a private data document and asks the Q&A robot to answer the question based on the document. In other words, the answer to the question comes from the document uploaded by the user, and the Q&A robot is required to find the answer to the question from the document and feedback it to the user.
[0042] The question-answering system corresponding to the question-answering robot can be implemented using a large language model. However, large language models usually have slow knowledge updates, cannot be effectively fine-tuned on small samples corresponding to private data, and have difficulty processing private data. In order to improve the accuracy and rationality of answering users in the above question-answering scenario. This specification provides a document-based answering method based on a large language model.
[0043] Figure 1 The following is a schematic diagram of an implementation scenario of an embodiment disclosed in this specification. In it, the user provides a document, which is stored in a knowledge base. The user asks a question to the question-answering robot, hoping that the question-answering robot can answer the question in the document uploaded by the user. The question-answering robot obtains the user's question from the knowledge base, and preliminarily matches the document block corresponding to the question from the document, and constructs the document block and the question into a prompt template. The question-answering robot inputs the prompt template into the large language model, and reorganizes and polishes the document block in the prompt template through the large language model, so as to obtain a more logical answer text.
[0044] Large language models (LLMs) are one of the applications of deep learning, especially in the field of natural language processing (NLP). The goal of large language models is to understand and generate human language. To achieve this goal, large language models need to be trained on a large amount of text data to learn various patterns and structures of language. Examples of large language models include ChatGPT and PaLM. Large language models are trained to solve common language problems such as text classification, question answering, document summarization, and text generation. In the context of large language models, "large" has two main meanings. On the one hand, it refers to the number of parameters of the model. In large language models, the number of parameters is usually very large, reaching billions or even tens of billions. This enables large language models to learn and represent very complex patterns. On the other hand, "large" also refers to the scale of training data. Large language models are usually trained on large-scale text data, which can come from various sources such as the Internet, books, and news. Large language models use data from a variety of large application fields during training, which contains a lot of knowledge, so they can handle tasks related to a variety of large application fields, such as text classification, question answering, document summarization, and text generation. Large language models have stronger language processing capabilities and wider applicability.
[0045] The document provided by the user contains text. The document can be in various formats. For example, the document can be in the lightweight markup language format markdown. The text content contained in the document can be the user's personal private data. The knowledge base can be a document knowledge base for storing documents.
[0046] A question-and-answer robot is an intelligent dialogue system implemented through artificial intelligence technology, which can simulate human question-and-answer communication. Finding answers to user questions in documents provided by users is a document-based question-and-answer system. When a question-and-answer robot conducts document-based question-and-answer, it can use retrieval to determine the answer. However, the answers determined in this way are usually disorganized and stiff, resulting in a poor user experience.
[0047] The document-based answering method based on a large language model provided in the embodiments of this specification is intended to obtain an organized and logical answer to a document-based question and answer. The method includes: step S210, the question-answering robot can obtain the answer-related document uploaded by the first user, and divide the answer-related document into several document blocks, and determine the block vectors corresponding to the several document blocks; step S220, the question-answering robot receives the question input by the first user and determines the text vector of the question; step S230, the question-answering robot determines the document block related to the answer to the question from the several document blocks based on the matching results between the text vector and the several block vectors; step S240, the question-answering robot constructs a prompt template based on the question and the determined document block; step S250, the question-answering robot inputs the prompt template into the large language model, and through the large language model, performs logical reasoning analysis based on the document block of the prompt template to obtain the answer to the question.
[0048] In this embodiment, the question-answering robot combines vector retrieval with a large language model, first retrieving document blocks related to the question from the document blocks, then constructing a prompt template with the document blocks and the question, inputting the prompt template into the large language model, and performing logical reasoning analysis based on the question and the document blocks to obtain the answer to the question. This method does not require fine-tuning of the large language model, and enables the large language model to process private data at a low cost.
[0049] Combine the following Figure 2 This embodiment is described in detail. Figure 2 A flowchart of a document-based answering method provided in an embodiment. The method can be performed by a question-answering robot. The question-answering robot can be implemented by any device, equipment, platform, device cluster, etc. with computing and processing capabilities. The method includes the following steps.
[0050] In step S210, the question-answering robot obtains the answer-related document uploaded by the first user U1, divides the answer-related document into a number of document blocks, and determines the block vectors corresponding to the several document blocks.
[0051] The first user U1 may be any one of the multiple users. The answer-related document contains text and may be in a variety of formats, such as markdown format. The text content contained in the answer-related document is the user's personal private data. The answer-related document may be one document or multiple documents.
[0052] The first user U1 can upload answer-related documents to the designated knowledge base. When it is necessary to obtain answer-related documents, the question-answering robot can obtain the answer-related documents uploaded by the first user U1 from the designated knowledge base. When it is necessary to answer the user's question, the operation of obtaining answer-related documents can be triggered.
[0053] When the answer-related document contains table data, the original data of the answer-related document can be obtained from the specified knowledge base, and the header fields in the original data are concatenated with the corresponding table values to obtain the answer-related document. For example, the specified knowledge base can be the Yuque knowledge base, and the Q&A robot can load the answer-related documents in the Yuque knowledge base through the SDK publicly available on Yuque. SDK is a software development kit, which is a toolkit used to integrate into the Yuque application and assist in loading data.
[0054] In one example, the raw data of answer-related documents is shown in Table 1.
[0055] Table 1
[0056] A B C 1 2 3 4 5 6
[0057] A, B, and C are header fields. 1 to 6 are corresponding table values.
[0058] After obtaining the original data of Table 1, the header fields can be concatenated with the corresponding table values, that is, A:1, B:2, C:3, A:4, B:5, C:6. The colon is the connector between the header fields and the table values, and the connector can also be text. The header fields can also be directly concatenated with the corresponding table data without adding connectors. The answer-related documents obtained by concatenating the header fields with the table data in this way can make the semantics of the document content clearer and improve the accuracy of matching document blocks from the document.
[0059] When the answer-related documents are segmented in step S210, the segmentation can be performed based on the designated symbols in the text of the answer-related documents. The designated symbols can be, for example, a period or a line break. There can be overlapping parts of text between adjacent document blocks that are segmented, and the length of the overlapping parts can be specified. This can make the connection between document blocks more reasonable. The several document blocks obtained by segmentation can include one document block or multiple document blocks.
[0060] When determining the block vector of each document block, a trained text embedding model (Embedding model) can be used. That is, the text of the document block is input into the Embedding model, and the document block is vectorized by the Embedding model. After obtaining several block vectors of several document blocks, the several block vectors can be saved in a vector database.
[0061] In step S220, the question-answering robot receives question Q1 input by the first user U1 and determines the text vector of question Q1. Question Q1 can be voice or text. The text vector of question Q1 can be obtained by inputting the text of question Q1 into the Embedding model. The above steps S220 and S210 are executed in no particular order.
[0062] In step S230, the question-answering robot may perform similarity matching between the text vector and several block vectors respectively, and based on the matching results, determine a document block related to the answer to question Q1 from the several document blocks.
[0063] When several block vectors are stored in the vector database, the text vector can be matched with several block vectors in the vector database to obtain a matching result. The question-answering robot can obtain the matching result from the vector database. The matching process is also a retrieval process of the text vector. In this method, the semantic relevance between the question text and the text block is measured by calculating the similarity between the text vector and the block vector in the representation space, and is used to determine their matching scores. The similarity matching between vectors can adopt existing methods, such as cosine similarity, Euclidean distance, etc.
[0064] In step S240, the question-answering robot constructs a prompt template P1 based on the question Q1 and the determined document block. Specifically, the question-answering robot can construct the prompt template P1 based on the text of the question Q1 and the determined document block. The prompt template P1 contains the text of the question Q1 and the text of the determined document block. When constructing the prompt template P1, it can be constructed in a predetermined format based on the question Q1 and the determined document block. The prompt template P1 contains a predetermined execution logic, which is used to instruct the large language model to determine the answer to the question Q1 from the document block of the prompt template P1 through logical reasoning analysis.
[0065] The prompt template is an input form or template designed by researchers to perform downstream tasks of large language models, which is used to help the pre-trained large language model "recall" what it has "learned" during pre-training.
[0066] In step S250, the question-answering robot inputs the prompt template P1 into the large language model. The large language model performs logical reasoning analysis based on the document block of the prompt template P1 and the execution logic in the prompt template P1 to obtain the answer A1 to the question Q1. The question-answering robot can obtain the answer A1 from the large language model and feedback the answer A1 to the first user U1.
[0067] The above steps S210 to S250 are the process of the question-answering robot determining the answer A1 for the question Q1 of the first user U1. The execution of this process takes a certain amount of time. In order to improve the user experience, after the question-answering robot receives the question Q1 input by the first user U1, it can feedback a preset response to the first user U1, and the preset response indicates that the answer is being determined. For example, the preset response may include, but is not limited to, such text: Please wait, the answer is being checked for you. After the answer A1 is determined, the question-answering robot can then feedback the accurate answer A1 to the first user U1.
[0068] Through the above-mentioned asynchronous call, the above-mentioned embodiment can overcome the time-consuming problem of directly calling a large language model in a personal user document-type question-and-answer scenario, and can directly serve the user with the built question-and-answer system, so that the user can get a more accurate and logical summary answer.
[0069] The implementation of step S240 is described in detail below. In one embodiment, the prompt template P1 includes a known information part p1, a user question part p2 and an analysis logic part p3. When executing step S240, the following steps 1 to 3 may be included.
[0070] Step 1: Fill the determined document block into the known information part p1. Step 2: Fill the question text of question Q1 into the user question part p2.
[0071] Step 3, determine the reasoning question that instructs the large language model to perform analytical reasoning, and fill the reasoning question into the analysis logic part p3. The reasoning question is composed of the known information part p1 and the user question part p2. The reasoning question can contain at least one sub-question. When the reasoning question contains multiple sub-questions, there is a specified logical relationship between the multiple sub-questions.
[0072] When determining the reasoning question, a preset question related to the known information part p1 and the user question part p2 may be used as the reasoning question. Alternatively, the reasoning question may be determined based on the question type of question Q1.
[0073] For example, the preset questions may include: first, what is the question in the user question part p2; second, is the question in the user question part p2 highly relevant to the content in the known information part p1. The first and second steps reflect the logical relationship between the two sub-questions.
[0074] In one implementation, the question types of question Q1 may include: type 1—what, type 2—why, type 3—how, and type 4—how much. For example, the text of a question is: Please help me find how many times I bought takeout in a month based on the document. Then the question is of the type "how much". The above question types are only examples, and in actual applications, the question types can be set according to specific circumstances.
[0075] Different reasoning questions can be set for different question types, so as to obtain a correspondence between question types and reasoning questions. After determining the question type of question Q1, the reasoning question corresponding to the question type can be determined from the correspondence, and the reasoning question can be used as the reasoning question of question Q1.
[0076] In step S250, the large language model may analyze the text of the known information part p1 and the user question part p2 in the prompt template P1 as a basis, and under the guidance of the reasoning question, infer the answer A1 to the question Q1.
[0077] In this embodiment, by setting the known information part, the user question part and the analysis logic part in the prompt template, the large language model is prompted for logical analysis, thereby helping the large language model to obtain the answer to the question through analysis, logical reasoning and summary according to the analysis logic in the prompt template.
[0078] Figure 3 A schematic diagram of another process of the document-based answering method provided in the embodiment. It includes loading documents, segmenting documents, vector embedding, a large language model, a vector database, a retrieval method, summarizing questions and answers, services, and question-and-answer robots. In the document loading part, documents in the knowledge base can be loaded through the SDK. When segmenting documents, they can be segmented according to delimiters. In the vector embedding part, the text embedding model can use the bge-base-zh-v1.5 or text2vec-base-chinese model to vectorize the text. The large language model can be implemented using large language models such as Qwen-14B-Chat or Chatgpt. The vector database can be, but is not limited to, a Faiss or chroma database. When retrieving a block vector matching the text vector from the vector database, the retrieval method includes similarity retrieval and keyword retrieval. After obtaining the retrieval results, the retrieval results can be used to assemble a prompt template prompt, and then the large language model can be called to generate a result, that is, a polished answer. The retrieval results include question text and successfully matched document blocks. Among them, the service part includes assembling prompt, calling the model, and generating results. After the generated result is obtained, the generated result can be sent to the question-answering robot. The gateway system included in the question-answering robot receives the generated result and completes the user's answer in an asynchronous call manner.
[0079] Looking back at steps S210 and S220, when determining the block vector of the document block and the text vector of question Q1, the text embedding model used can be a bidirectional encoding model based on Transformers (Bidirectional Encoder Representations from Transformers, BERT). The sentence vectors derived based on the BERT model usually have a collapse phenomenon, which makes it difficult to reflect the semantic similarity between the two sentences. The BERT model encodes all sentences into a smaller spatial area, and most sentence pairs have a higher similarity score. When calculating sentence vectors using the average word vector method, the word vectors of high-frequency words will dominate the sentence vectors, making it difficult to reflect the original semantics. The methods for learning sentence vectors mainly include the InferSent model and the Sentence-BERT model. The InferSent model uses a siamese structure. Two sentences use the same encoder to obtain text vector expressions of u and v. Vector concatenation [u,v], multiplication u*v and subtraction |uv| are used to help the fully connected layer extract interactive information between vectors. The Sentence-BERT model replaces the encoder part of the InferSent model with the BERT model. During the training process, u, v, and |uv| are concatenated and connected to the classification layer. The prediction process is the same as the ordinary sentence vector model. The sentence vector after average pooling is first calculated, and then the cosine cosine is calculated using the vector to obtain the similarity value. However, these two methods are inconsistent during training and prediction, resulting in a phenomenon in which the loss decreases and the accuracy increases.
[0080] The text2vec-base-chinese model is trained using the CoSENT vector representation method. When calculating vector similarity, cosine distance is usually used, and CoSENT vector representation is used as the loss function when calculating cosine distance. CoSENT vector representation supervises the training of sentence vector representation on a pre-trained language model similar to BERT, so that the model can achieve better results in text matching. Usually, two sentences are encoded in the form of sentence pairs such as (sentence 1, sentence 2, label) to obtain vectors u and v respectively. The cosine similarity cos(u,v) is calculated in the prediction stage, and the loss function is designed based on cos(u,v) to make the similarity of positive sample pairs as large as possible and the similarity of negative sample pairs as small as possible. Among them, the loss function can also be in the following forms:
[0081]
[0082] Among them, the input sample is (x i ,x i ,x i -), x i With x i is an implication relation, x i - With x i It is a contradictory relationship. i is x i The sentence vector representation, h i + is x i + The sentence vector representation, h i - is x i - The sentence vector representation of . N is the number of samples in a batch, sim is the cosine similarity function. τ is the temperature coefficient, which is a hyperparameter.
[0083] In the cosine-based ranking loss function, the positive sample pair (x i ,x i + ) and negative sample pairs (x i ,x i - ), for any positive and negative samples, there should be the following relationship:
[0084] cos(h i ,h i + )>cos(h i ,h i - )
[0085] It can be seen that the similarity of positive samples should be as much greater as possible than that of negative samples. The difference of the above cosine results is used as the loss value, and the loss function when optimizing the loss value is as follows:
[0086]
[0087] Among them, the meaning of each parameter is the same as above.
[0088] In this embodiment, by adopting a suitable text embedding model, more accurate block vectors and text vectors can be obtained, and when a text block matching question Q1 is retrieved from multiple text blocks, a text block with higher accuracy can be obtained.
[0089] In this specification, the term "first" in the term "first user" and the corresponding "second" (if any) in the text are merely for the convenience of distinction and description and do not have any limiting meaning.
[0090] The foregoing describes certain embodiments of the present specification, and other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims may be performed in an order different from that in the embodiments, and the desired results may still be achieved. In addition, the processes depicted in the accompanying drawings do not necessarily have to be performed in the specific order or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0091] Figure 4 A schematic block diagram of a question-answering robot provided in an embodiment. Figure 2 The question-answering robot 400 includes:
[0092] The document acquisition module 410 is configured to acquire the answer-related document uploaded by the first user, divide the answer-related document into a plurality of document blocks, and determine the block vectors corresponding to the plurality of document blocks;
[0093] The question receiving module 420 is configured to receive a question input by a first user and determine a text vector of the question;
[0094] A document matching module 430, configured to determine a document block related to the answer to the question from among the plurality of document blocks based on a matching result between the text vector and the plurality of block vectors;
[0095] A template building module 440, configured to build a prompt template based on the question and the determined document block;
[0096] The model prediction module 450 is configured to input the prompt template into a large language model, and perform logical reasoning analysis based on the document block of the prompt template through the large language model to obtain an answer to the question.
[0097] In one embodiment, the question-answering robot 400 further includes:
[0098] a response feedback module (not shown in the figure), configured to feedback a preset response to the first user after receiving the question input by the first user, wherein the preset response indicates that an answer is being determined;
[0099] The question-answering robot 400 further includes:
[0100] The answer feedback module (not shown in the figure) is configured to feed back the answer to the first user after determining the answer to the question.
[0101] In one implementation, the answer-related documents are stored in a designated knowledge base; when the document acquisition module 410 acquires the answer-related documents uploaded by the first user, it includes: acquiring the answer-related documents uploaded by the first user from the designated knowledge base.
[0102] In one implementation, the document acquisition module 410, when acquiring the answer-related document uploaded by the first user, specifically includes:
[0103] When the answer-related document contains table data, obtaining original data of the answer-related document from the designated knowledge base;
[0104] The header fields in the original data are concatenated with the corresponding table values to obtain the answer-related document.
[0105] In one implementation, the prompt template includes a known information portion, a user question portion, and an analysis logic portion; the template construction module 440 specifically includes:
[0106] A first filling unit 41 is configured to fill the determined document block into the known information part;
[0107] A second filling unit 42 is configured to fill the question text of the question into the user question part;
[0108] The third filling unit 43 is configured to determine a reasoning question that instructs the large language model to perform analytical reasoning, and fill the reasoning question into the analysis logic part; the reasoning question is composed based on the known information part and the user question part.
[0109] In one implementation, the third filling unit 43, when determining the reasoning problem for instructing the large language model to perform analytical reasoning, includes:
[0110] The inference question is determined based on a question type of the question.
[0111] In one embodiment, the model prediction module 450 is specifically configured to: use the large language model to analyze the text of the known information part and the user question part, and under the guidance of the reasoning question, infer the answer to the question.
[0112] The above device embodiments correspond to the method embodiments. For specific descriptions, please refer to the description of the method embodiments, which will not be repeated here. The device embodiments are obtained based on the corresponding method embodiments and have the same technical effects as the corresponding method embodiments. For specific descriptions, please refer to the corresponding method embodiments.
[0113] The present specification also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed in a computer, the computer is caused to execute Figures 1 to 3 Any of the methods described above.
[0114] The embodiment of the present specification also provides a computing device, including a memory and a processor, wherein the memory stores an executable code, and when the processor executes the executable code, Figures 1 to 3 Any of the methods described above.
[0115] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the storage medium and computing device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0116] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the embodiments of the present invention may be implemented using hardware, software, firmware, or any combination thereof. When implemented using software, these functions may be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium.
[0117] The specific implementation methods described above further describe the purpose, technical solutions and beneficial effects of the embodiments of the present invention in detail. It should be understood that the above description is only a specific implementation method of the embodiments of the present invention and is not intended to limit the scope of protection of the present invention. Any modification, equivalent replacement, improvement, etc. made on the basis of the technical solution of the present invention shall be included in the scope of protection of the present invention.
Claims
1. A document-based answering method based on a large language model, comprising: Obtaining the answer-related document uploaded by the first user, dividing the answer-related document into a plurality of document blocks, and determining the block vectors corresponding to the plurality of document blocks; receiving a question input by a first user, and determining a text vector of the question; Based on the matching results between the text vector and the plurality of block vectors, determining a document block related to the answer to the question from the plurality of document blocks; constructing a prompt template based on the question and the identified document chunks; The prompt template is input into a large language model, and logical reasoning analysis is performed based on the document blocks in the prompt template through the large language model to obtain an answer to the question.
2. The method according to claim 1, after receiving the question input by the first user, further comprising: Feedback a preset response to the first user, wherein the preset response indicates that an answer is being determined; After determining the answer to the question, the method further comprises: The answer is fed back to the first user.
3. According to the method of claim 1, the answer-related documents are stored in a designated knowledge base; the step of obtaining the answer-related documents uploaded by the first user comprises: Obtain answer-related documents uploaded by the first user from the designated knowledge base.
4. According to the method of claim 3, the step of obtaining the answer-related document uploaded by the first user comprises: When the answer-related document contains table data, obtaining original data of the answer-related document from the designated knowledge base; The header fields in the original data are concatenated with the corresponding table values to obtain the answer-related document.
5. The method according to claim 1, wherein the prompt template comprises a known information part, a user question part and an analysis logic part; The step of constructing a prompt template based on the question and the determined document block comprises: Filling the determined document block into the known information portion; Fill the question text of the question into the user question part; Determine a reasoning question that instructs the large language model to perform analytical reasoning, and fill the reasoning question into the analysis logic part; the reasoning question is composed based on the known information part and the user question part.
6. The method according to claim 5, wherein the step of determining the reasoning question that instructs the large language model to perform analytical reasoning comprises: The inference question is determined based on a question type of the question.
7. According to the method of claim 5, the step of obtaining the answer to the question by performing logical reasoning analysis based on the document blocks in the prompt template using the large language model comprises: Through the large language model, the text of the known information part and the user question part is used as the analysis basis, and under the guidance of the reasoning question, the answer to the question is inferred.
8. A question-answering robot, comprising: a document acquisition module, configured to acquire the answer-related document uploaded by the first user, divide the answer-related document into a plurality of document blocks, and determine the block vectors corresponding to the plurality of document blocks; a question receiving module, configured to receive a question input by a first user and determine a text vector of the question; A document matching module, configured to determine a document block related to the answer to the question from among the plurality of document blocks based on a matching result between the text vector and the plurality of block vectors; A template building module, configured to build a prompt template based on the question and the determined document block; The model prediction module is configured to input the prompt template into a large language model, and perform logical reasoning analysis based on the document block of the prompt template through the large language model to obtain an answer to the question.
9. A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute the method according to any one of claims 1 to 7.
10. A computing device, comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Table processing method and device, equipment and medium
CN117312520A
Table question and answer processing method, device and equipment
CN117332054A
Solution plan generation method and device, equipment and storage medium
CN117407514A
Method for realizing document question and answer by using large language model
CN117972059A
Cited By
Conversational classroom teaching quality evaluation method and system based on multi-agent cooperation
CN121329202A
Dialogue classroom teaching quality evaluation method and system based on multi-agent cooperation
CN121329202B
