Question and answer method, device and equipment based on large language model and storage medium

By adopting a hierarchical architecture and knowledge distillation technology in large language models, the generation of thought chain reasoning steps and answer generation are separated. A small-size model is used for reasoning step generation, and a large-size model is used for answer generation. This solves the computational cost and response delay problems of large language models in the fields of financial management and medical consulting, and improves user experience and system efficiency.

CN120763286APending Publication Date: 2025-10-10ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510852119.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-24
Publication Date
2025-10-10

AI Technical Summary

Technical Problem

Existing large language models have problems with high computational costs and response delays in applications in financial management and medical consulting. It is difficult to effectively reduce computational costs and response delays while ensuring generation accuracy, which affects user experience.

Method used

A hierarchical architecture of two large language models is adopted, in which a small-size model is used to generate the thought chain reasoning steps, and the other large-size model is used to generate the answer. The knowledge of the large-size model is transferred to the small-size model through knowledge distillation technology, ensuring the accuracy of the thought chain reasoning steps and reducing computing costs and response delays.

Benefits of technology

This reduces computing costs and response delays while ensuring the accuracy of answer generation, improving user experience and system efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120763286A_ABST
    Figure CN120763286A_ABST
Patent Text Reader

Abstract

One or more embodiments of the invention provide a question and answer method and device based on a large language model, equipment and a storage medium. The method comprises the following steps: obtaining a to-be-solved question; inputting the question into a first large language model, and generating a compressed thinking chain reasoning step corresponding to the question by the first large language model; wherein the first large language model is a large language model obtained by training based on a compressed thinking chain sample; the step of thinking chain reasoning in the compressed thinking chain sample is the step of thinking chain reasoning after context compression; inputting the question and the compressed thinking chain reasoning step into a second large language model, and generating an answer corresponding to the question by the second large language model based on the compressed thinking chain reasoning step; wherein the number of model parameters of the first large language model is smaller than that of model parameters of the second large language model. According to the method, the calculation cost and the response delay of the model can be effectively reduced while the model generation precision is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] One or more embodiments of the present application relate to the field of artificial intelligence technology, and in particular, to a question-answering method, apparatus, device, and storage medium based on a large language model. Background Art

[0002] A Large Language Model (LLM) is a natural language processing model based on deep learning technology, boasting powerful language understanding and generation capabilities. LLMs are increasingly being used. For example, intelligent dialogue systems (IDSs) based on LLMs are widely used in numerous fields, including customer service, online education, medical consulting, financial management, and legal aid. In the financial management field, for example, IDSs have become a key tool for improving the quality and efficiency of financial services. By simulating human communication, they provide users with financial-related conversations, Q&A, and query services, such as asset allocation, investment analysis, and risk identification. IDSs are a specific user-facing application of LLMs, designed to understand and answer questions posed by users in natural language and generate concise and clear answers. Specifically, IDSs are based on LLMs, which understand and answer user questions and generate corresponding answers.

[0003] In actual application scenarios, it is usually expected to ensure the generation accuracy of the large language model while effectively reducing the computational cost and response delay of the large language model, so that the large language model can provide services to users accurately and efficiently, improving the user experience when using the large language model. Summary of the Invention

[0004] One or more embodiments of the present application provide the following technical solutions:

[0005] This application provides a question-answering method based on a large language model, the method comprising:

[0006] Get the problems to be solved;

[0007] Inputting the question into a first large language model, and generating a compressed thought chain reasoning step corresponding to the question by the first large language model; wherein the first large language model is a large language model trained based on a compressed thought chain sample; and the thought chain reasoning step in the compressed thought chain sample is the thought chain reasoning step after context compression;

[0008] input the question and the compressed thought chain reasoning step into a second large language model, and generate an answer corresponding to the question based on the compressed thought chain reasoning step by the second large language model; wherein the number of model parameters of the first large language model is less than the number of model parameters of the second large language model.

[0009] The application also provides a question and answer method based on a large language model, which comprises:

[0010] obtaining a question to be solved;

[0011] inputting the question into a first large language model, and generating a thought chain reasoning step corresponding to the question by the first large language model;

[0012] contextually compressing the thought chain reasoning step;

[0013] inputting the question and the compressed thought chain reasoning step into a second large language model, and generating an answer corresponding to the question based on the compressed thought chain reasoning step by the second large language model; wherein the number of model parameters of the first large language model is less than the number of model parameters of the second large language model.

[0014] The application also provides a question and answer device based on a large language model, which comprises:

[0015] an obtaining module, which obtains a question to be solved;

[0016] a first generating module, which inputs the question into a first large language model, and generates a compressed thought chain reasoning step corresponding to the question by the first large language model; wherein the first large language model is a large language model trained based on a compressed thought chain sample; the thought chain reasoning step in the compressed thought chain sample is a thought chain reasoning step after context compression;

[0017] a second generating module, which inputs the question and the compressed thought chain reasoning step into a second large language model, and generates an answer corresponding to the question based on the compressed thought chain reasoning step by the second large language model; wherein the number of model parameters of the first large language model is less than the number of model parameters of the second large language model.

[0018] The application also provides a question and answer device based on a large language model, which comprises:

[0019] an obtaining module, which obtains a question to be solved;

[0020] a first generating module, which inputs the question into a first large language model, and generates a thought chain reasoning step corresponding to the question by the first large language model;

[0021] a compression module configured to perform context compression on the chain-of-thought reasoning steps;

[0022] a second generation module configured to input the question and the compressed chain-of-thought reasoning steps into a second large language model, and generate, by the second large language model, an answer corresponding to the question based on the compressed chain-of-thought reasoning steps; wherein a number of model parameters of the first large language model is less than a number of model parameters of the second large language model.

[0023] The present application also provides an electronic device comprising:

[0024] a processor;

[0025] a memory for storing processor-executable instructions;

[0026] wherein the processor implements the steps of the method of any of the above by running the executable instructions.

[0027] The present application also provides a computer-readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the steps of the method of any of the above.

[0028] In the above technical solution, the number of model parameters of the first large language model used to perform the chain-of-thought reasoning step generation task can be less than the number of model parameters of the second large language model used to perform the question and answer task; for a problem to be solved, the problem can be first input into the first large language model, and the first large language model can generate a chain-of-thought reasoning step corresponding to the problem, and then the problem and the chain-of-thought reasoning step can be input into the second large language model, and the second large language model can generate an answer corresponding to the problem based on the chain-of-thought reasoning step.

[0029] In the above manner, the reasoning process that needs to output intermediate reasoning steps can be divided into two nodes of chain-of-thought reasoning process generation and answer generation, the first large language model with a smaller number of model parameters can be used to perform the chain-of-thought reasoning step generation task, and the second large language model with a larger number of model parameters can be used to perform the answer generation task. On the one hand, since the first large language model has a smaller number of model parameters, the first large language model also has a relatively small calculation cost and response delay; on the other hand, the first large language model can be obtained by knowledge distillation of the second large language model, so as to ensure the accuracy of the chain-of-thought reasoning step generated by the first large language model, thereby ensuring the accuracy of the answer further generated by the second large language model based on the chain-of-thought reasoning step. BRIEF DESCRIPTION OF DRAWINGS

[0030] The drawings needed to be used in the following description of exemplary embodiments will be described below, in which:

[0031] Figure 1 FIG. 1 is a schematic diagram of an intelligent dialogue system according to an example embodiment of the present application.

[0032] Figure 2 FIG. 2 is a flowchart of a large language model-based question answering method according to an example embodiment of the present application.

[0033] Figure 3 FIG. 3 is a schematic diagram of a large language model-based question answering process according to an example embodiment of the present application.

[0034] Figure 4 FIG. 4 is a flowchart of another large language model-based question answering method according to an example embodiment of the present application.

[0035] Figure 5 FIG. 5 is a schematic diagram of another large language model-based question answering process according to an example embodiment of the present application.

[0036] Figure 6 FIG. 6 is a structural schematic diagram of a device according to an example embodiment of the present application.

[0037] Figure 7 FIG. 7 is a block diagram of a large language model-based question answering apparatus according to an example embodiment of the present application.

[0038] Figure 8 FIG. 8 is a block diagram of another large language model-based question answering apparatus according to an example embodiment of the present application. DETAILED DESCRIPTION

