An ancient poem intelligent question and answer method and system based on a knowledge graph

By constructing a knowledge graph of classical Chinese poetry (TPKG) and employing multi-task learning, combined with deep learning technology, the problems of information redundancy and insufficient accuracy in the intelligent question-and-answer system for classical Chinese poetry were solved, achieving efficient intelligent question-and-answer for classical Chinese poetry and improving the user experience.

CN116737889BActive Publication Date: 2025-12-12HUAZHONG NORMAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310496726.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-27
Publication Date
2025-12-12
Estimated Expiration
2043-04-27

AI Technical Summary

Technical Problem

In existing technologies, the unstructured information of ancient poems is relatively redundant and lacks high-quality knowledge graphs, resulting in insufficient accuracy and efficiency in intelligent question-answering systems for ancient poems, making it difficult to effectively understand the relationship between ancient poems and poets.

Method used

A knowledge graph for classical Chinese poetry, TPKG, is constructed using a three-level fine-grained framework and a time-chain framework. It combines deep learning technology and knowledge graphs, employs multi-task learning and graph attention networks, and achieves intelligent question answering for classical Chinese poems through speech recognition, question/entity encoding, graph attention networks, and speech generation modules.

Benefits of technology

It improves the accuracy and efficiency of intelligent Q&A for classical Chinese poems, enabling a deeper exploration of the relationship between classical poems and poets, promoting the research and learning of classical poetry, and enhancing the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116737889B_ABST
    Figure CN116737889B_ABST
Patent Text Reader

Abstract

The technical scheme of the present application provides an ancient poem intelligent question and answer method and system based on a knowledge graph, constructs an ancient poem knowledge graph TPKG; uses a pre-training strategy combining ancient poems and translations, trains based on a basic model ChineseBERT, and obtains a pre-training language model CP-ChineseBERT for ancient poems; uses multi-task learning and a graph attention network to construct an ancient poem intelligent question and answer model KBQA-CP-ChineseBERT based on a knowledge graph, which includes a speech recognition, a question / entity coding layer, a graph attention network layer, an attention layer and a speech generation module, wherein the speech recognition finds entities related to the ancient poem knowledge graph TPKG in the question, and the question / entity coding layer is realized based on the pre-training language model CP-ChineseBERT for ancient poems; model training is performed using multi-task learning, two auxiliary tasks of entity recognition and intent recognition are introduced, to understand semantic information expressed by a user question, obtain an answer to an ancient poem-related question, and feed back the answer to the user in the form of speech through speech generation.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of intelligent question and answer interaction, and more particularly to an intelligent question and answer scheme for ancient poems based on a knowledge graph, which is an intelligent voice data recognition technology. BACKGROUND

[0002] With the continuous development of artificial intelligence technology, more and more researchers use artificial intelligence technology to process data information of ancient poems, and have made certain progress.

[0003] Intelligent question and answer technology is one of the core technologies in the field of artificial intelligence, and has great research value. Intelligent question and answer understands the semantic information expressed by user questions, and efficiently and accurately answers the questions of users. Early intelligent question and answer systems are mostly for a specific field, and have a narrow range and are not easy to expand, such as Baseball and Lunar. At this stage, people mainly use information retrieval or shallow semantic representation to find answers from a large number of candidate data. Due to the lack of high-quality question and answer data and the limitation of natural language processing technology, the intelligent question and answer task is relatively slow at this stage. With the explosive growth of Internet data, more and more high-quality data sets are proposed for natural language processing tasks. Intelligent question and answer based on knowledge graph has gradually become one of the research hotspots of intelligent question and answer tasks.

[0004] The network contains rich ancient poem information, which is conducive to the learning and understanding of ancient poems. However, the ancient poem information on the network is mostly unstructured information. Compared with structured text, unstructured text information is more redundant, and the potential relationship between different ancient poems and the fine-grained and multi-dimensional information of the ancient poems themselves are easily ignored, which brings challenges to the research and learning of ancient poems. In 2012, Google first proposed the concept of knowledge graph. As a structured data representation method, knowledge graph has strong semantic expression ability and can complete query, reasoning and other operations, and has great development potential. Ancient poems contain information such as poets and poem lines, and using knowledge graph to store ancient poem information is conducive to reasoning about ancient poems and promoting the understanding and learning of ancient poems. With the help of knowledge graph, and combining it with ancient poems, it is of great research significance to structure the related information of ancient poems and poets. However, at present, there are few knowledge graphs for ancient poems, and they are basically not open source, which is not conducive to researchers to carry out intelligent learning of ancient poems based on knowledge graph. Constructing an ancient poem knowledge graph, counting the related information of ancient poems and integrating them into structured data is conducive to improving the reasoning ability of artificial intelligence technology in ancient poems.

