Model training method and device, description text generation method, equipment and medium

By using pre-trained models and graph neural network training, the problems of knowledge graph updates and insufficient labeled data are solved, enabling the generation of accurate descriptive text with a small amount of labeled data, and supporting the continuous learning and updating of the model.

CN115422337BActive Publication Date: 2026-02-03PING AN TECH (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211102133.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-09
Publication Date
2026-02-03
Estimated Expiration
2042-09-09

AI Technical Summary

Technical Problem

Existing technologies require a large amount of labeled data to generate descriptive text when knowledge graphs are updated and knowledge domains are imbalanced, which makes data labeling and model training inconvenient.

Method used

By acquiring a pre-trained text prediction model, using masking and graph neural network training to train the encoding module, and combining the knowledge graph update, a text generation model is constructed, reducing the dependence on labeled data and enabling the model to learn continuously.

Benefits of technology

Even with limited labeled data, it can accurately generate descriptive text for knowledge graphs and update the model at any time to adapt to changes in the knowledge graph, reducing retraining costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115422337B_ABST
    Figure CN115422337B_ABST
Patent Text Reader

Abstract

A model training method and device, a description text generation method, equipment and a medium are provided. The model training method comprises: obtaining a pre-trained text prediction model. A first knowledge graph and a corresponding first description text are obtained, a to-be-processed field is obtained from the first description text and is subjected to mask processing to obtain a second description text. The second description text is input into a first encoding module of the text prediction model for encoding processing to obtain a first feature vector. A second encoding module is trained according to the first knowledge graph and the first feature vector to obtain a third encoding module. The first knowledge graph is input into the third encoding module for encoding processing to obtain a second feature vector. The second feature vector is input into a first decoding module of the text prediction model for training processing to obtain a second decoding module. A text generation model is constructed according to the third encoding module and the second decoding module, which can reduce the dependence on labeled data and accurately generate a description text of a knowledge graph.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular to a model training method and apparatus, a descriptive text generation method, device, and medium. Background Technology

[0002] Knowledge graphs are structured text data used to provide common sense support for various downstream tasks of natural language generation (NLG). In contexts such as question answering or intelligent dialogue, by combining the common sense relationships contained in the knowledge graph, an introductory text can be generated to help users quickly understand the graph's content. Currently, traditional generative models are typically used to generate descriptive text for knowledge graphs, but this approach requires a large amount of labeled data for training the model. Because knowledge graphs are constantly updated and the distribution of knowledge domains is uneven, this poses significant challenges to data labeling and model training. Therefore, how to accurately generate descriptive text for knowledge graphs with limited labeled data has become a pressing technical problem. Summary of the Invention

[0003] The main objective of this application is to propose a model training method and apparatus, a descriptive text generation method, device, and medium that can reduce the dependence on labeled data and accurately generate descriptive text for knowledge graphs.

[0004] To achieve the above objectives, a first aspect of this application proposes a model training method for training a dialogue generation model, the method comprising:

[0005] A pre-trained text prediction model is obtained, comprising a first encoding module and a first decoding module; a first knowledge graph and a first descriptive text corresponding to the first knowledge graph are obtained; a field to be processed is obtained from the first descriptive text, and the field to be processed is masked to obtain a second descriptive text; the second descriptive text is input into the first encoding module for encoding processing to obtain a first feature vector; a preset second encoding module is trained based on the first knowledge graph and the first feature vector to obtain a third encoding module; the first knowledge graph is input into the third encoding module for encoding processing to obtain a second feature vector; the second feature vector is input into the first decoding module for training processing to obtain a second decoding module; and the text generation model is constructed based on the third encoding module and the second decoding module.

[0006] In some embodiments, before inputting the second feature vector into the first decoding module for training processing to obtain the second decoding module, the method further includes:

[0007] The second feature vector is serialized to obtain the first sequence;

[0008] The step of inputting the second feature vector into the first decoding module for training processing to obtain the second decoding module includes:

[0009] The first sequence is input into the first decoding module for training processing to obtain the second decoding module.

[0010] In some implementations, the step of inputting the second feature vector into the first decoding module for training processing to obtain the second decoding module includes:

[0011] The second feature vector is input into the first decoding module for decoding to obtain the second description text; a first loss value is calculated based on the second description text and the first description text; the parameters of the first decoding module are updated based on the first loss value to obtain the second decoding module.

[0012] In some implementations, the step of inputting the second feature vector into the first decoding module for training processing to obtain the second decoding module includes:

[0013] The second feature vector is input into the first decoding module for decoding to obtain the second description text. At least two first entity objects and a second entity object associated with each of the first entity objects are identified from the second description text, and the first association information between the first entity objects and the second entity objects is analyzed. At least two third entity objects and a fourth entity object associated with each of the third entity objects are obtained from the first knowledge graph, and the second association information between the third entity objects and the fourth entity objects is analyzed. A second loss value is calculated based on the first entity objects, the first association information, the third entity objects, and the second association information. The parameters of the first decoding module are updated based on the second loss value to obtain the second decoding module.

[0014] In some implementations, the training steps of the text prediction model include:

[0015] Obtain descriptive text samples; determine the fields to be masked from the descriptive text samples, and perform masking processing on the fields to be masked to obtain reference descriptive text; input the reference descriptive text into a pre-built generative model for training processing to obtain a text prediction model.

[0016] To achieve the above objectives, a second aspect of this application provides a method for generating descriptive text, the method comprising:

[0017] Obtain the second knowledge graph;

[0018] A text generation model is obtained, which includes a third encoding module and a second decoding module, and the text generation model is trained according to the model training method described in the first aspect above; the second knowledge graph is input into the third encoding module for encoding processing to obtain a third feature vector; the third feature vector is input into the second decoding module for decoding processing to obtain the target description text corresponding to the second knowledge graph.

[0019] In some implementations, the step of inputting the third feature vector into the second decoding module for decoding processing to obtain the target description text corresponding to the second knowledge graph includes:

[0020] The third feature vector is serialized to obtain a second sequence; the second sequence is then input into the second decoding module for decoding to obtain the target description text corresponding to the second knowledge graph.

[0021] To achieve the above objectives, a third aspect of this application provides a model training apparatus for training a text generation model, the apparatus comprising:

[0022] The first acquisition unit is used to acquire a pre-trained text prediction model, the text prediction model including a first encoding module and a first decoding module; and to acquire a first knowledge graph and a first descriptive text corresponding to the first knowledge graph.

[0023] A masking unit is used to obtain the field to be processed from the first description text and to perform masking processing on the field to be processed to obtain the second description text.

[0024] The first encoding unit is used to input the second descriptive text into the first encoding module for encoding processing to obtain a first feature vector;

[0025] The first training unit is used to train the preset second encoding module based on the first knowledge graph and the first feature vector to obtain the third encoding module;

[0026] The second encoding unit is used to input the first knowledge graph into the third encoding module for encoding processing to obtain the second feature vector;

[0027] The second training unit is used to input the second feature vector into the first decoding module for training processing to obtain the second decoding module;

[0028] The construction unit is used to construct the text generation model based on the third encoding module and the second decoding module.

[0029] To achieve the above objectives, a fourth aspect of this application provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the model training method described in the first aspect or the descriptive text generation method described in the second aspect.

[0030] To achieve the above objectives, a fifth aspect of the present application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the model training method described in the first aspect or the descriptive text generation method described in the second aspect.

[0031] The model training method, apparatus, descriptive text generation method, device, and medium proposed in this application obtain a first descriptive text from a first knowledge graph. The fields to be processed in the first descriptive text are masked to obtain a second descriptive text. This second descriptive text is then input into the first encoding module of a text prediction model for encoding to obtain a first feature vector. Subsequently, a second encoding module is trained based on the first feature vector and the first knowledge graph to obtain a third encoding module. This third encoding module can encode the first knowledge graph into a second feature vector aligned with the first feature vector. Therefore, it can fully utilize incomplete descriptive text, guiding the second encoding module to learn the relevant graph structure and the internal representation of knowledge within the descriptive text, effectively solving the problem of insufficient labeled data in practical applications. Based on this, the second feature vector is input into the first decoding module of the text prediction model for training to obtain a second decoding module. This enables the second decoding module to predict complete descriptive text by combining the knowledge graph, thereby achieving accurate generation of descriptive text from the knowledge graph even with limited labeled data. Furthermore, it can train relevant modules to learn new knowledge at any time according to updates to the knowledge graph, with low retraining costs, thus facilitating the model's sustainable learning. Attached Figure Description

[0032] Figure 1 This is a schematic flowchart of a model training method provided in an embodiment of this application;

[0033] Figure 2 This is a schematic diagram of the model structure used in the embodiments of this application;

[0034] Figure 3 This is a flowchart illustrating a training method for a text prediction model provided in an embodiment of this application;

[0035] Figure 4 yes Figure 1 A schematic diagram of a specific process for step S107;

[0036] Figure 5 yes Figure 1 Another specific process diagram for step S107;

[0037] Figure 6 This is a flowchart illustrating a text generation method provided in an embodiment of this application;

[0038] Figure 7 This is a block diagram of a model training apparatus provided in some embodiments of this application;

[0039] Figure 8 This is a block diagram of a descriptive text generation apparatus provided in some embodiments of this application;

[0040] Figure 9 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0041] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0042] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.

