Content generation method, device, equipment and storage medium based on artificial intelligence

By editing and processing the attention weight of the input content, the target output content is generated, which solves the problems of complexity of model retraining and insufficient content generation effect in the existing technology, and achieves efficient and accurate content generation effect.

CN117194696BActive Publication Date: 2024-10-18BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311076947.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-24
Publication Date
2024-10-18
Estimated Expiration
2043-08-24

AI Technical Summary

Technical Problem

In the existing technology, the retraining method of the generative model has problems such as heavy workload and complex implementation, and the content generation effect needs to be improved.

Method used

By editing the attention weight of the input content, the target output content is generated, which avoids the need to retrain the model and realizes the editability of the attention weight, thus improving the content generation effect.

Benefits of technology

This method does not require retraining the model, reduces the workload and implementation complexity, improves the effect and accuracy of content generation, and realizes the overall style and local editing of images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117194696B_ABST
    Figure CN117194696B_ABST
Patent Text Reader

Abstract

The present disclosure provides a method, device, equipment and storage medium for content generation based on artificial intelligence, which relates to the field of artificial intelligence technology, specifically computer vision, deep learning, large models and other technical fields, and can be applied to scenarios such as artificial intelligence content generation. The content generation method based on artificial intelligence includes: performing attention processing on a first input content feature of a first input content to obtain a first attention weight; performing attention processing on a second input content feature of a second input content to obtain a second attention weight; wherein the second input content is obtained by editing the first input content; editing the first attention weight and the second attention weight to obtain a target attention weight; generating the target attention weight and the second input content feature to generate a target output content. The present disclosure can improve the content generation effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, specifically computer vision, deep learning, large models and other technical fields, and can be applied to scenarios such as AIGC, and in particular to an artificial intelligence-based content generation method, device, equipment and storage medium. Background Art

[0002] Generative AI (Artificial Intelligence Generated Content, AIGC) refers to the technology based on artificial intelligence technical methods such as generative adversarial networks and large pre-trained models, which generates relevant content with appropriate generalization capabilities through learning and recognition of existing data.

[0003] Taking text2img as an example, there is a need for image editing. Summary of the invention

[0004] The present disclosure provides a method, apparatus, device and storage medium for content generation based on artificial intelligence.

[0005] According to one aspect of the present disclosure, there is provided an artificial intelligence-based content generation method, comprising: performing attention processing on a first input content feature of a first input content to obtain a first attention weight; performing attention processing on a second input content feature of a second input content to obtain a second attention weight; wherein the second input content is obtained by editing the first input content; performing editing processing on the first attention weight and the second attention weight to obtain a target attention weight; and performing generation processing on the target attention weight and the second input content feature to generate a target output content.

[0006] According to another aspect of the present disclosure, there is provided an artificial intelligence-based content generation device, comprising: a first processing module, configured to perform attention processing on a first input content feature of a first input content to obtain a first attention weight; a second processing module, configured to perform attention processing on a second input content feature of a second input content to obtain a second attention weight; wherein the second input content is obtained by editing the first input content; an editing module, configured to perform editing processing on the first attention weight and the second attention weight to obtain a target attention weight; and a generating module, configured to perform generating processing on the target attention weight and the second input content feature to generate a target output content.

[0007] According to another aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any method as described in any of the above aspects.

[0008] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute any one of the methods according to any one of the above aspects.

[0009] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the computer program implements any one of the methods described in any one of the above aspects.

[0010] According to the technical solution disclosed in the present invention, the content generation effect can be improved.

[0011] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0013] Figure 1 is a schematic diagram according to a first embodiment of the present disclosure;

[0014] Figure 2 is a schematic diagram of an application scenario provided according to an embodiment of the present disclosure;

[0015] Figure 3 is a schematic diagram according to a second embodiment of the present disclosure;

[0016] Figure 4 is a schematic diagram of the overall architecture of a Wenshengtu scene provided according to an embodiment of the present disclosure;

[0017] Figure 5 is a schematic diagram according to a third embodiment of the present disclosure;

