Large model generation effect optimization method and system based on knowledge graph guidance

By building a keyword extraction model and using a graph database for entity expansion, combining the LLM Q&A big model to generate Q&A results, and performing relationship consistency detection and correction, the problem of deep learning models generating high-quality content in the medical field is solved, significantly improving the generation effect and accuracy.

CN119577103AInactive Publication Date: 2025-03-07DIGITAL HEALTH CHINA TECHNOLOGIES CO LTD

Patent Information

Application Number
CN202510144215.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-10
Publication Date
2025-03-07
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In complex fields such as medical care, deep learning models are difficult to generate high-quality content when data is sparse and knowledge expression is insufficient. The existing technology lacks systematic and deep optimization methods to effectively use knowledge graphs to guide the generation of large models.

Method used

By obtaining the query condition data entered by the user, a keyword extraction model is constructed for the first key information extraction, the pre-constructed graph database is used for entity expansion and splicing, the LLM Q&A big model is input to generate Q&A results, and the second key information extraction and relationship consistency detection are performed through the keyword extraction model, and the correct and optimization are performed.

Benefits of technology

The model's Q&A generation effect and accuracy in medical fields has been significantly improved. Through the guidance of the knowledge graph, the model's ability to expand user data and test questions and answer results is enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119577103A_ABST
    Figure CN119577103A_ABST
Patent Text Reader

Abstract

The invention discloses a large model generation effect optimization method and system based on knowledge graph guidance, and the method comprises the steps: pre-constructing a domain-specific graph database, enabling the graph database to serve as guidance information, integrating the guidance information into a model generation process, carrying out the knowledge expansion of user data through a generated model, and carrying out the examination of a question and answer result, thereby achieving the optimization of a large model generation effect. Therefore, the large model is effectively guided to obtain high-quality content according to user input data, and the question and answer generation effect and accuracy of the model in the fields of medical treatment and the like are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field, and specifically relates to a method and system for optimizing the generation effect of a large model guided by a knowledge graph. Background Art

[0002] With the rapid development of artificial intelligence technology, large deep learning models (such as generative models) have shown great potential in many fields. However, these models often face problems such as sparse data and insufficient knowledge expression in complex fields (such as medical applications), which makes it difficult to ensure the quality of generated content. As a symbolic knowledge base, knowledge graphs have strong reasoning capabilities and interpretability of results, but they are expensive to build and have limited generalization capabilities. Combining knowledge graphs with large deep learning models can complement each other's strengths and improve model performance.

[0003] In the existing technology, although there are attempts to introduce knowledge graphs into deep learning models to improve the effect, most of them remain at the level of simple integration and lack systematic and deep optimization methods. Especially in the medical field, due to the complexity of professional knowledge and the sensitivity of data, how to effectively use knowledge graphs to guide large models to generate high-quality content has become a problem that needs to be solved. Summary of the invention

[0004] In response to the above-mentioned deficiencies in the prior art, the present application provides a method and system for optimizing the generation effect of a large model based on knowledge graph guidance.

[0005] In the first aspect, the present application proposes a method for optimizing the generation effect of a large model based on knowledge graph guidance, comprising the following steps:

[0006] Get the query condition data entered by the user;

[0007] Constructing a keyword extraction model to extract first key information from the query condition data to obtain keyword entities and corresponding entity types;

[0008] Expand the keyword entity corresponding to the entity type through a pre-built graph database, and splice the keyword entity with its adjacent entities to obtain an entity expansion splicing result;

[0009] Constructing an LLM question-answering model, inputting the entity expansion and splicing results into the LLM question-answering model to obtain a question-answering result;

[0010] The keyword extraction model is called to extract the second key information from the question and answer result, and the extracted result is subjected to a relationship consistency test through the graph database. If the relationship consistency test is passed, the question and answer result is output; if the relationship consistency test is not passed, the question and answer result is corrected and reconnected with the query condition data, and input into the LLM question and answer model to generate a corrected question and answer result.