[0039] The example embodiments will be described in detail herein with reference to the attached drawings. The following description is with reference to the drawings, in which like numerals refer to like elements throughout. The embodiments described in the following example embodiments are not representative of all embodiments consistent with one or more embodiments of the present application. Rather, they are merely examples consistent with some aspects of one or more embodiments of the present application.

[0040] It should be noted that the steps of the corresponding methods are not necessarily performed in the order shown and described in the present application in other embodiments. In some other embodiments, the steps included in the methods can be more or less than those described in the present application. In addition, a single step described in the present application can be divided into multiple steps for description in other embodiments, and multiple steps described in the present application can be combined into a single step for description in other embodiments.

[0041] In practical application scenarios, users often hope to have intelligent and efficient methods to help solve their own problems. Large language models have received widespread attention due to their excellent natural language understanding and generation capabilities. These models, trained on large text datasets, can understand and handle the subtle differences in human language, providing new ideas for solving various problems.

[0042] For example, in the field of medical consultation, the workload of medical personnel continues to increase as the number of patients and the complexity of disease types grow. Traditional one-on-one artificial consultation services are inefficient and cannot meet the needs of large groups of people. Moreover, for rare diseases or complex conditions, a single doctor may lack sufficient experience and resources to provide the best diagnosis and treatment recommendations. In addition, there is a gap in professional knowledge between patients and medical providers, leading to difficulties in communication, and many patients have difficulty understanding complex medical terminology, affecting their understanding of their own health status and compliance with treatment plans. Therefore, there is a need for a technology that can integrate vast amounts of medical knowledge, enable fast and accurate query analysis, and provide personalized medical advice to users in an easily understandable manner.

[0043] Large language models not only can process and understand large amounts of medical text data, but also can help doctors improve their work efficiency and assist in decision-making processes through natural language interaction, while also providing understandable medical information directly to patients, thereby improving the service quality and accessibility of the entire medical consultation field.

[0044] For example, in the field of financial management, with the development of globalization and the increasing complexity of financial markets, investors have an increasing demand for efficient, personalized, and scientific asset management solutions, especially in the field of fund allocation. How to make accurate decisions based on vast amounts of information has become a key problem. Financial market data is vast and complex, including but not limited to macroeconomic indicators, company financial reports, market trend analysis, policy changes, etc. These data sources are extensive and updated rapidly, and traditional data analysis methods are difficult to process and extract valuable information from them in a timely and effective manner to guide investment decisions. At the same time, investor demand is highly personalized, with different risk preferences, income expectations, and fund sizes requiring customized investment strategies. However, existing automated investment tools often only provide limited options or general solutions, failing to fully consider individual differences, resulting in low customer satisfaction. In addition, the uncertainty and volatility of financial markets increase the difficulty of investment decisions. In order to make more accurate predictions, it is necessary to consider multiple factors and quickly adapt to new information. Traditional methods are inefficient in handling such dynamic adjustments and are difficult to respond in real time. Therefore, there is a need for a technology that can integrate multi-source heterogeneous data, automatically learn market rules, and provide personalized investment recommendations.

[0045] Large language models can identify potential investment opportunities and risks by understanding and parsing large amounts of text information (such as news reports, research reports, etc.), and dynamically adjust strategies based on real-time market changes, providing investors with more accurate and personalized fund allocation recommendations, thereby improving the scientific nature and accuracy of investment decisions.

[0046] In this application, medical consultation systems, financial management systems and other service systems can be implemented using intelligent dialogue systems (or intelligent question-and-answer systems). Taking the intelligent dialogue system as an example, it provides users with dialogue, question-and-answer, query and other services by simulating human communication methods. The intelligent dialogue system is a specific application form of the large language model for users. It aims to understand and answer questions raised by users in natural language and generate concise and clear answers. Specifically, the intelligent dialogue system is based on the large language model, which understands and answers questions raised by users and generates corresponding answers.

[0047] In actual applications, using an intelligent dialogue system, users can submit questions to a large language model, which will understand and answer the questions raised by the users and generate corresponding answers, allowing users to formulate problem-solving solutions based on the answers corresponding to the questions output by the large language model.

[0048] A large language model is a natural language processing model based on deep learning technology, with powerful language understanding and generation capabilities. Large language models typically refer to deep learning models trained using large amounts of text data. They can be used to understand the meaning of natural language text or generate natural language text. Large language models can handle a variety of natural language tasks, such as text classification, named entity recognition (NER), question answering, and conversation, and are an important path to artificial intelligence.

[0049] In the field of natural language processing (NLP), large-scale text datasets are often referred to as corpuses. Corpuses can contain a variety of text data, such as literary works, academic papers, legal documents, news reports, everyday conversations, emails, and online forum posts. By learning from the text data in a corpus, large language models can acquire and understand the patterns and regularities of natural language, enabling effective processing and generation of human language.

[0050] Large language models typically use the Transformer architecture, meaning they are deep learning models based on the Transformer architecture. Transformer-based deep learning models are a type of neural network model that excels in fields like natural language processing.

[0051] Transformer is a neural network model used for sequence-to-sequence modeling. Transformer does not rely on recursive structures and can parallelize training and inference, speeding up model processing. In deep learning models based on the Transformer architecture, a multi-layer Transformer encoder is typically used to extract features from the input sequence, and a Transformer decoder is used to convert the extracted features into an output sequence. At the same time, such models typically also use a self-attention mechanism to capture long-distance dependencies in the input sequence, as well as residual connections and regularization methods to accelerate training and improve model performance.

[0052] A pretrained model is a large language model pretrained on large amounts of unlabeled text data. Pretrained models are general-purpose models; they are not designed or optimized for specific tasks. To adapt pretrained models to specific application scenarios and task requirements, they require fine-tuning to improve their performance on specific tasks. The large language model that is ultimately put into use is typically a pretrained model that has been further fine-tuned, performing supervised learning on labeled text data. Pretraining and fine-tuning are complementary processes: pretraining enables the model to acquire broad language understanding capabilities, while fine-tuning makes the model more specialized and accurate for specific tasks.

[0053] In other words, the training process of a large language model can be divided into two stages: pre-training and fine-tuning. During the pre-training stage, unsupervised learning (e.g., self-supervised learning) can be used on large-scale, unlabeled text datasets (e.g., online encyclopedias, online articles, books, etc.). Specifically, the model can predict missing parts or the next word based on the context, learn statistical laws such as semantics and syntax, and language structure. Backpropagation and optimization algorithms (e.g., gradient descent) are used to minimize prediction losses, iteratively update model parameters, and gradually improve the model's understanding of language. During the fine-tuning phase, you can select corresponding supervised learning tasks (for example, text classification, named entity recognition, question-answering systems, dialogue systems, etc.) based on the specific application scenarios and task requirements, and prepare task-specific text datasets. You can then use the pre-trained model as the starting point for fine-tuning, and use supervised learning to fine-tune on the task-specific text dataset. Specifically, you can perform the task based on the text dataset, and minimize the loss used to measure the performance of the model in processing specific tasks through backpropagation and optimization algorithms (for example, gradient descent). The model parameters are iteratively updated to gradually improve the model's performance on specific tasks. In practical applications, fine-tuning can flexibly choose supervised learning, unsupervised learning, or semi-supervised learning methods based on the specific application scenarios and the type of available data.

[0054] The language comprehension ability learned by the large language model during the pre-training and fine-tuning stages enables the large language model to perform logical inference, knowledge reasoning, or problem-solving by understanding, analyzing, and integrating text information when faced with complex problems or tasks. This ability is usually referred to as the reasoning ability of the large language model.

[0055] In practical applications, the pre-trained large language model is usually called the base model of the large language model, and the fine-tuned large language model is called the serving model of the large language.

[0056] Large language models are typically guided or stimulated by prompts (often called prompts) to perform specific tasks. A prompt can be an initial text or text fragment provided to the large language model, such as a sentence, a question, or a conversation, intended to guide or stimulate the model to produce the corresponding output. Prompts are key tools for guiding model output and can be very simple or quite complex, including instructions, examples, and descriptions of the desired output format. Prompts explicitly indicate the task expected of the large language model, such as answering a question, simulating a conversation, writing an article, or translating text. Prompts also provide the large language model with necessary background information and context, enabling it to understand the logic, style, theme, or stance that should be followed when generating content. Furthermore, prompts can inspire the large language model to demonstrate its inherent knowledge or specific language abilities, such as explaining complex concepts, citing regulations, or imitating the writing style of a specific author.