[0018] Figure 6 It is a schematic diagram of an electronic device used to implement the artificial intelligence-based content generation method of an embodiment of the present disclosure. DETAILED DESCRIPTION

[0019] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0020] In the related art, image editing can be achieved by retraining the generation model. However, the retraining of the generation model has problems such as large workload and complex implementation. In addition, the content generation effect needs to be improved.

[0021] In order to improve the content generation effect, the present disclosure provides the following embodiments.

[0022] Figure 1 is a schematic diagram according to the first embodiment of the present disclosure. This embodiment provides a content generation method based on artificial intelligence, the method comprising:

[0023] 101. Perform attention processing on a first input content feature of a first input content to obtain a first attention weight.

[0024] 102. Perform attention processing on a second input content feature of a second input content to obtain a second attention weight; wherein the second input content is obtained by editing the first input content.

[0025] 103. Based on the first input content and the second input content, edit the first attention weight and the second attention weight to obtain a target attention weight.

[0026] 104. Generate the target attention weight and the second input content feature to generate target output content.

[0027] In the AICG scenario, one type of content can be used to generate another type of content, wherein the former type of content can be referred to as input content and the latter type of content can be referred to as output content.

[0028] For example, in the text2img scenario, the input content is text and the output content is an image. For another example, in the text2video scenario, the input content is text and the output content is a video. For another example, in the text2text scenario, the input content is text and the output content is also text.

[0029] Taking a text image as an example, there is a need for image editing. In this embodiment, the output content (image) can be edited by editing the input content (text).

[0030] The input content before editing can be called the first input content, and the input content after editing can be called the second input content. In the text-image scenario, for example, if the text before editing is "lemon cake" and the text after editing is "cheese cake", then the first input content is "lemon cake" and the second input content is "cheese cake".

[0031] The target output content refers to the output content generated based on the edited input content. For example, in the above example, the target output content refers to the image generated based on "cheese cake".

[0032] The first input content feature is obtained after feature extraction of the first input content;

[0033] The second input content feature is obtained after feature extraction of the second input content.

[0034] The generative model can be implemented based on an attention network, which can be a cross-attention network or a self-attention network.

[0035] In the attention network, the input content features can be processed with attention to obtain the corresponding attention weights.

[0036] The first attention weight refers to the attention weight obtained based on the first input content feature.

[0037] The second attention weight refers to the attention weight obtained based on the second input content feature.

[0038] The target attention weight refers to the attention weight obtained after editing the first attention weight and the second attention weight.

[0039] After obtaining the target attention weight, the target attention weight and the second input content feature can be used for generation processing to obtain the target output content.

[0040] In this embodiment, the target output content is obtained based on the target attention weight and the second input content feature. There is no need to retrain the model as a whole, which can avoid problems such as large workload and complex implementation caused by retraining the model. In addition, by editing the first attention weight and the second attention weight to obtain the target attention weight, the editability of the attention weight can be achieved, thereby improving the generation effect of the target output content.

[0041] In order to better understand the embodiments of the present disclosure, application scenarios to which the embodiments of the present disclosure can be applied are described.

[0042] Figure 2 2 is a schematic diagram of an application scenario provided by an embodiment of the present disclosure. The scenario includes: a user terminal 201 and a server 202. The user terminal 201 may include: a personal computer (PC), a mobile phone, a tablet computer, a laptop computer, a smart wearable device, etc. The server 202 may be a cloud server or a local server. The user terminal 201 and the server 202 may communicate using a communication network, and the communication network may include, for example, a wired network and / or a wireless network.

[0043] Taking the text-to-image scenario as an example, the user can transmit the input text to the server through the user terminal, and the server generates an image based on the text. The image generated by the server can also be fed back to the user terminal and displayed to the user through the user terminal.

[0044] The above takes the server performing text generation processing as an example. If the user terminal has relevant capabilities locally, the user terminal can also perform text generation processing.

[0045] For the server, a large language model (LLM) may be used to perform content generation processing.