[0011] In some optional implementations of some embodiments, the keyword extraction model is constructed to extract the first key information from the query condition data to obtain a keyword entity and a corresponding entity type, and the keyword extraction model structure includes: an embedding layer, an attention mechanism layer, and a feedforward network layer;

[0012] The embedding layer: the embedding weight matrix and the ID mapped to the input data are matched to obtain the embedding word vector as the embedding matrix representation of the input data, and the vector dimension is 768 dimensions;

[0013] The attention mechanism layer: the 768-dimensional feature vector output by the embedding layer is subjected to matrix feature extraction by three linear layers, and a 768-dimensional vector representation of each input data incorporating attention information is obtained through matrix multiplication calculation;

[0014] The feedforward network layer: each input of the multi-head attention mechanism layer passes through two linear layers, and after activation by the activation layer, the final 768-dimensional vector representation of each data is output.

[0015] In some optional implementations of some embodiments, the constructing of the keyword extraction model performs first key information extraction on the query condition data to obtain a keyword entity and a corresponding entity type, and the first key information extraction includes:

[0016] The query condition data is converted into an ID format through vocabulary mapping and input into the keyword extraction model, and a 768-dimensional vector representation is output. When each character vector in the query condition data passes through the linear layer, entity classification prediction is performed, and the prediction result is mapped into a numerical value through the softmax function. The formula of the linear layer is:

[0017]

[0018] Among them, x is the 768-dimensional vector representation of each character in the text E obtained by the model, A is the weight matrix of the linear layer, b is the bias matrix of the linear layer, and y is the result obtained after passing the linear layer, recorded as logits;

[0019] The formula for Softmax is:

[0020]

[0021] Yes means The exponential function of n indicates that there are n neurons in the output layer. Indicates the current input character calculated, and calculates the output of k neurons , the numerator of the softmax function is the input character The exponential function of , the denominator is the sum of the exponential functions of all input signals;

[0022] Finally, the keyword entity and the corresponding entity type are output.

[0023] In some optional implementations of some embodiments, the keyword entity corresponding to the entity type is expanded through the pre-constructed graph database, and the keyword entity is spliced ​​with entities in an adjacent relationship to obtain an entity expansion splicing result, including:

[0024] The adjacent relationship of the keyword entity is obtained, and all entities pointed to by the keyword entity and their corresponding relationship types are retrieved in the graph database according to the adjacent relationship, and the keyword entity, relationship type and pointed entity are spliced ​​to obtain an entity expansion splicing result.

[0025] In some optional implementations of some embodiments, constructing the LLM question-answering model, inputting the entity expansion and splicing result into the LLM question-answering model, and obtaining the question-answering result includes:

[0026] The embedding weight matrix and the ID mapping data of the entity expansion splicing result are matrix-matched through the embedding layer to obtain the embedding word vector as the embedding matrix representation of the input data. The ID mapping data of the entity expansion splicing result is output as the sentence vector representation x after embedding.

[0027] The sentence vector representation x is input into the feature network layer for calculation. The calculation process is:

[0028] Calculation of the filter network: A filter with a window length of h slides the sentence vector to represent the sentence corresponding to x Divided into , for the window After convolution and activation by tanh function, the formula is:

[0029]

[0030] Where n is the number of characters in the sentence vector representation x;

[0031] Sliding the convolution window and reactivating it, we get a feature mapping of the filter:

[0032]

[0033] For m filters, we have:

[0034]

[0035] Input the feature mapping of m filters into the Max pooling layer for maximum pooling to obtain the features corresponding to specific filters:

[0036]

[0037] in Feature mapping for a filter;

[0038] The output of the Max pooling layer is:

[0039]

[0040] Calculate the output of the Max pooling layer, define z_gated=z, and pass z_gated through the sigmoid activation function:

[0041]

[0042] Perform matrix operations on z_gated and z activated by the sigmoid activation function to obtain the output z3 of the control gate model layer:

[0043]

[0044] Through the residual connection mechanism, the original vector representation H before the control gate model layer is calculated and z3 output by the control gate model layer is added to output the information z4 after the fusion residual connection:

[0045]