[0057] Since large language models are primarily used to understand and generate human language based on text processing, prompts typically appear in the form of text. However, in practical applications, large language models can also accept other forms of input as prompts, such as images, audio, and even video, provided that the large language model is designed or trained to process multimodal data.

[0058] One or more embodiments of the present application provide a technical solution for implementing question answering based on a large language model. In this technical solution, the number of model parameters of the first large language model used to perform the task of generating thought chain reasoning steps may be less than the number of model parameters of the second large language model used to perform the question answering task; for a problem to be solved, the problem can be first input into the first large language model, and the first large language model generates the thought chain reasoning steps corresponding to the problem, and then the problem and the thought chain reasoning steps are input into the second large language model, and the second large language model generates the answer corresponding to the problem based on the thought chain reasoning steps.

[0059] Using this approach, the reasoning process requiring the output of intermediate reasoning steps can be divided into two nodes: thought chain reasoning process generation and answer generation. The first language model, with a smaller number of model parameters, performs the thought chain reasoning step generation task, while the second language model, with a larger number of model parameters, performs the answer generation task. On the one hand, due to the smaller number of model parameters of the first language model, the computational cost and response latency of the first language model are also relatively small. On the other hand, the first language model can be obtained by performing knowledge distillation on the second language model, thereby ensuring the accuracy of the thought chain reasoning steps generated by the first language model, and thus the accuracy of the answers further generated by the second language model based on these thought chain reasoning steps.

[0060] Please refer to Figure 1 , Figure 1 It is a schematic diagram of an intelligent dialogue system shown in an exemplary embodiment of the present application.

[0061] like Figure 1 As shown, the intelligent dialogue system may include a server and at least one client accessing the server via any type of wired or wireless network.

[0062] The above-mentioned server may correspond to a server comprising an independent physical host, or may be a server cluster consisting of multiple independent physical hosts; or, may correspond to a virtual server, cloud server, etc. hosted by a host cluster.

[0063] The above-mentioned client can correspond to terminal devices such as smart phones, tablet computers, laptops, desktop computers, PCs (Personal Computers), PDAs (Personal Digital Assistants), wearable devices (such as smart glasses, smart watches, etc.), smart car devices or game consoles.

[0064] Users can use the intelligent dialogue service provided by the intelligent dialogue system through the client; the client and the server can implement user-oriented intelligent dialogue services through data interaction between each other.

[0065] Specifically, the above-mentioned server can be equipped with a large language model, and the above-mentioned intelligent dialogue system can be based on the large language model. The large language model can perform reasoning based on the question text (which can be called Query or Question) to understand and answer the questions raised by the question text, and generate an answer text corresponding to the question text (which can be called Response or Answer).

[0066] For example, the above client can output a corresponding user interface to the user, so that the user can perform operations such as inputting question text, uploading documents or pictures for assisting in asking questions, etc. in the user interface to ask questions to the above intelligent dialogue system and use the intelligent dialogue service provided by the intelligent dialogue system. The client can send the question text input by the user to the above server, and the server can generate a corresponding answer text for the question text and output the answer text to the user, that is, return the answer text to the client, and the client displays the answer text to the user through the user interface for the user to view, thereby realizing the intelligent dialogue service for the user.

[0067] It should be noted that the question text can be regarded as a special Prompt. The question text describes a specific problem that the user wants to solve, and the problem is usually expressed through a well-designed Prompt.

[0068] In actual application, the intelligent dialogue system mainly relies on the knowledge obtained by the large language model therein through learning static corpus in the training process. Due to the limitation of the knowledge, the intelligent dialogue system may have illusion problems when answering complex or specific questions. Among them, the illusion problem refers to that the content generated by the large language model looks very reasonable and coherent, and sometimes can even imitate human emotions and thinking modes, causing an illusion of “understanding” the input content, but actually the content is inaccurate or misleading.

[0069] In order to improve the adaptability and response accuracy of the intelligent dialogue system, the RAG (Retrieval-Augmented Generation) mode can be used to combine information retrieval and model generation, so that the above intelligent dialogue system can no longer rely only on the knowledge obtained by the large language model therein through learning static corpus in the training process when answering the question raised by the user, but can first perform information retrieval in a large-scale document set based on the question, and then understand and answer the question according to the relevant documents retrieved, and generate a corresponding answer. That is, the document set and the large language model can be combined, and in the model generation process, relevant information is retrieved from the document set in real time to assist the model to make more accurate and comprehensive answers or decisions. Since the retrieved information and the context of the question are considered in the model generation process, it can be ensured that the generated content not only meets the actual needs, but also is accurate, reliable, coherent and natural.

[0070] Specifically, the server can also be equipped with a knowledge base and an information retrieval component. This knowledge base is external to the large language model installed on the server. That is, the data in this knowledge base is not the knowledge acquired by the large language model through learning during training. Instead, it serves as auxiliary information in the large language model's reasoning process, assisting the large language model in generating an answer text corresponding to the question text. During the reasoning process of the large language model, the information retrieval component can perform information retrieval in the knowledge base based on the question text, thereby assisting the large language model in generating an answer text corresponding to the question text through the retrieved relevant information.

[0071] It should be noted that the aforementioned server can also be equipped with other functional components or subsystems such as a prompt generation component. These components or subsystems can work in conjunction with the large language model installed on the server to jointly generate the answer text corresponding to the question text.

[0072] Furthermore, the intelligent dialogue system described above can have only one large language model, which can be used to perform dialogue tasks or question-answering tasks, and can also, depending on actual needs, be used to perform tasks such as generating thought chain reasoning steps, information retrieval tasks, context compression tasks, and relationship extraction tasks. Alternatively, the intelligent dialogue system can have multiple large language models, which, in addition to the large language model used to perform dialogue tasks or question-answering tasks, can also include large language models used to perform thought chain reasoning step generation tasks, large language models used to perform information retrieval tasks, large language models used to perform context compression tasks, and large language models used to perform relationship extraction tasks.

[0073] One or more embodiments of the present application provide a method for implementing a question answering method based on a large language model, which can be applied to Figure 1 The intelligent dialogue system shown (or the specific data processing components in the intelligent dialogue system).

[0074] In the above-mentioned question-answering method based on the large language model, two different large language models can be used, and these two large language models can be respectively referred to as the first large language model and the second large language model. Among them, the number of model parameters of the first large language model can be less than the number of model parameters of the second large language model; that is, the first large language model can be a large language model of small size, and the second large language model can be a large language model of large size. For example, the first large language model can be a Qwen2.5-1.5B-level model (that is, a large language model with 150 million parameters), and the second large language model can be a Qwen2.5-72B-level model (that is, a large language model with 7.2 billion parameters). Since the number of model parameters of the first large language model is small, the computational cost and response delay of the first large language model are also relatively small.

[0075] The first language model can be used to perform the task of generating reasoning steps of a thought chain. That is, the first language model can perform reasoning based on the question as a prompt and generate the reasoning steps of a thought chain corresponding to the question under the guidance of the prompt.

[0076] Chain of Thought is a technology used to improve the performance of AI models in complex reasoning tasks. It mimics the step-by-step thinking process of humans when solving problems, breaking down the problem into multiple intermediate steps and gradually deriving the final answer. Chain of Thought can be introduced into the training and use of large-scale language models, aiming to enhance the model's interpretability and ability to solve complex problems by explicitly expressing intermediate reasoning steps.

[0077] Thought chaining emphasizes breaking down the problem-solving process into a series of sequential, logically related intermediate reasoning steps. This involves identifying the key elements of the problem, listing possible solution paths, and evaluating the feasibility of each path until the final answer is reached. By including the thinking and reasoning behind each step in the model's input or output, the decision-making process becomes transparent, which is critical for understanding the model's decision logic and improving interpretability. Thought chaining aims to make the machine's thinking process more human-like. By mimicking how humans think step by step to solve complex problems, it helps the model make reasonable inferences in the absence of direct training data.

