Model construction and application method, device and equipment fusing target field knowledge

By introducing a domain classifier and a preset domain adaptive module into the large language model, and judging the weight parameter calls based on the classification results of the target domain, a model that integrates the knowledge of the target domain is constructed. This solves the problem of the damage to the performance of other domains caused by fine-tuning in a specific domain, and achieves a balance of performance across multiple domains.

CN117875358BActive Publication Date: 2026-07-03ATHENAEYES CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ATHENAEYES CO LTD
Filing Date
2023-12-04
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

Existing technologies, when fine-tuning large language models for specific domains, can impair their processing performance in other domains, leading to performance imbalances.

Method used

By introducing a domain classifier and a preset domain adaptation module into a pre-trained large language model, the target domain classification results are used to determine whether to call learnable weight parameters. The converter module is optimized to build a model that integrates target domain knowledge, ensuring performance in a specific domain while reducing the impact on performance in other domains.

Benefits of technology

It achieves high performance in a specific domain while minimizing the impact on performance in other domains, thus improving the overall performance of the model in multi-domain applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117875358B_ABST
    Figure CN117875358B_ABST
Patent Text Reader

Abstract

This application discloses a model construction and application method, apparatus, and device that integrates target domain knowledge, relating to the field of deep learning. The model integrates target domain knowledge and includes a domain classifier, several consecutive first converter modules, and several consecutive second converter modules. The first converter modules are the original converter modules in a pre-trained large language model, and the second converter modules are modules obtained by structurally optimizing the original converter modules using a domain adaptation module. The domain classifier classifies the input vector determined by the first converter modules to obtain a classification result. The domain adaptation module in the second converter module determines whether to call learnable weight parameters based on whether the classification result belongs to the target domain, and determines the output result based on the determination result and the weight parameters of the pre-trained large language model. This application determines whether to call learnable weight parameters based on the classification result, mitigating the performance degradation of the model when processing data from other domains.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of deep learning, and in particular to a method, apparatus, and device for constructing and applying a model that integrates knowledge from a target domain. Background Technology

[0002] To enable the practical application of large language models in real-world projects, fine-tuning is often necessary using domain-specific data. For instance, training a large language model with medical data can improve its performance in that field, but it can negatively impact its performance in other domains (such as poetry writing or coding), thus impairing its performance in those areas. Therefore, how to ensure the performance of a large language model in its specific domain without affecting its performance in other domains remains a challenge. Summary of the Invention

[0003] In view of this, the purpose of this invention is to provide a method, apparatus, and device for constructing and applying a model that integrates knowledge of the target domain, capable of determining whether to call learnable weight parameters based on classification results, thereby mitigating the impairment of the model's processing performance on data from other domains. The specific solution is as follows:

[0004] Firstly, this application provides a method for constructing and applying a model that integrates target domain knowledge. The model integrating target domain knowledge is a model built based on a pre-trained large language model. The model includes a domain classifier, several consecutive first converter modules, and several consecutive second converter modules. The first converter modules are the original converter modules in the pre-trained large language model, and the second converter modules are modules obtained by structurally optimizing the original converter modules in the pre-trained large language model using a preset domain adaptive module. The method includes:

[0005] The system acquires query data and processes the query data based on the plurality of consecutive first converter modules to obtain an input vector.

[0006] The input vector is classified based on the domain classifier to obtain the target domain classification result;

[0007] The preset domain adaptive module in the second converter module determines whether to call the learnable weight parameters based on the target domain classification result, and determines the module output result of the preset domain adaptive module corresponding to the input vector based on the judgment result and the weight parameters of the pre-trained large language model; wherein, if the target domain classification result indicates that the domain corresponding to the input vector is a preset target domain, it is determined that the learnable weight parameters need to be called in the process of determining the module output result;

[0008] Based on the output of the module, the model output corresponding to the input vector is determined to obtain the response result corresponding to the question data.

[0009] Optionally, obtaining the query data includes:

[0010] The question data is acquired, and the question data is extracted using embedding technology to obtain the corresponding question vector.

