Text generation method and system based on large language model

Through the text generation method based on the large language model, the problem of slow text generation speed and difficult to meet the multi-platform style requirements in the existing technology is solved, and efficient and diversified text generation is achieved to adapt to the format requirements of different platforms.

CN119005133APending Publication Date: 2024-11-22CTRIP TRAVEL NETWORK TECH SHANGHAI0
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411009122.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-26
Publication Date
2024-11-22

AI Technical Summary

Technical Problem

In the prior art, text generation speed is slow, and it is difficult to meet the needs of multiple platforms for text diversified styles.

Method used

Using a text generation method based on a large language model, by obtaining text prompt information, initial propt template and the text format corresponding to the platform, fill and generate the target propt template, and input the large language model to generate output text consistent with the text format, satisfying different platforms Requirements.

Benefits of technology

It improves text generation efficiency and meets the diverse style needs of multiple platforms. The generated text is both content-relevant and can adapt to the format requirements of different platforms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119005133A_ABST
    Figure CN119005133A_ABST
Patent Text Reader

Abstract

The invention provides a text generation method and system based on a large language model, and the method comprises the steps: obtaining text prompt information, an initial prompt template and a text format corresponding to each platform, filling the text prompt information into a role and guide statement part of the initial prompt template, and filling a knowledge base and the text format into a text data part of the initial prompt template, and generating a target prompt template, then inputting the target prompt template into the large language model, and generating an output text consistent with the filled text in format. According to the method, the structural style of the output text is defined through the text formats, and at least two text formats are input when the initial prompt template is filled, so that texts meeting different text format requirements can be output simultaneously when the target prompt template is input into the large language model, the text generation efficiency is improved, and the user experience is improved. And the requirements of multiple platforms on diversified text styles are met.
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 and machine learning, and in particular to a text generation method and system based on a large language model. Background Art

[0002] Traditional text content generation requires manual conception and text writing, which not only consumes a lot of time and manpower costs, but also has different requirements for text style and format on different network platforms and media forms, such as news reports. Existing text generation methods are difficult to cope with the Internet environment's demand for text generation speed and the demand for diversified text styles on multiple platforms. Summary of the invention

[0003] The technical problem to be solved by the present disclosure is to overcome the defects of the prior art in that the text generation speed is slow and it is difficult to meet the current multi-platform requirements for diversified text styles, and to provide a text generation method and system based on a large language model.

[0004] The present invention solves the above technical problems through the following technical solutions:

[0005] A first aspect of the present disclosure provides a text generation method based on a large language model, wherein the steps of the text generation method specifically include:

[0006] Acquire text prompt information, an initial prompt template, and a text format corresponding to the platform, wherein the initial prompt template is composed of a role, a guide sentence, and text data, wherein the text format is at least two;

[0007] Filling the roles and guiding sentences of the initial prompt template according to the text prompt information, and filling the text data of the initial prompt template according to the knowledge base and the text format, to generate a target prompt template;

[0008] The target prompt template is input into a large language model to generate output text consistent with the text format.

[0009] Optionally, the step of filling the text data of the initial prompt template according to the knowledge base and the text format to generate the target prompt template specifically includes:

[0010] Acquire data information related to the text prompt information in a knowledge base;

[0011] Fill in the text data of the initial prompt template according to the data information and text format.

[0012] Optionally, obtain the text format corresponding to the platform by following the steps below:

[0013] Get sample texts for different platforms;

[0014] Extracting paragraph structure elements of the text sample;

[0015] A text format corresponding to the platform is generated according to the paragraph structure elements.

[0016] Optionally, the knowledge base includes public transportation information and scenic spot information, and the step of obtaining data information related to the text prompt information in the knowledge base specifically includes:

[0017] Filtering corresponding public transportation information from the knowledge base according to the text information; wherein the public transportation information includes destination information;

[0018] The corresponding scenic spot information is filtered out from the knowledge base according to the destination information.

[0019] Optionally, before the step of acquiring data information related to the text prompt information in the knowledge base, the step further includes:

[0020] The formats of all data in the knowledge base are converted to the same format.

[0021] Optionally, the text generation method further includes:

