Optimization method and device for reasoning process of large language model

By conducting complex quantitative evaluation of the problem text in the inference process of large language models and dynamically adjusting the number of activations of the decoding layer, the problem of high resource consumption in the inference process of large language models is solved, and the inference efficiency and answer quality are improved.

CN119849626APending Publication Date: 2025-04-18北京中科闻歌科技股份有限公司
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411916870.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-24
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

Large language models have high computational cost and resource consumption in the inference process, especially when generating long text or processing complex tasks, inference efficiency becomes a bottleneck restricting their wide application.

Method used

By receiving the question text input by the user, obtaining its corresponding target feature set, and performing complex metric quantization evaluation based on these features, determining the number of decoding layers to be activated, only the necessary decoding layers are activated for decoding analysis, and obtaining the target reply text.

Benefits of technology

It improves the inference efficiency of large language models, avoids waste of resources, and ensures that the deep semantic and logical relationships of the text can be fully explored when dealing with complex problems and generates high-quality answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119849626A_ABST
    Figure CN119849626A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an optimization method and device for the reasoning process of a large language model, and relates to the technical field of large language models.The method specifically comprises the steps that a question text input by a user is received; obtaining a target feature set corresponding to the question text, and performing complexity quantitative evaluation on the question text based on the target feature set to obtain target complexity corresponding to the question text; features in the target feature set are used for representing the complexity of the question text; determining a target number M of to-be-activated decoding layers based on the target complexity, and activating the target number of decoding layers; wherein M is an integer greater than or equal to 1; and after the M decoding layers are activated, performing decoding analysis on the question text by using the M decoding layers to obtain a target reply text corresponding to the question text. The reasoning efficiency of the large language model can be improved, and meanwhile resource waste is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of large language models, and in particular to an optimization method and device for an inference process of a large language model. Background Art

[0002] In recent years, large language models have made significant progress in the field of natural language processing. With their powerful semantic understanding and generation capabilities, large language models are widely used in various tasks such as machine translation, intelligent dialogue, automatic summarization, and text generation. However, as the scale of large language models continues to expand, the computational cost and resource consumption problems in the reasoning process have gradually emerged. In particular, when it is necessary to generate long texts or process complex tasks, reasoning efficiency has become one of the bottlenecks restricting its widespread application.

[0003] The traditional large language model reasoning process often adopts a unified processing method, without considering the complexity differences of the question text. This may lead to excessive consumption of computing resources when processing simple questions, because simple questions do not require complex processing flows and a large number of decoding layers. For example, for a simple word query question, the model may still start all decoding layers for analysis, resulting in a waste of resources and unnecessary increase in computing overhead and processing time. On the contrary, when faced with complex questions, due to the lack of targeted resource allocation, it may not be possible to fully explore the deep semantics and logical relationships of the text, resulting in the generated answers not being accurate, comprehensive, and in-depth enough to meet the user's demand for high-quality answers.

[0004] Therefore, how to improve the reasoning efficiency and make rational use of resources during the reasoning process of large language models has become an urgent problem to be solved. Summary of the invention

[0005] In view of this, an embodiment of the present application provides a method and device for optimizing the reasoning process of a large language model, which can improve the reasoning efficiency of the large language model while avoiding waste of resources.

[0006] In a first aspect, an embodiment of the present application provides a method for optimizing the reasoning process of a large language model, including:

[0007] Receive question text entered by the user;

[0008] Obtaining a target feature set corresponding to the question text, and performing a complexity quantification evaluation on the question text based on the target feature set to obtain a target complexity corresponding to the question text; the features in the target feature set are used to characterize the complexity of the question text;

[0009] Determining a target number M of decoding layers to be activated based on the target complexity, and activating the target number of decoding layers; wherein M is an integer greater than or equal to 1;

[0010] After the M decoding layers are activated, the question text is decoded and analyzed using the M decoding layers to obtain a target answer text corresponding to the question text.

[0011] As an optional implementation of the embodiment of the present application, obtaining a target feature set corresponding to the question text, and performing a complexity quantification evaluation on the question text based on the target feature set to obtain a target complexity corresponding to the question text includes:

[0012] Performing feature analysis on the question text to obtain the target feature set;

[0013] In combination with the target feature set, a target multi-layer perceptron is used to perform a complexity quantification evaluation on the question text to obtain a target complexity corresponding to the question text.

[0014] As an optional implementation of the embodiment of the present application, before combining the target feature set and performing a complexity quantification evaluation on the question text by a target multi-layer perceptron to obtain a target complexity corresponding to the question text, the method includes:

[0015] Obtain multiple sample feature sets and the sample complexity corresponding to each of the sample feature sets;

[0016] An initial multi-layer perceptron is trained based on the multiple sample feature sets and the sample complexity corresponding to the sample feature sets to obtain the target multi-layer perceptron.