[0078] The specific implementation of the thinking chain can be to directly embed this step-by-step reasoning format in the Prompt of the service model for the large language model, guiding the large language model to generate intermediate reasoning steps while generating the answer corresponding to the question; or, it can also be to construct a question and answer dataset containing intermediate reasoning steps as a thinking chain sample set, and use the thinking chain sample dataset to fine-tune the basic model of the large language model, so that the service model of the large language model obtained by fine-tuning can subsequently perform the thinking chain reasoning step generation task.

[0079] Specifically, thought chain samples can contain key content such as problem statements, intermediate reasoning steps, and final answers, which are used to guide and train large language models for step-by-step logical reasoning and problem solving.

[0080] A problem statement is a description of the specific problem or task that needs to be solved. It can be a mathematical problem, logical reasoning, factual inquiry, or any inquiry that requires a series of thinking steps to arrive at an answer.

[0081] The intermediate reasoning steps are the core part of the thought chain sample, including a series of logical reasoning, calculation or analysis from the question to the answer. Each step should be coherent, and the previous step should reasonably lead to the next step until the final answer is reached. For example, in solving mathematical problems, this may involve formula application, variable substitution, calculation simplification, etc.; in logical reasoning tasks, it may include premise analysis, hypothesis verification, etc.

[0082] The final answer is the solution to the question explicitly given after all the intermediate reasoning steps. This answer should be the natural result of the reasoning chain and closely connected to the previous reasoning steps.

[0083] It should be noted that in order to ensure the accuracy of the large language model after training (usually fine-tuning) to generate thought chain reasoning steps corresponding to the question, the thought chain sample used to train the large language model usually contains the contents of the question, thought chain reasoning steps and answer. However, in some cases, for example, in order to speed up the model training, the thought chain sample used to train the large language model can only contain the contents of the question and the thought chain reasoning steps. The specific content of the thought chain sample used to train the first large language model and the second large language model is not specially limited in the present application.

[0084] The thought chain sample can guide the large language model to learn to imitate such reasoning patterns through complete examples of questions, intermediate reasoning steps and answers. That is, the large language model can first learn the reasoning pattern shown in the thought chain sample, and then imitate such reasoning pattern to reason based on the question and output the intermediate reasoning steps and the answer in the reasoning process.

[0085] The second large language model can be used to perform a dialogue task or a question and answer task. That is, the second large language model can further reason based on the above question and the thought chain reasoning steps corresponding to the question generated by the first large language model to generate an answer corresponding to the question. Specifically, a Prompt can be generated based on the question and the thought chain reasoning steps corresponding to the question, for example, the question and the thought chain reasoning steps corresponding to the question can be spliced as a Prompt, and the second large language model can further reason based on the question and the thought chain reasoning steps corresponding to the question in the Prompt, and generate an answer corresponding to the question under the guidance of the Prompt.

[0086] It should be noted that the first large language model can refer to a service model of the first large language model. In actual application, the first large language model can be pre-trained on a large-scale unlabeled text dataset in an unsupervised learning manner to obtain a base model of the first large language model; then, the thought chain reasoning step generation task can be used as a supervised learning task in fine-tuning, and a text dataset specific to the thought chain reasoning step generation task can be prepared, and then the base model of the first large language model can be used as a starting point for fine-tuning, and the text dataset specific to the thought chain reasoning step generation task can be used for fine-tuning in a supervised learning manner to obtain the service model of the first large language model.

[0087] The text dataset specific to the thought chain reasoning step generation task can include the thought chain sample. In this case, the base model of the first large language model learns the reasoning mode shown in the thought chain sample, and becomes the service model of the first large language model. Subsequently, the service model of the first large language model can imitate the reasoning mode to generate the thought chain reasoning step corresponding to the question.

[0088] In actual application, for a thought chain sample, the question therein can be used as sample content, and the thought chain reasoning step (or the thought chain reasoning step and the answer) therein can be used as sample label. Fine-tuning of the large language model based on the thought chain sample can be supervised training.

[0089] Similarly, the second large language model can refer to a service model of the second large language model. In actual application, the second large language model can be pre-trained on a large-scale unlabeled text dataset in an unsupervised learning manner to obtain a base model of the second large language model; then, the dialogue task or the question and answer task can be used as a supervised learning task in fine-tuning, and a text dataset specific to the dialogue task or the question and answer task can be prepared, and then the base model of the second large language model can be used as a starting point for fine-tuning, and the text dataset specific to the dialogue task or the question and answer task can be used for fine-tuning in a supervised learning manner to obtain the service model of the second large language model.

[0090] In constructing the text dataset specific to the dialogue task or the question and answer task, the collected questions (the questions are training samples) can be labeled, and answers corresponding to the questions can be labeled (the labeled answers are labels of the training samples). In this way, the labeled questions can be used as the text dataset specific to the dialogue task or the question and answer task for supervised training of the second large language model.

[0091] In some embodiments, since the number of model parameters of the second large language model is much larger than the number of model parameters of the first large language model, in order to ensure the model effect of the first large language model as much as possible, thereby ensuring the accuracy of the thought chain reasoning steps corresponding to the question generated by the first large language model, the second large language model (which can be a basic model or a service model that cannot perform the thought chain reasoning step generation task but can perform other tasks) can be fine-tuned using the thought chain samples first, so that the fine-tuned second large language model can be used to perform the thought chain reasoning step generation task, and then the knowledge related to the thought chain reasoning step generation in the second large language model that can be used to perform the thought chain reasoning step generation task is migrated to the first large language model in the manner of model distillation.

[0092] Among them, knowledge distillation (Knowledge Distillation) is a model compression technology, its core idea is to migrate the knowledge of a complex, large and excellent performance "teacher model" (Teacher Model) to a simpler and lighter "student model" (Student Model). It trains the student model to imitate the behavior of the teacher model, which can reduce the computational cost and resource demand of the model while maintaining high model performance, making the student model more suitable for deployment on resource-constrained devices (such as mobile devices or embedded systems).

[0093] Specifically, in the process of migrating the knowledge related to the thought chain reasoning step generation in the second large language model that can be used to perform the thought chain reasoning step generation task to the first large language model in the manner of model distillation, first, on the one hand, the thought chain samples used to train (usually fine-tune) the second large language model that can be used to perform the thought chain reasoning step generation task as the teacher model can be obtained, and on the other hand, for each thought chain sample, the thought chain reasoning steps corresponding to the question in the thought chain sample generated by the second large language model based on the reasoning of the question in the thought chain sample can be obtained; then, for each thought chain sample, the original thought chain reasoning steps in the thought chain sample can be further replaced with the thought chain reasoning steps corresponding to the question in the thought chain sample generated by the second large language model based on the reasoning of the question in the thought chain sample, to update the thought chain sample, and the updated thought chain sample is determined as a distillation sample; finally, the first large language model as the student model can be trained (usually also fine-tuned) based on the distillation sample, so that the distillation loss function corresponding to the first large language model converges.

[0094] Alternatively, for each thought chain sample, the thought chain reasoning steps and answers corresponding to the question generated by the above-mentioned second largest language model based on the question in the thought chain sample can be obtained, and the original thought chain reasoning steps and answers in the thought chain sample can be further replaced with the thought chain reasoning steps and answers corresponding to the question generated by the second largest language model based on the question in the thought chain sample to update the thought chain sample, and the updated thought chain sample can be determined as a distilled sample.

[0095] In some embodiments, thought chains have a certain templated nature, meaning they typically follow a fixed structure or pattern. For example, they first pose a question, then gradually outline the thought steps required to solve it. These steps often follow a certain logical order and format. Therefore, during the aforementioned knowledge distillation process, the distillation loss function can be optimized to preserve the key reasoning logic.

[0096] In one example, in the above-mentioned knowledge distillation process, higher attention can be paid to the "logical connectives" (for example, "therefore", "because", "so", "hypothesis", "it can be seen from this", etc.) and "conclusion guiding words" (for example, "the result is", "finally concluded" and other reasoning conclusions, as well as mathematical operators such as "+", "-", "×", "÷", "=") in the reasoning steps of the thinking chain, thereby optimizing the distillation loss function and enabling the student model to more accurately inherit the key reasoning capabilities of the teacher model.

[0097] Specifically, the traditional loss function treats all tokens (which can be called word units, specifically words, phrases or sentences) equally, that is, the weights of the sub-loss functions corresponding to each token are equal. However, in this application, since the logical connectives and conclusion guides in the reasoning steps are more important than the detailed descriptions, the tokens containing the logical connectives and the reasoning conclusions can be used as anchor points of the thinking chain (Anchor Point, referring to words, phrases or sentences that play a key role in the reasoning process), and the weight of the sub-loss function corresponding to the token as the anchor point of the thinking chain in the above distillation loss function is made higher than the weights of the sub-loss functions corresponding to other tokens.