[0022] In response to the reading amount of the output text not exceeding a threshold, text prompt information and text format are re-acquired.

[0023] A second aspect of the present disclosure provides a text generation system based on a large language model, the text generation system comprising:

[0024] A data acquisition module, used to acquire text prompt information, an initial prompt template, and a text format corresponding to the platform, wherein the initial prompt template is composed of a role, a guide sentence, and text data, wherein the text format is at least two;

[0025] A template generation module, used to fill in the role and guide sentence of the initial prompt template according to the text prompt information, and fill in the text data of the initial prompt template according to the knowledge base and the text format, so as to generate a target prompt template;

[0026] The text generation module is used to input the target prompt template into the large language model to generate an output text consistent with the text format.

[0027] Optionally, the template generation module is specifically used to obtain data information related to the text prompt information in a knowledge base, and to fill in the text material of the initial prompt template according to the data information and text format.

[0028] Optionally, the data acquisition module is specifically used to acquire text examples of different platforms, extract paragraph structure elements of the text examples, and generate a text format corresponding to the platform according to the paragraph structure elements.

[0029] Optionally, the knowledge base includes public transportation information and tourist attraction information, and the template generation module is specifically used to filter out corresponding public transportation information from the knowledge base according to the text prompt information, wherein the public transportation information includes destination information, and corresponding tourist attraction information is filtered out from the knowledge base according to the destination information.

[0030] Optionally, the data acquisition module is specifically used to convert the formats of all data in the knowledge base into the same format.

[0031] Optionally, the text generation system further comprises a judgment module, which is used to call the acquisition module to re-acquire text prompt information and text format when it is judged that the reading amount of the output text does not exceed a threshold.

[0032] A third aspect of the present disclosure provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and used to run on the processor, wherein when the processor executes the computer program, the text generation method as described in any one of the first aspects is implemented.

[0033] A fourth aspect of the present disclosure is a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the text generation method as described in any one of the first aspects is implemented.

[0034] A fifth aspect of the present disclosure provides a computer program product, including a computer program, wherein when the computer program is executed by a processor, the text generation method as described in any one of the first aspects is implemented.

[0035] On the basis of being in accordance with the common sense in the art, the above-mentioned optional conditions can be arbitrarily combined to obtain the preferred embodiments of the present disclosure.

[0036] The positive progressive effect of the present disclosure is that the structure and style of the output text are defined by the text format. Since at least two text formats can be input when filling the initial prompt template, the generated target prompt template is input into the large language model and the output text that meets the requirements of different text formats is output at the same time, which not only improves the text generation efficiency, but also can meet the requirements of multiple platforms for diversified text styles. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 A flow chart of a text generation method based on a large language model provided in Embodiment 1 of the present disclosure;

[0038] Figure 2 A partial flow chart of a text generation method based on a large language model provided in Embodiment 1 of the present disclosure;

[0039] Figure 3 A schematic diagram of the construction process of a knowledge base of a text generation method based on a large language model provided in Embodiment 1 of the present disclosure;

[0040] Figure 4 A schematic diagram of a process for manually verifying the output text of a large language model provided in Embodiment 1 of the present disclosure;

[0041] Figure 5 A schematic diagram of modules of a text generation system based on a large language model provided in Embodiment 2 of the present disclosure;

[0042] Figure 6 A schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present disclosure. DETAILED DESCRIPTION

[0043] The present disclosure is further described below by way of examples, but the present disclosure is not limited to the scope of the examples.

[0044] Prefixes such as "first" and "second" are used in the embodiments of the present disclosure only to distinguish different description objects, and have no limiting effect on the position, order, priority, quantity or content of the described objects. The use of prefixes such as ordinal numbers to distinguish description objects in the embodiments of the present disclosure does not constitute a limitation on the described objects. For the statement of the described objects, please refer to the description in the context of the claims or embodiments, and no unnecessary limitation should be constituted due to the use of such prefixes. In addition, in the description of the present embodiment, unless otherwise specified, the meaning of "plurality" is two or more.

[0045] In the embodiments 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.

[0046] Example 1

