Question answering method, system, device and medium based on knowledge graph in specific fields
By constructing a domain-specific knowledge graph and predictive relationship path, the existing question-and-answer system answers accuracy and comprehensiveness in a specific domain, achieving more robust and accurate domain-specific knowledge Q&A.
Patent Information
- Application Number
- CN202411388659.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-08
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2044-10-08
AI Technical Summary
Existing Q&A systems have poor accuracy and comprehensiveness in generating answers in specific fields, especially when dealing with multi-hop reasoning.
By building a knowledge graph of the target field, predicting the number of multiple hops and relationship paths of user questions, generating initial inference link paths, and fine-tuning of multiple instructions and large language models to generate candidate answers, and finally selecting the final answers through voting.
It improves the accuracy and comprehensiveness of Q&A in specific fields, enhances the robustness of model output, can better adapt to the knowledge graph in specific fields, and improves the comprehensiveness and accuracy of Q&A in specific fields.
Smart Images

Figure CN118897886B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a question-answering method, system, device and medium based on a knowledge graph in a specific field. Background Art
[0002] In recent years, large language models (LLMs) have demonstrated excellent performance in question-answering and reasoning tasks, and their application scope has expanded to specific fields such as finance, law, and medicine. However, since LLMs usually lack knowledge in specific fields, misleading and erroneous information may be fed back to users asking questions in question-answering systems. Existing technologies generally combine knowledge graphs in specific fields with LLMs to build question-answering systems that can answer questions in specific fields. However, since LLMs trained in open domains are difficult to directly migrate to specific fields, and current question-answering systems are not perfect in handling questions that require multi-hop reasoning, the accuracy and comprehensiveness of answers generated by existing question-answering systems are poor. Summary of the invention
[0003] To solve the above technical problems, the present invention provides a question-answering method, system, device and medium based on a knowledge graph in a specific field, which improves the accuracy and comprehensiveness of question-answering in a specific field.
[0004] The embodiment of the present invention provides a question-answering method based on a specific domain knowledge graph, including:
[0005] Acquire data in the target field and build a knowledge graph;
[0006] Obtain the question input by the user, predict the number of multi-hops of the question on the knowledge graph, and obtain the corresponding number of hops;
[0007] If the hop count is not zero, predicting the relationship path corresponding to the question based on the knowledge graph and the hop count to construct an initial reasoning chain path for the question;
[0008] According to the preset filtering rules, the initial reasoning chain path is modified, and the modified initial reasoning chain path is converted into a natural language form to obtain a final reasoning chain path;
[0009] Acquire multiple preset instructions, respectively splice each instruction with the reasoning chain path and the question to obtain multiple splicing data, and generate multiple candidate answers according to the splicing data; wherein different instructions are set with different specific contents, and the instructions are all used to associate the question and answer with the reasoning chain path;
[0010] Voting is performed on the multiple candidate answers, and the candidate answer with the largest number of votes is returned to the user as the answer to the question.
[0011] As an improvement of the above solution, the step of acquiring data in the target field and constructing a knowledge graph includes:
[0012] Acquire data in a target field, and perform data cleaning and text length standardization on the data in the target field to obtain a first data set;
[0013] Extracting a number of data from the first data set as a second data set; preliminarily extracting knowledge triples from the second data set to obtain a first knowledge triple set, so as to check and supplement the first knowledge triple set to obtain a first training data set; wherein the knowledge triple consists of a head entity, a relationship, and a tail entity;
[0014] Based on the first training data set, fine-tuning the basic large language model to obtain a knowledge extraction model;
[0015] The first data set is input into the knowledge extraction model to obtain a second knowledge triple set corresponding to the first data set; according to preset rules, the erroneous information in the second knowledge triple set is eliminated to obtain a third knowledge triple set; entities with the same concepts are screened out in the third knowledge triple set, and the knowledge triples corresponding to the entities with the same concepts are merged to obtain a fourth knowledge triple set to form a knowledge graph of the target field.
[0016] As an improvement of the above solution, predicting the number of multi-hops of the question on the knowledge graph to obtain the corresponding number of hops includes:
[0017] Input the problem into a preset hop count prediction model to obtain a confidence distribution of the hop count output by the model, and use the hop count corresponding to the maximum confidence value in the confidence distribution as the hop count corresponding to the problem;
[0018] The training method of the hop count prediction model includes:
[0019] Acquire a number of first questions unrelated to the target domain and their hop count labels, and a number of second questions related to the target domain and their hop count labels, to form a second training data set; wherein the hop count labels of the first questions are all 0;
[0020] A pre-trained BERT model is obtained, and based on the second training data set, the BERT model is trained again to obtain the hop count prediction model.
[0021] As an improvement of the above solution, predicting the relationship path corresponding to the problem based on the knowledge graph and the number of hops to construct an initial reasoning chain path for the problem includes:
[0022] Extracting entities in the question to obtain question entities;
[0023] Taking the number of hops as the prediction round of the relationship path, several rounds of prediction are performed on the relationship path corresponding to the question to obtain a set of relationship paths in the last round; in each round of prediction, each relationship path in the relationship path set obtained in the previous round is spliced with the problem entity to obtain several input data, and the input data are respectively input into the relationship prediction model based on the knowledge graph to predict the relationship between entities to obtain corresponding relationship sets; each relationship in each relationship set is spliced to the relationship path of the previous round corresponding to the relationship set to obtain the relationship path set of the current round; wherein, in the first round of prediction, the input of the relationship prediction model is the spliced data of the question and the problem entity;
[0024] Optimizing the number of relationship paths for the relationship path set of the last round to obtain an optimized relationship path set;
[0025] According to the problem entity and each relational path in the optimized relational path set, the corresponding knowledge triples are queried and extracted in the knowledge graph, and an initial reasoning chain path consisting of a number of knowledge triples corresponding to each relational path is constructed.
[0026] As an improvement of the above solution, the input data is respectively input into the relationship prediction model based on the knowledge graph to predict the relationship between entities, and the corresponding relationship sets are obtained respectively, including:
[0027] Input the input data into the relationship prediction model based on the knowledge graph, respectively, obtain the confidence distribution of all the relationships in the knowledge graph under the condition of the input data output by the model, and select several relationships corresponding to the confidences greater than a preset threshold in the confidence distribution to obtain a relationship set corresponding to the input data;
[0028] Then, the number of relationship paths is optimized for the relationship path set of the last round to obtain an optimized relationship path set, including:
[0029] In the relationship path set of the last round, the score of each relationship path is calculated according to the confidence of the relationship included in the relationship path;
[0030] A preset number of relationship paths are selected in descending order of the scores to obtain an optimized relationship path set.
[0031] As an improvement of the above solution, the preset filtering rules include:
[0032] Screening and deleting the path where the knowledge triples with missing entities are located in the initial reasoning chain path;
[0033] The repeated paths in the initial reasoning chain path are screened and deleted.
[0034] As an improvement of the above solution, the generating of multiple candidate answers according to the spliced data includes:
[0035] Input each concatenated data into a preset large language model to obtain a candidate answer corresponding to each concatenated data;
[0036] The training method of the preset large language model includes:
[0037] Obtaining a number of third questions and their answer labels, as well as historical reasoning chain paths corresponding to the third questions;
[0038] Obtain the preset multiple instructions, and respectively concatenate each instruction, the third question, and the corresponding historical reasoning chain path as third training data to obtain a third training data set;
[0039] Based on the third training data set, the basic large language model is fine-tuned to obtain the preset large language model.
[0040] The embodiment of the present invention also provides a question-answering system based on a specific domain knowledge graph, including:
[0041] The knowledge graph construction module is used to obtain data in the target field and construct a knowledge graph;
[0042] A multi-hop prediction module is used to obtain a question input by a user, predict the multi-hop number of the question on the knowledge graph, and obtain the corresponding number of hops;
[0043] A reasoning path construction module, configured to predict the relationship path corresponding to the question based on the knowledge graph and the number of hops if the number of hops is not zero, so as to construct an initial reasoning chain path for the question;
[0044] A reasoning path optimization module, used to modify the initial reasoning chain path according to a preset filtering rule, and convert the modified initial reasoning chain path into a natural language form to obtain a final reasoning chain path;
[0045] A candidate answer generation module is used to obtain a plurality of preset instructions, respectively splice each instruction with the reasoning chain path and the question to obtain a plurality of spliced data, and generate a plurality of candidate answers according to the spliced data; wherein different instructions are provided with different specific contents, and the instructions are all used to associate the question and answer with the reasoning chain path;
[0046] The question answer output module is used to vote on the multiple candidate answers and return the candidate answer with the largest number of votes as the answer to the question to the user.
[0047] An embodiment of the present invention also provides a question-answering device based on a knowledge graph for a specific domain, comprising a processor and a memory, wherein a computer program is stored in the memory, and the computer program is configured to be executed by the processor, and when the processor executes the computer program, it implements any of the above-mentioned question-answering methods based on a knowledge graph for a specific domain.
[0048] An embodiment of the present invention also provides a computer-readable storage medium, which stores a computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute any of the above-mentioned question-answering methods based on a specific domain knowledge graph.
[0049] Compared with the prior art, the question-answering method, system, device and medium based on a domain-specific knowledge graph provided by the embodiments of the present invention have the following beneficial effects:
[0050] By constructing a knowledge graph in the target domain, the multi-hop count and relationship path prediction of the user-input question are first performed to construct an inference chain path, and then multiple candidate answers are generated based on the inference chain path, the question and multiple instructions, and then the final answer is voted and returned to the user, which enhances the robustness of the model output and achieves more accurate knowledge question and answer in a specific domain. When constructing the knowledge graph in the target domain, a part of the data is first extracted and its knowledge triples are extracted, and then the knowledge triples are further completed and used for fine-tuning the large language model, so as to obtain a knowledge extraction model with stronger extraction ability to extract knowledge triples and construct a more complete and comprehensive knowledge graph. By training the hop count prediction model and the relationship prediction model, the relationship of the next hop can be predicted based on the previous multi-hop relationship to form a relationship path set and an inference chain path, and a chain reasoning mechanism is introduced, which enhances the ability to handle multi-hop problems and improves the accuracy and comprehensiveness of question and answer. By fine-tuning the model using multiple instructions, the LLM can better adapt to the knowledge graph in a specific domain and improve the model's ability to learn and understand the knowledge graph in a specific domain. The embodiments of the present invention can automatically extract more comprehensive knowledge from the knowledge graph of the target field, improve efficiency, enhance the adaptability of LLM to the knowledge graph of a specific field, and improve the comprehensiveness and accuracy of knowledge questions and answers in a specific field. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 It is a flowchart of a question-answering method based on a knowledge graph in a specific field provided by an embodiment of the present invention;
[0052] Figure 2 It is a schematic diagram of a process of constructing a knowledge graph in a question-answering method based on a knowledge graph in a specific field provided by an embodiment of the present invention;
[0053] Figure 3 It is a flowchart of constructing a reasoning chain path in a question-answering method based on a specific domain knowledge graph provided by an embodiment of the present invention;
[0054] Figure 4 It is a schematic diagram of a process of generating answers in a question-answering method based on a specific domain knowledge graph provided by an embodiment of the present invention;
[0055] Figure 5 It is a structural diagram of a question-answering system based on a knowledge graph in a specific field provided by an embodiment of the present invention;
[0056] Figure 6 It is a structural diagram of a question-answering device based on a domain-specific knowledge graph provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0057] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0058] See also Figure 1 , Figure 1 1 is a flowchart of a question-answering method based on a domain-specific knowledge graph provided by an embodiment of the present invention. The question-answering method based on a domain-specific knowledge graph includes:
[0059] S1: Obtain data in the target domain and build a knowledge graph.
[0060] As one of the optional embodiments, the step of acquiring data in the target field and constructing a knowledge graph includes:
[0061] Acquire data in a target field, and perform data cleaning and text length standardization on the data in the target field to obtain a first data set;
[0062] Extracting a number of data from the first data set as a second data set; preliminarily extracting knowledge triples from the second data set to obtain a first knowledge triple set, so as to check and supplement the first knowledge triple set to obtain a first training data set; wherein the knowledge triple consists of a head entity, a relationship, and a tail entity;
[0063] Based on the first training data set, fine-tuning the basic large language model to obtain a knowledge extraction model;
[0064] The first data set is input into the knowledge extraction model to obtain a second knowledge triple set corresponding to the first data set; according to preset rules, the erroneous information in the second knowledge triple set is eliminated to obtain a third knowledge triple set; entities with the same concepts are screened out in the third knowledge triple set, and the knowledge triples corresponding to the entities with the same concepts are merged to obtain a fourth knowledge triple set to form a knowledge graph of the target field.
[0065] For details, please refer to Figure 2 , Figure 2 The following is a flow chart of constructing a knowledge graph in a question-answering method based on a knowledge graph in a specific field provided by an embodiment of the present invention. First, data in the target field is collected manually or by a web crawler. ,data Can be in PDF, Word or data table formats; Perform data preprocessing. Specifically, first Clean the data to get , and then use text interception to Each piece of data in Perform text length standardization, where the maximum length of the text is set to L, and finally obtain a set of texts whose length is not greater than L, i.e. the first data set , denoted as .
[0066] The specific process of data cleaning is as follows: first, use Python libraries such as PyPDF2, Python-docx and pandas to extract text data that meets the requirements from files of different formats; on this basis, perform preliminary data preprocessing, first delete irrelevant content, and then use a unified encoding method to encode all text data to prevent character parsing errors; finally, convert all encoded data into a unified CSV format for centralized processing.
[0067] Then, knowledge triples are extracted: First, from the first dataset Extract n data from the second dataset ; Use open source large language models LLM for extracting triples, such as TechGPT-7B model, to analyze the second dataset Perform zero-shot reasoning to obtain the first knowledge triple set ; Then for the first knowledge triple set Check the knowledge triples in the dataset and complete the missing triples due to incomplete LLM extraction to obtain the knowledge triple set for training. ,in Represents a set of supplementary knowledge triples, and then obtains the first training data set .in, is a set of sample data in the format of "text->knowledge triples", which includes , Represents text The corresponding knowledge triple set, s represents the head entity, r represents the relationship between the head entity and the tail entity, o represents the tail entity, and m represents the text The number of corresponding knowledge triples, each text The number m of corresponding knowledge triples is not necessarily equal, and the number m can be zero, one or more.
[0068] Furthermore, using the first training data set The open source large language model LLM for extracting triples is fine-tuned by LoRA to obtain the knowledge extraction model TR_LLM; the first dataset Input into the knowledge extraction model TR_LLM to perform the knowledge triple extraction task and obtain the second knowledge triple set .
[0069] Furthermore, the second knowledge triple set is eliminated according to the preset rules The error message in the third knowledge triple set is obtained ,Specifically, the preset rules include: deleting the results with incorrect output ,formats, such as triples with missing head entities, triples with missing ,head entities, etc.; deleting the results whose relations are not in the defined ,schema; deleting the results with the same head and tail entities.
[0070] Furthermore, the text embedding tool text2vec is used to embed the third knowledge triple set The head entity in is converted into a vector matrix ,in, is the vector corresponding to the head entity, for The number of head entities in the query; then calculate the cosine similarity between every two head entities, and determine whether the cosine similarity is not less than the preset similarity threshold , if the cosine similarity is not less than the preset similarity threshold ,Right now , it means that these two head entities are equivalent entities, and then their corresponding knowledge triple sets are merged to finally obtain the fourth knowledge triple set .
[0071] Further, use Cypher to transform the fourth knowledge triple set Save it to the Neo4j database to obtain the knowledge graph of the target field.
[0072] S2: Obtain the question input by the user, predict the number of multiple hops of the question on the knowledge graph, and obtain the corresponding number of hops.
[0073] As one of the optional embodiments, predicting the number of multiple hops of the question on the knowledge graph to obtain the corresponding number of hops includes:
[0074] Input the problem into a preset hop count prediction model to obtain a confidence distribution of the hop count output by the model, and use the hop count corresponding to the maximum confidence value in the confidence distribution as the hop count corresponding to the problem;
[0075] The training method of the hop count prediction model includes:
[0076] Acquire a number of first questions unrelated to the target domain and their hop count labels, and a number of second questions related to the target domain and their hop count labels, to form a second training data set; wherein the hop count labels of the first questions are all 0;
[0077] A pre-trained BERT model is obtained, and based on the second training data set, the BERT model is trained again to obtain the hop count prediction model.
[0078] Specifically, the problem of obtaining user input After that, the question Input the hop count prediction model H_BERT to predict the number of multi-hops and obtain a confidence distribution of the hop count. , the confidence distribution is ,in Indicates in the problem The number of hops under the condition The corresponding confidence level, , is the preset maximum number of hops, confidence distribution The sum of all confidences in is 1. Select the confidence distribution The maximum confidence in the problem Corresponding hop count prediction results .
[0079] In the training phase of the hop count prediction model, we first obtain an open source pre-trained BERT model, and then use the pre-annotated questions and actual hop counts as input and labels, and use the Adam optimizer and cross entropy loss function to perform secondary training on the BERT model to obtain the hop count prediction model H_BERT.
[0080] The training data of the hop count prediction model includes two categories. One category is the problem that is completely unrelated to the target domain, and the corresponding true value label of the hop count is set as , that is, the number of hops is 0; the other type is problems related to the target domain, and the true value label of the corresponding hop number is set to , , is the preset maximum hop count, represents the actual hop count, where the label is represented by a one-hot vector.
[0081] S3: If the number of hops is not zero, predicting the relationship path corresponding to the question based on the knowledge graph and the number of hops to construct an initial reasoning chain path for the question.
[0082] Specifically, when getting the problem Corresponding hop count prediction results Then, determine the hop count Is it 0? , then a prompt message is output to prompt the user to enter the question Not relevant to the target domain, so that the user can re-enter the question; if , then the problem The relationship path is predicted and the corresponding reasoning chain path is constructed to generate the corresponding answer. The relationship path is a sequential set of relationships.
[0083] As one of the optional embodiments, predicting the relationship path corresponding to the question based on the knowledge graph and the number of hops to construct an initial reasoning chain path for the question includes:
[0084] Extracting entities in the question to obtain question entities;
[0085] Taking the number of hops as the prediction round of the relationship path, several rounds of prediction are performed on the relationship path corresponding to the question to obtain a set of relationship paths in the last round; in each round of prediction, each relationship path in the relationship path set obtained in the previous round is spliced with the problem entity to obtain several input data, and the input data are respectively input into the relationship prediction model based on the knowledge graph to predict the relationship between entities to obtain corresponding relationship sets; each relationship in each relationship set is spliced to the relationship path of the previous round corresponding to the relationship set to obtain the relationship path set of the current round; wherein, in the first round of prediction, the input of the relationship prediction model is the spliced data of the question and the problem entity;
[0086] Optimizing the number of relationship paths for the relationship path set of the last round to obtain an optimized relationship path set;
[0087] According to the problem entity and each relational path in the optimized relational path set, the corresponding knowledge triples are queried and extracted in the knowledge graph, and an initial reasoning chain path consisting of a number of knowledge triples corresponding to each relational path is constructed.
[0088] As one of the optional embodiments, the input data is respectively input into the relationship prediction model based on the knowledge graph to predict the relationship between entities, and the corresponding relationship sets are obtained respectively, including:
[0089] Input the input data into the relationship prediction model based on the knowledge graph, respectively, obtain the confidence distribution of all the relationships in the knowledge graph under the condition of the input data output by the model, and select several relationships corresponding to the confidences greater than a preset threshold in the confidence distribution to obtain a relationship set corresponding to the input data;
[0090] Then, the number of relationship paths is optimized for the relationship path set of the last round to obtain an optimized relationship path set, including:
[0091] In the relationship path set of the last round, the score of each relationship path is calculated according to the confidence of the relationship included in the relationship path;
[0092] A preset number of relationship paths are selected in descending order of the scores to obtain an optimized relationship path set.
[0093] See also Figure 3 , Figure 3 It is a flowchart of constructing a reasoning chain path in a question-answering method based on a specific domain knowledge graph provided by an embodiment of the present invention.
[0094] Specifically, when the predicted hop count When For each step (i.e. each round) of prediction, M candidate relationship sets are selected by default.
[0095] exist When extracting the question Entities in the question ; Among them, the problem entity The extraction can use large language models, such as GLM, Llama3 and other models, by solving the problem After being concatenated with the prompt: "Please extract entities based on the above question", it is input into the large language model for zero-shot reasoning to obtain the question entity Then the question With the problem entity Separate with a comma and concatenate the two As the input of the relation prediction model R_BERT. The relation prediction model R_BERT outputs the confidence distribution of the relation ,in , In the given problem Under the condition of exist The confidence level at , is the total number of relations in the knowledge graph of the target domain. Finally, according to the confidence distribution of the relations , select the first M relationships in descending order of confidence as The relationship set ,exist The relationship path set Equivalent to a relation set .
[0096] exist When first obtain The relationship path set obtained when , the set includes relationship paths, where a relationship path is represented by ,in, Indicates The relationship path is Jump (i.e. rounds), , . The problem entity Respectively with the relationship path set Each relationship path in is concatenated as Input of the time relation prediction model R_BERT , Then, we use the relational prediction model R_BERT to predict each input Perform relationship prediction and obtain the corresponding confidence distribution of the relationship , Indicates that in a given Under the condition of exist The confidence level at , is the total number of relations in the knowledge graph of the target domain. Each relationship path in , we can get the corresponding confidence distribution of the relationship , select each The first M relationships in the order of confidence from high to low are used as the relationship path The corresponding Jump relationship set . Set the relationship Each relationship in is concatenated to the relationship path At the end of , specifically:
[0097] ;
[0098] in, , Indicates that the Jump (i.e. round) The relationship paths are respectively The relationship path set obtained by concatenating the M relationships obtained by jumping is Jump to get a total of A set of relationship paths . Further, The set of all relationship paths obtained by jumping Merge to get The corresponding relationship path set , specifically:
[0099]
[0100]
[0101] when Similarly, we get the relationship path set of the last round .
[0102] Furthermore, the relationship path set is calculated The score of each relationship path in , and a constant is preset , thus selecting the top ranked in descending order of scores Paths as the optimized relationship path set Among them, the calculation of the relationship path score is as follows: When , the relationship path set obtained The relationship path in , , its score The calculation formula is:
[0103]
[0104] in, For the The relationship path is Relationship between time jump selection confidence level.
[0105] It should be noted that the training method of the relationship prediction model R_BERT is similar to the training method of the hop count prediction model H_BERT. It is trained based on historical questions and their corresponding real relationship labels, and the specific process will not be repeated here.
[0106] Further, according to the obtained relationship path set and the problem entity , find the corresponding knowledge triples in the knowledge graph of the target domain, and then build the initial reasoning chain path. Specifically, for the relationship path set The Relationship Path ,in , is the total number of relationship paths, The relationship contained in is expressed as ,in, Indicates The relationship path is Jumping relationship, . The problem entity As the head entity, and according to the relationship in the relationship path, the corresponding tail entity is searched in the knowledge graph to obtain the knowledge triples, and then the reasoning chain path composed of the knowledge triples is obtained.
[0107] Specifically, when When The set of knowledge triples constructed by the first hop of the relationship path :
[0108] ;
[0109] in, , Indicates The relationship path is the relationship at the first hop, Indicates the first jump according to the problem entity And the relationship The first The tail entity, , Indicates the number of tail entities (also indicated by The number of tail entities can be zero, one, or multiple.
[0110] when When The relationship path is The knowledge triples constructed by jumping :
[0111]
[0112]
[0113] in, , , Indicated in Time jump according to entity And the relationship The set of knowledge triples obtained by querying in the knowledge graph, Indicates Time jump according to entity And the relationship The total number of knowledge triples obtained by querying in the knowledge graph. , , which is in The total number of knowledge triplets obtained during the time jump is .
[0114] when Similarly, we can get the knowledge triple set .
[0115] Further, the following connection rules are used to , , …, Connect to get The initial reasoning chain path corresponding to the relationship path , the connection rules are as follows:
[0116]
[0117]
[0118] Furthermore, for the relationship path set Each relationship path in , , perform the above operations, and then summarize the results to get the total initial reasoning chain path :
[0119]
[0120] in, Indicates The initial reasoning chain path corresponding to the relationship path, .
[0121] S4: According to a preset filtering rule, the initial reasoning chain path is modified, and the modified initial reasoning chain path is converted into a natural language form to obtain a final reasoning chain path.
[0122] Specifically, after the initial reasoning chain path is obtained, the path is verified and corrected to further ensure the correctness of the reasoning chain path.
[0123] As one of the optional embodiments, the preset filtering rules include:
[0124] Screening and deleting the path where the knowledge triples with missing entities are located in the initial reasoning chain path;
[0125] The repeated paths in the initial reasoning chain path are screened and deleted.
[0126] It should be noted that the filtering rules can be modified and set according to the actual application scenario and the output feedback of the actual model.
[0127] Furthermore, since the input accepted by LLM is in text format, the corrected reasoning chain path needs to be converted into natural text.
[0128] Specifically, an open-source large language model can be used for processing, and the prompt message "Please convert the following path consisting of triplets into natural text, and the triplets of each path are separated by the '|' symbol" and the data to be converted are used as input. After the large language model is inferred, the reasoning chain path in the form of natural text is obtained, that is, the final reasoning chain path .
[0129] For example, assume that an inference path is (China, capital, Beijing) (Beijing, area code, 010), which is converted into a natural text form as “(China, capital, Beijing) | (Beijing, area code, 010)”.
[0130] S5: Obtain multiple preset instructions, splice each instruction with the reasoning chain path and the question respectively to obtain multiple splicing data, and generate multiple candidate answers based on the splicing data; wherein different instructions are set with different specific contents, and the instructions are all used to associate questions and answers with the reasoning chain path.
[0131] As one of the optional embodiments, generating a plurality of candidate answers according to the spliced data includes:
[0132] Input each concatenated data into a preset large language model to obtain a candidate answer corresponding to each concatenated data;
[0133] The training method of the preset large language model includes:
[0134] Obtaining a number of third questions and their answer labels, as well as historical reasoning chain paths corresponding to the third questions;
[0135] Obtain the preset multiple instructions, and respectively concatenate each instruction, the third question, and the corresponding historical reasoning chain path as third training data to obtain a third training data set;
[0136] Based on the third training data set, the basic large language model is fine-tuned to obtain the preset large language model.
[0137] For details, please refer to Figure 4 , Figure 4 It is a flowchart of generating answers in a question-answering method based on a knowledge graph in a specific field provided by an embodiment of the present invention. In an embodiment of the present invention, LoRA fine-tuning is performed on open source LLMs, such as Llama3, ChatGLM6B, Baichuan, etc., to obtain LLM' (i.e., a preset large language model), and then the LLM' is used to generate answers. As an efficient fine-tuning under low resources, LoRA fine-tuning can increase LLM's understanding of facts in a specific field, thereby generating better answers.
[0138] Among them, multiple sets of instructions are preset To construct the third training data for LLM fine-tuning. Exemplarily, the design of the instruction can be = "Based on the above triple reasoning chain path, please answer:", = "Assuming you are an expert and you have the above knowledge, please answer the question: " etc. The specific expression of each instruction is different, but its function is similar. The embodiment of the present invention can enhance the accuracy of LLM in answering questions in the reasoning stage by designing multiple groups of instructions, and effectively prevent the wrong reasoning caused by a single instruction.
[0139] Specifically, when constructing the third training data set, first obtain the question (i.e., the third question) and the answer pair for training. , for each question and answer pair , set the preset command Each instruction in the problem is spliced into Earlier, we got the data set :
[0140]
[0141] Among them, + represents text concatenation, one is For data.
[0142] Based on the dataset According to the operations of steps S2 to S4 above, the third question is obtained. The corresponding reasoning chain path, and splice the reasoning chain path into the data set The third training data set is obtained :
[0143]
[0144]
[0145] in, For the problem The corresponding reasoning chain path set, .
[0146] Furthermore, after obtaining the fine-tuned LLM', it is used for system reasoning generation problem Specifically, the preset instructions , User Questions And the reasoning chain path After concatenation, the LLM's are input in sequence. One instruction can correspond to an input, and each input can get a candidate answer after LLM' reasoning. , and finally get the answer candidate set ,in , .
[0147] S6: Vote for the multiple candidate answers, and return the candidate answer with the largest number of votes to the user as the answer to the question.
[0148] Specifically, for I answers in the answer candidate set, the best candidate answer is selected by voting as the question The answer O is selected and returned to the user. Preferably, the answer selected is the answer with the largest number of identical answers.
[0149] The embodiment of the present invention constructs a knowledge graph of the target domain, first predicts the number of multi-hops and the relationship path of the question input by the user to construct an inference chain path, then generates multiple candidate answers based on the inference chain path, the question and multiple instructions, and then votes for the final answer and returns it to the user, thereby enhancing the robustness of the model output and achieving more accurate knowledge questions and answers in specific fields. When constructing the knowledge graph of the target domain, a part of the data is first extracted and its knowledge triples are extracted, and then the knowledge triples are further completed and used for fine-tuning the large language model, thereby obtaining a knowledge extraction model with stronger extraction ability to extract knowledge triples to construct a more complete and comprehensive knowledge graph. By training the hop prediction model and the relationship prediction model, the relationship of the next hop can be predicted according to the previous multi-hop relationship to form a relationship path set and an inference chain path, a chain reasoning mechanism is introduced, the ability to handle multi-hop problems is enhanced, and the accuracy and comprehensiveness of questions and answers are improved. By fine-tuning the model using multiple instructions, the LLM can better adapt to the knowledge graph of the specific domain, and the model's learning and understanding ability of the knowledge graph of the specific domain is improved. The embodiments of the present invention can automatically extract more comprehensive knowledge from the knowledge graph of the target field, improve efficiency, enhance the adaptability of LLM to the knowledge graph of a specific field, and improve the comprehensiveness and accuracy of knowledge questions and answers in a specific field.
[0150] Correspondingly, the present invention also provides a question-answering system based on a specific domain knowledge graph, which can implement all processes of the question-answering method based on a specific domain knowledge graph in the above-mentioned embodiment.
[0151] See also Figure 5 , Figure 5 : is a schematic diagram of the structure of a question-answering system based on a specific domain knowledge graph provided by an embodiment of the present invention. The question-answering system based on a specific domain knowledge graph includes:
[0152] A knowledge graph construction module 501 is used to obtain data in a target field and construct a knowledge graph;
[0153] The multi-hop number prediction module 502 is used to obtain the question input by the user, predict the multi-hop number of the question on the knowledge graph, and obtain the corresponding hop number;
[0154] A reasoning path construction module 503 is used to predict the relationship path corresponding to the question based on the knowledge graph and the hop number if the hop number is not zero, so as to construct an initial reasoning chain path for the question;
[0155] The reasoning path optimization module 504 is used to modify the initial reasoning chain path according to a preset filtering rule, and convert the modified initial reasoning chain path into a natural language form to obtain a final reasoning chain path;
[0156] The candidate answer generation module 505 is used to obtain a plurality of preset instructions, respectively splice each instruction with the reasoning chain path and the question to obtain a plurality of spliced data, and generate a plurality of candidate answers according to the spliced data; wherein different instructions are provided with different specific contents, and the instructions are all used to associate the question and answer with the reasoning chain path;
[0157] The question answer output module 506 is used to vote on the multiple candidate answers and return the candidate answer with the largest number of votes as the answer to the question to the user.
[0158] Preferably, the knowledge graph construction module 501 is specifically used for:
[0159] Acquire data in a target field, and perform data cleaning and text length standardization on the data in the target field to obtain a first data set;
[0160] Extracting a number of data from the first data set as a second data set; preliminarily extracting knowledge triples from the second data set to obtain a first knowledge triple set, so as to check and supplement the first knowledge triple set to obtain a first training data set; wherein the knowledge triple consists of a head entity, a relationship, and a tail entity;
[0161] Based on the first training data set, fine-tuning the basic large language model to obtain a knowledge extraction model;
[0162] The first data set is input into the knowledge extraction model to obtain a second knowledge triple set corresponding to the first data set; according to preset rules, the erroneous information in the second knowledge triple set is eliminated to obtain a third knowledge triple set; entities with the same concepts are screened out in the third knowledge triple set, and the knowledge triples corresponding to the entities with the same concepts are merged to obtain a fourth knowledge triple set to form a knowledge graph of the target field.
[0163] Preferably, the multi-hop number prediction module 502 is specifically used for:
[0164] Input the problem into a preset hop count prediction model to obtain a confidence distribution of the hop count output by the model, and use the hop count corresponding to the maximum confidence value in the confidence distribution as the hop count corresponding to the problem;
[0165] The training method of the hop count prediction model includes:
[0166] Acquire a number of first questions unrelated to the target domain and their hop count labels, and a number of second questions related to the target domain and their hop count labels, to form a second training data set; wherein the hop count labels of the first questions are all 0;
[0167] A pre-trained BERT model is obtained, and based on the second training data set, the BERT model is trained again to obtain the hop count prediction model.
[0168] Preferably, the reasoning path building module 503 is specifically used for:
[0169] Extracting entities in the question to obtain question entities;
[0170] Taking the number of hops as the prediction round of the relationship path, several rounds of prediction are performed on the relationship path corresponding to the question to obtain a set of relationship paths in the last round; in each round of prediction, each relationship path in the relationship path set obtained in the previous round is spliced with the problem entity to obtain several input data, and the input data are respectively input into the relationship prediction model based on the knowledge graph to predict the relationship between entities to obtain corresponding relationship sets; each relationship in each relationship set is spliced to the relationship path of the previous round corresponding to the relationship set to obtain the relationship path set of the current round; wherein, in the first round of prediction, the input of the relationship prediction model is the spliced data of the question and the problem entity;
[0171] Optimizing the number of relationship paths for the relationship path set of the last round to obtain an optimized relationship path set;
[0172] According to the problem entity and each relational path in the optimized relational path set, the corresponding knowledge triples are queried and extracted in the knowledge graph, and an initial reasoning chain path consisting of a number of knowledge triples corresponding to each relational path is constructed.
[0173] Preferably, the inputting of the input data into the relationship prediction model based on the knowledge graph to predict the relationship between entities, and obtaining the corresponding relationship sets respectively, includes:
[0174] Input the input data into the relationship prediction model based on the knowledge graph, respectively, obtain the confidence distribution of all the relationships in the knowledge graph under the condition of the input data output by the model, and select several relationships corresponding to the confidences greater than a preset threshold in the confidence distribution to obtain a relationship set corresponding to the input data;
[0175] Then, the number of relationship paths is optimized for the relationship path set of the last round to obtain an optimized relationship path set, including:
[0176] In the relationship path set of the last round, the score of each relationship path is calculated according to the confidence of the relationship included in the relationship path;
[0177] A preset number of relationship paths are selected in descending order of the scores to obtain an optimized relationship path set.
[0178] Preferably, the preset filtering rules include:
[0179] Screening and deleting the path where the knowledge triples with missing entities are located in the initial reasoning chain path;
[0180] The repeated paths in the initial reasoning chain path are screened and deleted.
[0181] Preferably, in the candidate answer generation module 505, generating a plurality of candidate answers according to the spliced data includes:
[0182] Input each concatenated data into a preset large language model to obtain a candidate answer corresponding to each concatenated data;
[0183] The training method of the preset large language model includes:
[0184] Obtaining a number of third questions and their answer labels, as well as historical reasoning chain paths corresponding to the third questions;
[0185] Obtain the preset multiple instructions, and respectively concatenate each instruction, the third question, and the corresponding historical reasoning chain path as third training data to obtain a third training data set;
[0186] Based on the third training data set, the basic large language model is fine-tuned to obtain the preset large language model.
[0187] In the specific implementation, the working principle, control process and technical effect of the question and answer system based on the specific domain knowledge graph provided by the embodiment of the present invention are the same as those of the question and answer method based on the specific domain knowledge graph in the above embodiment, and will not be repeated here.
[0188] See also Figure 6 , Figure 6 6 is a structural block diagram of a question-answering device based on a specific domain knowledge graph provided in an embodiment of the present application, and the question-answering device based on a specific domain knowledge graph includes: a processor 601, a memory 602, and a computer program stored in the memory 602 and executable on the processor 601. When the processor 601 executes the computer program, the steps in the above-mentioned question-answering method embodiment based on the specific domain knowledge graph are implemented. Alternatively, when the processor 601 executes the computer program, the functions of each module / unit in the above-mentioned system embodiments are implemented.
[0189] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory 602 and executed by the processor 601 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program in the question-answering device based on the domain-specific knowledge graph.
[0190] The question-answering device based on the domain-specific knowledge graph may include, but is not limited to, a processor 601 and a memory 602. Those skilled in the art will appreciate that the schematic diagram is merely an example of a question-answering device based on a domain-specific knowledge graph, and does not constitute a limitation on the question-answering device based on the domain-specific knowledge graph. The question-answering device may include more or fewer components than shown in the diagram, or may combine certain components, or different components. For example, the question-answering device based on the domain-specific knowledge graph may also include input and output devices, network access devices, buses, and the like.
[0191] The processor 601 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The processor 601 is the control center of the question-answering device based on the domain-specific knowledge graph, and uses various interfaces and lines to connect the various parts of the entire question-answering device based on the domain-specific knowledge graph.
[0192] The memory 602 can be used to store the computer program and / or module. The processor 601 implements various functions of the question-answering device based on the knowledge graph of a specific field by running or executing the computer program and / or module stored in the memory 602 and calling the data stored in the memory 602. The memory 602 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 602 can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0193] Wherein, if the module / unit integrated in the question-answering device based on the knowledge graph of a specific field 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 application 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. When the computer program is executed by the processor 601, the steps of the above-mentioned method embodiments can be implemented. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or system that can carry the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc.
[0194] An embodiment of the present invention also provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the question-answering method based on a specific domain knowledge graph as described in any of the above embodiments.
[0195] The beneficial effects of a question-answering method, system, device, and medium based on a domain-specific knowledge graph provided by an embodiment of the present invention are:
[0196] By constructing a knowledge graph in the target domain, the multi-hop count and relationship path prediction of the user-input question are first performed to construct an inference chain path, and then multiple candidate answers are generated based on the inference chain path, the question and multiple instructions, and then the final answer is voted and returned to the user, which enhances the robustness of the model output and achieves more accurate knowledge question and answer in a specific domain. When constructing the knowledge graph in the target domain, a part of the data is first extracted and its knowledge triples are extracted, and then the knowledge triples are further completed and used for fine-tuning the large language model, so as to obtain a knowledge extraction model with stronger extraction ability to extract knowledge triples and construct a more complete and comprehensive knowledge graph. By training the hop count prediction model and the relationship prediction model, the relationship of the next hop can be predicted based on the previous multi-hop relationship to form a relationship path set and an inference chain path, and a chain reasoning mechanism is introduced, which enhances the ability to handle multi-hop problems and improves the accuracy and comprehensiveness of question and answer. By fine-tuning the model using multiple instructions, the LLM can better adapt to the knowledge graph in a specific domain and improve the model's ability to learn and understand the knowledge graph in a specific domain. The embodiments of the present invention can automatically extract more comprehensive knowledge from the knowledge graph of the target field, improve efficiency, enhance the adaptability of LLM to the knowledge graph of a specific field, and improve the comprehensiveness and accuracy of knowledge questions and answers in a specific field.
[0197] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A question-answering method based on a domain-specific knowledge graph, characterized in that: include: Acquire data in the target field and build a knowledge graph; Obtain the question input by the user, predict the number of multi-hops of the question on the knowledge graph, and obtain the corresponding number of hops; If the hop count is not zero, predicting the relationship path corresponding to the question based on the knowledge graph and the hop count to construct an initial reasoning chain path for the question; According to the preset filtering rules, the initial reasoning chain path is modified, and the modified initial reasoning chain path is converted into a natural language form to obtain a final reasoning chain path; Acquire multiple preset instructions, respectively splice each instruction with the reasoning chain path and the question to obtain multiple splicing data, and generate multiple candidate answers according to the splicing data; wherein different instructions are set with different specific contents, and the instructions are all used to associate the question and answer with the reasoning chain path; Voting on the multiple candidate answers, and returning the candidate answer with the largest number of votes to the user as the answer to the question; The step of predicting the relationship path corresponding to the problem based on the knowledge graph and the number of hops to construct an initial reasoning chain path for the problem includes: Extracting entities in the question to obtain question entities; Taking the number of hops as the prediction round of the relationship path, several rounds of prediction are performed on the relationship path corresponding to the question to obtain a set of relationship paths in the last round; in each round of prediction, each relationship path in the relationship path set obtained in the previous round is spliced with the problem entity to obtain several input data, and the input data are respectively input into the relationship prediction model based on the knowledge graph to predict the relationship between entities to obtain corresponding relationship sets; each relationship in each relationship set is spliced to the relationship path of the previous round corresponding to the relationship set to obtain the relationship path set of the current round; wherein, in the first round of prediction, the input of the relationship prediction model is the spliced data of the question and the problem entity; Optimizing the number of relationship paths for the relationship path set of the last round to obtain an optimized relationship path set; According to the problem entity and each relational path in the optimized relational path set, query and extract corresponding knowledge triples in the knowledge graph, and construct an initial reasoning chain path consisting of a plurality of knowledge triples corresponding to each relational path; In the initial reasoning chain path, the tail entity of the first knowledge triple in two adjacent knowledge triples is the same as the head entity of the second knowledge triple; The step of generating a plurality of candidate answers according to the spliced data includes: Each concatenated data is input into a preset large language model to obtain a candidate answer corresponding to each concatenated data; each of the concatenated data includes a plurality of reasoning chain paths corresponding to the question.
2. The question-answering method based on a domain-specific knowledge graph as claimed in claim 1, characterized in that: The step of acquiring data in the target field and constructing a knowledge graph includes: Acquire data in a target field, and perform data cleaning and text length standardization on the data in the target field to obtain a first data set; Extracting a number of data from the first data set as a second data set; preliminarily extracting knowledge triples from the second data set to obtain a first knowledge triple set, so as to check and supplement the first knowledge triple set to obtain a first training data set; wherein the knowledge triple consists of a head entity, a relationship, and a tail entity; Based on the first training data set, fine-tuning the basic large language model to obtain a knowledge extraction model; The first data set is input into the knowledge extraction model to obtain a second knowledge triple set corresponding to the first data set; according to preset rules, the erroneous information in the second knowledge triple set is eliminated to obtain a third knowledge triple set; entities with the same concepts are screened out in the third knowledge triple set, and the knowledge triples corresponding to the entities with the same concepts are merged to obtain a fourth knowledge triple set to form a knowledge graph of the target field.
3. The question-answering method based on a domain-specific knowledge graph as claimed in claim 1, characterized in that: The predicting the number of multiple hops of the question on the knowledge graph to obtain the corresponding number of hops includes: Input the problem into a preset hop count prediction model to obtain a confidence distribution of the hop count output by the model, and use the hop count corresponding to the maximum confidence value in the confidence distribution as the hop count corresponding to the problem; The training method of the hop count prediction model includes: Acquire a number of first questions unrelated to the target domain and their hop count labels, and a number of second questions related to the target domain and their hop count labels, to form a second training data set; wherein the hop count labels of the first questions are all 0; A pre-trained BERT model is obtained, and based on the second training data set, the BERT model is trained again to obtain the hop count prediction model.
4. The question-answering method based on a domain-specific knowledge graph according to claim 1, characterized in that: The input data are respectively input into the relationship prediction model based on the knowledge graph to predict the relationship between entities, and the corresponding relationship sets are obtained respectively, including: Input the input data into the relationship prediction model based on the knowledge graph, respectively, obtain the confidence distribution of all the relationships in the knowledge graph under the condition of the input data output by the model, and select several relationships corresponding to the confidences greater than a preset threshold in the confidence distribution to obtain a relationship set corresponding to the input data; Then, the number of relationship paths is optimized for the relationship path set of the last round to obtain an optimized relationship path set, including: In the relationship path set of the last round, the score of each relationship path is calculated according to the confidence of the relationship included in the relationship path; A preset number of relationship paths are selected in descending order of the scores to obtain an optimized relationship path set.
5. The question-answering method based on a domain-specific knowledge graph as claimed in claim 1, characterized in that: The preset filtering rules include: Screening and deleting the path where the knowledge triples with missing entities are located in the initial reasoning chain path; The repeated paths in the initial reasoning chain path are screened and deleted.
6. The question-answering method based on a domain-specific knowledge graph as claimed in claim 1, characterized in that: The training method of the preset large language model includes: Obtaining a number of third questions and their answer labels, as well as historical reasoning chain paths corresponding to the third questions; Obtain the preset multiple instructions, and respectively concatenate each instruction, the third question, and the corresponding historical reasoning chain path as third training data to obtain a third training data set; Based on the third training data set, the basic large language model is fine-tuned to obtain the preset large language model.
7. A question-answering system based on a domain-specific knowledge graph, characterized in that: include: The knowledge graph construction module is used to obtain data in the target field and construct a knowledge graph; A multi-hop number prediction module is used to obtain a question input by a user, predict the multi-hop number of the question on the knowledge graph, and obtain a corresponding number of hops; A reasoning path construction module, configured to predict the relationship path corresponding to the question based on the knowledge graph and the number of hops if the number of hops is not zero, so as to construct an initial reasoning chain path for the question; A reasoning path optimization module, used to modify the initial reasoning chain path according to a preset filtering rule, and convert the modified initial reasoning chain path into a natural language form to obtain a final reasoning chain path; A candidate answer generation module is used to obtain a plurality of preset instructions, respectively splice each instruction with the reasoning chain path and the question to obtain a plurality of spliced data, and generate a plurality of candidate answers according to the spliced data; wherein different instructions are provided with different specific contents, and the instructions are all used to associate the question and answer with the reasoning chain path; A question answer output module, used to vote on the multiple candidate answers, and return the candidate answer with the largest number of votes as the answer to the question to the user; The reasoning path building module is specifically used for: Extracting entities in the question to obtain question entities; Taking the number of hops as the prediction round of the relationship path, several rounds of prediction are performed on the relationship path corresponding to the question to obtain a set of relationship paths in the last round; in each round of prediction, each relationship path in the relationship path set obtained in the previous round is spliced with the problem entity to obtain several input data, and the input data are respectively input into the relationship prediction model based on the knowledge graph to predict the relationship between entities to obtain corresponding relationship sets; each relationship in each relationship set is spliced to the relationship path of the previous round corresponding to the relationship set to obtain the relationship path set of the current round; wherein, in the first round of prediction, the input of the relationship prediction model is the spliced data of the question and the problem entity; Optimizing the number of relationship paths for the relationship path set of the last round to obtain an optimized relationship path set; According to the problem entity and each relational path in the optimized relational path set, query and extract corresponding knowledge triples in the knowledge graph, and construct an initial reasoning chain path consisting of a plurality of knowledge triples corresponding to each relational path; In the initial reasoning chain path, the tail entity of the first knowledge triple in two adjacent knowledge triples is the same as the head entity of the second knowledge triple; The step of generating a plurality of candidate answers according to the spliced data includes: Each concatenated data is input into a preset large language model to obtain a candidate answer corresponding to each concatenated data; each of the concatenated data includes a plurality of reasoning chain paths corresponding to the question.
8. A question-answering device based on a domain-specific knowledge graph, characterized in that: It includes a processor and a memory, wherein a computer program is stored in the memory, and the computer program is configured to be executed by the processor, and when the processor executes the computer program, the question-answering method based on a specific domain knowledge graph as described in any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein when the device where the computer-readable storage medium is located executes the computer program, the question-answering method based on the specific domain knowledge graph as described in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Knowledge graph-based open domain question and answer method and related equipment
CN115470328A
Problem reasoning method and device, electronic equipment and storage medium
CN117764177A
Space target recognition method based on knowledge graph and large language model
CN118470415A