[0043] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0044] First, let's analyze some of the terms used in this application:

[0045] Artificial intelligence (AI) is a new branch of computer science that studies, develops, and applies theories, methods, technologies, and systems to simulate, extend, and expand human intelligence. It aims to understand the essence of intelligence and produce intelligent machines that can react in a way similar to human intelligence. Research in this field includes robotics, speech recognition, image recognition, natural language processing, and expert systems. AI can simulate the information processes of human consciousness and thought. Furthermore, AI utilizes digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceiving the environment, acquiring knowledge, and using that knowledge to achieve optimal results.

[0046] Natural Language Processing (NLP): NLP uses computers to process, understand, and utilize human language (such as Chinese and English). It is a branch of artificial intelligence and an interdisciplinary field of computer science and linguistics, often referred to as computational linguistics. NLP includes syntactic analysis, semantic analysis, and discourse understanding. It is commonly used in machine translation, handwritten and printed character recognition, speech recognition and text-to-speech conversion, information retrieval, information extraction and filtering, text classification and clustering, sentiment analysis, and opinion mining. It involves data mining, machine learning, knowledge acquisition, knowledge engineering, artificial intelligence research, and linguistic research related to language computation.

[0047] Knowledge graphs are structured text data used to provide common sense support for various downstream tasks in natural language generation. In contexts such as question answering or intelligent dialogue, by combining the common sense relationships contained within a knowledge graph, introductory text can be generated to help users quickly understand the graph's content. Currently, traditional generative models are typically used to generate descriptive text for knowledge graphs, but this approach requires a large amount of labeled data for training the model. Because knowledge graphs are constantly updated and the distribution of knowledge domains is uneven, this poses significant challenges to data labeling and model training. Therefore, accurately generating descriptive text for knowledge graphs with limited labeled data has become a pressing technical problem.