[0046] LLM is a hot topic in the field of artificial intelligence in recent years. LLM is a pre-trained language model that learns rich language knowledge and world knowledge through pre-training on massive text data, so that it can achieve amazing results in various natural language processing (NLP) tasks. Wenxinyiyan, ChatGPT, etc. are applications developed based on LLM. They can generate fluent, logical, and creative text content, and can even have natural conversations with humans. In the natural language processing scenario, the large model can be a general pre-trained Transformer (Generative Pre-trained Transformer, GPT) model based on Transformer, an enhanced representation through knowledge integration (Enhanced Representation through Knowledge Integration, ERNIE) model, etc.

[0047] In this embodiment, taking the scene of cultural image as an example, the corresponding generation model can be selected as a diffusion model.

[0048] The diffusion model is iterated based on the time step t, and its initial image is a noise image (Z T ), and after a preset number of iterations (T), the final denoised image (Z 0 ). In each iterative process (such as from the tth moment to the (t-1)th moment), a denoising network can be used to denoise the current image (Z t ) is processed to obtain the next image (Z t-1 ), t=T,T-1,..., iterate continuously to get the final image Z 0 .

[0049] The denoising network can be selected as a UNet network, which includes an encoder and a decoder, and there is a cross-attention network in both the encoder and the decoder.

[0050] This embodiment mainly modifies (edits) the weights of the cross-attention network. If the denoising network includes multiple cross-attention networks, the weights of one or more of them can be modified.

[0051] In combination with the above application scenarios, the present disclosure also provides the following embodiments.

[0052] Figure 3 is a schematic diagram according to the second embodiment of the present disclosure, which provides a method for generating content based on artificial intelligence. This embodiment takes a text image as an example, and takes multiple iterations of a denoising network to generate an image as an example. Figure 3 As shown, the method includes:

[0053] 301. Obtain a first text and a second text, and generate a noise image according to a random seed s.

[0054] The first text refers to the text before editing, and the second text refers to the text after editing. For example, the first text P is "lemon cake", and the second text P * It's "cheesecake".

[0055] The random seed can be set, such as 1234567, to generate a noise image. Assume that the noise image is represented by Z T express.

[0056] 302. Initialization parameters.

[0057] The initialization parameters may include: the current iteration number t, the first current image Z t , the second current image Z * t .

[0058] The initial value of t is the maximum number of iterations T, which can be set.

[0059] First current image Z t , the second current image Z * t The initial values ​​are all noise images Z T .

[0060] 303. Determine whether the current iteration number t is greater than 0. If so, execute 304-308; otherwise, execute 309.

[0061] If t is greater than 0, the current iteration process can be executed, and the next image can be obtained based on the current image through the current iteration process. The next image can be obtained through the attention network.

[0062] Since this embodiment involves the first current image Z corresponding to P t , and P * The corresponding second current image Z * t , then the next image (target image) includes: the first target image Z corresponding to P t-1 , and P * The corresponding second target image Z * t-1 .

[0063] 304. Based on the first text P and the first current image Z t , get the first attention weight M at the current moment t .

[0064] 305. Based on the second text P * and the second current image Z * t , get the second attention weight M at the current moment * t .

[0065] Among them, for P and Z t , after a denoising process, we get M t ;

[0066] For P * and Z * t , after a denoising process, we get M * t .

[0067] There is no time-limited relationship between 304 and 305.

[0068] Specifically, Figure 4As shown, it may include: converting the first text feature corresponding to the first text P into a first key value feature K; t Perform feature extraction to obtain a first current image feature; convert the first current image feature into a first query feature Q; perform weight calculation on the first query feature Q and the first key value feature K to obtain the first attention weight M t ;

[0069] Similarly, the second text P * The corresponding second text feature is converted into the second key value feature K * ; For the second current image Z * t Perform feature extraction to obtain a second current image feature; convert the second current image feature into a second query feature Q * ; For the second query feature Q * and the second key value feature K * Perform weight calculation to obtain the second attention weight M * t .