[0047] This embodiment provides a text generation method based on a large language model, such as Figure 1 As shown, the steps of the text generation method specifically include:

[0048] S1. Obtain text prompt information, an initial prompt template, and a text format corresponding to the platform, wherein the initial prompt template is composed of a role, a guide sentence, and text data, wherein the text format is at least two;

[0049] In this embodiment, the obtained text prompt information is usually concise and clear text, and its core purpose is to enable the large language model to accurately understand the task to be performed. The role in the initial prompt template defines the identity of the participant in the interaction, such as "user, AI assistant or expert". Clarifying the role helps the large language model adjust the answer style and content depth according to different identities. The guiding sentence is an important part of guiding the large language model to perform the next step; the text material provides the background information or data required to complete the task, which helps to improve the accuracy and professionalism of the answer. The text format is the way the text material is presented. For example, some platforms may prefer a list format, while other platforms may be more suitable for a paragraph format. According to the characteristics and needs of the platform, select the appropriate text material presentation method to ensure accurate communication of information and effective interaction.

[0050] S2, filling the role and guide sentence of the initial prompt template according to the text prompt information, and filling the text data of the initial prompt template according to the knowledge base and the text format, to generate a target prompt template;

[0051] In this embodiment, the text prompt information is filled into the role and guide sentence part of the initial prompt template, and combined with the knowledge base and the text format of different platforms, the two are filled into the text material part of the initial prompt template, and the role, guide sentence and text material are integrated into an initial prompt template, thereby generating a highly customized and effective target prompt template. For example, the text prompt information obtained is "You are a writer, please write an article according to the following information". In the above initial prompt template filling process, "writer" is filled into the role part of the initial prompt template, and "please write an article according to the following information" is filled into the guide sentence part of the initial prompt template. At the same time, the data information contained in the knowledge base and the text format obtained from different platforms are used to fill the text material part of the initial prompt template. Based on the above filling method, the target prompt template obtained not only includes clear roles, specific guide sentences and rich, formatted text materials, but also takes into account the text format requirements of different platforms, which can improve the accuracy of large language models in executing tasks.

[0052] S3. Input the target prompt template into a large language model to generate an output text consistent with the text format.

[0053] In this embodiment, the integrated target prompt template is input into the large language model to generate output texts that meet specific requirements. These output texts are not only related to the input text prompt information in terms of content, but also their formats can be consistent with the text formats corresponding to different platforms. Since multiple different text formats can be filled in the initial prompt template, the final output text also has diverse characteristics and can meet the specific requirements of different platforms for text formats. For example, if the target prompt template contains three different text formats for news, social media A, and social media B platforms, then three articles in different formats will be output based on the large language model. The first article conforms to the standard text format of news reports, with strict fact checking and citation sources, the second article contains more personal insights and interactive elements in the text format, and the third article is suitable for social media, using short and powerful sentences and eye-catching elements. This method not only improves the adaptability and attractiveness of the content, but also optimizes the efficiency of cross-platform content publishing.

[0054] In an optional embodiment, Figure 2 As shown, the steps of S2 specifically include:

[0055] S21, obtaining data information related to the text prompt information in a knowledge base;

[0056] S22. Fill in the text data of the initial prompt template according to the data information and text format.

[0057] In this embodiment, according to the subject relevance and keyword matching in the text prompt information, the relevant data is accurately searched in the knowledge base, and the most relevant and most valuable information is screened out and filled into the text material part of the initial prompt template together with the text format. Due to the huge amount of knowledge base data, directly filling all the data in the knowledge base into the initial prompt template will lead to low efficiency and may introduce a large amount of irrelevant information, thereby affecting the relevance and accuracy of the output text of the large language model and the expected output text. Filling the data information screened according to the text prompt information into the initial prompt template can ensure that the data information directly supports the task requirements proposed in the guide sentence. This process can not only improve the filling efficiency of the initial prompt template, but also enable the large language model to proceed in the right direction when conceiving and expanding the text, thereby helping the large language model to generate more in-depth and more attractive text.