[0005] The development of knowledge graph brings a new research direction to intelligent question answering, and the intelligent question answering based on knowledge graph has become one of the solutions to intelligent question answering. The intelligent question answering of ancient poems based on knowledge graph is one of the important applications of the combination of ancient poems and artificial intelligence technology, which needs to understand the user's question related to ancient poems, then match the answer of the question in the ancient poem knowledge graph, and finally feedback to the user. The combination of ancient poems and intelligent question answering based on knowledge graph can not only help users obtain the required knowledge more efficiently, but also can explore the relationship between ancient poems, ancient poems and poets, and poets in depth, facilitate better research and learning of ancient poems, and promote the development of artificial intelligence technology. SUMMARY

[0006] The problem to be solved by the present application is to construct a high-quality ancient poem knowledge graph, accurately represent the related information and relationship of poems and poets, and improve the accuracy of intelligent question answering of ancient poems by using deep learning technology and knowledge graph technology.

[0007] The present application provides a kind of ancient poem intelligent question answering method based on knowledge graph, constructs ancient poem knowledge graph TPKG;Using the pre-training strategy of ancient poem and translation text combination, based on basic model ChineseBERT Training, obtain the pre-training language model CP-ChineseBERT for ancient poems;Using multi-task learning and graph attention network constructs the ancient poem intelligent question answering model KBQA-CP-ChineseBERT based on knowledge graph, including speech recognition, question / entity coding layer, graph attention network layer, attention layer and speech generation module, wherein, find the entity related to ancient poem knowledge graph TPKG in question in speech recognition, question / entity coding layer is realized based on the pre-training language model CP-ChineseBERT for ancient poems;Using multi-task learning carries out model training, introduces two auxiliary tasks of entity recognition and intent recognition, to understand the semantic information expressed by user question, obtains the answer of the question related to ancient poems, and the answer is fed back to the user in the form of voice through voice generation.

[0008] And, in the following processing is carried out in the ancient poem intelligent question answering model KBQA-CP-ChineseBERT based on knowledge graph,

[0009] For the voice containing ancient poem question sent by the user, the question is recognized as text by speech recognition, the entity related to the knowledge graph in the question is found, and the knowledge triple in the two-hop knowledge graph is extracted as a candidate subgraph centered on the entity;

[0010] In the question / entity coding layer, the pre-training language model CP-ChineseBERT for Chinese ancient poems containing ancient poem character shape and pinyin information is used to encode the entities involved in the question and candidate subgraph.

[0011] In the graph attention network layer, the entity vector obtained by the CP-ChineseBERT encoding entity is operated using the graph attention network to obtain an entity vector containing neighbor node information;

[0012] The question vector obtained by the CP-ChineseBERT and the entity vector obtained by the CP-ChineseBERT and GAT in the candidate subgraph are subjected to the attention layer to obtain the entity vector after the question information selection;

[0013] Finally, the answer to the question is played to the user by using the speech generation.

[0014] Moreover, when constructing the ancient poetry knowledge graph TPKG, a three-level fine-grained framework is used to store the poetry knowledge in layers, and a time chain framework is set to perform reasoning related to the poetry and poets.

[0015] Moreover, the pre-training strategy of the ancient poetry and translation combination is as follows,

[0016] Ancient poetry upper sentence and ancient poetry lower sentence, denoted as P&P: the ancient poetry is directly split into upper and lower two parts, and then spliced as training corpus of the model;

[0017] Ancient poetry upper sentence and upper sentence translation, ancient poetry lower sentence and lower sentence translation, denoted as PT&PT: the ancient poetry is split into upper and lower two parts, and then the corresponding translation is spliced behind, and then spliced as training corpus of the model;

[0018] Ancient poetry upper sentence and lower sentence translation / upper sentence translation and ancient poetry lower sentence, denoted as P&T: after splitting the ancient poetry, replace one part with the corresponding translation, and one ancient poetry data will be split and combined into two training data.

[0019] Moreover, multi-task learning is used for model training, and three training tasks are included, which are two auxiliary tasks of intent recognition and entity recognition and the ancient poetry intelligent question and answer task.

[0020] Moreover, the graph attention network is composed of multiple graph attention layers, and the candidate subgraph can fully interact to integrate all entity information connected with the current entity into the current entity.

[0021] On the other hand, the application provides an ancient poetry intelligent question and answer system based on a knowledge graph, which is used to realize the ancient poetry intelligent question and answer method based on the knowledge graph.

[0022] Moreover, the application comprises a processor and a memory, the memory is used to store program instructions, and the processor is used to call the storage instructions in the memory to execute the ancient poetry intelligent question and answer method based on the knowledge graph.