[0070] In this embodiment, by obtaining a first query feature based on the first current output content, converting the first input content into a first key-value feature, and obtaining a first attention weight based on the first query feature and the first key-value feature, the first input content information and the first current output content information can be referred to when calculating the first attention weight, thereby improving the accuracy of calculating the first attention weight and thereby improving the accuracy of content generation.

[0071] In this embodiment, by obtaining a second query feature based on the second current output content, converting the second input content into a second key-value feature, and obtaining a second attention weight based on the second query feature and the second key-value feature, the second input content information and the second current output content information can be referred to when calculating the second attention weight, thereby improving the accuracy of the second attention weight calculation and thereby improving the accuracy of content generation.

[0072] 306. The first attention weight M based on the current moment t and the second attention weight M at the current moment * t , get the target attention weight at the current moment

[0073] Among them, based on the content editing method of the first input content by the second input content, the first attention weight and the second attention weight can be weight-edited to obtain the target attention weight; wherein different content editing methods correspond to different weight editing processing methods.

[0074] In this embodiment, by performing different editing processing on the attention weight based on different content editing methods, the accuracy of the target attention weight can be improved and the content generation effect can be improved.

[0075] In some embodiments, the content editing method is content replacement;

[0076] The weight editing processing of the first attention weight and the second attention weight to obtain the target attention weight includes: taking the first attention weight or the second attention weight as the target attention weight.

[0077] In this embodiment, for the content replacement scenario, the first attention weight or the second attention weight is used as the target attention weight, which can achieve global editing and change the overall style to meet the needs of the content replacement scenario.

[0078] Furthermore, the target output content is generated after multiple iterations of the initial output content; using the first attention weight or the second attention weight as the target attention weight includes: in the first iteration stage, using the first attention weight as the target attention weight; in the second iteration stage, using the second attention weight as the target attention weight; wherein the second iteration stage is later than the first iteration stage.

[0079] For example, if the total number of iterations is 50, the first attention weight can be used as the target attention weight in the first 30 times, and the second attention weight can be used as the target attention weight in the last 20 times.

[0080] In this embodiment, by modifying the target attention weight from the first attention weight to the second attention weight in the later stage of iteration, content with overall style changes can be efficiently generated to improve the global editing effect.

[0081] In some embodiments, the content editing method is adding new content or adjusting the content level;

[0082] The weight editing processing of the first attention weight and the second attention weight to obtain the target attention weight includes: obtaining a first weight based on the first attention weight, obtaining a second weight based on the second attention weight; and, combining the first weight and the second weight into the target attention weight.

[0083] In this embodiment, for scenarios where new content is added or the degree of content is adjusted, the target attention weight is obtained based on the partial weight of the first attention weight and the partial weight of the second attention weight, so that local editing can be achieved while keeping the overall structure and appearance unchanged.

[0084] Further, if the content editing mode is content addition, the obtaining of a first weight based on the first attention weight and the obtaining of a second weight based on the second attention weight include:

[0085] Using the first attention weight as the first weight;

[0086] The weight corresponding to the newly added content in the second attention weight is used as the second weight.

[0087] In this embodiment, by using the weight corresponding to the newly added content as the second weight and using the first attention weight for the remaining weights, the overall structure and appearance of the original image can be kept unchanged when new content is added.

[0088] Further, if the content editing mode is content degree adjustment, the obtaining of a first weight based on the first attention weight and the obtaining of a second weight based on the second attention weight include:

[0089] The other weights outside the position to be adjusted in the first attention weight are used as the first weight; the second weight is obtained based on the adjustment coefficient and the weight at the position to be adjusted in the second attention weight; wherein the position to be adjusted is the position corresponding to the degree adjustment content.

[0090] In this embodiment, the second weight is obtained based on the adjustment coefficient and the weight at the position to be adjusted in the second attention weight, so that local editing of the image can be achieved.

[0091] Further, the obtaining of the second weight based on the adjustment coefficient and the weight at the position to be adjusted in the second attention weight includes: multiplying the adjustment coefficient by the weight at the position to be adjusted to obtain the second weight.