[0058] In a specific example, the text prompt message is "Please output an article on the topic of environmental protection". First, the latest scientific reports on global climate change, statistical data on environmental protection measures taken by governments of various countries, and reports on environmental protection related events that have occurred in the recent period are screened out from the knowledge base. For example: According to the 2023 Global Environment Report, global greenhouse gas emissions continue to rise, and the impact of climate change is becoming increasingly serious; the latest data released by the United Nations Environment Programme shows that global forest coverage has dropped by 5% in the past decade; a study conducted by an international environmental organization shows that marine plastic pollution has caused long-term and irreversible damage to marine ecosystems; according to the International Energy Agency, global sales of electric vehicles reached 5 million in 2023, ten times that of 2013; the European Union has passed a new environmental protection regulation aimed at reducing industrial emissions and promoting the development of a circular economy. The selected data information are all statistical data, research reports and timely news closely related to the environmental protection theme. By filling the above selected data information into the text material part of the initial prompt template, no content unrelated to the environmental protection theme will appear in the initial prompt template. Therefore, the text content output based on the large language model will be highly relevant to the environmental protection theme, which not only meets the requirements of the text prompt information, but also improves the relevance and accuracy of the content in the output text, and its professionalism and credibility are also increased accordingly, which can better attract the attention of target readers.

[0059] In an optional implementation manner, step S1 specifically includes:

[0060] S11. Obtain text samples from different platforms;

[0061] S12, extracting paragraph structure elements of the text model;

[0062] S13. Generate a text format corresponding to the platform according to the paragraph structure elements.

[0063] In this embodiment, text examples from different platforms, such as news websites and different social media, are collected. This can be achieved by searching the Internet or accessing specific platforms. The collected text examples from different platforms are analyzed, and their paragraph structure elements are extracted. These paragraph elements include titles, introductions, body paragraphs, subheadings, lists, icons, conclusions, etc. The extracted paragraph structure elements are integrated together to generate a text format corresponding to the platform.

[0064] In a specific example, a text sample is obtained from three platforms: a news website, social media A, and social media B. The text sample obtained from the news website is a report on scientific and technological progress, the text sample obtained from social media A is a personal opinion on environmental protection issues, and the text sample obtained from social media B is a tweet about a healthy lifestyle. Based on the above three text samples, their respective paragraph structure elements are extracted. The paragraph structure elements of the news website include: title, subtitle, introduction, body paragraph, citation of expert opinions, charts, and conclusions. The paragraph structure elements of social media A include: title, introduction body paragraph, personal experience, list, conclusion, and author information. The paragraph structure elements of social media B include: short title, body, tags, and emoticons. Three different text formats can be generated based on the extracted paragraph structure elements. The format is: Title: [Title of scientific and technological progress report], subtitle: [Brief description], introduction: [Introduction to the background of scientific and technological progress], body paragraph: [Detailed report content], quotation: [Expert opinion], chart: [Related data chart], conclusion: [Summarize the main points of the report], the text format of social media A is: Title: [Personal opinion title], introduction: [Introduction to the topic], body paragraph: [Personal opinions and arguments], personal experience: [Related personal stories], list: [Related key points or suggestions], conclusion: [Summarize the views], author information: [Author profile and contact information], the text format of social media B is: Title: [Short and attention-grabbing title], body: [One or two sentences describing a healthy lifestyle], tags: [Related topic tags], emoticons: [Increase the expression effect], the above three text samples generated text formats corresponding to the three platforms of news websites, social media A and social media B.

[0065] In an optional implementation, the knowledge base includes public transportation information and scenic spot information, and step S21 specifically includes:

[0066] Filtering corresponding public transportation information from the knowledge base according to the text information, wherein the public transportation information includes destination information;

[0067] The corresponding scenic spot information is filtered out from the knowledge base according to the destination information.

[0068] The data information in the knowledge base includes relevant information on public transportation, such as the departure place, destination, price, departure time, arrival time, etc. of air tickets, train tickets, long-distance buses, etc. Based on the destination provided in the public transportation information, the knowledge base further filters out the attraction information of the city where the destination is located, which may include the attraction name, attraction address, attraction introduction, attraction opening hours, travel guide, recommended visiting time, etc.

