Powerpoint generation method and device, computer equipment and storage medium
By generating presentations based on predefined prompt word templates and large models, the problem of inefficient presentations production in the prior art is solved, and a high-quality presentation is generated quickly and efficiently.
Patent Information
- Application Number
- CN202411467286.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-21
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2044-10-21
AI Technical Summary
In the prior art, users need to manually produce presentations, prepare a large amount of text and images for topics in different fields, and design and type, resulting in low production efficiency.
By obtaining the subject information of the document, the outline directory and content text are generated based on the predefined prompt word template, and the preloaded large model call is used to generate a presentation. Combined with the parsing result file of the target document template, the matching relationship between the target text and the template elements is determined, and the presentation containing the target text is generated.
It significantly improves the production efficiency of presentations, reduces the time for manual design and layout, and improves the accuracy and quality of generated presentations.
Smart Images

Figure CN119598982A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a presentation generation method, apparatus, computer equipment, storage medium and computer program product. Background Art
[0002] Currently, office software has become popular and users can edit presentations on specific topics through terminals.
[0003] However, for topics in different fields, users can only manually make presentations, prepare a large amount of text and images for topics in different fields, and design and layout the content of the text and images to obtain presentations of different topics. However, this method of making presentations takes a lot of time and has low efficiency. Summary of the invention
[0004] Based on this, it is necessary to provide a presentation generation method, device, computer equipment, computer-readable storage medium and computer program product that can improve the efficiency of presentation production in response to the above technical problems.
[0005] In a first aspect, the present application provides a method for generating a presentation. The method comprises:
[0006] When the manuscript subject information is obtained, a first prompt word corresponding to the manuscript subject information is generated based on a predefined first prompt word template, and a preloaded large model is called based on the first prompt word to generate an outline directory corresponding to the manuscript subject information; the outline directory includes at least two levels of directories;
[0007] For each subdirectory in the outline directory, a second prompt word corresponding to each subdirectory is generated based on a predefined second prompt word template, and the large model is called based on the second prompt word to generate a content text corresponding to each subdirectory; the subdirectory is the last level directory of the at least two levels of directories, and the second prompt word template is different from the first prompt word template;
[0008] When a target text including the outline directory and the content texts corresponding to each of the subdirectories is obtained, the elements included in the target document template and the association information between the elements are obtained based on the parsing result file of the target document template; based on the elements and the association information between the elements, the matching relationship between the target text and the elements is obtained, and a presentation including the target text is generated based on the matching relationship.
[0009] In one embodiment, the element includes a text placeholder and an image placeholder; and generating a presentation containing the target text based on the matching relationship includes:
[0010] For the text placeholder in the target document template, determine a first text in the target text corresponding to the text placeholder according to the matching relationship, and replace the text placeholder with the first text;
[0011] For the image placeholder in the target document template, based on the association information between the elements, determine the target text placeholder associated with the image placeholder, and determine the second text corresponding to the target text placeholder according to the matching relationship;
[0012] generating a third prompt word corresponding to the second text based on a predefined third prompt word template, calling the large model based on the third prompt word, determining a text entity corresponding to the second text, and obtaining a corresponding text feature vector from the text entity; the third prompt word template is different from any one of the first prompt word template and the second prompt word template;
[0013] Determine a target image vector matching the text feature vector from a pre-built image vector database, and replace the image placeholder with an image corresponding to the target image vector; the image vector database stores image feature vectors corresponding to a plurality of preset images;
[0014] After the text placeholder and the image placeholder in the target document template are replaced, a presentation document containing the target text is obtained.
[0015] In one embodiment, the method further comprises:
[0016] Traversing a plurality of images pre-saved in an image library, calling the large model to determine an image feature vector corresponding to each of the images;
[0017] A correspondence between storage addresses of multiple images and image feature vectors corresponding to each of the images is established, and the image feature vectors corresponding to the images and the correspondence are stored in a pre-constructed image vector database.
[0018] In one embodiment, determining a target image vector matching the text feature vector from a pre-built image vector database comprises:
[0019] Determining the vector distance between each of the image feature vectors and the text feature vector in the image vector database;
[0020] Determining a predetermined number of image feature vectors as target image vectors matching the text feature vectors according to the order of the vector distances from small to large;
[0021] The replacing the image placeholder with the image corresponding to the target image vector comprises:
[0022] The images corresponding to the predetermined number of image feature vectors are determined as candidate images, and an image is randomly determined from the candidate images as a target image, and the image placeholder is replaced.
[0023] In one embodiment, replacing the image placeholder with the image corresponding to the target image vector comprises:
[0024] The target image is adjusted according to the size information of the image placeholder and the size information of the target image, and the image placeholder is replaced with the adjusted target image.
[0025] In one embodiment, the method further comprises:
[0026] Parsing each page contained in the target document template to obtain elements in the page and element attributes of each element; the element attributes include level information and position information;
[0027] Determine association information between the elements based on the level information and the position information;
[0028] According to the order of each of the pages in the target document template, the elements, the element attributes of the elements and the associated information in each page included in the target document template are stored as a JSON file as a parsing result file of the target document template.
[0029] In one embodiment, obtaining the matching relationship between the target text and the element based on the element and the association information between the elements includes:
[0030] Based on the JSON file, obtain the elements in the target document template and the association relationship between the elements as the first association information;
[0031] Based on the hierarchical relationship of the directories in the outline directory and the corresponding relationship between each subdirectory and the content text, a second association relationship of the text in the target text is obtained;
[0032] A matching relationship between the target text and the element is determined according to the first association relationship and the second association relationship.
[0033] In a second aspect, the present application also provides a presentation document generation device. The device comprises:
[0034] An outline generation module is used to generate a first prompt word corresponding to the manuscript subject information based on a predefined first prompt word template when the manuscript subject information is acquired, and to call a preloaded large model based on the first prompt word to generate an outline directory corresponding to the manuscript subject information; the outline directory includes at least two levels of directories;
[0035] a content generation module, configured to generate, for each subdirectory in the outline directory, a second prompt word corresponding to each subdirectory based on a predefined second prompt word template, and call the main model based on the second prompt word to generate a content text corresponding to each subdirectory; the subdirectory is the last level directory of the at least two levels of directories, and the second prompt word template is different from the first prompt word template;
[0036] A document generation module is used to obtain the target text containing the outline directory and the content text corresponding to each sub-directory, and then obtain the elements contained in the target document template and the association information between the elements based on the parsing result file of the target document template; based on the elements and the association information between the elements, obtain the matching relationship between the target text and the elements, and generate a presentation containing the target text based on the matching relationship.
[0037] In a third aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the method described in the first aspect are implemented.
[0038] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the method described in the first aspect are implemented.
[0039] In a fifth aspect, the present application further provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the method described in the first aspect are implemented.
[0040] The above-mentioned presentation generation method, device, computer equipment, storage medium and computer program product, when obtaining the subject information of the manuscript, generates the first prompt word corresponding to the subject information of the manuscript through the predefined first prompt word template, so that the preloaded large model generates the outline directory corresponding to the subject information of the manuscript according to the first prompt word. The outline directory can contain multiple levels of directories, wherein the last level of directory is a subdirectory. For each subdirectory in the outline directory, the second prompt word corresponding to the subdirectory can be generated based on the predefined second prompt word template, so that the preloaded large model generates the content text corresponding to each subdirectory according to the second prompt word, thereby obtaining the outline directory corresponding to the subject information of the manuscript and the multi-level text composed of the content text corresponding to each subdirectory, that is, obtaining the target text. Furthermore, based on the parsing result file of the target manuscript template, the association information between each element and the elements in the target manuscript template can be obtained, and the matching relationship between the target text and each element in the target manuscript template can be obtained according to the association information and the internal connection of the multi-level text, and the presentation containing the target text can be generated through the matching relationship. The predefined first prompt word template and the second prompt word template can generate corresponding first prompt words and second prompt words for the document theme and each sub-directory respectively, and call the big model to generate corresponding content based on different prompt words, thereby improving the standardization and accuracy of the content text of the outline directory and sub-directory generated by the big model. In addition, since the complete target text generated by the big model is a multi-level text, the matching relationship between the target text and the elements in the target document template can be determined by obtaining the association information between the elements in the target document template, so that the target text can be accurately applied to the target document template, and then the presentation corresponding to the document theme information can be obtained, thereby improving the efficiency of presentation production. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0042] Figure 1 A diagram of an application environment of a method for generating a presentation in an embodiment;
[0043] Figure 2 A schematic diagram of a flow chart of a method for generating a presentation in one embodiment;
[0044] Figure 3 A schematic diagram of a flow chart of steps for generating a presentation based on a matching relationship in one embodiment;
[0045] Figure 4A schematic diagram of a flow chart of a method for generating a presentation in another embodiment;
[0046] Figure 5 is a schematic diagram of a presentation in one embodiment;
[0047] Figure 6 is a structural block diagram of a presentation document generating device in one embodiment;
[0048] Figure 7 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0050] The presentation generation method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown, the terminal 102 communicates with the server 104 through a network. The data storage system can store data that the server 104 needs to process. The data storage system can be integrated on the server 104, or placed on the cloud or other network servers.
[0051] Among them, the terminal 102 can receive the document subject information input or selected by the user, and the server 104 can receive the document subject information sent by the terminal 102, perform entity recognition on the received information, and determine the document subject information. Further, the server 104 can call the first prompt word template to generate the first prompt word corresponding to the document subject information, and input the first prompt word into the preloaded large model to obtain the outline directory corresponding to the document subject information. For each subdirectory in the outline directory, the server 104 can also call the second prompt word template to generate the second prompt word corresponding to the subdirectory, and input the second prompt word into the preloaded large model to obtain the content text corresponding to the subdirectory, thereby obtaining a complete target text including the outline directory and the content text corresponding to each subdirectory. Furthermore, the server 104 obtains the parsing result file corresponding to the determined target document template, and obtains the association information between each element and the elements in the target document template according to the parsing result file. Since the complete target text generated by the large model belongs to the multi-level text, the matching relationship between the target text and the elements in the target document template can be determined. Finally, based on the matching relationship, the target text is added to the target document template to obtain a presentation corresponding to the document theme information. Afterwards, the server 104 can also send the obtained presentation to the terminal 102 for display.
[0052] In addition, if the computing power of terminal 102 supports it, the terminal can also pre-load the large model locally and generate the above-mentioned presentation locally on terminal 102.
[0053] The terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, IoT devices, and portable wearable devices. The IoT devices may be smart TVs, smart car devices, etc. The portable wearable devices may be head-mounted devices, etc. The head-mounted devices may be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. The server 104 may be implemented by an independent server or a server cluster consisting of multiple servers.
[0054] In an exemplary embodiment, Figure 2 As shown, a presentation generation method is provided, which is applied to Figure 1 The server 104 in the example is used as an example to illustrate the method, which includes the following steps S202 to S206. Among them:
[0055] Step S202, when the document subject information is obtained, a first prompt word corresponding to the document subject information is generated based on a predefined first prompt word template, and a preloaded large model is called based on the first prompt word to generate an outline directory corresponding to the document subject information.
[0056] The above outline directory includes at least two levels of directories, wherein the last level of directory is also called a subdirectory. The manuscript subject information can be a subject selected by the user from preset subjects through the terminal, or a subject input. The first prompt word template is used to generate a first prompt word according to the manuscript subject information, and the first prompt word is used to generate an outline directory corresponding to the manuscript subject information.
[0057] Specifically, the server receives document subject information input by the user terminal through a guide message, and the server can perform entity recognition on the document subject information to obtain multiple entities corresponding to the document subject information. The server inputs the entity corresponding to the document subject information into a predefined first prompt word template, so that the entity corresponding to the document subject information replaces the entity placeholder in the first prompt word template, thereby generating a first prompt word corresponding to the document subject information.
[0058] The server can take the first prompt word as input and input it into the preloaded large model. The large model outputs an outline directory corresponding to the document subject information according to the content of the first prompt word. The outline directory can be a directory of a multi-level directory combination corresponding to the document subject. For example, the outline directory can include multiple levels such as a primary directory, a secondary directory, and a tertiary directory. The primary directory and the secondary directory can be a one-to-one or one-to-many relationship. The directories at the same level can be in parallel or in a logical sequence. The last level target is a subdirectory. For example, in the case of including primary, secondary, and tertiary directories, the third-level directory is a subdirectory. Similarly, the outline directory can also contain more levels of subdirectories, which is not limited in the embodiments of the present application.
[0059] In one example, the entity of the manuscript subject information may include the manuscript subject, the number of manuscript pages, and the manuscript format. The first prompt word template is a slide outline prompt word template, for example, "You are now a PPT (PowerPoint) outline generation expert. Generate a PPT outline with 'manuscript subject' as the theme. The output language is required to be Chinese. The generated outline directory has 'N' levels. The output is strictly in accordance with the 'manuscript format' format, and no other irrelevant information is output." The server can use the manuscript subject, directory level, and manuscript format to replace the entity placeholder in the slide outline prompt word, thereby obtaining the slide outline prompt word of the manuscript subject information.
[0060] Step S204, for each sub-directory in the outline directory, generate a second prompt word corresponding to each sub-directory based on a predefined second prompt word template, and call the large model based on the second prompt word to generate a content text corresponding to each sub-directory.
[0061] Among them, the above-mentioned sub-directory is the last level directory in the above-mentioned at least two levels of directories, and the above-mentioned second prompt word template is different from the above-mentioned first prompt word template; the second prompt word template is used to generate corresponding second prompt words according to each sub-directory of the outline directory, and the second prompt word is used to generate the content text corresponding to the sub-directory.
[0062] Specifically, the server splits the outline directory to obtain multiple sub-directories. The server traverses each sub-directory in the outline directory, and generates a second prompt word corresponding to the sub-directory by inputting the sub-directory into a predefined second prompt word template so that the entity corresponding to the sub-directory replaces the entity placeholder in the second prompt word template. The server can use the second prompt word as input to the preloaded large model, and the large model outputs the content text corresponding to the sub-directory according to the content of the second prompt word. For example, the sub-directories can be motors, electronic controls, and batteries, and the content text corresponding to the sub-directories can be detailed introduction texts of motors, electronic controls, and batteries.
[0063] In one example, the entities of the subdirectory include subdirectories, text word counts, etc. The second prompt word template is a slide content prompt word template, for example, "You are now an expert in PPT content generation. Generate PPT content with 'subdirectory' as the theme extension. The output language is required to be Chinese. The output content should be as concise and written as possible. The output word count is required to not exceed 'text word count', and no other irrelevant information should be output." The server can use the corresponding subdirectory and text word count to replace the entity placeholder in the slide content prompt word template to obtain the slide content prompt word of the subdirectory. If the entity of the subdirectory has not been assigned a value, the preset entity can be used as the default entity, and the default entity can be used to replace the entity placeholder in the slide content prompt word.
[0064] Step S206, when the target text including the above outline directory and the content text corresponding to each of the above sub-directories is obtained, based on the parsing result file of the target document template, the elements included in the above target document template and the association information between the above elements are obtained; based on the above elements and the association information between the elements, the matching relationship between the above target text and the above elements is obtained, and a presentation including the above target text is generated based on the above matching relationship.
[0065] The parsing result file is a file parsed from the document templates of various styles stored in the database. The parsing result file contains all elements, element attributes, and association information between elements in the document template. The association information is used to indicate the hierarchical relationship, positional relationship, and other relationship information between each element in the document template and its related elements. The matching relationship is used to indicate the correspondence between the content texts of each directory and each subdirectory in the target text and each element in the target document template.
[0066] Specifically, the server can obtain the complete target text corresponding to the theme based on the sub-directories contained in the outline directory and the content texts corresponding to the sub-directories. The target text contains directory information and sub-directory content texts, so the target text is a text with a multi-level relationship. Based on the parsing result file corresponding to the target document template, the server can obtain the association information between the elements in the template and the elements, and then map the directories at all levels and the content texts in the target text with the elements in the parsing result file, so as to obtain the matching relationship between the text information in the target text and the elements in the template. Furthermore, the server can apply the target text to the target document template based on the matching relationship, and generate a presentation with the document theme information as the theme, the outline directory as the framework, the content texts corresponding to the sub-directories as the content, and the target document template as the style.
[0067] In one example, the server can replace the elements of each page of the target document template with corresponding texts according to the matching relationship between the target text and the elements in the template, and generate the document template for that page. The server merges multiple pages of documents to obtain a presentation document.
[0068] Optionally, if the number of elements in each page of the target document template does not match the number of texts in the target text in the process of generating a presentation document containing the target text through a matching relationship, the elements in the above target document template can be adjusted to obtain an adjusted target document template; the adjustment process includes at least one of adding elements, deleting elements, and adjusting the spacing between elements. For example, if the number of elements in a page in the template is greater than the number of entries in the text that matches it, the server can delete the redundant elements in the page, and adjust the position information of the remaining elements according to the style of the target document template so that the element spacing meets the style. If the number of elements in a page in the template is less than the number of entries in the text that matches it, the server can add elements to the page and adjust the position information of all elements according to the style of the target document template.
[0069] In the above-mentioned presentation generation method, when the document subject information is obtained, the first prompt word corresponding to the document subject information is generated by the predefined first prompt word template, so that the preloaded large model generates an outline directory corresponding to the document subject information according to the first prompt word. The outline directory can contain multiple levels of directories, wherein the last level of directory is a subdirectory. For each subdirectory in the outline directory, the second prompt word corresponding to the subdirectory can be generated based on the predefined second prompt word template, so that the preloaded large model generates the content text corresponding to each subdirectory according to the second prompt word, thereby obtaining the outline directory corresponding to the document subject information and the content text corresponding to each subdirectory, i.e., obtaining the target text. Furthermore, based on the parsing result file of the target document template, the association information between each element and the elements in the target document template can be obtained, and the matching relationship between the target text and each element in the target document template can be obtained according to the association information and the internal connection of the multi-level text, and the presentation containing the target text can be generated through the matching relationship. The predefined first prompt word template and the second prompt word template can generate corresponding first prompt words and second prompt words for the document theme and each sub-directory respectively, and call the big model to generate corresponding content based on different prompt words, thereby improving the standardization and accuracy of the content text of the outline directory and sub-directory generated by the big model. In addition, since the complete target text generated by the big model is a multi-level text, the matching relationship between the target text and the elements in the target document template can be determined by obtaining the association information between the elements in the target document template, so that the target text can be accurately applied to the target document template, and then the presentation corresponding to the document theme information can be obtained, thereby improving the efficiency of presentation production.
[0070] In an exemplary embodiment, Figure 3 As shown, the elements include text placeholders and image placeholders, and the specific implementation process of the step "generating a presentation containing the target text based on the matching relationship" includes steps S302 to S310. Among them:
[0071] Step S302, for the text placeholder in the target document template, determine the first text in the target text corresponding to the text placeholder according to the matching relationship, and replace the text placeholder with the first text.
[0072] Specifically, the server traverses the elements in the target document template. If the current element is a text placeholder, the server can determine the first text corresponding to the text placeholder in the target text based on the matching relationship. In one example, the target document template contains three text placeholders, namely, placeholder A, placeholder B, and placeholder C, and the target text contains three texts, namely, content text 1, directory text 2, and content text 3. The server can determine that the first text corresponding to placeholder A is content text 1, the first text corresponding to placeholder B is directory text 2, and the first text corresponding to placeholder C is content text 3 through the matching relationship. The server inputs content text 1 into placeholder A and updates the text of placeholder A, thereby completing the replacement of the text placeholder with the first text. Similarly, the server can input directory text 2 into placeholder B and update the text of placeholder B, and the server can input content text 3 into placeholder C and update the text of placeholder C.
[0073] It should be understood that replacing the text placeholder will only change the text in the target document template, and will not change the layout and style of other elements in the target document template.
[0074] Step S304, for the image placeholder in the target document template, based on the association information between the elements, determine the target text placeholder associated with the image placeholder, and determine the second text corresponding to the target text placeholder according to the matching relationship.
[0075] Specifically, the server traverses the elements in the target document template. If the current element is an image placeholder, the server can determine the target text placeholder associated with the image placeholder based on the association information between the elements. And, based on the matching relationship, the second text corresponding to the target text placeholder is determined in the target text. The image corresponding to the image placeholder is an image related to the second text corresponding to the target text placeholder.
[0076] In one example, the target document template further includes an image placeholder D, and the image placeholder D is associated with the text placeholder A. The server can determine that the placeholder A is the target text placeholder through the association information. The server can determine that the content text corresponding to the placeholder A is the second text corresponding to the target text placeholder through the matching relationship.
[0077] Step S306, generating a third prompt word corresponding to the second text based on a predefined third prompt word template, calling the large model based on the third prompt word, determining a text entity corresponding to the second text, and obtaining a corresponding text feature vector from the text entity.
[0078] The third prompt word template is different from any one of the first prompt word template and the second prompt word template. The third prompt word is used to enable the preloaded large model to perform entity recognition on the second text contained in the third prompt word to obtain at least one text entity corresponding to the second text.
[0079] Specifically, the server can input the second text into the third prompt word template to obtain a third prompt word containing the second text. The server uses the third prompt word as input and inputs it into the preloaded large model. The preloaded large model analyzes and processes the third prompt word and outputs at least one text entity contained in the second text. The server can generate a text feature vector corresponding to the text entity through a natural language processing model. The natural language processing model can be a large model, a bag of words model, a TF-IDF (Term Frequency-Inverse Document Frequency) model, a Word2Vec model, and the like.
[0080] In one example, the second text may be "The key technology for new energy vehicles is to develop an efficient and safe new type of automotive power battery system", and the third prompt word template is an entity extraction prompt word template, for example, "Please extract the entities of the following text content, which should be as concise as possible and no other related content should be output. The following text includes: 'second text'". The server can use the second text to replace the placeholder in the entity extraction prompt word template to obtain the entity extraction prompt word of the second text. The server performs entity recognition on the second text through the preloaded large model, and the recognition results obtained may be "new energy vehicles" and "power batteries".
[0081] Step S308: Determine a target image vector that matches the text feature vector from a pre-constructed image vector database, and replace the image placeholder with the image corresponding to the target image vector.
[0082] The image vector database stores image feature vectors corresponding to a plurality of preset images.
[0083] Specifically, the server traverses at least one text feature vector corresponding to the second text, searches in a pre-constructed image vector database, and determines that the image vector most similar to the text feature vector is the target image vector. The server obtains the image corresponding to the target image vector, and updates the image to the image placeholder, so that the image is displayed at the corresponding position of the image placeholder in the target document template.
[0084] Step S310, after the text placeholder and the image placeholder in the target document template are replaced, a presentation document including the target text is obtained.
[0085] Specifically, the server may replace the text placeholders and image placeholders in the target document template by traversing the elements, thereby obtaining an updated target document template and determining it as a presentation document containing the target text.
[0086] In this embodiment, the text placeholder is replaced by the first text corresponding to the text placeholder, and the image placeholder is replaced by the image of the target image vector corresponding to the image placeholder, thereby completing the update of the text placeholder and the image placeholder in the target document template to obtain a presentation. Without changing the style of the target document template, the target text and the image corresponding to the target text can be replaced, thereby updating the target document template and improving the accuracy and efficiency of the generated presentation.
[0087] In an exemplary embodiment, the method further includes: traversing multiple images pre-saved in an image library, calling the large model to determine the image feature vector corresponding to each of the images; establishing a correspondence between the storage addresses of multiple images and the image feature vectors corresponding to each of the images, and storing the image feature vectors corresponding to the images and the correspondence in a pre-constructed image vector database.
[0088] The image library may store pre-saved images of various types, and each image type may contain multiple images.
[0089] Specifically, the server can traverse the image library, and for each image, the image feature vector of the image can be generated through a preloaded large model. The image feature vector and the text feature vector should be calculated by the same large model or the same type of algorithm. The server can establish a correspondence between the storage address of each image and the image feature vector, and store the image feature vector and the correspondence in a pre-built image vector database. In one example, the server can create a correspondence table, and store the correspondence between the storage address of each image and the image feature vector in the correspondence table. The server stores the correspondence table in the image vector database.
[0090] Optionally, the server can generate the image feature vector feature of the image through a preloaded large model, and normalize the image feature vector through a preset normalization strategy, for example, the normalization formula is feature / ||feature||2. The server can create a vector database index of a preset vector dimension through faiss vector data. The server adds each image feature vector to the vector database index. Finally, the server calls the storage function, saves the vector database index to a preset storage path, and obtains the image vector database. The server can read the image vector database through the preset storage path, and retrieve each image feature vector through the established vector database index.
[0091] In this embodiment, the image feature vector of each image and the correspondence between the storage address of the image and the image feature vector are determined by traversing the image library, and image vector data is established to improve the efficiency of determining the target image vector when the image corresponding to the text feature vector is subsequently determined.
[0092] In an exemplary embodiment, the specific implementation process of the step of "determining a target image vector matching the above text feature vector from a pre-built image vector database" includes:
[0093] The vector distances between each of the above-mentioned image feature vectors and the above-mentioned text feature vectors are determined in the above-mentioned image vector database; and a predetermined number of image feature vectors are determined as target image vectors matching the above-mentioned text feature vectors in order of the distances between the above-mentioned vectors from small to large.
[0094] Specifically, for the text feature vector corresponding to each text entity, the server calculates the Euclidean distance value between the text feature vector and each image feature vector in the image vector database, and obtains multiple Euclidean distance values. The image feature vectors are sorted in ascending order according to the Euclidean distance values, and a preset number of image feature vectors are selected from the sorted multiple image feature vectors as target image vectors that match the text feature vector.
[0095] In an exemplary embodiment, before the step of "replacing the above-mentioned image placeholder with the image corresponding to the above-mentioned target image vector", the above-mentioned method also includes: determining that the images corresponding to the above-mentioned predetermined number of image feature vectors are candidate images, and randomly determining an image from the above-mentioned candidate images as the target image, and replacing the above-mentioned image placeholder.
[0096] Specifically, the server obtains the number of images corresponding to the image placeholder, obtains images corresponding to each target image vector, determines them as candidate images, and randomly selects at least one image corresponding to the number of images from the candidate images as the target image. In one example, if the number of images corresponding to the image placeholder is 1, the server can randomly select one image from the candidate images as the target image.
[0097] In this embodiment, the correlation between the text feature vector and the image feature vector is determined by the Euclidean distance value, and the image feature vector with the highest correlation is selected as the target image vector, and the image corresponding to the target image vector is determined as the target image, thereby determining the target image, which can improve the image of the adapted image placeholder and improve the adaptability of the target image.
[0098] In an exemplary embodiment, the specific implementation process of the step of "replacing the image placeholder with the image corresponding to the target image vector" includes:
[0099] The target image is adjusted according to the size information of the image placeholder and the size information of the target image, and the image placeholder is replaced with the adjusted target image.
[0100] Specifically, the server may obtain the size information of the image placeholder and the size information of the target image. The server adjusts the length, width, and aspect ratio of the target image based on the size information of the image placeholder so that the size information of the target image matches the size information of the image placeholder, and obtains the adjusted target image. The server replaces the image placeholder with the adjusted target image.
[0101] In one example, if the aspect ratio corresponding to the image placeholder is the same as the aspect ratio of the target image, the target image is scaled proportionally so that the length and width of the target image are the same as the length and width of the image placeholder. If the aspect ratio corresponding to the image placeholder is different from the aspect ratio of the target image, the target image is scaled proportionally so that one of the length or width of the target image is the same as the length or width of the image placeholder, thereby obtaining an adjusted target image.
[0102] In this embodiment, the size of the target image is adjusted according to the size information of the image placeholder to improve the adaptability of the target image in the presentation.
[0103] In an exemplary embodiment, the method further includes: parsing each page contained in the target document template to obtain the elements in the page and the element attributes of each of the elements; determining the association information between the elements based on the hierarchical information and position information; and storing the elements, the element attributes of the elements and the association information in each page contained in the target document template as a JSON file according to the order of the pages in the target document template as the parsing result file of the target document template.
[0104] The above-mentioned element attributes include hierarchical information and position information. Hierarchical information is used to indicate the hierarchical relationship between elements, and position information can be the coordinates of the elements on the page. Association information can include the order of elements, hierarchical information between elements, and text-image association information.
[0105] Specifically, the server can parse each page of the target document template in advance, obtain the elements in each page, and the attributes contained in the elements, so as to obtain the hierarchical information and position information of each element. For each element, the server can determine the superior and subordinate information between the elements in the current page based on the hierarchical information of the elements. For example, the hierarchical information of element 1 is the first level, and the hierarchical information of element 2 is the second level. It can be determined that element 1 is the parent of element 2, and element 2 is the child of element 1.
[0106] In addition, the server can determine the order of elements according to the order of traversal of the elements. The server can determine the order of elements according to the first order from top to bottom and the second order from left to right. For example, the upper left of the page is element 1, the upper right of the page is element 2, the lower left of the page is element 3, and the lower right of the page is element 4. The order of elements in the page can be determined as element 1, element 2, element 3, and element 4.
[0107] If the page contains a text placeholder and an image placeholder, the server can determine the text placeholder corresponding to the image placeholder based on the position information of the text placeholder and the image placeholder. In one example, the server can obtain the position information of the image placeholder, and based on the position information of multiple text placeholders and the position information of the image placeholder contained in the page, determine the text placeholder that is closest, and determine the text-image association information between the text placeholder and the image placeholder.
[0108] The server can store the elements, element attributes and associated information in each page in the order of each page in the target document template in the form of a JSON file, and use it as the parsing result file of the target document template.
[0109] In this embodiment, by parsing each page in the target document template, each element and the element attributes of each element are obtained, and the association information between the elements is determined based on the element attributes. Finally, the elements, element data, and association information are stored in a JSON file. This can optimize the content in the target document template, obtain a parsing result file containing association information, reduce repeated parsing processes, improve the efficiency of applying the target document template, and improve the efficiency of presentation generation.
[0110] In an exemplary embodiment, the specific implementation process of the step of "obtaining the matching relationship between the target text and the elements based on the elements and the association information between the elements" includes:
[0111] Based on the above JSON file, the elements in the above target document template and the association relationship between the elements are obtained as the first association information; based on the hierarchical relationship of the directory in the above outline directory and the correspondence between each sub-directory and the content text, the second association relationship of the text in the above target text is obtained; according to the above first association relationship and the above second association relationship, the matching relationship between the above target text and the above elements is determined.
[0112] Specifically, the server can obtain multiple subdirectories contained in the outline directory, and the server reads the JSON file, and determines the first association information between each element in each page and each element in the multiple pages in the target document template. The server can determine the second association relationship between each text in the target text based on the hierarchical relationship of the directory, the sequence of each subdirectory, and the content text corresponding to each subdirectory. For example, the server can determine the matching relationship between elements and subdirectories based on the hierarchical relationship between elements in the first association information and the hierarchical relationship between subdirectories in the second association relationship, such as the hierarchical relationship between subdirectories can be subdirectories with the same parent. The server can determine the matching relationship between elements and content texts based on the hierarchical relationship between elements in the first association information and the hierarchical relationship between subdirectories and content texts in the second association relationship, thereby matching each element with the corresponding target text to obtain a matching relationship between the element and the target text.
[0113] In this embodiment, the matching relationship between an element and a subdirectory, and between an element and a content text is determined through the association relationship between the elements, and the association relationship between the subdirectory and the content text, so that the accuracy of determining the matching relationship can be improved.
[0114] like Figure 4 As shown, the specific execution process of the above-mentioned presentation generation method is described in detail below in combination with a specific embodiment, including the following steps:
[0115] Step 1, preparation stage. Prepare multiple (for example, 30-50) PPT templates; collect offline image libraries, including natural scenery, people, architecture, cars, food, outdoor, indoor and other categories according to scenes, with at least 500 images for each category; use CLIP (Contrastive Language–Image Pretraining) multimodal large model to extract image features and store them in the image vector database. The process is as follows:
[0116] Step 1.1, download the trained Chinese CLIP large model weights to the local computer, call the ChineseCLIPModel.from_pretrained(pretrained_model_name_or_path) function to load the model weights, where the parameter pretrained_model_name_or_path is the local save path of the downloaded model;
[0117] Step 1.2, traverse the offline image library in turn, read the image, call the get_image_features(self, pixel_values, output_attentionsNone, output_hidden_states=None, return_dict=None) function to perform model forward reasoning to encode and obtain the image feature vector feature, where the pixel_values parameter value is the read image, and the obtained feature vector is normalized using the formula feature / ||feature||2.
[0118] Step 1.3, create an image vector database using faiss vector data. The server can use the index=faiss.IndexFlatL2(768) function to build a vector database index, and use the index.add(feature) function to add the feature vector in step 1.2 to the vector database index.
[0119] Among them, 768 represents the feature vector dimension, and IndexFlatL2 represents the Euclidean distance L2 for precise retrieval.
[0120] Step 1.4, call faiss.write_index(index, save_path) to save the vector database index locally in the form of an image vector database, where index is the vector database index established in 1.3, and save_path represents the local save path.
[0121] Step 2: predefine a PPT outline prompt word template (a first prompt word template) and a content generation prompt word template (a second prompt word template).
[0122] Among them, an example of a PPT outline generation prompt is as follows: "You are now a PPT outline generation expert. Generate a PPT outline with xxx as the theme. The output language is required to be Chinese. The number of pages of the generated PPT is xxx pages. The output must strictly follow the markdown format, and no other irrelevant information will be output."
[0123] An example of a PPT content generation prompt is as follows: "You are now a PPT content generation expert. Generate PPT content that expands on the theme of xxx. The output language must be Chinese. The output content must be as concise and written as possible. The output word count must not exceed xxx, and no other irrelevant information must be output."
[0124] Step 3, determine whether the user inputs a theme generated by PPT, if yes, proceed to step 4.
[0125] Step 4: Call the big model and generate the PPT outline directory in combination with the preset PPT outline prompts. The PPT outline directory contains multiple levels of directories.
[0126] Step 5: For each level of the outline directory, call the large model and combine it with the preset PPT content prompt words to generate the corresponding PPT content text in sequence.
[0127] Step 6: For the built-in PPT template selected by the user, combined with the PPT outline directory and content text generated by the large model, use the python-pptx plug-in to fill in the text and layout the style. The detailed steps of layout include:
[0128] Step 6.1, use python-pptx plug-in to read the preset PPT template. Each PPT template consists of a cover page, a title page, a directory page, a content page and an end page. Read the PPT elements of each page and the element attributes of the nested elements. For example, background color, shape, position information and placeholder information, etc., and save the elements and element attributes obtained by the above analysis offline in JSON format.
[0129] Step 6.2, fill the placeholders of each page with text according to the JSON file corresponding to the template selected by the user, combined with the outline and content of each page generated in step 5. If the number of elements in the template selected by the user is inconsistent with the number of generated outline directories and content texts, dynamically adjust the object spacing according to the width and height of the PPT, and increase or decrease the number of elements. If the current page contains an image placeholder, proceed to step 7;
[0130] Step 7: For the illustrations in the PPT, the large model is called to determine the relevant subject of the content text corresponding to the illustration, such as new energy vehicles, buildings, etc. The server uses the image vector database to quickly search for the text of the relevant subject to determine the offline image with the highest similarity, and performs processing such as cropping and scaling on the image. The detailed steps are as follows:
[0131] Step 7.1, define prompt words. The example is as follows: "Please extract the entities of the following text content. It is required to be as concise as possible and do not output other related content. For example, 'The key technology of new energy vehicles is to develop efficient and safe new automotive power battery systems', then you need to output 'new energy vehicles', 'power batteries'.
[0132] Step 7.2, randomly select the text outputted in step 7.1 to obtain a set of selected texts. The server uses the same method as step 1, loads the model weights of the word segmentation model model_processor=ChineseCLIPModel.from_pretrained(pretrained_model_name_or_path) function, calls output=model_processor.processor(text=text, padding=True, return_tensors="pt") to segment the text, and obtains the segmentation token id.
[0133] Where text represents entity text, padding is True to pad the words to ensure the consistency of token length, return_tensors="pt" means returning tensor in pytorch format and output in dictionary format.
[0134] Step 7.3, call text_features=model.get_text_features(**output), pass the output obtained in the previous step into the function, perform forward reasoning, and obtain the encoded text feature vector.
[0135] Step 7.4, call the image vector database index.search(text_features, topk=3) function, for example, the parameter topk is set to 3, and the top3 image feature vectors are returned. The server calculates the Euclidean distance between each image feature vector and the text feature vector in the image vector database, returns the image feature vector corresponding to the topk closest to it, and determines the image corresponding to the image feature vector.
[0136] Step 7.5, for the image output in step 7.4, randomly select an image, call the opencv function cv2.rezie & cv2. cv2.copymakeborder function to scale and fill the image so that the image meets the length and width requirements of the image placeholder of the PPT illustration, and insert the processed image into the corresponding position of the PPT image placeholder on this page.
[0137] Step 8. After the typesetting is completed, synthesize the PPT page by page, call the python-pptx plug-in to render the JSON file into PPT, and save the generated PPT file locally.
[0138] like Figure 5 As shown, one page of the generated PPT file can include a partial outline directory, which is composed of a primary directory and a secondary directory, respectively. The secondary directory is a subdirectory, and each secondary directory contains corresponding content text. Based on this, the elements in the page can contain three-level association information consisting of a primary directory-a secondary directory-content text. In addition, the page can contain multiple image elements, each of which matches the corresponding content text.
[0139] In this embodiment, through the content generation capability of the large language model, as well as image vector database, image matching, PPT typesetting and other technologies, the user only needs to input the document subject information of the presentation to be generated, and a PPT with the document subject information as the theme and the target document template as the style can be automatically generated, thereby improving the generation efficiency of the presentation.
[0140] It should be understood that, although the steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indications of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0141] Based on the same inventive concept, the embodiment of the present application also provides a presentation generation device for implementing the above-mentioned presentation generation method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above-mentioned method, so the specific limitations of one or more presentation generation device embodiments provided below can refer to the limitations of the presentation generation method above, and will not be repeated here.
[0142] In an exemplary embodiment, Figure 6 As shown, a presentation document generation device 600 is provided, comprising: an outline generation module 601, a content generation module 602 and a document generation module 603, wherein:
[0143] The outline generation module 601 is used to generate a first prompt word corresponding to the above-mentioned manuscript subject information based on a predefined first prompt word template when the manuscript subject information is obtained, and call a preloaded large model based on the above-mentioned first prompt word to generate an outline directory corresponding to the above-mentioned manuscript subject information; the above-mentioned outline directory includes at least two levels of directories;
[0144] The content generation module 602 is used to generate a second prompt word corresponding to each subdirectory in the outline directory based on a predefined second prompt word template, and call the large model based on the second prompt word to generate a content text corresponding to each subdirectory; the subdirectory is the last level directory in the at least two levels of directories, and the second prompt word template is different from the first prompt word template;
[0145] The document generation module 603 is used to obtain the elements contained in the above-mentioned target document template and the association information between the above-mentioned elements based on the parsed result file of the target document template when the target text containing the above-mentioned outline directory and the content text corresponding to each of the above-mentioned sub-directories is obtained; based on the above-mentioned elements and the association information between the elements, determine the matching relationship between the above-mentioned target text and the above-mentioned elements, and generate a presentation document containing the above-mentioned target text based on the above-mentioned matching relationship.
[0146] Based on the above-mentioned presentation generating device 600, an outline generating module 601 generates an outline catalog corresponding to the document subject information based on the prompt words corresponding to the outline, and a content generating module 602 generates content text corresponding to the outline catalog according to the prompt words corresponding to each sub-catalog in the outline catalog. The document generating module 603 calls the parsing result file of the target document template to determine the association information between the elements, determine the matching relationship between the target text and the elements, and generate a presentation of the target text through the matching relationship. When the document subject information is obtained, the outline catalog and content text corresponding to the document subject information can be generated through the large model, and the outline catalog and content text can be applied to the target document template to obtain the presentation corresponding to the document subject information, thereby improving the production efficiency of the presentation.
[0147] Furthermore, the elements include text placeholders and image placeholders, and the document generation module 603 is specifically used to: for the text placeholder in the above-mentioned target document template, determine the first text in the above-mentioned target text corresponding to the above-mentioned text placeholder according to the above-mentioned matching relationship, and replace the above-mentioned text placeholder with the above-mentioned first text; for the image placeholder in the above-mentioned target document template, determine the target text placeholder associated with the above-mentioned image placeholder based on the association information between the above-mentioned elements, and determine the second text corresponding to the above-mentioned target text placeholder according to the above-mentioned matching relationship; generate a third prompt word corresponding to the above-mentioned second text based on a predefined third prompt word template, and replace the above-mentioned text placeholder with the first text based on the above-mentioned third prompt word template; The three prompt words call the above-mentioned large model to determine the text entity corresponding to the above-mentioned second text, and obtain the corresponding text feature vector from the above-mentioned text entity; the above-mentioned third prompt word template is different from any one of the above-mentioned first prompt word template and the above-mentioned second prompt word template; from the pre-constructed image vector database, the target image vector matching the above-mentioned text feature vector is determined, and the above-mentioned image placeholder is replaced with the image corresponding to the above-mentioned target image vector; the above-mentioned image vector database stores image feature vectors corresponding to multiple preset images; after the above-mentioned text placeholder and the above-mentioned image placeholder in the above-mentioned target document template are replaced, a presentation document containing the above-mentioned target text is obtained.
[0148] Furthermore, the above-mentioned device also includes a vector database construction module, which is specifically used to: traverse multiple images pre-saved in the image library, call the above-mentioned large model to determine the image feature vector corresponding to each of the above-mentioned images; establish a corresponding relationship between the storage addresses of multiple images and the image feature vector corresponding to each of the above-mentioned images, and store the image feature vectors corresponding to the above-mentioned images and the above-mentioned corresponding relationship in a pre-constructed image vector database.
[0149] Furthermore, the content generation module 602 is specifically used to: determine the vector distance between each of the above-mentioned image feature vectors and the above-mentioned text feature vector in the above-mentioned image vector database; determine a predetermined number of image feature vectors as target image vectors matching the above-mentioned text feature vectors in order of the distance between each of the above-mentioned vectors from small to large; before replacing the above-mentioned image placeholder with the image corresponding to the above-mentioned target image vector, the above-mentioned method also includes: determining the images corresponding to the above-mentioned predetermined number of image feature vectors as candidate images, and randomly determining an image from the above-mentioned candidate images as the target image, and replacing the above-mentioned image placeholder.
[0150] Furthermore, the content generation module 602 is further specifically configured to: adjust the target image according to the size information of the image placeholder and the size information of the target image, and replace the image placeholder with the adjusted target image.
[0151] Furthermore, the device also includes a template parsing module, which is specifically used to: parse each page included in the above-mentioned target document template to obtain the elements in the above-mentioned page and the element attributes of each of the above-mentioned elements; the above-mentioned element attributes include hierarchical information and position information; based on the above-mentioned hierarchical information and position information, determine the association information between each of the above-mentioned elements; according to the order of each of the above-mentioned pages in the above-mentioned target document template, store the above-mentioned elements, the element attributes of the above-mentioned elements and the above-mentioned association information in each page included in the above-mentioned target document template as a JSON file as the parsing result file of the above-mentioned target document template.
[0152] Furthermore, the document generation module 603 is specifically used to: based on the above-mentioned JSON file, obtain the elements in the above-mentioned target document template and the association relationship between the elements as the first association information; based on the hierarchical relationship of the directory in the above-mentioned outline directory and the correspondence between each sub-directory and the content text, obtain the second association relationship of the text in the above-mentioned target text; according to the above-mentioned first association relationship and the above-mentioned second association relationship, determine the matching relationship between the above-mentioned target text and the above-mentioned elements.
[0153] Each module in the above-mentioned presentation generation device can be implemented in whole or in part by software, hardware and their combination. Each module can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the corresponding operations of each module.
[0154] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Figure 7 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data such as images, image vectors, and text templates of presentations. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a presentation generation method is implemented.
[0155] Those skilled in the art will understand that Figure 7The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0156] In an exemplary embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.
[0157] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0158] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0159] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0160] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0161] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0162] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for generating a presentation, characterized in that: The method comprises: When the manuscript subject information is obtained, a first prompt word corresponding to the manuscript subject information is generated based on a predefined first prompt word template, and a preloaded large model is called based on the first prompt word to generate an outline directory corresponding to the manuscript subject information; the outline directory includes at least two levels of directories; For each subdirectory in the outline directory, a second prompt word corresponding to each subdirectory is generated based on a predefined second prompt word template, and the large model is called based on the second prompt word to generate a content text corresponding to each subdirectory; the subdirectory is the last level directory of the at least two levels of directories, and the second prompt word template is different from the first prompt word template; When a target text including the outline directory and the content texts corresponding to each of the subdirectories is obtained, the elements included in the target document template and the association information between the elements are obtained based on the parsing result file of the target document template; based on the elements and the association information between the elements, the matching relationship between the target text and the elements is determined, and a presentation including the target text is generated based on the matching relationship.
2. The method according to claim 1, characterized in that The elements include text placeholders and image placeholders; and generating a presentation document including the target text based on the matching relationship includes: For the text placeholder in the target document template, determine a first text in the target text corresponding to the text placeholder according to the matching relationship, and replace the text placeholder with the first text; For the image placeholder in the target document template, based on the association information between the elements, determine the target text placeholder associated with the image placeholder, and determine the second text corresponding to the target text placeholder according to the matching relationship; generating a third prompt word corresponding to the second text based on a predefined third prompt word template, calling the large model based on the third prompt word, determining a text entity corresponding to the second text, and obtaining a corresponding text feature vector from the text entity; the third prompt word template is different from any one of the first prompt word template and the second prompt word template; Determine a target image vector matching the text feature vector from a pre-built image vector database, and replace the image placeholder with an image corresponding to the target image vector; the image vector database stores image feature vectors corresponding to a plurality of preset images; After the text placeholder and the image placeholder in the target document template are replaced, a presentation document containing the target text is obtained.
3. The method according to claim 2, characterized in that The method further comprises: Traversing a plurality of images pre-saved in an image library, calling the large model to determine an image feature vector corresponding to each of the images; A correspondence between storage addresses of multiple images and image feature vectors corresponding to each of the images is established, and the image feature vectors corresponding to the images and the correspondence are stored in a pre-constructed image vector database.
4. The method according to claim 2, characterized in that: The step of determining a target image vector matching the text feature vector from a pre-built image vector database comprises: Determining the inter-vector distance between each of the image feature vectors and the text feature vector in the image vector database; Determining a predetermined number of image feature vectors as target image vectors matching the text feature vectors according to the order of distances between the vectors from small to large; The replacing the image placeholder with the image corresponding to the target image vector comprises: The images corresponding to the predetermined number of image feature vectors are determined as candidate images, and an image is randomly determined from the candidate images as a target image, and the image placeholder is replaced.
5. The method according to claim 4, characterized in that The replacing the image placeholder with the image corresponding to the target image vector comprises: The target image is adjusted according to the size information of the image placeholder and the size information of the target image, and the image placeholder is replaced with the adjusted target image.
6. The method according to claim 1, characterized in that The method further comprises: Parsing each page contained in the target document template to obtain elements in the page and element attributes of each element; the element attributes include level information and position information; Determine association information between the elements based on the level information and the position information; According to the order of each of the pages in the target document template, the elements, the element attributes of the elements and the associated information in each page included in the target document template are stored as a JSON file as a parsing result file of the target document template.
7. The method according to claim 6, characterized in that The obtaining, based on the elements and the association information between the elements, a matching relationship between the target text and the elements includes: Based on the JSON file, obtain the elements in the target document template and the association relationship between the elements as the first association information; Based on the hierarchical relationship of the directories in the outline directory and the corresponding relationship between each subdirectory and the content text, a second association relationship of the text in the target text is obtained; A matching relationship between the target text and the element is determined according to the first association relationship and the second association relationship.
8. A presentation document generating device, characterized in that: The device comprises: An outline generation module is used to generate a first prompt word corresponding to the manuscript subject information based on a predefined first prompt word template when the manuscript subject information is acquired, and to call a preloaded large model based on the first prompt word to generate an outline directory corresponding to the manuscript subject information; the outline directory includes at least two levels of directories; a content generation module, configured to generate, for each subdirectory in the outline directory, a second prompt word corresponding to each subdirectory based on a predefined second prompt word template, and call the main model based on the second prompt word to generate a content text corresponding to each subdirectory; the subdirectory is the last level directory of the at least two levels of directories, and the second prompt word template is different from the first prompt word template; A document generation module is used to obtain the target text containing the outline directory and the content text corresponding to each sub-directory, and then obtain the elements contained in the target document template and the association information between the elements based on the parsing result file of the target document template; based on the elements and the association information between the elements, obtain the matching relationship between the target text and the elements, and generate a presentation containing the target text based on the matching relationship.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Method and device for generating UI (User Interface) design draft and storage medium
CN116991406A
Powerpoint generation method and device, electronic equipment and storage medium
CN117436414A
PPT generation method and device and PPT display method and device
CN118070767A
Presentation generation method and apparatus, computer device and storage medium
WO2021164255A1
Cited By
Course ideological and political teaching plan generation method based on large language model
CN120278127A