[0092] In this embodiment, local editing can be performed simply and efficiently by multiplying the adjustment coefficient and the above weight.

[0093] The attention weight editing processing corresponding to the above-mentioned various content editing methods is expressed by the formula:

[0094] (1) For content replacement: For example, if you want to replace "lemon" with "cheese", use the following editing formula:

[0095]

[0096] Among them, τ is an artificially set value.

[0097] The editing formula shows that in the later stage of iteration (when t is small), the target attention weight is selected as the second attention weight, and in the early stage of iteration, the target attention weight is selected as the first attention weight. This can achieve global editing.

[0098] (2) For newly added content: For example, if you want to change "lemon cake" to "lemon cheese cake", use the following editing formula:

[0099]

[0100] Among them, i and j are position coordinates, i corresponds to image features, j corresponds to text features, and A(j) indicates the text content corresponding to the weight.

[0101] The editing formula shows that: in the target attention weight, only the word content (token) corresponding to the original text (first text P) is empty, that is, the edited text (second text P * ) uses the weight of the corresponding position of the second attention weight, and the remaining weights remain the weights of the corresponding positions of the first attention weight. This ensures that the structure of the entire graph remains unchanged.

[0102] (3) Adjustment of the degree of content: For example, to adjust the degree of old in "a old man", use the following editing formula:

[0103]

[0104] Among them, j * It is the position corresponding to the content with adjusted degree (such as old).

[0105] c is the adjustment coefficient. When editing text, the user can specify the degree of a certain word, such as specifying old (c = 1.2), based on which the adjustment coefficient c = 1.2.

[0106] The editing formula shows that: in the target attention weight: the weight of the word with degree adjustment is calculated based on the adjustment coefficient and the weight of the corresponding position of the second attention weight, and the remaining weights remain the weight of the corresponding position of the first attention weight unchanged. This can achieve local editing.

[0107] 307. Get the target image Z at the current moment t-1 and Z * t-1 .

[0108] Among them, at the current time t, the target image includes: the first target image Z corresponding to P t-1 , and P * The corresponding second target image Z *t-1 .

[0109] Among them, Figure 4 As shown, the first text feature can also be converted into a first value feature V, and the second text feature can be converted into a second value feature V * , using the first attention weight M t And the first value feature V is generated to obtain the first target image Z t-1 ; Attention weight for target and the second value feature V * Perform generation processing to obtain the second target image Z * t-1 .

[0110] 308. Reduce the current number of iterations by 1 (t=t-1); then repeat 303 and subsequent steps.

[0111] 309. Obtain the final image Z after denoising 0 and Z * 0 .

[0112] Among them, Z * 0 is the final image corresponding to the edited text, that is, the final image after editing. 0 This is the final image corresponding to the text before editing.

[0113] In this embodiment, image editing can be achieved by editing the text, and there is no need to retrain the model. Therefore, it is a training-free method, which can reduce the workload and implementation complexity. Based on the text editing method, the attention weight can be edited accordingly to obtain the target attention weight. The editing of the target image can be controlled based on the target attention weight, which can change the overall style of the image, change the local elements of the image, change the descriptive weight ratio of the local objects in the image, and better maintain the general structure of the original image.

[0114] Figure 5 is a schematic diagram according to the third embodiment of the present disclosure. This embodiment provides a content generation device based on artificial intelligence, such as Figure 5 As shown, the device 500 includes: a first processing module 501, a second processing module 502, an editing module 503 and a generating module 504.

[0115] The first processing module 501 is used to perform attention processing on the first input content feature of the first input content to obtain a first attention weight; the second processing module 502 is used to perform attention processing on the second input content feature of the second input content to obtain a second attention weight; wherein, the second input content is obtained by editing the first input content; the editing module 503 is used to edit the first attention weight and the second attention weight to obtain a target attention weight; the generation module 504 is used to generate the target attention weight and the second input content feature to generate a target output content.