[0069] In a specific example, Figure 3 As shown in the figure, the knowledge base includes real-time updated air ticket information and daily updated scenic spot information. When the text prompt information is "cheap travel", first search the knowledge base for data related to economical travel, such as finding special air ticket information. After filtering out the special air ticket information from Shanghai to Xi'an, determine that Xi'an is the travel destination, and then further filter out the popular tourist attractions information of the destination Xi'an from the knowledge base, such as Big Wild Goose Pagoda, Terracotta Warriors and Bell Tower, etc. The introduction information of these attractions is filtered out to ensure that it is consistent with the theme of cheap travel and provide cost-effective travel suggestions. Based on the above filtered special air ticket information and scenic spot information, a recommendation text specifically for cheap travel is generated based on the large language model. The text may include strategies on how to use special air tickets to save travel costs, combined with the introduction of various scenic spots in Xi'an, emphasizing that rich cultural experiences and beautiful scenery can be enjoyed without spending huge amounts of money. The final output text not only allows customers to understand attractive low-cost air ticket information, but also greatly improves the attractiveness of the text content to the target audience through detailed scenic spot introductions, and enhances users' willingness to book.

[0070] In an optional implementation manner, before step S2, the method further includes: converting the formats of all data in the knowledge base into the same format.

[0071] In order to accurately and efficiently filter out data that matches the text prompt information, all data in the knowledge base are converted to a unified format to ensure that no matter where the data in the knowledge base comes from, it can be effectively and uniformly managed, thereby improving the efficiency of data analysis and increasing the accuracy of information query.

[0072] In a specific example, the knowledge base contains ticket information from different airlines and attraction information from different travel websites. The ticket information from different airlines only retains the departure place, destination, price, take-off time and arrival time. When converting the data to a unified format, the "departure place" field is uniformly named "origin", the "destination" field is uniformly named "destination", the "price" field is uniformly named "price", the "take-off time" field is uniformly named "departure", and the "arrival" field is uniformly named "arrival". All occurrences of "Shanghai" in the ticket information and attraction information are converted to Change to "sha", "Xi'an" is converted to "xaa", for example, the original ticket information is: departure: Shanghai, destination: Xi'an, price: 1000 yuan, departure time: 08:00, arrival time: 10:30, the ticket information after unified format conversion is: origin: sha, destination: xaa, price: 1000 yuan, departure: 08:00, arrival: 10:30, the original attraction information is: Shanghai Oriental Pearl Tower: One of the landmark buildings in Shanghai, providing a panoramic view of the city, the converted attraction information is: sha Oriental Pearl Tower: One of the landmark buildings in sha, providing a panoramic view of the city.

[0073] In an optional implementation, the text generation method further includes: in response to the reading volume of the output text not exceeding a threshold, reacquiring text prompt information and text format.

[0074] Publish the text that meets the format requirements to the target platform. After publishing, use analysis tools to continuously monitor the reading volume of the text. Set an expected reading volume threshold as a standard for evaluating text quality. If the reading volume exceeds the set threshold, the text can be considered successful. If the threshold is not reached, it is necessary to re-acquire the text prompt information and text format to adjust and optimize the prompt template. This may involve strategies such as changing topics, adjusting content style, and adding specific keywords to better match user needs and platform characteristics. By monitoring the text reading volume after each release, analyze which types of content are more popular and which topics can attract more users' attention, thereby improving the quality of the output text and ultimately achieving higher reading volume and better user experience.

[0075] In a specific example, a "Shanghai Travel Guide" text based on the output of the large language model is published to social media platform A, and it is set that the user reading volume is at least 500 times within one week of the release. The Google Analytics tool monitors that the reading volume of this text is only 200 times within a week. At this time, new text prompt information and text format are obtained, wherein the new text prompt information is changed to "Shanghai Weekend Travel", and more image setting positions are added to the new text format. The obtained new text prompt information and text format are filled into the initial prompt template to generate a new target prompt template, and a "Shanghai Weekend Travel Guide" text is regenerated based on the large language model. The new output text focuses more on short-term tourists and provides richer visual content. According to the reading volume of the newly generated text, the text prompt information and text format are continuously adjusted until the reading volume of the article exceeds 500.