[0011] Optionally, classifying the input vector based on the domain classifier to obtain the target domain classification result includes:

[0012] The input vector is classified based on the domain classifier to obtain the corresponding classification probability;

[0013] Determine whether the classification probability is greater than a preset classification threshold;

[0014] If it is greater than, then the domain corresponding to the input vector is determined to be the preset target domain, so as to obtain the corresponding target domain classification result;

[0015] If the value is less than or equal to the target value, the domain corresponding to the input vector is determined to be a preset non-target domain, so as to obtain the corresponding target domain classification result.

[0016] Optionally, the step of using the preset domain adaptive module in the second converter module to determine whether to call learnable weight parameters based on the target domain classification result, and determining the module output of the preset domain adaptive module corresponding to the input vector based on the determination result and the weight parameters of the pre-trained large language model, includes:

[0017] If the target domain classification result indicates that the domain corresponding to the input vector is the preset target domain, then the learnable weight parameters are called, and the input vector is weighted by the preset domain adaptive module in the second converter module using the learnable weight parameters and the weight parameters of the pre-trained large language model to obtain the corresponding module output result of the preset domain adaptive module.

[0018] Optionally, the step of using the preset domain adaptive module in the second converter module to determine whether to call learnable weight parameters based on the target domain classification result, and determining the module output of the preset domain adaptive module corresponding to the input vector based on the determination result and the weight parameters of the pre-trained large language model, includes:

[0019] If the target domain classification result indicates that the domain corresponding to the input vector is a preset non-target domain, then the call to the learnable weight parameters is prohibited, and the input vector is weighted by the preset domain adaptive module in the second converter module using the weight parameters of the pre-trained large language model to obtain the corresponding module output result of the preset domain adaptive module.

[0020] Optionally, before obtaining the query data, the process further includes:

[0021] A training set is constructed based on the data in the preset target domain;

[0022] The model that integrates target domain knowledge is trained using the training set and based on a pre-built target loss function, and the learnable weight parameters determined based on the training set are adjusted to obtain a trained model that integrates target domain knowledge.

[0023] Optionally, before training the model that integrates target domain knowledge using the training set and based on a pre-built target loss function, the method further includes:

[0024] The target loss function is constructed based on the loss function of the pre-trained large language model and the cross-entropy loss function corresponding to the domain classifier.

[0025] Secondly, this application provides a model construction and application apparatus for fusing target domain knowledge. The model fusing target domain knowledge is a model constructed based on a pre-trained large language model. The model fusing target domain knowledge includes a domain classifier, several consecutive first converter modules, and several consecutive second converter modules. The first converter modules are the original converter modules in the pre-trained large language model, and the second converter modules are modules obtained by structurally optimizing the original converter modules in the pre-trained large language model using a preset domain adaptive module. The apparatus includes:

[0026] A data processing module is used to acquire query data and process the query data based on the plurality of consecutive first converter modules to obtain an input vector;

[0027] The vector classification module is used to classify the input vector based on the domain classifier to obtain the target domain classification result;

[0028] The first result determination module is used to determine whether to call the learnable weight parameters based on the target domain classification result using the preset domain adaptive module in the second converter module, and to determine the module output result of the preset domain adaptive module corresponding to the input vector based on the determination result and the weight parameters of the pre-trained large language model; wherein, if the target domain classification result indicates that the domain corresponding to the input vector is a preset target domain, it is determined that the learnable weight parameters need to be called in the process of determining the module response result;

[0029] The second result determination module is used to determine the model output result corresponding to the input vector based on the output result of the module, so as to obtain the response result corresponding to the question data.

[0030] Optionally, the vector classification module includes:

[0031] A classification probability determination unit is used to classify the input vector based on the domain classifier to obtain the corresponding classification probability;

[0032] A classification probability determination unit is used to determine whether the classification probability is greater than a preset classification threshold; if it is greater, the domain corresponding to the input vector is determined to be the preset target domain, so as to obtain the corresponding target domain classification result; if it is less than or equal to, the domain corresponding to the input vector is determined to be a preset non-target domain, so as to obtain the corresponding target domain classification result.