[0098] In practical applications, the above distillation loss function can be a KL divergence (Kullback-Leibler Divergence) loss function or a cross entropy loss function. Taking the KL divergence loss function as an example, the formula of the traditional KL divergence loss function can be as follows:

[0099]

[0100] Where i represents Token; P is the probability distribution of the teacher model; Q is the probability distribution of the student model.

[0101] In this application, the traditional KL divergence loss function can be extended to a weighted form:

[0102]

[0103] Where N is the sequence length, that is, the number of tokens in the reasoning step of the thinking chain; ω i is the weight of the ith Token, indicating the importance of the Token in the reasoning step of the thinking chain; i is the probability of the teacher model on the i-th Token; q i is the probability of the student model on the i-th token. At this point, the weight of the token as the anchor point of the thinking chain can be higher than the weight of other tokens.

[0104] In another example, the core of the thought chain is the causal / dependency relationship of the reasoning chain, which cannot be explicitly modeled by traditional loss functions. Therefore, in the above-mentioned knowledge distillation process, it is necessary not only to imitate the probability distribution output by the teacher model, but also to explicitly model and retain the logical relationship structure (such as causality, dependency, etc.), so that the student model can more accurately inherit the reasoning ability of the teacher model.

[0105] Specifically, traditional loss functions (such as KL divergence and cross entropy) calculate the loss equally for each token and fail to capture the semantic relationship or logical dependency between tokens. This may result in the student model imitating the surface text well, but the key reasoning chain is destroyed. However, in this application, a "logical relationship graph" can be extracted from the reasoning steps of the thought chain generated by the teacher model, and a graph structure consistency loss is introduced in the knowledge distillation process, so that the student model can not only imitate the token-level output, but also learn the reasoning structure behind it.

[0106] That is, the distillation loss function described above can include a graph structure consistency loss function. The graph structure consistency loss function can be a loss function calculated based on an entity relationship graph corresponding to the thought chain reasoning step of the question generated by the second large language model and an entity relationship graph corresponding to the thought chain reasoning step of the question generated by the first large language model for each thought chain sample. Graph structure consistency generally refers to the similarity or equivalence of graph data structures, which can involve the consistency of the number, type, and connection method between nodes and edges of the graph. In practical applications, the graph structure consistency loss can be the cosine distance between graph embeddings or the graph similarity calculated using a graph kernel function.

[0107] The entity relationship graph corresponding to the thought chain reasoning step generated by the second large language model can include an entity relationship graph generated based on the semantic relationship between entities extracted from the thought chain reasoning step generated by the second large language model. The entity relationship graph corresponding to the thought chain reasoning step generated by the first large language model can include an entity relationship graph generated based on the semantic relationship between entities extracted from the thought chain reasoning step generated by the first large language model.

[0108] Relation extraction (RE) aims to automatically identify and extract semantic relationships between entities from unstructured text, ultimately forming structured knowledge.

[0109] The extracted relationship from the thought chain reasoning step can be represented as a unit tuple in the form of (Subject, Relation, Object). For example, assuming that the thought chain reasoning step contains the sentence "According to Newton's second law, force is equal to mass times acceleration", the extracted relationship can be represented as the following triple: ("Newton's second law", "definition", "force is equal to mass times acceleration"); and assuming that the thought chain reasoning step contains the sentence "Because the weather is sunny, we decide to go on a picnic", the extracted relationship can be represented as the following triple: ("sunny weather", "leads to", "go on a picnic"). In this case, Subject and Object can be used as nodes, and Relation can be used as an edge to generate an entity relationship graph based on the extracted relationship.

[0110] In practical applications, the distillation loss function described above can be a weighted loss function obtained by optimizing a traditional loss function and the sum of the graph structure consistency loss function.

[0111] In some embodiments, the reasoning steps in the chain of thought generated by the model often contain redundant information such as repeated verification and irrelevant details. This leads to an overflow of redundant content in the model generation, a sharp increase in computing resource consumption, and thus affects the speed of generating the reasoning steps. Therefore, to speed up the generation of the reasoning steps in the chain of thought, the reasoning steps in the above-mentioned chain of thought samples can be thought-chain reasoning steps that have undergone context compression.

[0112] Specifically, when the first language model is trained directly based on thought chain samples, the thought chain reasoning steps in each thought chain sample used can be thought chain reasoning steps after context compression.

[0113] When the first language model as a student model is obtained by adopting the knowledge distillation method, the chain of thought reasoning steps in each chain of thought sample used to train the second language model as a teacher model can be the chain of thought reasoning steps after context compression, so that the trained second language model can directly generate compressed chain of thought reasoning steps; or, the chain of thought reasoning steps in each chain of thought sample used to train the second language model as a teacher model can be complete chain of thought reasoning steps, and after generating the complete chain of thought reasoning steps, the second language model can further perform context compression on the generated chain of thought reasoning steps to obtain compressed chain of thought reasoning steps. In this way, the chain of thought reasoning steps in the distilled samples obtained by sample update can be the chain of thought reasoning steps after context compression.

[0114] Context compression is a technique for optimizing the inference efficiency of large language models. It aims to reduce computational costs and response times by reducing redundant information in input prompts, while preserving key semantic content as much as possible to maintain the quality of model output. It is particularly important when processing long text or complex tasks, as the attention mechanism of large models often has input length limitations, and long contexts significantly increase computing resource consumption.

[0115] The core idea of context compression is to identify and retain the most relevant part of the information for the current task, and remove those unnecessary or repetitive contents. Context compression can be achieved through information filtering, summary generation, structured representation, dynamic pruning, etc. Information filtering refers to extracting the most critical information from the input, such as the question itself, relevant facts or parts of the context that explicitly affect the answer. Summary generation refers to using the model itself or other lightweight models to summarize the input content, compressing it into a shorter but more informative form. Structured representation refers to converting the original context into a structured data format (e.g., JSON, table, etc.), thereby reducing redundant descriptions. Dynamic pruning refers to selectively retaining the part of the content that is closely related to the current reasoning step based on the current query or task requirements.

[0116] In practical applications, the context compression of the thought chain reasoning steps in the above thought chain samples can be completed manually, or using tools such as LLMLingua (an open-source tool focused on text compression of large language model reasoning process), or a combination of manual and tool-based methods. The present application does not make special restrictions on this.

[0117] Since the thought chain reasoning steps in the thought chain samples used for training are context-compressed thought chain reasoning steps, the first large language model trained in this way can generate relatively short thought chain reasoning steps, thereby speeding up the generation of thought chain reasoning steps by the first large language model and reducing the response delay of the first large language model.

[0118] In this application, the thought chain sample in which the thought chain reasoning steps are context-compressed thought chain reasoning steps is referred to as a compressed thought chain sample. For a large language model trained based on a compressed thought chain sample, the thought chain reasoning steps generated by this large language model subsequently are referred to as compressed thought chain reasoning steps.

[0119] Please refer to Figure 2 , Figure 2 is a flowchart of a large language model-based question answering method according to an exemplary embodiment of the present application. The large language model-based question answering method can be applied to an intelligent dialogue system as shown in Figure 1 .

[0120] As shown in Figure 2 , the large language model-based question answering method can include the following steps:

[0121] Step 202: Obtain a problem to be solved.

[0122] In this embodiment, the problem to be solved may be obtained first.

[0123] For example, the question text submitted by the user may be obtained, thereby obtaining the question raised by the user using the question text.

[0124] Step 204: Input the question into the first large language model, and the first large language model generates a compressed thought chain reasoning step corresponding to the question; wherein, the first large language model is a large language model obtained by training based on a compressed thought chain sample; the thought chain reasoning step in the compressed thought chain sample is the thought chain reasoning step after context compression.

[0125] In this embodiment, the first large language model used to perform the task of generating thought chain reasoning steps can be a large language model trained based on compressed thought chain samples. The thought chain reasoning steps in each compressed thought chain sample are all thought chain reasoning steps after context compression.