[0076] In a specific example, Figure 4 As shown, the initial prompt template is filled with text prompt information, knowledge base and text format to generate a target prompt template, the target prompt template is input into the large language model, and batch text is output. At this time, professionals manually review the output text. If the manual verification pass rate of the text is lower than 90%, the text prompt information and text format are re-acquired to optimize the target prompt template. If the manual verification pass rate of the text is higher than 90%, the target prompt template constructed above is put online to the production environment. When text needs to be generated, high-quality text can be generated quickly and in large quantities.

[0077] Example 2

[0078] Corresponding to the text generation method based on a large language model in the aforementioned embodiment 1, the present disclosure also provides a text generation system based on a large language model, such as Figure 5 As shown, the text generation system includes:

[0079] The data acquisition module 101 is used to acquire text prompt information, an initial prompt template, and a text format corresponding to the platform, wherein the initial prompt template is composed of a role, a guide sentence, and text data, wherein the text format is at least two;

[0080] The template generation module 102 is used to fill in the role and guide sentence of the initial prompt template according to the text prompt information, and fill in the text data of the initial prompt template according to the knowledge base and the text format to generate a target prompt template;

[0081] The text generation module 103 is used to input the target prompt template into the large language model to generate an output text consistent with the text format.

[0082] In an optional implementation, the template generation module 102 is specifically used to obtain data information related to the text prompt information in a knowledge base, and to fill in the text material of the initial prompt template according to the data information and text format.

[0083] In an optional implementation, the data acquisition module 101 is specifically used to acquire text examples from different platforms, extract paragraph structure elements of the text examples, and generate a text format corresponding to the platform according to the paragraph structure elements.

[0084] In an optional embodiment, the knowledge base includes public transportation information and scenic spot information, and the template generation module 102 is specifically used to filter out corresponding public transportation information from the knowledge base according to the text prompt information, wherein the public transportation information includes destination information, and the corresponding scenic spot information is filtered out from the knowledge base according to the destination information.

[0085] In an optional implementation manner, the data acquisition module 101 is specifically used to convert the formats of all data in the knowledge base into the same format.

[0086] In an optional implementation, the text generation system further includes a judgment module, which is used to call the acquisition module to re-acquire text prompt information and text format when it is determined that the reading volume of the output text does not exceed a threshold.

[0087] As for the system embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The system embodiment described above is only illustrative, wherein the units described as separate components may or may not be physically separated, and the components as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the disclosed solution.

[0088] Example 3

[0089] This embodiment provides an electronic device, including a processor, a memory, and a computer program stored in the memory and used to run on the processor. When the computer program is executed by the processor, the text generation method based on the large language model as in Embodiment 1 is implemented.

[0090] Figure 6The structure diagram of an electronic device provided in this embodiment. The electronic device includes a memory, a processor, and a computer program stored in the memory and used to run on the processor. When the processor executes the program, the text generation method based on the large language model of embodiment 1 is implemented. Figure 6 The electronic device 90 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0091] The electronic device 90 may be in the form of a general-purpose computing device, for example, it may be a server device. The components of the electronic device 90 may include, but are not limited to: at least one processor 91, at least one memory 92, and a bus 93 connecting different system components (including the memory 92 and the processor 91).

[0092] The bus 93 includes a data bus, an address bus, and a control bus.

[0093] The memory 92 may include a volatile memory, such as a random access memory (RAM) 921 and / or a cache memory 922 , and may further include a read-only memory (ROM) 923 .

[0094] The memory 92 may also include a program / utility 925 having a set (at least one) of program modules 924, such program modules 924 including but not limited to: an operating system, one or more application programs, other program modules and program data, each of which or some combination may include an implementation of a network environment.

[0095] The processor 91 executes various functional applications and data alignment by running the computer programs stored in the memory 92, such as the text generation method based on the large language model of the first embodiment of the present disclosure.

[0096] The electronic device 90 may also communicate with one or more external devices 94 (e.g., keyboards, pointing devices, etc.). Such communication may be performed via an input / output (I / O) interface 95. Furthermore, the model-generated device 90 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 96. As shown, the network adapter 96 communicates with other modules of the model-generated device 90 via a bus 93. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the model-generated device 90, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (RAID) systems, tape drives, and data backup storage systems, etc.