[0033] Thirdly, this application provides an electronic device, comprising:

[0034] Memory, used to store computer programs;

[0035] A processor is used to execute the computer program to implement the aforementioned model construction and application method for integrating target domain knowledge.

[0036] Fourthly, this application provides a computer-readable storage medium for storing a computer program, which, when executed by a processor, implements the aforementioned model construction and application method for integrating target domain knowledge.

[0037] In this application, the model integrating target domain knowledge is a model constructed based on a pre-trained large language model. This model includes a domain classifier, several consecutive first converter modules, and several consecutive second converter modules. The first converter modules are the original converter modules in the pre-trained large language model, and the second converter modules are modules obtained by structurally optimizing the original converter modules in the pre-trained large language model using a preset domain adaptive module. Specifically, question data is acquired and processed based on the several consecutive first converter modules to obtain an input vector; the input vector is then processed based on the domain classifier. The first converter module classifies input vectors based on several consecutive first converter modules, and determines whether to call learnable weight parameters based on the target domain classification result. Then, based on the judgment result and the weight parameters of the pre-trained large language model, it determines the module output of the preset domain adaptive module corresponding to the input vector. If the target domain classification result indicates that the domain corresponding to the input vector is a preset target domain, then it is determined that the learnable weight parameters need to be called during the determination of the module output. Based on the module output, the model output corresponding to the input vector is determined to obtain the response result corresponding to the question data. Therefore, this application adds a domain classifier to classify input vectors determined by several consecutive first converter modules, and determines whether the domain to which the input vector belongs is a preset target domain based on the target domain classification result. This determines whether the preset domain adaptive module in the second converter module needs to call learnable weight parameters. If it belongs to the preset target domain, the module output corresponding to the input vector is determined based on the learnable weight parameters and the weight parameters of the pre-trained large language model. If it does not belong to the preset target domain, the module output corresponding to the input vector is directly determined based on the weight parameters of the pre-trained large language model. In this way, by determining whether to call learnable weight parameters based on the target domain classification results, this application can not only ensure the processing performance of the model that integrates target domain knowledge on data from specific domains, but also mitigate the damage to the processing performance of the model that integrates target domain knowledge on data from other domains. Attached Figure Description

[0038] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0039] Figure 1This application discloses a flowchart of a model construction and application method that integrates target domain knowledge.

[0040] Figure 2 This is a schematic diagram of a converter module structure disclosed in this application;

[0041] Figure 3 This is a schematic diagram of a domain adaptive module structure disclosed in this application;

[0042] Figure 4 This is a schematic diagram of a model structure that integrates target domain knowledge as disclosed in this application;

[0043] Figure 5 This is a schematic diagram of a model construction and application device that integrates target domain knowledge, as disclosed in this application.

[0044] Figure 6 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation

[0045] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0046] To enable the practical application of large language models in real-world projects, fine-tuning of these models on specific domain data is often necessary. However, this can negatively impact performance in other domains. Therefore, ensuring the performance of large language models in specific domains without compromising their performance in other domains remains a challenge. To address this, this application provides a method for constructing and applying models that integrate target domain knowledge. This method can determine whether to invoke learnable weight parameters based on classification results, mitigating the performance degradation caused by the model's inability to process data from other domains.

[0047] See Figure 1 As shown, this invention discloses a method for constructing and applying a model that integrates target domain knowledge. The model integrating target domain knowledge is a model built based on a pre-trained large language model. The model includes a domain classifier, several consecutive first converter modules, and several consecutive second converter modules. The first converter modules are the original converter modules in the pre-trained large language model, and the second converter modules are modules obtained by structurally optimizing the original converter modules in the pre-trained large language model using a preset domain adaptive module. The method includes:

[0048] Step S11: Obtain the question data and process the question data based on the several consecutive first converter modules to obtain the input vector.