[0017] As an optional implementation of the embodiment of the present application, after the M decoding layers are activated, the question text is decoded and analyzed by using the M decoding layers to obtain a target answer text corresponding to the question text, including:

[0018] After the M decoding layers are activated, the question text is decoded and analyzed by the M decoding layers to obtain the output results corresponding to the M decoding layers respectively; wherein the output of the previous decoding layer and the question text are used as the input of the next decoding layer;

[0019] The M output results are weightedly fused to obtain the target answer text corresponding to the question text.

[0020] As an optional implementation of the embodiment of the present application, the weighted fusion of the M output results to obtain the target answer text corresponding to the question text includes:

[0021] According to the target complexity corresponding to the question text, obtaining a weight coefficient of each decoding layer corresponding to the target complexity;

[0022] Based on the weight coefficient of each decoding layer, the M output results are weightedly fused to obtain the target answer text corresponding to the question text.

[0023] As an optional implementation of the embodiment of the present application, after the M decoding layers are activated, the question text is decoded and analyzed using the M decoding layers to obtain output results corresponding to the M decoding layers respectively, including:

[0024] Through each of the M decoding layers, context encoding is performed on the question text and the output of the previous decoding layer to extract context information;

[0025] Based on the context information, output results corresponding to the M decoding layers are obtained.

[0026] As an optional implementation of the embodiment of the present application, determining the target number M of decoding layers to be activated based on the target complexity includes:

[0027] The target number M of decoding layers to be activated is obtained by performing calculations in combination with the target complexity and a preset mapping function.

[0028] In a second aspect, an embodiment of the present application provides an optimization device for the reasoning process of a large language model, including:

[0029] A receiving unit, used for receiving a question text input by a user;

[0030] An evaluation unit, used to obtain a target feature set corresponding to the question text, and perform a complexity quantification evaluation on the question text based on the target feature set to obtain a target complexity corresponding to the question text; the features in the target feature set are used to characterize the complexity of the question text;

[0031] an activation unit, configured to determine a target number M of decoding layers to be activated based on the target complexity, and activate the target number of decoding layers; wherein M is an integer greater than or equal to 1;

[0032] The acquisition unit is used to decode and analyze the question text using the M decoding layers after the M decoding layers are activated, so as to acquire the target answer text corresponding to the question text.

[0033] As an optional implementation of the embodiment of the present application, the evaluation unit is specifically used to perform feature analysis on the question text to obtain the target feature set; in combination with the target feature set, a complexity quantification evaluation is performed on the question text through a target multi-layer perceptron to obtain a target complexity corresponding to the question text.

[0034] As an optional implementation of the embodiment of the present application, the evaluation unit is also used to obtain multiple sample feature sets and the sample complexity corresponding to each of the sample feature sets; based on the multiple sample feature sets and the sample complexity corresponding to the sample feature sets, an initial multilayer perceptron is trained to obtain the target multilayer perceptron.

[0035] As an optional implementation of the embodiment of the present application, the acquisition unit is specifically used to, after M decoding layers are activated, use the M decoding layers to decode and analyze the question text, and obtain output results corresponding to the M decoding layers respectively; wherein the output of the previous decoding layer and the question text are used as inputs of the next decoding layer; and weighted fusion is performed on the M output results to obtain a target answer text corresponding to the question text.

[0036] As an optional implementation of the embodiment of the present application, the acquisition unit is specifically used to obtain the weight coefficient of each decoding layer corresponding to the target complexity corresponding to the question text; based on the weight coefficient of each decoding layer, the M output results are weightedly fused to obtain the target answer text corresponding to the question text.

[0037] As an optional implementation of an embodiment of the present application, the acquisition unit is specifically used to perform context encoding on the question text and the output of the previous decoding layer through each of the M decoding layers, and extract context information; based on the context information, obtain the output results corresponding to the M decoding layers respectively.

[0038] As an optional implementation of the embodiment of the present application, the evaluation unit is further used to perform calculations in combination with the target complexity and a preset mapping function to obtain the target number M of decoding layers to be activated.

[0039] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a memory and a processor, wherein the memory is used to store a computer program; and the processor is used to enable the electronic device to implement the optimization method for the reasoning process of a large language model described in any of the above embodiments when executing the computer program.

[0040] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a computing device, the computing device implements the optimization method for the reasoning process of a large language model described in any of the above embodiments.

