Reasoning method and device for domain-specific knowledge learning

By utilizing a collaborative reasoning method between the domain reasoning model and the general model without altering the weights of the general model, the problem of low hit rate of the general model in enterprise tasks is solved, achieving efficient domain knowledge embedding and stable reasoning output.

CN122334460BActive Publication Date: 2026-08-25BEIJING SILICON HEART TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202610241471.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-02-28
Publication Date
2026-08-25
Estimated Expiration
2046-02-28

AI Technical Summary

Technical Problem

General-purpose large language models lack coverage of enterprise-specific knowledge in internal enterprise tasks, resulting in low business hit rate and poor factual accuracy. Existing technologies are prone to alignment drift and catastrophic forgetting when attempting incremental pre-training, and it is difficult to effectively incorporate domain knowledge.

Method used

A collaborative reasoning method combining a domain reasoning model and a general reasoning model is adopted. The domain model is trained based on the hidden layer information of the general model without changing its weights. Domain knowledge is embedded into the reasoning process using a cross-model attention mechanism. The general model is responsible for the final answer, while the domain model provides structured response fragments.

Benefits of technology

It improves the hit rate and availability of enterprise tasks, reduces training costs and validation cycles, maintains the stability and consistency of general models, and avoids alignment drift and forgetting risks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122334460B_ABST
    Figure CN122334460B_ABST
Patent Text Reader

Abstract

The application provides a reasoning method and device for domain knowledge learning, the reasoning method comprising: inputting a word vector sequence into a general reasoning model and a domain reasoning model; the general reasoning model generates a first word according to the word vector sequence; when the first word is a first special word, inputting a plurality of first words and the word vector sequence as first input parameters into the general reasoning model and the domain reasoning model; the domain reasoning model generates a second word according to the first input parameters, a first key vector and a first value vector; when the second word is a second special word, inputting the plurality of first words, the word vector sequence and a plurality of second words as second input parameters into the general reasoning model; the general reasoning model generates a third word according to the second input parameters; and generating answer information according to the plurality of first words, the plurality of second words and the plurality of third words. The application can improve the reasoning hit rate of a target domain and reduce the damage to the existing ability of the general reasoning model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, specifically to a reasoning method and apparatus for domain-specific knowledge learning. Background Technology

[0002] In recent years, large language models (LLMs) based on the Transformer architecture have demonstrated powerful language understanding, instruction following, and multi-task generalization capabilities through pre-training on massive general corpora, and have become a core driving force for enterprise intelligent transformation.

[0003] However, when such general-purpose inference models are directly applied to internal enterprise tasks, their performance often falls short of publicly available benchmark results. The fundamental reason is that general-purpose pre-trained corpora struggle to cover the proprietary knowledge corresponding to enterprise tasks, including but not limited to organizational structure, business processes, technical specifications, historical data, industry terminology, and specific business logic. This lack of proprietary knowledge samples leads to low business hit rates and poor factual accuracy in the output of general-purpose inference models. Summary of the Invention

[0004] In view of this, this application proposes a reasoning method and apparatus for domain-specific knowledge learning to solve the problem in related technologies that the lack of target knowledge domain knowledge leads to low business hit rate and poor factual accuracy of the output of general reasoning models.

[0005] The first aspect of this application proposes a domain-specific knowledge learning reasoning method, which is applied to a reasoning system comprising a general reasoning model and a domain-specific reasoning model; the domain-specific reasoning model is trained based on the intermediate hidden layer vector information of the general reasoning model without changing the weights of the general reasoning model; at least one computational layer in the general reasoning model corresponds to at least one processing layer in the domain-specific reasoning model; the reasoning method includes: In response to receiving question text input from the user, the word vector sequence corresponding to the question text is input into the general inference model and the domain inference model respectively, so that the general inference model generates a first word based on the word vector sequence of the question text; during the process of the general inference model generating the first word, the domain inference model generates a domain hidden state based on the word vector sequence corresponding to the question text and the first key vector and first value vector sent by the general inference model, and does not generate a second word based on the domain hidden state; When the first word element generated by the general inference model is a first special word element, the multiple first word elements already generated by the general inference model and the word element vector sequence corresponding to the question text are input as first input parameters to the general inference model and the domain inference model respectively, so that the domain inference model generates a second word element based on the first input parameters and the first key vector and the first value vector sent by the general inference model; during the process of the domain inference model generating the second word element, the general inference model generates a general hidden state based on the question text, but does not generate a first word element based on the general hidden state; When the second word element generated by the domain reasoning model is a second special word element, the multiple first word elements, the word element vector sequence corresponding to the question text, and the multiple second word elements already generated by the domain reasoning model are input as second input parameters into the general reasoning model, so that the general reasoning model generates a third word element according to the second input parameters; Based on the plurality of first words, the plurality of second words, and the plurality of third words, the answer information for the question text is generated.

[0006] This application provides "inference context memory (KV / hidden state)" through a general inference model, and the domain mini-model learns "how to query on this memory and output domain fragments" through a cross-model attention mechanism. This approach avoids the alignment drift / forgetting risk caused by directly continuing to train the main model, while reducing training / inference overhead through KV caching and reuse. Domain knowledge is learned and output by the domain inference model as an intermediate reference, while the general inference model remains frozen and is responsible for the final answer, thereby improving the hit rate in the target knowledge domain task, while minimizing the disruption to the existing capabilities of the general inference model.

[0007] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description

[0008] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings: Figure 1 This illustration shows a flowchart of a cross-model attention mechanism based on a general inference model and a domain inference model, provided in an embodiment of this application. Figure 2 A flowchart illustrating a domain-specific knowledge learning reasoning method provided in an embodiment of this application is shown. Figure 3 This illustration shows a flowchart of another cross-model attention mechanism based on a general inference model and a domain inference model provided in an embodiment of this application; Figure 4 A schematic diagram illustrating the training process of a domain inference model provided in an embodiment of this application is shown; Figure 5 This illustration shows a schematic diagram of the structure of a domain-enhanced inference system for enterprise scenarios provided in an embodiment of this application; Figure 6 This illustration shows a flowchart of a domain-enhanced reasoning system in an enterprise scenario provided by an embodiment of this application; Figure 7 This illustration shows a schematic diagram of the structure of a domain-specific knowledge learning inference device provided in one embodiment of this application; Figure 8 This illustration shows a schematic diagram of the structure of a computer device according to an embodiment of this application; Figure 9 A schematic diagram of a storage medium provided in one embodiment of this application is shown. Detailed Implementation

[0009] Exemplary embodiments of this application will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of this application are shown in the drawings, it should be understood that this application may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of this application and to fully convey the scope of this application to those skilled in the art.

[0010] It should be noted that, unless otherwise stated, the technical or scientific terms used in this application shall have the ordinary meaning as understood by one of ordinary skill in the art to which this application pertains.

[0011] The technical scenarios involved in the embodiments of this application are described below.