[0049] In this embodiment, a domain classifier is added to the pre-trained large language model, and the last 8 layers of the 12 consecutive first converter module in the pre-trained large language model are replaced with the second converter module to obtain a model that integrates target domain knowledge; wherein, as shown... Figure 2 As shown, the first converter module is the original converter module (Transformer Block) in the pre-trained large language model, meaning its structure is the original transformer structure. The second converter module is obtained by optimizing the original converter module in the pre-trained large language model using a pre-defined domain adaptation block (DAB). The second converter module can also be described as a domain adaptation transformer block (DATB). It should be noted that the original converter module receives the input vector, i.e., the input embedding, as input, while the second converter module receives the input embedding and the domain classification result determined by the domain classifier as input. Figure 3 As shown, the Pre-trained Domain Adaptation Module (DAB) consists of pre-trained weights and a Domain Adaptation Module (DAM), taking the input vector x and the target domain classification result C determined based on the domain classifier as input. The pre-trained weights are the weight parameters W of the pre-trained large language model, and these weight parameters remain fixed when fine-tuning the model incorporating target domain knowledge to ensure that the model's output is not affected in non-domain-specific scenarios. The DAM is a newly added learnable module used to adapt to domain-specific knowledge. The DAM mainly consists of two added model weights, including the learnable weight parameter W determined based on domain-specific data. a1 and W a2 Specifically, if the target domain classification result C determined based on the domain classifier belongs to R... 1 This indicates that the domain corresponding to the input vector x belongs to the target domain, and the learnable weight parameter W is enabled. a1 and W a2 Therefore, based on the learnable weight parameters and the weight parameters W of the pre-trained large language model, the output result h of the domain adaptive module corresponding to the input vector x is determined; if the target domain classification result C determined based on the domain classifier does not belong to R... 1If the domain corresponding to the input vector x is not the target domain, then the learnable weight parameters are disabled. In other words, the output h of the domain adaptation module corresponding to the input vector x can be determined based only on the weight parameters W of the pre-trained large language model.

[0050] In this embodiment, question data is acquired and extracted using embedding technology to obtain the corresponding question vector. The question vector is processed by the first converter module of the first layer to obtain the first layer output result; the first layer output result is then used as the input of the first converter module of the second layer, and the first layer output result is further processed to obtain the second layer output result, and so on, until the output result of the first converter module of the fourth layer is obtained, and the output result of the first converter module of the fourth layer is used as the input vector.

[0051] Step S12: Classify the input vector based on the domain classifier to obtain the target domain classification result.

[0052] In this embodiment, a domain classifier is used to classify the input vector to obtain the corresponding classification probability. The classification probability is then determined to be greater than a preset classification threshold. If the classification probability is greater than the preset threshold, the domain corresponding to the input vector is determined to be a preset target domain, thus obtaining the corresponding target domain classification result. If the classification probability is less than or equal to the preset threshold, the domain corresponding to the input vector is determined to be a preset non-target domain, thus obtaining the corresponding target domain classification result. It should be noted that 1 indicates that the domain corresponding to the input vector is a preset target domain, and 0 indicates that the domain corresponding to the input vector is a preset non-target domain.

[0053] Step S13: The preset domain adaptive module in the second converter module determines whether to call the learnable weight parameters based on the target domain classification result, and determines the module output result of the preset domain adaptive module corresponding to the input vector based on the judgment result and the weight parameters of the pre-trained large language model; wherein, if the target domain classification result indicates that the domain corresponding to the input vector is a preset target domain, it is determined that the learnable weight parameters need to be called in the process of determining the module output result.

[0054] In this embodiment, after obtaining the input vector determined by the first four consecutive layers of the first converter module and the target domain classification result C determined by the domain classifier, the input vector needs to be further processed by the second eight consecutive layers of the second converter module based on the target domain classification result to obtain the final output of the model that integrates target domain knowledge and corresponds to the question data. For the preset domain adaptive module in each layer of the second converter module, it is necessary to determine whether to call the learnable weight parameter W based on the target domain classification result C.a1 and W a2 Based on the judgment results and the weight parameters W of the pre-trained large language model, pretrained Determine the module output of the predefined domain adaptive module corresponding to the input vector X of this layer; the relevant formulas are as follows:

[0055] h = W pretrained X+W a1 W a2 X⊙C;

[0056] Where ⊙ represents the dot product; h represents the output of the preset domain adaptive module; C is the target domain classification result determined by the domain classifier, and C is 1 or 0; 1 indicates that the domain corresponding to the input vector is the preset target domain; 0 indicates that the domain corresponding to the input vector is the preset non-target domain.

[0057] In this embodiment, if the target domain classification result represents the domain corresponding to the input vector as a preset target domain, then the learnable weight parameters need to be called, and the preset domain adaptive module in the second converter module uses the learnable weight parameters and the weight parameters of the pre-trained large language model to perform a weighted operation on the input vector to obtain the corresponding preset domain adaptive module output result. That is, at this time C=1, then the above formula can be transformed into:

[0058] h = W pretrained X+W a1 W a2 X.

[0059] In this embodiment, if the target domain classification result represents the domain corresponding to the input vector as a preset non-target domain, then it is not necessary to call the learnable weight parameters. Instead, the input vector is weighted using the weight parameters of the pre-trained large language model through the preset domain adaptation module in the second converter module to obtain the corresponding module output of the preset domain adaptation module. It should be noted that since only the weight parameters of the pre-trained large language model are used at this time, the final model output of the model incorporating target domain knowledge is consistent with the model output determined by the pre-trained large language model. Furthermore, C equals 0 at this time, and the above formula can be transformed into:

[0060] h = W pretrainned X.

[0061] Step S14: Determine the model output result corresponding to the input vector based on the module output result, so as to obtain the response result corresponding to the question data.

[0062] In this embodiment, the output result of the second converter module can be determined based on the output result of the preset domain adaptive module in the second converter module. After processing by the next eight consecutive layers of the second converter module, the model output result corresponding to the input vector can be determined based on the output result of the second converter module, thereby obtaining the answer result corresponding to the question data.

[0063] In this embodiment, training the model that integrates target domain knowledge requires first constructing a training set based on data from a preset target domain. Then, two learnable weight parameters are determined based on the training set, and a target loss function is constructed based on the loss function of a pre-trained large language model and the cross-entropy loss function corresponding to the domain classifier. The model integrating target domain knowledge is then trained using the training set and the target loss function to adjust the two learnable weight parameters, resulting in a well-trained model integrating target domain knowledge.

[0064] Therefore, this application adds a domain classifier to classify the input vector determined by several consecutive first converter modules. Based on the target domain classification result, it determines whether the input vector belongs to a preset target domain, thereby determining whether the preset domain adaptive module in the second converter module needs to call learnable weight parameters. If it belongs to the preset target domain, the module output corresponding to the input vector is determined based on the learnable weight parameters and the weight parameters of the pre-trained large language model. If it does not belong to the preset target domain, the module output corresponding to the input vector is directly determined based on the weight parameters of the pre-trained large language model. In this way, by determining whether to call learnable weight parameters based on the target domain classification result, this application can ensure the processing performance of the model incorporating target domain knowledge on data from specific domains, and also mitigate the performance degradation of the model incorporating target domain knowledge on data from other domains.

[0065] See Figure 4 As shown, this embodiment of the invention discloses a method for constructing and applying a model that integrates knowledge of a target domain, including:

[0066] By adding a domain classifier to the pre-trained large language model and replacing the last 8 layers of the 12 consecutive original transformer blocks in the pre-trained large language model with domain adaptive transformer blocks (DATB), a model that integrates target domain knowledge is obtained; that is, the first to fourth layers are original transformer blocks, and the fifth to twelfth layers are domain adaptive transformer blocks.