[0023] Alternatively, it may include a readable storage medium storing a computer program that, when executed, implements a knowledge graph-based intelligent question-and-answer method for ancient poetry as described above.

[0024] This invention constructs a knowledge graph of ancient poetry, TPKG, and establishes a three-level fine-grained framework for poems, verses, and words. This framework can connect related knowledge at different levels to corresponding entities, store knowledge more rationally, and designs a time chain framework for reasoning related to poems and poets.

[0025] This invention proposes a smart question-answering model for classical Chinese poetry, KBQA-CP-ChineseBERT. This invention employs a pre-training strategy combining classical Chinese poetry with its translations, trained on top of ChineseBERT to obtain a pre-trained language model for classical Chinese poetry, CP-ChineseBERT. CP-ChineseBERT incorporates the glyphs and pinyin of the classical poems into its embedding layer, enabling a better understanding of the poem's meaning using the semantic information contained in the glyphs and pinyin. This strategy reconstructs classical Chinese poetry data into a combination of the poem and its modern Chinese translation, quickly aligning the semantic spaces of classical and modern Chinese while doubling the data volume. For user-related questions about classical Chinese poetry, KBQA-CP-ChineseBERT first uses speech recognition to convert the questions into text. Then, it uses the pre-trained language model CP-ChineseBERT to encode the relevant questions and related knowledge graphs, employing a graph attention network to obtain the semantic representation of the knowledge graph. Considering the close semantic connection between the intent and entities in a question and its expression, this invention employs a multi-task learning training model, introducing two auxiliary tasks: entity recognition and intent recognition. This allows for a better understanding of the semantic information expressed in the user's question, thereby more accurately obtaining answers to questions related to classical poetry. Finally, the answer is fed back to the user via voice generation.

[0026] This invention can improve user experience and has significant market value. Attached Figure Description

[0027] Figure 1 This is a schematic diagram of the three-level fine-grained framework of the Tang Poetry Knowledge Graph (TPKG) according to an embodiment of the present invention.

[0028] Figure 2 This is a schematic diagram of the TPKG timeline framework of the Tang Poetry Knowledge Graph, an embodiment of the present invention.

[0029] Figure 3 This is a schematic diagram of the TPKG poet ontology model of Tang poetry knowledge graph, an embodiment of the present invention.

[0030] Figure 4A structure diagram of a knowledge graph-based ancient poetry intelligent question and answer model KBQA-CP-ChineseBERT model of an embodiment of the present application. DETAILED DESCRIPTION

[0031] The technical solutions of the present application are specifically described below in combination with the drawings and embodiments.

[0032] The present application provides a knowledge graph-based ancient poetry intelligent question and answer method, constructs an ancient poetry knowledge graph TPKG, uses a pre-training strategy combining ancient poetry and translation, trains based on a basic model ChineseBERT, and obtains a pre-training language model for ancient poetry CP-ChineseBERT. A knowledge graph-based ancient poetry intelligent question and answer model KBQA-CP-ChineseBERT is constructed using multi-task learning and a graph attention network, including speech recognition, a question / entity encoding layer, a graph attention network layer, an attention layer, and a speech generation module. When speech recognition is performed, entities related to the ancient poetry knowledge graph TPKG in the question are found, and the question / entity encoding layer is realized based on the pre-training language model for ancient poetry CP-ChineseBERT. Model training is performed using multi-task learning, two auxiliary tasks of entity recognition and intent recognition are introduced to understand the semantic information expressed by the user question, obtain the answer to the question related to the ancient poetry, and feed back the answer to the user in the form of speech through the speech generation.

[0033] An embodiment of the present application takes the intelligent question and answer implementation scheme of the Three Hundred Tang Poems as an example, first constructs an ancient poetry knowledge graph based on the Three Hundred Tang Poems for representing information and relationships related to poems and poets. Secondly, a knowledge graph-based ancient poetry intelligent question and answer model is constructed, the ancient poetry knowledge graph is used, and multi-task learning and a graph attention network are used to better answer questions related to ancient poetry.

[0034] An embodiment of the present application constructs a knowledge graph corresponding to the Three Hundred Tang Poems, referred to as TPKG. The Tang Dynasty was a period of prosperity for the development of classical Chinese poetry, and the theme, school, and style were perfect. The Three Hundred Tang Poems includes 313 poems by 77 poets. The poems selected by the Three Hundred Tang Poems are mostly works describing daily life and personal feelings, reflecting the social life style of the Tang Dynasty, and are the focus of historians and literary scholars, and the essence of Tang poetry culture. The poems in the Three Hundred Tang Poems are popular and are included in the compulsory recitation list for primary and secondary school students. Related products have important market value, and there is a lot of information related to the poems on the network, and the information is easy to obtain. Therefore, the present application selects the Three Hundred Tang Poems as the core to construct the Three Hundred Tang Poems knowledge graph TPKG.