[0012] In enterprise-wide task scenarios, general-purpose large language models often lack a deep understanding of enterprise-specific terminology, process rules, historical knowledge, and data distribution, leading to unstable responses and low business hit rates. Existing technologies typically attempt to "solidify" enterprise knowledge into the weights of general-purpose inference models through incremental pre-training / continued pre-training, SFT / RL, and other post-training methods. However, in engineering practice, this often presents a contradiction of "limited benefits - high costs - significant side effects." The root cause is that general-purpose inference models are prone to alignment drift and catastrophic forgetting when absorbing incremental domain knowledge, thereby damaging the original instruction compliance ability, general reasoning ability, and generalization ability, and causing the model to degrade in non-domain tasks or under complex instructions.

[0013] Therefore, the core technical problem to be solved by this invention can be summarized as follows: 1. How to enable a general inference model to effectively utilize enterprise domain knowledge to complete enterprise tasks without updating / breaking the weights of the general inference model.

[0014] In existing solutions, directly using domain data to train general inference models can easily lead to side effects such as decreased instruction compliance, unstable inference chains, and altered alignment behavior. On the other hand, relying solely on prompt word concatenation or external injection makes it difficult to "integrate domain knowledge into the inference process," resulting in shallow knowledge utilization, dependence on context length, and poor output controllability.

[0015] 2. How to achieve incremental learning and rapid iteration of domain knowledge while "preserving the strong instruction compliance and reasoning ability of the general reasoning model".

[0016] Enterprise knowledge is frequently updated. If each update requires retraining of the general reasoning model, it will not only be costly and time-consuming to verify, but also bring unpredictable risk of capability regression. Therefore, a mechanism is needed to decouple domain capabilities from general reasoning model capabilities, so that domain knowledge can continue to evolve through smaller and easier-to-train modules without affecting the stability of the general reasoning model.

[0017] 3. How to enable domain knowledge to enter the general reasoning model's thinking chain as a "reasoning reference" and ultimately be answered by the general reasoning model, thereby reducing the disturbance of domain modules to the overall behavior of the general reasoning model.

[0018] In existing technologies, if domain modules directly replace the output of the general inference model, it can easily lead to inconsistent styles, misunderstandings of instructions, or breaks in reasoning. If domain modules are only used for concatenating retrieval text, it cannot be guaranteed that their information will be reliably absorbed during the reasoning stage within the general inference model. This invention aims to solve the technical challenge of "how domain information is effectively consumed by the general inference model during reasoning," so that it can provide highly accurate domain conclusions without dominating the final response of the general inference model.