[0126] When the above question is obtained, the question can be input into the above first language model, and the first language model performs reasoning based on the question to generate a compressed thinking chain reasoning step corresponding to the question.

[0127] For example, a question text submitted by a user can be input as a prompt into the first language model. Guided by the prompt, the first language model performs reasoning based on the question text, thereby generating description text corresponding to each intermediate reasoning step included in the reasoning process based on the question text. In this case, the generated description text can be regarded as a compressed description text obtained by contextually compressing the complete description text corresponding to each intermediate reasoning step included in the reasoning process based on the question text.

[0128] Step 206: Input the question and the compressed thought chain reasoning steps into the second largest language model, and the second largest language model generates an answer corresponding to the question based on the compressed thought chain reasoning steps; wherein the number of model parameters of the first largest language model is less than the number of model parameters of the second largest language model.

[0129] In this embodiment, when the compressed thinking chain reasoning steps corresponding to the above-mentioned question are obtained, the question and the compressed thinking chain reasoning steps can be further input into the above-mentioned second largest language model, and the second largest language model can perform further reasoning based on the question and the compressed thinking chain reasoning steps to generate an answer corresponding to the question.

[0130] For example, the question text submitted by the user and the compressed description text corresponding to the intermediate reasoning steps included in the reasoning process based on the question text generated by the above-mentioned first language model can be spliced, and the spliced ​​text can be input into the above-mentioned second language model as a new Prompt. Under the guidance of the Prompt, the second language model can further reason based on the question text in the Prompt and the compressed description text corresponding to the intermediate reasoning steps, so as to generate an answer text corresponding to the question text.

[0131] In some embodiments, the question may be about fund allocation, the chain of reasoning may include an analysis of user preferences and fund categories, and the answer may include fund categories and their allocation ratios. Alternatively, the question may be about medical diagnosis, the chain of reasoning may include the process of reasoning from symptoms to disease, and the answer may be the diagnosis result.

[0132] For example, the question could be: "I am 35 years old, have a stable income, a moderate risk tolerance, and hope to achieve steady growth in my assets. How should I allocate funds?"

[0133] The above thought chain reasoning steps can be as follows:

[0134] “Analyze user basic information and investment goals:

[0135] Age: 35 → Longer investment horizon, but not extremely high risk tolerance;

[0136] Stable income → can make regular fixed investments;

[0137] Medium risk tolerance → Not suitable for high-volatility products, but still want returns higher than deposits;

[0138] Goal: Steady appreciation → Hope that assets can maintain their value and grow moderately.

[0139] Filter fund categories based on user preferences:

[0140] Equity funds: They are more volatile and not suitable for all allocations, but can be invested in small amounts to capture growth potential;

[0141] Hybrid funds: moderate risk, suitable as one of the main configurations;

[0142] Bond funds: low risk, stable returns, suitable for conservative investors;

[0143] Money market funds: highly liquid and extremely low risk, suitable for short-term funds or emergency preparedness;

[0144] Index funds / ETFs: low cost, high transparency, can be part of the stock allocation.

[0145] Consider risk diversification principles and investment goal achievement probability:

[0146] Balance returns and risks;

[0147] Diversify investments across different types of funds to avoid single asset class risk.

[0148] The above answers can be shown as follows:

[0149] "Based on your situation, the following fund allocation plan is recommended:

[0150] Hybrid funds, 40%, moderate risk, balance returns and stability, suitable as core allocation;

[0151] Bond funds, 30%, stable returns, reduce overall portfolio volatility;

[0152] Index funds (e.g. Shanghai and Shenzhen 300 ETF), 20%, obtain long-term capital appreciation, control position to control risk;

[0153] Money market funds, 10%, for liquidity management, to deal with unexpected expenses."

[0154] Please refer to Figure 3 , Figure 3 is a schematic diagram of a question and answer process based on a large language model according to an example embodiment of the present application.

[0155] As Figure 3 indicated, in the above question and answer process based on a large language model, two different large language models can be used, which can be referred to as a first large language model and a second large language model. The number of model parameters of the first large language model can be less than the number of model parameters of the second large language model. The first large language model can be a large language model trained based on compressed thought chain samples, so the trained first large language model can generate compressed thought chain reasoning steps corresponding to the question.

[0156] In the above case, the problem to be solved can be obtained first.

[0157] In the case of obtaining the above problem, the problem can be input into the above first large language model, and the first large language model can perform reasoning based on the problem to generate compressed thought chain reasoning steps corresponding to the problem.

[0158] When the compressed thinking chain reasoning steps corresponding to the above-mentioned question are obtained, the question and the compressed thinking chain reasoning steps can be further input into the above-mentioned second largest language model, and the second largest language model can perform further reasoning based on the question and the compressed thinking chain reasoning steps to generate an answer corresponding to the question.

[0159] In the above technical solution, the first large language model used to perform the task of generating thought chain reasoning steps can be a large language model obtained by training based on compressed thought chain samples, wherein the thought chain reasoning steps in the compressed thought chain samples are thought chain reasoning steps after context compression; and the number of model parameters of the first large language model can be less than the number of model parameters of the second large language model used to perform the question-answering task. For the problem to be solved, the problem can be first input into the first large language model, and the first large language model generates the compressed thought chain reasoning steps corresponding to the problem. Then, the problem and the compressed thought chain reasoning steps are input into the second large language model, and the second large language model generates the answer corresponding to the problem based on the compressed thought chain reasoning steps.

[0160] Using the above method, the reasoning process that requires outputting intermediate reasoning steps can be divided into two nodes: thought chain reasoning process generation and answer generation. The first large language model with a smaller number of model parameters performs the thought chain reasoning step generation task, and the second large language model with a larger number of model parameters performs the answer generation task. First, the first large language model can be trained based on compressed thought chain samples in which the thought chain reasoning steps are thought chain reasoning steps after context compression. Therefore, the first large language model can generate relatively short thought chain reasoning steps, thereby reducing the response delay and computational cost of the first large language model; second, because the first large language model has a smaller number of model parameters, the computational cost and response delay of the first large language model are also relatively small; third, the first large language model can be obtained by performing knowledge distillation on the second large language model, thereby ensuring the accuracy of the thought chain reasoning steps generated by the first large language model, thereby ensuring the accuracy of the answers further generated by the second large language model based on the thought chain reasoning steps.

[0161] Please refer to Figure 4 , Figure 4 This is a flowchart of another question answering method based on a large language model shown in an exemplary embodiment of the present application. The question answering method based on a large language model can be applied to Figure 1 The intelligent dialogue system shown.

[0162] like Figure 4 As shown, the above-mentioned question answering method based on the large language model may include the following steps:

[0163] Step 402: Obtain the problem to be solved.

[0164] In this embodiment, the problem to be solved may be obtained first.

[0165] For example, the question text submitted by the user may be obtained, thereby obtaining the question raised by the user using the question text.

[0166] Step 404: Input the question into the first large language model, and use the first large language model to generate a thought chain reasoning step corresponding to the question.

[0167] In this embodiment, when the above question is obtained, the question can be input into the above first language model, and the first language model can perform reasoning based on the question to generate a thought chain reasoning step corresponding to the question.

[0168] For example, the question text submitted by the user can be input into the above-mentioned first language model as a prompt. Under the guidance of the prompt, the first language model performs reasoning based on the question text, thereby generating descriptive text corresponding to the various intermediate reasoning steps included in the reasoning process based on the question text.

[0169] Step 406: Context compression is performed on the thought chain reasoning steps.

[0170] In this embodiment, when the above-mentioned thought chain reasoning steps corresponding to the above-mentioned question are obtained, the thought chain reasoning steps can be context-compressed first to obtain compressed thought chain reasoning steps.

[0171] Step 408: Input the question and the compressed chain of thought reasoning steps into the second largest language model, and the second largest language model generates an answer corresponding to the question based on the compressed chain of thought reasoning steps; wherein the number of model parameters of the first largest language model is less than the number of model parameters of the second largest language model.

[0172] In this embodiment, when the compressed thought chain reasoning steps are obtained, the question and the compressed thought chain reasoning steps can be further input into the second largest language model, and the second largest language model can perform further reasoning based on the question and the compressed thought chain reasoning steps to generate an answer corresponding to the question.