[0035] However, the data collected on the Internet is mostly unstructured information, and the information crawled by the crawler contains a lot of noise, which is difficult to use directly. Secondly, there are many versions of the Three Hundred Tang Poems from ancient times to the present, and the information on the network is not unique. For example, a poem may have different translations and appreciations. It is difficult for a computer to automatically select the appropriate version. Finally, the information contained in the same data source is not complete, and multiple data sources need to be accessed. Different data sources require different crawler codes, which is low in efficiency.

[0036] Considering that the Three Hundred Tang Poems only contains 77 poets and 313 poems, the data volume is not large, and there is a lot of redundant information on the network. The embodiment of the application collects data by using a crawler in a manner that supports user adjustment. Specifically, for the main data source containing a lot of information, a crawler is used to crawl by using Python, and then user modification and arrangement are supported. For information that is difficult to scale by using a crawler, such as the growth experience of a poet obtained from the poet's chronological history, a pre-collected manner is adopted to extract the information and save it as structured data. For controversial data, user voting can be supported to determine whether to keep it and which version to keep.

[0037] In constructing the TPKG, a bottom-up method is adopted, that is, the entities are first inducted and organized, and then the upper layer concepts are abstracted. The TPKG takes the 313 poems, 77 poets and 306 time nodes in years from 618 to 923 in the Tang Dynasty as the three main entity types. In order to better understand the emotions contained in the poems and learn the artistic forms of the poems, the embodiment extracts the full-text appreciation and single-sentence appreciation of the poems. At the same time, the relationship network of the poets is highlighted, which facilitates better attention to the connection between the poets and their friends and relatives. The embodiment also focuses on the concept of time, which is related to the experience of the poets and the creation of the poems, facilitating further reasoning.

[0038] Specifically, the TPKG has the following two structural characteristics:

[0039] Reference Figure 1, the embodiment designs a three-level fine-grained framework for poems, verses, and words, which can connect different levels of related knowledge to the corresponding entities and store the knowledge more reasonably. Specifically, the Tang poem entities are divided into three different levels of sub-entities, namely poems, verses, and words. The word entity is the lowest level entity, which only has a "word explanation" attribute. The verse entity is a middle-level entity, which can be combined into a poem and split into a word, and contains more attributes and information than a word. The poem entity is the highest level entity in the poem, which is related to the overall attributes of the poem and other two main entities (poet and time) in the poem. This three-level fine-grained structure conforms to the structural characteristics of the poem and can store Tang poem knowledge more reasonably and in detail. For example, for the ancient poem "Early White Emperor City", its genre is "seven-character quatrains", its rhetoric is "exaggeration", and the full text is "Chengci Baide Caiyunjian, Qianli Jiangling Yiri Huan. Liang'an Juansheng Tizhi, Qianzhao Yiguoshi Chuanzhan." At the verse level, for example, "Chengci Baide Caiyunjian", the intention has "Cheng", "Caiyun", and "Baide", and is located in the "first verse". At the word level, for example, "Cheng" has a word explanation of "morning".

[0040] See Figure 2 , the embodiment connects the time of the Tang Dynasty, and designs a time chain framework. The time chain framework connects the information of the reign title of the Tang Dynasty, the events that occurred, the birth and death of the poet, and other information with the 306 time entities from 618 to 923 in the Tang Dynasty, and can perform reasoning related to poems and poets. For example, in 678, Liao Binwang created the poem "In Prison Singing Cicadas", and in the same year, he experienced "Liao Binwang was transferred to the post of Wu Gong Zhusi, Chang'an Zhusi, and then entered the court as a Shiyushi. When Wu Zetian was in power, he repeatedly wrote memorials to criticize and offend, and was imprisoned." According to the creation time of the poem and the experience of the poet, it can be inferred that "In Prison Singing Cicadas" was used to express the poet's inner sadness.

[0041] Figure 3 The poet ontology model is shown. The ontology model shows the basic information of the poet, such as the number, the character, the alias, the place of birth, and other information, and also records the experience, achievements, and friends of the poet. By connecting these event entities with time entities, the poet's life can be traced back from the time chain, and the poet's social network can be constructed to record the poet's friend relationship and the relationship between poets. For example, through the relationship between Li Bai and Du Fu, Li Bai and Meng Haoran, and other poets, a social network centered on Li Bai can be constructed.