[0048] Embedding: The embedding layer is a word embedding jointly learned with a neural network model specific to natural language processing. This embedding method performs one-hot encoding on words in cleaned text, and the size or dimension of the vector space is specified as part of the model, such as 50, 100, or 300 dimensions. The vectors are initialized with small random numbers. The embedding layer is used as the front end of the neural network and is supervised by backpropagation. Encoded words are mapped to word vectors, which are concatenated before being input into the model if a multilayer perceptron (MLP) model is used. If a recurrent neural network (RNN) is used, each word can be used as an input to the sequence. This method of learning embedding layers requires a large amount of training data and can be slow, but it can train embedding models that are suitable for both text-specific data and NLP. Embedding is a vector representation that uses a low-dimensional vector to represent an object. This object can be a word, a product, a movie, etc. The property of this embedding vector is that vectors with close proximity correspond to objects with similar meanings. For example, the embeddings of "Avengers" and "Iron Man" are very close, but the embeddings of "Avengers" and "Gone with the Wind" are farther apart. Essentially, embedding is a mapping from semantic space to vector space, while preserving the semantic relationships of the original samples in the vector space as much as possible. For instance, two semantically similar words are also relatively close in the vector space. Embedding can encode objects using low-dimensional vectors while retaining their meaning. It is commonly used in machine learning. In the process of building machine learning models, objects are encoded into low-dimensional dense vectors before being fed into a deep neural network (DNN) to improve efficiency.

[0049] Based on this, embodiments of this application provide a model training method and apparatus, a descriptive text generation method, device, and medium that can reduce reliance on labeled data and accurately generate descriptive text for knowledge graphs.

[0050] This application provides a model training method and apparatus, a descriptive text generation method, a device, and a medium, which are specifically described through the following embodiments. First, the model training method in the embodiments of this application is described.

[0051] The embodiments of this application can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence is the theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results.

[0052] Foundational technologies for artificial intelligence generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies mainly encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.

[0053] The model training method and descriptive text generation method provided in this application relate to the field of artificial intelligence technology. The model training method or descriptive text generation method provided in this application can be applied to a terminal, a server, or software running on either a terminal or a server. In some embodiments, the terminal can be a smartphone, tablet, laptop, desktop computer, or smartwatch, etc.; the server can be an independent server or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms; the software can be an application implementing the model training method or descriptive text generation method, but is not limited to the above forms.

[0054] This application can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0055] Firstly, please refer to Figure 1 and Figure 2 , Figure 1 This is a flowchart illustrating a model training method provided in an embodiment of this application. Figure 2 This is a schematic diagram of the model structure used in the embodiments of this application. The model training method includes steps S101 to S108. It should be understood that the model training method in the embodiments of this application includes, but is not limited to, steps S101 to S108. The following describes the method in conjunction with... Figure 1 and Figure 2 A detailed introduction will be provided.

