CN-115757808-B - Text generation method and device
Abstract
The embodiment of the specification provides a text generation method and a text generation device, wherein the text generation method comprises the steps of obtaining user characteristics of a target user, determining text generation information related to a target object according to the user characteristics, inputting the text generation information into a text generation model, encoding the text generation information through an encoding unit fused with a knowledge graph in the text generation model to obtain an encoding vector containing second entity information, decoding the encoding vector through a decoding unit in the text generation model, and outputting a target text containing text control information. The text generation model of the coding unit based on the fusion knowledge graph processes the text generation information containing the text control information, outputs a target text which meets the requirements of users, and realizes the controllability of the knowledge graph to the text generation.
Inventors
- CHENG LIYING
- BING LIDONG
Assignees
- 阿里巴巴(中国)有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20221020
Claims (13)
- 1. A text generation method, comprising: Acquiring user characteristics of a target user, and determining text generation information of an associated target object according to the user characteristics, wherein the text generation information comprises first entity information and text control information of the target object; Inputting the text generation information into a text generation model, carrying out coding processing on the text generation information through a coding unit with a fusion knowledge graph in the text generation model to obtain a coding vector containing second entity information, wherein the second entity information is obtained from the first entity information and the text control information in the knowledge graph, carrying out coding processing on the text generation information through the coding unit with the fusion knowledge graph in the text generation model to obtain the coding vector containing the second entity information, and updating preset parameters in a preset parameter template according to the text control information, wherein the preset parameter template is used for providing a preset parameter input function for the coding unit, generating target input information based on the updated preset parameters and the first entity information, and carrying out coding processing on the target input information through the coding unit with the fusion knowledge graph in the text generation model to obtain the coding vector containing the second entity information; And decoding the coded vector through a decoding unit in the text generation model, and outputting target text containing the text control information.
- 2. The method of claim 1, obtaining user characteristics of a target user, comprising: receiving a text generation instruction of a target user; determining the identity information of the target user and the object information of the target object carried in the text generation instruction; And acquiring a user characteristic set of the target user based on the identity information, and selecting user characteristics associated with the target object from the user characteristic set based on the object information.
- 3. The method of claim 1, determining text generation information associated with a target object based on the user characteristics, comprising: Determining a service field to which the target object belongs, and determining first entity information of the target object in a knowledge graph corresponding to the service field; And determining text control information of the target object according to the user characteristics, and generating text generation information of the associated target object based on the text control information and the first entity information.
- 4. A method according to claim 1 or 3, further comprising, prior to entering the text generation information into a text generation model: acquiring an initial text generation model and a knowledge graph corresponding to the target object; linearizing the knowledge graph to obtain a linearization knowledge graph; Fusing the linearization knowledge graph with an initial coding unit of the initial text generation model; and determining a text generation model containing the coding units according to the fusion result.
- 5. The method of claim 4, determining a text generation model containing coding units based on the fusion result, comprising: Determining an initial coding unit of the fusion knowledge graph according to the fusion result; Determining a preset parameter template corresponding to the initial text generation model; And performing splicing processing on the preset parameter template and the initial coding unit of the fusion knowledge graph, and generating a text generation model containing the coding unit of the fusion knowledge graph according to a splicing result.
- 6. The method of claim 1, wherein the encoding unit of the text generation model fused with the knowledge-graph encodes the text generation information to obtain the encoded vector containing the second entity information, and the method comprises: Determining second entity information in the knowledge graph according to the first entity information and the text control information; encoding the first entity information, the text control information and the second entity information based on an encoding unit fused with a knowledge graph in the text generation model to obtain a first entity vector corresponding to the first entity information, a text control vector corresponding to the text control information and a second entity vector corresponding to the second entity information; And generating a coding vector containing second entity information according to the first entity vector, the text control vector and the second entity vector.
- 7. The method of claim 1, decoding the encoded vector by a decoding unit in the text generation model, outputting a target text containing the text control information, comprising: Decoding the coded vector through a decoding unit in the text generation model to obtain a target text sequence containing the text control information; And determining target text containing the text control information based on the target text sequence.
- 8. A text generation method, comprising: receiving a text generation instruction submitted by a target user aiming at a target object in a recommendation service; responding to the text generation instruction, acquiring user characteristics of the target user, and determining text generation information associated with the target object based on the user characteristics, wherein the text generation information comprises first entity information and text control information of the target object; Inputting the text generation information into a text generation model for processing to obtain a target text output by the text generation model, wherein the text generation model comprises a coding unit and a decoding unit which are integrated with a knowledge graph, the text generation information is coded by the coding unit which is integrated with the knowledge graph in the text generation model to obtain a coding vector containing second entity information, the second entity information is obtained from the first entity information and the text control information in the knowledge graph, the text generation information is coded by the coding unit which is integrated with the knowledge graph in the text generation model to obtain the coding vector containing the second entity information, and the method comprises the steps of updating preset parameters in a preset parameter template according to the text control information, wherein the preset parameter template is used for providing a preset parameter input function for the coding unit, generating the target input information based on the updated preset parameters and the first entity information, and coding the target input information by the coding unit which is integrated with the knowledge graph in the text generation model to obtain the coding vector containing the second entity information; And generating recommendation information according to the target text and the object resource of the target object, and feeding back the recommendation information to the target user.
- 9. A text generation method is applied to a server and comprises the following steps: Receiving a text generation instruction submitted by a target user through a client; responding to the text generation instruction, acquiring user characteristics of a target user, and determining text generation information associated with a target object according to the user characteristics, wherein the text generation information comprises first entity information and text control information of the target object; Inputting the text generation information into a text generation model, carrying out coding processing on the text generation information through a coding unit with a fusion knowledge graph in the text generation model to obtain a coding vector containing second entity information, wherein the second entity information is obtained from the first entity information and the text control information in the knowledge graph, carrying out coding processing on the text generation information through the coding unit with the fusion knowledge graph in the text generation model to obtain the coding vector containing the second entity information, and updating preset parameters in a preset parameter template according to the text control information, wherein the preset parameter template is used for providing a preset parameter input function for the coding unit, generating target input information based on the updated preset parameters and the first entity information, and carrying out coding processing on the target input information through the coding unit with the fusion knowledge graph in the text generation model to obtain the coding vector containing the second entity information; And decoding the coded vector through a decoding unit in the text generation model, outputting a target text containing the text control information, and feeding back the target text to the client.
- 10. A text generation apparatus comprising: The determining module is configured to acquire user characteristics of a target user, and determine text generation information associated with a target object according to the user characteristics, wherein the text generation information comprises first entity information and text control information of the target object; the encoding module is configured to input the text generation information into a text generation model, encode the text generation information through an encoding unit fused with a knowledge graph in the text generation model, and obtain an encoding vector containing second entity information, wherein the second entity information is obtained from the first entity information and the text control information in the knowledge graph; The encoding module is further configured to update preset parameters in a preset parameter template according to the text control information, wherein the preset parameter template is used for providing a preset parameter input function for the encoding unit; encoding the target input information through an encoding unit fused with a knowledge graph in the text generation model to obtain an encoding vector containing second entity information; and the decoding module is configured to perform decoding processing on the coded vector through a decoding unit in the text generation model and output target text containing the text control information.
- 11. A computing device comprising a memory, a processor and computer instructions stored on the memory and executable on the processor, the processor implementing the steps of the method of any one of claims 1-7 or 8 or 9 when the computer instructions are executed.
- 12. A computer readable storage medium storing computer instructions which, when executed by a processor, implement the steps of the method of any one of claims 1-7 or 8 or 9.
- 13. A computer program product comprising computer instructions which, when executed by a processor, implement the steps of the method of any of claims 1-7 or 8 or 9.
Description
Text generation method and device Technical Field The embodiment of the specification relates to the technical field of natural language, in particular to a text generation method. One or more embodiments of the present specification relate to a text generating apparatus, a computing device, and a computer-readable storage medium. Background Along with the rapid development of technologies such as computers, artificial intelligence and the like, the application of knowledge maps is also becoming wider and wider. Knowledge graph is one of the important carriers for storing a large amount of data and knowledge, and describes the relationship between entities. Because the knowledge graph contains a large amount of structured data, the knowledge graph is mostly applied to the fields of search engines, question-answering systems, recommendation systems and the like. However, when the user acquires the related information based on the knowledge graph, the amount of data stored in the knowledge graph is too large, so that the information fed back to the user is also large, the user needs to further select the information expected to be acquired in the feedback information, and unnecessary trouble and poor use experience are brought to the user. Therefore, how to accurately provide feedback information to the user, which the user wants to obtain, is a problem that needs to be solved at present. Disclosure of Invention In view of this, the present embodiment provides a text generation method. One or more embodiments of the present specification relate to a text generating apparatus, a computing device, a computer-readable storage medium, and a computer program that solve the technical drawbacks existing in the prior art. According to a first aspect of embodiments of the present specification, there is provided a text generation method, including: Acquiring user characteristics of a target user, and determining text generation information of an associated target object according to the user characteristics, wherein the text generation information comprises first entity information and text control information of the target object; Inputting the text generation information into a text generation model, and carrying out coding processing on the text generation information through a coding unit fused with a knowledge graph in the text generation model to obtain a coding vector containing second entity information, wherein the second entity information is obtained from the first entity information and the text control information in the knowledge graph; And decoding the coded vector through a decoding unit in the text generation model, and outputting target text containing the text control information. According to a second aspect of embodiments of the present specification, there is provided a text generation method, including: receiving a text generation instruction submitted by a target user aiming at a target object in a recommendation service; Responding to the text generation instruction, acquiring user characteristics of the target user, and determining text generation information associated with the target object based on the user characteristics; Inputting the text generation information into a text generation model for processing to obtain a target text output by the text generation model, wherein the text generation model comprises a coding unit and a decoding unit which are integrated with a knowledge graph; And generating recommendation information according to the target text and the object resource of the target object, and feeding back the recommendation information to the target user. According to a third aspect of embodiments of the present specification, there is provided a text generating apparatus including: The determining module is configured to acquire user characteristics of a target user, and determine text generation information associated with a target object according to the user characteristics, wherein the text generation information comprises first entity information and text control information of the target object; the encoding module is configured to input the text generation information into a text generation model, encode the text generation information through an encoding unit fused with a knowledge graph in the text generation model, and obtain an encoding vector containing second entity information, wherein the second entity information is obtained from the first entity information and the text control information in the knowledge graph; and the decoding module is configured to perform decoding processing on the coded vector through a decoding unit in the text generation model and output target text containing the text control information. According to a fourth aspect of embodiments of the present specification, there is provided a text generating apparatus comprising: The receiving module is configured to receive a text generation instruction submitted by a target user aiming at a