Text generation method, device and equipment, computer readable storage medium and product
By extracting keywords and second keywords associated with topic information to form a keyword group, and using a text generation model to generate the second text, the problem of high repetition rates among multiple texts in the prior art is solved and the text quality is improved.
Patent Information
- Application Number
- CN202410717006.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2024-08-23
AI Technical Summary
In the existing technology, the repetition rate between multiple texts generated based on the same topic information is high, resulting in the text being unable to meet user needs.
By obtaining the keywords associated with the topic information input by the user, text retrieval is performed and the associated second keywords are extracted to form a keyword group. The text generation model is used to generate second text corresponding to different keyword groups, thereby reducing the repetition rate.
It effectively reduces the duplication rate between multiple texts generated by the same topic information and improves the quality and readability of the text.
Smart Images

Figure CN118535705A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer processing technology, and in particular to a text generation method, device, equipment, computer-readable storage medium and product. Background Art
[0002] Media platforms are the main way for users to read and publish texts such as microblogs. At present, in order to simplify the text publishing process of users, media platforms can automatically generate texts based on the topic information input by users. However, when multiple texts are generated for the same topic information through a text generation model, the repetition rate between the generated multiple texts is usually high, resulting in the generated text failing to meet user needs. Summary of the invention
[0003] The present application provides a text generation method, apparatus, device, computer-readable storage medium and product, which can reduce the repetition rate between multiple texts generated based on the same topic information and improve the text quality.
[0004] In a first aspect, the present application provides a text generation method, comprising:
[0005] Obtain a first keyword associated with the topic information input by the user; perform text search based on the first keyword to obtain one or more first texts containing the first keyword; extract a second keyword associated with the first keyword from the one or more first texts; determine a plurality of keyword groups based on a keyword set consisting of the first keyword and the second keyword, the keyword group including at least two keywords in the keyword set; and generate a second text corresponding to each keyword group based on the plurality of keyword groups.
[0006] In some possible implementations, there are multiple second keywords; based on a keyword set consisting of a first keyword and a second keyword, multiple keyword groups are determined, including: determining a first association degree for each second keyword in the keyword set, the first association degree being used to represent the degree of association between the second keyword and the corresponding first keyword in the keyword set; combining any first keyword in the keyword set with a second keyword having a different first association degree to obtain multiple keyword groups.
[0007] In some possible implementations, any first keyword in a keyword set is combined with a second keyword having a different first degree of association to obtain a plurality of keyword groups, including: dividing the plurality of second keywords in the keyword set into a plurality of subsets according to the first degree of association, different subsets corresponding to different first degree of association value intervals; and combining any first keyword in the keyword set with second keywords in different subsets to obtain a plurality of keyword groups.
[0008] In some possible implementations, any first keyword in a keyword set and second keywords in different subsets are combined to obtain multiple keyword groups, including: configuring a weight for each of the multiple subsets, where the weight is used to indicate the number of second keywords obtained from each subset when generating a keyword group; combining a corresponding number of second keywords obtained from each subset according to the weight with any first keyword in the keyword set to obtain multiple keyword groups.
[0009] In some possible implementations, the method further includes: determining the priority of each subset based on the first association value interval corresponding to each subset, the priority being positively correlated with the first association value interval corresponding to the subset; and configuring a weight for each subset based on the priority.
[0010] In some possible implementations, determining a first relevance of each second keyword in a keyword set includes: obtaining a second relevance of a target second keyword, the target second keyword being any second keyword in the keyword set, the second relevance being used to indicate a degree of relevance between the target second keyword and a target first text, the target first text being the first text where the target second keyword is located, the second relevance being positively correlated with the number of times the target second keyword appears in the target first text, the target first text being retrieved based on the target first keyword; determining a third relevance of the target first keyword, the target first keyword being the first keyword used when retrieving the target first text, the third relevance being used to indicate a degree of relevance between the target first keyword and the target first text, the third relevance being positively correlated with the number of times the target first keyword appears in the target first text; determining a degree of attention of the target first text based on user interaction information of the target first text, wherein the user interaction information is used to indicate the number of times the target first text interacts with the user, and the degree of attention is used to indicate the degree to which the target first text is paid attention to by the user; determining a first relevance of the target second keyword based on the second relevance, the third relevance, and the degree of attention.
[0011] In some possible implementations, based on multiple keyword groups, a second text corresponding to each keyword group is generated, including: using a text generation model to generate text based on multiple keyword groups to obtain a second text corresponding to each keyword group, wherein the text generation model is trained based on topic sample information and text samples corresponding to the topic sample information.
[0012] In some possible implementations, extracting a second keyword associated with a first keyword from one or more first texts includes: obtaining at least one first candidate word from multiple first texts; determining the number of first texts containing each first candidate word from the multiple first texts to obtain a first number; determining the total number of the multiple first texts to obtain a second number; and determining, as the second keyword, a first candidate word for which the ratio of the first number to the second number is greater than a preset ratio.
[0013] In some possible implementations, extracting a second keyword associated with a first keyword from one or more first texts includes: obtaining at least one second candidate word from the one or more first texts; determining the distance between the second candidate word and the first keyword in the same first text, wherein the distance is positively correlated with the number of characters between the second candidate word and the first keyword in the first text; and determining the second candidate word in each first text whose distance is less than a preset distance as the second keyword.
[0014] In some possible implementations, obtaining a first keyword associated with topic information input by a user includes: determining the type of the topic information; obtaining a third text corresponding to the topic information and the type; and generating a first keyword associated with the topic information based on the third text and the topic information.
[0015] In a second aspect, the present application provides a text generation device, the device comprising:
[0016] A keyword construction result module is used to obtain a first keyword associated with the topic information input by the user; a first reinforcement learning module is used to perform text retrieval based on the first keyword to obtain one or more first texts containing the first keyword; a second reinforcement learning module is used to extract a second keyword associated with the first keyword from the one or more first texts; a first keyword decomposition module is used to determine a plurality of keyword groups based on a keyword set consisting of the first keyword and the second keyword, the keyword group including at least two keywords in the keyword set; a text generation module is used to generate a second text corresponding to each keyword group based on the plurality of keyword groups.
[0017] In some possible implementations, there are multiple second keywords; the first keyword disassembly module is used to: determine the first association degree of each second keyword in the keyword set, the first association degree is used to indicate the degree of association between the second keyword and the corresponding first keyword in the keyword set; combine any first keyword in the keyword set with a second keyword with a different first association degree to obtain multiple keyword groups.
[0018] In some possible implementations, the first keyword disassembly module is used to: divide multiple second keywords in the keyword set into multiple subsets according to the first correlation, and different subsets correspond to different first correlation value intervals; combine any first keyword in the keyword set and second keywords in different subsets to obtain multiple keyword groups.
[0019] In some possible implementations, the first keyword disassembly module is used to: configure a weight for each of a plurality of subsets, where the weight is used to indicate the number of second keywords obtained from each subset when generating a keyword group; and combine a corresponding number of second keywords obtained from each subset according to the weight with any first keyword in the keyword set to obtain multiple keyword groups.
[0020] In some possible implementations, the device also includes: a determination module, used to determine the priority of each subset based on the first association value interval corresponding to each subset, the priority being positively correlated with the first association value interval corresponding to the subset; and a second keyword decomposition module, used to configure a weight for each subset based on the priority.
[0021] In some possible implementations, the first keyword disassembly module is used to: obtain a second relevance of a target second keyword, where the target second keyword is any second keyword in a keyword set, the second relevance is used to indicate the degree of relevance between the target second keyword and a target first text, where the target first text is the first text where the target second keyword is located, the second relevance is positively correlated with the number of times the target second keyword appears in the target first text, and the target first text is retrieved based on the target first keyword; determine a third relevance of the target first keyword, where the target first keyword is the first keyword used when retrieving the target first text, the third relevance is used to indicate the degree of relevance between the target first keyword and the target first text, and the third relevance is positively correlated with the number of times the target first keyword appears in the target first text; determine the degree of attention of the target first text based on user interaction information of the target first text, where the user interaction information is used to indicate the number of times the target first text interacts with the user, and the degree of attention is used to indicate the degree to which the target first text is paid attention to by the user; determine the first relevance of the target second keyword based on the second relevance, the third relevance, and the degree of attention.
[0022] In some possible implementations, the text generation module is used to: generate text based on multiple keyword groups through a text generation model to obtain a second text corresponding to each keyword group, wherein the text generation model is trained based on topic sample information and text samples corresponding to the topic sample information.
[0023] In some possible implementations, the second reinforcement learning module is used to: obtain at least one first candidate word from multiple first texts; determine the number of first texts containing each first candidate word from the multiple first texts to obtain a first number; determine the total number of the multiple first texts to obtain a second number; and determine, as a second keyword, a first candidate word for which the ratio of the first number to the second number is greater than a preset ratio.
[0024] In some possible embodiments, the second reinforcement learning module is used to: obtain at least one second candidate word from one or more first texts; determine the distance between the second candidate word and the first keyword in the same first text, wherein the distance is positively correlated with the number of characters between the second candidate word and the first keyword in the first text; and determine the second candidate word in each first text whose distance is less than a preset distance as the second keyword.
[0025] In some possible implementations, the keyword construction result module is used to: determine the type of topic information; obtain a third text corresponding to the topic information and the type; and generate a first keyword associated with the topic information based on the third text and the topic information.
[0026] In a third aspect, the present application provides an electronic device, comprising: a memory for storing executable instructions; and a processor for executing the executable instructions stored in the memory to implement the method provided by the present application.
[0027] In a fourth aspect, the present application provides a computer-readable storage medium storing executable instructions for implementing the method provided in the present application when the executable instructions are executed by a processor.
[0028] In a fifth aspect, the present application provides a computer program product, including a computer program or instructions, which are used to implement the method provided by the present application when the computer program or instructions are executed by a processor.
[0029] This application has the following beneficial effects:
[0030] In the present application, after obtaining the first keyword associated with the topic information, the text generation device can also use the first keyword as a search term to obtain a first text, and extract a second keyword from the first text. Afterwards, the first keyword and the second keyword can be formed into a keyword set, and at least two keywords in the keyword set can be grouped into a keyword group to obtain multiple keyword groups, and then a corresponding second text is generated based on each keyword group. Since different second texts are generated based on different keyword groups, at least some of the keywords included in different keyword groups are different. Therefore, the second texts generated based on different keyword groups are different, which can reduce the repetition rate between multiple second texts generated based on the same topic information. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 It is a schematic diagram of the architecture of a text generation system provided in an embodiment of the present application;
[0032] Figure 2 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0033] Figure 3 It is an optional flow chart of a text generation method provided in an embodiment of the present application;
[0034] Figure 4 This is an optional flow chart of a method for generating a keyword group provided in an embodiment of the present application;
[0035] Figure 5 is a schematic diagram of a subset provided in an embodiment of the present application;
[0036] Figure 6 It is a flowchart of an exemplary embodiment of the text generation method provided in the embodiment of the present application. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.
[0038] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it can be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0039] If similar descriptions of "first / second" appear in the application documents, the following explanation is added. In the following description, the terms "first / second / third" involved are merely to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first / second / third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0040] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0041] Media platforms are the main way for users to read and publish texts such as microblogs. At present, in order to simplify the text publishing process of users, media platforms can realize automatic text generation based on the topic information input by users. At present, automatic text generation can be realized in two ways. In the first way, the keywords included in the topic information are extracted, and then the extracted keywords are subjected to text retrieval and text splicing to obtain multiple texts related to the topic. In the second way, the topic information is input into the trained text generation model to obtain multiple texts related to the topic information.
[0042] For the first method, since the newly generated text is obtained by splicing multiple retrieved texts, the generated text is relatively templated and may have word order or logic problems, resulting in poor readability of the text. For the second method, since the text generation model generates text based on keywords extracted from topic information, the topic information is usually relatively brief and the number of keywords extracted from the topic information is limited, when multiple texts need to be generated based on the same topic information, the repetition rate between the multiple texts is usually high. For example, when 100 texts are generated based on the same topic information through an end-to-end text generation model, the repetition rate between the 100 texts may be as high as 80%.
[0043] The embodiments of the present application provide a text generation method, apparatus, device, computer-readable storage medium and product, which can solve the problem of high repetition rate between multiple texts generated based on the same topic information.
[0044] The following describes an exemplary application of the electronic device provided by the embodiment of the present application. The electronic device provided by the embodiment of the present application can be a user terminal of various types such as a laptop computer, a tablet computer, a desktop computer, a mobile device (e.g., a mobile phone, a wearable smart watch, a dedicated messaging device), and can also be implemented as a server. The following describes an exemplary application when the electronic device is implemented as a server.
[0045] See also Figure 1 , Figure 1 1 is a schematic diagram of the structure of a text generation system 100 provided in an embodiment of the present application. To implement the text generation method in an embodiment of the present application, electronic devices 400-1 and 400-2 ( Figure 1 Only two electronic devices are shown, but this does not constitute a limitation on the number of electronic devices included in the text generation system of the embodiment of the present application) The server 200 is connected via a network 300, and the network 300 can be a wide area network or a local area network, or a combination of the two.
[0046] In one embodiment, the user can enter topic information in the topic box on the electronic device 400-1 and the electronic device 400-2. Accordingly, the server 200 can receive the topic information sent by the electronic device 400-1 and the electronic device 400-2 based on the user input, and store the received topic information in the database 500. Afterwards, the server 200 can obtain the first keyword associated with the topic information, and perform text retrieval based on the first keyword to obtain one or more first texts including the first keyword. Afterwards. The server 200 can extract the second keyword associated with the first keyword from the one or more first texts, and determine multiple keyword groups based on the keyword set consisting of the second keyword and the first keyword, and then generate different second texts based on different keyword groups. After obtaining the second text, the server can send the second text to the electronic device 400-1 and the electronic device 400-2 through the network, so as to expose the second text to the user through the electronic device 400-1 and the electronic device 400-2, so that the user can consume the second text through the electronic device.
[0047] In some embodiments, the server 200 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, and big data and artificial intelligence platforms. The electronic device 400 may be an electronic device with a display screen, such as a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart watch, etc., but is not limited thereto. The electronic device and the server may be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiments of the present invention.
[0048] Figure 2 It is a schematic diagram of the structure of an electronic device 400 provided in an embodiment of the present application. Figure 2 The electronic device 400 shown includes: at least one processor 410, a memory 450, at least one network interface 420 and a user interface 430. The various components in the electronic device 400 are coupled together via a bus system 440. It is understood that the bus system 440 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 440 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 440 is not described in detail. Figure 2 Various buses are labeled as bus system 440 .
[0049] Processor 410 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0050] The user interface 430 includes one or more output devices 431 that enable presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 430 also includes one or more input devices 432, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.
[0051] The memory 450 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard disk drives, optical disk drives, etc. The memory 450 may optionally include one or more storage devices that are physically remote from the processor 410.
[0052] The memory 450 includes a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memories. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 450 described in the embodiments of the present application is intended to include any suitable type of memory.
[0053] In some embodiments, memory 450 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplarily described below.
[0054] Operating system 451, including system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks;
[0055] A network communication module 452, for reaching other computing devices via one or more (wired or wireless) network interfaces 420, exemplary network interfaces 420 include: Bluetooth, wireless compatibility certification (WiF i), and universal serial bus (USB), etc.;
[0056] a presentation module 453 for enabling presentation of information via one or more output devices 431 (e.g., display screen, speaker, etc.) associated with the user interface 430 (e.g., a user interface for operating peripherals and displaying content and information);
[0057] The input processing module 454 is used to detect one or more user inputs or interactions from one of the one or more input devices 432 and translate the detected inputs or interactions.
[0058] In some embodiments, the text generation device 455 provided in the embodiments of the present application can be implemented in software. Figure 2 The text generation device 455 stored in the memory 450 is shown, which can be software in the form of a program and a plug-in, etc., including the following software modules: a keyword construction result module 4551, a first reinforcement learning module 4552, a second reinforcement learning module 4553, a first keyword disassembly module 4554 and a text generation module 4555. These modules are logical, so they can be arbitrarily combined or further split according to the functions implemented. The functions of each module will be explained below.
[0059] In other embodiments, the text generation device 455 provided in the embodiment of the present application can be implemented in hardware. As an example, the text generation device 455 provided in the embodiment of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the text generation method provided in the embodiment of the present application. For example, the processor in the form of a hardware decoding processor can adopt one or more application specific integrated circuits (ASIC), DSP, programmable logic device (PLD), complex programmable logic device (CPLD), field-programmable gate array (FPGA) or other electronic components.
[0060] The text generation method provided in the embodiment of the present application will be described below in conjunction with the exemplary application and implementation of the electronic device provided in the embodiment of the present application.
[0061] See also Figure 3 , Figure 3 This is an optional flow chart of a text generation method provided in an embodiment of the present application. Figure 3 The steps shown illustrate the text generation method provided in the embodiment of the present application.
[0062] Step S301: Obtain a first keyword associated with topic information input by a user.
[0063] It is understandable that when the user needs to generate text, the topic information of the second text to be generated can be input into the topic box of the terminal device held. Based on this, the text generation device can obtain the topic information input by the user from the topic box and generate the first keyword associated with the topic information.
[0064] In some embodiments, after obtaining the topic information, the text generation device may extract keywords from the topic information to obtain the first keyword.
[0065] In other embodiments, after obtaining the topic information, the text generation device can generate a first keyword associated with the topic information through a trained keyword generation model, wherein the keyword generation model is trained based on the topic sample information and the sample keywords corresponding to the topic sample information.
[0066] In some embodiments, the keyword generation model can be any type of neural network model. This embodiment of the present application is not limited to this. Exemplarily, the keyword generation model can be a reinforcement learning model.
[0067] In some embodiments, the text generation device may obtain one or more first keywords based on the topic information input by the user, which is not limited in this embodiment of the present application.
[0068] For example, when the topic information obtained by the text generation device is "How to get a white complexion in autumn", the text generation device may input the topic information "How to get a white complexion in autumn" into the keyword generation model. Since the topic information is related to skin care, the keyword generation model may output some brand names of skin care products related to skin care, or output some keywords related to skin care, such as "whitening" and "skin care". Based on this, the text generation device may use the brand name of the skin care product and / or the keyword related to skin care output by the keyword generation model as the first keyword.
[0069] For example, when the topic information obtained by the text generation device is "good price technology product sharing", the text generation device can input the topic information "good price technology product sharing" into the keyword generation model. At this time, the keyword generation model can output the names of some technology products, such as "keyboard" and "mouse". The keyword generation model can also output some company names related to technology products. At this time, the text generation device can use the obtained product name and / or company name as the first keyword associated with the topic information.
[0070] It should be noted that the above lists only several exemplary methods of obtaining the first keyword, and does not constitute a limitation on the method of obtaining the first keyword provided in the embodiment of the present application.
[0071] In some embodiments, step S301 includes: determining the type of topic information; acquiring a third text corresponding to the topic information and the type; and generating a first keyword associated with the topic information based on the third text and the topic information.
[0072] It is understandable that, considering that topic information is usually relatively brief, the content related to the topic indicated by the topic information is usually relatively small. Therefore, after obtaining the topic information input by the user, the text generation device can also determine the type of the topic input by the user, and obtain a third text corresponding to the type of the topic information and related to the topic information according to the type of the topic information. Afterwards, the text generation device can jointly generate the first keyword associated with the topic information based on the third text and the topic information.
[0073] In some embodiments, the text generation device may perform keyword extraction on the topic information, and determine the type of the topic information based on the keywords extracted from the topic information.
[0074] Exemplarily, the text generation device may store the correspondence between the type of topic information and the keyword. Based on this, after extracting the first keyword from the topic information input by the user, the text generation device may determine the type of topic information corresponding to the first keyword based on the correspondence between the type of topic information and the keyword, and then obtain the type of topic information input by the user.
[0075] In some embodiments, after determining the type of the topic information, the text generating device may search the network for text corresponding to the type of the topic information and related to the topic information, and determine the found text as the third text.
[0076] In other embodiments, after determining the type corresponding to the topic information, the text generation device may output prompt information, prompting the user to supplement the third text corresponding to the type of the topic information through the prompt information. Afterwards, the text generation device may generate a first keyword related to the topic information based on the third text input by the user.
[0077] In some embodiments, the types of topic information include first-class topic information, second-class topic information, and third-class topic information. When the text generation device determines that the topic information input by the user is the first-class topic information, a third text that introduces or explains the topic information can be found from the network. Alternatively, when the text generation device determines that the type corresponding to the topic information is the first-class topic information, a prompt message can be output to prompt the user to further explain the topic information, for example, prompt the user to introduce the background information of the topic indicated by the topic information. At this time, the text generation device can obtain the third text based on the user's input for the prompt message. When the text generation device determines that the topic information is the second-class topic information, the information of the brand or product related to the topic information can be determined as the third text. When the text generation device determines that the type corresponding to the topic information is the third-class topic information, a prompt message can be output to prompt the user to supplement any content related to the topic information. At this time, the text generation device can obtain the third text based on the user's input for the prompt message.
[0078] In some embodiments, the brand or product information related to the topic information may be retrieved from the Internet by the text generating device, or may be pre-stored in the text generating device, or may be obtained based on the user's input operation on the prompt information, or may be obtained by the text generating device through other means, and the embodiments of the present application are not limited to this.
[0079] Exemplarily, the first type of topic information may include hot topic information or topic information with timeliness. The second type of topic information may be topic information related to any type of product. The third type of topic information may be all topic information except the first type of topic information and the second type of topic information.
[0080] In some embodiments, after obtaining the third text, the text generation device may input both the third text and the topic information into a trained keyword generation model to obtain a first keyword related to the topic information.
[0081] In some embodiments, at least one of the first keywords obtained by the text generation device through step S301 is an entity word.
[0082] In the embodiment of the present application, after obtaining the topic information input by the user, the text generation device can also obtain a third text related to the topic information, because the third text is a further supplement or explanation of the topic indicated by the topic information. Therefore, the first keyword is generated based on the third text and the topic information, which can not only make the generated first keyword closer to the topic indicated by the topic information, but also increase the number of the obtained first keywords, thereby making the generated second text closer to the topic information.
[0083] Step S302: Perform text search based on the first keyword to obtain one or more first texts containing the first keyword.
[0084] It can be understood that after obtaining the first keyword, the text generation device can use the first keyword as a search term to perform text search and use the text containing the first keyword as the first text.
[0085] In some embodiments, when there are multiple first keywords, the text generation device can perform text search using each first keyword as a search term in turn to obtain one or more first texts.
[0086] In other embodiments, when there are multiple first keywords, the text generation device can also use multiple first keywords to perform text retrieval at the same time to obtain one or more first texts.
[0087] In some embodiments, when performing text retrieval, the text generating device may perform text retrieval from a text library related to the topic information to obtain one or more first texts.
[0088] In some embodiments, the text generation device may determine a text library related to the topic information input by the user from a server storing text libraries, and retrieve one or more first texts from the text library related to the topic information based on the first keyword.
[0089] In some embodiments, the server storing the text library can be a server that executes the text generation method provided in the embodiment of the present application, or it can be another server that has a communication connection established with the server that executes the text generation method provided in the embodiment of the present application. The embodiment of the present application is not limited to this.
[0090] Step S303: extracting second keywords associated with the first keywords from one or more first texts.
[0091] It can be understood that after obtaining one or more first texts through the above step S302, the text generation device can extract one or more second keywords associated with the first keyword in each first text according to the first keyword included in the first text.
[0092] In some embodiments, when a first keyword a is included in a first text, the text generating device may extract a second keyword associated with the first keyword a from the first text including the first keyword a.
[0093] For example, when performing text retrieval based on the first keyword "whitening", the first text obtained is: "Recently, someone asked how to choose domestic whitening products. Take a look at XX brand! Their Zhenbaiyin essence has whitening characteristics, and the whitening and lightening effect is amazing [wow]. The Zhenbaiyin Pro ingredient developed by the XX brand itself is gentle and effective, and it is scientifically compounded with other whitening and soothing ingredients to achieve the effect of 1+1>2! Buy 50ml and get 110ml during Double 11, so hurry up and stock up!" The text generation device can obtain the second keywords "XX brand" and "soothing" associated with "whitening".
[0094] In some embodiments, if the first text contains multiple first keywords, the text generation device may extract the second keyword associated with each first keyword from the first text in sequence.
[0095] Exemplarily, if the first keywords contained in the first text are first keyword a and first keyword c, the text generating device can extract the second keyword associated with the first keyword a and the second keyword associated with the first keyword c in sequence from the first text containing the first keyword a and the first keyword c.
[0096] In some embodiments, when there are multiple first texts, step S303 includes: obtaining at least one first candidate word from the multiple first texts; determining the number of first texts containing each first candidate word from the multiple first texts to obtain a first number; determining the total number of the multiple first texts to obtain a second number; and determining the first candidate word whose ratio of the first number to the second number is greater than a preset ratio as the second keyword.
[0097] It can be understood that when the text generation device obtains multiple first texts through the above step S302, the text generation device can extract the words contained in each first text, and use the words extracted from each first text as the first candidate word. Based on this, the text generation device can obtain at least one first candidate word. For any first candidate word in at least one first candidate word, the text generation device can determine the number of first texts including the first candidate word and obtain the first number. Afterwards, the text generation device can calculate the ratio of the first number to the second number. If the ratio of the first number to the second number is greater than the preset ratio, the first candidate word is determined as the second keyword. If the ratio of the first number to the second number is less than or equal to the preset ratio, it is determined that the first candidate word cannot be used as the second keyword.
[0098] Exemplarily, assuming that the first candidate word is the first candidate word d, the text generation device may determine the number of first texts including the first candidate word d in the plurality of first texts to obtain a first number. Afterwards, the text generation device may calculate the ratio of the first number to the second number, and if the ratio of the first number to the second number is greater than a preset ratio, the first candidate word d is determined to be the second keyword, and if the ratio of the first number to the second number is less than or equal to the preset ratio, it is determined that the first candidate word d cannot be used as the second keyword.
[0099] In some embodiments, the text generation device may extract the first candidate words from each first text based on a left-right combined entropy algorithm, a mutual information algorithm or other algorithms.
[0100] In some embodiments, after extracting words from the first text, the text generation device may match the extracted words with words in a preset word library, and if the extracted words are words included in the preset word library, the extracted words are used as the first candidate words.
[0101] In some embodiments, the size of the preset ratio can be set as needed, and the embodiments of the present application are not limited to this.
[0102] In the embodiment of the present application, if the ratio of the number of first texts containing the first candidate word to the second number is greater than the preset ratio, it means that the first candidate word is included in most of the first texts, and further, it means that the first candidate word has a high correlation with the first keyword. Therefore, by using the first candidate word whose ratio of the first number to the second number is greater than the preset ratio as the second keyword, a second keyword with a high correlation with the first keyword can be screened out.
[0103] In other embodiments, step S303 also includes: obtaining at least one second candidate word from one or more first texts; determining the distance between each second candidate word and the first keyword in the same first text, wherein the distance is positively correlated with the number of characters between the second candidate word and the first keyword in the first text; and determining the second candidate word in each first text whose distance is less than a preset distance as the second keyword.
[0104] It can be understood that after the text generation device obtains one or more first texts through the above step S302, the text generation device can extract words from each first text and use the words extracted from the first text as the second candidate word. Afterwards, the text generation device can determine the number of characters between the second candidate word in the same first text and the first keyword in the first text. Afterwards, the text generation device can determine the distance between the second candidate word and the first keyword based on the number of characters between the second candidate word in the same first text and the first keyword in the first text. When the text generation device determines that the distance between the second candidate word and the first keyword is less than a preset distance, the second candidate word can be determined as the second keyword. If the distance between the second candidate word and the first keyword is greater than or equal to the preset distance, it is determined that the second candidate word cannot be used as the second keyword.
[0105] In some embodiments, when the text generation device determines that the distance between the second candidate word and the first keyword is less than or equal to a preset distance, the second candidate word is determined as the second keyword; when the distance between the second candidate word and the first keyword is greater than the preset distance, the text generation device determines that the second candidate word cannot be used as the second keyword.
[0106] In some embodiments, taking a first text containing a first keyword a and a second candidate word e as an example, the implementation process of determining a second keyword from a second candidate word is introduced. After obtaining the first text containing the first keyword a and the second candidate word e, the text generation device can determine the number of characters between the second candidate word e and the first keyword a, and determine the distance between the second candidate word e and the first keyword a based on the number of characters. If the text generation device determines that the distance between the second candidate word e and the first keyword a is less than a preset distance, the second candidate word e is determined as the second keyword. If the distance between the second candidate word e and the first keyword a is greater than or equal to the preset distance, it is determined that the second candidate word e cannot be used as the second keyword.
[0107] In some embodiments, the size of the preset distance can be set as needed, and the embodiments of the present application are not limited to this.
[0108] In some embodiments, if a first text includes multiple first keywords, the text generation device can calculate the distance between the second candidate word in the first text and any first keyword, and when the distance between the second candidate word and any first keyword is less than a preset distance, determine that the second candidate word is the second keyword. Alternatively, the text generation device can also calculate the distance between each second candidate word in the first text and all first keywords, and when the average distance between the second candidate word and all first keywords is less than a preset distance, determine that the second candidate word is the second keyword.
[0109] Step S304: Determine a plurality of keyword groups based on the keyword set consisting of the first keyword and the second keyword.
[0110] It is understandable that after obtaining the first keyword and the second keyword, the text generation device can combine all the first keywords and all the second keywords to obtain a keyword set. Afterwards, the text generation device can group the keywords in the keyword set with at least two keywords in the keyword set as a group to obtain multiple keyword groups.
[0111] In some embodiments, any one of the multiple keyword groups may include at least one first keyword and at least one second keyword, or may include multiple first keywords without including the second keyword, or may include multiple second keywords without including the first keyword.
[0112] Exemplarily, when a plurality of first keywords and one second keyword are included in the keyword set, the text generation device can combine different first keywords and second keywords, or combine at least two first keywords to obtain multiple keyword groups. When a first keyword and multiple second keywords are included in the keyword set, the text generation device can combine different second keywords with the first keyword, or combine at least two second keywords to obtain multiple keyword groups. In the case where there are multiple first keywords and multiple second keywords, the text generation device can combine multiple first keywords into one keyword group, or combine multiple second keywords into one keyword group, and can also combine different first keywords with different second keywords into different keyword groups to obtain multiple keyword groups.
[0113] In some embodiments, reference Figure 4 , Figure 4 1 is an optional flow chart of a method for generating a keyword group provided in an embodiment of the present application. Figure 4 The steps shown in are further introduced for the above step 304.
[0114] Step S401: Determine a first relevance of each second keyword in the keyword set.
[0115] Here, the first degree of association is used to indicate the degree of association between the second keyword and the corresponding first keyword in the keyword set.
[0116] It can be understood that after extracting multiple second keywords from the first text, the text generation device can calculate the degree of association between each second keyword and the corresponding first keyword to obtain the first degree of association of each second keyword.
[0117] In some embodiments, a text search is performed using the first keyword as a search term, and the second keyword obtained may be the second keyword corresponding to the first keyword. For example, a text search is performed using the first keyword a as a search term, a first text is obtained, and the second keyword b is extracted from the first text, then the first keyword corresponding to the second keyword b is the first keyword a. If a text search is performed using the first keyword a and the first keyword b as search terms, a first text is obtained, and the second keyword b is extracted from the first text, then the first keywords corresponding to the second keyword b are the first keyword a and the first keyword b.
[0118] In some embodiments, for any second keyword in the keyword set, if there is only one first keyword corresponding to the second keyword, the text generation device can calculate the degree of association between the second keyword and the first keyword to obtain a first degree of association of the second keyword.
[0119] In other embodiments, for any second keyword in the keyword set, if there are multiple first keywords corresponding to the second keyword, the text generation device can calculate the degree of association between the second keyword and each first keyword, and take the average, maximum or minimum value of the first association between the second keyword and all the first keywords as the first association of the second keyword.
[0120] In some embodiments, for any second keyword in the keyword set, the text generation device may also determine the degree of association between the second keyword and the first keyword according to the number of first texts containing the second keyword, and obtain a first degree of association. The first degree of association of the second keyword is positively correlated with the number of first texts containing the second keyword.
[0121] Exemplarily, when calculating the first relevance of the second keyword b, the text generation device may determine the number of first texts containing the second keyword b from the plurality of first texts. Thereafter, the text generation device may determine the first relevance of the second keyword b according to the number of first texts containing the second keyword b.
[0122] In some embodiments, step S401 includes: obtaining a second association degree of a target second keyword, where the target second keyword is any second keyword in a keyword set, and the second association degree is used to indicate the degree of association between the target second keyword and the target first text, where the target first text is the first text where the target second keyword is located, and the second association degree is positively correlated with the number of times the target second keyword appears in the target first text; determining a third association degree of the target first keyword, where the target first keyword is the first keyword used when retrieving the target first text, and the third association degree is used to indicate the degree of association between the target first keyword and the target first text, and the third association degree is positively correlated with the number of times the target first keyword appears in the target first text; determining the degree of attention of the target first text based on user interaction information of the target first text, where the user interaction information is used to indicate the number of interactions between the target first text and the user, and the degree of attention is used to indicate the degree to which the target first text is paid attention to by the user; determining a first association degree of the target second keyword based on the second association degree, the third association degree, and the degree of attention.
[0123] It can be understood that for any second keyword in the keyword set, for the convenience of explanation, it is referred to as the target second keyword, and any first text including the target second keyword is the target first text. The text generation device can determine the number of times the target second keyword appears in the target first text, and determine the second degree of association between the target second keyword and the target first text based on the number of times the target second keyword appears in the target first text. The text generation device can also determine the number of times the first keyword used to retrieve the target first text appears in the target first text. For the convenience of explanation, the first keyword used to retrieve the target first text is referred to as the target first keyword. After obtaining the number of times the target first keyword appears in the target first text, the text generation device can determine the third degree of association between the target first keyword and the target first text according to the number of times the target first keyword appears in the target first text. In addition, the text generation device can also obtain user interaction information of the target first text, and determine the degree of attention of the target first text based on the user interaction information of the target first text. Among them, the more times the target first text indicated by the user interaction information of the target first text interacts with the user, the greater the degree of attention of the target first text. Afterwards, the text generation device may determine the first relevance of the target second keyword according to the second relevance of the target second keyword, the third relevance of the target first keyword, and the attention level of the target first text.
[0124] In some embodiments, when a target first text contains multiple target first keywords, the text generation device may determine the first relevance of the target second keyword based on the second relevance of the target second keyword, the attention of the target first text, and the third relevance of any target first keyword. Alternatively, the text generation device may also calculate the average third relevance of the target first keyword, and determine the first relevance of the target second keyword based on the second relevance of the target second keyword, the attention of the target first text, and the average third relevance of the target first keyword.
[0125] In some embodiments, when there are multiple target first texts including the target first keyword and the target second keyword, the text generation device can refer to the above method and determine the first relevance of the target second keyword based on any target first text among the multiple target first texts. Alternatively, the maximum value, minimum value or average value of multiple first relevances of the target second keyword calculated based on the multiple target first texts is used as the first relevance of the target second keyword.
[0126] Exemplarily, assuming that the target second keyword is the second keyword b, the target first keyword is the first keyword a, and the number of first texts including the first keyword a and the second keyword b is n. The text generation device can calculate a first relevance of the second keyword b based on each of the n first texts to obtain n first relevances. At this time, the text generation device can determine the maximum value, minimum value or average value of the n first relevances as the first relevance of the second keyword b. Wherein n is an integer greater than 1.
[0127] In some embodiments, the user interaction information includes but is not limited to at least one of the number of comments, clicks, favorites, visits and / or forwardings of the target first text. The attention paid to the target first text is positively correlated with the number of comments, clicks, visits and / or forwardings of the target first text.
[0128] In some embodiments, when the user interaction information includes the number of comments, the number of visits and the number of clicks, the text generation device can configure weights for the number of comments, the number of visits and the number of clicks. Based on this, when calculating the attention of the target first text, the text generation device can determine the attention of the target first text according to the number of comments, the number of visits and the number of clicks, and the weights corresponding to the number of comments, the number of visits and the number of clicks.
[0129] Exemplarily, when configuring weights for the number of comments, the number of visits, and the number of clicks, the text generation device may make the weight of the number of comments greater than the weight of the number of clicks, and make the weight of the number of clicks greater than the weight of the number of visits.
[0130] In some embodiments, the text generation device may determine the first relevance of the second keyword by using the following formula (1).
[0131]
[0132] a is the first keyword, b is the second keyword, L(ab) is the first association degree, t is the tth first text among the multiple first texts (including the first text of the first keyword a and the second keyword b), r t(θ) is the identifier of the t-th first text, is the third correlation between the first keyword a and the tth first text, a t is the number of times the first keyword a appears in the tth first text, s t is the total number of times the first keyword a and the second keyword b appear in the tth first text, sft() is the calculation function, θ is the first hyperparameter, clip(r t(θ) ,1-ε,1+ε) is the attention degree of the t-th first text, clip() is the score function, ε is the second hyperparameter, is the second correlation between the second keyword b and the tth first text, b t is the number of times the second keyword b appears in the tth first text.
[0133] In some embodiments, the identifier of the t-th first text may be an ID of the t-th first text.
[0134] In some embodiments, the text generation device may also calculate the second degree of association and the third degree of association by using a KL (Kullback-Leibler) divergence algorithm.
[0135] Exemplarily, the text generation device may calculate the second degree of association and the third degree of association by the following formula (2).
[0136]
[0137] Among them, when P(x) is a t , and Q(x) is s t When P(x) is b, KL[P(x)PQ(x)] is the second degree of association. t , and Q(x) is s t , KL[P(x)PQ(x)] is the third degree of association.
[0138] Step S402: combining any first keyword in the keyword set with a second keyword with a different first relevance to obtain a plurality of keyword groups.
[0139] It can be understood that after obtaining the first relevance of each second keyword, the text generation device can combine any first keyword in the keyword set with a second keyword with a different first relevance to obtain multiple keyword groups with different first relevances.
[0140] In some embodiments, after obtaining the first degree of association of each second keyword, the text generation device can also determine second keywords with different first degrees of association from multiple second keywords based on the first degree of association of each second keyword, and combine the second keywords with different first degrees of association with any first keyword in the keyword set to obtain multiple keyword groups.
[0141] In some embodiments, step S402 includes: dividing multiple second keywords in the keyword set into multiple subsets according to the first correlation degree, and different subsets correspond to different first correlation degree value intervals; combining any first keyword in the keyword set and second keywords in different subsets to obtain multiple keyword groups.
[0142] It is understandable that after obtaining the first relevance of each second keyword, the text generation device can divide the multiple second keywords into multiple subsets according to the magnitude of the first relevance, wherein one subset corresponds to one first relevance value interval. Afterwards, the text generation device can also combine the second keywords in different subsets with any one or more first keywords in the keyword set to obtain multiple keyword groups.
[0143] In some embodiments, when generating a keyword group, the text generation device may combine any first keyword in the keyword set with at least one second keyword obtained from at least one subset to obtain a keyword group. The text generation device may repeat this process to obtain multiple keyword groups.
[0144] In some embodiments, the text generation device may sort the second keywords according to the magnitude of the first relevance, and divide a preset number of second keywords into a subset according to the order of the first relevance from large to small, thereby obtaining multiple subsets.
[0145] In some embodiments, the number of second keywords included in each subset may be the same. For example, when the number of second keywords is 20 and the preset number is 5, the text generation device may sort the 20 second keywords according to the magnitude of the first relevance, and divide every 5 second keywords into a subset according to the order of the first relevance from large to small, thereby obtaining 4 subsets.
[0146] In some other embodiments, the number of second keywords included in a subset may be twice the number of second keywords in the previous subset. Figure 5 , Figure 5 is a schematic diagram of a subset provided by an embodiment of the present application. When the number of second keywords is 12, the text generation device can divide the 4 second keywords with the largest first correlation into the first subset, and divide the remaining 8 second keywords into the second subset, to obtain Figure 5 The 2 subsets are shown.
[0147] In other embodiments, the text generation device may also divide the first correlation degree into multiple value intervals based on the maximum first correlation degree and the minimum first correlation degree of the second keyword, and divide all second keywords whose first correlation degrees are in the same value interval into the same subset, thereby obtaining multiple subsets.
[0148] Exemplarily, the text generation device can divide the second keyword into a first value interval, a second value interval, and a third value interval based on the maximum first relevance and the minimum first relevance. Based on this, the text generation device can divide the second keyword with the first relevance in the first value interval into the same subset; divide the second keyword with the first relevance in the second value interval into the same subset; divide the second keyword with the first relevance in the third value interval into the same subset, and obtain three subsets.
[0149] In some embodiments, the upper limit of the first value interval may be greater than or equal to the maximum first degree of association, the lower limit of the first value interval may be greater than or equal to the upper limit of the second value interval, the lower limit of the second value interval may be greater than or equal to the upper limit of the third value interval, and the lower limit of the third value interval may be less than or equal to the minimum first degree of association.
[0150] In some embodiments, the text generation device can also generate a keyword tree based on all keywords in the keyword set. When the text generation device generates the keyword tree, if the first keyword is one, the text generation device can use the first keyword as the root node of the keyword tree. If the first keyword is multiple, the text generation device can use any first keyword as the root node of the keyword tree and use the remaining first keywords as direct child nodes of the keyword tree. The text generation device can also use each second keyword as a direct child node and an indirect child node of the keyword tree based on the size of the first relevance of the second keyword. Among them, the distance between the second keyword and the first keyword in the keyword tree is negatively correlated with the first relevance of the second keyword.
[0151] In some embodiments, after the text generation device obtains the keyword tree, step S402 includes: combining multiple keyword groups on the same branch of the keyword tree into one keyword group, and / or combining multiple keyword groups at the same level of the keyword tree into one keyword group, thereby obtaining multiple keyword groups.
[0152] In some embodiments, any first keyword in a keyword set and a second keyword in a different subset are combined to obtain a plurality of keyword groups, including: configuring a weight for each of the plurality of subsets, the weight being used to indicate the number of second keywords obtained from each subset when generating a keyword group; combining a corresponding number of second keywords obtained from each subset according to the weight with any first keyword in the keyword set to obtain a plurality of keyword groups.
[0153] It is understandable that after dividing the plurality of second keywords into a plurality of subsets, the text generation device may further configure a weight for each subset. When generating a keyword group, the text generation device may determine to obtain a corresponding number of second keywords from each subset according to the weight of each subset. Afterwards, the text generation device may combine the second keywords obtained from each subset according to the weight with any first keyword to obtain a keyword group, and repeat the above process to obtain multiple keyword groups.
[0154] In some embodiments, the text generation device may configure a weight for the corresponding subset according to the first association degree of each subset. Exemplarily, the size of the weight configured by the text generation device for a subset may be positively correlated with the first association degree of the second keyword included in the subset.
[0155] In other embodiments, taking the generation of a keyword group as an example, the implementation process of the text generation device generating a keyword group is described. When the text generation device generates a keyword group each time, it can also configure a random number for each subset, and use the configured random number as the weight of the corresponding subset. Afterwards, the text generation device can obtain a corresponding number of second keywords from each subset according to the random number configured for each subset, and combine the corresponding number of second keywords obtained from each subset with any first keyword to obtain a keyword group.
[0156] In some embodiments, the text generating device may generate a random number configured for each subset through a random function.
[0157] In some embodiments, the method further includes: determining the priority of each subset based on the first association value interval corresponding to each subset, the priority being positively correlated with the first association value interval corresponding to the subset; and configuring a weight for each subset based on the priority.
[0158] It is understandable that the text generation device can determine the first association value interval corresponding to each subset, and then determine the priority of each subset according to the first association value interval corresponding to each subset. Afterwards, the text generation device can configure a corresponding weight for each subset according to the priority of each subset.
[0159] In an embodiment of the present application, since the first degree of association value interval of the subset is larger, it means that the first degree of association of the second keyword included in the subset is higher. Configuring a larger weight for a subset with a larger first degree of association value interval can increase the proportion of the second keyword with a larger first degree of association in the keyword group. Since the first degree of association between the second keyword and the first keyword is larger, the correlation between the second text generated based on the second keyword and the topic information is also larger. Therefore, configuring a weight for each subset according to the first degree of association can increase the proportion of the second keyword with a larger first degree of association in the keyword group, thereby improving the correlation between the second text generated based on the keyword group and the topic information.
[0160] Step S305: Based on the multiple keyword groups, generate a second text corresponding to each keyword group.
[0161] It can be understood that after obtaining multiple keyword groups in step S304, the text generation device can generate a second text for each keyword group to obtain multiple second texts.
[0162] In some embodiments, step S305 includes: the text generation device can obtain the first keyword and the second keyword included in a keyword group, and generate a corresponding text segment for each first keyword and each second keyword. Afterwards, the text generation device can splice the text segments generated based on the first keyword and the second keyword included in a keyword group to obtain a second text.
[0163] In other embodiments, step S305 also includes: generating text based on multiple keyword groups through a text generation model to obtain a second text corresponding to each keyword group, wherein the text generation model is trained based on topic sample information and text samples corresponding to the topic sample information.
[0164] It is understandable that before the corresponding second text is generated based on the keyword group by the text generation model, the text generation model can be trained by the topic sample information and the text sample corresponding to the topic sample information, so that the text generation model has text generation capability, and then the trained text generation model is obtained. Wherein, the text generation model in the embodiment of the present application includes but is not limited to a deep neural network model or a convolutional neural network model. For example, the text generation model can be a BERT (bidirectional encoder representation from transformers) model. After obtaining a plurality of keyword groups, the text generation device can input the plurality of keyword groups into the text generation model, at which time, the text generation model can generate the second text corresponding to each keyword group based on the first keyword and the second keyword included in each keyword group.
[0165] Exemplarily, when the first keyword and the second keyword in a keyword group are the brand names of two brands of the same product, the keyword group is input into the text generation model, and a second text introducing or comparing the two brands can be obtained. Exemplarily, when the first keyword and the second keyword in a keyword group are the product names of two products of the same brand, the keyword group is input into the text generation model, and a second text introducing or comparing the two products can be obtained.
[0166] In some embodiments, when the keyword tree is obtained through the above steps, the text generation device can also input the keyword tree into a trained text generation model to obtain different second texts obtained by the text generation model based on the combination of different keywords on the keyword tree.
[0167] In some embodiments, the training method of the text generation model may include, but is not limited to: SFT (supervised fine-tuning) supervised fine-tuning method, or low-rank adaptation (LoRA) fine-tuning method.
[0168] The following is a detailed description of the implementation process of the text generation method provided in the above embodiment in actual application.
[0169] In some embodiments, Figure 6 1 is a flowchart of an exemplary embodiment of the text generation method provided by the embodiment of the present application. The text generation method described above will be described below by taking the topic information "How to get back in autumn" input by the user in the topic box as an example.
[0170] Step S601: Get "How to get back in autumn" from the topic box.
[0171] Step S602: By performing keyword extraction or semantic analysis on “How to get fair skin in autumn”, it is determined that “How to get fair skin in autumn” is the second type of topic information related to whitening products.
[0172] Step S603: Determine that the third text corresponding to the second type of topic information is product information and / or brand information.
[0173] Step S604: Obtain product information or brand information related to “How to get fair skin in autumn”, for example, product information of YY whitening products.
[0174] Step S605: Input “How to get white skin back in autumn” and product information of YY whitening products into the reinforcement learning model to generate the first keyword associated with “How to get white skin back in autumn”, for example, “whitening”.
[0175] Step S606: Perform text search using "whitening" as the search term to obtain one or more first texts.
[0176] Step S607: extract keywords from the first text to obtain second keywords, for example, "soothing" and "XX brand".
[0177] Step S608: Combine "soothing" and "XX brand" with "whitening" to obtain {"whitening", "soothing"} and {"whitening", "XX brand"}.
[0178] Step S609: Input {"whitening", "soothing"} and {"whitening", "XX brand"} into the trained BERT model to obtain the second text associated with {"whitening", "soothing"} and the second text associated with {"whitening", "XX brand"}.
[0179] At this point, the text generation device completes the above-mentioned text generation method.
[0180] In an embodiment of the present application, first, after obtaining the first keyword associated with the topic information, the first keyword can also be used as a search term to obtain a first text, and multiple second keywords can be extracted from the first text. Afterwards, based on a keyword set consisting of the first keyword and the second keyword, multiple keyword groups are determined, and then a corresponding second text is generated based on each keyword group. Since different second texts are generated based on different keyword groups, at least some of the keywords included in different keyword groups are different. Therefore, the second texts generated based on different keyword groups are different, which can reduce the repetition rate between multiple second texts generated based on the same topic information.
[0181] Secondly, the text generation device can obtain multiple keyword groups including second keywords with different first associations by combining second keywords with different first associations. Based on multiple keyword groups including second keywords with different first associations, multiple second texts can be generated to obtain second texts with different associations with topic information.
[0182] Finally, the text generation device generates a second text corresponding to each keyword group based on a text generation model. Compared with obtaining text related to the topic information by performing text retrieval and text splicing on the extracted keywords, since the text generation model is trained based on text samples, it can learn the expressions in the text samples, thereby improving the readability of the output second text.
[0183] The following is a description of an exemplary structure of the text generation device 455 provided in the embodiment of the present application implemented as a software module. In some embodiments, Figure 2 As shown, the software modules stored in the text generation device 455 of the memory 450 may include:
[0184] The keyword construction result module 4551 is used to obtain the first keyword associated with the topic information input by the user; the first reinforcement learning module 4552 is used to perform text retrieval based on the first keyword to obtain one or more first texts containing the first keyword; the second reinforcement learning module 4553 is used to extract the second keyword associated with the first keyword from the one or more first texts; the first keyword decomposition module 4554 is used to determine multiple keyword groups based on a keyword set consisting of the first keyword and the second keyword; the text generation module 4555 is used to generate a second text corresponding to each keyword group based on the multiple keyword groups.
[0185] In some possible implementations, there are multiple second keywords; the first keyword disassembly module 4554 is used to: determine the first association degree of each second keyword in the keyword set, the first association degree is used to indicate the degree of association between the second keyword and the corresponding first keyword in the keyword set; combine any first keyword in the keyword set with a second keyword with a different first association degree to obtain multiple keyword groups.
[0186] In some possible implementations, the first keyword disassembly module 4554 is used to: divide multiple second keywords in the keyword set into multiple subsets according to the first correlation, and different subsets correspond to different first correlation value intervals; combine any first keyword in the keyword set and second keywords in different subsets to obtain multiple keyword groups.
[0187] In some possible implementations, the first keyword disassembly module 4554 is used to: configure a weight for each of a plurality of subsets, where the weight is used to indicate the number of second keywords obtained from each subset when generating a keyword group; and combine a corresponding number of second keywords obtained from each subset according to the weight with any first keyword in the keyword set to obtain multiple keyword groups.
[0188] In some possible implementations, the device also includes: a determination module, used to determine the priority of each subset based on the first association value interval corresponding to each subset, the priority being positively correlated with the first association value interval corresponding to the subset; and a second keyword decomposition module, used to configure a weight for each subset based on the priority.
[0189] In some possible implementations, the first keyword disassembly module is used to: obtain a second relevance of a target second keyword, where the target second keyword is any second keyword in a keyword set, the second relevance is used to indicate the degree of relevance between the target second keyword and a target first text, where the target first text is the first text where the target second keyword is located, the second relevance is positively correlated with the number of times the target second keyword appears in the target first text, and the target first text is retrieved based on the target first keyword; determine a third relevance of the target first keyword, where the target first keyword is the first keyword used when retrieving the target first text, the third relevance is used to indicate the degree of relevance between the target first keyword and the target first text, and the third relevance is positively correlated with the number of times the target first keyword appears in the target first text; determine the degree of attention of the target first text based on user interaction information of the target first text, where the user interaction information is used to indicate the number of times the target first text interacts with the user, and the degree of attention is used to indicate the degree to which the target first text is paid attention to by the user; determine the first relevance of the target second keyword based on the second relevance, the third relevance, and the degree of attention.
[0190] In some possible implementations, the text generation module 4555 is used to: generate text based on multiple keyword groups through a text generation model to obtain a second text corresponding to each keyword group, wherein the text generation model is trained based on topic sample information and text samples corresponding to the topic sample information.
[0191] In some possible embodiments, the second reinforcement learning module 4553 is used to: obtain at least one first candidate word from multiple first texts; determine the number of first texts containing each first candidate word from the multiple first texts to obtain a first number; determine the total number of the multiple first texts to obtain a second number; and determine a first candidate word whose ratio of the first number to the second number is greater than a preset ratio as a second keyword.
[0192] In some possible embodiments, the second reinforcement learning module 4553 is used to: obtain at least one second candidate word from one or more first texts; determine the distance between the second candidate word and the first keyword in the same first text, wherein the distance is positively correlated with the number of characters between the second candidate word and the first keyword in the first text; and determine the second candidate word in each first text whose distance is less than a preset distance as the second keyword.
[0193] In some possible implementations, the keyword construction result module 4551 is used to: determine the type of topic information; obtain a third text and topic information corresponding to the topic information and the type; and generate a first keyword associated with the topic information based on the third text.
[0194] The embodiment of the present application provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the text generation method described in the embodiment of the present application.
[0195] The present application embodiment provides a computer-readable storage medium storing executable instructions, wherein the executable instructions are stored. When the executable instructions are executed by a processor, the processor will execute the text generation method provided by the present application embodiment, for example, Figure 3 The text generation method shown.
[0196] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EP ROM, EEPROM, flash memory, magnetic surface storage, optical disk, or CD-ROM; or it may be various devices including one or any combination of the above memories.
[0197] In some embodiments, executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.
[0198] As an example, executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).
[0199] As an example, executable instructions may be deployed to be executed on one computing device, or on multiple computing devices located at one location, or on multiple computing devices distributed at multiple locations and interconnected by a communication network. The above is only an embodiment of the present application and is not intended to limit the scope of protection of the present application. Any modifications, equivalent substitutions, and improvements made within the spirit and scope of the present application are included in the scope of protection of the present application.
Claims
1. A text generation method, characterized in that: The method comprises: Obtaining a first keyword associated with the topic information input by the user; Performing a text search based on the first keyword to obtain one or more first texts containing the first keyword; extracting a second keyword associated with the first keyword from the one or more first texts; Determine a plurality of keyword groups based on a keyword set consisting of the first keyword and the second keyword, wherein the keyword groups include at least two keywords in the keyword set; Based on the plurality of keyword groups, a second text corresponding to each keyword group is generated.
2. The method according to claim 1, characterized in that The second keyword is multiple; The determining of a plurality of keyword groups based on a keyword set consisting of the first keyword and the second keyword includes: Determine a first degree of association for each second keyword in the keyword set, where the first degree of association is used to indicate a degree of association between the second keyword and a corresponding first keyword in the keyword set; Any first keyword in the keyword set is combined with a second keyword with a different first relevance to obtain the multiple keyword groups.
3. The method according to claim 2, characterized in that The combining of any first keyword in the keyword set with a second keyword having a different first relevance to obtain the plurality of keyword groups includes: According to the first relevance, the plurality of second keywords in the keyword set are divided into a plurality of subsets, wherein different subsets correspond to different first relevance value intervals; The plurality of keyword groups are obtained by combining any first keyword in the keyword set with second keywords in different subsets.
4. The method according to claim 3, characterized in that The combining of any first keyword in the keyword set and second keywords in different subsets to obtain the multiple keyword groups includes: configuring a weight for each of the plurality of subsets, the weight being used to indicate the number of second keywords obtained from each subset when generating a keyword group; A corresponding number of second keywords obtained from each subset according to the weight are combined with any first keyword in the keyword set to obtain the multiple keyword groups.
5. The method according to claim 4, characterized in that The method further comprises: Determine the priority of each subset based on the first association degree value interval corresponding to each subset, wherein the priority is positively correlated with the first association degree value interval corresponding to the subset; The weight is configured for each of the subsets based on the priority.
6. The method according to any one of claims 2 to 5, characterized in that: The determining a first relevance of each second keyword in the keyword set includes: Acquire a second relevance of a target second keyword, the target second keyword being any second keyword in the keyword set, the second relevance being used to indicate a degree of relevance between the target second keyword and a target first text, the target first text being a first text where the target second keyword is located, and the second relevance being positively correlated with the number of times the target second keyword appears in the target first text; Determining a third relevance of the target first keyword, where the target first keyword is a first keyword used when searching the target first text, the third relevance is used to indicate a degree of relevance between the target first keyword and the target first text, and the third relevance is positively correlated with the number of times the target first keyword appears in the target first text; Determine the attention degree of the target first text based on the user interaction information of the target first text, wherein the user interaction information is used to indicate the number of interactions between the target first text and the user, and the attention degree is used to indicate the degree to which the target first text is paid attention to by the user; Based on the second relevance, the third relevance, and the attention degree, a first relevance of the target second keyword is determined.
7. The method according to any one of claims 1 to 5, characterized in that: The step of generating a second text corresponding to each keyword group based on the plurality of keyword groups includes: Through a text generation model, text generation is performed based on the multiple keyword groups to obtain a second text corresponding to each keyword group, wherein the text generation model is trained based on topic sample information and text samples corresponding to the topic sample information.
8. The method according to any one of claims 1 to 5, characterized in that: The extracting a second keyword associated with the first keyword from the one or more first texts includes: Acquire at least one first candidate word from the plurality of first texts; Determine the number of first texts containing each first candidate word from the plurality of first texts to obtain a first number; Determine the total number of the plurality of first texts to obtain a second number; A first candidate word whose ratio of the first quantity to the second quantity is greater than a preset ratio is determined as the second keyword.
9. The method according to any one of claims 1 to 5, characterized in that: The extracting a second keyword associated with the first keyword from the one or more first texts includes: Acquire at least one second candidate word from the one or more first texts; Determining a distance between a second candidate word and a first keyword in the same first text, wherein the distance is positively correlated with the number of characters between the second candidate word and the first keyword in the first text; In each of the first texts, the second candidate word whose distance is less than the preset distance is determined as the second keyword.
10. The method according to any one of claims 1 to 5, characterized in that: The obtaining of a first keyword associated with the topic information input by the user includes: Determining the type of the topic information; Acquire a third text corresponding to the topic information and the type; Based on the third text and the topic information, a first keyword associated with the topic information is generated.
11. A text generation device, characterized in that: The device comprises: A keyword construction result module is used to obtain a first keyword associated with the topic information input by the user; A first reinforcement learning module, configured to perform text retrieval based on the first keyword to obtain one or more first texts containing the first keyword; A second reinforcement learning module, configured to extract a second keyword associated with the first keyword from the one or more first texts; A first keyword decomposition module, based on a keyword set consisting of the first keyword and the second keyword, determines a plurality of keyword groups, wherein the keyword groups include at least two keywords in the keyword set; The text generation module is used to generate a second text corresponding to each keyword group based on the multiple keyword groups.
12. An electronic device, characterized in that: The electronic device comprises: A memory for storing executable instructions; A processor, configured to implement the method according to any one of claims 1 to 10 when executing the executable instructions or computer programs stored in the memory.
13. A computer-readable storage medium storing executable instructions or a computer program, characterized in that: When the executable instructions are executed by a processor, the method according to any one of claims 1 to 10 is implemented.
14. A computer program product, characterized in that It includes a computer program or an instruction, which is used to implement the method provided in the present application when the computer program or the instruction is executed by a processor.