[0056] Step S101: Obtain a pre-trained text prediction model, which includes a first encoding module and a first decoding module.

[0057] In this embodiment, the text prediction model can employ a pre-trained language model. The principle of a pre-trained language model is as follows: the model is pre-trained through a series of tasks to obtain initial model parameters, the model is initialized using these initial parameters, and then the model undergoes subsequent training. Specifically, the text prediction model can employ a bidirectional and auto-regressive transformer (BART) model, a BERT model, or a GPT model, etc., without limitation.

[0058] It is understandable that the text prediction model can be the initially built and pre-trained prediction model, or it can be the text prediction model obtained from the previous training, without any specific limitation.

[0059] Step S102: Obtain the first knowledge graph and the first description text corresponding to the first knowledge graph.

[0060] In this embodiment of the application, the first descriptive text is used to describe the common knowledge content and semantic relationships contained in the first knowledge graph. For example, if the first knowledge graph is a knowledge graph of a certain type of flower variety, the first descriptive text may be an introductory text including graph knowledge points such as the type and origin of that type of flower variety. In practical applications, the first descriptive text may be text content manually annotated for the first knowledge graph, and there is no specific limitation.

[0061] In some optional implementations, when a change event in the knowledge base is detected, a first knowledge graph and its corresponding first descriptive text can be obtained. The first knowledge graph then becomes the knowledge graph corresponding to the change event, facilitating timely model updates based on the changes in the knowledge graph. The knowledge base is a graph database used to store the knowledge graphs. Graph databases may include, but are not limited to, Neo4j, JanusGraph, HugeGraph, Nebula, gStore, DGraph, OrientDB, or ArangoDB. Change events include, but are not limited to, any of the following: a new knowledge graph is added to the knowledge base; or any knowledge graph in the knowledge base undergoes a content change, such as deletion, modification, or addition of content (including nodes and node connection relationships).

[0062] Step S103: Obtain the field to be processed from the first description text and perform masking on the field to be processed to obtain the second description text.

[0063] In this embodiment, the first descriptive text may include at least two fields, and the fields to be processed are the fields in the first descriptive text that are to be masked. In one implementation, commonly known fields marked by human intervention can be obtained from the first descriptive text as fields to be processed. In another implementation, the usage frequency of each field in the first descriptive text can be obtained, and the N fields with the highest usage frequency can be selected as fields to be processed, where N is a positive integer that can be set and adjusted manually and is not limited. In yet another implementation, N fields can be randomly selected from the first descriptive text as fields to be processed.

[0064] In the embodiments of this application, the masking process includes, but is not limited to, replacing the field to be processed with a specified mask field. The specified mask field includes, but is not limited to, blank fields and other special characters.

[0065] Step S104: Input the second descriptive text into the first encoding module for encoding processing to obtain the first feature vector.

[0066] Step S105: Train the preset second encoding module based on the first knowledge graph and the first feature vector to obtain the third encoding module.

[0067] In the embodiments of this application, the second encoding module may adopt a graph neural network model, such as a graph neural network (GCN) model, a graph attention network (GAT) model, or a diffusion graph convolution (DGC) model, etc., without specific limitations.

[0068] In some optional implementations, step S105 may include, but is not limited to, the following steps:

[0069] The first knowledge graph is input into the second encoding module for encoding processing to obtain the fourth feature vector. Based on the first and fourth feature vectors, a third loss value is calculated, and the parameters of the second encoding module are updated according to the third loss value to obtain the third encoding module.

[0070] In one implementation, the cosine similarity between the first and fourth feature vectors can be calculated, and the negative value of the cosine similarity can be used as the third loss value. Further optionally, the first feature vector can include m (m is a positive integer) first word embeddings, and the fourth feature vector can include m second word embeddings. Since there is a one-to-one correspondence between the m first word embeddings and the m second word embeddings, m embedding pairs can be obtained. Based on this, the cosine similarity of each embedding pair can be summed to obtain the summed result, and the negative value of the summed result can be used as the third loss value.

[0071] In other implementations, the first and fourth feature vectors are substituted into a preset first loss function to obtain the third loss value. The first loss function can be any of the following, including but not limited to the 0-1 loss function, absolute value loss function, logarithmic loss function, exponential loss function, and Hinge loss function. It can be selected and adjusted according to actual needs, and will not be elaborated here.