[0116] In this embodiment, the target output content is obtained based on the target attention weight and the second input content feature. There is no need to retrain the model as a whole, which can avoid problems such as large workload and complex implementation caused by retraining the model. In addition, by editing the first attention weight and the second attention weight to obtain the target attention weight, the editability of the attention weight can be achieved, thereby improving the generation effect of the target output content.

[0117] In some embodiments, the editing module 503 is further used to: perform weight editing processing on the first attention weight and the second attention weight based on the content editing method of the first input content by the second input content to obtain the target attention weight; wherein different content editing methods correspond to different weight editing processing methods.

[0118] In this embodiment, by performing different editing processing on the attention weight based on different content editing methods, the accuracy of the target attention weight can be improved and the content generation effect can be improved.

[0119] In some embodiments, the content editing method is content replacement; the editing module 503 is further used to: use the first attention weight or the second attention weight as the target attention weight.

[0120] In this embodiment, for the content replacement scenario, the first attention weight or the second attention weight is used as the target attention weight, which can achieve global editing and change the overall style to meet the needs of the content replacement scenario.

[0121] In some embodiments, the target output content is generated after multiple iterations of the initial output content; the editing module 503 is further used to: in a first iteration stage, use the first attention weight as the target attention weight; in a second iteration stage, use the second attention weight as the target attention weight; wherein the second iteration stage is later than the first iteration stage.

[0122] In this embodiment, by modifying the target attention weight from the first attention weight to the second attention weight in the later stage of iteration, content with overall style changes can be efficiently generated to improve the global editing effect.

[0123] In some embodiments, the content editing method is adding new content, or adjusting the degree of content; the editing module 503 is further used to: obtain a first weight based on the first attention weight, obtain a second weight based on the second attention weight; and, combine the first weight and the second weight into the target attention weight.

[0124] In this embodiment, for scenarios where new content is added or the degree of content is adjusted, the target attention weight is obtained based on the partial weight of the first attention weight and the partial weight of the second attention weight, so that local editing can be achieved while keeping the overall structure and appearance unchanged.

[0125] In some embodiments, if the content editing method is adding new content, the editing module 503 is further used to: use the first attention weight as the first weight; and use the weight corresponding to the newly added content in the second attention weight as the second weight.

[0126] In this embodiment, by using the weight corresponding to the newly added content as the second weight and using the first attention weight for the remaining weights, the overall structure and appearance of the original image can be kept unchanged when new content is added.

[0127] In some embodiments, if the content editing method is content degree adjustment, the editing module is further used to: use other weights outside the position to be adjusted in the first attention weight as the first weight; obtain the second weight based on the adjustment coefficient and the weight at the position to be adjusted in the second attention weight; wherein the position to be adjusted is the position corresponding to the degree adjustment content.

[0128] In this embodiment, the second weight is obtained based on the adjustment coefficient and the weight at the position to be adjusted in the second attention weight, so that local editing of the image can be achieved.

[0129] In some embodiments, the editing module 503 is further used to: multiply the adjustment coefficient by the weight at the position to be adjusted to obtain the second weight.

[0130] In this embodiment, local editing can be performed simply and efficiently by multiplying the adjustment coefficient and the above weight.

[0131] In some embodiments, the first processing module 501 is further used to: convert the first input content feature into a first key-value feature; perform feature extraction on the first current output content to obtain the first current output content feature; convert the first current output content feature into a first query feature; perform weight operation on the first query feature and the first key-value feature to obtain the first attention weight.

[0132] In this embodiment, by obtaining a first query feature based on the first current output content, converting the first input content into a first key-value feature, and obtaining a first attention weight based on the first query feature and the first key-value feature, the first input content information and the first current output content information can be referred to when calculating the first attention weight, thereby improving the accuracy of calculating the first attention weight and thereby improving the accuracy of content generation.

[0133] In some embodiments, the second processing module 502 is further used to: convert the second input content feature into a second key value feature; perform feature extraction on the second current output content to obtain a second current output content feature; perform query feature extraction on the second initial output content feature to obtain a second query feature; perform weight operation on the second query feature and the second key value feature to obtain the second attention weight.