[0019] In view of the above-mentioned shortcomings, the purpose of this invention and the technical effects it can achieve are as follows: To address the above issues, this invention proposes a collaborative reasoning and training method using a "domain reasoning model Query and a general reasoning model KV": During the training phase, a domain reasoning model is constructed and trained based on the hidden states of the general reasoning model, primarily learning incremental knowledge from the enterprise domain; during the reasoning phase, the general reasoning model remains frozen and is responsible for overall reasoning and the final answer. When the general reasoning model reasones to a preset trigger flag (such as `...`),... <domainresponse>When `), the domain reasoning model generates structured domain reasoning / domain response fragments with the support of representation / memory (KV) provided by the general reasoning model. Then, the general reasoning model continues to reason and synthesizes the domain fragments to complete the final output.

[0020] The technical effects that can be achieved as a result include: Avoid compromising the capabilities of the general reasoning model: The general reasoning model is not further trained or minimally modified, which significantly reduces the risk of instruction compliance degradation, alignment drift and catastrophic forgetting, and maximizes the preservation of the original general reasoning and instruction execution capabilities of the general reasoning model.

[0021] Improve domain task hit rate and usability: Domain knowledge is acquired by the domain inference model through weight learning, which can better fit the enterprise data distribution; and it is embedded in the reasoning process of the general inference model in a structured way, so that the general inference model can consume domain information more stably.

[0022] Achieve low-cost iteration of domain knowledge: When updating enterprise knowledge, only the domain inference model or its incremental part needs to be updated / retrained, significantly reducing training costs, validation cycles and regression risks.

[0023] Reduce the perturbation of the domain reasoning model on the final output behavior: The domain reasoning model provides a "reference domain response", and the general reasoning model continues to reason and unifies the final answer style and instruction constraints, thereby improving consistency and controllability at the system level.

[0024] According to an embodiment of this application, a reasoning method for domain-specific knowledge learning is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0025] Example 1: This embodiment provides a domain-specific knowledge learning inference method. This method is applied to an inference system comprising a general inference model and a domain-specific inference model. The domain-specific inference model is trained based on the intermediate hidden layer vector information of the general inference model without changing its weights. At least one computational layer in the general inference model corresponds to at least one processing layer in the domain-specific inference model, such as... Figure 1 As shown: Processing layer 1 - Computation layer 1, Processing layer 2 - Computation layer 2, Processing layer n - Computation layer n.

[0026] Figure 2 This is a flowchart of a domain-specific knowledge learning reasoning method according to an embodiment of this application, such as... Figure 2 As shown, the process includes the following steps: Step S101: In response to receiving the question text input by the user terminal, the word vector sequence corresponding to the question text is input into the general reasoning model and the domain reasoning model respectively, so that the general reasoning model generates the first word based on the word vector sequence of the question text.

[0027] Specifically, during the process of generating the first lexical unit by the general inference model, the domain inference model generates a domain hidden state based on the lexical vector sequence corresponding to the question text and the first key vector and first value vector sent by the general inference model, and does not generate the second lexical unit based on the domain hidden state.

[0028] In some specific embodiments, the question text can be determined based on the application scenario involved on the user's end. For example, when the application scenario is finance, the substantive content of the question text is related to the financial field; as another example, when the application scenario is equipment maintenance, the substantive content of the question text is related to the equipment maintenance field; and as yet another example, when the application scenario is software development, the substantive content of the question text is related to code generation.

[0029] In some specific embodiments, step S101 above includes steps S1011-S1017: Step S1011: Input the word vector sequence corresponding to the question text into multiple computation layers of the general reasoning model and multiple processing layers of the domain reasoning model.

[0030] Step S1012: Generate a first query vector, a first key vector, and a first value vector using any target computing layer (excluding the tail computing layer) based on the word vector sequence corresponding to the question text or the hidden state sent by the previous computing layer; generate a first hidden state based on the first query vector, the first key vector, and the first value vector; send the first hidden state to the next computing layer of the target computing layer; and send the first key vector and the first value vector to the target processing layer corresponding to the target computing layer.

[0031] In this embodiment of the application, when the target computation layer is the first computation layer in the general inference model (e.g. Figure 1 When the target computation layer is "computation layer 1" in the context of the problem text, it can generate the corresponding key vector and value vector based on the word vector sequence of the problem text; when the target computation layer is any computation layer other than the first computation layer in the general inference model (e.g., ... Figure 1 When the target computation layer is any one of "computation layer 2...computation layer n", the target computation layer can generate the corresponding key vector and value vector based on the hidden state output by the previous computation layer. For example, when the target computation layer is computation layer 2, the corresponding key vector and value vector can be generated based on the hidden state output by computation layer 1.

[0032] In this embodiment of the application, the target processing layer corresponding to the target computing layer is, for example... Figure 1 As shown: when the target computation layer is computation layer 1, the target processing layer is processing layer 1; when the target computation layer is computation layer 2, the target processing layer is processing layer 2.

[0033] In this embodiment, the first query vector is used to characterize the query requirement of the word vector sequence corresponding to the question text or the hidden state sent by the previous computing layer in the target knowledge domain; the first key vector is used to characterize the knowledge index identifier of the word vector sequence corresponding to the question text or the hidden state sent by the previous computing layer in the general reasoning model; and the first value vector is used to characterize the knowledge description information of the word vector sequence corresponding to the question text or the hidden state sent by the previous computing layer in the general reasoning model.

[0034] In some specific embodiments, the corresponding key vector K and value vector V can be obtained by projection onto the corresponding learnable weight matrix, as shown in the following formula: K = X * W_k, V = X * W_v Where X represents the sequence of word vectors of the question text or the hidden state output by the previous computational layer, K represents the key vector, W_k represents the first weight matrix corresponding to the key vector, V represents the value vector, and W_v represents the second weight matrix corresponding to the value vector.

[0035] Step S1013: The tail computation layer generates a second query vector, a second key vector, and a second value vector based on the hidden state sent by the previous computation layer; the second key vector and the second value vector are sent to the tail processing layer corresponding to the tail computation layer; a second hidden state is generated according to the second query vector, the second key vector, and the second value vector; and a corresponding first word is generated according to the second hidden state. Step S1014: The target processing layer generates a third query vector based on the word vector sequence corresponding to the question text or the hidden state output by the previous processing layer; generates a third hidden state based on the third query vector, the first key vector, and the first value vector; and sends the third hidden state to the next processing layer of the target processing layer.

[0036] In some specific embodiments, when the target processing layer is the first processing layer in the domain inference model (e.g. Figure 1 When the target processing layer is layer 1 in the domain inference model, it generates a corresponding query vector based on the word vector sequence of the question text; when the target processing layer is any processing layer other than the first processing layer in the domain inference model (e.g., ... Figure 1 When processing layers 2 through n are involved, the target processing layer can generate a corresponding query vector based on the hidden state output by the previous processing layer, such as... Figure 3 As shown, the hidden state can be transformed into the corresponding query vector through linear projection. Figure 3 The small model in this application can be understood as the domain reasoning model in this application.

[0037] In some specific embodiments, the corresponding query vector Q can be obtained by projection onto the corresponding learnable weight matrix, as shown in the following formula: Q=X*W_Q_domain Where X represents the sequence of word vectors of the question text or the hidden state output by the previous processing layer, Q represents the query vector, and W_Q_domain represents the third weight matrix corresponding to the query vector.

[0038] Step S1015: The tail processing layer generates a fourth query vector based on the hidden state sent by the previous processing layer; the fourth hidden state is generated according to the fourth query vector, the second key vector, and the second value vector.

[0039] In the embodiments of this application, during the multi-round iteration process of the general inference model outputting multiple first words ending with the first special word, the tail processing layer in the domain inference model in each round of iteration will output the corresponding hidden state, but will not further output the corresponding word based on the hidden state (because the hidden state can be updated to KVCache to reduce subsequent computation costs).

[0040] The first special term can be understood as the ending term in the terminology sequence generated by the general inference model. Its terminology form is not specifically limited, for example: Domain Response.

[0041] More specifically, the general inference model inserts a token when generating inference content to tell the system: "The general inference part ends here, and the domain inference model takes over." The general inference model generates: [General inference content...] → Domain Response → Stop; upon seeing the Domain Response token, the system automatically switches to the domain inference model to begin generating the second token.

[0042] Step S1016: The first word element, the word vector sequence corresponding to the question text, and the fourth hidden state that have been generated are concatenated to obtain the first context. The first context is then input into the multiple computing layers and the multiple processing layers to generate the next first word element.

[0043] Step S1017: Iteratively execute the steps of concatenating the generated first word element, the word element vector sequence corresponding to the question text, and the generated fourth hidden state to obtain the first context, and inputting the first context into the multiple computing layers and the multiple processing layers to generate the next first word element, until the termination condition is met to obtain multiple first words elements.

[0044] Specifically, the termination condition is that the first word element generated by the general reasoning model is the first special word element. That is to say, when the general reasoning model generates the first special word element, the word element generation of the general reasoning model is stopped, resulting in multiple first word elements with the first special word element as the ending word element.

[0045] Step S102: When the first word element generated by the general reasoning model is the first special word element, the multiple first word elements generated by the general reasoning model and the word element vector sequence corresponding to the question text are input as first input parameters into the general reasoning model and the domain reasoning model respectively, so that the domain reasoning model generates the second word element according to the first input parameters and the first key vector and the first value vector sent by the general reasoning model.

[0046] Specifically, during the process of generating the second lexical unit by the domain inference model, the general inference model generates a general hidden state based on the question text, but does not generate the first lexical unit based on the general hidden state.

[0047] In some specific embodiments, step S102 above includes steps S1021-S1027: Step S1021: Concatenate the multiple first word units and the word unit vector sequence corresponding to the question text to obtain the second context, and input the second context into multiple computing layers of the general reasoning model and multiple processing layers of the domain reasoning model respectively.

[0048] Step S1022: Generate a fifth query vector, a fifth key vector, and a fifth value vector based on the hidden state sent by the second context or the previous computing layer through any target computing layer other than the tail computing layer; generate a fifth hidden state based on the fifth query vector, the fifth key vector, and the fifth value vector; send the fifth hidden state to the next computing layer of the target computing layer; send the fifth key vector and the fifth value vector to the target processing layer corresponding to the target computing layer. Specifically, such as Figure 1 As shown: When the target computation layer is computation layer 1, computation layer 1 will generate a fifth query vector, a fifth key vector, and a fifth value vector based on the second context, and generate a fifth hidden state based on the fifth query vector, the fifth key vector, and the fifth value vector, and send the fifth hidden state to computation layer 2; in addition, computation layer 1 will also send the fifth key vector K and the fifth value vector V to the processing layer 1 corresponding to computation layer 1.

[0049] More specifically, such as Figure 1 As shown: When the target computation layer is any computation layer other than the head computation layer and the tail computation layer, such as computation layer 2, computation layer 2 will generate the corresponding query vector, key vector and value vector based on the fifth hidden state sent by computation layer 1, and generate a new hidden state based on the query vector, key vector and value vector, and send the new hidden state to the next computation layer (such as computation layer 3); in addition, computation layer 2 will also send the key vector K and value vector V generated by itself to the processing layer 2 corresponding to computation layer 2.

[0050] Step S1023: The tail computation layer generates a sixth query vector, a sixth key vector, and a sixth value vector based on the hidden state sent by the previous computation layer; the sixth key vector and the sixth value vector are sent to the tail processing layer corresponding to the tail computation layer; and a sixth hidden state is generated based on the sixth query vector, the sixth key vector, and the sixth value vector.

[0051] Step S1024: The target processing layer generates a seventh query vector based on the second context or the hidden state output by the previous processing layer; generates a seventh hidden state based on the seventh query vector, the fifth key vector, and the fifth value vector; and sends the seventh hidden state to the next processing layer of the target processing layer. Step S1025: The tail processing layer generates an eighth query vector based on the hidden state sent by the previous processing layer; the eighth hidden state is generated according to the eighth query vector, the sixth key vector, and the sixth value vector; the corresponding second word is generated according to the eighth hidden state. Step S1026: The generated second word element, the second context, and the generated sixth hidden state are concatenated to obtain the third context. The third context is then input into the multiple computing layers and the multiple processing layers to generate the next second word element. Step S1027: Iteratively execute the step of concatenating the generated second word, the second context, and the generated sixth hidden state to obtain the third context, and inputting the third context into the multiple computing layers and the multiple processing layers to generate the next second word, until the termination condition is met to obtain multiple second words; the termination condition is that the second word generated by the domain reasoning model is the second special word.

[0052] Step S103: When the second word element generated by the domain reasoning model is a second special word element, the multiple first word elements, the word element vector sequence corresponding to the question text, and the multiple second word elements generated by the domain reasoning model are input into the general reasoning model as second input parameters, so that the general reasoning model generates a third word element according to the second input parameters.

[0053] Specifically, the second special lexical unit can be understood as the ending lexical unit in the lexical unit sequence generated by the domain reasoning model. Its lexical unit form is not specifically limited, for example: End of Domain.

[0054] More specifically, the domain reasoning model inserts a token when generating content to tell the system: "The domain reasoning part ends here, and the general reasoning model takes over." Domain reasoning model generation: [Domain reasoning content...] → End of Domain → Stop; upon seeing the End of Domain token, the system automatically switches to the general reasoning model to continue generating the third terminology.

[0055] In some specific embodiments, step S103 above includes steps S1031-S1033: Step S1031: The multiple first word units, the word unit vector sequence corresponding to the question text, and the multiple second word units generated by the domain reasoning model are concatenated to obtain the fourth context. Step S1032: Generate a third word element based on the fourth context through multiple computational layers of the general reasoning model; Step S1033: Repeat the iterative steps to generate the third word element until one of the following termination conditions is met to obtain multiple third word elements.

[0056] Specifically, the termination conditions include: the generated lexical is a sentence-end marker lexical, the number of generated lexicals reaches a preset threshold, and the length of the generated lexical sequence reaches the maximum input length limit of the general inference model.

[0057] More specifically, the preset threshold and the maximum input length limit of the general inference model can be set according to the actual situation, and no specific restrictions are made here.

[0058] Step S104: Generate answer information for the question text based on the plurality of first word elements, the plurality of second word elements, and the plurality of third word elements.

[0059] In this embodiment of the application, the process of outputting the answer information corresponding to the question text through the inference system mainly includes the following steps: First, the word vector sequence of the question text is input into the general inference model and the domain inference model respectively. The general inference model outputs multiple first words ending with the first special word word through multiple iterations based on the word vector sequence of the question text. In each iteration, the tail processing layer in the domain inference model outputs the corresponding hidden state, but does not further output the corresponding word word based on the hidden state (because the hidden state can be updated to KVCache to reduce subsequent computation costs). Second, a second context is obtained by concatenating multiple hidden states generated by the domain inference model through multiple iterations, the first word element generated by the general inference model through multiple iterations, and the word element vector sequence of the question text. This second context is then input into both the general inference model and the domain inference model. The domain inference model uses the second context and the key and value vectors from each computational layer of the general inference model to perform multiple iterations and output multiple second words ending with the second special word element. During each iteration of generating the second word element, the tail computational layer in the general inference model outputs the corresponding hidden state, but does not further output the corresponding word element based on the hidden state (because the hidden state can be updated to KVCache to reduce subsequent computational costs). Third, the fourth context is obtained by concatenating the multiple first word units output by the general inference model, the multiple second word units output by the domain inference model, and the word unit vector sequence of the question text. The fourth context is then input into the general inference model so that the general inference model iterates through multiple rounds of multiple third word units based on the fourth context. During this process, the domain inference model does not work and does not generate hidden states or word units. Fourth, generate answer information corresponding to the question text based on multiple first-word units, multiple second-word units, and multiple third-word units.

[0060] In some specific embodiments, sending the first key vector and the first value vector to the target processing layer corresponding to the target computation layer includes: The first key vector and the first value vector generated by each computational layer in the general inference model are stored in the key-value cache; If the word vector sequence corresponding to the question text has not changed, then the first key vector and the first value vector corresponding to the target processing layer are read from the key-value cache, and the first key vector and the first value vector are sent to the target processing layer corresponding to the target computing layer in the domain inference model.

[0061] In the embodiments of this application, such as Figure 3 The "Main Model Key Cache" is used to store the first key vector generated by each computation layer. Figure 3 The "Main Model Value Cache" is used to store the first value vector generated by each computation layer.

[0062] In some specific embodiments, the general inference model and the domain inference model are jointly trained, and the training objective function is:

[0063] in, For the loss of the general inference model, For the domain inference model loss, For cross-model alignment loss, and These are the corresponding equilibrium hyperparameters.

[0064] In some specific embodiments, the method further includes a model training step: The parameters of the general inference model are fixed, and the domain inference model is fine-tuned and trained using a domain-specific dataset; wherein the training loss is calculated based on the cross-entropy loss between the response information generated by the general inference model and the standard response information.

[0065] In some specific embodiments, the main model can be understood as a general inference model, and the domain-specific models can be understood as domain-specific inference models. The training method for the domain-specific inference models is as follows: Figure 4 As shown, it includes: Under the condition of freezing the main model, the domain mini-model is made to fit the enterprise domain data distribution and learn how to utilize the key-value / hidden state of the intermediate layer of the main model; Construct a domain training set from internal enterprise knowledge and business data, which includes at least: user questions / instructions (X); domain reference outputs (Y) (which may be standard answers, work order processing conclusions, structured steps, rule clauses, etc.); and optional structured fields (such as SOP number, rule ID, risk level, etc.) to supervise the structured output of domain fragments.

[0066] Add and register a special token in the tokenizer: <think> `、`< / think> `、` <domainresponse> `、`< / domainresponse> `, and stipulates that domain-specific small models are only in` <domainresponse> ...< / domainresponse> ` Token generation within a range; The specific training steps are as follows: S1: Initialize the main model (BigModel), load the general capability weights and freeze all parameters.