[0041] The optimization method for the reasoning process of a large language model provided in the embodiment of the present application is specifically as follows: receiving a question text input by a user; obtaining a target feature set corresponding to the question text, and performing a complexity quantification evaluation on the question text based on the target feature set to obtain a target complexity corresponding to the question text; the features in the target feature set are used to characterize the complexity of the question text; determining a target number M of decoding layers to be activated based on the target complexity, and activating the target number of decoding layers; wherein M is an integer greater than or equal to 1; after the M decoding layers are activated, the M decoding layers are used to perform decoding analysis on the question text to obtain a target answer text corresponding to the question text. By performing a complexity quantification evaluation on the question text, the present application can determine the number of decoding layers to be activated according to the complexity of the question text. For simple question texts, only a small number of decoding layers need to be activated to complete the processing, avoiding the waste of computing resources caused by using the same number of decoding layers for all questions in the traditional way; for low-complexity question texts, too many computing resources are no longer occupied for in-depth semantic analysis and complex logical processing, so that when the system processes a large number of simple questions, more computing resources can be allocated to other more needed tasks or complex problem processing, thereby improving the overall utilization efficiency of computing resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings required in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0044] Figure 1 One of the step flow charts of the optimization method for the reasoning process of a large language model provided in an embodiment of the present application;

[0045] Figure 2 The second step flow chart of the optimization method for the reasoning process of a large language model provided in the embodiment of the present application;

[0046] Figure 3A schematic diagram of the structure of an optimization device for the reasoning process of a large language model provided in an embodiment of the present application;

[0047] Figure 4 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0048] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.

[0049] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0050] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a concrete way. In addition, in the description of the embodiments of the present application, unless otherwise specified, the meaning of "multiple" refers to two or more.

[0051] It should be noted that, in this article, the term "comprises" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0052] The present application embodiment provides an optimization method for the reasoning process of a large language model, referring to Figure 1 As shown, the optimization method for the reasoning process of the large language model includes the following steps S101-S104:

[0053] S101, receiving a question text input by a user.

[0054] In some embodiments, the user can initiate an input operation through the interactive interface corresponding to the large language model, which can be in the form of a text input box on the web page, a chat window on the mobile terminal, a voice input button corresponding to the voice assistant, etc. For example, on the web version of the intelligent question-and-answer platform, the user enters the content he wants to ask in a designated text box in natural language, such as "recommend a few good science fiction movies" or when using a voice assistant, press the voice button and say a question text such as "how is the weather today", and enter the question text into the designated location through the interactive interface to obtain the question text entered by the user.

[0055] It should be noted that in order to improve the accuracy of understanding user intentions, after obtaining the question text input by the user, the question text can be preprocessed. Specifically, the question text can be cleaned, part-of-speech tagged, and word segmented. The original question text input by the user can be converted into a standardized form that is more convenient for subsequent analysis, processing, and model application, laying the foundation for obtaining accurate and high-quality text processing results.

[0056] Text cleaning removes interfering factors such as special characters, garbled characters, and extra spaces, so that the vocabulary can be presented in a purer form. For example, if garbled characters are not cleaned up, the model may encounter unrecognizable vocabulary units, which will affect the understanding of the entire sentence. Word segmentation (for languages ​​such as Chinese) divides continuous character sequences into meaningful words, which helps the model to accurately grasp each semantic unit. For example, the Chinese sentence "The weather is very good today" is divided into "today", "weather", and "very good", so that the model can more clearly understand the meaning of each word and its combination, thereby improving the accuracy of the overall semantic understanding of the text.

[0057] S102: Obtain a target feature set corresponding to the question text, and perform a complexity quantification evaluation on the question text based on the target feature set to obtain a target complexity corresponding to the question text.

[0058] The features in the target feature set are used to characterize the complexity of the question text.

[0059] In some embodiments, the target feature set corresponding to the question text includes elements that can reflect the complexity of the text. These features can be used to measure the complexity of the question text from multiple dimensions, thereby obtaining the difficulty of the large language model in answering the question text.

[0060] Specifically, the features included in the target feature set may be features corresponding to three factors: text length, context dependency, and task type.

[0061] Among them, text length is an intuitive and important consideration. Generally speaking, longer text often means that it contains more contextual information, and these rich contents need to be sorted, analyzed, and associated when understanding and processing.

[0062] Context dependency mainly focuses on the dependency density between the contexts involved in the task corresponding to the current question text. For example, in a multi-round dialogue scenario, the user and the large language model have multiple rounds of communication, and the subsequent dialogue content is often closely dependent on the previously mentioned topics, opinions, and related background information. Each round of replies must fully consider all the details of the previous communication in order to give a reasonable and coherent response. For another example, when a large language model processes some complex reasoning tasks issued by users, it may need to deduce layer by layer based on multiple conditions and assumptions given in the previous text. A complex dependency network is formed between the contexts. A misunderstanding of any link may lead to errors in the final result. Therefore, the stronger the context dependency, the higher the complexity of the task.

