Intelligent appeal question and answer large model construction method and device and medium
By combining knowledge graphs and similarity retrieval, we build knowledge graphs and vector index libraries in the appeal field, fine-tune large models, and solve the accuracy and cost problems of intelligent question and answer systems in complex appeal processing, achieving more efficient intelligent question and answer capabilities.
Patent Information
- Application Number
- CN202410870174.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-09-27
AI Technical Summary
When existing intelligent question answering systems deal with complex, semantically ambiguous or diverse user appeals, they cannot effectively understand semantics and context, resulting in inaccurate responses. In addition, large models have limited knowledge transfer capabilities and high training costs, making them unable to meet complex needs.
Combining knowledge graphs, similarity retrieval and fine-tuning large models, by building knowledge graphs in the request field, work order vector index databases and question and answer data sets, entity relationships are extracted, potential relationships are inferred, similar work orders are retrieved, and answers are generated.
It improves the understanding and reasoning ability of large models on problems, reduces training costs, can generate accurate responses, provides more accurate information when dealing with complex problems, and enhances system performance and user satisfaction.
Smart Images

Figure CN118708693A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent question answering technology, and more specifically, to a method, device and medium for constructing a large model of intelligent question answering. Background Art
[0002] With the development of society and the advancement of science and technology, people's demand for services is growing and becoming more complex. By developing an intelligent question-and-answer system in the field of appeals to efficiently handle appeals, we can provide the required information and services in a timely manner, save time and energy, and reduce the manpower costs of relevant departments, avoiding a large number of staff to deal with repetitive questions and consultations. It is of great significance and value to efficiently handle appeals through an intelligent question-and-answer system, improve service efficiency, reduce costs, enhance user satisfaction and trust, and thus better meet user needs and expectations.
[0003] With the development of big models and artificial intelligence technology, there are currently several main methods for building intelligent question and answer systems:
[0004] Retrieval-based question answering finds answers related to user questions by building and searching text indexes. Commonly used technologies include TF-IDF, BM25, etc. Although this method is simple and efficient to implement, suitable for large-scale text data, and can handle open-domain question answering tasks, it cannot understand semantics and contextual information, and the search results are limited by the indexing and retrieval algorithms, and have limited effects on complex questions and fuzzy queries.
[0005] Based on generated questions and answers, more and more large models are being applied to generative intelligent question and answer in different fields. Nowadays, fine-tuning the pre-trained large model with professional field data is a common method of building large models in vertical fields. However, when the target field is very different from the pre-trained field, the knowledge transfer ability of the pre-trained large model may be limited and cannot achieve good training results. In addition, each time the large model wants to update its internal knowledge, it needs to consume a lot of resources, and the training cost is high.
[0006] Intelligent question answering based on knowledge graphs is another common method. This method uses knowledge graphs to organize and represent rich structured knowledge. When users ask questions, the system uses entities, relationships, and attributes in the knowledge graph to infer answers. Compared with question answering based on large models, this method has limited ability to understand semantically complex content and often cannot provide accurate answers when dealing with semantically ambiguous or complex questions.
[0007] As user demands cover a variety of topics, have complex content, have many repeated similar demands, and have various forms of expressing demands, the above methods are no longer able to provide efficient and accurate responses to such user demands. Summary of the invention
[0008] In order to solve the above-mentioned problems existing in the prior art, the present invention provides a method, device and medium for constructing a large model of intelligent question and answer of demands, starting from three aspects: knowledge graph, similarity retrieval and fine-tuning of the large model. Through the effective combination of the three, the large model can generate valuable responses with reference significance.
[0009] According to a first aspect of the present invention, a method for constructing a large model of intelligent question and answer is provided, the method comprising:
[0010] Acquire demand domain data, extract entity relationships existing in the demand domain data, and construct a demand domain knowledge graph;
[0011] Obtain the request work order data, encode and vectorize each request work order data, and build a work order vector index library;
[0012] Based on the demand domain data, annotation is performed to construct a demand domain question-answering dataset, and the domain question-answering dataset is used to fine-tune the pre-trained large model;
[0013] Obtaining questions, extracting entity relationships in the questions, inferring potential entity relationships using the knowledge graph of the demand domain, and constructing potential relationship prompts;
[0014] Vectorize the problem encoding, use the ticket vector index library to retrieve similar tickets, and build similar problem prompts based on the retrieved similar tickets;
[0015] The potential relationship prompts, similar question prompts and questions are simultaneously input into the fine-tuned large model to generate answers.
[0016] Furthermore, the demand domain data is obtained, and the entity relationships existing in the demand domain data are extracted to construct a demand domain knowledge graph, which specifically includes:
[0017] Convert the demand domain data into text data, extract entity relationships in the text data, wherein the entity relationships include multiple entities and multiple relationships, and there is at least one relationship between two entities. The multiple entities include at least five entities: joint processing unit, business supervisory unit, service object, and matter type. The multiple relationships include at least six relationships: main management, joint processing, subordinate to, assist, type belonging to, and service.
[0018] The entity relationships are used to construct a triple set to obtain a knowledge graph of the demand domain.
[0019] Furthermore, the request work order data is obtained, each request work order data is encoded and vectorized, and a work order vector index library is constructed, which specifically includes:
[0020] After word segmentation of the request work order data using a word segmentation tool, encoding and vectorizing each request work order data is performed to obtain a vector feature representation set of the request work order data, wherein the vector feature representation set includes a vector feature representation corresponding to the request work order data;
[0021] Based on the LSH index, create an index object using the API of the FAISS library;
[0022] The vector feature representation is added to an index object.
[0023] Furthermore, based on the demand domain data, annotation is performed to construct a demand domain question-answering dataset, specifically including:
[0024] Based on the demand domain data, after annotation, a plurality of question-answer pairs are formed, and a demand domain question-answer data set is constructed through the plurality of question-answer pairs.
[0025] Furthermore, the question is obtained, the entity relationship in the question is extracted, the potential entity relationship is inferred using the knowledge graph of the demand domain, and the potential relationship prompt is constructed, which specifically includes:
[0026] Entities and relationships in the question are extracted and input into the knowledge graph of the demand domain. Potential relationships are determined by combining with the knowledge reasoning model, and potential relationship prompts are generated using the set prompt template.
[0027] Furthermore, the knowledge reasoning model determines the potential relationship and generates the potential relationship prompt using the set prompt template, which specifically includes:
[0028] Initialize the vectors of the relations and entities in the question, and use the RHGT model to learn the nodes and edges in the knowledge graph of the demand domain, where the nodes and edges correspond to entities and relations respectively;
[0029] The operation of the lth layer in the RHGT model T on the demand domain knowledge graph is expressed as:
[0030]
[0031] in, For node v j The lth layer of i and v j are adjacent nodes, For node v j The l-1th layer of For node v i The l-1th layer of is the relationship representation of adjacent nodes in the lth layer, is the relationship representation of adjacent nodes in the l-1th layer, Aggregate() represents the aggregation function, Att() is the weight calculation function between nodes, and Msg() is the message passing function;
[0032] The triple in the demand domain knowledge graph <v i ,e,v j > as a meta-relation, where e represents the node v i and node v j relationship;
[0033] Set weight matrices for each type of entity and relationship;
[0034] Multi-head attention is designed to learn the weights and message passing of meta-relationships from multiple perspectives. The method for calculating attention weights is as follows:
[0035]
[0036]
[0037] Among them, ATT_head() is the multi-head attention calculation function, m is the number of attention heads, and n is the sequence number of the attention head; and Respectively represent the node v i and node v j The query vector and key vector in the nth attention head; d is the dimension size of the vector embedding; Indicates all with v j connected nodes; is a tensor representing the meta-relation feature, softmax represents the normalization function, Represents the learnable parameter matrix when the relationship type is r(e), Represents node v j The type of the linear layer corresponding to the nth attention head, t(v j ) represents node v j Type;
[0038] After obtaining the attention weight of the meta-relation, the message passing from the head entity to the tail entity is completed by the following formula:
[0039]
[0040] in, is the linear projection of the message passing entity in the nth attention head, is the learnable weight matrix, t(v j ) represents node v j Type;
[0041] The low-dimensional representation of entities and relationships is obtained by calculating the multi-head attention weights and message passing for all adjacent entities of the target entity and then aggregating them. The process is as follows:
[0042]
[0043]
[0044] in, is the update vector obtained at layer l, W r is a learnable relation type weight matrix, which updates the vector After ReLU activation and residual connection, Perform linear projection and compare it with the entity v in the previous layer i The representation vector Add as the final output vector representation of the current layer Relation vector representation The update is achieved through matrix transformation, and σ is the ReLU activation function.
[0045] Furthermore, the problem encoding is vectorized, similar work orders are retrieved using the work order vector index library, and similar problem prompts are constructed based on the retrieved similar work orders, including:
[0046] Use the word segmentation tool to segment the question, encode and vectorize the segmented question to obtain the query vector;
[0047] Based on the maximum inner product search method, the top-k vector indexes are retrieved, and the corresponding similar work order texts are returned according to the position information attached to the vector indexes;
[0048] The returned similar work order texts are constructed into similar work order prompts using the set prompt template.
[0049] Furthermore, the potential relationship prompts, similar question prompts and questions are simultaneously input into the fine-tuned large model to generate answers, specifically including:
[0050] Constructing a comprehensive prompt template, and filling the potential relationship prompt, similar problem prompt and problem into the comprehensive prompt template;
[0051] The completed comprehensive prompt template is fed into the fine-tuned large model to generate an answer.
[0052] According to a second aspect of the present invention, a device for constructing a large model of intelligent question and answer is provided, the device comprising:
[0053] An input module is configured to obtain demand domain data, question and demand ticket data, and feed them to the knowledge graph module, the similar ticket retrieval module and the prompt construction module respectively;
[0054] A knowledge graph module is configured to extract entity relationships existing in the demand domain data, construct a demand domain knowledge graph, extract entity relationships in the question, use the demand domain knowledge graph to infer potential entity relationships, and construct potential relationship prompts;
[0055] The similar work order retrieval module is configured to encode and vectorize each work order data and build a work order vector index library;
[0056] A prompt construction module is configured to vectorize the problem encoding, retrieve similar work orders using the work order vector index library, construct similar problem prompts based on the retrieved similar work orders, and simultaneously input the potential relationship prompts, similar problem prompts and the problems into the fine-tuned large model;
[0057] The answer module is configured to perform annotation based on the demand domain data to construct a demand domain question and answer dataset, and use the domain question and answer dataset to fine-tune the pre-trained large model.
[0058] According to a third aspect of the present invention, there is provided a readable storage medium storing one or more programs, wherein the one or more programs can be executed by one or more processors to implement the method as described above.
[0059] The present invention has at least the following beneficial effects:
[0060] The present invention effectively improves the ability of the big model in the field of claims to understand problems and reason and respond to them. Combined with knowledge graph reasoning and similarity retrieval, it can effectively utilize the potential relationships in knowledge graph reasoning and the semantic information of similar work orders to guide the big model to generate accurate replies. By updating the content of the work order vector index library, the big model can retrieve new content in real time, avoiding retraining the big model, greatly reducing training costs. By retrieving similar work orders, it can not only provide effective guidance for the reasoning of the big model, but also directly display similar work order issues to users, providing users with meaningful references. Reasoning through the knowledge graph can provide the question-answering system with information that cannot be inferred by the big model alone, which helps the model to better understand and handle complex problems and improve the performance and accuracy of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] Figure 1 A flowchart of a method for constructing a large model of intelligent question and answer according to an embodiment of the present invention is shown.
[0062] Figure 2 A question-answering flow chart of a large model of intelligent question-answering according to an embodiment of the present invention is shown.
[0063] Figure 3A structural diagram of a device for constructing a large model of intelligent question and answer according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0064] In order to enable those skilled in the art to better understand the technical solution of the present invention, the present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. The embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings and specific embodiments, but are not intended to limit the present invention. For the various steps described herein, if there is no necessity for a causal relationship between each other, the order in which they are described as examples herein should not be regarded as a limitation, and those skilled in the art should know that they can be adjusted in order, as long as the logic between them is not destroyed, resulting in the inability to implement the entire process.
[0065] Based on the previous research status, the present invention proposes a method for constructing a large model of intelligent question answering. Figure 1 and Figure 2 , which are respectively the flow chart of the method and the schematic diagram of the question-answering process of the large model constructed based on the method.
[0066] Combination Figure 1 and Figure 2 As shown, the method for constructing the intelligent question-answering model includes the following steps:
[0067] Step 1: Obtain demand domain data, extract entity relationships existing in the demand domain data, and construct a demand domain knowledge graph.
[0068] In step 1, build a knowledge graph of the demand domain:
[0069] Collect data related to the field of demands, such as work orders for public demands and standard documents related to demands handled by government departments of enterprises and institutions, clean the data, remove irregular or duplicate files, and filter invalid characters such as web page tags. Convert all data into text format, apply the entity relationship joint extraction model BERT-BILSTM-CRF to extract entity relationships in the data, and obtain five entities of problem classification, joint processing unit, business supervisory unit, service object and item type through manual screening and deduplication, and six relationships of main management, joint processing, affiliation, assistance, type belonging and service. Through manual assisted review, use entity relationships to construct a triple set, and use Neo4J to store and build a knowledge graph in the field of demands.
[0070] Step 2: Obtain the request work order data, encode and vectorize each request work order data, and build a work order vector index library.
[0071] In step 2, build the work order vector index library:
[0072] Collect relevant data in the field of appeals, clean text data, remove web page tags, irrelevant characters, etc. The data mainly consists of public appeal work orders handled by government departments. The work orders are in the form of question-answer pairs, so there is no need to perform additional segmentation on the data. After using the word segmentation tool to segment the work order, use BERT to encode and vectorize each work order to obtain the feature representation set of the vector. Due to the large amount of work order data, the LSH index suitable for large-scale data in the FAISS index type is selected, and the index object is created using the API of the FAISS library. Use the add method of FAISS to add the vector to the index and train the index so that it can quickly find the most similar work order data.
[0073] Step 3: Based on the demand domain data, annotate to construct a demand domain question and answer dataset, and use the domain question and answer dataset to fine-tune the pre-trained large model.
[0074] In step 3, fine-tune the large model using the demand domain data:
[0075] After the above two steps of preprocessing, the demand domain data (i.e., cleaning text data, removing web page tags, irrelevant characters, etc.) is manually annotated by experts to form question-answer pairs and construct a domain fine-tuned question-answering dataset. Select a suitable generative large model according to the needs to ensure that the model can process natural language text and has sufficient context understanding capabilities. Use the demand domain question-answering dataset to supervise and fine-tune the large model so that it can learn professional knowledge in the demand domain and initially adapt to the question types and language characteristics in this field.
[0076] Step 4: obtain the question, extract the entity relationship in the question, use the knowledge graph of the demand domain to infer the potential entity relationship, and construct potential relationship prompts.
[0077] In step 4, the knowledge reasoning model is used to infer the potential relationship:
[0078] For the knowledge graph, when the user enters a question, the BERT-BI LSTM-CRF model is first used to extract the entities and relationships in the question and input them into the demand knowledge graph. Combined with the knowledge reasoning model, the possible potential relationships are inferred and discovered. Using the defined prompt template, they are constructed as potential relationship prompts for the input of subsequent large models.
[0079] The knowledge reasoning model combines heterogeneous graph neural network and Bert pre-training model. Specifically, in order to obtain the vector representation of entities and relationships, the Bert pre-training model is first used to initialize the vectors of relationships and entities. Then, based on the HGT framework, the RHGT model is designed to learn the entity (node) and relationship (edge) vectors in the knowledge graph. For the lth layer in RHGT, its operation on the demand knowledge graph can be expressed as:
[0080]
[0081] in, For node v j The lth layer of i and v j are adjacent nodes, For node v j The l-1th layer of For node v i The l-1th layer of is the relationship representation of adjacent nodes in the lth layer, is the relationship representation of adjacent nodes in the l-1th layer, Aggregate() represents the aggregation function, Att() is the weight calculation function between nodes, and Msg() is the message passing function.
[0082] In order to describe in detail the working principle of the knowledge reasoning model, the triples in the knowledge graph are used. i ,e,v j > As a meta-relation, this indicates that the head entity v i and tail entity v j There is a relationship e between them. In order to calculate the attention between entities, we first use the Bert pre-trained model to initialize the entity and relationship vectors, and then set the weight matrix W for each type of entity and relationship. t(v) and W r(e) ,In this way, we can pay attention to the feature distribution of different ,types of entities and relations.
[0083] After the vector is initialized, it is necessary to obtain low-dimensional representations of entities and relations. Inspired by Transformer, a multi-head attention is designed to learn the weights and message passing of meta-relations from multiple perspectives. Given a triplet <v i ,e,v j >, the method for calculating attention weight is as follows:
[0084]
[0085] Among them, ATT_head() is the multi-head attention calculation function, m is the number of attention heads, and n is the sequence number of the attention head; and Respectively represent the node v i and node v j The query vector and key vector in the nth attention head; d is the dimension size of the vector embedding; Indicates all with v j connected nodes; is a tensor representing the meta-relation feature, softmax represents the normalization function, Represents the learnable parameter matrix when the relationship type is r(e), Represents node v j The type of the linear layer corresponding to the nth attention head, t(v j ) represents node v j Type;
[0086] After obtaining the attention weight of the meta-relation, it is necessary to complete the message passing from the head entity to the tail entity. In this process, the type of relationship needs to be considered to reduce the distribution differences between heterogeneous nodes and relationships. The message passing principle for calculating this process is as follows:
[0087]
[0088] in, is the linear projection of the message passing entity in the nth attention head, is the learnable weight matrix, t(v j ) represents node v j Type;
[0089] Finally, information aggregation is to obtain a low-dimensional representation of entities and relationships by calculating multi-head attention weights and message passing for all adjacent entities of the target entity and then aggregating them. The process is as follows:
[0090]
[0091] in, is the update vector obtained at layer l, W r is a learnable relation type weight matrix, which updates the vector After ReLU activation and residual connection, Perform linear projection and compare it with the entity v in the previous layer i The representation vector Add as the final output vector representation of the current layer Relation vector representation The update is achieved through matrix transformation, and σ is the ReLU activation function.
[0092] By combining multiple layers of the above methods to complete the convolution operation of the demand knowledge graph, we can obtain the graph representation of the demand knowledge graph. On this basis, we complete the triples in the demand knowledge graph to realize knowledge reasoning.
[0093] Step 5: vectorize the problem encoding, use the work order vector index library to retrieve similar work orders, and construct similar problem prompts based on the retrieved similar work orders.
[0094] In step 5, build similar ticket prompts:
[0095] For the ticket vector index library, after the user enters the question, the word segmentation tool is used to segment the question, and then BERT is used to encode and vectorize it to obtain the query vector. The maximum inner product search method is used to retrieve the top-k most similar vector indexes, and the corresponding similar ticket text is returned based on the position information attached to the vector index. The defined prompt template is used to construct it into a similar ticket prompt for the input of the subsequent large model.
[0096] Step 6: Input the potential relationship prompts, similar question prompts and questions into the fine-tuned large model at the same time to generate answers.
[0097] In step 6, the potential relationship hints and similar question hints are input into the fine-tuned large model together with the question, and the large model infers and generates accurate answers:
[0098] Design a comprehensive prompt template: {"Now that you are an expert in the field of government affairs appeals, please refer to the following similar work orders: {similar work orders}, and combine the following partial answers: {potential relationship}, answer the question: {the question entered by the user}"}. For the constructed potential relationship prompts and similar work order prompts, add the user's question and fill in the comprehensive prompt template in the form of string concatenation. Input it into the large model after domain fine-tuning. The background prompt can provide additional contextual information for the large model and guide the large model to infer and generate accurate responses.
[0099] In summary, the intelligent question-answering model constructed in the embodiment of the present invention has at least the following characteristics compared with the traditional question-answering model:
[0100] (1) Constructing a knowledge graph in the field of demands: Collect professional data in the field of demands and perform preprocessing such as data cleaning. Use the entity-relationship joint extraction model BERT-BI LSTM-CRF to extract entities and relationships in the data. After manual screening, five entities are obtained: problem classification, joint processing unit, business supervisory unit, service object, and item type. Six relationships are mainly management, joint processing, affiliation, assistance, type belonging, and service. In this way, a set of entity-relationship-entity triples is constructed, and the triple set is used to construct a knowledge graph in the field of demands;
[0101] (2) Constructing a work order vector index library: Collect a large amount of public demand work order data, perform data cleaning and other preprocessing, and remove special symbols such as web page tags. Use the BERT model to encode and vectorize each processed work order data to obtain a feature representation set of the work order data. Perform a whitening operation on the semantic vector to reduce the correlation between features, and use the local sensitive hashing algorithm to construct a work order vector index library for the reduced dimensionality semantic vector. Vectors similar to the query vector can be quickly found through similarity search.
[0102] (3) Fine-tune the large model using the data in the field of demands: Using the collected data in the field of demands, experts annotate large-scale question-and-answer data to describe <question, answer> pairs, forming a question-and-answer dataset in the field of demands. Use the field question-and-answer dataset to fine-tune the pre-trained large language model, inject domain expertise, and enable it to initially have the ability to answer questions related to public demands.
[0103] (4) Constructing potential relationship prompts: The entity relationship joint extraction model BERT-BILSTM-CRF is used to extract entities and relationships in user questions. A knowledge reasoning model based on knowledge graph representation is designed. This model combines heterogeneous graph neural network and Bert pre-training model to realize the reasoning of potential relationships in requests. The entity relationships extracted from user questions are reasoned using knowledge graphs to obtain possible potential relationships. Based on the designed prompt templates and the reasoning results of the knowledge graph, potential relationship prompts are constructed as part of the subsequent large model input.
[0104] (5) Construct similar work order prompts: Use the BERT model to encode and vectorize user questions to obtain user question vectors. Based on the maximum inner product search method, calculate the vector index with the largest inner product with the question vector, which is the vector with the highest similarity. Obtain the corresponding work order text through the retrieved vector index. Based on the designed prompt template and the retrieved work order, construct similar work order prompts as part of the subsequent large model input.
[0105] (6) Generate answers through reasoning using the big model: Use the preset prompt template to combine the potential relationship prompt and the similar question prompt as a comprehensive background knowledge prompt. The comprehensive background knowledge prompt and the user question are input into the domain-fine-tuned big model to guide the big model to generate accurate answers.
[0106] The embodiment of the present invention also provides a device for constructing a large model of intelligent question and answer. Figure 3 As shown, the device includes an input module, a knowledge graph module, a similar work order retrieval module, a prompt construction module and an answer module, wherein the input module is used to obtain the user's questions and input them into the knowledge graph module, the similar work order retrieval module and the prompt construction module respectively. The knowledge graph module is a knowledge graph constructed based on the data in the field of demands. According to the user's questions, the entity relationships therein are extracted and the potential relationships that may exist are inferred. The similar work order retrieval module is a work order vector index library constructed based on the work order data of public demands. By encoding the user's questions into vectors, similar work orders can be quickly retrieved. The prompt construction module constructs potential relationships and similar work orders into comprehensive prompts based on pre-defined prompt templates and merges them with user questions as the input of the model. The answer module applies a fine-tuned large model, combines background knowledge to synthesize prompts and questions, and infers and predicts answers.
[0107] Specifically, each module can be configured to implement the following functions:
[0108] An input module is configured to obtain demand domain data, question and demand ticket data, and feed them to the knowledge graph module, the similar ticket retrieval module and the prompt construction module respectively;
[0109] A knowledge graph module is configured to extract entity relationships existing in the demand domain data, construct a demand domain knowledge graph, extract entity relationships in the question, use the demand domain knowledge graph to infer potential entity relationships, and construct potential relationship prompts;
[0110] The similar work order retrieval module is configured to encode and vectorize each work order data and build a work order vector index library;
[0111] A prompt construction module is configured to vectorize the problem encoding, retrieve similar work orders using the work order vector index library, construct similar problem prompts based on the retrieved similar work orders, and simultaneously input the potential relationship prompts, similar problem prompts and the problems into the fine-tuned large model;
[0112] The answer module is configured to perform annotation based on the demand domain data to construct a demand domain question and answer dataset, and use the domain question and answer dataset to fine-tune the pre-trained large model.
[0113] In some embodiments, the knowledge graph module is further configured to:
[0114] Convert the demand domain data into text data, extract entity relationships in the text data, wherein the entity relationships include multiple entities and multiple relationships, and there is at least one relationship between two entities. The multiple entities include at least five entities: joint processing unit, business supervisory unit, service object, and matter type. The multiple relationships include at least six relationships: main management, joint processing, subordinate to, assist, type belonging to, and service.
[0115] The entity relationships are used to construct a triple set to obtain a knowledge graph of the demand domain.
[0116] In some embodiments, the similar work order retrieval module is further configured to:
[0117] After word segmentation of the request work order data using a word segmentation tool, encoding and vectorizing each request work order data is performed to obtain a vector feature representation set of the request work order data, wherein the vector feature representation set includes a vector feature representation corresponding to the request work order data;
[0118] Based on the LSH index, create an index object using the API of the FAISS library;
[0119] The vector feature representation is added to an index object.
[0120] In some embodiments, the answer module is further configured to:
[0121] Based on the demand domain data, after annotation, a plurality of question-answer pairs are formed, and a demand domain question-answer data set is constructed through the plurality of question-answer pairs.
[0122] In some embodiments, the knowledge graph module is further configured to:
[0123] Entities and relationships in the question are extracted and input into the knowledge graph of the demand domain. Potential relationships are determined by combining with the knowledge reasoning model, and potential relationship prompts are generated using the set prompt template.
[0124] In some embodiments, the knowledge graph module is further configured to:
[0125] Initialize the vectors of the relations and entities in the question, and use the RHGT model to learn the nodes and edges in the knowledge graph of the demand domain, where the nodes and edges correspond to entities and relations respectively;
[0126] The operation of the lth layer in the RHGT model T on the demand domain knowledge graph is expressed as:
[0127]
[0128] in, For node v j The lth layer of i and v j are adjacent nodes, For node v j The l-1th layer of For node v i The l-1th layer of is the relationship representation of adjacent nodes in the lth layer, is the relationship representation of adjacent nodes in the l-1th layer, Aggregate() represents the aggregation function, Att() is the weight calculation function between nodes, and Msg() is the message passing function;
[0129] The triple in the demand domain knowledge graph <v i ,e,v j > as a meta-relation, where e represents the node v i and node v j relationship;
[0130] Set weight matrices for each type of entity and relationship;
[0131] Multi-head attention is designed to learn the weights and message passing of meta-relationships from multiple perspectives. The method for calculating attention weights is as follows:
[0132]
[0133] Among them, ATT_head() is the multi-head attention calculation function, m is the number of attention heads, and n is the sequence number of the attention head; and Respectively represent the node v i and node v j The query vector and key vector in the nth attention head; d is the dimension size of the vector embedding; Indicates all with v j connected nodes; is a tensor representing the meta-relation feature, softmax represents the normalization function, Represents the learnable parameter matrix when the relationship type is r(e), Represents node v j The type of the linear layer corresponding to the nth attention head, t(v j ) represents node v j Type;
[0134] After obtaining the attention weight of the meta-relation, the message passing from the head entity to the tail entity is completed by the following formula:
[0135]
[0136] in, is the linear projection of the message passing entity in the nth attention head, is the learnable weight matrix, t(v j ) represents node v j Type;
[0137] The low-dimensional representation of entities and relationships is obtained by calculating the multi-head attention weights and message passing for all adjacent entities of the target entity and then aggregating them. The process is as follows:
[0138]
[0139] in, is the update vector obtained at layer l, W r is a learnable relation type weight matrix, which updates the vector After ReLU activation and residual connection, Perform linear projection and compare it with the entity v in the previous layer i The representation vector Add as the final output vector representation of the current layer Relation vector representation The update is achieved through matrix transformation, and σ is the ReLU activation function.
[0140] In some embodiments, the prompt building module is further configured to:
[0141] Use the word segmentation tool to segment the question, encode and vectorize the segmented question to obtain the query vector;
[0142] Based on the maximum inner product search method, the top-k vector indexes are retrieved, and the corresponding similar work order texts are returned according to the position information attached to the vector indexes;
[0143] The returned similar work order texts are constructed into similar work order prompts using the set prompt template.
[0144] In some embodiments, the input module is further configured to:
[0145] Constructing a comprehensive prompt template, and filling the potential relationship prompt, similar problem prompt and problem into the comprehensive prompt template;
[0146] The completed comprehensive prompt template is fed into the fine-tuned large model to generate an answer.
[0147] It should be noted that the various device structures described in this embodiment belong to the same technical concept as the previously described method, and achieve the same technical effect through the same principle, which will not be repeated here.
[0148] An embodiment of the present invention further provides a readable storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the method described in any of the above embodiments.
[0149] In addition, although exemplary embodiments have been described herein, the scope includes any and all embodiments based on the present invention with equivalent elements, modifications, omissions, combinations (e.g., various embodiments intersecting schemes), adaptations or changes. The elements in the claims will be interpreted broadly based on the language adopted in the claims, and are not limited to the examples described in this specification or during the implementation of this application, and the examples will be interpreted as non-exclusive. Therefore, this specification and examples are intended to be considered as examples only, and the true scope and spirit are indicated by the following claims and the full scope of their equivalents.
[0150] The above description is intended to be illustrative rather than restrictive. For example, the above examples (or one or more of them) can be used in combination with each other. For example, those of ordinary skill in the art can use other embodiments when reading the above description. In addition, in the above-mentioned specific embodiments, various features can be grouped together to simplify the present invention. This should not be interpreted as a feature of an invention that is not claimed for protection being necessary for any claim. On the contrary, the subject matter of the present invention may be less than all the features of the embodiments of a specific invention. Thus, the following claims are incorporated into the specific embodiments as examples or embodiments, wherein each claim is independently used as a separate embodiment, and it is considered that these embodiments can be combined with each other in various combinations or arrangements. The scope of the present invention should be determined with reference to the full scope of the equivalent forms of the attached claims and these claims.
Claims
1. A method for constructing a large model of intelligent question answering, characterized in that: The method comprises: Acquire demand domain data, extract entity relationships existing in the demand domain data, and construct a demand domain knowledge graph; Obtain the request work order data, encode and vectorize each request work order data, and build a work order vector index library; Based on the demand domain data, annotation is performed to construct a demand domain question-answering dataset, and the domain question-answering dataset is used to fine-tune the pre-trained large model; Obtaining questions, extracting entity relationships in the questions, inferring potential entity relationships using the knowledge graph of the demand domain, and constructing potential relationship prompts; Vectorize the problem encoding, use the ticket vector index library to retrieve similar tickets, and build similar problem prompts based on the retrieved similar tickets; The potential relationship prompts, similar question prompts and questions are simultaneously input into the fine-tuned large model to generate answers.
2. The method according to claim 1, characterized in that Obtaining demand domain data, extracting entity relationships in the demand domain data, and constructing a demand domain knowledge graph, specifically including: Convert the demand domain data into text data, extract entity relationships in the text data, wherein the entity relationships include multiple entities and multiple relationships, and there is at least one relationship between two entities. The multiple entities include at least five entities: joint processing unit, business supervisory unit, service object, and matter type. The multiple relationships include at least six relationships: main management, joint processing, subordinate to, assist, type belonging to, and service. The entity relationships are used to construct a triple set to obtain a knowledge graph of the demand domain.
3. The method according to claim 1, characterized in that Obtain the request work order data, encode and vectorize each request work order data, and build a work order vector index library, including: After word segmentation of the request work order data using a word segmentation tool, encoding and vectorizing each request work order data is performed to obtain a vector feature representation set of the request work order data, wherein the vector feature representation set includes a vector feature representation corresponding to the request work order data; Based on the LSH index, create an index object using the API of the FAISS library; The vector feature representation is added to an index object.
4. The method according to claim 1, characterized in that: Based on the demand domain data, annotation is performed to construct a demand domain question-answering dataset, specifically including: Based on the demand domain data, after annotation, a plurality of question-answer pairs are formed, and a demand domain question-answer data set is constructed through the plurality of question-answer pairs.
5. The method according to claim 2, characterized in that: Obtain the question, extract the entity relationship in the question, use the knowledge graph of the demand domain to infer the potential entity relationship, and construct potential relationship prompts, specifically including: Entities and relationships in the question are extracted and input into the knowledge graph of the demand domain. Potential relationships are determined by combining with the knowledge reasoning model, and potential relationship prompts are generated using the set prompt template.
6. The method according to claim 5, characterized in that The knowledge reasoning model determines the potential relationship and generates potential relationship prompts using the set prompt template, including: Initialize the vectors of the relations and entities in the question, and use the RHGT model to learn the nodes and edges in the knowledge graph of the demand domain, where the nodes and edges correspond to entities and relations respectively; The operation of the lth layer in the RHGT model T on the demand domain knowledge graph is expressed as: in, For node v j The lth layer of i and v j are adjacent nodes, For node v j The l-1th layer of For node v i The l-1th layer of is the relationship representation of adjacent nodes in the lth layer, is the relationship representation of adjacent nodes in the l-1th layer, Aggregate() represents the aggregation function, Att() is the weight calculation function between nodes, and Msg() is the message passing function; The triple in the demand domain knowledge graph <v i ,e,v j > as a meta-relation, where e represents the node v i and node v j relationship; Set weight matrices for each type of entity and relationship; Multi-head attention is designed to learn the weights and message passing of meta-relationships from multiple perspectives. The method for calculating attention weights is as follows: Among them, ATT_head() is the multi-head attention calculation function, m is the number of attention heads, and n is the sequence number of the attention head; and Respectively represent the node v i and node v j The query vector and key vector in the nth attention head; d is the dimension size of the vector embedding; Indicates all with v j connected nodes; is a tensor representing the meta-relation feature, softmax represents the normalization function, Represents the learnable parameter matrix when the relationship type is r(e), Represents node v j The type of the linear layer corresponding to the nth attention head, t(v j ) represents node v j Type; After obtaining the attention weight of the meta-relation, the message passing from the head entity to the tail entity is completed by the following formula: in, is the linear projection of the message passing entity in the nth attention head, is the learnable weight matrix, t(v j ) represents node v j Type; By calculating the multi-head attention weights and message passing for all neighboring entities of the target entity and then aggregating them, a low-dimensional representation of entities and relationships is obtained. The process is as follows: in, is the update vector obtained at layer l, W r is a learnable relation type weight matrix, which updates the vector After ReLU activation and residual connection, Perform linear projection and compare it with the entity v in the previous layer i The representation vector Add as the final output vector representation of the current layer Relation vector representation The update is achieved through matrix transformation, and σ is the ReLU activation function.
7. The method according to claim 1, characterized in that Vectorize the problem encoding, use the ticket vector index library to retrieve similar tickets, and build similar problem prompts based on the retrieved similar tickets, including: Use the word segmentation tool to segment the question, encode and vectorize the segmented question to obtain the query vector; Based on the maximum inner product search method, the top-k vector indexes are retrieved, and the corresponding similar work order texts are returned according to the position information attached to the vector indexes; The returned similar work order texts are constructed into similar work order prompts using the set prompt template.
8. The method according to claim 1, characterized in that The potential relationship prompts, similar question prompts and questions are simultaneously input into the fine-tuned large model to generate answers, specifically including: Constructing a comprehensive prompt template, and filling the potential relationship prompt, similar problem prompt and problem into the comprehensive prompt template; The completed comprehensive prompt template is fed into the fine-tuned large model to generate an answer.
9. A device for constructing a large model of intelligent question and answer, characterized in that: The device comprises: An input module is configured to obtain demand domain data, question and demand ticket data, and feed them to the knowledge graph module, the similar ticket retrieval module and the prompt construction module respectively; A knowledge graph module is configured to extract entity relationships existing in the demand domain data, construct a demand domain knowledge graph, extract entity relationships in the question, use the demand domain knowledge graph to infer potential entity relationships, and construct potential relationship prompts; The similar work order retrieval module is configured to encode and vectorize each work order data and build a work order vector index library; A prompt construction module is configured to vectorize the problem encoding, retrieve similar work orders using the work order vector index library, construct similar problem prompts based on the retrieved similar work orders, and simultaneously input the potential relationship prompts, similar problem prompts and the problems into the fine-tuned large model; The answer module is configured to perform annotation based on the demand domain data to construct a demand domain question and answer dataset, and use the domain question and answer dataset to fine-tune the pre-trained large model. 10 . A non-transitory computer-readable storage medium storing instructions, which, when executed by a processor, perform the method according to claim 1 .
Citation Information
Patent Citations
Knowledge retrieval enhancement-based large language model question and answer method and device
CN118113836A
Cited By
Knowledge graph-based Hash government affair service vertical domain large model construction method and system
CN119721131A
Government affair work order structured extraction method, device and equipment
CN122412499A
A government affair work order structured extraction method, device and equipment
CN122412499B