[0067] S2: Initialize the domain small model (SmallModel), whose hidden dimension and attention head dimension are aligned with the main model fusion layer (or projected alignment is achieved through (\phi(\cdot))).

[0068] S3: For each training sample, construct the input sequence: `[X] + <think>+ [Optional: Empty or Template] + <domainresponse>` And set the target sequence as: `[Y_domain_structured] +< / domainresponse> (Or supervise together with the output of the subsequent main model, see S6).

[0069] S4: The main model is computed forward to the trigger position, and ({L}) is exported to the specified layer. , (Can be cached in the form of KVCache).

[0070] S5: In each decoding step, the domain-specific small model is calculated via the fusion interface ( It is then injected into the hidden state of the small model to generate a domain fragment token.

[0071] S6 (Optional Joint Supervision): Feed the tokens generated by the domain small model to the main model in a teacher-forcing manner, so that the main model forms a "context after writing back the domain fragment" in the training graph, thereby training the small model to output a structure that is more suitable for the main model to continue reasoning and consumption.

[0072] S7: Calculate the loss function and update the parameters belonging only to the domain-specific small model and the fusion interface: Domain autoregressive cross-entropy loss ( (Predict the next token); Optional structural consistency loss ( (Ensure JSON / field / tag closure); Optional gating regular expression ( )(constraint( (Prevent over-reliance or noise injection).

[0073] Total loss: ( ).

[0074] S8: Iterate training until convergence, obtaining the parameters of the domain mini-model and the fusion interface; the parameters of the main model are never updated. In this embodiment, the main model provides "inference context memory (KV / hidden states)," and the domain mini-model learns "how to query on this memory and output domain fragments." This approach avoids the alignment drift / forgetting risk caused by directly continuing to train the main model, while reducing training / inference overhead through KV cache reuse.

[0075] Example 2: Corresponding to the above implementation methods of domain-specific knowledge learning reasoning, this application embodiment also provides a domain-enhanced reasoning system for enterprise scenarios, including: a main model reasoning module, a fusion interface module, a cache management module, a domain model module, and a structured reasoning triggering module, such as... Figure 5 As shown; BigModel Engine (Main Model Inference Module) Includes the Transformer main model (general knowledge + reasoning ability), with parameters frozen; Receive the input token sequence, perform autoregressive inference, and generate ` <think>`Internal reasoning text, and outputting a special marker when the trigger condition is met` <domainresponse>`.

[0076] Transformer attention is essentially a computational process of "mapping a query to a set of key-value pairs and then to the output".

[0077] Domain Model Module (SmallModel Engine) It contains a small domain model (domain knowledge), and its parameters are trainable; During the training phase, incremental domain knowledge is learned; during the inference phase, a structured domain response token sequence is generated within the trigger interval; and at the end, the result is output.< / domainresponse> `.