[0063] Different task types have a significant impact on complexity. If it is a simple dialogue task, it may focus on understanding the user's immediate speech and giving a response that conforms to the logic of daily communication. For example, if the user asks "What's the weather like today", the system replies "Today's weather is sunny and the temperature is suitable, which is very suitable for outdoor activities." However, if it is a text generation task, such as requiring the creation of a story with rich plot, rigorous logic and literary talent based on a specific theme, it is necessary to consider multiple aspects such as conceiving the plot, shaping the characters, and organizing the language, and the complexity is significantly increased; and for question answering tasks, especially some highly professional questions that require in-depth knowledge reserves and complex reasoning, such as "In the field of quantum physics, how to explain the entanglement phenomenon of microscopic particles and its application", to accurately answer such questions, it is necessary to have a deep understanding of professional knowledge and make reasonable logical deductions, so the complexity of the task is also high, depending on the different properties and requirements of the generation target.

[0064] Then, the above factors such as text length, context dependency, and task type are quantified and converted into feature forms that can be further analyzed and calculated by computers. For example, the text length feature can be quantified based on the specific number of words in the text, and the context dependency can be quantified by counting the frequency of words or structures that represent logical associations, referential relationships, etc. in the text. For task types, classification coding can be used (such as 0 for dialogue, 1 for text generation, 2 for question answering, etc.) to reflect different types.

[0065] Then, these quantified multi-dimensional features are combined and input into a multi-layer perceptron (MLP). The multi-layer perceptron is a common neural network structure. It can perform nonlinear transformation and combination of input features through multiple layers of neurons, and finally output a complexity score. However, it should be noted that in order for this multi-layer perceptron to accurately predict the complexity of tasks, it is necessary to collect some labeled task difficulty data in advance to train it. That is, these labeled data clearly define the complexity level corresponding to each task (such as simple, medium, complex, etc.). By allowing the multi-layer perceptron to learn the correspondence between features and complexity in these known data, it can be equipped with the ability to predict the complexity of newly input user tasks.

[0066] S103. Determine a target number M of decoding layers to be activated based on the target complexity, and activate the target number of decoding layers.

[0067] Wherein, M is an integer greater than or equal to 1.

[0068] In an embodiment of the present application, when answering a question text with high complexity, more decoding layers need to be activated. Simple questions may only require fewer decoding layers to accurately understand and generate replies. Therefore, it is necessary to decide how many decoding layers need to be activated for subsequent analysis when answering the current question text based on the target complexity. For low-complexity tasks (such as answering short questions), only the first 2-3 layers of decoders can be activated; for high-complexity tasks (such as long text generation or complex reasoning), more decoding layers need to be activated until all decoding layers are activated.

[0069] For example, when the user's question text is a low-complexity question such as "How is the weather today?", only two decoding layers need to be activated for simple semantic understanding and information retrieval. When the user's question text is a highly complex question such as "Under a complex economic situation, how to use a variety of financial tools combined with the development trends of different industries to achieve steady appreciation of assets", more decoding layers need to be activated (for example, 5 or even more), and operations such as gradually disassembling the problem, analyzing related knowledge, and integrating logical relationships through multiple levels are performed to generate high-quality responses that better meet user needs.

[0070] S104: After the M decoding layers are activated, the question text is decoded and analyzed using the M decoding layers to obtain a target answer text corresponding to the question text.

[0071] It should be noted that when all M decoding layers are activated, the question text will enter these decoding layers in turn for processing. Each decoding layer will perform decoding analysis based on the question text.

[0072] It should be noted that when decoding and analyzing the problem text by using the M decoding layers, the i-th (1 < i ≤ M) decoding layer takes the output result of the (i - 1)-th decoding layer as its input, and so on, so as to obtain the output results corresponding to the M decoding layers respectively, enabling the output of each decoding layer to be sequentially passed to the next layer as input, thereby gradually improving the decoding and analysis effect and accuracy of the problem text, ensuring the coherence and progression of the entire decoding process, and further realizing a more accurate and in-depth parsing and processing of the problem text, enhancing the processing ability and adaptability of the system to complex problem texts.

[0073] The optimization method for the inference process of the large language model provided by the embodiments of the present application is specifically as follows: receiving the problem text input by the user; obtaining the target feature set corresponding to the problem text, and performing a complexity quantification evaluation on the problem text based on the target feature set to obtain the target complexity corresponding to the problem text; the features in the target feature set are used to characterize the complexity of the problem text; determining the target number M of decoding layers to be activated based on the target complexity, and activating the decoding layers with the target number; where M is an integer greater than or equal to 1; after M decoding layers are activated, using the M decoding layers to decode and analyze the problem text to obtain the target response text corresponding to the problem text. By performing a complexity quantification evaluation on the problem text, the present application can determine the number of decoding layers to be activated according to the complexity of the problem text. For simple problem texts, only a small number of decoding layers need to be activated to complete the processing, avoiding the waste of computing resources caused by using the same number of decoding layers for all problems in the traditional method; for problem texts with low complexity, excessive computing resources are no longer occupied for in-depth semantic analysis and complex logic processing, so that when the system processes a large number of simple problems, more computing resources can be allocated to other tasks or complex problem processing that are more in need, improving the overall utilization efficiency of computing resources.