[0046] The LayerNorm transforms z4 into a data form with a mean of 0 and a variance of 1:

[0047]

[0048] Where f means LayerNorm conversion;

[0049] The output z after the conversion of the LayerNorm layer passes through the defined feed_forward layer. In feed_forward, the network structure is defined as two fully connected layers. Then, it is added with LayerNorm for residual connection and normalized by LayerNorm. The input formula is expressed as:

[0050]

[0051] At this point, the feature network layer calculation has been completed, and the final output character vector representation will be passed to the next layer of network for calculation, including:

[0052] Let H = z2, and the sentence character vector set H calculated and output by the feature network layer is average pooled as the vector representation of the current sentence. , the calculation formula is:

[0053]

[0054] Finally After passing through the fully connected layer, the probability p value of the next character to be predicted is obtained through softmax calculation. The formula is as follows:

[0055]

[0056] Among them, W2 is the weight matrix of the last linear layer, the dimension is L*d, L is the number of all characters in the vocabulary, and p is the probability value of the next generated character, so as to predict the next character in sequence according to the input entity expansion and splicing results to generate the content of the question and answer result.

[0057] In some optional implementations of some embodiments, the keyword extraction model is called to extract the second key information from the question and answer result, and the extracted result is subjected to a relationship consistency test through the graph database, and the relationship consistency test includes a hierarchical relationship closure test:

[0058] The results of the second key information extraction are searched through the graph database to obtain all entity concept types from the top-level entity concept type to the bottom-level concept type, and mutual verification is performed through top-down attribution relationships and bottom-up subordinate relationships. If the results of the mutual verification form a closed-loop relationship, the hierarchical relationship closure detection is performed.

[0059] In some optional implementations of some embodiments, the keyword extraction model is called to extract the second key information from the question and answer result, and the extracted result is subjected to a relationship consistency test through the graph database, and the relationship consistency test also includes a relationship uniqueness test:

[0060] Determine the relationship type between the entities corresponding to all entity concept types and the entities in all their subsets. If multiple relationship types with different names appear, the relationship uniqueness test will not pass. The entities that fail the relationship uniqueness test will be screened out for review and correction. If only relationship types with the same name exist, it means that the relationship uniqueness test has passed.

[0061] In the second aspect, the present application proposes a large model generation effect optimization system based on knowledge graph guidance, including an input data acquisition module, a key information extraction module, an entity expansion and splicing module, a question and answer result acquisition module, and a question and answer result verification module;

[0062] The input data acquisition module is used to acquire the query condition data input by the user;

[0063] The key information extraction module is used to construct a keyword extraction model to extract the first key information from the query condition data to obtain a keyword entity and a corresponding entity type;

[0064] The entity expansion and splicing module is used to expand the keyword entity corresponding to the entity type through a pre-built graph database, and to splice the keyword entity with its adjacent entities to obtain an entity expansion and splicing result;

[0065] The question-answering result acquisition module is used to construct an LLM question-answering model, input the entity expansion and splicing results into the LLM question-answering model, and obtain the question-answering result;

[0066] The question and answer result verification module is used to call the keyword extraction model to extract the second key information from the question and answer result, and to perform a relationship consistency test on the extracted result through the graph database. If the relationship consistency test is passed, the question and answer result is output; if the relationship consistency test is not passed, the question and answer result is corrected and reconnected with the query condition data, and then input into the LLM question and answer model to generate a corrected question and answer result.

[0067] In a third aspect, the present application proposes an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.

[0068] In a fourth aspect, the present application proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.

[0069] Beneficial effects of the present invention:

[0070] By pre-building a domain-specific graph database and integrating it into the model generation process as guiding information, and using the generated model to expand the knowledge of user data and verify the question and answer results, the question and answer generation effect and accuracy of the model in fields such as medicine can be significantly improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0071] Figure 1 It is the overall flow chart of the present invention.

[0072] Figure 2 It is a system principle block diagram of the present invention. DETAILED DESCRIPTION

[0073] The exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments described herein; on the contrary, these embodiments are provided to enable a more thorough understanding of the present invention and to fully convey the scope of the present invention to those skilled in the art.