[0078] Q-KV Fusion Interface Module Used to provide the cached or hidden K / V (key / value) representation of a specified layer of the main model to the domain sub-model; The domain-specific small model generates a query based on its own hidden state, and performs attention queries on the key / value pairs of the main model to achieve cross-model information injection. This idea is computationally isomorphic to cross-attention in Transformer (where the decoder's query focuses on the encoder's key / value pairs), but in this invention, the "memory source" is replaced by "encoder output" with "key / value pairs / hidden states of a specified layer in the main model".

[0079] Structured reasoning trigger module Responsibilities include: special token management, alternation of generation between the two models, key-value cache management, and consistency maintenance of "domain output being written back to the main model context".

[0080] Key-Value Cache Manager (KV Cache Manager) It is responsible for saving and reusing the main model KV Cache, as well as incremental updates when injecting domain output tokens; the KV caching mechanism is a common inference acceleration and reuse technology in the industry.

[0081] Core integration mechanism (corresponding appendix) Figure 3 (Q-KV fusion principle block diagram) Integrating location and data format Select a set of several layers of the main model. (For example, layer 1, layer 2, or more), derive the key / value pairs of the main model in the current context at these layers:

[0082] Where (T) is the current context length (including user input, tokens generated by the main model, and domain tokens injected subsequently).

[0083] The domain-specific small model generates a query at the corresponding layer (or a sub-layer at the corresponding depth):

[0084] in, The weight matrix is ​​used to generate the query vector Query when the hidden state of this layer in the small model is generated.

[0085] Cross-model attention query (Small Query → Big KV) The fusion interface computes cross-model attention output at each selected layer:

[0086] This form is consistent with Transformer scaled dot product attention (Attention(Q,K,V)).

[0087] Will Inject residuals into the output of the small model layer (gating coefficients optional) :

[0088] in, It can be a linear mapping or a small MLP for dimension alignment / non-linear transformation; It can be a fixed hyperparameter or a trainable scalar / vector gating.

[0089] The key point of this invention is that the query comes from the small model and the key-value pair comes from the main model, thereby realizing "the main model is not trained, the knowledge is learned by the small model and the main model is used to reason about the context".

[0090] In some specific embodiments, the training method for domain-specific small models is as follows: Figure 4 As shown, the specific implementation method can refer to the training method of the domain reasoning model in the above embodiment 1, and will not be described in detail here.

[0091] In some specific embodiments, the reasoning method of this domain-enhanced reasoning system in enterprise scenarios is as follows: Figure 6 As shown: T1: Receive user input (X), construct the input sequence `X + <think>`, input into the main model to begin autoregressive inference.