[0074] As an extension and refinement of the above embodiments, the embodiments of the present application also provide another optimization method for the inference process of the large language model, and the specific steps include the following S201 to S206:

[0075] S201. Receive the problem text input by the user.

[0076] S202. Perform feature analysis on the problem text to obtain the target feature set.

[0077] Specifically, the target feature set can be obtained by performing feature analysis on the problem text through a deep learning model, or the target feature set can be generated by performing feature analysis by using a natural language toolkit. The embodiments of the present application do not make any limitations on this.

[0078] S203. In combination with the target feature set, a target multi-layer perceptron is used to perform a complexity quantification evaluation on the question text to obtain a target complexity corresponding to the question text.

[0079] In some embodiments, a multilayer perceptron (MLP) is a common neural network structure, which is composed of multiple neurons and includes an input layer, a hidden layer (there may be multiple layers) and an output layer.

[0080] Since the complexity of the question text is determined by the interweaving and joint action of multiple features. These features are not in a simple linear relationship. The multi-layer perceptron can capture this complex feature interaction relationship well through its multi-layer neuron structure and nonlinear activation function, unlike a simple linear model that can only handle simple addition or multiplication relationships. Furthermore, in the embodiment of the present application, a target multi-layer perceptron will be pre-trained to perform a complexity quantification evaluation on the question text to obtain the target complexity corresponding to the question text.

[0081] Specifically, before the execution of S203, the target multilayer perceptron needs to be obtained through training, and the specific implementation steps include the following steps 1 and 2:

[0082] Step 1: Obtain multiple sample feature sets and the sample complexity corresponding to each of the sample feature sets.

[0083] In some embodiments, a large number of sample question texts can be collected from various channels. These sample question texts include a large number of different text lengths, different context dependencies, different task types, and cover a variety of different topics and fields, so as to build a rich and diverse sample library to prepare for subsequent feature extraction and complexity determination.

[0084] Then, sample feature extraction is performed for each sample question text to mine the sample feature set corresponding to each sample question text. The sample feature set includes features corresponding to the three factors of text length, context dependency, and task type corresponding to each sample. After extracting the sample feature set, it is necessary to further determine the sample complexity corresponding to each sample question text. Here, the sample feature set corresponding to each sample can be annotated with sample complexity by manual annotation.

[0085] Specifically, the complexity level classification standard can be pre-set, for example, the complexity level can be divided into three levels: simple, medium, and complex, or a specific numerical range can be used to represent different complexity intervals, etc. Then, the complexity of each sample is manually judged and labeled. Through manual labeling, each sample feature set is matched with the corresponding sample complexity, providing a data basis for subsequent training of the multi-layer perceptron.

[0086] Step 2: training an initial multilayer perceptron based on the multiple sample feature sets and the sample complexity corresponding to the sample feature sets to obtain the target multilayer perceptron.

[0087] Specifically, the multiple sample feature sets obtained above are used as input data, and the corresponding sample complexity is used as the output target data (that is, label data) to construct a data set for training the multi-layer perceptron. For example, if there are 1,000 samples, each of which has a corresponding feature set and complexity annotation, then these 1,000 sets of feature sets are used as input feature vectors, and the corresponding 1,000 complexity annotations are used as target outputs to form a training data set.

[0088] Furthermore, the initial multilayer perceptron is trained using the multiple sample feature sets and the sample complexities corresponding to the sample feature sets, to obtain a target multilayer perceptron that can more accurately predict the complexity based on the input sample feature sets.

[0089] S204 , performing calculations in combination with the target complexity and a preset mapping function to obtain the target number M of decoding layers to be activated, and activating the target number of decoding layers.

[0090] Wherein, M is an integer greater than or equal to 1.

[0091] In an embodiment of the present application, a correspondence between the complexity of the question text and the number of decoding layers can be established through a preset mapping function. Because texts of different complexities require different degrees of processing depth, simple texts may only require fewer decoding layers to understand and generate appropriate replies, while complex texts often require more decoding layers to fully explore semantics, sort out logic, and integrate knowledge, thereby generating high-quality responses. Through the preset mapping function, the system can automatically and reasonably allocate processing resources based on a quantitative assessment of the complexity of the text, that is, determine the number of decoding layers to be activated.

[0092] Assuming that the decoder of the large language model contains L decoding layers, according to the target complexity T, the target number M of decoding layers to be activated is calculated by the following formula:

[0093] M=g(T)

[0094] Wherein, g(T) is the preset mapping function.