[0134] In this embodiment, by obtaining a second query feature based on the second current output content, converting the second input content into a second key-value feature, and obtaining a second attention weight based on the second query feature and the second key-value feature, the second input content information and the second current output content information can be referred to when calculating the second attention weight, thereby improving the accuracy of the second attention weight calculation and thereby improving the accuracy of content generation.

[0135] It can be understood that in the embodiments of the present disclosure, the same or similar contents in different embodiments can be referenced to each other.

[0136] It can be understood that the “first”, “second”, etc. in the embodiments of the present disclosure are only used for distinction and do not indicate the degree of importance, time sequence, etc.

[0137] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0138] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.

[0139] Figure 6A schematic block diagram of an example electronic device 600 that can be used to implement an embodiment of the present disclosure is shown. The electronic device 600 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0140] like Figure 6 As shown, the electronic device 600 includes a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 602 or a computer program loaded from a storage unit 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 can also be stored. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0141] Multiple components in the electronic device 600 are connected to the I / O interface 605, including: an input unit 606, such as a keyboard, a mouse, etc.; an output unit 607, such as various types of displays, speakers, etc.; a storage unit 608, such as a disk, an optical disk, etc.; and a communication unit 609, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 609 allows the electronic device 600 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0142] The computing unit 601 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 601 performs the various methods and processes described above, such as a content generation method based on artificial intelligence. For example, in some embodiments, the content generation method based on artificial intelligence may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 600 via the ROM 602 and / or the communication unit 609. When the computer program is loaded into the RAM 603 and executed by the computing unit 601, one or more steps of the content generation method based on artificial intelligence described above may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform a content generation method based on artificial intelligence in any other appropriate manner (e.g., by means of firmware).

[0143] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0144] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0145] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0146] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0147] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0148] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server may also be a server of a distributed system, or a server combined with a blockchain.

[0149] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0150] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A content generation method based on artificial intelligence, comprising: Performing attention processing on a first input content feature of the first input content to obtain a first attention weight; Performing attention processing on a second input content feature of a second input content to obtain a second attention weight; wherein the second input content is obtained by editing the first input content; Based on the content editing method of the second input content on the first input content, weight editing processing is performed on the first attention weight and the second attention weight to obtain a target attention weight; wherein different content editing methods correspond to different weight editing processing methods; Generate the target attention weight and the second input content feature to generate target output content; The first input content and the second input content are both texts, and the target output content is an image, a video or text.

2. The method according to claim 1, wherein: The content editing method is content replacement; The performing weight editing processing on the first attention weight and the second attention weight to obtain the target attention weight includes: The first attention weight or the second attention weight is used as the target attention weight.

3. The method according to claim 2, wherein: The target output content is generated after multiple iterations of the initial output content; The taking the first attention weight or the second attention weight as the target attention weight includes: In a first iteration stage, taking the first attention weight as the target attention weight; In a second iteration phase, the second attention weight is used as the target attention weight; The second iteration phase is later than the first iteration phase.

4. The method according to claim 1, wherein: The content editing method is to add new content or adjust the content level; The performing weight editing processing on the first attention weight and the second attention weight to obtain the target attention weight includes: Acquire a first weight based on the first attention weight, and acquire a second weight based on the second attention weight; as well as, The first weight and the second weight are combined into the target attention weight.

5. The method according to claim 4, wherein: If the content editing mode is content addition, the obtaining of a first weight based on the first attention weight and the obtaining of a second weight based on the second attention weight include: Using the first attention weight as the first weight; The weight corresponding to the newly added content in the second attention weight is used as the second weight.

6. The method according to claim 4, wherein: If the content editing mode is content level adjustment, obtaining a first weight based on the first attention weight, and obtaining a second weight based on the second attention weight, includes: Using other weights of the first attention weights other than the position to be adjusted as the first weights; Acquire the second weight based on the adjustment coefficient and the weight at the to-be-adjusted position in the second attention weight; The position to be adjusted is a position corresponding to the degree adjustment content.