[0097] It should be noted that although several units / modules or sub-units / modules of the electronic device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more units / modules described above can be embodied in one unit / module. Conversely, the features and functions of one unit / module described above can be further divided into multiple units / modules to be embodied.

[0098] Example 4

[0099] This embodiment provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the text generation method based on a large language model of Embodiment 1 is implemented.

[0100] The readable storage medium may include but is not limited to: a portable disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory, an optical storage device, a magnetic storage device or any suitable combination of the above.

[0101] Example 5

[0102] This embodiment provides a computer program product, including a computer program, which, when executed by a processor, implements the text generation method based on a large language model as described in Embodiment 1.

[0103] Among them, the program code for executing the computer program product of the present disclosure can be written in any combination of one or more programming languages, and the program code can be executed completely on the user device, partially on the user device, as an independent software package, partially on the user device and partially on a remote device, or completely on the remote device.

[0104] Although the specific embodiments of the present disclosure are described above, those skilled in the art should understand that this is only an example, and the protection scope of the present disclosure is defined by the appended claims. Those skilled in the art may make various changes or modifications to these embodiments without departing from the principles and essence of the present disclosure, but these changes and modifications all fall within the protection scope of the present disclosure.

Claims

1. A text generation method based on a large language model, It is characterized in that The steps of the text generation method specifically include: Acquire text prompt information, an initial prompt template, and a text format corresponding to the platform, wherein the initial prompt template is composed of a role, a guide sentence, and text data, wherein the text format is at least two; Filling the roles and guiding sentences of the initial prompt template according to the text prompt information, and filling the text data of the initial prompt template according to the knowledge base and the text format, to generate a target prompt template; The target prompt template is input into a large language model to generate output text consistent with the text format.

2. The text generation method according to claim 1, It is characterized in that The step of filling the text data of the initial prompt template according to the knowledge base and the text format to generate the target prompt template specifically includes: Acquire data information related to the text prompt information in a knowledge base; Fill in the text data of the initial prompt template according to the data information and text format.

3. The text generation method according to claim 1, It is characterized in that To obtain the text format corresponding to the platform, follow these steps: Get sample texts for different platforms; Extracting paragraph structure elements of the text sample; A text format corresponding to the platform is generated according to the paragraph structure elements.

4. The text generation method according to claim 2, It is characterized in that The knowledge base includes public transportation information and scenic spot information, and the step of obtaining data information related to the text prompt information in the knowledge base specifically includes: Filtering corresponding public transportation information from the knowledge base according to the text prompt information, wherein the public transportation information includes destination information; The corresponding scenic spot information is filtered out from the knowledge base according to the destination information.

5. The text generation method according to claim 2, It is characterized in that Before the step of obtaining data information related to the text prompt information in the knowledge base, the step also includes: The formats of all data in the knowledge base are converted to the same format.

6. The text generation method according to any one of claims 1 to 5, It is characterized in that The text generation method also includes: In response to the reading amount of the output text not exceeding a threshold, text prompt information and text format are re-acquired.

7. A text generation system based on a large language model, It is characterized in that The text generation system comprises: A data acquisition module, used to acquire text prompt information, an initial prompt template, and a text format corresponding to the platform, wherein the initial prompt template is composed of a role, a guide sentence, and text data, wherein the text format is at least two; A template generation module, used to fill in the role and guide sentence of the initial prompt template according to the text prompt information, and fill in the text data of the initial prompt template according to the knowledge base and the text format, so as to generate a target prompt template; The text generation module is used to input the target prompt template into the large language model to generate an output text consistent with the text format.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and for running on the processor, It is characterized in that When the processor executes the computer program, the text generation method according to any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the text generation method according to any one of claims 1 to 6 is implemented.

10. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the text generation method according to any one of claims 1 to 6 is implemented.

Citation Information

Cited By

  • Script generation method and device, equipment and storage medium

    CN119922390A

  • Text generation method and system based on large language model

    CN119962510A