[0095] Exemplarily, for low-complexity tasks (such as answering short questions), the preset mapping function can be used to obtain M=2, that is, activating the first two layers of decoders can complete the current reasoning and obtain the answer text corresponding to the question; for high-complexity tasks (such as long text generation or complex reasoning), the preset mapping function can be used to obtain M=6, that is, activating six layers of decoders can complete the current reasoning and obtain the answer text corresponding to the question; it should be noted that since the decoder of the large language model only contains L decoding layers, when determining the target number M of the decoding layers to be activated according to the preset mapping function, the maximum value of M can only be L.

[0096] S205 . After the M decoding layers are activated, context encoding is performed on the question text and the output of the previous decoding layer through each of the M decoding layers to extract context information.

[0097] Specifically, when the question text and the output of the previous decoding layer are context-encoded through each of the M decoding layers, except for the first decoding layer, the input of each decoding layer includes not only the question text but also the output of the previous decoding layer, so that each layer of decoder comprehensively considers two aspects of information when encoding, one is the basic information and initial context of the current question text; the other is the output of the previous layer of decoder. In this way, each layer of decoder can further deeply understand and process the text based on the processing results of the previous layer, and gradually enrich the understanding of the entire task.

[0098] For example, the complexity of the current question text requires the activation of four decoding layers, then corresponding data transmission links will be established between the four decoding layers. The first decoding layer begins to receive the preprocessed question text, and after preliminary processing, passes the result to the second decoding layer. The second decoding layer continues to conduct in-depth analysis based on the output of the first layer, and passes the processing result to the third decoding layer, and so on, until it is processed layer by layer by four decoding layers and finally generates a suitable reply text.

[0099] Therefore, by rationally activating the corresponding number of decoding layers based on the complexity of the text, the system can achieve optimal allocation of resources, avoid problems such as inefficiency and poor response quality caused by excessive processing of simple texts or insufficient processing of complex texts, and effectively improve the entire system's processing capabilities and service quality for texts of different complexities, thus better meeting the diverse needs of users.

[0100] Specifically, assume that the context information of the l-th layer decoder is represented as h l , it can be encoded by the following formula:

[0101] h l =Encoder(X,y l-1 )

[0102] Where Encoder is the encoder, X is the question text; y l-1 is the output of the previous layer, h l is the context representation of the current layer.

[0103] The input information is encoded by the encoder to obtain the context representation of the current layer. This context representation is the result of the semantic understanding and feature extraction of the input text at the decoder of the current layer. It includes key information related to the text used to answer the current question and provides a basis for subsequent decoding to generate output.

[0104] S206. Based on the context information, obtain output results corresponding to the M decoding layers respectively.

[0105] Specifically, the context information is represented as h l , the decoder output y is obtained by the following formula l :

[0106] y l =decoderl l (h l )

[0107] The subscript of decoder is l, which is used to identify the number of the decoding layer.

[0108] S207: Perform weighted fusion on the M output results to obtain the target answer text corresponding to the question text.

[0109] Specifically, after processing the question text using M decoding layers, each decoding layer will output a corresponding result. However, the output results of these different decoding layers have different focuses and importance, and there are also differences in the role they play in ultimately generating high-quality, logically coherent and accurate target response texts. Specifically, the output results of the low-level decoding layers are more about the basic information such as the initial understanding of the text, key entities and themes; the output of the middle-level decoding layer focuses on the deep semantic relationships, logical clues and integrated related knowledge mined; and the output of the high-level decoding layer tends to be the integrated content framework and the initially generated text expression. In order to make full use of the advantages of the output of each layer and avoid the problems of uneven response quality and unclear organization caused by simply listing or randomly combining these results, it is necessary to use weighted fusion to assign appropriate weights according to the value and role of each output result, and organically integrate them together to form a complete and high-quality target response text.

[0110] In the embodiment of the present application, the weighted fusion formula for the M output results is:

[0111]

[0112] Among them, R final is the final output result after weighted fusion, w l is the weight coefficient of the lth layer, reflecting the "importance" of this layer in the current task. The size of the weight coefficient will be dynamically adjusted according to the complexity of the task.

[0113] In the embodiment of the present application, before weighted fusion of the M output results, it is also necessary to obtain the weight coefficient of each decoding layer corresponding to the target complexity corresponding to the question text. Then, based on the weight coefficient of each decoding layer, weighted fusion of the M output results is performed to obtain the target answer text corresponding to the question text.

[0114] In some embodiments, when weighted fusion is performed on the output results of the M decoding layers, it is important to set a suitable weight coefficient for each decoding layer. This is because for question texts of different complexity, the output results of each decoding layer play different roles and contribute different degrees in the process of finally generating the target answer text.