[0092] T2: The main model generates several inference tokens until an output trigger flag is generated. <domainresponse>The triggering condition can be: Fixed rule trigger (appearance of ` <domainresponse>(i.e., triggered by the classifier / confidence score); or triggered by the classifier / confidence score.

[0093] T3: The orchestration module freezes the main model's "sampled output" but continues to retain the KVCache of the main model's current context.

[0094] T4: Domain Small Model Decoding Startup: In each generation step, obtain the main model ({L}) layer from the fusion interface. The cross-model attention is calculated using "small model Query → main model KV" to generate domain fragment tokens.

[0095] T5: Domain-specific mini-models are continuously generated until an end marker is generated.< / domainresponse> ` or reaches the length threshold.

[0096] T6 (Critical Consistency Write-Back): Write domain fragment tokens back to the main model one by one. The main model does not perform sampling, but only performs forward updates to the KV Cache (teacher-forcing), so that the internal context of the main model contains domain fragments; This step leverages the incremental update feature of the KV cache to avoid recalculating from scratch. ([Hugging Face][3]) T7: The main model continues from `< / domainresponse> `Generate subsequent` <think> `Reasoning token, until`< / think> `.

[0097] T8: The main model outputs the final answer (user-oriented natural language output) based on the complete reasoning context, while the domain-specific small models are not directly responsible for the user's final output.

[0098] To ensure the main model can stably consume domain knowledge, the domain fragments output by the domain mini-models... <domainresponse>The structured format of ` is recommended to use "strongly structured constraints" for the fragment, for example: ```text <domainresponse> { "domain_facts": ["..."], "rules": [{"id":"...", "text":"..."}], "diagnosis": ["..."], "action_plan": [{"step":1,"do":"..."}, {"step":2,"do":"..."}], "risk": {"level":"...", "notes":"..."}, "confidence": } < / domainresponse> ``` In this embodiment, the orchestration module can perform lightweight checks in the T5 / T6 stages, such as bracket closure, field missing completion, and maximum length pruning, to ensure the stability of subsequent inference of the main model.

[0099] This application also provides a specific embodiment for illustration: Enterprise Operations and Maintenance Troubleshooting Assistant (Database Master-Slave Latency Scenario) Scenario and Data: The enterprise possesses a large number of SOP documents, historical work orders, and fault review records. Constructing Domain Training Samples: Input (X): A question from an operations engineer, such as "The latency of the online MySQL master-slave replication for module A suddenly increased. How do I locate the problem?" Objective (Y): Standard positioning steps, key indicator thresholds, common causes and handling actions of internal SOPs, expressed in structured fields (indicators, commands, rollback conditions, risk levels).

[0100] Training: Freeze the main model; the domain mini-model learns to query on the main model's KV / hidden state, outputs structured localization steps (such as checking replication latency, binlog, IO / SQL thread status, network jitter, slow queries, etc.), and provides risk warnings and rollback conditions.

[0101] reasoning: 1. Master Model Generation <think>The problem is determined to belong to the "Operation and Maintenance Fault Localization" domain, and the following output is generated during the reasoning process: <domainresponse>`; 2. Domain-specific small models in ` <domainresponse>The internal output includes structured SOP steps and thresholds, common causes and corresponding actions; 3. The orchestration module writes the domain fragments back to the main model context; 4. The main model continues reasoning, transforming the domain steps into a final response for engineers (with priorities, risk warnings, and the order of executable commands), while maintaining the original instruction style (e.g., requiring "confirm the impact before implementing changes").

[0102] In this embodiment, domain knowledge is learned and output by the small model as an intermediate reference, while the main model remains frozen and is responsible for the final answer, thereby improving the hit rate in enterprise tasks while minimizing disruption to the existing capabilities of the main model.

[0103] This invention introduces a fusion mechanism of "cross-model attention + alignment mapping + gated residual injection" at the domain small model level. Without modifying or with minimal modification to the main model parameters, it directly reuses the knowledge representation (K / V or hidden states) of the main model in multi-layer caching, achieving targeted enhancement of domain generation capabilities. Therefore, on the one hand, it significantly reduces the training cost and deployment risk associated with full-scale fine-tuning, improving iteration efficiency and maintainability; on the other hand, by leveraging joint loss constraints such as format / gating, it makes the domain output more stable and structurally consistent, reducing deviations and illusions, and improving the accuracy and controllability of domain tasks. The overall effect is superior to solutions relying solely on cue engineering or single-model fine-tuning.

[0104] Corresponding to the above implementation methods of domain-specific knowledge learning inference, this application also provides a domain-specific knowledge learning inference device for executing the domain-specific knowledge learning inference method described in the above embodiments. This domain-specific knowledge learning inference device is applied to an inference system comprising a general inference model and a domain-specific inference model; the domain-specific inference model is trained based on the intermediate hidden layer vector information of the general inference model without changing its weights; at least one computational layer in the general inference model corresponds to at least one processing layer in the domain-specific inference model; such as... Figure 7 As shown, the inference device for domain-specific knowledge learning includes: The first lexical generation module is used to respond to receiving question text input from the user terminal, and input the lexical vector sequence corresponding to the question text into the general inference model and the domain inference model respectively, so that the general inference model generates a first lexical based on the lexical vector sequence of the question text; during the process of the general inference model generating the first lexical, the domain inference model generates a domain hidden state based on the lexical vector sequence corresponding to the question text and the first key vector and first value vector sent by the general inference model, and does not generate a second lexical based on the domain hidden state; The second lexical generation module is used to input multiple first lexical units already generated by the general inference model and the lexical vector sequence corresponding to the question text as first input parameters into the general inference model and the domain inference model respectively when the first lexical unit generated by the general inference model is a first special lexical unit. This allows the domain inference model to generate a second lexical unit based on the first input parameters and the first key vector and first value vector sent by the general inference model. During the process of the domain inference model generating the second lexical unit, the general inference model generates a general hidden state based on the question text, but does not generate a first lexical unit based on the general hidden state. The third lexical generation module is used to input the plurality of first lexical elements, the lexical vector sequence corresponding to the question text, and the plurality of second lexical elements already generated by the domain reasoning model as second input parameters into the general reasoning model when the second lexical element generated by the domain reasoning model is a second special lexical element, so that the general reasoning model generates a third lexical element according to the second input parameters. The answer information generation module is used to generate answer information for the question text based on the plurality of first word elements, the plurality of second word elements, and the plurality of third word elements.

[0105] Preferably, the first lexical generation module is further configured to input the lexical vector sequence corresponding to the question text into multiple computational layers of the general inference model and multiple processing layers of the domain inference model; generate a first query vector, a first key vector, and a first value vector through any target computational layer other than the tail computational layer based on the lexical vector sequence corresponding to the question text or the hidden state sent by the previous computational layer; generate a first hidden state based on the first query vector, the first key vector, and the first value vector, and send the first hidden state to the next computational layer of the target computational layer; send the first key vector and the first value vector to the target processing layer corresponding to the target computational layer; generate a second query vector, a second key vector, and a second value vector through the tail computational layer based on the hidden state sent by the previous computational layer; send the second key vector and the second value vector to the tail processing layer corresponding to the tail computational layer; generate a second hidden state based on the second query vector, the second key vector, and the second value vector; generate a corresponding first lexical based on the second hidden state; and generate a first lexical based on the question text through the target processing layer. A third query vector is generated from the corresponding lexical vector sequence or the hidden state output by the previous processing layer; a third hidden state is generated based on the third query vector, the first key vector, and the first value vector; the third hidden state is sent to the next processing layer of the target processing layer; a fourth query vector is generated by the tail processing layer based on the hidden state sent by the previous processing layer; a fourth hidden state is generated based on the fourth query vector, the second key vector, and the second value vector; the generated first lexical, the lexical vector sequence corresponding to the question text, and the generated fourth hidden state are concatenated to obtain a first context; the first context is input again into the multiple computation layers and the multiple processing layers to generate the next first lexical; the steps of concatenating the generated first lexical, the lexical vector sequence corresponding to the question text, and the generated fourth hidden state to obtain a first context, and inputting the first context again into the multiple computation layers and the multiple processing layers to generate the next first lexical are iteratively executed until a termination condition is met to obtain multiple first lexicals; the termination condition is that the first lexical generated by the general inference model is a first special lexical.

[0106] Preferably, the second lexical generation module is further configured to concatenate the plurality of first lexical units and the lexical vector sequence corresponding to the question text to obtain a second context, and input the second context into the plurality of computational layers of the general inference model and the plurality of processing layers of the domain inference model respectively; generate a fifth query vector, a fifth key vector, and a fifth value vector by any target computational layer other than the tail computational layer based on the second context or the hidden state sent by the previous computational layer; generate a fifth hidden state based on the fifth query vector, the fifth key vector, and the fifth value vector, and send the fifth hidden state to the next computational layer of the target computational layer; send the fifth key vector and the fifth value vector to the target processing layer corresponding to the target computational layer; generate a sixth query vector, a sixth key vector, and a sixth value vector by the tail computational layer based on the hidden state sent by the previous computational layer; send the sixth key vector and the sixth value vector to the tail processing layer corresponding to the tail computational layer; generate a sixth hidden state based on the sixth query vector, the sixth key vector, and the sixth value vector; and generate a sixth hidden state by the target processing layer based on the second context or the hidden state sent by the previous computational layer. The following steps are performed: First, a seventh query vector is generated from the hidden state output by the previous or next processing layer. Second, a seventh hidden state is generated based on the seventh query vector, the fifth key vector, and the fifth value vector. Third, the seventh hidden state is sent to the next processing layer of the target processing layer. Fourth, an eighth query vector is generated by the tail processing layer based on the hidden state sent by the previous processing layer. Fifth, an eighth hidden state is generated based on the eighth query vector, the sixth key vector, and the sixth value vector. Sixth, a corresponding second lexical is generated based on the eighth hidden state. Sixth, the generated second lexical, the second context, and the generated sixth hidden state are concatenated to obtain a third context. The third context is then input into the multiple computation layers and the multiple processing layers again to generate the next second lexical. The process iteratively executes the steps of concatenating the generated second lexical, the second context, and the generated sixth hidden state to obtain a third context, and inputting the third context into the multiple computation layers and the multiple processing layers again to generate the next second lexical, until a termination condition is met to obtain multiple second lexicals. The termination condition is that the second lexical generated by the domain inference model is a second special lexical.

[0107] Preferably, the third word generation module is further configured to concatenate the plurality of first words, the word vector sequence corresponding to the question text, and the plurality of second words generated by the domain inference model to obtain a fourth context; generate a third word based on the fourth context through multiple computational layers of the general inference model; and repeat the step of generating the third word until one of the following termination conditions is met to obtain a plurality of third words: the generated word is a sentence-end marker word, the number of generated words reaches a preset threshold, or the length of the generated word sequence reaches the maximum input length limit of the general inference model.

[0108] Preferably, the apparatus further includes: a vector reading module, used to store the first key vector and the first value vector generated by each computational layer in the general inference model in a key-value cache; if the word vector sequence corresponding to the question text has not changed, then read the first key vector and the first value vector corresponding to the target processing layer from the key-value cache, and send the first key vector and the first value vector to the target processing layer corresponding to the target computational layer in the domain inference model.

[0109] The domain-specific knowledge learning inference apparatus and the domain-specific knowledge learning inference method provided in the above embodiments of this application are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by the applications stored therein.

[0110] This application also provides a computer device for performing the above-described domain-specific knowledge learning reasoning method. Please refer to... Figure 8 This illustrates a schematic diagram of a computer device provided by some embodiments of this application. For example... Figure 8 As shown, the computer device 8 includes: a processor 800, a memory 801, a bus 802, and a communication interface 803. The processor 800, the communication interface 803, and the memory 801 are connected via the bus 802. The memory 801 stores a computer program that can run on the processor 800. When the processor 800 runs the computer program, it executes the domain-specific knowledge learning reasoning method provided in the foregoing embodiments of this application.

[0111] The memory 801 may include high-speed random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 803 (which can be wired or wireless), such as the Internet, wide area network, local area network, or metropolitan area network.

[0112] Bus 802 can be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. The memory 801 is used to store programs. After receiving an execution instruction, the processor 800 executes the program. The domain-specific knowledge learning reasoning method disclosed in the foregoing embodiments can be applied to the processor 800, or implemented by the processor 800.

[0113] The processor 800 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 800 or by instructions in software form. The processor 800 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules may reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory 801. Processor 800 reads the information in memory 801 and, in conjunction with its hardware, completes the steps of the above method.

[0114] The computer device provided in this application embodiment and the domain-specific knowledge learning reasoning method provided in this application embodiment are based on the same inventive concept and have the same beneficial effects as the methods they adopt, run or implement.

[0115] This application also provides a computer-readable storage medium corresponding to the domain-specific knowledge learning reasoning method provided in the foregoing embodiments. Please refer to... Figure 9 The computer-readable storage medium shown is an optical disc 30, on which a computer program (i.e., a program product) is stored. When the computer program is run by a processor, it executes the domain-specific knowledge learning reasoning method provided in any of the foregoing embodiments.

[0116] It should be noted that examples of the computer-readable storage medium may also 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 optical and magnetic storage media, which will not be elaborated here.

[0117] The computer-readable storage medium provided in the above embodiments of this application and the domain-specific knowledge learning reasoning method provided in the embodiments of this application are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by the applications stored therein.

[0118] It should be noted that: Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of this application may be practiced without these specific details. In some instances, well-known structures and techniques have not been shown in detail so as not to obscure the understanding of this specification.

[0119] Similarly, it should be understood that, for the sake of brevity and to aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of this application, various features of this application are sometimes grouped together in a single embodiment, figure, or description thereof. However, this disclosure should not be construed as reflecting a schematic diagram in which the claimed application requires more features than expressly recited in each claim. Rather, as reflected in the following claims, inventive aspects lie in fewer than all features of a single foregoing disclosed embodiment. Therefore, the claims following the detailed description are hereby expressly incorporated into that detailed description, wherein each claim itself is a separate embodiment of this application.

[0120] Furthermore, those skilled in the art will understand that although some embodiments described herein include certain features but not others included in other embodiments, combinations of features from different embodiments are intended to be within the scope of this application and form different embodiments. For example, in the following claims, any of the claimed embodiments can be used in any combination.

[0121] The above description is merely a preferred embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.< / domainresponse> < / domainresponse> < / think> < / domainresponse> < / think> < / think> < / think> < / domainresponse>

Claims

1. A reasoning method for domain-specific knowledge learning, characterized in that, The method is applied to an inference system that includes a general inference model and a domain inference model. The domain inference model is trained based on the intermediate hidden layer vector information of the general inference model without changing the weights of the general inference model. At least one computational layer in the general reasoning model corresponds to at least one processing layer in the domain reasoning model; The reasoning method includes: In response to receiving question text input from the user, the word vector sequence corresponding to the question text is input into the general inference model and the domain inference model respectively, so that the general inference model generates a first word based on the word vector sequence of the question text; during the process of the general inference model generating the first word, the domain inference model generates a domain hidden state based on the word vector sequence corresponding to the question text and the first key vector and first value vector sent by the general inference model, and does not generate a second word based on the domain hidden state; When the first word element generated by the general inference model is a first special word element, the multiple first word elements already generated by the general inference model and the word element vector sequence corresponding to the question text are respectively input into the general inference model and the domain inference model as first input parameters, so that the domain inference model generates a second word element based on the first input parameters and the first key vector and the first value vector sent by the general inference model; during the process of the domain inference model generating the second word element, the general inference model generates a general hidden state based on the first input parameters, but does not generate the first word element based on the general hidden state; When the second word element generated by the domain reasoning model is a second special word element, the multiple first word elements, the word element vector sequence corresponding to the question text, and the multiple second word elements already generated by the domain reasoning model are input as second input parameters into the general reasoning model, so that the general reasoning model generates a third word element according to the second input parameters; Based on the plurality of first words, the plurality of second words, and the plurality of third words, the answer information for the question text is generated.

2. The method according to claim 1, characterized in that, The word vector sequence corresponding to the question text is input into the general inference model and the domain inference model, respectively, so that the general inference model generates the first word element based on the word vector sequence of the question text, including: The word vector sequence corresponding to the question text is input into multiple computational layers of the general reasoning model and multiple processing layers of the domain reasoning model, respectively. A first query vector, a first key vector, and a first value vector are generated by any target computing layer (excluding the tail computing layer) based on the word vector sequence corresponding to the question text or the hidden state sent by the previous computing layer; a first hidden state is generated based on the first query vector, the first key vector, and the first value vector; the first hidden state is sent to the next computing layer of the target computing layer; and the first key vector and the first value vector are sent to the target processing layer corresponding to the target computing layer. The tail computation layer generates a second query vector, a second key vector, and a second value vector based on the hidden state sent by the previous computation layer; the second key vector and the second value vector are sent to the tail processing layer corresponding to the tail computation layer; a second hidden state is generated according to the second query vector, the second key vector, and the second value vector; and a corresponding first word element is generated according to the second hidden state. The target processing layer generates a third query vector based on the word vector sequence corresponding to the question text or the hidden state output by the previous processing layer; a third hidden state is generated based on the third query vector, the first key vector, and the first value vector; and the third hidden state is sent to the next processing layer of the target processing layer. The tail processing layer generates a fourth query vector based on the hidden state sent by the previous processing layer; the fourth hidden state is generated based on the fourth query vector, the second key vector, and the second value vector. The first word element, the word vector sequence corresponding to the question text, and the fourth hidden state that have been generated are concatenated to obtain the first context. The first context is then input into the multiple computing layers and the multiple processing layers to generate the next first word element. The process iteratively executes the steps of concatenating the generated first word element, the word element vector sequence corresponding to the question text, and the generated fourth hidden state to obtain a first context, and then inputting the first context back into the multiple computation layers and the multiple processing layers to generate the next first word element, until a termination condition is met to obtain multiple first word elements; the termination condition is that the first word element generated by the general inference model is a first special word element.

3. The method according to claim 2, characterized in that, The multiple first lexical units generated by the general inference model and the lexical vector sequence corresponding to the question text are input as first input parameters into the general inference model and the domain inference model, respectively, so that the domain inference model generates second lexical units based on the first input parameters and the first key vector and first value vector sent by the general inference model, including: The first word units and the word unit vector sequence corresponding to the question text are concatenated to obtain the second context. The second context is then input into multiple computational layers of the general reasoning model and multiple processing layers of the domain reasoning model. A fifth query vector, a fifth key vector, and a fifth value vector are generated by any target computing layer (excluding the tail computing layer) based on the hidden state sent by the second context or the previous computing layer; a fifth hidden state is generated based on the fifth query vector, the fifth key vector, and the fifth value vector, and the fifth hidden state is sent to the next computing layer of the target computing layer; the fifth key vector and the fifth value vector are sent to the target processing layer corresponding to the target computing layer. The tail computation layer generates a sixth query vector, a sixth key vector, and a sixth value vector based on the hidden state sent by the previous computation layer; the sixth key vector and the sixth value vector are sent to the tail processing layer corresponding to the tail computation layer; and a sixth hidden state is generated based on the sixth query vector, the sixth key vector, and the sixth value vector. The target processing layer generates a seventh query vector based on the second context or the hidden state output by the previous processing layer; generates a seventh hidden state based on the seventh query vector, the fifth key vector, and the fifth value vector; and sends the seventh hidden state to the next processing layer of the target processing layer. The tail processing layer generates an eighth query vector based on the hidden state sent by the previous processing layer; the eighth hidden state is generated based on the eighth query vector, the sixth key vector, and the sixth value vector; and the corresponding second word element is generated based on the eighth hidden state. The generated second word element, the second context, and the generated sixth hidden state are concatenated to obtain the third context. The third context is then input into the multiple computation layers and the multiple processing layers to generate the next second word element. The process iteratively executes the steps of concatenating the generated second lexical unit, the second context, and the generated sixth hidden state to obtain the third context, and then inputting the third context back into the multiple computation layers and the multiple processing layers to generate the next second lexical unit, until a termination condition is met to obtain multiple second lexical units; the termination condition is that the second lexical unit generated by the domain reasoning model is a second special lexical unit.

4. The method according to claim 1 or 2, characterized in that, The plurality of first lexical units, the lexical vector sequence corresponding to the question text, and the plurality of second lexical units already generated by the domain inference model are input as second input parameters into the general inference model, so that the general inference model generates a third lexical unit based on the second input parameters, including: The fourth context is obtained by concatenating the plurality of first word elements, the word element vector sequence corresponding to the question text, and the plurality of second word elements generated by the domain reasoning model. The third lexical unit is generated based on the fourth context through multiple computational layers of the general reasoning model; The process of iteratively generating third lexical units is repeated until one of the following termination conditions is met, resulting in multiple third lexical units: the generated lexical unit is a sentence-end marker lexical unit, the number of generated lexical units reaches a preset threshold, or the length of the generated lexical unit sequence reaches the maximum input length limit of the general inference model.

5. The method according to claim 2, characterized in that, Sending the first key vector and the first value vector to the target processing layer corresponding to the target computation layer includes: The first key vector and the first value vector generated by each computational layer in the general inference model are stored in the key-value cache; If the word vector sequence corresponding to the question text has not changed, then the first key vector and the first value vector corresponding to the target processing layer are read from the key-value cache, and the first key vector and the first value vector are sent to the target processing layer corresponding to the target computing layer in the domain inference model.

6. A reasoning device for domain-specific knowledge learning, characterized in that, The device is applied to an inference system that includes a general inference model and a domain inference model; the domain inference model is trained based on the intermediate hidden layer vector information of the general inference model without changing the weights of the general inference model. At least one computational layer in the general reasoning model corresponds to at least one processing layer in the domain reasoning model; The reasoning device for domain-specific knowledge learning includes: The first lexical generation module is used to respond to receiving question text input from the user terminal, and input the lexical vector sequence corresponding to the question text into the general inference model and the domain inference model respectively, so that the general inference model generates a first lexical based on the lexical vector sequence of the question text; during the process of the general inference model generating the first lexical, the domain inference model generates a domain hidden state based on the lexical vector sequence corresponding to the question text and the first key vector and first value vector sent by the general inference model, and does not generate a second lexical based on the domain hidden state; The second lexical generation module is used to input multiple first lexical units already generated by the general inference model and the lexical vector sequence corresponding to the question text as first input parameters into the general inference model and the domain inference model respectively when the first lexical unit generated by the general inference model is a first special lexical unit. This allows the domain inference model to generate a second lexical unit based on the first input parameters and the first key vector and first value vector sent by the general inference model. During the process of the domain inference model generating the second lexical unit, the general inference model generates a general hidden state based on the first input parameters, but does not generate a first lexical unit based on the general hidden state. The third lexical generation module is used to input the plurality of first lexical elements, the lexical vector sequence corresponding to the question text, and the plurality of second lexical elements already generated by the domain reasoning model as second input parameters into the general reasoning model when the second lexical element generated by the domain reasoning model is a second special lexical element, so that the general reasoning model generates a third lexical element according to the second input parameters. The answer information generation module is used to generate answer information for the question text based on the plurality of first word elements, the plurality of second word elements, and the plurality of third word elements.

7. A computer device, characterized in that, include: A memory and a processor are interconnected, the memory stores computer instructions, and the processor executes the reasoning method for domain-specific knowledge learning as described in any one of claims 1 to 5 by executing the computer instructions.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to execute the reasoning method for domain-specific knowledge learning as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Artificial intelligence-based query information processing method and device, equipment and medium

    CN119249000A

  • Inference language model training and inference method and model based on microstack and computer equipment

    CN120430398A