[0067] The system acquires the question data "What should I do about a cold?" and extracts the corresponding input embedding using embedding technology. Then, it processes the input embedding using the original converter modules (layers 1-4) of the model, which integrates target domain knowledge, to obtain the input vector. The input vector is then classified using a domain classifier to obtain the target domain classification result, which is sent to the domain adaptive converter modules (layers 5-12). Finally, the last eight consecutive domain adaptive converter modules further process the input vector based on the target domain classification result to obtain the final output of the model, which corresponds to the question data.

[0068] For each domain adaptive converter module in each layer, it is necessary to determine whether to call the learnable weight parameters based on the target domain classification result. If the target domain classification result indicates that the domain corresponding to the input vector is the preset target domain, i.e., C=1, then the learnable weight parameters need to be called, and the input vector is weighted using the learnable weight parameters and the weight parameters of the pre-trained large language model to obtain the module output of the corresponding domain adaptive converter. If the target domain classification result indicates that the domain corresponding to the input vector is a preset non-target domain, i.e., C=0, then the learnable weight parameters do not need to be called, and the input vector is weighted using the weight parameters of the pre-trained large language model to obtain the module output of the corresponding domain adaptive converter. Finally, based on the output of the last layer, i.e., the twelfth layer domain adaptive converter module, the model output corresponding to the input vector is determined, thus obtaining the response result corresponding to the question data.

[0069] Therefore, this application adds a domain classifier to classify the input vector determined by the first four consecutive layers of the original converter module. Based on the target domain classification result, it determines whether the input vector belongs to a preset target domain, thus determining whether the domain adaptation module in the domain adaptation converter module needs to call learnable weight parameters. If it belongs to the preset target domain, the module output corresponding to the input vector is determined based on the learnable weight parameters and the weight parameters of the pre-trained large language model. If it does not belong to the preset target domain, the module output corresponding to the input vector is directly determined based on the weight parameters of the pre-trained large language model. In this way, by determining whether to call learnable weight parameters based on the target domain classification result, this application can ensure the processing performance of the model incorporating target domain knowledge on data from specific domains, and also mitigate the performance degradation of the model incorporating target domain knowledge on data from other domains.

[0070] See Figure 5As shown, this invention discloses a model construction and application device that integrates target domain knowledge. The model integrating target domain knowledge is a model constructed based on a pre-trained large language model. The model integrating target domain knowledge includes a domain classifier, several consecutive first converter modules, and several consecutive second converter modules. The first converter modules are the original converter modules in the pre-trained large language model, and the second converter modules are modules obtained by structurally optimizing the original converter modules in the pre-trained large language model using a preset domain adaptive module. The device includes:

[0071] The data processing module 11 is used to acquire the question data and process the question data based on the plurality of consecutive first converter modules to obtain an input vector;

[0072] Vector classification module 12 is used to classify the input vector based on the domain classifier to obtain the target domain classification result;

[0073] The first result determination module 13 is used to determine whether to call the learnable weight parameters based on the target domain classification result using the preset domain adaptive module in the second converter module, and to determine the module output result of the preset domain adaptive module corresponding to the input vector based on the determination result and the weight parameters of the pre-trained large language model; wherein, if the target domain classification result indicates that the domain corresponding to the input vector is a preset target domain, it is determined that the learnable weight parameters need to be called in the process of determining the module response result;

[0074] The second result determination module 14 is used to determine the model output result corresponding to the input vector based on the output result of the module, so as to obtain the response result corresponding to the question data.

[0075] Therefore, this application adds a domain classifier to classify the input vector determined by several consecutive first converter modules. Based on the target domain classification result, it determines whether the input vector belongs to a preset target domain, thereby determining whether the preset domain adaptive module in the second converter module needs to call learnable weight parameters. If it belongs to the preset target domain, the module output corresponding to the input vector is determined based on the learnable weight parameters and the weight parameters of the pre-trained large language model. If it does not belong to the preset target domain, the module output corresponding to the input vector is directly determined based on the weight parameters of the pre-trained large language model. In this way, by determining whether to call learnable weight parameters based on the target domain classification result, this application can ensure the processing performance of the model incorporating target domain knowledge on data from specific domains, and also mitigate the performance degradation of the model incorporating target domain knowledge on data from other domains.