[0072] As can be seen, by combining the feature vectors output by the first encoding module, the second encoding module is trained into a third encoding module, ensuring that the feature vectors output by the third encoding module are aligned with those output by the first encoding module. Since the feature vectors output by the first encoding module include the feature vectors predicted for the field to be processed, the above model training steps can better train the third encoding module to accurately identify specific words from the knowledge graph and perform vector encoding. The type of specific words is related to the type of the field to be processed; in practical applications, specific words can include, but are not limited to, common knowledge words, key words, or frequently used words.

[0073] Step S106: Input the first knowledge graph into the third encoding module for encoding processing to obtain the second feature vector.

[0074] Step S107: Input the second feature vector into the first decoding module for training processing to obtain the second decoding module.

[0075] In other words, in the pre-trained text prediction model, the first encoding module can play an auxiliary role in training the second encoding module and is used to align vectors with the second encoding module, but it does not need to update parameters through backpropagation, while the first decoding module participates in the entire training process of the text generation model.

[0076] Step S108: Construct a text generation model based on the third encoding module and the second decoding module.

[0077] As can be seen, through the steps S101 to S108 described above, incomplete descriptive text can be fully utilized to guide the second encoding module to learn the relevant graph structure and the internal representation of knowledge in the descriptive text, effectively solving the problem of insufficient labeled data in practical applications. Based on this, the second feature vector is input into the first decoding module of the text prediction model for training, resulting in the second decoding module. This enables the second decoding module to predict complete descriptive text by combining the knowledge graph, thereby achieving accurate generation of descriptive text of the knowledge graph even with limited labeled data. Furthermore, the relevant modules can be trained to learn new knowledge at any time according to the updates of the knowledge graph, with low retraining costs, thus facilitating the model's sustainable learning.

[0078] For some alternative implementation methods, please refer to Figure 3 , Figure 3This is a flowchart illustrating a training method for a text prediction model provided in an embodiment of this application. Figure 3 As shown, the training steps for the text prediction model may include, but are not limited to, steps S301 to S303.

[0079] Step S301: Obtain a sample descriptive text.

[0080] Step S302: Determine the field to be masked from the description text sample, and perform masking processing on the field to be masked to obtain the reference description text.

[0081] The descriptive text sample may include at least two fields, and the fields to be masked are the fields in the descriptive text sample that require masking. One implementation involves obtaining manually labeled common-sense fields from the descriptive text sample as the fields to be masked. Another implementation involves obtaining the usage frequency of each field in the descriptive text sample and selecting the K most frequently used fields as the fields to be masked, where K is a manually set and adjusted positive integer without limitation. Yet another implementation involves randomly selecting K fields from the descriptive text sample as the fields to be masked.

[0082] Step S303: Input the reference description text into the pre-built generative model for training to obtain the text prediction model.

[0083] The pre-built generative model can be any model, such as BART, BERT, or GPT, without limitation. Specifically, step S303 can be as follows: Input the reference description text into the pre-built generative model for text prediction to obtain the predicted description text. Calculate the similarity between the reference description text and the predicted description text using the loss function of the generative model. Optimize the loss function of the generative model based on the similarity. Perform backpropagation on the model loss of the loss function, continuously adjusting the model parameters until the similarity is greater than or equal to the similarity threshold. Stop optimizing the generative model to obtain a text prediction model that meets the requirements.

[0084] As can be seen, through steps S301 to S303, a text prediction model can be pre-trained using a large-scale corpus, and the text prediction model can be used as an expert model to train the first encoding module to achieve the effect of vector alignment, which makes it easier to make full use of a small amount of labeled text to learn the internal representation of graph structure knowledge in the text.

[0085] Before step S107 in some embodiments, the following step may be included: serializing the second feature vector to obtain a first sequence. Correspondingly, step S107 may be: inputting the first sequence into a first decoding module for training processing to obtain a second decoding module. It is evident that serializing the second feature vector enables flexible mining and processing of nodes and knowledge relationships in different knowledge graphs. Optionally, the serialization processing methods include, but are not limited to, depth-first search (DFS), breadth-first search (BFS), and other graph search algorithms.

[0086] In step S107 of some embodiments, please refer to Figure 4 , Figure 4 yes Figure 1 A schematic diagram of a specific process for step S107. For example... Figure 4 As shown, step S107 may also include, but is not limited to, the following steps S401 to S403.

[0087] Step S401: Input the second feature vector into the first decoding module for decoding processing to obtain the second description text.

[0088] Step S402: Calculate the first loss value based on the second description text and the first description text.

[0089] In step S402, the first loss value between the second descriptive text and the first descriptive text can be calculated using the second loss function of the first decoding module. The second loss function can be any of the following, including but not limited to the 0-1 loss function, absolute value loss function, logarithmic loss function, exponential loss function, and Hinge loss function. It can be selected and adjusted according to actual needs, and will not be elaborated here.