[0074] In the first aspect, the present application proposes a method for optimizing the generation effect of a large model based on knowledge graph guidance, comprising the following steps:

[0075] S100: Acquire query condition data input by the user;

[0076] Among them, first, after the user enters the query (query condition), the query content is returned to the backend through the HTTP interface. After receiving the incoming API request, the backend starts to call the subsequent steps for subsequent processing.

[0077] S200: constructing a keyword extraction model to extract first key information from the query condition data to obtain keyword entities and corresponding entity types;

[0078] In some optional implementations of some embodiments, the keyword extraction model is constructed to extract the first key information from the query condition data to obtain a keyword entity and a corresponding entity type, and the keyword extraction model structure includes: an embedding layer, an attention mechanism layer, and a feedforward network layer;

[0079] The embedding layer: the embedding weight matrix and the ID mapped to the input data are matched to obtain the embedding word vector as the embedding matrix representation of the input data, and the vector dimension is 768 dimensions;

[0080] The attention mechanism layer: the 768-dimensional feature vector output by the embedding layer is subjected to matrix feature extraction by three linear layers, and a 768-dimensional vector representation of each input data incorporating attention information is obtained through matrix multiplication calculation;

[0081] The feedforward network layer: each input of the multi-head attention mechanism layer passes through two linear layers, and after activation by the activation layer, the final 768-dimensional vector representation of each data is output.

[0082] In some optional implementations of some embodiments, the constructing of the keyword extraction model performs first key information extraction on the query condition data to obtain a keyword entity and a corresponding entity type, and the first key information extraction includes:

[0083] The query condition data is converted into an ID format through vocabulary mapping and input into the keyword extraction model, and a 768-dimensional vector representation is output. When each character vector in the query condition data passes through the linear layer, entity classification prediction is performed, and the prediction result is mapped into a numerical value through the softmax function. The formula of the linear layer is:

[0084]

[0085] Assume that the input query text is E, ei~en are the characters in the text E, and a 768-dimensional vector representation is obtained after the model output. Then, each character vector is classified and predicted whether it is an entity through a linear layer. The prediction result is mapped to a value between 0 and 1 through a softmax function. x is the 768-dimensional vector representation of each character in the text E obtained by the model, A is the weight matrix of the linear layer, b is the bias matrix of the linear layer, and y is the result obtained after the linear layer, recorded as logits;

[0086] The formula for Softmax is:

[0087]

[0088] Yes means The exponential function of n indicates that there are n neurons in the output layer. Indicates the current input character calculated, and calculates the output of k neurons , the numerator of the softmax function is the input character The exponential function of , the denominator is the sum of the exponential functions of all input signals;

[0089] Finally, the keyword entity and the corresponding entity type are output.

[0090] At this point, the key entity information in the query has been extracted. Next, this information is input into the knowledge graph of the graph database for retrieval to obtain relevant additional knowledge.

[0091] S300: Expanding the keyword entity corresponding to the entity type through a pre-built graph database, and splicing the keyword entity with entities in an adjacent relationship to obtain an entity expansion splicing result;

[0092] In some optional implementations of some embodiments, the keyword entity corresponding to the entity type is expanded through the pre-constructed graph database, and the keyword entity is spliced ​​with the entity of its adjacent relationship to obtain the entity expansion splicing result, including:

[0093] The adjacent relationship of the keyword entity is obtained, and all entities pointed to by the keyword entity and their corresponding relationship types are retrieved in the graph database according to the adjacent relationship, and the keyword entity, relationship type and pointed entity are spliced ​​to obtain an entity expansion splicing result.

[0094] Among them, according to the keyword entities and corresponding entity types in the user query extracted by the keyword extraction model, the corresponding entity under the type is found in the knowledge graph. The current strategy is to find the direct adjacent relationship of the current entity, find all entities pointed to by the adjacent relationship of the current entity, add the relationship type, and splice them as an expansion of the entity in the query:

[0095] An example is shown in Table 1 below:

[0096] Table 1

[0097]