[0076] In some specific embodiments, the data processing module 11 includes:

[0077] The vector extraction unit is used to acquire question data and extract the question data using embedding technology to obtain the corresponding question vector.

[0078] In some specific embodiments, the vector classification module 12 includes:

[0079] A classification probability determination unit is used to classify the input vector based on the domain classifier to obtain the corresponding classification probability;

[0080] A classification probability determination unit is used to determine whether the classification probability is greater than a preset classification threshold; if it is greater, the domain corresponding to the input vector is determined to be the preset target domain, so as to obtain the corresponding target domain classification result; if it is less than or equal to, the domain corresponding to the input vector is determined to be a preset non-target domain, so as to obtain the corresponding target domain classification result.

[0081] In some specific embodiments, the first result determination module 13 includes:

[0082] The first weighting unit is used to call the learnable weight parameters if the target domain classification result indicates that the domain corresponding to the input vector is the preset target domain, and then use the preset domain adaptive module in the second converter module to perform a weighting operation on the input vector using the learnable weight parameters and the weight parameters of the pre-trained large language model to obtain the corresponding module output result of the preset domain adaptive module.

[0083] In some specific embodiments, the first result determination module 13 includes:

[0084] The second weighting unit is used to prohibit the use of the learnable weight parameters if the target domain classification result indicates that the domain corresponding to the input vector is a preset non-target domain, and to perform a weighting operation on the input vector by the preset domain adaptive module in the second converter module using the weight parameters of the pre-trained large language model to obtain the corresponding module output result of the preset domain adaptive module.

[0085] In some specific embodiments, the model construction and application apparatus for fusing target domain knowledge further includes:

[0086] A training set construction unit is used to construct a training set based on data in the preset target domain.

[0087] The parameter adjustment unit is used to train the model that integrates target domain knowledge using the training set and based on a pre-built target loss function, so as to adjust the learnable weight parameters determined based on the training set to obtain a trained model that integrates target domain knowledge.

[0088] In some specific embodiments, the model construction and application apparatus for fusing target domain knowledge further includes:

[0089] The loss function construction unit is used to construct a target loss function based on the loss function of the pre-trained large language model and the cross-entropy loss function corresponding to the domain classifier.

[0090] Furthermore, embodiments of this application also disclose an electronic device, Figure 6 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.

[0091] Figure 6 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the model construction and application method for integrating target domain knowledge disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0092] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0093] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.

[0094] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including computer programs capable of performing the model construction and application methods integrating target domain knowledge disclosed in any of the foregoing embodiments, the computer program 222 may further include computer programs capable of performing other specific tasks.

[0095] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned disclosed method for constructing and applying a model that integrates target domain knowledge. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.

[0096] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0097] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0098] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0099] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0100] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A model application method that integrates target domain knowledge, characterized in that, The model that integrates target domain knowledge is a model built based on a pre-trained large language model. The model includes a domain classifier, several consecutive first converter modules, and several consecutive second converter modules. The first converter modules are the original converter modules in the pre-trained large language model, and the second converter modules are modules obtained by structurally optimizing the original converter modules in the pre-trained large language model using a preset domain adaptive module. The method includes: S11: Obtain the question data and process the question data based on the plurality of consecutive first converter modules to obtain the input vector; S12: Classify the input vector based on the domain classifier to obtain the target domain classification result; S13: The preset domain adaptive module in the second converter module determines whether to call the learnable weight parameters based on the target domain classification result, and determines the module output result of the preset domain adaptive module corresponding to the input vector based on the determination result and the weight parameters of the pre-trained large language model; wherein, if the target domain classification result indicates that the domain corresponding to the input vector is a preset target domain, it is determined that the learnable weight parameters need to be called in the process of determining the module output result; wherein, the preset domain adaptive module in the second converter module determines whether to call the learnable weight parameters based on the target domain classification result, and determines the module output result of the preset domain adaptive module corresponding to the input vector based on the determination result and the weight parameters of the pre-trained large language model. The module output results include: if the target domain classification result indicates that the domain corresponding to the input vector is the preset target domain, then the learnable weight parameters are invoked, and the input vector is weighted by the preset domain adaptive module in the second converter module using the learnable weight parameters and the weight parameters of the pre-trained large language model to obtain the corresponding module output result of the preset domain adaptive module; if the target domain classification result indicates that the domain corresponding to the input vector is a preset non-target domain, then the learnable weight parameters are prohibited from being invoked, and the input vector is weighted by the preset domain adaptive module in the second converter module using the weight parameters of the pre-trained large language model to obtain the corresponding module output result of the preset domain adaptive module. S14: Determine the model output result corresponding to the input vector based on the output result of the module, so as to obtain the response result corresponding to the question data; Prior to obtaining the question data, the process also includes: A training set is constructed based on the data in the preset target domain; The model that integrates target domain knowledge is trained using the training set and based on a pre-built target loss function, and the learnable weight parameters determined based on the training set are adjusted to obtain a trained model that integrates target domain knowledge.