[0042] The TPKG includes a total of 34567 RDF triples, including 8 categories of entities and 59 types of relationships in RDF triples, and the data is relatively rich.

[0043] This invention utilizes the Tang Poetry Knowledge Graph (TPKG) and employs multi-task learning and graph attention networks to construct a knowledge graph-based intelligent question-answering model for classical Chinese poetry, KBQA-CP-ChineseBERT. A key component of this model is the pre-trained language model CP-ChineseBERT, specifically designed for classical Chinese poetry.

[0044] To obtain more accurate semantic representations of classical Chinese poetry, this invention designs three pre-training strategies that combine classical poems with their translations. These strategies construct training corpora by combining classical poems with their modern Chinese translations. Then, using ChineseBERT as the base model, further training is conducted using the strategies designed in this invention to obtain CP-ChineseBERT. Specifically, the three strategies for combining classical poems with their translations are as follows:

[0045] Poem and Poem (P&P): This strategy involves directly splitting an ancient poem into two parts, such as splitting "Quiet Night Thoughts" into "Before my bed, the bright moonlight shines, I wonder if it is frost on the ground" and "I raise my head to gaze at the bright moon, I lower my head to think of my hometown." These parts are then combined to form the training corpus for the model. This strategy does not incorporate modern Chinese translations of the ancient poems.

[0046] The method involves splitting the poem into two parts: the first line and its translation, and the second line and its translation (PT&PT). Each part is then combined with its corresponding translation. For example, the poem "Quiet Night Thoughts" is split and combined into two parts: "Before my bed, the bright moonlight shines, I wonder if it's frost on the ground" and "I raise my head to gaze at the bright moon, then lower it to think of my hometown; I raise my head to gaze at the mountain moon, and lower it to ponder, my longing for my hometown growing stronger." These parts are then combined as training data for the model. This strategy incorporates modern Chinese translations of the poem. When learning the poem, the model can first learn the modern Chinese translation from the input data and then utilize the semantic connections between the two lines to understand the poem. This method can alleviate the difficulty of directly learning from the poem to some extent.

[0047] Poem and Translation (P&T): This method involves splitting an ancient Chinese poem and replacing one part with its corresponding translation. For example, "Quiet Night Thoughts" can be split and combined into "Before my bed, the bright moonlight shines, I wonder if it's frost on the ground; I raise my head to gaze at the mountain moon, and can't help but lower my head in deep thought, increasingly missing my hometown" and "Before my bed, I see the bright moonlight shining on the ground, and in my hazy state, I wonder if it's a patch of autumn frost; I raise my head to gaze at the bright moon, and lower my head in thought of my hometown." One poem is split and combined into two training datasets, increasing the data volume. This strategy helps the model understand the poem and also expands the original poem data into a combination of the poem and its translation, doubling the original data volume.

[0048] Furthermore, CP-ChineseBERT incorporates the glyphs and pinyin of Chinese characters. These glyphs and pinyin contain rich semantic information, helping the model to better understand classical Chinese poetry.

[0049] During training, CP-ChineseBERT uses a Masked Language Model (MLM) and a Next Sentence Prediction (NSP) task. The MLM task masks words only in the classical Chinese poem portion, not in its modern Chinese translation. The masking strategy involves randomly masking 15% of the words; of these masked words, 80% are replaced with "[MASK]", 10% are replaced with any word from the vocabulary, and 10% remain unchanged. The NSP task predicts the relationship between the preceding and following sentences of the input. Depending on the strategy, the subject of the prediction varies. In the P&T strategy, the NSP task predicts the relationship between the classical Chinese poem and its modern Chinese translation; in the P&P and PT&PT strategies, the NSP task predicts the adjacency relationship between the preceding and following sentences of the classical Chinese poem.

[0050] KBQA-CP-ChineseBERT comprises five modules: speech recognition, question / entity encoding layer, graph attention network layer, attention layer, and speech generation. Its model structure diagram is shown below. Figure 4 As shown. Specifically, for voice messages sent by users that contain questions about classical Chinese poems, the following processing is performed:

[0051] 1) First, speech recognition technology is used to identify the question as text. Entities related to the knowledge graph within the question are found, and these entities are used as the center to extract two-hop knowledge triples from the knowledge graph as candidate subgraphs. A two-hop refers to two knowledge triples. For example, for the knowledge triples <Early Departure from Baidi City, Author, Li Bai> and <Li Bai, Style Name, Taibai>, both triples contain the entity "Li Bai". Therefore, through this entity, the two knowledge triples can be connected into a two-hop path: Early Departure from Baidi City → Li Bai → Taibai.