[0098] In this embodiment, the keyword entity is "cervical spondylosis", and the directly adjacent relationships are: "disease alias", "site of onset", "patient population", and "infectivity". All the entities pointed to by these relationships are found, and the relationships are added for splicing. The entity expansion and splicing result is: "The disease alias of cervical spondylosis is 'cervical degeneration, cervical bone hyperplasia', the site of onset is 'spine', the patient population is 'middle-aged and elderly people, over 40 years old', and the infectivity is 'non-infectious'".

[0099] S400: constructing an LLM question-answering model, inputting the entity expansion and splicing result into the LLM question-answering model, and obtaining a question-answering result;

[0100] In some optional implementations of some embodiments, constructing the LLM question-answering model, inputting the entity expansion and splicing result into the LLM question-answering model, and obtaining the question-answering result includes:

[0101] Through the embedding layer, the embedding weight matrix and the ID mapping data of the entity expansion splicing result are matrix-matched to obtain the embedding word vector as the embedding matrix representation of the input data. The ID mapping data of the entity expansion splicing result is output as the sentence vector representation x after embedding.

[0102] The sentence vector representation x is input into the feature network layer for calculation. The calculation process is:

[0103] Calculation of the filter network: A filter with a window length of h slides the sentence vector to represent the sentence corresponding to x Divided into , for the window After convolution and activation by tanh function, the formula is:

[0104]

[0105] Where n is the number of characters in the sentence vector representation x;

[0106] Sliding the convolution window and reactivating it, we get a feature mapping of the filter:

[0107]

[0108] For m filters, we have:

[0109]

[0110] Input the feature mapping of m filters into the Max pooling layer for maximum pooling to obtain the features corresponding to specific filters:

[0111]

[0112] in Feature mapping for a filter;

[0113] The output of the Max pooling layer is:

[0114]

[0115] Calculate the output of the Max pooling layer, define z_gated=z, and pass z_gated through the sigmoid activation function:

[0116]

[0117] Perform matrix operations on z_gated and z activated by the sigmoid activation function to obtain the output z3 of the control gate model layer:

[0118]

[0119] Through the residual connection mechanism, the original vector representation H before the control gate model layer is calculated and z3 output by the control gate model layer is added to output the information z4 after the fusion residual connection:

[0120]

[0121] The LayerNorm transforms z4 into a data form with a mean of 0 and a variance of 1:

[0122]

[0123] Where f means LayerNorm conversion;

[0124] The output z after the conversion of the LayerNorm layer passes through the defined feed_forward layer. In feed_forward, the network structure is defined as two fully connected layers. Then, it is added with LayerNorm for residual connection and normalized by LayerNorm. The input formula is expressed as:

[0125]

[0126] At this point, the feature network layer calculation has been completed, and the final output character vector representation will be passed to the next layer of network for calculation, including:

[0127] Let H = z2, and the sentence character vector set H calculated and output by the feature network layer is average pooled as the vector representation of the current sentence. , the calculation formula is:

[0128]

[0129] Finally After passing through the fully connected layer, the probability p value of the next character to be predicted is obtained through softmax calculation. The formula is as follows:

[0130]

[0131] Among them, W2 is the weight matrix of the last linear layer, the dimension is L*d, L is the number of all characters in the vocabulary, and p is the probability value of the next generated character, so as to predict the next character in sequence according to the input entity expansion and splicing results to generate the content of the question and answer result.

[0132] S500: Call the keyword extraction model to extract the second key information from the question and answer result, and perform a relationship consistency test on the extracted result through the graph database. If the relationship consistency test is passed, the question and answer result is output; if the relationship consistency test is not passed, the question and answer result is corrected and reconnected with the query condition data, and input into the LLM question and answer model to generate a corrected question and answer result.

[0133] In some optional implementations of some embodiments, the keyword extraction model is called to extract the second key information from the question and answer result, and the extracted result is subjected to a relationship consistency test through the graph database, and the relationship consistency test includes a hierarchical relationship closure test:

[0134] The results of the second key information extraction are searched through the graph database to obtain all entity concept types from the top-level entity concept type to the bottom-level concept type, and mutual verification is performed through top-down attribution relationships and bottom-up subordinate relationships. If the results of the mutual verification form a closed-loop relationship, the hierarchical relationship closure detection is performed.

[0135] Among them, assuming that Z is the top-level entity concept type in the knowledge graph, and A is the bottom-level entity concept type, for each belong to relationship from top to bottom in the knowledge graph in the graph database, such as A→B→C→...→Z, then there should be a subset relationship subordinate in turn: Z→...→C→B→A, so that the mutually deduced and verified relationship must form a closed loop.

[0136] In some optional implementations of some embodiments, the keyword extraction model is called to extract the second key information from the question and answer result, and the extracted result is subjected to a relationship consistency test through the graph database, and the relationship consistency test also includes a relationship uniqueness test:

[0137] Determine the relationship type between the entities corresponding to all entity concept types and the entities in all their subsets. If multiple relationship types with different names appear, the relationship uniqueness test will not pass. The entities that fail the relationship uniqueness test will be screened out for review and correction. If only relationship types with the same name exist, it means that the relationship uniqueness test has passed.

[0138] Among them, for each entity corresponding to all entity concept types, there should be one and only one relationship of the same type. There cannot be two relationships with different names but expressing the same meaning at the same time. The relationships that exist in this situation are found out through rule verification. For an entity E1, all its subset entities are set to S1. For entities of the same type in S1, the relationship type between them and the current entity E1 is judged. After all entities under each entity type in S1 are judged, if there are multiple relationships with different names under the corresponding entity type, there is a situation where the relationship is not unique. At this time, these relationships and their corresponding entities need to be screened out for review and correction.

[0139] In the second aspect, the present application proposes a large model generation effect optimization system based on knowledge graph guidance, including an input data acquisition module, a key information extraction module, an entity expansion and splicing module, a question and answer result acquisition module, and a question and answer result verification module;

[0140] The input data acquisition module is used to acquire the query condition data input by the user;

[0141] The key information extraction module is used to construct a keyword extraction model to extract the first key information from the query condition data to obtain a keyword entity and a corresponding entity type;

[0142] The entity expansion and splicing module is used to expand the keyword entity corresponding to the entity type through a pre-built graph database, and to splice the keyword entity with its adjacent entities to obtain an entity expansion and splicing result;

[0143] The question-answering result acquisition module is used to construct an LLM question-answering model, input the entity expansion and splicing results into the LLM question-answering model, and obtain the question-answering result;

[0144] The question and answer result verification module is used to call the keyword extraction model to extract the second key information from the question and answer result, and to perform a relationship consistency test on the extracted result through the graph database. If the relationship consistency test is passed, the question and answer result is output; if the relationship consistency test is not passed, the question and answer result is corrected and reconnected with the query condition data, and then input into the LLM question and answer model to generate a corrected question and answer result.

[0145] In a third aspect, the present application proposes an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.

[0146] In a fourth aspect, the present application proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.

[0147] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0148] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0149] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this disclosure.

[0150] In the embodiments provided in the present disclosure, it should be understood that the disclosed apparatus / computer equipment and methods can be implemented in other ways. For example, the apparatus / computer equipment embodiments described above are merely schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation. Multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection of the apparatus or unit, which may be electrical, mechanical or other forms.

[0151] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0152] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0153] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present disclosure implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, and the computer program code may be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electric carrier signals and telecommunication signals.

[0154] The above are only preferred implementations of the present invention. It should be pointed out that a number of modifications and improved technical solutions made by those skilled in the art without departing from the technical solution should also be deemed to fall within the scope of protection required by the claims.

Claims