7. The method according to claim 6, wherein: The obtaining the second weight based on the adjustment coefficient and the weight at the to-be-adjusted position in the second attention weight comprises: The adjustment coefficient is multiplied by the weight at the position to be adjusted to obtain the second weight.

8. The method according to any one of claims 1 to 7, wherein: The performing attention processing on the first input content feature of the first input content to obtain a first attention weight includes: Converting the first input content feature into a first key-value feature; Performing feature extraction on the first current output content to obtain a first current output content feature; converting the first current output content feature into a first query feature; A weight operation is performed on the first query feature and the first key value feature to obtain the first attention weight.

9. The method according to any one of claims 1 to 7, wherein: The performing attention processing on the second input content feature of the second input content to obtain a second attention weight includes: Converting the second input content feature into a second key-value feature; Performing feature extraction on the second current output content to obtain a second current output content feature; performing query feature extraction on the second current output content feature to obtain a second query feature; A weight operation is performed on the second query feature and the second key value feature to obtain the second attention weight.

10. A content generation device based on artificial intelligence, comprising: A first processing module, configured to perform attention processing on a first input content feature of the first input content to obtain a first attention weight; A second processing module is used to perform attention processing on a second input content feature of a second input content to obtain a second attention weight; wherein the second input content is obtained by editing the first input content; An editing module, configured to perform weight editing processing on the first attention weight and the second attention weight based on a content editing method of the first input content by the second input content, so as to obtain a target attention weight; wherein different content editing methods correspond to different weight editing processing methods; A generation module, used for performing generation processing on the target attention weight and the second input content feature to generate target output content; The first input content and the second input content are both texts, and the target output content is an image, a video or text.

11. The device according to claim 10, wherein: The content editing method is content replacement; The editing module is further used for: The first attention weight or the second attention weight is used as the target attention weight.

12. The device according to claim 11, wherein The target output content is generated after multiple iterations of the initial output content; The editing module is further used for: In a first iteration stage, taking the first attention weight as the target attention weight; In a second iteration phase, the second attention weight is used as the target attention weight; The second iteration phase is later than the first iteration phase.

13. The device according to claim 10, wherein: The content editing method is to add new content or adjust the content level; The editing module is further used for: Acquire a first weight based on the first attention weight, acquire a second weight based on the second attention weight; and, The first weight and the second weight are combined into the target attention weight.

14. The device according to claim 13, wherein: If the content editing mode is content addition, the editing module is further used to: Using the first attention weight as the first weight; The weight corresponding to the newly added content in the second attention weight is used as the second weight.

15. The device according to claim 13, wherein: If the content editing mode is content level adjustment, the editing module is further used to: Using other weights of the first attention weights other than the position to be adjusted as the first weights; Acquire the second weight based on the adjustment coefficient and the weight at the to-be-adjusted position in the second attention weight; The position to be adjusted is a position corresponding to the degree adjustment content.

16. The device according to claim 15, wherein: The editing module is further used for: The adjustment coefficient is multiplied by the weight at the position to be adjusted to obtain the second weight.

17. The device according to any one of claims 10 to 16, wherein: The first processing module is further configured to: Converting the first input content feature into a first key-value feature; Performing feature extraction on the first current output content to obtain a first current output content feature; converting the first current output content feature into a first query feature; A weight operation is performed on the first query feature and the first key value feature to obtain the first attention weight.

18. The device according to any one of claims 10 to 16, wherein: The second processing module is further used for: Converting the second input content feature into a second key-value feature; Performing feature extraction on the second current output content to obtain second current output content features; Performing query feature extraction on the second current output content feature to obtain a second query feature; A weight operation is performed on the second query feature and the second key value feature to obtain the second attention weight.

19. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 9.

20. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-9.

21. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Machine translation method and device, equipment and storage medium

    CN114936566A

  • Query statement generation method and device, model training method, equipment and medium

    CN115238143A