[0115] Specifically, the specific method of obtaining the weight coefficient of each decoding layer corresponding to the target complexity corresponding to the question text may be: first, according to the past experience of processing a large amount of text and the standard for complexity evaluation, the complexity of the question text is divided into different levels, such as simple, medium and complex levels (of course, it can also be divided into more levels more finely).

[0116] Then, for each complexity level, analyze the importance of each decoding layer output in generating replies, and conduct a large number of experiments to verify and optimize the weight coefficient of each layer at each complexity. You can select multiple representative question texts at different complexity levels as samples. For each sample question text, set a different number of decoding layers for processing, get the output results of each layer, and then try different weight coefficient combinations to perform weighted fusion on these output results to generate a reply text. Then, through multiple attempts to summarize and analyze the optimal weight coefficients corresponding to each decoding layer at each complexity, gradually determine the corresponding relationship between the weight coefficient and the target complexity that is more accurate and in line with the actual processing situation of the system.

[0117] This application effectively improves the reasoning efficiency of large language models through dynamic task complexity evaluation and layered decoding mechanism. In tasks with higher complexity, the system can automatically activate more decoding layers to fully tap into the semantic depth; while in simple tasks, it reduces unnecessary calculations, optimizes resource utilization, and significantly improves reasoning speed.

[0118] This application uses a weighted fusion mechanism to adjust the output weight of each layer of decoders according to the complexity of the task, ensuring that the generated results achieve the best balance between semantic quality and computational efficiency. For complex tasks, the system gives priority to the output of high-level decoders to ensure the accuracy and naturalness of the generated results; for low-complexity tasks, it relies more on low-level decoders to improve reasoning efficiency.

[0119] This application uses refined decoding layer activation control to flexibly adjust the participation of each layer of decoders and optimize the allocation of computing resources according to the specific needs of the task. While ensuring the quality of reasoning, it avoids unnecessary computing overhead and improves the adaptability and reasoning efficiency of large language models in multiple scenarios.

[0120] Based on the same inventive concept, as an implementation of the above method, an embodiment of the present application also provides an optimization device for the reasoning process of a large language model. This embodiment corresponds to the aforementioned method embodiment. For ease of reading, this embodiment will no longer repeat the details of the aforementioned method embodiment one by one, but it should be clear that an optimization device for the reasoning process of a large language model in this embodiment can correspond to all the contents of the aforementioned method embodiment.

[0121] The embodiment of the present application provides an optimization device for the reasoning process of a large language model. Figure 3 Schematic diagram of the structure of the optimization device for the reasoning process of the large language model, such as Figure 3 As shown, the optimization device 300 for the reasoning process of a large language model includes:

[0122] The receiving unit 301 is used to receive a question text input by a user;

[0123] An evaluation unit 302 is used to obtain a target feature set corresponding to the question text, and perform a complexity quantification evaluation on the question text based on the target feature set to obtain a target complexity corresponding to the question text; the features in the target feature set are used to characterize the complexity of the question text;

[0124] An activation unit 303, configured to determine a target number M of decoding layers to be activated based on the target complexity, and activate the target number of decoding layers; wherein M is an integer greater than or equal to 1;

[0125] The acquisition unit 304 is used to, after the M decoding layers are activated, use the M decoding layers to perform decoding analysis on the question text to acquire a target answer text corresponding to the question text.

[0126] As an optional implementation of the embodiment of the present application, the evaluation unit 302 is specifically used to perform feature analysis on the question text to obtain the target feature set; in combination with the target feature set, perform complexity quantification evaluation on the question text through a target multi-layer perceptron to obtain the target complexity corresponding to the question text.

[0127] As an optional implementation of the embodiment of the present application, the evaluation unit 302 is also used to obtain multiple sample feature sets and the sample complexity corresponding to each of the sample feature sets; based on the multiple sample feature sets and the sample complexity corresponding to the sample feature sets, an initial multi-layer perceptron is trained to obtain the target multi-layer perceptron.

[0128] As an optional implementation of the embodiment of the present application, the acquisition unit 304 is specifically used to, after M decoding layers are activated, use the M decoding layers to decode and analyze the question text, and obtain output results corresponding to the M decoding layers respectively; wherein the output of the previous decoding layer and the question text are used as inputs of the next decoding layer; and weighted fusion is performed on the M output results to obtain a target answer text corresponding to the question text.

[0129] As an optional implementation of the embodiment of the present application, the acquisition unit 304 is specifically used to obtain the weight coefficient of each decoding layer corresponding to the target complexity corresponding to the question text; based on the weight coefficient of each decoding layer, the M output results are weightedly fused to obtain the target answer text corresponding to the question text.

[0130] As an optional implementation of the embodiment of the present application, the acquisition unit 304 is specifically used to perform context encoding on the question text and the output of the previous decoding layer through each of the M decoding layers, and extract context information; based on the context information, obtain the output results corresponding to the M decoding layers respectively.