[0090] Step S403: Update the parameters of the first decoding module according to the first loss value to obtain the second decoding module.

[0091] It can be seen that by taking steps S401 to S403, the accuracy of the first decoding module in generating descriptive text based on feature vectors can be improved.

[0092] In step S107 of some other embodiments, please refer to Figure 5 , Figure 5 yes Figure 1 Another specific process diagram for step S107. (See diagram below.) Figure 5 As shown, step S107 may further include the following steps S501 to S505.

[0093] Step S501: Input the second feature vector into the first decoding module for decoding processing to obtain the second description text.

[0094] Step S502: Identify at least two first entity objects and a second entity object associated with each first entity object from the second description text, and analyze the first association information between the first entity objects and the second entity objects.

[0095] The first entity object can be a word or a phrase, etc., without specific limitations. By segmenting the second descriptive text, at least two first entity objects can be obtained. The segmentation methods include, but are not limited to, maximum matching algorithm, shortest path segmentation, and segmentation algorithms based on n-gram models.

[0096] Step S503: Obtain at least two third entity objects and the fourth entity object associated with each third entity object from the first knowledge graph, and analyze the second association information between the third entity objects and the fourth entity objects.

[0097] In this embodiment, specifically, depending on actual needs, each node in the first knowledge graph can be selected as the third entity object, or a changed node can be selected from the first knowledge graph as the third entity object; there is no limitation in this regard. Based on this, the node connected to the selected node is designated as the fourth entity object, thereby determining the second association information based on the connection edge information between the third entity object and the fourth entity object.

[0098] Step S504: Calculate the second loss value based on the first entity object, the first associated information, the third entity object, and the second associated information.

[0099] In step S504, specifically, by obtaining a preset third loss function, the first entity object, the third entity object, the first association information, and the second association information can be substituted into the third loss function to obtain the second loss value. The third loss function can be a negative log-likelihood function or a cross-flashing loss function, etc., and is not limited thereto.

[0100] In some optional implementations, step S504 may specifically involve: calculating a first similarity between the first entity object and the third entity object, calculating a second similarity between the first association information and the second association information, and then calculating a second loss value based on the first and second similarities. For example, the second loss value = -s1 - s2, where s1 is the first similarity and s2 is the second similarity.

[0101] Step S505: Update the parameters of the first decoding module according to the second loss value to obtain the second decoding module.

[0102] As can be seen, through steps S501 to S505, the first decoding module can be trained to correctly predict the node entities contained in the knowledge graph and the relationships between different node entities based on the feature vectors, so that the trained second decoding module can generate a structured understanding of the changed serialized graph.

[0103] Secondly, please refer to Figure 6 , Figure 6 This is a flowchart illustrating a descriptive text generation method provided in an embodiment of this application. The descriptive text generation method includes steps S601 to S604. It should be understood that the descriptive text generation method in this embodiment includes, but is not limited to, steps S601 to S604. The following is a detailed explanation... Figure 6 A detailed introduction will be provided.

[0104] Step S601: Obtain the second knowledge graph.

[0105] In this embodiment of the application, the second knowledge graph can be a knowledge graph that has changed in the knowledge base or a newly added knowledge graph in the knowledge base, without limitation.

[0106] Step S602: Obtain the text generation model, which includes a third encoding module and a second decoding module.

[0107] In this embodiment of the application, the text generation model is trained according to the model training method described in the first aspect.

[0108] Step S603: Input the second knowledge graph into the third encoding module for encoding processing to obtain the third feature vector.

[0109] Step S604: Input the third feature vector into the second decoding module for decoding processing to obtain the target description text corresponding to the second knowledge graph.

[0110] In some embodiments, step S604 may specifically include the following steps: serializing the third feature vector to obtain a second sequence, thereby serializing the knowledge graph. The second sequence is then input into a second decoding module for decoding to obtain the target description text corresponding to the second knowledge graph.

[0111] The method for serializing the third feature vector can be referred to the above description of the serialization of the second feature vector, and will not be repeated here.

[0112] Please refer to Figure 7 , Figure 7This is a block diagram of a model training apparatus provided in some embodiments of this application. In some embodiments, the model training apparatus is used to train a text generation model, and the model training apparatus includes a first acquisition unit 701, a mask processing unit 702, a first encoding unit 703, a first training unit 704, a second encoding unit 705, a second training unit 706, and a construction unit 707.

[0113] The first acquisition unit 701 is used to acquire a pre-trained text prediction model, which includes a first encoding module and a first decoding module; and to acquire a first knowledge graph and a first descriptive text corresponding to the first knowledge graph.