[0173] For example, the question text submitted by the user and the descriptive text generated by the first language model and corresponding to the various intermediate reasoning steps included in the reasoning process based on the question text and subjected to context compression can be spliced ​​together, and the spliced ​​text can be input into the second language model as a new Prompt. Under the guidance of the Prompt, the second language model can further reason based on the question text in the Prompt and the compressed descriptive text corresponding to the intermediate reasoning steps, thereby generating an answer text corresponding to the question text.

[0174] In some embodiments, the question may be about fund allocation, the chain of reasoning may include an analysis of user preferences and fund categories, and the answer may include fund categories and their allocation ratios. Alternatively, the question may be about medical diagnosis, the chain of reasoning may include the process of reasoning from symptoms to disease, and the answer may be the diagnosis result.

[0175] Please refer to Figure 5 , Figure 5 This is a schematic diagram of another question-answering process based on a large language model, shown as an exemplary embodiment of the present application.

[0176] like Figure 5 As shown, in the above-mentioned question-answering process based on the large language model, two different large language models can be used, and these two large language models can be respectively referred to as the first large language model and the second large language model. The number of model parameters of the first large language model can be less than the number of model parameters of the second large language model. The first large language model can be a large language model trained based on thought chain samples (thought chain samples that have not undergone context compression processing).

[0177] In the above situation, you can first get the problem that needs to be solved.

[0178] When the above question is obtained, the question can be input into the above first language model, and the first language model performs reasoning based on the question to generate a thought chain reasoning step corresponding to the question.

[0179] When the above-mentioned thought chain reasoning steps corresponding to the above-mentioned question are obtained, the thought chain reasoning steps may be context-compressed first to obtain compressed thought chain reasoning steps.

[0180] After obtaining the compressed thought chain reasoning steps, the question and the thought chain reasoning steps can be further input into the second language model, and the second language model can perform further reasoning based on the question and the thought chain reasoning steps to generate an answer corresponding to the question.

[0181] In the above technical solution, the number of model parameters of the first language model used to perform the task of generating thought chain reasoning steps can be less than the number of model parameters of the second language model used to perform the question-answering task. For a problem to be solved, the problem can be first input into the first language model, which then generates the thought chain reasoning steps corresponding to the problem. The thought chain reasoning steps are then context-compressed. Finally, the problem and the compressed thought chain reasoning steps are input into the second language model, which then generates the answer corresponding to the problem based on the compressed thought chain reasoning steps.

[0182] Using the above method, the reasoning process that requires outputting intermediate reasoning steps can be divided into two nodes: thought chain reasoning process generation and answer generation. The first large language model with a smaller number of model parameters performs the thought chain reasoning step generation task, and the second large language model with a larger number of model parameters performs the answer generation task. On the one hand, by contextually compressing the thought chain reasoning steps generated by the first large language model, the second large language model can perform reasoning based on the compressed thought chain reasoning steps to generate answers, thereby reducing the computational cost and response delay of the second large language model; on the other hand, since the first large language model has a smaller number of model parameters, the computational cost and response delay of the first large language model are also relatively small; on the third hand, the first large language model can be obtained by performing knowledge distillation on the second large language model, thereby ensuring the accuracy of the thought chain reasoning steps generated by the first large language model, thereby ensuring the accuracy of the answers further generated by the second large language model based on the thought chain reasoning steps.

[0183] Corresponding to the aforementioned method embodiments, the present application also provides device embodiments.

[0184] Please refer to Figure 6 , Figure 6 6 is a structural diagram of a device shown in an exemplary embodiment of the present application. At the hardware level, the device includes a processor 602, an internal bus 604, a network interface 606, a memory 608 and a non-volatile memory 610, and of course may also include other required hardware. One or more embodiments of the present application can be implemented based on software, such as the processor 602 reading the corresponding computer program from the non-volatile memory 610 into the memory 608 and then running it. Of course, in addition to software implementation, one or more embodiments of the present application do not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic module, but can also be hardware or logic devices.

[0185] Please refer to Figure 7 , Figure 7This is a block diagram of a question-answering device based on a large language model, shown as an exemplary embodiment of the present application.

[0186] The above-mentioned question-answering device based on the large language model can be applied to Figure 6 The device shown in the figure is used to implement the technical solution of this application. The device includes:

[0187] Acquisition module 702, acquiring the problem to be solved;

[0188] The first generation module 704 inputs the question into a first large language model, and generates a compressed thought chain reasoning step corresponding to the question by the first large language model; wherein the first large language model is a large language model trained based on a compressed thought chain sample; and the thought chain reasoning step in the compressed thought chain sample is the thought chain reasoning step after context compression;

[0189] The second generation module 706 inputs the question and the compressed thinking chain reasoning steps into the second largest language model, and the second largest language model generates an answer corresponding to the question based on the compressed thinking chain reasoning steps; wherein the number of model parameters of the first largest language model is less than the number of model parameters of the second largest language model.

[0190] In some embodiments, the apparatus further comprises:

[0191] A first sample acquisition module, which acquires a question sample before inputting the question into the first large language model, and acquires the reasoning steps of the thought chain corresponding to the question sample generated by the second large language model;

[0192] A sample generation module performs context compression on the thought chain reasoning steps, and generates a compressed thought chain sample based on the question sample and the compressed thought chain reasoning steps;

[0193] A training module is used to train the first language model based on the compressed thought chain samples.

[0194] In some embodiments, the apparatus further comprises:

[0195] a second sample acquisition module, which acquires, before inputting the question into the first large language model, a compressed thought chain sample for training the second large language model as a teacher model; wherein the thought chain reasoning steps in the compressed thought chain sample are thought chain reasoning steps after context compression;

[0196] a sample updating module, configured to obtain a compressed thought chain inference step corresponding to the question generated by the second large language model based on inference of the question in the compressed thought chain sample, update the compressed thought chain sample based on the generated compressed thought chain inference step, and determine the updated compressed thought chain sample as a distillation sample;

[0197] a distillation module, configured to train the first large language model as a student model based on the distillation sample, so that a distillation loss function corresponding to the first large language model converges.

[0198] In some embodiments, the weight of a sub-loss function corresponding to a word piece as a thought chain anchor point in the distillation loss function is higher than the weight of a sub-loss function corresponding to other word pieces in the distillation loss function.

[0199] In some embodiments, the distillation loss function includes a graph structure consistency loss calculated based on an entity relationship graph corresponding to the compressed thought chain inference step generated by the second large language model and an entity relationship graph corresponding to the compressed thought chain inference step generated by the first large language model; the entity relationship graph includes semantic relationships between entities obtained by performing relationship extraction on the compressed thought chain inference step.

[0200] Please refer to Figure 8 , Figure 8 is another block diagram of a large language model-based question answering device according to an example embodiment of the present application.

[0201] The above large language model-based question answering device can be applied to Figure 6 the device shown in the figure to implement the technical solutions of the present application. The device includes:

[0202] an acquisition module 802 configured to acquire a question to be solved;

[0203] a first generation module 804 configured to input the question into a first large language model and generate a thought chain inference step corresponding to the question by the first large language model;

[0204] a compression module 806 configured to perform context compression on the thought chain inference step;

[0205] a second generation module 808 configured to input the question and the compressed thought chain inference step into a second large language model and generate an answer corresponding to the question by the second large language model based on the compressed thought chain inference step; the number of model parameters of the first large language model is less than the number of model parameters of the second large language model.

[0206] In some embodiments, the device includes:

[0207] a sample obtaining module, before inputting the question into the first large language model, obtaining a thought chain sample used for training the second large language model as a teacher model;

[0208] a sample updating module, obtaining a thought chain inference step corresponding to the question generated by the second large language model based on inference of the question in the thought chain sample, updating the thought chain sample based on the generated thought chain inference step, and determining the updated thought chain sample as a distillation sample;

[0209] a distillation module, training the first large language model as a student model based on the distillation sample, so that a distillation loss function corresponding to the first large language model converges.

[0210] In some embodiments, the weight of a sub-loss function corresponding to a word piece as a thought chain anchor point in the distillation loss function is higher than the weight of a sub-loss function corresponding to other word pieces in the distillation loss function.

[0211] In some embodiments, the distillation loss function includes a graph structure consistency loss calculated based on an entity relationship graph corresponding to the thought chain inference step generated by the second large language model and an entity relationship graph corresponding to the thought chain inference step generated by the first large language model; the entity relationship graph includes semantic relationships between entities obtained based on relationship extraction of the thought chain inference step.