2. The model application method for integrating target domain knowledge according to claim 1, characterized in that, The acquisition of question data includes: The question data is acquired, and the question data is extracted using embedding technology to obtain the corresponding question vector.

3. The model application method for integrating target domain knowledge according to claim 1, characterized in that, The process of classifying the input vector based on the domain classifier to obtain the target domain classification result includes: The input vector is classified based on the domain classifier to obtain the corresponding classification probability; Determine whether the classification probability is greater than a preset classification threshold; If it is greater than, then the domain corresponding to the input vector is determined to be the preset target domain, so as to obtain the corresponding target domain classification result; If the value is less than or equal to the target value, the domain corresponding to the input vector is determined to be a preset non-target domain, so as to obtain the corresponding target domain classification result.

4. The model application method for integrating target domain knowledge according to claim 1, characterized in that, Before training the model that integrates target domain knowledge using the training set and based on a pre-built target loss function, the method further includes: The target loss function is constructed based on the loss function of the pre-trained large language model and the cross-entropy loss function corresponding to the domain classifier.

5. A model application device that integrates target domain knowledge, characterized in that, The model integrating target domain knowledge is a model built based on a pre-trained large language model. The model includes a domain classifier, several consecutive first converter modules, and several consecutive second converter modules. The first converter modules are the original converter modules in the pre-trained large language model, and the second converter modules are modules obtained by structurally optimizing the original converter modules in the pre-trained large language model using a preset domain adaptive module. The model application device integrating target domain knowledge is used to implement the model application method integrating target domain knowledge as described in any one of claims 1 to 4. The model application device integrating target domain knowledge includes: A data processing module is used to acquire query data and process the query data based on the plurality of consecutive first converter modules to obtain an input vector; The vector classification module is used to classify the input vector based on the domain classifier to obtain the target domain classification result; The first result determination module is used to determine whether to call the learnable weight parameters based on the target domain classification result using the preset domain adaptive module in the second converter module, and to determine the module output result of the preset domain adaptive module corresponding to the input vector based on the determination result and the weight parameters of the pre-trained large language model; wherein, if the target domain classification result indicates that the domain corresponding to the input vector is a preset target domain, it is determined that the learnable weight parameters need to be called in the process of determining the module output result; The second result determination module is used to determine the model output result corresponding to the input vector based on the output result of the module, so as to obtain the response result corresponding to the question data.

6. The model application device for integrating target domain knowledge according to claim 5, characterized in that, The vector classification module includes: A classification probability determination unit is used to classify the input vector based on the domain classifier to obtain the corresponding classification probability; A classification probability determination unit is used to determine whether the classification probability is greater than a preset classification threshold; if it is greater, the domain corresponding to the input vector is determined to be the preset target domain, so as to obtain the corresponding target domain classification result; if it is less than or equal to, the domain corresponding to the input vector is determined to be a preset non-target domain, so as to obtain the corresponding target domain classification result.

7. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the model application method for fusing target domain knowledge as described in any one of claims 1 to 4.