Question and answer assistant enhancement method based on general large language model and knowledge retrieval
By constructing an external knowledge base and refining question categories, the accuracy and dynamism issues of general-purpose large language models in smart education were resolved, achieving efficient and accurate question-and-answer services.
Patent Information
- Application Number
- CN202411467047.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2024-08-21
- Filing Date
- 2024-10-21
- Publication Date
- 2026-02-03
AI Technical Summary
Existing general-purpose large language models struggle to provide accurate and dynamic question-and-answer services in the field of smart education, and are unable to continuously update knowledge, easily providing irrelevant or incorrect answers.
An external knowledge base is constructed, question categories are refined through a student question classifier, and documents are retrieved and rearranged in the external knowledge base using a scoring algorithm. Collaborative reasoning is then performed using a general large language model to obtain accurate answers.
It improves the accuracy and flexibility of the question-and-answer assistant, ensures the high quality and relevance of the knowledge base, reduces manpower consumption, and enhances the model's understanding and the relevance of the answers.
Smart Images

Figure CN121457573A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of smart education technology, specifically to a question-answering assistant enhancement method based on a general large language model and knowledge retrieval. Background Technology
[0002] As a deep learning model, the general-purpose large language model is trained to understand and generate human language. Relying on a large amount of training data and model parameters, current mainstream large language models have extensive knowledge coverage and deep understanding capabilities.
[0003] When a user inputs a question into the generalized large language model, the model can quickly respond based on the user's input. Leveraging this flexible interaction method, the generalized large language model can effectively serve as a question-and-answer assistant.
[0004] In the field of smart education, the use of general-purpose large language models as question-and-answer assistants for students is gradually becoming mainstream. These models can interact with students naturally through language, providing real-time feedback even when the teacher is unavailable, effectively improving teaching efficiency. This application aligns perfectly with the smart education philosophy of leveraging modern technology to optimize and improve teaching processes.
[0005] However, directly using a general-purpose large language model as a question-answering assistant is difficult to meet the question-answering needs of the education field. On the one hand, after learning from a large amount of training data, the general-purpose large language model stores knowledge implicitly in its parameters, making it difficult to determine whether the model truly possesses comprehension and judgment capabilities. Therefore, when answering student questions, the model may provide irrelevant or even incorrect answers. These answers could mislead students' learning, which is unacceptable in education. On the other hand, the knowledge of a general-purpose large language model is static; it can only answer questions based on knowledge already present in its training dataset and cannot achieve continuous knowledge updates. For example, when a student asks for their class schedule information, the large language model cannot answer because it lacks relevant knowledge.
[0006] To address the aforementioned issues, it's necessary to provide explicit knowledge to the model beyond its implicit knowledge. Contextual learning can be considered, where additional knowledge is added to the general language model as hints. However, acquiring additional knowledge is not arbitrary. Appropriate additional knowledge can help the model better understand the problem and generate more accurate answers. Inappropriate additional knowledge, on the other hand, can unnecessarily interfere with the model, leading to incorrect inferences. Therefore, to obtain reasonable additional information, it's necessary to construct an external knowledge base and design algorithms for effective retrieval from it.
[0007] In addition, to help the model better understand student questions, these questions can be further categorized. Student questions can be divided into personalized questions and general questions. Personalized questions have answers directly related to the questioner, such as inquiries about exam scores. General questions, on the other hand, have answers unrelated to the questioner, such as inquiries about specific knowledge points. During external knowledge base retrieval, the category information of student questions is used to achieve targeted searches, further ensuring the effectiveness and relevance of additional knowledge.
[0008] Existing technological solutions, when facing the specific field of smart education, often directly use a general-purpose large language model as a question-answering assistant. This approach lacks accuracy and dynamism. To address this issue, additional knowledge can be added to the model to assist reasoning. However, flexibly constructing an external knowledge base and retrieving appropriate additional knowledge based on student questions and effectively integrating it into the general-purpose large language model remains a challenging task. Summary of the Invention
[0009] To address the aforementioned technical problems, this invention provides a question-answering assistant enhancement method based on a general large language model and knowledge retrieval.
[0010] To solve the above-mentioned technical problems, the present invention adopts the following technical solution:
[0011] An enhanced question-answering assistant method based on a general large language model and knowledge retrieval includes the following steps:
[0012] S1, External Knowledge Base Construction: Personalized and general information are parsed from the tables in the smart education platform's database. Based on the first general language model, personalized and general information are automatically labeled as personalized and general documents, respectively, completing the construction of the external knowledge base. The basic unit of the external knowledge base is a document. Each document includes a type field, a time field, a question field, and an answer field. The type field indicates the document's category, which includes personalized and general categories. The time field indicates the document's creation time in the database. The content of the question and answer fields constitutes a knowledge entry, recording the student's question and corresponding answer, respectively.
[0013] S2, Student Question Classifier Construction: Collect and label student questions to obtain student question samples; select an LSTM model to construct a student question classifier, and train the student question classifier for text classification using student question samples. The trained student question classifier can classify student questions into individual questions and general questions.
[0014] S3, Knowledge Base Retrieval and Quality Re-ranking: For a new student question query, retrieve the top m documents with the highest similarity from the external knowledge base; input the student question query into the trained student question classifier to obtain the category of the student question query; based on the second general large language model and combined with the category of the student question, design a scoring algorithm to re-rank the quality of the retrieved m documents, and select the top n documents with the highest quality as the final retrieval result F″ of the external knowledge base, where n < m;
[0015] S4, Collaborative Reasoning: Guide the third general language model to learn the final retrieval results of the external knowledge base, input the student's question query into the third general language model for collaborative reasoning, and obtain the answer to the student's question.
[0016] Further, step S1 specifically includes: classifying the tables in the database according to the student identifiers in the tables, and forming a set of personalized tables P = (p1, p2, ..., p...) based on the student identifiers in the tables. a The remaining tables form a general-purpose table set G = (g1, g2, ..., gb); p1, p2, ..., p a Let g1, g2, ..., g be the first to the a-th tables with student identifiers. b The first to the bth sheets do not have student identifiers;
[0017] For each table p in P, construct a personalized document:
[0018] Obtain the structural information L1 of table p, input the structural information L1 into the first general large language model, prompt the first general large language model to generate multiple sets of question templates for specific students based on the structural information L1 of table p, and then obtain the question template set Q;
[0019] For each data d in p, construct template 2 prompt2, prompting the first general language model to generate information such as type field, question field, answer field, and time field of the document category based on the question template set Q; generate the personalized document based on the information returned by the first general language model;
[0020] For each table g in G, construct a generic document:
[0021] After exporting table g as text, it is divided into blocks to obtain a set of text blocks T = (t1, t2, ..., t...). c ), t1, t2, ..., t c These are the first to c-th text blocks;
[0022] Obtain the structural information L2 of table g; construct template 3 prompt3 to guide the first general language model to learn the structural information L2, and generate information such as type field, question field, answer field and time field of document category for each text block t, so as to obtain the initial general document;
[0023] The initial general-purpose documents are grouped into a set E, which is then fed into the first general-purpose large language model. A template four, prompt4, is constructed to deduplicate and perform quality checks on set E, resulting in the final general-purpose documents.
[0024] By aggregating personalized documents and general-purpose documents, we obtain an external knowledge base F = (f1, f2, ..., f...). d ), where f1, f2, ..., f d These are the first to d documents in the external knowledge base F.
[0025] Furthermore, the template prompt1 is:
[0026] prompt1=smooth(identity+L1);
[0027] Here, "smooth" represents the operation of concatenating statements, and "identity" represents setting an identity for the first general large language model.
[0028] Furthermore, the second template, prompt2, is:
[0029] prompt2=smooth(identity+d+Q);
[0030] Here, "smooth" represents the operation of concatenating statements, and "identity" represents setting an identity for the first general large language model.
[0031] Furthermore, the template three, prompt3, is as follows:
[0032] prompt3=smooth(identity+L2+t);
[0033] Here, "smooth" represents the operation of concatenating statements, and "identity" represents setting an identity for the first general large language model.
[0034] Furthermore, the template four, prompt4, is as follows:
[0035] prompt4 = smooth(identity + E)
[0036] Here, "smooth" means using fluent sentences to concatenate relevant information, and "identity" means setting an identity for the first general large language model.
[0037] Furthermore, step S2 specifically includes:
[0038] After collecting student questions and segmenting them into words, the word embedding interface is used to represent the segmented words as word vectors k; for each student question, a set of word vectors K = (k1, k2, ..., k) is obtained. h ), where h is the maximum number of word segments for the student question; if the number of word segments is less than h, the corresponding word segmentation vector is padded with 0; k h Let h be the word segmentation vector of the h-th word;
[0039] Based on whether the answer is relevant to the questioner, the corresponding student questions are manually labeled to obtain a sample of student questions. The labels include labels for individual questions and labels for general questions.
[0040] The LSTM model is used to train on student question samples. A fully connected layer and a sigmoid activation function are added after the output layer of the LSTM model to construct a student question classifier. Then, binary cross-entropy is used as the loss function for the student question classifier. The output yt of the student question classifier is expressed as:
[0041] y t =σ(W y ·h t +b y );
[0042] Where σ represents the sigmoid activation function, W y h represents the weights of the fully connected layer. t b represents the hidden layer state of the LSTM model. y This indicates the bias of the fully connected layer.
[0043] Furthermore, step S3 specifically includes knowledge base retrieval and quality re-ranking:
[0044] Knowledge base retrieval: For a new student question query, retrieve the query from the external knowledge base F = (f1, f2, ..., f...). d Search for documents most relevant to student questions in f. d For the d-th document in the external knowledge base F, the retrieval criterion is the similarity between the document's question field and the student's question, specifically including:
[0045] Using a word embedding interface, the question field of a document in an external knowledge base is encoded, where document f d The corresponding question field is encoded as d′;
[0046] Use the word embedding interface to encode the student question query as q′;
[0047] The cosine similarity method is used to calculate the similarity between the student's question query and the document f. d The similarity s(q′, d′) between the question fields:
[0048]
[0049] Where q′·d′ is the inner product of q′ and d′, and |q′| and |d′| represent the lengths of q′ and d′, respectively;
[0050] The top m documents with the highest similarity are selected to form the search results F′=(f′1,f′2,…,f′ m ), f′ m For the m documents in the search result F′;
[0051] Quality Reordering: Design a scoring algorithm to reorder the documents in the retrieval result F′ of the second general large language model, specifically including:
[0052] Input the student question query into the trained student question classifier to obtain the student question category;
[0053] The scoring method, presented as template 5, is input into the second general language model to re-rank the documents in the retrieval result F′; template 5 (prompt5) is as follows:
[0054] prompt5=smooth(identity+F′+m+query+category);
[0055] Here, "smooth" indicates the operation of concatenating statements, and "identity" indicates setting the identity for the model;
[0056] In the quality-reordered search results F′, the top n documents by score are retained to form the final search results F″=(f1″,f2″,…,f n "), f n "The nth document in the final search result F".
[0057] Furthermore, step S4 specifically includes:
[0058] Template 6 (prompt6) is constructed, which uses the final retrieval result F″ from the external knowledge base as auxiliary information to pass to the third general-purpose language model. This allows the third general-purpose language model to combine its own knowledge with additional supplementary knowledge to answer the student's question. Template 6 (prompt6) is as follows:
[0059] prompt6=smooth(identity+query+F″);
[0060] Here, "smooth" indicates the operation of concatenating statements, and "identity" indicates setting the identity for the model;
[0061] The output of the third general large language model is the answer to the student's query.
[0062] Compared with the prior art, the beneficial technical effects of the present invention are:
[0063] This invention improves the accuracy and flexibility of question-answering assistants by combining information from an external knowledge base with a general large language model. The innovative construction method of the external knowledge base ensures its high quality and relevance, while the construction process is flexible and efficient, effectively reducing manpower consumption. Furthermore, by refining student question categories, our designed retrieval algorithm can identify highly relevant documents in the external knowledge base, ensuring the targeted nature of supplementary knowledge and further improving the accuracy of collaborative reasoning. Attached Figure Description
[0064] Figure 1 This is a schematic diagram of the overall process of the present invention. Detailed Implementation
[0065] A preferred embodiment of the present invention will now be described in detail with reference to the accompanying drawings.
[0066] This invention provides an enhanced question-answering assistant method based on a generalized large language model and knowledge retrieval in a smart education scenario. It involves fine-grained analysis of existing databases and, relying on the generalized large language model, automates the construction of an external knowledge base. The method refines student question categories and designs a retrieval algorithm to find highly relevant documents in the external knowledge base. Based on the generalized large language model and combined with effective information retrieved from the external knowledge base, it achieves highly accurate question answering.
[0067] The present invention specifically includes the following steps:
[0068] S1: External Knowledge Base Construction. Analyze the existing database of the online smart education platform to extract personalized and general information. Based on a general large language model, automatically label the above information as personalized and general documents, efficiently constructing an external knowledge base.
[0069] S2: Student Question Classifier Construction. Collect and label student questions, then divide them into training and test sets. Select an LSTM model for text classification training to construct a student question classifier capable of binary classification, categorizing student questions into personalized and general questions.
[0070] S3: Knowledge Base Retrieval and Quality Re-ranking. Based on the student's question, retrieve the top m documents with the highest similarity from an external knowledge base. Using a general large language model and a scoring algorithm, rank the documents by quality. Select the top n documents by quality as the final retrieval results from the external knowledge base.
[0071] S4: Collaborative Reasoning. The model learns the final retrieval results from an external knowledge base, inputs student questions into a general large language model to achieve collaborative reasoning, and obtains the answers to the student questions.
[0072] Furthermore, step S1 specifically includes:
[0073] Smart education platforms that provide question-and-answer assistant functions often have databases containing rich information. This information includes not only personalized information such as student learning records, but also general information such as teaching knowledge points. The goal of step S1 is to parse these two types of information from the existing database and then construct an external knowledge base.
[0074] The basic unit of the external knowledge base is a document. Each document contains four fields: type, time, question, and answer. `type` indicates the document's content category, with two types: personalized and general. Personalized is set to 0, and general is set to 1. `time` represents the time the document was created in the database, used to ensure the timeliness of the knowledge. The `question` and `answer` fields represent a single piece of knowledge. Storing knowledge in this question-and-answer pair format helps the general large language model better understand the knowledge.
[0075] Based on their nature, the tables in the database are categorized. The categorization criterion is whether they contain student identifiers; tables containing fields such as `studentId` are grouped into a set of personalized tables, while the remaining tables are grouped into a set of general tables. Since the number of tables in the database is extremely limited, this step is done manually. Ultimately, the set of personalized tables is obtained as P = (p1, p2, ..., p...). a ) and the generalized set of tables G = (g1, g2, ..., gb), p1, p2, ..., p a Let there be a tables with student identifiers, g1, g2, ..., g... b There are b tables without student identifiers.
[0076] For each table p in P, a personalized document is constructed. The core steps are as follows:
[0077] 1) Based on the database type, enter the relevant command to obtain the structure information L1 of table p. For example, for a MongoDB database, the db.myCollection.stats() command can be used to obtain the table's structure information.
[0078] 2) Input the table's structure information into the first general large language model (LLM1), prompting it to generate multiple sets of question templates for specific students based on this table. The construction formula for template one, prompt1, is as follows:
[0079] prompt1=smooth(identity+L1);
[0080] Here, smooth means using fluent sentences to concatenate relevant information, identity means setting the identity for the model, and L1 means the structure of table p.
[0081] In this embodiment, template one, prompt1, is as follows:
[0082] prompt1 = "You are an experienced teacher. There is a table in a database that records student information. The table structure is ["+L1+"]. Please study this table and construct question templates based on its contents. For example, "What is student xx's class schedule?". Please construct question templates with different question-and-answer content as much as possible and return these templates to me as a JSON array. No other additional description is needed."
[0083] In this way, the problem template set Q was obtained.
[0084] 3) For each data point d in p, prompt LLM1 generates question, answer, and time information based on the question template set Q. The formula for constructing template 2 prompt2 is as follows:
[0085] prompt2=smooth(identity+d+Q);
[0086] Here, smooth means using fluent sentences to concatenate relevant information, identity means setting an identity for the model, d is a data point in p, and Q represents a set of question templates.
[0087] In this embodiment, template two, prompt2, is as follows:
[0088] prompt2 = "You are an experienced teacher. You have a set of question templates Q: ["+Q+"] and known information d: ["+d+"]. For each question template in Q, you need to construct a JSON object containing four attributes. The type attribute is set to the default value of 0, the question attribute is the question template you fill in based on d, the answer attribute is the answer to the question based on d, and the time attribute is the creation time you parse from d; if it exists, fill it in, otherwise set it to null. After processing all the question templates, please encapsulate all the JSON objects you constructed into a JSON array and return it to me; no other additional description is needed."
[0089] 4) By formatting and processing the JSON data returned by LLM1, you can efficiently obtain personalized documents.
[0090] For each table g in G, construct a generic document. The core steps are as follows:
[0091] 1) Export table g as a text file named txt. Then, divide the text file into blocks with a maximum length of 1000 characters, obtaining a text block set T = (t1, t2, ..., t...). c ), t1, t2, ..., t c There are c text blocks.
[0092] 2) Based on the database type, enter the relevant command to obtain the structure information S2 of table g. For example, for a MongoDB database, the db.myCollection.stats() command can be used to obtain the table structure information.
[0093] 3) Guide LLM1 to learn the structure L2 of table g, and generate a general document for each text block t. The formula for constructing template 3 (prompt3) is as follows:
[0094] prompt3=smooth(identity+L2+t);
[0095] Here, smooth means using fluent sentences to concatenate relevant information, identity means setting an identity for the first general large language model, L2 means the structure of the table, and t means the text block after the above processing.
[0096] In this embodiment, template three, prompt3, is as follows:
[0097] prompt3 = "You are an experienced teacher. There is a table in a database that records some teaching information. The table structure is ["+L2+"], and the content information in the table is ["+t+"]. Please carefully study the structure and content of this table, and think about what questions and answers can be constructed based on this information. Then, please construct a batch of JSON objects in the same format. These objects each have four properties: the type property is set to the default value of 1, the question property is the question stem, the answer property is the question and answer, and the time property is the creation time of the knowledge in the database. If it exists, fill it in; otherwise, set it to null. Please encapsulate all the JSON objects you construct into a JSON array and return it to me. No other additional description is needed."
[0098] In this way, the dataset E generated by the first general-purpose large language model is obtained.
[0099] 4) The generated dataset E is then fed back into LLM1 for deduplication and quality checks. Data that passes the checks is used for document construction. Template 4 (prompt4) is as follows:
[0100] prompt4=smooth(identity+E);
[0101] Here, "smooth" means to use fluent sentences to concatenate relevant information, and "identity" means to set an identity for the model.
[0102] In this embodiment, template four, prompt4, is as follows:
[0103] prompt4 = "You are a data processing expert. You have a JSON dataset: ["+E+"]. The basic unit of data is an object, which has four properties: type (category), question (question), answer (time), and time (source of knowledge). Please carefully analyze and study this dataset and process it according to my requirements. My requirements are as follows: 1. Object deduplication. If the content examined in the question-answer pair is completely identical, please keep one of the data entries. If the time property of both objects is not null, prioritize keeping the object with the newer time value. 2. Quality check. Please check the quality of the question-answer pair. If there are errors, remove duplicate objects. Please carefully process my data according to my two requirements and return the processed data to me in JSON format. No other additional description is needed."
[0104] 5) By formatting and processing the JSON data returned by LLM1, you can efficiently obtain general-purpose documents.
[0105] By aggregating the personalized and general documents obtained through the above methods, an external knowledge base can be constructed, denoted as F = (f1, f2, ..., f...). d ), where f1, f2, ..., f d There are d documents, each containing type, question, answer, and time.
[0106] Furthermore, step S2 specifically includes:
[0107] The construction of the student problem classifier mainly relies on machine learning methods to build a model capable of classifying student problems into personalized problems and general problems. The core steps are as follows:
[0108] 1) Based on online education platforms, frequently asked questions from students are collected. The questions are segmented using the Python Chinese word segmentation library jieba, and the segmented words are represented as k using the open-source word embedding interface of OpenAI. For each question, the final representation is K = (k1, k2, ..., kk). h ), where h is the maximum value of the words into which the question is divided, and words less than h are padded with 0.
[0109] 2) Based on whether the answer to the question is relevant to the questioner, manually label the question. There are two types of labels: 0, which represents a personalized question; and 1, which represents a general question. If the answer to the question is relevant to the questioner, it is labeled with a personalized question label of 0; otherwise, it is labeled with a general question label of 1.
[0110] 3) Divide the dataset, with 70% used as the training set and 30% used as the test set.
[0111] 4) Train the LSTM model on the data to build a student question classifier capable of binary classification. The core formula of the LSTM model is as follows:
[0112] h t =f(k) t h t-1 );
[0113] Among them, h t with h t-1 k represents the hidden layer state in two stages. t t represents the word representation processed in stage t, and f represents the internal correlation function of LSTM.
[0114] To enable the student question classifier to perform binary classification, a fully connected layer and a sigmoid activation function are added after the output layer of the LSTM. Binary cross-entropy is then used as the loss function. The output of the student question classifier is represented as follows:
[0115] y t =σ(W y ·h t +b y );
[0116] Among them, y t This represents the model output, σ represents the sigmoid activation function, and W... y h represents the weights of the fully connected layer. t Indicates the hidden layer state, b y This indicates the bias of the fully connected layer.
[0117] Furthermore, step S3 specifically includes:
[0118] After obtaining the student's question, the most relevant documents need to be retrieved from an external knowledge base. Then, based on the nature of the student's question, the relevant documents are reordered using the Second General Large Language Model (LLM2) to obtain high-quality search results. The core steps of knowledge base retrieval and quality reordering are as follows:
[0119] Knowledge base retrieval: Retrieves documents most relevant to the student's question from an external knowledge base, based on the similarity between the document's question field and the student's question. The query for the student's question is compared to the external knowledge base F = (f1, f2, ..., f...). d The operation steps are as follows:
[0120] 1) Use OpenAI's open-source word embedding interface to encode the question fields of documents in the knowledge base. Among them, document f d The corresponding question field is encoded as d′. This step is performed only once, and the encoded information is stored in the database for future queries.
[0121] 2) Using the same encoder, encode the student question query as q′.
[0122] 3) The cosine similarity method is used to calculate the similarity between the student question and the document question fields. For q′ and d′, the similarity calculation formula is:
[0123]
[0124] Where q′·d′ is the inner product of two vectors, and |q′| and |d′| represent the lengths of the two vectors.
[0125] 4) Select the top m documents with the highest similarity to form the search result F′=(f′1,f′2,…,f′ m ), f′1, f′2,…, f′ m Let m be the number of documents retrieved.
[0126] Quality Reordering: Based on the Second General Large Language Model (LLM2) and considering the nature of student questions, an algorithm is designed to reorder the quality of the retrieved documents. For the above search result F′, the operation steps are as follows:
[0127] 1) Input the student question query into the student question classifier trained in step S2 to obtain the student question category.
[0128] 2) Inform LLM2 of the scoring algorithm in the form of prompts to achieve quality reordering. The formula for constructing template 5 (prompt5) is as follows:
[0129] prompt5=smooth(identity+F′+m+query+category);
[0130] Here, smooth means using fluent sentences to concatenate relevant information, identity means setting an identity for the second general large language model, F′ represents the above search results, m represents the number of documents retrieved, query represents student questions, and category represents the categories of student questions.
[0131] In this embodiment, template five (prompt5) is as follows:
[0132] prompt5 = "You are an experienced teacher, and your student asked you the question ["+query+"]. To better answer the student's question, you searched an external knowledge base and obtained the m most relevant documents: ["+F′+"]. Since the quality of the search is difficult to guarantee, you now need to score these m documents according to my algorithm. The scoring steps are as follows: 1. Each document starts with a score of 0. 2. Pair the m documents together to create m*(m-1) / 2 document pairs. 3. For each document pair, rank them according to their importance to your answer to the student's question. Winning documents gain 2 points if their type attribute matches ["+category+"], otherwise gain 1 point; losing documents lose 1 point if their type attribute matches ["+category+"], otherwise lose 2 points. After you have processed all document pairs, return the documents to me in descending order of score, without any additional descriptions."
[0133] 3) Process the documents returned in step 2), retain the top n documents by score, and form the final retrieval result F″=(f1″,f2″,…,f n ″), f1″, f2″,…, f n "These are the n highest quality documents retrieved."
[0134] Furthermore, step S4 specifically includes:
[0135] The final retrieval result F″ from the external knowledge base is passed as auxiliary information to the third general-purpose large language model (LLM3), allowing it to combine its own knowledge with additional supplementary knowledge to answer the student's question. The formula for constructing template six, prompt6, is as follows:
[0136] prompt6=smooth(identity+query+F″);
[0137] Here, smooth means using fluent sentences to concatenate relevant information, identity means setting the identity for the model, query means student question, and F″ means the final retrieval result from the external knowledge base.
[0138] In this embodiment, the template for prompt6 is as follows:
[0139] Prompt6 = "You are an experienced teacher, and your student has asked you the question ["+query+"]. To better answer the student's question, you searched an external knowledge base and obtained the search results: ["+F"+". Now, please combine your existing knowledge with the information retrieved from the external knowledge base to answer the student's question. While ensuring the accuracy and professionalism of your answer, please use language that is as easy to understand as possible."
[0140] The final answer from the third general language model is returned to the student, resulting in high-quality question and answer.
[0141] The general large language model in this invention adopts a large language model that already exists and is widely used in the prior art.
[0142] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from its spirit or essential characteristics. Therefore, the embodiments should be considered in all respects as exemplary and non-limiting, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within the present invention, and no reference numerals in the claims should be construed as limiting the scope of the claims.
[0143] Furthermore, it should be understood that although this specification describes embodiments, not every embodiment contains only one independent technical solution. This narrative style is merely for clarity. Those skilled in the art should consider the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.
Claims
1. A question-answering assistant enhancement method based on a general large language model and knowledge retrieval, characterized in that, Includes the following steps: S1, External Knowledge Base Construction: Personalized and general information are parsed from the tables in the smart education platform's database. Based on the first general language model, personalized and general information are automatically labeled as personalized and general documents, respectively, completing the construction of the external knowledge base. The basic unit of the external knowledge base is a document, and each document includes a type field, a time field, a question field, and an answer field. The type field indicates the document's category, which includes personalized and general categories. The time field indicates the document's creation time in the database. The contents of the question field and the answer field together form a knowledge record, which records the student's question and the corresponding answer, respectively. S2, Student Question Classifier Construction: Collect and label student questions to obtain student question samples; select an LSTM model to construct a student question classifier, and train the student question classifier for text classification using student question samples. The trained student question classifier can classify student questions into individual questions and general questions. S3, Knowledge Base Retrieval and Quality Re-ranking: For a new student question query, retrieve the top m documents with the highest similarity from the external knowledge base; input the student question query into the trained student question classifier to obtain the category of the student question query; based on the second general large language model and combined with the category of the student question, design a scoring algorithm to re-rank the quality of the retrieved m documents, and select the top n documents with the highest quality as the final retrieval result F of the external knowledge base. ′′ , where n < m; S4, Collaborative Reasoning: Guide the third general language model to learn the final retrieval results of the external knowledge base, input the student's question query into the third general language model for collaborative reasoning, and obtain the answer to the student's question.
2. The question-answering assistant enhancement method based on a general large language model and knowledge retrieval according to claim 1, characterized in that, Step S1 specifically includes: classifying the tables in the database according to the student identifiers in the tables, and forming a personalized table set P = (p1, p2, ..., p...) from the tables containing student identifiers. a The remaining tables form a general-purpose table set G = (g1, g2, ..., g...). b ); p1, p2, ..., p a For the first to the a-th tables with student identifiers, g1, g2, ..., g b The first to the bth sheets do not have student identifiers; For each table p in P, construct a personalized document: Obtain the structural information L1 of table p, input the structural information L1 into the first general large language model, prompt the first general large language model to generate multiple sets of question templates for specific students based on the structural information L1 of table p, and then obtain the question template set Q; For each data d in p, construct template 2 prompt2, prompting the first general language model to generate information such as type field, question field, answer field, and time field of the document category based on the question template set Q; generate the personalized document based on the information returned by the first general language model; For each table g in G, construct a generic document: After exporting table g as text, it is divided into blocks to obtain a set of text blocks T = (t1, t2, ..., t...). c ), t1, t2, ..., t c These are the first to c-th text blocks; Obtain the structural information L2 of table g; construct template 3 prompt3 to guide the first general language model to learn the structural information L2, and generate information such as type field, question field, answer field and time field of document category for each text block t, so as to obtain the initial general document; The initial general-purpose documents are grouped into a set E, which is then fed into the first general-purpose large language model. A template four, prompt4, is constructed to deduplicate and perform quality checks on set E, resulting in the final general-purpose documents. By aggregating personalized documents and general-purpose documents, we obtain an external knowledge base F = (f1, f2, ..., f d ), where f1, f2, ..., f d These are the first to d documents in the external knowledge base F.
3. The question-answering assistant enhancement method based on a general large language model and knowledge retrieval according to claim 2, characterized in that, The template 1 prompt1 is: prompt1=smooth(identity+L1); Here, "smooth" represents the operation of concatenating statements, and "identity" represents setting an identity for the first general large language model.
4. The question-answering assistant enhancement method based on a general large language model and knowledge retrieval according to claim 2, characterized in that, The template 2 prompt2 is: prompt2=smooth(identity+d+Q); Here, "smooth" represents the operation of concatenating statements, and "identity" represents setting an identity for the first general large language model.
5. The question-answering assistant enhancement method based on a general large language model and knowledge retrieval according to claim 2, characterized in that, The template three, prompt3, is as follows: prompt3=smooth(identity+L2+t); Here, "smooth" represents the operation of concatenating statements, and "identity" represents setting an identity for the first general large language model.
6. The question-answering assistant enhancement method based on a general large language model and knowledge retrieval according to claim 2, characterized in that, The template four, prompt4, is: prompt4 = smooth(identity + E) Here, "smooth" means using fluent sentences to concatenate relevant information, and "identity" means setting an identity for the first general large language model.
7. The question-answering assistant enhancement method based on a general large language model and knowledge retrieval according to claim 1, characterized in that, Step S2 specifically includes: After collecting student questions and segmenting them into words, the word embedding interface is used to represent the segmented words as word vectors k. For each student question, a set of word vectors K = (k1, k2, ..., k) is obtained. h ), where h is the maximum number of word segments for the student question; if the number of word segments is less than h, the corresponding word segmentation vector is padded with 0; k h Let h be the word segmentation vector of the h-th word; Based on whether the answer is relevant to the questioner, the corresponding student questions are manually labeled to obtain a sample of student questions. The labels include labels for individual questions and labels for general questions. An LSTM model is used to train on student question samples. A fully connected layer and a sigmoid activation function are added after the output layer of the LSTM model to construct a student question classifier. Then, binary cross-entropy is used as the loss function for the student question classifier, and the output y of the student question classifier is... t Represented as: y t =σ(W y ·h t +b y ); Where σ represents the sigmoid activation function, W y h represents the weights of the fully connected layer. t b represents the hidden layer state of the LSTM model. y This indicates the bias of the fully connected layer.
8. The question-answering assistant enhancement method based on a general large language model and knowledge retrieval according to claim 1, characterized in that, Step S3 specifically includes knowledge base retrieval and quality re-ranking: Knowledge base retrieval: For a new student question query, retrieve it from the external knowledge base F = (f1, f2, ..., f...). d Search for documents most relevant to student questions in f. d For the d-th document in the external knowledge base F, the retrieval criterion is the similarity between the document's question field and the student's question, specifically including: Using a word embedding interface, the question field of a document in an external knowledge base is encoded, where document f d The corresponding question field is encoded as d ′ ; Using a word embedding interface, the student question query is encoded as q. ′ ; The cosine similarity method is used to calculate the similarity between the student's question query and the document f. d The similarity s(q) of the question fields ′ ,d ′ ): Where q′·d′ is the inner product of q′ and d′, and |q′| and |d′| represent the lengths of q′ and d′, respectively; The top m documents with the highest similarity are selected to form the search results F′=(f′1,f′2,…,f′). m ), f′ m For the m documents in the search result F′; Quality Reordering: Design a scoring algorithm to reorder the documents in the retrieval result F′ of the second general large language model, specifically including: Input the student question query into the trained student question classifier to obtain the student question category; The scoring method, presented as template 5, is input into the second general language model to re-rank the documents in the retrieval result F′; template 5 (prompt5) is as follows: prompt5=smooth(identity+F′+m+query+category); Here, "smooth" indicates the operation of concatenating statements, and "identity" indicates setting the identity for the model; In the quality-reordered search results F′, the top n documents by score are retained to form the final search results F″=(f″1,f″2,…,f″) of the external knowledge base. n ), f″ n This refers to the nth document in the final search result F″.
9. The question-answering assistant enhancement method based on a general large language model and knowledge retrieval according to claim 1, characterized in that, Step S4 specifically includes: Template 6 (prompt6) is constructed, which uses the final retrieval result F″ from the external knowledge base as auxiliary information to pass to the third general-purpose language model. This allows the third general-purpose language model to combine its own knowledge with additional supplementary knowledge to answer the student's question. Template 6 (prompt6) is as follows: prompt6=smooth(identity+query+F″); Here, "smooth" indicates the operation of concatenating statements, and "identity" indicates setting the identity for the model; The output of the third general large language model is the answer to the student's query.