[0212] For the device embodiment, it basically corresponds to the method embodiment, so for the related part, refer to the part of the method embodiment. The device embodiments described above are only illustrative, wherein the modules described as separate components can or can not be physically separated, and the components displayed as modules can or can not be physical modules, i.e., they can be located in one place or distributed on multiple network modules. According to actual needs, some or all of the modules can be selected to achieve the purpose of the technical solution of the present application.

[0213] The system, device, module or unit illustrated in the above embodiments can be specifically implemented by a computer chip or entity, or by a product with certain functions. A typical implementation device is a computer, and the specific form of the computer can be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0214] In a typical configuration, a computer includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0215] The memory can include non-persistent memory and / or volatile memory, such as random access memory (RAM) having a common memory space employable to store the processing unit instructions and data. The memory is an example of computer readable media.

[0216] Computer readable media includes permanent and non-permanent, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), electrically erasable programmable read only memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital versatile disc (DVD), or other optical storage, magnetic cassettes, magnetic disk storage, quantum memory, graphene-based storage media, or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible to computing devices. According to the definition herein, computer readable media does not include transitory media, such as modulated data signals and carrier waves.

[0217] It should be noted that the terms "comprising," "including," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements recited, but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element preceded by "comprises a" does not, without more constraints, foreclose the existence of additional identical elements in the process, method, article, or apparatus that includes the recited element.

[0218] The above description of specific embodiments of the application has been presented for the purpose of illustration. Other embodiments are within the scope of the application. In some instances, acts or steps described in the application can be performed in an order different from that recited in the embodiments, and still achieve the desired result. Additionally, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve the desired results. In certain implementations, multitasking and parallel processing can be advantageous.

[0219] The terminology used by the descriptive herein is intended to be interpreted in only a descriptive sense, and not intended to limit the one or more embodiments. Singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. The term "and / or" means and includes any or all possible combinations of one or more associated listed items.

[0220] The description of the terms "one embodiment", "some embodiments", "example", "specific example" or "implementation" and the like used in the descriptive herein means that the particular feature or characteristic described in connection with the embodiment is included in at least one embodiment of the present application. The illustrative description of these terms does not necessarily refer to the same embodiment. Moreover, the particular features or characteristics described can be combined in any suitable manner in one or more embodiments. In addition, different embodiments and specific features or characteristics in different embodiments can be combined, if not mutually exclusive.

[0221] It should be understood that although the terms first, second, third, etc. can be used in the descriptive herein to describe various information, these information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other. For example, without departing from the scope of the one or more embodiments, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as the first information. Depending on the context, the word "if" as used herein can be interpreted as "when", "when", or "in response to determining".

[0222] The above description is only the preferred embodiment of the one or more embodiments of the present application, and is not intended to limit the one or more embodiments of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the one or more embodiments of the present application should be included in the scope of protection of the one or more embodiments of the present application.

[0223] The user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation portal for user to choose authorization or refusal.

Claims

1. A question-answering method based on a large language model, the method comprising: Get the problems to be solved; Inputting the question into a first large language model, and generating a compressed thought chain reasoning step corresponding to the question by the first large language model; wherein the first large language model is a large language model trained based on a compressed thought chain sample; and the thought chain reasoning step in the compressed thought chain sample is the thought chain reasoning step after context compression; The question and the compressed thinking chain reasoning steps are input into the second largest language model, and the second largest language model generates an answer corresponding to the question based on the compressed thinking chain reasoning steps; wherein the number of model parameters of the first largest language model is less than the number of model parameters of the second largest language model.

2. The method according to claim 1, before inputting the question into the first large language model, the method further comprises: Obtaining a question sample, and obtaining the reasoning steps of the thought chain corresponding to the question sample generated by the second largest language model; Contextually compressing the thought chain reasoning steps, and generating a compressed thought chain sample based on the question sample and the compressed thought chain reasoning steps; The first language model is trained based on the compressed thought chain samples.

3. The method according to claim 1, before inputting the question into the first large language model, the method further comprises: Obtaining a compressed thought chain sample for training the second language model as a teacher model; wherein the thought chain reasoning steps in the compressed thought chain sample are thought chain reasoning steps after context compression; Obtaining a compressed thought chain reasoning step corresponding to the question generated by the second largest language model through reasoning based on the question in the compressed thought chain sample, updating the compressed thought chain sample based on the generated compressed thought chain reasoning step, and determining the updated compressed thought chain sample as a distilled sample; The first large language model as a student model is trained based on the distilled samples so that a distillation loss function corresponding to the first large language model converges.

4. According to the method of claim 3, the weight of the sub-loss function corresponding to the word unit serving as the anchor point of the thought chain in the distillation loss function is higher than the weight of the sub-loss function corresponding to other word units in the distillation loss function.

5. According to the method of claim 3, the distillation loss function includes a graph structure consistency loss calculated based on the entity relationship graph corresponding to the compressed thought chain reasoning step generated by the second largest language model, and the entity relationship graph corresponding to the compressed thought chain reasoning step generated by the first largest language model; the entity relationship graph includes an entity relationship graph generated based on the semantic relationship between entities obtained by relationship extraction of the compressed thought chain reasoning step.

6. A question-answering method based on a large language model, the method comprising: Get the problems to be solved; Inputting the question into a first language model, and generating a thought chain reasoning step corresponding to the question by the first language model; Performing context compression on the reasoning steps of the thought chain; The question and the compressed thought chain reasoning steps are input into the second largest language model, and the second largest language model generates an answer corresponding to the question based on the compressed thought chain reasoning steps; wherein the number of model parameters of the first largest language model is less than the number of model parameters of the second largest language model.

7. The method according to claim 1, before inputting the question into the first large language model, the method comprising: Obtaining a thought chain sample for training the second largest language model serving as a teacher model; Obtaining a thought chain reasoning step corresponding to the question generated by the second largest language model through reasoning based on the question in the thought chain sample, updating the thought chain sample based on the generated thought chain reasoning step, and determining the updated thought chain sample as a distilled sample; The first large language model as a student model is trained based on the distilled samples so that a distillation loss function corresponding to the first large language model converges.

8. According to the method of claim 7, the weight of the sub-loss function corresponding to the word unit serving as the anchor point of the thought chain in the distillation loss function is higher than the weight of the sub-loss function corresponding to other word units in the distillation loss function.

9. According to the method of claim 7, the distillation loss function includes a graph structure consistency loss calculated based on the entity relationship graph corresponding to the thought chain reasoning step generated by the second largest language model, and the entity relationship graph corresponding to the thought chain reasoning step generated by the first largest language model; the entity relationship graph includes an entity relationship graph generated based on the semantic relationship between entities obtained by relationship extraction of the thought chain reasoning step.

10. A question-answering device based on a large language model, comprising: Get the module and get the problem to be solved; A first generation module inputs the question into a first large language model, and generates a compressed thought chain reasoning step corresponding to the question by the first large language model; wherein the first large language model is a large language model trained based on a compressed thought chain sample; and the thought chain reasoning step in the compressed thought chain sample is the thought chain reasoning step after context compression; The second generation module inputs the question and the compressed thinking chain reasoning steps into the second largest language model, and the second largest language model generates an answer corresponding to the question based on the compressed thinking chain reasoning steps; wherein the number of model parameters of the first largest language model is less than the number of model parameters of the second largest language model.

11. A question-answering device based on a large language model, comprising: Get the module and get the problem to be solved; A first generation module inputs the question into a first large language model, and the first large language model generates a thought chain reasoning step corresponding to the question; A compression module, performing context compression on the reasoning steps of the thought chain; The second generation module inputs the question and the compressed thought chain reasoning steps into the second largest language model, and the second largest language model generates an answer corresponding to the question based on the compressed thought chain reasoning steps; wherein the number of model parameters of the first largest language model is less than the number of model parameters of the second largest language model.

12. An electronic device comprising: processor; a memory for storing processor-executable instructions; The processor implements the method according to any one of claims 1 to 9 by running the executable instructions.

13. A computer-readable storage medium having computer instructions stored thereon, wherein when the instructions are executed by a processor, the method according to any one of claims 1 to 9 is implemented.

Citation Information

Cited By

  • Financial research report structured identification method and system based on multi-modal large model

    CN121582957A