[0052] 2) Then, a pre-trained language model for classical Chinese poetry (CP-ChineseBERT) containing information on the glyphs and pinyin of the ancient poems is used to encode the entities involved in the question and candidate subgraphs. The question / entity encoding layer is described in detail below.

[0053] At the question / entity encoding layer, for a given piece of data, the encoder encodes the question q into a statement vector V. q The candidate subgraph involves all entities E = {e1, e2, ..., e}. m Encode as entity vector V E={v1,v2,…,v m}, where m is the number of entities involved in the candidate subgraph, v i It is e i The entity vector. The specific encoding process is expressed as follows:

[0054] V q =CP-ChineseBERT(q)

[0055] v i =CP-ChineseBERT(e i )

[0056] Wherein, CP-ChineseBERT(·) represents the pre-trained language model CP-ChineseBERT for classical Chinese poetry trained in this invention. CP-ChineseBERT is used to encode entities within each candidate subgraph, and then these are merged to obtain the entity vector V. E For example, each entity, after being processed by CP-ChineseBERT, yields a vector of dimension (1, 768). There are m entities in total. Merging these entities results in an entity vector V of dimension (m, 768). E .

[0057] 3) The entity vectors obtained by CP-ChineseBERT encoding are processed using a Graph Attention Network (GAT) to obtain entity vectors containing information about neighboring nodes. The Graph Attention Network layers are described in detail below.

[0058] In the graph attention network layer, considering the matching degree between the knowledge graph structure and the graph neural network, this embodiment of the invention preferentially uses a graph attention network layer (GAT) to process candidate subgraphs. The basic idea of ​​existing graph attention networks (GAT) is to calculate the attention weight between each neighbor node and the current node, and then sum the representations of the neighbor nodes with their corresponding weights to obtain the aggregated representation. In this embodiment, for each entity in the candidate subgraph, information from its surrounding nodes is integrated. The graph attention network transmits information between entities by stacking multiple graph attention layers. Each layer learns and updates the representation of the current entity by aggregating the information of its neighbor nodes through self-attention. Through organization and aggregation, the current entity can contain information from its surrounding neighbor nodes.

[0059] Graph attention networks will apply entity vectors V E ={v1,v2,…,v m As input, in the t-th graph attention layer (t≠1), This represents the input vector of this layer, which is also the output of the (t-1)th graph attention layer, where entity e iThe vector representation is The graph attention mechanism applies attention to each entity e in the candidate subgraph. i Perform the operation, as shown in the formula below.

[0060]

[0061] in, It is entity e in the t-th graph attention layer that combines information from all neighboring nodes. i The output, It is entity e in the (t-1)th graph attention layer that combines information from all neighboring nodes. j The output, W t and b t These are learnable parameters, where E(i) represents the relationship between the candidate subgraph and entity e. i Directly connected entities, such as if e i If it is connected to e1 and e2, then j takes the values ​​1 and 2 here. It is the attention weight, which reflects the entity e. i and entity e j The degree of matching between them is determined by ReLU(·), which is the activation function. The specific learning process is as follows:

[0062]

[0063]

[0064] Where [;] indicates splicing, W t It is a learnable weight matrix. This indicates that entity e is fused at the t-th graph attention layer. j Information entity e i This indicates that LeakyReLU(·) is the activation function. Ultimately, the entity e in the t-th graph attention layer is obtained. i and entity e j Attention weights.

[0065] By using a graph attention network to encode the entity vectors within the candidate subgraph, an entity representation VG incorporating neighbor node information is obtained. E ={vg1,vg2,…,vg m}

[0066] To more comprehensively extract the relationships between entities, this invention employs multi-head attention, where each head can independently obtain the vector representation of each entity. By utilizing a graph attention network composed of multiple graph attention layers, candidate subgraphs can fully interact. Integrating the information of all entities connected to the current entity into the current entity can supplement entity information, demonstrating good performance in the ancient poetry intelligent question answering task.

[0067] 4) Then, the question vector obtained by the CP-ChineseBERT of the question and the entity vector obtained by the CP-ChineseBERT and GAT of the entity in the candidate subgraph are input into the attention layer to obtain the entity vector after the selection of the question information. The attention layer is described in detail below.

[0068] In the attention layer, in order to correctly select the answer to the question in the candidate subgraph, the application uses an attention network to fuse the question and the candidate subgraph. Specifically, the encoding vector V q As the query (query), the entity VG E As the key (key) and value (value), the calculation process is as follows:

[0069]