[0131] As an optional implementation of the embodiment of the present application, the evaluation unit 302 is further used to perform calculations in combination with the target complexity and a preset mapping function to obtain the target number M of decoding layers to be activated.

[0132] Based on the same inventive concept, an embodiment of the present disclosure also provides an electronic device. Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure, such as Figure 4As shown, the electronic device provided in this embodiment includes: a memory 401 and a processor 402, wherein the memory 401 is used to store a computer program; and the processor 402 is used to execute the audio data processing method provided in the above embodiment when executing the computer program.

[0133] Based on the same inventive concept, an embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the computing device implements the optimization method for the reasoning process of a large language model provided in the above embodiment.

[0134] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media that include computer-usable program code.

[0135] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0136] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0137] Computer readable media include permanent and non-permanent, removable and non-removable storage media. Storage media can be implemented by any method or technology to store information, and the information can be 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 disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0138] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for optimizing the reasoning process of a large language model, characterized in that: include: Receive question text entered by the user; Obtaining a target feature set corresponding to the question text, and performing a complexity quantification evaluation on the question text based on the target feature set to obtain a target complexity corresponding to the question text; the features in the target feature set are used to characterize the complexity of the question text; Determining a target number M of decoding layers to be activated based on the target complexity, and activating the target number of decoding layers; wherein M is an integer greater than or equal to 1; After the M decoding layers are activated, the question text is decoded and analyzed using the M decoding layers to obtain a target answer text corresponding to the question text.

2. The method according to claim 1, characterized in that The step of obtaining a target feature set corresponding to the question text, and performing a complexity quantification evaluation on the question text based on the target feature set to obtain a target complexity corresponding to the question text includes: Performing feature analysis on the question text to obtain the target feature set; In combination with the target feature set, a target multi-layer perceptron is used to perform a complexity quantification evaluation on the question text to obtain a target complexity corresponding to the question text.

3. The method according to claim 2, characterized in that Before combining the target feature set and performing a complexity quantification evaluation on the question text by a target multi-layer perceptron to obtain a target complexity corresponding to the question text, the method includes: Obtain multiple sample feature sets and the sample complexity corresponding to each of the sample feature sets; An initial multi-layer perceptron is trained based on the multiple sample feature sets and the sample complexity corresponding to the sample feature sets to obtain the target multi-layer perceptron.

4. The method according to claim 1, characterized in that After the M decoding layers are activated, the question text is decoded and analyzed by using the M decoding layers to obtain a target answer text corresponding to the question text, including: After the M decoding layers are activated, the question text is decoded and analyzed by the M decoding layers to obtain the output results corresponding to the M decoding layers respectively; wherein the output of the previous decoding layer and the question text are used as the input of the next decoding layer; The M output results are weightedly fused to obtain the target answer text corresponding to the question text.

5. The method according to claim 4, characterized in that The step of performing weighted fusion on the M output results to obtain a target answer text corresponding to the question text includes: According to the target complexity corresponding to the question text, obtaining a weight coefficient of each decoding layer corresponding to the target complexity; Based on the weight coefficient of each decoding layer, the M output results are weightedly fused to obtain the target answer text corresponding to the question text.

6. The method according to claim 4, characterized in that After the M decoding layers are activated, the question text is decoded and analyzed using the M decoding layers to obtain output results corresponding to the M decoding layers, including: Through each of the M decoding layers, context encoding is performed on the question text and the output of the previous decoding layer to extract context information; Based on the context information, output results corresponding to the M decoding layers are obtained.

7. The method according to claim 1, characterized in that The determining a target number M of decoding layers to be activated based on the target complexity includes: The target number M of the decoding layers to be activated is obtained by performing calculations in combination with the target complexity and a preset mapping function.

8. An optimization device for the reasoning process of a large language model, characterized in that: include: A receiving unit, used for receiving a question text input by a user; An evaluation unit, used to obtain a target feature set corresponding to the question text, and perform a complexity quantification evaluation on the question text based on the target feature set to obtain a target complexity corresponding to the question text; the features in the target feature set are used to characterize the complexity of the question text; an activation unit, configured to determine a target number M of decoding layers to be activated based on the target complexity, and activate the target number of decoding layers; wherein M is an integer greater than or equal to 1; The acquisition unit is used to decode and analyze the question text using the M decoding layers after the M decoding layers are activated, so as to acquire the target answer text corresponding to the question text.

9. An electronic device, characterized in that: include: A memory and a processor, wherein the memory is used to store a computer program; and the processor is used to enable the electronic device to implement the optimization method for the reasoning process of a large language model as described in any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a computing device, the computing device implements the optimization method for the reasoning process of a large language model as described in any one of claims 1 to 7.

Citation Information

Cited By

  • Method and system for enhancing logical reasoning ability of large language model

    CN120806171A