[0114] The masking processing unit 702 is used to obtain the field to be processed from the first description text and perform masking processing on the field to be processed to obtain the second description text.

[0115] The first encoding unit 703 is used to input the second descriptive text into the first encoding module for encoding processing to obtain the first feature vector.

[0116] The first training unit 704 is used to train the preset second encoding module based on the first knowledge graph and the first feature vector to obtain the third encoding module.

[0117] The second encoding unit 705 is used to input the first knowledge graph into the third encoding module for encoding processing to obtain the second feature vector.

[0118] The second training unit 706 is used to input the second feature vector into the first decoding module for training processing to obtain the second decoding module.

[0119] Construction unit 707 is used to construct a text generation model based on the third encoding module and the second decoding module.

[0120] It should be noted that the model training device in this application corresponds to the aforementioned model training method. For the specific training process, please refer to the aforementioned model training method, which will not be described in detail here.

[0121] Please see Figure 8 , Figure 8 This is a block diagram of a descriptive text generation apparatus provided in some embodiments of this application. For example... Figure 8 As shown, the descriptive text generation device includes a second acquisition unit 801, a third encoding unit 802, and a decoding unit 803.

[0122] The second acquisition unit 801 is used to acquire a second knowledge graph; acquire a text generation model, the text generation model including a third encoding module and a second decoding module, and the text generation model is trained according to the model training method described in the first aspect of the embodiments of this application;

[0123] The third encoding unit 802 is used to input the second knowledge graph into the third encoding module for encoding processing to obtain the third feature vector;

[0124] The decoding unit 803 is used to input the third feature vector into the second decoding module for decoding processing to obtain the target description text corresponding to the second knowledge graph.

[0125] It should be noted that the descriptive text generation device in this application corresponds to the aforementioned descriptive text generation method. For the specific training process, please refer to the aforementioned descriptive text generation method, which will not be described in detail here.

[0126] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the model training method of the first aspect described above, or to implement the descriptive text generation method of the second aspect described above. This electronic device can be any smart terminal, including mobile phones, tablet computers, personal digital assistants (PDAs), and in-vehicle computers.

[0127] The following is combined with Figure 9 The electronic devices described in the embodiments of this application will be described in detail.

[0128] like Figure 9 , Figure 9 The hardware structure of an electronic device according to another embodiment is illustrated. The electronic device includes:

[0129] The processor 901 can be implemented using a general-purpose central processing unit (CPU), microprocessor, 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 application.

[0130] The memory 902 can be implemented as a read-only memory (ROM), static storage device, dynamic storage device, or random access memory (RAM). The memory 902 can store the operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 902 and is called and executed by the processor 901 to execute the model training method or descriptive text generation method of the embodiments of this application.

[0131] The input / output interface 903 is used to implement information input and output;

[0132] The communication interface 904 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).

[0133] Bus 905 transmits information between various components of the device (e.g., processor 901, memory 902, input / output interface 903, and communication interface 904);

[0134] The processor 901, memory 902, input / output interface 903, and communication interface 904 are connected to each other within the device via bus 905.

[0135] This application also provides a storage medium, which is a computer-readable storage medium storing computer-executable instructions for causing a computer to execute the above-described model training method or descriptive text generation method.

[0136] The storage medium of this application embodiment is used to execute the above-described model training method or descriptive text generation method. It can fully utilize incomplete descriptive text to guide the second encoding module to learn the relevant graph structure and the internal representation of knowledge in the descriptive text, effectively solving the problem of lack of labeled data in practical applications. Based on this, the second feature vector is input into the first decoding module of the text prediction model for training to obtain the second decoding module. This enables the second decoding module to predict complete descriptive text by combining the knowledge graph, thereby achieving accurate generation of descriptive text of the knowledge graph even with limited labeled data. In addition, it can train relevant modules to learn new knowledge at any time according to the updates of the knowledge graph, with low retraining costs, thus facilitating the sustainable learning of the model.

[0137] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0138] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.

[0139] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.

[0140] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0141] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.

[0142] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0143] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

[0144] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

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

[0146] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0147] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory, random access memory, magnetic disks, or optical disks.

[0148] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.

Claims