1. A large model generation effect optimization method based on knowledge graph guidance, characterized by: The following steps are involved: Get the query condition data entered by the user; Constructing a keyword extraction model to extract first key information from the query condition data to obtain keyword entities and corresponding entity types; Expand the keyword entity corresponding to the entity type through a pre-built graph database, and splice the keyword entity with its adjacent entities to obtain an entity expansion splicing result; Constructing an LLM question-answering model, inputting the entity expansion and splicing results into the LLM question-answering model to obtain a question-answering result; The keyword extraction model is called to extract the second key information from the question and answer result, and the second key information extraction result is subjected to a relationship consistency test through the graph database. If the relationship consistency test is passed, the question and answer result is output; if the relationship consistency test is not passed, the question and answer result is corrected and reconnected with the query condition data, and then input into the LLM question and answer model to generate a corrected question and answer result.

2. The method according to claim 1, characterized in that: The keyword extraction model is constructed to extract the first key information from the query condition data to obtain the keyword entity and the corresponding entity type, and the keyword extraction model structure includes: an embedding layer, an attention mechanism layer and a feedforward network layer; The embedding layer: the embedding weight matrix and the ID mapped to the input data are matched to obtain the embedding word vector as the embedding matrix representation of the input data, and the vector dimension is 768 dimensions; The attention mechanism layer: the 768-dimensional feature vector output by the embedding layer is subjected to matrix feature extraction by three linear layers, and a 768-dimensional vector representation of each input data incorporating attention information is obtained through matrix multiplication calculation; The feedforward network layer: each input of the multi-head attention mechanism layer passes through two linear layers, and after activation by the activation layer, the final 768-dimensional vector representation of each data is output.

3. The method according to claim 2, characterized in that: The keyword extraction model is constructed to extract the first key information from the query condition data to obtain a keyword entity and a corresponding entity type, wherein the first key information extraction includes: The query condition data is converted into an ID format through vocabulary mapping and input into the keyword extraction model, and a 768-dimensional vector representation is output. When each character vector in the query condition data passes through the linear layer, entity classification prediction is performed, and the prediction result is mapped into a numerical value through the softmax function. The formula of the linear layer is: Among them, x is the 768-dimensional vector representation of each character in the text E obtained by the model, A is the weight matrix of the linear layer, b is the bias matrix of the linear layer, and y is the result obtained after passing the linear layer, recorded as logits; The formula for Softmax is: Yes means The exponential function of n indicates that there are n neurons in the output layer. Indicates the current input character calculated, and calculates the output of k neurons , the numerator of the softmax function is the input character The exponential function of , the denominator is the sum of the exponential functions of all input signals; Finally, the keyword entity and the corresponding entity type are output.

4. The method according to claim 3, characterized in that: The keyword entity corresponding to the entity type is expanded through the pre-built graph database, and the keyword entity is spliced ​​with entities in an adjacent relationship to obtain an entity expansion splicing result, including: The adjacent relationship of the keyword entity is obtained, and all entities pointed to by the keyword entity and their corresponding relationship types are retrieved in the graph database according to the adjacent relationship, and the keyword entity, relationship type and pointed entity are spliced ​​to obtain an entity expansion splicing result.

5. The method according to claim 4, characterized in that: The constructing of the LLM question-answering model, inputting the entity expansion and splicing result into the LLM question-answering model, and obtaining the question-answering result, includes: Through the embedding layer, the embedding weight matrix and the ID mapping data of the entity expansion splicing result are matrix-matched to obtain the embedding word vector as the embedding matrix representation of the input data. The ID mapping data of the entity expansion splicing result is output as the sentence vector representation x after embedding. The sentence vector representation x is input into the feature network layer for calculation. The calculation process is: Calculation of the filter network: A filter with a window length of h slides the sentence vector to represent the sentence corresponding to x Divided into , for the window After convolution and activation by tanh function, the formula is: Where n is the number of characters in the sentence vector representation x; Sliding the convolution window and reactivating it, we get a feature mapping of the filter: For m filters, we have: Input the feature mapping of m filters into the Max pooling layer for maximum pooling to obtain the features corresponding to specific filters: in Feature mapping for a filter; The output of the Max pooling layer is: Calculate the output of the Max pooling layer, define z_gated=z, and pass z_gated through the sigmoid activation function: Perform matrix operations on z_gated and z activated by the sigmoid activation function to obtain the output z3 of the control gate model layer: Through the residual connection mechanism, the original vector representation H before the control gate model layer is calculated and z3 output by the control gate model layer is added to output the information z4 after the fusion residual connection: The LayerNorm transforms z4 into a data form with a mean of 0 and a variance of 1: Where f means LayerNorm conversion; The output z after the LayerNorm layer conversion passes through the defined feed_forward layer. In feed_forward, the network structure is defined as two fully connected layers. Then, it is added to the LayerNorm layer for residual connection and normalized by LayerNorm. The input formula is expressed as: At this point, the feature network layer calculation has been completed, and the final output character vector representation will be passed to the next layer of network for calculation, including: Let H = z2, and the sentence character vector set H calculated and output by the feature network layer is average pooled as the vector representation of the current sentence. , the calculation formula is: Finally After passing through the fully connected layer, the probability p value of the next character to be predicted is obtained through softmax calculation. The formula is as follows: Among them, W2 is the weight matrix of the last linear layer, the dimension is L*d, L is the number of all characters in the vocabulary, and p is the probability value of the next generated character, so as to predict the next character in sequence according to the input entity expansion and splicing results to generate the content of the question and answer result.