[0070] Where m is the number of entities in the candidate subgraph, s(·) is a function for calculating relevance, commonly used dot product, softmax(·) is an activation function, · is a cumulative function. Att(K, Q, V (is the attention information of a group K, V for a Q.

[0071] After the candidate subgraph entity vector and the question encoding vector pass through the attention layer, the entity vector V qa After passing through the fully connected layer and the Softmax activation function, the final answer is obtained.

[0072] 5) Finally, the voice generation technology is used to play the answer to the question to the user.

[0073] Where the question vector obtained by the question / entity encoding layer using the user question is used to complete the entity recognition and intent recognition tasks, and the final entity vector output by the attention layer is used to complete the intelligent question and answer task, so that the three tasks are trained at the same time.

[0074] The application uses multi-task learning to train the model, and contains three training tasks, which are two auxiliary tasks of intent recognition and entity recognition and the intelligent question and answer task of ancient poetry.

[0075] The intent recognition task is used to supervise the intent of the question. For the vector V q , the vector at the first position is used as the vector representation of the question, and after passing through the fully connected layer and the Softmax layer, the intent recognition task is completed, and the intent recognition loss L intend is calculated. intend The multi-class cross-entropy loss is used to calculate. The calculation method is as follows:

[0076] V intent= Softmax (Leaner (V q [0])

[0077]

[0078] where Vq q [0] is the output vector of the question encoder at the first position, Leaner (·) is a linear layer, Softmax (·) is an activation function, and T is the number of classes of the intent. Finally, the loss L intend .

[0079] The entity recognition task takes the entities related to ancient poems contained in the question as the supervision signal. For the vector V q obtained by question encoding, for positions other than '[CLS]' and '[SEP]', after passing through a fully connected layer and a Softmax layer, binary classification prediction is performed, then the adjacent words whose prediction results are 1 are spliced as the final entity prediction result, and the entity recognition loss L ner is calculated. The entity recognition loss L ner is calculated using the binary cross-entropy loss. The specific calculation process is as follows:

[0080] V ner = Softmax (Leaner (V q ))

[0081]

[0082] where V q is the output vector of the question encoder, Leaner (·) is a linear layer, Softmax (·) is an activation function, and N is the sequence length of the question. By calculating each position of the output vector V ner , the loss L ner of the entity recognition task is obtained.

[0083] The ancient poem intelligent question answering task calculates the loss using the final output V qa of the attention layer. The loss of the ancient poem intelligent question answering task is calculated using V qa , and the loss function is as follows:

[0084]

[0085] where m is the number of entities within the candidate subgraph. By calculating each position of the final output V qa , the loss L qa of the ancient poem intelligent question answering task is obtained.

[0086] The loss of the KBQA-CP-ChineseBERT is composed of the intelligent question answering task loss value, the intention recognition loss value and the entity recognition loss value, and the objective function of the model is as follows:

[0087] L Total =L qa +λ1L intent +λ2L ner

[0088] Wherein, λ1 and λ2 are preset hyperparameters, and the experience values can be set as 1 according to experiments.

[0089] Through the joint training of the three tasks of intelligent question answering, intention recognition and entity recognition, the model can accurately answer the questions related to the Three Hundred Tang Poems by using the ancient poetry knowledge graph.

[0090] The embodiment of the application constructs the knowledge graph of the Three Hundred Tang Poems and proposes an intelligent question answering method for ancient poetry, but the structure of the knowledge graph and the intelligent question answering method for ancient poetry are not limited to the Three Hundred Tang Poems. Specifically, the ancient poetry and ancient lyrics of any dynasty can be represented as structured data by using the three-level fine-grained framework for poetry, the time chain framework for time and the ontology model for poets proposed by the application, and can be used to complete the tasks related to ancient poetry. At the same time, as long as there is corresponding ancient poetry question answering corpus and knowledge graph, the model trained by using the intelligent question answering method for ancient poetry proposed by the application can answer questions related to ancient poetry.

[0091] Since the CP-ChineseBERT used in the application is for the semantic space of ancient poetry, the method cannot achieve significant results when used in modern texts, such as modern poetry, due to the gap between the semantics of ancient poetry and modern texts.

[0092] In specific implementation, the method proposed in the technical solution of the application can be automatically run by computer software technology, and the system device of the method, such as a computer readable storage medium storing the corresponding computer program of the technical solution of the application and a computer device including a computer program running device, should also be within the protection scope of the application.

[0093] In some possible embodiments, a knowledge graph-based intelligent question answering system for ancient poetry is provided, including a processor and a memory, the memory is used to store program instructions, and the processor is used to call the stored instructions in the memory to execute a knowledge graph-based intelligent question answering method for ancient poetry as described above.

[0094] In some possible embodiments, a knowledge graph-based ancient poetry intelligent question and answer system is provided, comprising a readable storage medium, and a computer program is stored on the readable storage medium, and the computer program is executed to implement the knowledge graph-based ancient poetry intelligent question and answer method.

[0095] The embodiments are only illustrative of the spirit of the present application. Those skilled in the art to which the present application pertains can make various modifications or supplements to the described specific embodiments or replace them with similar ways, for example, each threshold value can be set by those skilled in the art according to specific conditions, but will not deviate from the spirit of the present application or exceed the scope defined by the appended claims.

Claims

1. A method for intelligent question and answer of ancient poems based on a knowledge graph, characterized in that: The ancient poem knowledge graph TPKG is constructed; a pre-training strategy combining ancient poems and translations is used to train a pre-training language model CP-ChineseBERT based on a basic model ChineseBERT to obtain a pre-training language model CP-ChineseBERT for ancient poems; a knowledge graph-based ancient poem intelligent question-answering model KBQA-CP-ChineseBERT is constructed by using multi-task learning and a graph attention network, and comprises a speech recognition, a question / entity encoding layer, a graph attention network layer, an attention layer and a speech generation module, wherein the speech recognition finds the entities related to the ancient poem knowledge graph TPKG in the question, and the question / entity encoding layer is realized based on the pre-training language model CP-ChineseBERT for ancient poems; the model is trained by using multi-task learning, and two auxiliary tasks of entity recognition and intent recognition are introduced to understand the semantic information expressed by the user question and obtain the answer to the question related to the ancient poem, and the answer is fed back to the user in the form of speech through speech generation; In the knowledge graph-based ancient poem intelligent question-answering model KBQA-CP-ChineseBERT, the following processing is performed, For the speech containing an ancient poem question sent by the user, the question is recognized as text through speech recognition, the entities related to the knowledge graph in the question are found, and the knowledge triples within two hops of the knowledge graph are extracted as candidate subgraphs centered on the entities; In the question / entity encoding layer, the pre-training language model CP-ChineseBERT for Chinese ancient poems containing the information of the ancient poem characters and pinyin is used to encode the entities involved in the question and the candidate subgraphs; In the graph attention network layer, the graph attention network is used to operate on the entity vectors obtained by the CP-ChineseBERT encoding entities to obtain entity vectors containing neighbor node information; The question vector obtained by the CP-ChineseBERT and the entity vector obtained by the CP-ChineseBERT and the GAT on the entities in the candidate subgraph are subjected to the attention layer to obtain the entity vector selected by the question information; Finally, the answer to the question is played to the user by using the speech generation.

2. The method of claim 1, wherein the method comprises: When the ancient poem knowledge graph TPKG is constructed, a three-level fine-grained framework is used to store the poem knowledge in layers, and a time chain framework is set to perform reasoning related to poems and poets.

3. The method of claim 1, wherein the method further comprises: The pre-training strategy combining ancient poems and translations is as follows, Ancient poem upper sentence and ancient poem lower sentence, denoted as P&P: the ancient poem is directly split into upper and lower two parts, and then spliced as the training corpus of the model; Ancient poem upper sentence and upper sentence translation, and ancient poem lower sentence and lower sentence translation, denoted as PT&PT: the ancient poem is split into upper and lower two parts, and then the corresponding translation is spliced behind, and then spliced as the training corpus of the model; Ancient poem upper sentence and lower sentence translation / upper sentence translation, and ancient poem lower sentence, denoted as P&T: after splitting the ancient poem, replace part of it with the corresponding translation, and one ancient poem data will be split and combined into two training data.

4. The ancient poetry intelligent question and answer method based on a knowledge graph according to claim 1, characterized in that: The model is trained by using multi-task learning, and three training tasks are included, which are two auxiliary tasks of intent recognition and entity recognition and an ancient poem intelligent question-answering task.

5. The ancient poetry intelligent question and answer method based on a knowledge graph according to claim 1 or 2 or 3 or 4, characterized in that: The graph attention network is composed of multiple graph attention layers, candidate subgraphs can sufficiently interact, and all entity information connected with the current entity is integrated into the current entity.

6. An ancient poem intelligent question and answer system based on a knowledge graph, characterized by: The application discloses a knowledge graph-based ancient poetry intelligent question-answering method.

7. The ancient poetry intelligent question-answering system based on a knowledge graph according to claim 6, characterized in that: The application discloses a processor and a memory, the memory is used for storing program instructions, and the processor is used for calling the stored instructions in the memory to execute the knowledge graph-based ancient poetry intelligent question-answering method.

8. The ancient poetry intelligent question-answering system based on a knowledge graph according to claim 6, characterized in that: The application discloses a readable storage medium, and the readable storage medium stores a computer program, and the computer program is executed to realize the knowledge graph-based ancient poetry intelligent question-answering method.