1. A model training method for training a text generation model, characterized in that, The method includes: Obtain a pre-trained text prediction model, the text prediction model including a first encoding module and a first decoding module; Obtain the first knowledge graph and the first descriptive text corresponding to the first knowledge graph; The fields to be processed are obtained from the first description text, and the fields to be processed are masked to obtain the second description text; The second descriptive text is input into the first encoding module for encoding processing to obtain the first feature vector; The first knowledge graph and the first feature vector are used to train the preset second encoding module to obtain the third encoding module; specifically, the first knowledge graph is input into the second encoding module for encoding to obtain the fourth feature vector, the first feature vector and the fourth feature vector are used to calculate the third loss value, and the parameters of the second encoding module are updated according to the third loss value to obtain the third encoding module. The first knowledge graph is input into the third encoding module for encoding processing to obtain the second feature vector; The second feature vector is input into the first decoding module for training processing to obtain the second decoding module; The text generation model is constructed based on the third encoding module and the second decoding module; wherein the text generation model is used to generate descriptive text corresponding to the knowledge graph.

2. The method according to claim 1, characterized in that, Before inputting the second feature vector into the first decoding module for training processing to obtain the second decoding module, the method further includes: The second feature vector is serialized to obtain the first sequence; The step of inputting the second feature vector into the first decoding module for training processing to obtain the second decoding module includes: The first sequence is input into the first decoding module for training processing to obtain the second decoding module.

3. The method according to claim 1, characterized in that, The step of inputting the second feature vector into the first decoding module for training processing to obtain the second decoding module includes: The second feature vector is input into the first decoding module for decoding processing to obtain the second descriptive text; Calculate the first loss value based on the second description text and the first description text; The parameters of the first decoding module are updated based on the first loss value to obtain the second decoding module.

4. The method according to claim 1, characterized in that, The step of inputting the second feature vector into the first decoding module for training processing to obtain the second decoding module includes: The second feature vector is input into the first decoding module for decoding processing to obtain the second descriptive text; Identify at least two first entity objects and a second entity object associated with each first entity object from the second description text, and analyze the first association information between the first entity object and the second entity object; Obtain at least two third entity objects and a fourth entity object associated with each third entity object from the first knowledge graph, and analyze the second association information between the third entity objects and the fourth entity objects; Calculate the second loss value based on the first entity object, the first association information, the third entity object, and the second association information; The parameters of the first decoding module are updated based on the second loss value to obtain the second decoding module.

5. The method according to any one of claims 1 to 3, characterized in that, The training steps of the text prediction model include: Obtain a sample descriptive text; The fields to be masked are determined from the description text sample, and the fields to be masked are masked to obtain the reference description text; The reference description text is input into a pre-built generative model for training to obtain a text prediction model.

6. A method for generating descriptive text, characterized in that, The method includes: Obtain the second knowledge graph; A text generation model is obtained, the text generation model including a third encoding module and a second decoding module, and the text generation model is trained according to the model training method according to any one of claims 1 to 5; The second knowledge graph is input into the third encoding module for encoding processing to obtain the third feature vector; The third feature vector is input into the second decoding module for decoding processing to obtain the target description text corresponding to the second knowledge graph.

7. The method according to claim 6, characterized in that, The step of inputting the third feature vector into the second decoding module for decoding processing to obtain the target description text corresponding to the second knowledge graph includes: The third feature vector is serialized to obtain the second sequence; The second sequence is input into the second decoding module for decoding processing to obtain the target description text corresponding to the second knowledge graph.

8. A model training device for training a text generation model, characterized in that, The device includes: The first acquisition unit is used to acquire a pre-trained text prediction model, the text prediction model including a first encoding module and a first decoding module; and to acquire a first knowledge graph and a first descriptive text corresponding to the first knowledge graph. A masking unit is used to obtain the field to be processed from the first description text and to perform masking processing on the field to be processed to obtain the second description text. The first encoding unit is used to input the second descriptive text into the first encoding module for encoding processing to obtain a first feature vector; The first training unit is used to train a preset second encoding module based on the first knowledge graph and the first feature vector to obtain a third encoding module. Specifically, the first knowledge graph is input into the second encoding module for encoding to obtain a fourth feature vector. Based on the first feature vector and the fourth feature vector, a third loss value is calculated, and the parameters of the second encoding module are updated based on the third loss value to obtain the third encoding module. The second encoding unit is used to input the first knowledge graph into the third encoding module for encoding processing to obtain the second feature vector; The second training unit is used to input the second feature vector into the first decoding module for training processing to obtain the second decoding module; The construction unit is used to construct the text generation model based on the third encoding module and the second decoding module; wherein the text generation model is used to generate descriptive text corresponding to the knowledge graph.

9. An electronic device, characterized in that, The electronic device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the model training method according to any one of claims 1 to 5, or the descriptive text generation method according to claim 6 or 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the model training method according to any one of claims 1 to 5, or the descriptive text generation method according to claim 6 or 7.

Citation Information

Patent Citations

  • Image description method

    CN111523534A

  • Method and device for automatically generating natural language described by scatter diagram

    CN113283248A