6. The method according to claim 5, characterized in that: The calling of the keyword extraction model extracts the second key information from the question and answer result, and performs a relationship consistency test on the second key information extraction result through the graph database, wherein the relationship consistency test includes a hierarchical relationship closure test: The results of the second key information extraction are searched through the graph database to obtain all entity concept types from the top-level entity concept type to the bottom-level concept type, and mutual verification is performed through top-down attribution relationships and bottom-up subordinate relationships. If the results of the mutual verification form a closed-loop relationship, the hierarchical relationship closure detection is performed.

7. The method according to claim 6, characterized in that: The calling of the keyword extraction model to extract the second key information from the question and answer result, and performing a relationship consistency test on the extracted result through the graph database, wherein the relationship consistency test also includes a relationship uniqueness test: Determine the relationship type between the entities corresponding to all entity concept types and the entities in all their subsets. If multiple relationship types with different names appear, the relationship uniqueness test will not pass. The entities that fail the relationship uniqueness test will be screened out for review and correction. If only relationship types with the same name exist, it means that the relationship uniqueness test has passed.

8. A large model generation effect optimization system based on knowledge graph guidance, characterized by: It includes input data acquisition module, key information extraction module, entity expansion and splicing module, question and answer result acquisition module and question and answer result verification module; The input data acquisition module is used to acquire the query condition data input by the user; The key information extraction module is used to construct a keyword extraction model to extract the first key information from the query condition data to obtain a keyword entity and a corresponding entity type; The entity expansion and splicing module is used to expand the keyword entity corresponding to the entity type through a pre-built graph database, and to splice the keyword entity with its adjacent entities to obtain an entity expansion and splicing result; The question-answering result acquisition module is used to construct an LLM question-answering model, input the entity expansion and splicing results into the LLM question-answering model, and obtain the question-answering result; The question and answer result verification module is used to call the keyword extraction model to extract the second key information from the question and answer result, and to perform a relationship consistency test on the extracted result through the graph database. If the relationship consistency test is passed, the question and answer result is output; if the relationship consistency test is not passed, the question and answer result is corrected and reconnected with the query condition data, and then input into the LLM question and answer model to generate a corrected question and answer result.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Drug recommendation method and system based on deep convolutional network control gate model

    CN116913459A

  • Medical auxiliary question and answer method and system based on knowledge calibration and retrieval enhancement

    CN117573843A

  • Medical knowledge graph quality evaluation method and system

    CN118035678A

  • Intelligent customer service question and answer method based on knowledge graph and large language model

    CN118312600A

  • Large language model knowledge graph construction method in financial field

    CN119378660A

Cited By

  • Scientific achievement transformation method based on graph knowledge large model

    CN120670979A

  • A scientific research achievement transformation method based on a graph knowledge large model

    CN120670979B

  • Medical question and answer risk control method and device

    CN120767013A

  • Knowledge recommendation method, device and equipment based on aerospace remote sensing map and medium

    CN120804304A