A method for constructing a pre-trained language model based on knowledge graph
Through the pre-training language model construction method based on knowledge graph, using semantic analysis and multi-stage search algorithm, it solves the problem of large scale of knowledge graph and weak question and answer understanding ability, improves the efficiency and accuracy of natural language question and answer, and realizes the professional field Interpretability and efficient question answering.
Patent Information
- Application Number
- CN202410850693.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-06-28
AI Technical Summary
The large scale of the knowledge graph and the weak question and answer understanding ability lead to poor interpretability and low accuracy of natural language question and answer. Traditional KGQA has problems such as low retrieval efficiency, misleading generation and complex subtasks.
The pre-trained language model construction method based on the knowledge graph is used to process the data of natural language problems through the semantic parsing model of the pre-trained language, generate a list of candidate logical forms, and use an unsupervised multi-stage search algorithm to perform entity and relationship analysis in the knowledge graph. Search and convert into Cypher statements for graph query to form an answer set.
It improves the efficiency and interpretability of intelligent question and answer, provides a new paradigm of interpretable knowledge reasoning question and answer, is suitable for professional fields, and enhances the accuracy and service level of knowledge graph question and answer.
Smart Images

Figure CN118410130B
Abstract
Description
Technical Field
[0001] The present application belongs to the field of knowledge query technology, and in particular, relates to a method for constructing a pre-trained language model based on a knowledge graph. Background Art
[0002] Due to the large scale of knowledge graphs and their weak understanding ability, it costs a lot to use predefined models for natural language question answering. Therefore, how to deeply integrate structured digitalization with rich language systems to make services more intelligent, accurate, real-time and personalized is an urgent problem to be solved.
[0003] In the knowledge question answering task, the pre-trained language model (PLM) has shown great advantages, with superior text generation and semantic understanding capabilities, and has excellent performance in general fields. However, in professional fields, due to the lack of a complete knowledge base to support it, the operation process of knowledge question answering is like an opaque black box, and the specific decision logic is difficult to track, resulting in poor interpretability and low accuracy in actual application.
[0004] At present, some studies use PLM to directly generate executable programs based on given questions and other relevant KG information, which improves model performance and proves the effectiveness of introducing PLM into KG question answering. However, traditional KGQA still has problems such as low retrieval efficiency, misleading generation, and complex knowledge graph question answering subtasks. Summary of the invention
[0005] In view of this, this application aims to propose a method for constructing a pre-trained language model based on a knowledge graph to solve the problems of large scale of knowledge graph and weak question and answer comprehension ability in the knowledge query process.
[0006] To achieve the above purpose, the technical solution of this application is implemented as follows:
[0007] In a first aspect, the present application provides a method for constructing a pre-trained language model based on a knowledge graph, comprising:
[0008] Input a natural language question;
[0009] The input natural language question is processed based on the semantic parsing model of the pre-trained language to obtain a candidate logical form list, wherein the semantic parsing model is pre-built to extract the features of the natural language question, and perform entity recognition and intent recognition of the question sentence, and generate a candidate logical form list by combining the entity and the intent and filling it through logical conversion;
[0010] Based on the unsupervised multi-stage search algorithm, knowledge retrieval is performed on the generated candidate logical form list in the knowledge graph, the logical form content is updated in combination with the retrieval results and converted into Cypher statements for graph query, and the answer list is returned to form an answer set, wherein the knowledge retrieval includes entity retrieval and relationship retrieval.
[0011] In the second aspect, based on the same inventive concept, the present application also provides a system for building a pre-trained language model based on a knowledge graph, including:
[0012] An input module, the input module being configured to input a natural language question;
[0013] A generation module, wherein the generation module is configured to perform data processing on the input natural language question based on a semantic parsing model of a pre-trained language to obtain a candidate logical form list, wherein the semantic parsing model is pre-built to extract features of the natural language question, perform entity recognition and intent recognition of the question sentence, and generate a candidate logical form list by combining entities and intents and performing logical conversion;
[0014] A retrieval module is configured to perform knowledge retrieval on the generated candidate logical form list in the knowledge graph based on an unsupervised multi-stage search algorithm, update the logical form content in combination with the retrieval results and convert it into Cypher statements for graph query, and return an answer list to form an answer set, wherein the knowledge retrieval includes entity retrieval and relationship retrieval.
[0015] In a third aspect, based on the same inventive concept, the present application also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method described in the first aspect is implemented.
[0016] In a fourth aspect, based on the same inventive concept, the present application also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the method described in the first aspect.
[0017] Compared with the prior art, the method for constructing a pre-trained language model based on a knowledge graph described in this application has the following beneficial effects:
[0018] The present application describes a method for constructing a pre-trained language model based on a knowledge graph. The method adopts a generation-and-retrieval approach, takes the candidate logical form as a bridge, performs semantic analysis by fine-tuning the pre-trained language model, and retrieves answers in an unsupervised multi-stage search algorithm module. This method realizes a new paradigm of explainable reasoning question and answer of PLM+KG, which not only improves the efficiency and service level of intelligent question and answer, but also provides a new solution for future explainable knowledge reasoning question and answer in multiple professional fields such as medicine, law, and humanities. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0020] Figure 1 A schematic diagram of a method for constructing a pre-trained language model based on a knowledge graph according to an embodiment of the present application;
[0021] Figure 2 A framework diagram of a method for constructing a pre-trained language model based on a knowledge graph as described in an embodiment of the present application;
[0022] Figure 3 This is a diagram of the entity recognition framework described in the embodiment of the present application;
[0023] Figure 4 This is a consciousness recognition framework diagram described in an embodiment of the present application;
[0024] Figure 5 This is a framework diagram of the unsupervised multi-stage search algorithm described in the embodiment of the present application;
[0025] Figure 6 A graph showing the variation of the ablation experiment results in the generation phase described in the embodiment of the present application with the proportion of training data;
[0026] Figure 7 This is a comparison chart of ablation experiments of various modules of SP-PLM described in the embodiment of the present application;
[0027] Figure 8 This is a graph showing the variation of the ablation experiment results at the retrieval stage as the beam size changes as described in the embodiment of the present application;
[0028] Fig. 9 This is an example diagram of the knowledge graph question-answering system interface and query results described in the embodiment of the present application;
[0029] Fig.10 A schematic diagram of a system for constructing a pre-trained language model based on a knowledge graph as described in an embodiment of the present application;
[0030] Fig.11A schematic diagram of the hardware structure of the electronic device described in an embodiment of the present application. DETAILED DESCRIPTION
[0031] In order to make the objectives, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.
[0032] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present application should be the usual meanings understood by people with ordinary skills in the field to which the present application belongs. The "first", "second" and similar words used in the embodiments of the present application do not represent any order, quantity or importance, but are only used to distinguish different components. "Including" or "comprising" and similar words mean that the elements or objects appearing in front of the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0033] The embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0034] This embodiment provides a method for constructing a pre-trained language model based on a knowledge graph, which includes a semantic parsing model based on pre-trained language (Semantic Parsing Model Based on Pre-trained Language, SP-PLM) and an unsupervised multi-stage search algorithm (Unsupervised Multi-stage Search, Uns-MS). The framework diagram of the construction method is as follows: Figure 2 shown.
[0035] Among them, the SP-PLM model first extracts NL question features through knowledge graph and instruction fine-tuning PLM, then performs entity recognition and intent recognition of the question, and finally combines entities and intents to generate candidate logical forms through logical transformation and filling.
[0036] The Uns-MS algorithm first performs knowledge retrieval on the generated candidate logical forms in the knowledge graph, namely entity retrieval and relationship retrieval. Secondly, it updates the logical form content based on the retrieval results and converts it into Cypher statements for graph query. Finally, it returns the answer list to form an answer set.
[0037] Compared with the previous retrieval-and-generation mode, the generation-and-retrieval mode of the pre-trained language model construction method based on the knowledge graph retrieves the entities and relations in the generated logical form separately, avoiding the influence of the prior retrieval on the logical form generation in the previous method and improving the retrieval efficiency.
[0038] like Figure 1 As shown, the construction method specifically includes the following steps:
[0039] Step S101: input a natural language question.
[0040] Step S102: Process the input natural language question based on the semantic parsing model of the pre-trained language to obtain a list of candidate logical forms, wherein the semantic parsing model is pre-built to extract natural language question features and perform entity recognition and intent recognition of the question, and generate a list of candidate logical forms by combining entities and intents and filling them through logical conversion.
[0041] Specifically, in this embodiment, semantic parsing (SP) is the process of converting questions from unstructured natural language into structured logical forms in order to understand the questions and obtain accurate answers and explainable paths through executable graph database query languages (such as Cypher). Traditional knowledge question-answering research usually adopts two methods: one is to use NER technology, entity linking and other methods to directly obtain the answer to the question through seq2seq of the retrieved fact triples without semantic parsing, so only answers directly related to the facts can be provided; the other is to perform semantic parsing after retrieving the relevant triples, convert them into logical forms and execute Cypher queries to obtain answers in the knowledge base, but complex questions may have multiple logical forms, which can easily lead to ambiguous results. Instruction fine-tuning can train LMs suitable for tasks in specific fields to a certain extent, but the terminology is highly professional and the names are prone to conflict, which will lead to high computational consumption and semantic confusion.
[0042] Therefore, the SP-PLM model proposed in this embodiment improves entity recognition capabilities by fine-tuning the pre-trained language model, reduces the consumption of computing resources, performs intent recognition and fine-grained classification on the input natural language questions, generates accurate semantic representations of the question intent and semantics, and presents them in the form of candidate logic. The model mainly includes three modules: fine-tuning PLM, entity recognition, and intent recognition.
[0043] (1) Fine-tune the PLM module
[0044] To address the problem that PLM (pre-trained language model) has poor semantic parsing effect when solving tasks in specific fields, a fine-tuning PLM module is designed to improve the adaptability and scalability of the model through instruction fine-tuning (FT).
[0045] First, the Cypher queries corresponding to the natural language questions in the training set are converted into corresponding logical forms. Secondly, the entity IDs in these logical forms are replaced with corresponding entity tags, so that PLM can better understand entity tags instead of meaningless entity IDs. Finally, natural language questions such as "What standards has North China Aluminum Co., Ltd. drafted?" and the processed corresponding logical form "(AND(JOIN[drafting_unit, drafe, file)JOIN[drafting_unit, drafting_unitname, [North China Aluminum Co., Ltd.]))" are combined into "input" and "output", and "instructions" are added as "generate a logical form query to retrieve information corresponding to the given question", which constitutes instruction fine-tuning training data for open source PLM.
[0046] SP-PLM uses the RoBERTa model as an example for pre-training, and learns the word-level semantics in the language through the masked language model (MLM) mechanism. After embedding, it is fine-tuned by instructions for secondary training to meet the needs of question-answering tasks. In order to reduce the cost of fine-tuning pre-trained models with a large number of parameters, SP-PLM uses parameter efficient fine-tuning (PEFT) methods (such as LoRA, QLoRA, P-tuning v2, Freeze, etc.), and switches between the above-mentioned efficient fine-tuning methods and PLM according to the NLP tasks to be performed. The fine-tuned PLM is used for entity recognition and intent recognition tasks.
[0047] (2) Entity Recognition Module
[0048] The entity recognition module of SP-PLM proposes the FT-RoBERTa-BiLSTM-CRF model, which aims to accurately identify entities with practical significance in natural language questions, so that the included categories can be mapped to the graph for subsequent answer retrieval. To improve the performance of entity recognition, SP-PLM introduces a fine-tuned RoBERTa as a pre-trained language model for encoding and feature extraction to obtain rich semantic information; in addition, the BiLSTM-CRF model in knowledge extraction is used for entity sequence annotation to accurately identify the entity part in the question and accurately mark it. The framework diagram is shown in the figure below. Figure 3 shown.
[0049] The feature extraction layer performs word embedding in Embedding, and obtains word vectors with better quality by fine-tuning the RoBERTa language model trained for Chinese entity recognition. The calculation formulas are shown in (4.1) and (4.2).
[0050] (4.1)
[0051] h γ = Trans ( h γ -1 ), γ ∈[1, N ] (4.2)
[0052] in, represents the initial word embedding vector, and Represent the word embedding matrix and position embedding matrix respectively, which are used to initialize ; Represents the state of the hidden layer, which is The Transformer output of the layer, represents Transformer; N is the maximum number of layers, here it is 12, output .
[0053] In the entity annotation layer, BiLSTM-CRF uses the output of feature extraction As the input of the labeling task, in the BiLSTM-CRF model, given the sentence , whose label sequence is The probability calculation formulas are shown in (2.1) and (2.2).
[0054] (2.1)
[0055] (2.2)
[0056] In the formula Calculated by formula (2.3), where The corresponding emission probability (i.e. the frequency of BiLSTM output), The corresponding transition probability (that is, the value corresponding to the CRF transfer matrix).
[0057] (2.3)
[0058] BiLSTM-CRF is trained using the maximum likelihood method, and the corresponding loss function is shown in formula (2.4).
[0059] (2.4)
[0060] From (2.1)–(2.4), we can infer that the formula for question entity labeling is shown in (4.3).
[0061] (4.3)
[0062] in, Represents the input sequence, and the feature representation is obtained after feature extraction , Represents the feature representation of the i-th position of the input sequence; represents the feature weight, represents the transfer matrix, represents the transfer score, Represents the normalization factor. The model can effectively utilize the Transformer output features To perform sequence labeling, the constraints of context and labels are considered to identify meaningful entities.
[0063] (3) Intent Recognition Module
[0064] SP-PLM's intent recognition is a fine-grained classification model, which is a key process in semantic parsing and is divided into two parts: feature extraction and classification. Feature extraction maps text semantic features to digital space and converts them into digital vectors; the classification process transfers the features extracted from the text to the classification layer for fine-grained classification. The template library contains a set of rule templates for fine-grained category labels of intent. SP-PLM's intent recognition module proposes the FT-RoBERTa-TextCNN model, adds a classifier to fine-tune RoBERTa to adapt to the intent recognition task for keyword feature extraction, so that the model can better predict intent labels. TextCNN captures local features for text classification. The framework diagram of intent recognition is shown below. Figure 4 shown.
[0065] The intent recognition model performs word embedding in Embedding and forms a vectorized representation after fine-tuning RoBERTa. The calculation process formulas are shown in (4.4) and (4.5), and the reference parameters have the same meaning as (4.1) and (4.2).
[0066] (4.4)
[0067] (4.5);
[0068] In order to solve the overfitting problem caused by the pre-trained language model and improve the generalization ability of the model, the intent recognition module builds TextCNN to extract local features of the vector, which is mainly composed of convolution layer, pooling layer and splicing layer. For the convolution layer of TextCNN, the local feature vector after multi-layer filters is shown in formula (4.6).
[0069] (4.6)
[0070] in, is the activation function, is the weight matrix, is the bias, is the filter length.
[0071] The pooling layer performs dimensionality reduction on the text feature vector and selects maximum pooling. The calculation formula is shown in (4.7).
[0072] (4.7)
[0073] The concatenation layer concatenates all features to obtain the final output feature vector C. The calculation formula is shown in (4.8).
[0074] (4.8)
[0075] Finally Function classification completes the intent classification of the question, as shown in formula (4.9).
[0076] (4.9)
[0077] Among them, y represents the classification result of intent recognition, is the weight matrix, For bias.
[0078] SP-PLM performs semantic representation by fine-tuning PLM, entity recognition and intent recognition stages, and completes logical conversion of entities and intents by filling in. It has a certain semantic parsing ability to convert natural language questions into logical forms. By performing semantic parsing on newly input questions, a list of candidate logical forms can be obtained. .
[0079] Step S103: perform knowledge retrieval on the generated candidate logical form list in the knowledge graph based on the unsupervised multi-stage search algorithm, update the logical form content based on the retrieval results and convert it into Cypher statements for graph query, and return the answer list to form an answer set, where knowledge retrieval includes entity retrieval and relationship retrieval.
[0080] Specifically, in this embodiment, SP-PLM converts a series of natural language questions into corresponding logical form lists. , the retrieval process only needs to replace the entities and relations in the corresponding positions of the candidate logical form with the entities and relations existing in the KG, which can further improve the performance. However, the traditional method of question-answering retrieval relies only on entity links and is difficult to handle complex queries. Therefore, in order to enhance the adaptability of the method, further optimize the query and reduce the error, an unsupervised multi-stage search algorithm (Uns-MS) is proposed for knowledge retrieval. The framework diagram is shown in the figure Figure 5 shown.
[0081] First, the candidate logical form list output by the generation phase is Each entity in the knowledge graph is compared with the elements in the entity set by similarity, and updated to a list of candidate logical forms Secondly, according to Perform relationship retrieval, compare and sort the relationship similarity with K in the knowledge graph again, and obtain the final list of candidate logical forms after phrase-level semantic retrieval and update conversion. ; Finally, Convert it into a Cypher statement to query and generate an answer set.
[0082] The input of the algorithm is the list of candidate logical forms generated, and the logical forms are traversed in order. . First, perform entity retrieval. For each Entities in , calculate the entity label similarity between it and the entity set ε of the knowledge graph K . Secondly, sort the retrieved entities based on similarity to get the top and greater than the threshold Entity retrieval list of . Permutate the retrieved entities at each position, and get Finally, based on Similarity, take the top and greater than the threshold The value of gets a new list of candidate logical forms .
[0083] Relationship retrieval is performed after entity retrieval. Similar to entity retrieval, but Each r in is different, according to the logical form The entity set neighborhood of each candidate relationship is calculated Similarity . Sort the retrieved relations by similarity and take the top and greater than the threshold The value of By sorting the relationship retrieval results for each location, we can get the relationship retrieval results. , then take the top Greater than threshold The value of , to obtain a final list of candidate logical forms .
[0084] In the process of entity relationship retrieval in the knowledge graph, given a query, Uns-MS can select the top k most semantically similar to the candidate set as the retrieved answer set without additional training. Uns-MS switches between two unsupervised retrieval methods for entity retrieval and relationship retrieval. One uses BM25 as an example, using term frequency-inverse document (TF-IDF) to rank documents according to their relevance to a given query. With Documentation The correlation score calculation is shown in formulas (4.10) and (4.11).
[0085] (4.10)
[0086] (4.11)
[0087] in, is the adjustment factor, which is set here as =2, =1, =0.75. for In the documentation The frequency of occurrence in for The frequency of occurrence in the document query is taken =1. For Documentation Length, is the average length of all documents. Final question With Documentation The scoring formula is word weight and relevance score The sum of products, the word weight is The IDF value is calculated by the formula shown in (4.12).
[0088] (4.12)
[0089] Secondly, taking SimCSE as an example, unsupervised dense information retrieval using comparative learning is performed, and the training objective is shown in formula (4.13).
[0090] (4.13)
[0091] Among them, N is the number of sentences in a small batch, and two different Dropout masks are used for the same sentence, which are expressed as , , and get its embedding as two sentence vectors , , is an element in the sentence set, the score Calculated by the cosine similarity formula, is the temperature hyperparameter.
[0092] To sum up, the pseudo code of the Uns-MS implementation process is as follows:
[0093]
[0094] After searching, we get the final list of candidate logical forms. , traverse in sequence The logical form of , converting the logical form into an equivalent Cypher query according to the rule template When you find a knowledge base The first one to be executed When you execute the method, you can get the final answer set With this approach, Uns-MS queries in KG based on Cypher to obtain the complete reasoning path of natural language questions with good interpretability and accuracy.
[0095] In summary, the method for constructing a pre-trained language model based on knowledge graph uses the pre-trained language model to perform natural semantic parsing to generate graph queries, and then uses the external knowledge base to perform interpretable query reasoning, that is, thoughtful graph queries. This method is a combined paradigm that effectively combines PLM+KG, which can better utilize external knowledge, improve the interpretability of question answering, and avoid hallucinations caused by pre-trained language models.
[0096] Experiment and result analysis based on the above method
[0097] Experimental setup
[0098] The experiment is used to demonstrate the effectiveness of the knowledge graph-based pre-trained language model construction method in question-answering tasks. It is divided into three parts: comparative experiment, ablation experiment, and knowledge graph question-answering system. The detailed experimental structure directory is shown in Table 1.1.
[0099] Table 1.1 Experimental structure directory
[0100]
[0101] Data Description
[0102] The data source of this embodiment is the aluminum alloy standard file set. According to 200 preprocessed standard files, the pre-trained model unimo-text-1.0-question-generation is used for training to generate 1,000 natural language questions. The number of question intent types is the same as the defined relationship type.
[0103] The knowledge graph is regarded as a structured information base for knowledge retrieval, and the answers contained in it are extracted. The data is the results of standard graph experiments, including entities, relationships, attributes, etc. The data description used to verify the question-answering method is shown in Table 1.2.
[0104] Table 1.2 Question and answer data description
[0105]
[0106] Evaluation indicators
[0107] The experiment in this example is to evaluate the performance of the method. The first part is a comparative experiment of the proposed method, and the second part is an ablation experiment of the generation and retrieval stages of the method. The first part uses three indicators, F1, Hits@1, and Accuracy (Acc), to evaluate the coverage of all answers, the single highest-ranked answer, and the strict exact matching accuracy. The calculation formula of the evaluation indicators is as follows:
[0108] It is the harmonic mean of precision and recall. The specific calculation formula is shown in (4.14).
[0109] (4.14)
[0110] in, That is, precision, which refers to the ratio of the golden answer (one answer corresponding to the question) given to each natural language question in the question-answering method to the total number of all returned answers. That is, recall rate, which indicates the ratio of the number of correct answers returned by the knowledge graph question answering method to the number of golden answers returned. Usually, the overall performance of the knowledge graph question answering method is measured using The precision and recall are evaluated as a whole. Each question in the test set has its corresponding . The maximum value is 1 and the minimum value is 0. The closer the indicator is to 1, the better.
[0111] It is a commonly used indicator in knowledge graphs, which refers to the average proportion of triples ranked less than in link prediction. The specific calculation is shown in formula (4.15).
[0112] (4.15)
[0113] Among them, S is a set of triples, is the number of triple sets, is the indicator function (if the condition is true, the function value is 1, otherwise it is 0), Refers to the link prediction ranking of the i-th triple. In this embodiment, =1. It is a commonly used evaluation indicator, which indicates the probability of selecting the correct answer among the first k answers. The larger the indicator, the better. The above indicators can comprehensively evaluate the performance of the pre-trained language model construction method based on the knowledge graph from multiple aspects, including reliability, robustness and user interaction.
[0114] The accuracy rate (Acc) indicates the ratio of the number of questions answered correctly by the knowledge graph question-answering method to all questions. E is the error rate, which means that a samples out of m samples are classified incorrectly. The error rate is shown in formula (4.16). The accuracy rate Acc = 1-error rate, as shown in formula (4.17).
[0115] (4.16)
[0116] (4.17)
[0117] Comparative Experiment and Analysis
[0118] In order to meet the experimental requirements of the present invention, samples are selected from the graph dataset, and semantic parsing and knowledge retrieval are performed based on the natural language questions in the dataset. F1, Hits@1 and accuracy (Acc) are used to represent the coverage of all answers and the single highest-ranked answer, as well as the accuracy of exact matching. In order to verify whether the pre-trained language model construction method based on the knowledge graph is superior to other QA methods, this section conducts a comparative experiment on the knowledge graph dataset to compare the proposed pre-trained language model construction method based on the knowledge graph with the mainstream question-answering method, proving the effectiveness of the generation and re-retrieval mode of the pre-trained language model construction method based on the knowledge graph. The experimental results are shown in Table 1.3.
[0119] The baseline method selects three mainstream question-answering methods, namely, generative question-answering, retrieval-based question-answering, and structured knowledge graph-based question-answering. Generative question-answering does not rely on a pre-stored answer library, but generates answers based on the language patterns and knowledge learned by the model, such as FC-KBQA, AranceQA, and GMT-KBQA, which will result in inaccurate answers; retrieval-based question-answering matches questions with a pre-built knowledge base, such as CBR-KBQA and RnG-KBQA, and the results are more reliable but lack flexibility; structured knowledge graph-based question-answering uses entities and relationships in the knowledge graph to understand user questions and retrieve answers from the graph, such as StructGPT, UniKGQA, and UniK-QA. The descriptions of each baseline method are as follows:
[0120] (1) FC-KBQA: This method extracts relevant fine-grained knowledge components from the knowledge base and combines them into connected medium-grained knowledge pairs according to KB constraints. Finally, a generative model is used to generate the final logical expression.
[0121] (2) ArcaneQA: This method dynamically generates queries based on the results of the previous steps and handles large search spaces and pattern links in a unified framework, i.e., using dynamic programs to handle large search spaces and using dynamic contextualized encoding to enhance pattern links.
[0122] (3) GMT-KBQA: This method supplements the retrieval results of ELQ with FACC1, enhancing the coverage of candidate entities. It adopts a two-stage relation retrieval module with a dual encoder and cross encoder architecture, and uses FAISS for neighboring relation retrieval;
[0123] (4) CBR-KBQA: This method solves new problems based on existing cases. It reuses components in the cases, generates corresponding logical representations, and performs entity linking.
[0124] (5) RnG-KBQA: This method is based on ranking regeneration and solves the coverage problem with a generative model. First, the candidate logical forms are obtained and ranked through KB search, and then the final logical form is generated based on the question and the top-k candidates.
[0125] (6) StructGPT: This method separates the reading and reasoning processes of PLM. First, it uses the interface of structured data to achieve accurate and efficient data access and filtering, and further uses the reasoning ability of PLM to determine the next step or final result of the problem.
[0126] (7) UniKGQA: The core of this method is to use PLM to match the semantics of questions and relations, and use a minimalist GNN to propagate matching information on KG, and finally infer the answer node;
[0127] (8) Unik-QA: Text and table information share a set of indexes, and KB uses a set of indexes. The search results are merged into the final searched passage set according to a certain ratio (adjusted using the search recall rate on the validation set).
[0128] Table 1.3 Comparison of QA results between the knowledge graph-based pre-trained language model construction method and other baselines
[0129]
[0130] The above table lists the experimental results of the comparison between the pre-trained language model construction method based on the knowledge graph and other QA methods. The optimal settings are adopted, the beam search size is set to 15, and the bold values are the optimal results corresponding to each indicator. It can be seen that the pre-trained language model construction method based on the knowledge graph can achieve 77.8%, 82.70%, and 73.30% of the three indicators of F1, Hits@1, and Acc on the standard graph dataset, which is an average increase of 6.93%, 9.86%, and 3.78% compared with the comparison model. This shows that the pre-trained language model construction method based on the knowledge graph can achieve good results in the knowledge question answering task, and is better than the method of using semantic parsing and knowledge retrieval alone.
[0131] By comparing with the three types of question-answering methods, the pre-trained language model construction method based on the knowledge graph avoids the problem of low output credibility that may exist in the generative question-answering method through re-retrieval; compared with the retrieval-based question-answering, the PLM is fine-tuned in the semantic parsing stage, reducing the dependence on labeled data; compared with the question-answering based on the structured knowledge graph, the pre-trained language model construction method based on the knowledge graph can handle complex queries and multi-step reasoning processes more flexibly through multi-stage search, thereby improving the accuracy and coverage of the question-answering. In summary, the pre-trained language model construction method based on the knowledge graph integrates structured digitization with a rich language system, simplifies the question-answering process, and makes the service tend to be more intelligent, accurate, real-time and personalized.
[0132] Ablation experiments and analysis
[0133] In order to test whether the various components of the knowledge graph-based pre-trained language model construction method can work properly and verify the effectiveness of the generation and retrieval stages, ablation experiments were carried out on the knowledge graph-based pre-trained language model construction method in two stages respectively.
[0134] In the generation phase, different proportions of training data are used for fine-tuning. As the amount of training increases, the expected effect becomes better, which can prove the effectiveness of fine-tuning. In addition, in the entity recognition and intent recognition modules, the effectiveness of each component on SP-PLM is tested respectively.
[0135] In the retrieval stage, the effectiveness of entity retrieval (ER) and relation retrieval (RR) on Uns-MS is tested separately, ER or RR is deleted from the framework, and comparison is made with different beam search space sizes to verify the positive effects of entity retrieval and relation retrieval on the method in the knowledge retrieval stage.
[0136] Ablation experiment at the generation stage
[0137] In the generation stage, the training data ratio is set to 20%, 40%, 60%, and 80% of the complete training set, and the model is fine-tuned to compare the effects. The trend of the ablation experiment results in the generation stage with the change of the training data ratio is as follows Figure 6 shown.
[0138] like Figure 6 As shown in Table 1.4, in the generation stage, with the increase of the proportion of training data, the effects of the three indicators of SP-PLM, F1, Hit@1, and Acc, all become better, and with the increase of the training ratio, the growth rate of the indicators slows down. In addition, the specific experimental results of the generation stage are shown in Table 1.4, and the bold values are the best experimental results corresponding to each indicator.
[0139] Table 1.4 Ablation experiment results in the generation phase
[0140]
[0141] As can be seen from Table 1.4, when the training data reaches 100%, the three indicators can achieve the best results of 83.10%, 85.90%, and 77.90% respectively, which proves the effectiveness of fine-tuning in the generation stage.
[0142] In addition, we designed the module tests of entity recognition and intent recognition of SP-PLM respectively. When RoBERTa was not used, Word2vec was used for word embedding. P, R, and F1 indicators were selected for effect evaluation. Figure 7 shown.
[0143] Depend on Figure 7 It can be seen that with the increase of each module, the various indicators of SP-PLM in entity recognition and intent recognition tasks are on the rise, and the experimental effect is gradually optimized. In addition, the specific values are shown in Table 1.5, and the best experimental results for each indicator are in bold.
[0144] Table 1.5 Ablation test results of each module of SP-PLM
[0145]
[0146] Experimental results show that in the question entity recognition task, SP-PLM achieved experimental results of 86.52%, 88.17% and 87.34% on the three indicators, which is better than the use of each component alone, proving that the pre-trained language model with fine-tuning on the basis of entity labeling can achieve better recognition effect; in the intent recognition task, SP-PLM achieved results of 90.73%, 89.25% and 89.98% on the three indicators, which is better than the use of each component alone, and the effect is more obvious after adding fine-tuned RoBERTa, proving that the pre-trained language model with fine-tuning can better identify the intent of questions in the text classification process, thereby performing fine-grained classification.
[0147] Ablation experiment of retrieval stage
[0148] In the knowledge retrieval stage, ER or RR is removed from the framework to obtain three simplified variants, namely Uns-MS (-ER), Uns-MS (-RR), and Uns-MS (-ER-RR). Then, they are compared with different beam sizes (1, 2, 5, 8, and 15). The evaluation index is F1. The trend of the ablation experiment results in the retrieval stage with the change of beam size is shown in the figure. Figure 8 The specific values of the experimental results are shown in Table 1.6, and the bold ones are the optimal values.
[0149] Table 1.6 Ablation experiment results in the retrieval stage
[0150]
[0151] Depend on Figure 8 As shown in Table 1.6, with the increase of Beam Size, the retrieval effect is significantly improved, and the rate slows down. At the same time, it can be seen from Table 1.6 that under different Beam Sizes, increasing ER and RR contributes to the results, and since the F1 value of Uns-MS (-ER) after removing ER is lower than the F1 value of Uns-MS (-RR) after removing RR, it proves that ER contributes more to Uns-MS than RR.
[0152] Knowledge graph question answering system
[0153] The pre-trained language model construction method based on the knowledge graph can perform fine-grained classification of question types in the intent recognition module through semantic analysis and knowledge retrieval, and update the candidate logical form, replace the entity recognition results, and thus correspond to Cypher query statements for retrieval in the knowledge graph. The knowledge graph question answering system interface and query result examples are as follows: Fig. 9 shown.
[0154] This embodiment develops a question-and-answer system based on knowledge graph based on Python. The Flask framework is used to facilitate users to ask questions and query results. The back end is connected to the Neo4j graph database, and the system can map the query results to the Web front-end interface, so that users can intuitively view and browse the query results. In addition, users can use the provided interactive elements, such as query, delete buttons and search boxes, to perform further operations or browse related information. The internal logic of the system is a semantic analysis and knowledge retrieval module, which has high flexibility and efficiency, can handle various types of questions, and can be classified and subdivided according to the intention of the question, so that the method can query relationships such as "drafting", "verification rules" and "test methods".
[0155] For the question in the graph, the SP-PLM model can identify the question intent as "citation", which corresponds to the "cite" category in the graph database, and identify the standard entity as "aluminum alloy castings"; through the Uns-MS algorithm of knowledge retrieval, the logical form is updated multiple times and corresponds to the Cypher query statement "MATCH p=(n:file{file_name:"aluminum alloy castings"})-[r:cite]->(m:file) RETURN m", so as to perform answer retrieval query in the standard system knowledge graph.
[0156] In summary, this embodiment designs and completes three experiments: comparative experiment, ablation experiment and question-answering system. Comparative experiments have proved that the method proposed in this embodiment is superior to other question-answering methods in terms of F1, Hit@1 and Acc; ablation experiments in the generation and retrieval stages have proved that each component of the method proposed in this embodiment has a positive effect on the final experimental results, further proving that the pre-trained language model construction method based on the knowledge graph can well solve the problems of low language model retrieval efficiency and poor semantic understanding ability of knowledge base retrieval; the question-answering system interface is designed, and examples are given to illustrate the standard question-answering implementation process and demonstrate the effect, proving that the pre-trained language model construction method based on the knowledge graph can realize intelligent standard question-answering that combines digital standards and language systems.
[0157] In order to solve the problem that structured digitization and rich language systems are difficult to integrate in the process of redoing the application model, in this embodiment, in order to avoid the accumulation of errors caused by multiple subtask conversions in the question-answering process, the question-answering is simplified into two processes: a semantic parsing model based on a pre-trained language and an unsupervised multi-stage search by generating and re-searching, with the list of candidate logical forms as a bridge. This overcomes the inherent challenges of low retrieval efficiency and the misleading impact of retrieval errors to a certain extent.
[0158] The experimental part uses knowledge graphs and generated natural language questions as data sets. First, by comparing with other KGQA baseline methods, the effects are evaluated using F1, Hit@1, and Acc. It is confirmed that the pre-trained language model construction method based on knowledge graphs is better than the three mainstream question-answering methods in question-answering tasks, further proving the effectiveness of the generation-and-retrieval method. Secondly, the ablation experiment verifies that the pre-trained language model construction method based on knowledge graphs has a positive effect on the question-answering effect in each component of the generation and retrieval stages. Finally, a question-answering system is designed, and the knowledge question-answering process is explained with examples.
[0159] It can be seen that the method of building a pre-trained language model based on the knowledge graph is flexible, can make the integration of the language model and the knowledge graph more interpretable, has higher efficiency in question-answering tasks, and makes the service more intelligent, accurate, real-time and personalized.
[0160] It should be noted that the above describes some embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the above embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0161] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the embodiment of the present application also provides a pre-trained language model construction system based on a knowledge graph.
[0162] like Fig.10 As shown, the pre-trained language model construction system based on the knowledge graph includes:
[0163] An input module 11, the input module is configured to input a natural language question;
[0164] A generation module 12 is configured to perform data processing on the input natural language question based on the semantic parsing model of the pre-trained language to obtain a candidate logical form list, wherein the semantic parsing model is pre-built to extract natural language question features, and perform entity recognition and intent recognition of the question sentence, and combine the entity and intent and fill in the candidate logical form list through logical conversion;
[0165] Retrieval module 13, the retrieval module is configured to perform knowledge retrieval on the generated candidate logical form list in the knowledge graph based on an unsupervised multi-stage search algorithm, update the logical form content in combination with the retrieval results and convert it into Cypher statements for graph query, and return an answer list to form an answer set, wherein knowledge retrieval includes entity retrieval and relationship retrieval.
[0166] For the convenience of description, the above system is described by dividing the functions into various modules. Of course, when implementing the embodiments of the present application, the functions of each module can be implemented in the same or multiple software and / or hardware.
[0167] The system of the above-mentioned embodiment is used to implement the corresponding knowledge graph-based pre-trained language model construction method in any of the above-mentioned embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0168] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments and methods, an embodiment of the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a method for constructing a pre-trained language model based on a knowledge graph as described in any of the above embodiments is implemented.
[0169] Fig.11 A more specific schematic diagram of the hardware structure of an electronic device provided in this embodiment is shown, and the device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are connected to each other through the bus 1050 in the device.
[0170] The processor 1010 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.
[0171] The memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 may store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 1020 and are called and executed by the processor 1010.
[0172] The input / output interface 1030 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.
[0173] The communication interface 1040 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0174] The bus 1050 includes a path that transmits information between the various components of the device (eg, the processor 1010 , the memory 1020 , the input / output interface 1030 , and the communication interface 1040 ).
[0175] It should be noted that, although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040 and the bus 1050, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present specification, and does not necessarily include all the components shown in the figure.
[0176] The electronic device of the above-mentioned embodiment is used to implement the corresponding knowledge graph-based pre-trained language model construction method in any of the above-mentioned embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0177] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the method for constructing a pre-trained language model based on a knowledge graph as described in any of the above embodiments.
[0178] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.
[0179] The computer instructions stored in the storage medium of the above embodiment are used to enable the computer to execute the method for building a pre-trained language model based on a knowledge graph as described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0180] A person skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present application (including the claims) is limited to these examples. In line with the concept of the present application, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of the different aspects of the embodiments of the present application as described above, which are not provided in detail for the sake of simplicity.
[0181] In addition, to simplify the description and discussion, and in order not to make the embodiments of the present application difficult to understand, the known power / ground connections to the integrated circuit (IC) chip and other components may or may not be shown in the provided drawings. In addition, the device may be shown in the form of a block diagram to avoid making the embodiments of the present application difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform on which the embodiments of the present application are to be implemented (that is, these details should be fully within the scope of understanding of those skilled in the art). Where specific details (e.g., circuits) are set forth to describe exemplary embodiments of the present application, it is obvious to those skilled in the art that the embodiments of the present application can be implemented without these specific details or with changes in these specific details. Therefore, these descriptions should be considered illustrative rather than restrictive.
[0182] Although the present application has been described in conjunction with specific embodiments of the present application, many alternatives, modifications and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the discussed embodiments.
[0183] The embodiments of the present application are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application should be included in the scope of protection of the present application.
Claims
1. A method for constructing a pre-trained language model based on a knowledge graph, characterized in that: include: Input a natural language question; The input natural language question is processed based on the semantic parsing model of the pre-trained language to obtain a candidate logical form list, wherein the semantic parsing model is pre-built to extract the features of the natural language question, and perform entity recognition and intent recognition of the question sentence, and generate a candidate logical form list by combining the entity and the intent and filling it through logical conversion; The semantic parsing model includes a fine-tuning PLM module, and the fine-tuning PLM module is configured to: Convert the Cypher statement queries corresponding to the natural language questions in the training set into corresponding logical forms; Replacing the entity ID in the logical form with the entity tag; Combine natural language questions into "input" and "output", and add "instructions" as "generate a logical form query to retrieve information corresponding to the given question", and construct instructions to fine-tune training data; Pre-training the pre-trained language model, learning the word granularity level semantics in the language through the MLM mechanism, and performing secondary training after embedding and fine-tuning with instructions; Based on the unsupervised multi-stage search algorithm, the generated candidate logical form list is searched for knowledge in the knowledge graph, the logical form content is updated in combination with the search results and converted into Cypher statements for graph query, and the answer list is returned to form an answer set, wherein the knowledge search includes entity search and relationship search; The unsupervised multi-stage search algorithm includes: Entity retrieval: compare the similarity of each entity in the candidate logical form list output in the generation phase with the elements in the entity set of the knowledge graph, and update it into a new candidate logical form list; Relationship retrieval: Relationship retrieval is performed based on the new candidate logical form list. The relationship similarity is compared and sorted with the elements in the entity set neighborhood in the knowledge graph again. After phrase-level semantic retrieval and update conversion, the final candidate logical form list is obtained. Convert the final candidate logical form list into Cypher statements for query and generate an answer set; The method compares the similarity of each entity in the candidate logical form list outputted in the generation phase with the elements in the entity set of the knowledge graph, and updates the new candidate logical form list, including: Traverse the logical forms in the candidate logical form list in order, and for each entity e in the logical form, calculate the entity label similarity s between the entity e and the entity set ε of the knowledge graph K e ; Sort the retrieved entities based on similarity and get the top k e and greater than the threshold t e Entity retrieval list of e list ; By replacing the entities retrieved at each position, the logical form list result F is obtained after entity retrieval list ; List results based on the logical form F list , take the top k1 and the value greater than the threshold t1 to get a new candidate logical form list C′; The relationship retrieval is performed based on the new candidate logical form list, and the relationship similarity is compared and sorted with the elements in the entity set neighborhood in the knowledge graph again. After the phrase-level semantic retrieval and update conversion, the final candidate logical form list is obtained, including: According to the logical form entity set ε F The neighborhood of Calculate the similarity s of each candidate relation r′ r ; Sort the retrieved relations by similarity and take the top k r and greater than the threshold t r The value of , get the search result r list ; By sorting the relationship retrieval results of each position, we can get the relationship retrieval result F list ′, then take the top k2 and the value greater than the threshold t2 to obtain the final candidate logical form list C″.
2. The method according to claim 1, characterized in that: Also included is an entity recognition module, wherein the entity recognition module is configured to include a feature extraction layer and an entity annotation layer; In the feature extraction layer, word embedding is performed in Embedding, and encoding and feature extraction are performed by fine-tuning the RoBERTa model. The calculation formula is as follows: h0=W s +W p ; h γ =Trans(h γ-1 ),γ∈[1,N]; Where h0 represents the initial word embedding vector; W s and W p Respectively represent the word embedding matrix and the position embedding matrix, which are used to initialize h0; h γ represents the state of the hidden layer, which is the Transformer output of the yth layer, Trans(·) represents Transformer; N represents the maximum number of layers; In the entity annotation layer, the BiLSTM-CRF model uses the output result of feature extraction as the input of the annotation task. The formula for question entity annotation is as follows: In the formula, x represents the input sequence, y represents the label sequence, and the feature representation h is obtained after feature extraction. i ,h i represents the feature representation of the i-th position of the input sequence; w represents feature weight; t represents the transfer matrix; ty i ,y i+1 represents the transfer score; Z(x) represents the normalization factor.
3. The method according to claim 1, characterized in that: Also included is an intention recognition module, wherein the intention recognition module is configured to: Word embedding is performed in Embedding, and the vectorized representation is formed by fine-tuning the RoBERTa model. The calculation formula is as follows: H0=W s +W p ; H γ =Trans(H γ-1 ),γ∈[1,N]; Where H0 represents the initial word embedding vector; W s and W p Respectively represent the word embedding matrix and position embedding matrix, which are used to initialize H0; H γ represents the state of the hidden layer, which is the Transformer output of the γth layer, Trans(·) represents Transformer; N represents the maximum number of layers; Build a TextCNN model to extract local features of vectors, where the TextCNN model consists of a convolutional layer, a pooling layer, and a splicing layer; Among them, for the convolution layer, the local feature vector after multi-layer filters is as shown in the formula: c i =f(w·H i:i+h-1 +b); Where f(·) is the activation function, w is the weight matrix, b is the bias, and h is the filter length; The pooling layer performs a dimensionality reduction operation on the text feature vector and selects the maximum pooling. The specific calculation formula is: C m =max(c); The concatenation layer concatenates all features to obtain the final output feature vector C. The specific calculation formula is: The softmax function is used to classify the intent of the question. The specific calculation formula is: y = softmax(w·C+b); In the formula, y represents the classification result of intent recognition, w represents the weight matrix, and b represents the bias.
4. A system for building a pre-trained language model based on a knowledge graph, characterized in that: include: An input module, the input module being configured to input a natural language question; A generation module, wherein the generation module is configured to perform data processing on the input natural language question based on a semantic parsing model of a pre-trained language to obtain a candidate logical form list, wherein the semantic parsing model is pre-built to extract features of the natural language question, perform entity recognition and intent recognition of the question sentence, and generate a candidate logical form list by combining entities and intents and performing logical conversion; The semantic parsing model includes a fine-tuning PLM module, and the fine-tuning PLM module is configured to: Convert the Cypher statement queries corresponding to the natural language questions in the training set into corresponding logical forms; Replacing the entity ID in the logical form with the entity tag; Combine natural language questions into "input" and "output", and add "instructions" as "generate a logical form query to retrieve information corresponding to the given question", and construct instructions to fine-tune training data; Pre-training the pre-trained language model, learning the word granularity level semantics in the language through the MLM mechanism, and performing secondary training after embedding and fine-tuning with instructions; A retrieval module, wherein the retrieval module is configured to perform knowledge retrieval on the generated candidate logical form list in the knowledge graph based on an unsupervised multi-stage search algorithm, update the logical form content in combination with the retrieval results and convert it into a Cypher statement for graph query, and return an answer list to form an answer set, wherein the knowledge retrieval includes entity retrieval and relationship retrieval; The unsupervised multi-stage search algorithm includes: Entity retrieval: compare the similarity of each entity in the candidate logical form list output in the generation phase with the elements in the entity set of the knowledge graph, and update it into a new candidate logical form list; Relationship retrieval: Relationship retrieval is performed based on the new candidate logical form list. The relationship similarity is compared and sorted with the elements in the entity set neighborhood in the knowledge graph again. After phrase-level semantic retrieval and update conversion, the final candidate logical form list is obtained. Convert the final candidate logical form list into Cypher statements for query and generate an answer set; The method compares the similarity of each entity in the candidate logical form list outputted in the generation phase with the elements in the entity set of the knowledge graph, and updates the new candidate logical form list, including: Traverse the logical forms in the candidate logical form list in order, and for each entity e in the logical form, calculate the entity label similarity s between the entity e and the entity set ε of the knowledge graph K e ; Sort the retrieved entities based on similarity and get the top k e and greater than the threshold t e Entity retrieval list of e list ; By replacing the entities retrieved at each position, the logical form list result F is obtained after entity retrieval list ; List results based on the logical form F list , take the top k1 and the value greater than the threshold t1 to get a new candidate logical form list C′; The relationship retrieval is performed based on the new candidate logical form list, and the relationship similarity is compared and sorted with the elements in the entity set neighborhood in the knowledge graph again. After the phrase-level semantic retrieval and update conversion, the final candidate logical form list is obtained, including: According to the logical form entity set ε F The neighborhood of Calculate the similarity s of each candidate relation r′ r ; Sort the retrieved relations by similarity and take the top k r and greater than the threshold t r The value of , get the search result r list ; By sorting the relationship retrieval results of each position, we can get the relationship retrieval result F list ′, then take the top k2 and the value greater than the threshold t2 to obtain the final candidate logical form list C″.
5. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 3 is implemented.
6. A non-transitory computer-readable storage medium, characterized in that: in, The non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to cause a computer to execute the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Data knowledge dual-drive intelligent medical dialogue system and method based on knowledge graph
CN117077786A
Knowledge graph question-answering method for sub-graph retrieval optimization
CN117149974A
Financial question answering method, device, equipment, system, medium and product
CN118113852A
Knowledge graph question and answer method and device and storage medium
CN118170894A
Knowledge graph-based entity identification data enhancement method and system
WO2021017290A1
Cited By
Smart guidance system based on knowledge graph, method and computer readable medium thereof
TWI943273B
