Text generation method and apparatus

By conducting multi-dimensional quality evaluation and optimization of the search results, the generation effect of the large language model was improved, the problem of unsatisfactory generation effect caused by poor search result quality was solved, and a more efficient question answering system was achieved.

WO2025261249A1PCT designated stage Publication Date: 2025-12-26HUAWEI TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/100584
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-06-20
Filing Date
2025-06-12
Publication Date
2025-12-26

AI Technical Summary

Technical Problem

Large language models often fail to achieve ideal generation results due to poor quality of retrieval results, especially in question-answering tasks, where existing technologies are insufficient when only considering the relevance of retrieval results.

Method used

By conducting multi-dimensional quality evaluations of search results, including answerability, factuality, authority, and timeliness, the search results are dynamically optimized, and the quality evaluation is used as input to the language model to improve the generation effect.

Benefits of technology

It improves the fault tolerance and robustness of the question-answering system, enhances the efficiency of the language model in utilizing retrieval results, and reduces the generation pressure.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025100584_26122025_PF_FP_ABST
    Figure CN2025100584_26122025_PF_FP_ABST
Patent Text Reader

Abstract

A text generation method, applied to the field of artificial intelligence. The method comprises: acquiring a first text; determining, on the basis of the first text, a plurality of first retrieval results related to the first text; acquiring a first quality assessment of each first retrieval result; and inputting the first text, the plurality of first retrieval results, and the first quality assessments into a language model to obtain a response text of the first text. In the present application, quality evaluation can be conducted on retrieval results, and quality evaluation results are used as input for a language model; when processing a first text and the retrieval results, the language model can be informed of the quality assessments of the retrieval results; and by enabling the language model to perceive the quality of the retrieval results, the language model can more effectively use information of the retrieval results to generate responses, thereby improving the generation effect of the language model.
Need to check novelty before this filing date? Find Prior Art

Description

A text generation method and apparatus

[0001] This application claims priority to Chinese Patent Application No. 202410808202.2, filed on June 20, 2024, entitled “A Text Generation Method and Apparatus”, the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of artificial intelligence, and in particular to a text generation method and apparatus thereof. Background Technology

[0003] With the advancement of technology and the accumulation of data, large language models (LLMs) have developed rapidly. Large language models have a massive number of parameters, typically reaching billions or even hundreds of billions, enabling them to learn richer and more complex language structures and semantic features.

[0004] Large language models possess powerful language understanding and generation capabilities, broad knowledge coverage, and good adaptability and scalability, and are widely used in scenarios such as text generation, dialogue systems, educational assistance, and content creation. However, due to limitations in training methods and costs, they still have problems such as, but not limited to, knowledge illusion, difficulty in updating knowledge, and insufficient knowledge in specific domains.

[0005] To address the aforementioned issues, the mainstream solution in the industry is retrieval augmented generation (RAG). This method effectively alleviates the problems of large language models by retrieving external knowledge bases. The RAG system can retrieve relevant knowledge fragments based on the user's query request and input the search results, query request, and instruction prompts into the LLM to generate a response.

[0006] However, due to the diversity of user input queries, there may be problems such as unclear intent and complex queries, and the search results may be irrelevant, incomplete, or unanswerable, resulting in poor LLM generation performance. Summary of the Invention

[0007] In a first aspect, this application provides a text generation method, the method comprising: obtaining a first text; determining a plurality of first search results related to the first text based on the first text; obtaining a first quality evaluation for each of the first search results; and inputting the first text, the plurality of first search results, and the first quality evaluation into a language model to obtain a response text for the first text.

[0008] Existing RAG systems rely on high-quality search results. When the search results are of poor quality, the final generated result is poor. In this embodiment, the search results can be quality evaluated, and the quality evaluation result is used as input to the language model. When processing the first text and the search results, the language model can know the quality evaluation of the search results. By allowing the language model to perceive the quality of the search results, the language model can more effectively use the information of the search results to generate responses, thereby improving the generation effect of the language model.

[0009] Furthermore, since the language model does not need to judge the quality of the retrieval results during the generation process (quality evaluation is used as input to the language model), the generation pressure on the language model is reduced.

[0010] In one possible implementation, the first quality assessment includes one or more of the following assessments: the answerability of the first search result as a response to the first text; the factuality, authority, or timeliness of the first search result; whether there is a contradiction between the first search result and other first search results, or a contradiction between the first search result and other first search results.

[0011] In this context, factual accuracy assesses whether the search results violate common sense, facts, and relevant standards and norms. Authority assesses the factual accuracy, authority, and timeliness of the search results. Timeliness assesses whether the search results are outdated or belong to an obsolete version.

[0012] In existing technologies, the quality assessment of search results only uses the relevance between the input question and the search results. When the search results are relevant but cannot answer the question, the generation effect of the language model will still be poor, especially in question-answering tasks, where considering only relevance is insufficient. The embodiments of this application, however, can evaluate the quality of search results from multiple dimensions, resulting in a more accurate assessment.

[0013] In one possible implementation, the first quality assessment is described in natural language. The step of inputting the first text, the plurality of first search results, and the first quality assessment into a language model to obtain a response text for the first text includes: inputting a prompt containing the first text, the plurality of first search results, and the first quality assessment into a language model to obtain a response text for the first text.

[0014] In one possible implementation, determining a plurality of first search results related to the first text based on the first text includes: determining a plurality of second search results related to the first text based on the first text; obtaining a second quality evaluation for each second search result; and optimizing the plurality of second search results based on the second quality evaluation to obtain the plurality of first search results.

[0015] The embodiments of this application can dynamically optimize search results based on evaluation information, promptly correct low-quality search results, and improve the fault tolerance and robustness of the question-answering system.

[0016] In one possible implementation, optimizing the plurality of second search results based on the second quality evaluation includes: removing second search results from the plurality of second search results whose second quality evaluation is not satisfied with the preset conditions.

[0017] For example, a corresponding threshold can be set for the quality evaluation of each dimension, and search results with a quality evaluation lower than the threshold can be removed.

[0018] In one possible implementation, the method further includes: supplementing the plurality of second search results after removal when the number of the removed results is less than a preset value.

[0019] Secondly, this application provides a text generation apparatus, the apparatus comprising:

[0020] The acquisition module is used to acquire the first text.

[0021] The processing module is configured to determine multiple first search results related to the first text based on the first text; obtain a first quality evaluation for each first search result; and input the first text, the multiple first search results, and the first quality evaluation into a language model to obtain a response text for the first text.

[0022] In one possible implementation, the first quality assessment includes one or more of the following assessments:

[0023] The first search result is used as the answerability of the first text response;

[0024] The factual accuracy, authority, or timeliness of the first search result;

[0025] Is there a contradiction between the first search result and other first search results, or is there a contradiction between the first search result and other first search results?

[0026] In one possible implementation, the first quality assessment is described using natural language, and the processing module is specifically used for:

[0027] The prompt, which includes the first text, the plurality of first search results, and the first quality assessment, is input into the language model to obtain the response text for the first text.

[0028] In one possible implementation, the processing module is specifically used for:

[0029] Based on the first text, determine multiple second search results related to the first text;

[0030] Obtain a second quality assessment for each of the second search results;

[0031] Based on the second quality assessment, the plurality of second search results are optimized to obtain the plurality of first search results.

[0032] In one possible implementation, the processing module is specifically used for:

[0033] Remove the second search results from the multiple second search results whose second quality evaluation does not meet the preset conditions.

[0034] In one possible implementation, the processing module is further configured to:

[0035] If the number of the plurality of second search results after removal is less than a preset value, the plurality of second search results after removal will be supplemented.

[0036] Thirdly, embodiments of this application provide a text generation apparatus, which may include a memory, a processor, and a bus system, wherein the memory is used to store a program, and the processor is used to execute the program in the memory to perform the methods described in the first aspect above and any of its optional methods.

[0037] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when run on a computer, causes the computer to perform the methods described in the first aspect and any of its optional methods.

[0038] Fifthly, embodiments of this application provide a computer program that, when run on a computer, causes the computer to perform the first aspect and any of its optional methods described above.

[0039] Sixthly, this application provides a chip system including a processor for supporting an execution device or training device in implementing the functions involved in the foregoing aspects, such as transmitting or processing data involved in the foregoing methods; or, information. In one possible design, the chip system further includes a memory for storing program instructions and data necessary for the execution device or training device. This chip system may be composed of chips or may include chips and other discrete devices. Attached Figure Description

[0040] Figure 1A is a schematic diagram of a structural framework for artificial intelligence.

[0041] Figures 1B and 1C are schematic diagrams of the application system framework of the present invention;

[0042] Figure 1D is a schematic diagram of an optional hardware structure for the terminal;

[0043] Figure 2 is a schematic diagram of a server structure;

[0044] Figures 3 to 5 are schematic diagrams of a system architecture according to this application;

[0045] Figure 6 illustrates the process of a cloud service.

[0046] Figure 7 is a flowchart illustrating a text generation method provided in an embodiment of this application;

[0047] Figure 8 is a flowchart illustrating a text generation method provided in an embodiment of this application;

[0048] Figure 9 is a schematic diagram of an application architecture according to an embodiment of this application;

[0049] Figure 10 is a schematic diagram of an application architecture according to an embodiment of this application;

[0050] Figure 11 is a flowchart illustrating a text generation method provided in an embodiment of this application;

[0051] Figure 12 is a schematic diagram of a text generation device provided in an embodiment of this application;

[0052] Figure 13 is a schematic diagram of a terminal device provided in an embodiment of this application;

[0053] Figure 14 is a schematic diagram of a server structure provided in an embodiment of this application;

[0054] Figure 15 is a schematic diagram of a chip structure provided in an embodiment of this application. Detailed Implementation

[0055] The embodiments of the present invention will now be described with reference to the accompanying drawings. The terminology used in the embodiments section is for illustrative purposes only and is not intended to limit the scope of the invention.

[0056] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.

[0057] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of elements is not necessarily limited to those elements, but may include other elements not explicitly listed or inherent to those processes, methods, products, or apparatuses.

[0058] The terms “substantially,” “about,” and similar terms used herein are used as approximations rather than as terms of degree, and are intended to take into account the inherent biases of measurements or calculations known to those skilled in the art. Furthermore, the use of “may” in describing embodiments of the invention refers to “one or more possible embodiments.” The terms “use,” “using,” and “used” used herein are to be considered synonymous with the terms “utilize,” “utilizing,” and “utilized,” respectively. Additionally, the term “exemplary” is intended to refer to an instance or illustration.

[0059] First, the overall workflow of an artificial intelligence system is described, as shown in Figure 1A. Figure 1A is a structural diagram of the main framework of artificial intelligence. The framework is then elaborated from two dimensions: the "intelligent information chain" (horizontal axis) and the "IT value chain" (vertical axis). The "intelligent information chain" reflects a series of processes from data acquisition to processing. For example, it could be the general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, and intelligent execution and output. In this process, data undergoes a condensation process of "data—information—knowledge—wisdom." The "IT value chain" reflects the value that artificial intelligence brings to the information technology industry, from the underlying infrastructure of human intelligence and information (provided and processed by technology) to the industrial ecosystem of the system.

[0060] (1) Infrastructure

[0061] Infrastructure provides computing power to support artificial intelligence systems, enabling communication with the external world and providing support through a basic platform. This communication occurs through sensors; computing power is provided by intelligent chips (hardware acceleration chips such as CPUs, NPUs, GPUs, ASICs, and FPGAs); and the basic platform includes distributed computing frameworks and related platform guarantees and support, which may include cloud storage and computing, interconnected networks, etc. For example, sensors communicate with the outside world to acquire data, and this data is provided to intelligent chips in the distributed computing system provided by the basic platform for computation.

[0062] (2) Data

[0063] The data at the next layer of infrastructure is used to represent the data sources in the field of artificial intelligence. The data involves graphics, images, voice, text, and IoT data from traditional devices, including business data from existing systems and sensor data such as force, displacement, liquid level, temperature, and humidity.

[0064] (3) Data processing

[0065] Data processing typically includes methods such as data training, machine learning, deep learning, search, reasoning, and decision-making.

[0066] Among them, machine learning and deep learning can perform intelligent information modeling, extraction, preprocessing, and training on data, including symbolization and formalization.

[0067] Reasoning refers to the process in which, in a computer or intelligent system, the machine thinks and solves problems by simulating human intelligent reasoning, based on reasoning control strategies and using formalized information. Typical functions include search and matching.

[0068] Decision-making refers to the process of making decisions based on intelligent information after reasoning, and it typically provides functions such as classification, sorting, and prediction.

[0069] (4) General ability

[0070] After the data processing mentioned above, the results of the data processing can be used to form some general capabilities, such as algorithms or a general system, for example, translation, text analysis, computer vision processing, speech recognition, image recognition, etc.

[0071] (5) Smart Products and Industry Applications

[0072] Intelligent products and industry applications refer to products and applications of artificial intelligence systems in various fields. They are the encapsulation of overall artificial intelligence solutions, productizing intelligent information decision-making and realizing practical applications. Their application areas mainly include: intelligent terminals, intelligent transportation, intelligent healthcare, autonomous driving, smart cities, etc.

[0073] First, we will introduce the application scenarios of this application. This application can be used, but is not limited to, applications with generative artificial intelligence (AIGC) functionality (hereinafter referred to as synthetic applications) or cloud services provided by cloud-side servers, etc., which will be introduced separately below:

[0074] I. Synthesis Applications

[0075] The product form of this application embodiment can be a synthetic application. Synthetic applications can run on terminal devices or cloud-based servers.

[0076] In one possible implementation, a synthesis application can perform a data generation task based on input data (e.g., text), wherein the synthesis application can perform the data generation task in response to the input data (e.g., text) to obtain generated data.

[0077] For example, the task of generating the above data can be, but is not limited to:

[0078] Text generation task: It can generate various types of text content, including news reports, blog posts, product descriptions, social media posts, etc. It can generate logical and coherent text based on given themes and requirements.

[0079] Content summarization and conclusion tasks: It can read large amounts of text content and generate summaries or conclusions. It can extract key information from the text and present it to the user in a concise manner.

[0080] Language translation task: This function performs language translation, converting text from one language to another. It can handle multiple language pairs and provide accurate translation results.

[0081] Automated replies and customer service: This can be used to automatically answer user questions and provide customer service. It can understand the user's intent and provide accurate answers or suggestions.

[0082] In one possible implementation, a user can open a synthesis application installed on a terminal device and input data (e.g., text). The synthesis application can generate data from the input data using the method provided in the embodiments of this application and present the generated data to the user (the presentation method may include, but is not limited to, displaying, saving, uploading to the cloud, etc.).

[0083] In one possible implementation, a user can open a synthesis application installed on a terminal device and input data. The synthesis application can then send the input data to a cloud-based server. The cloud-based server uses the method provided in this application to generate data from the input data and sends the generated data back to the terminal device. The terminal device can then present the generated data to the user (the presentation method may include, but is not limited to, displaying, saving, or uploading to the cloud).

[0084] The following sections will describe the synthetic application in this application from the perspectives of functional architecture and product architecture that implements the functions.

[0085] Referring to Figure 1B, which is a schematic diagram of the functional architecture of the synthetic application in an embodiment of this application:

[0086] In one possible implementation, as shown in FIG1B, the synthesis application 102 may receive input parameters 101 (e.g., containing input data) and produce a synthesis result 103. The synthesis application 102 may execute on at least one computer system (for example) and includes computer code that, when executed by one or more computers, causes the computers to execute a natural language model trained by the methods provided in the embodiments of this application.

[0087] Referring to Figure 1C, which is a schematic diagram of the entity architecture for running a synthetic application in an embodiment of this application:

[0088] Referring to Figure 1C, which illustrates a system architecture, the system may include a terminal 100 and a server 200. The server 200 may include one or more servers (Figure 1C illustrates this using one server as an example), and the server 200 may provide synthesis function services to one or more terminals.

[0089] The terminal 100 may have a synthesis application installed or a webpage related to the synthesis function open. The application and webpage can provide an interface. The terminal 100 can receive relevant parameters input by the user on the synthesis function interface and send the parameters to the server 200. The server 200 can obtain the processing result based on the received parameters and return the processing result to the terminal 100.

[0090] It should be understood that in some optional implementations, the terminal 100 can also complete the action of obtaining the processing result based on the received parameters on its own, without the need for the server to cooperate. This application embodiment is not limited to this.

[0091] The product form of terminal 100 in Figure 1C will be described next;

[0092] The terminal 100 in this application embodiment can be a mobile phone, tablet computer, wearable device, vehicle device, augmented reality (AR) / virtual reality (VR) device, laptop computer, ultra-mobile personal computer (UMPC), netbook, personal digital assistant (PDA), etc., and this application embodiment does not impose any restrictions on it.

[0093] Figure 1D shows a schematic diagram of an optional hardware structure for terminal 100.

[0094] Referring to Figure 1D, terminal 100 may include components such as a radio frequency unit 110, a memory 120, an input unit 130, a display unit 140, a camera 150 (optional), an audio circuit 160 (optional), a speaker 161 (optional), a microphone 162 (optional), a processor 170, an external interface 180, and a power supply 190. Those skilled in the art will understand that Figure 1D is merely an example of a terminal or multi-functional device and does not constitute a limitation on the terminal or multi-functional device; it may include more or fewer components than illustrated, or combine certain components, or use different components.

[0095] The input unit 130 can be used to receive input numerical or character information, and to generate key signal inputs related to user settings and function control of the portable multi-functional device. Specifically, the input unit 130 may include a touchscreen 131 (optional) and / or other input devices 132. The touchscreen 131 can collect touch operations performed by the user on or near it (such as operations performed by the user using fingers, knuckles, styluses, or any suitable object on or near the touchscreen), and drive the corresponding connection devices according to a pre-set program. The touchscreen can detect the user's touch actions, convert the touch actions into touch signals and send them to the processor 170, and can receive and execute commands sent by the processor 170; the touch signal includes at least touch point coordinate information. The touchscreen 131 can provide an input interface and an output interface between the terminal 100 and the user. In addition, various types of touchscreens, such as resistive, capacitive, infrared, and surface acoustic wave, can be used to implement the touchscreen. Besides the touchscreen 131, the input unit 130 may also include other input devices. Specifically, other input devices 132 may include, but are not limited to, one or more of the following: physical keyboard, function keys (such as volume control buttons, power buttons, etc.), trackball, mouse, joystick, etc.

[0096] Among them, the input device 132 can receive input data, etc.

[0097] The display unit 140 can be used to display information input by the user or information provided to the user, various menus of the terminal 100, interactive interfaces, file display, and / or playback of any multimedia file. In this embodiment, the display unit 140 can be used to display the interface of a synthesis application, generated data, etc.

[0098] The memory 120 can be used to store instructions and data. The memory 120 may primarily include an instruction storage area and a data storage area. The data storage area can store various types of data, such as multimedia files and text. The instruction storage area can store software units such as operating systems, applications, and instructions required for at least one function, or subsets or extended sets thereof. It may also include non-volatile random access memory. It provides the processor 170 with hardware, software, and data resources for managing the computing device, supporting control software and applications. It is also used for storing multimedia files, as well as storing running programs and applications.

[0099] The processor 170 is the control center of the terminal 100. It connects various parts of the terminal 100 via various interfaces and lines. By running or executing instructions stored in the memory 120 and calling data stored in the memory 120, it performs various functions of the terminal 100 and processes data, thereby providing overall control of the terminal device. Optionally, the processor 170 may include one or more processing units; preferably, the processor 170 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 170. In some embodiments, the processor and memory can be implemented on a single chip; in some embodiments, they can also be implemented separately on independent chips. The processor 170 can also be used to generate corresponding operation control signals, send them to the corresponding components of the computing device, read and process data in the software, especially read and process data and programs in the memory 120, so that the various functional modules therein perform corresponding functions, thereby controlling the corresponding components to act according to the instructions.

[0100] The memory 120 can be used to store software code related to the text generation method, and the processor 170 can execute the steps of the chip's text generation method, and can also schedule other units (such as the above-mentioned input unit 130 and display unit 140) to achieve the corresponding functions.

[0101] The radio frequency unit 110 (optional) can be used for receiving and transmitting signals during information transmission or calls. For example, it can receive downlink information from the base station and process it for the processor 170; additionally, it can transmit uplink data to the base station. Typically, the RF circuit includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low-noise amplifier (LNA), a duplexer, etc. Furthermore, the radio frequency unit 110 can also communicate wirelessly with network devices and other devices. This wireless communication can use any communication standard or protocol, including but not limited to Global System for Mobile communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.

[0102] In this embodiment of the application, the radio frequency unit 110 can send input data to the server 200 and receive generated data sent by the server 200.

[0103] It should be understood that the radio frequency unit 110 is optional and can be replaced with other communication interfaces, such as a network port.

[0104] The terminal 100 also includes a power supply 190 (such as a battery) that supplies power to various components. Preferably, the power supply can be logically connected to the processor 170 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system.

[0105] Terminal 100 also includes an external interface 180, which can be a standard Micro USB interface or a multi-pin connector, which can be used to connect terminal 100 to other devices for communication or to connect a charger to charge terminal 100.

[0106] Although not shown, terminal 100 may also include a flash, a wireless fidelity (WiFi) module, a Bluetooth module, and sensors with various functions, which will not be described in detail here. Some or all of the methods described below can be applied to terminal 100 as shown in Figure 1D.

[0107] The product form of server 200 in Figure 1C is described below;

[0108] Figure 2 provides a schematic diagram of the structure of a server 200. As shown in Figure 2, the server 200 includes a bus 201, a processor 202, a communication interface 203, and a memory 204. The processor 202, the memory 204, and the communication interface 203 communicate with each other via the bus 201.

[0109] Bus 201 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, only one thick line is used in Figure 2, but this does not indicate that there is only one bus or one type of bus.

[0110] The processor 202 can be any one or more of the following processors: central processing unit (CPU), graphics processing unit (GPU), microprocessor (MP), or digital signal processor (DSP).

[0111] Memory 204 may include volatile memory, such as random access memory (RAM). Memory 204 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).

[0112] The memory 204 can be used to store software code related to the text generation method, and the processor 202 can execute the steps of the chip's text generation method, and can also schedule other units to achieve corresponding functions.

[0113] It should be understood that the aforementioned terminal 100 and server 200 can be centralized or distributed devices. The processors (e.g., processor 170 and processor 202) in the aforementioned terminal 100 and server 200 can be hardware circuits (such as application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), general-purpose processors, digital signal processors (DSPs), microprocessors or microcontrollers, etc.) or combinations of these hardware circuits. For example, the processor can be a hardware system with instruction execution capabilities, such as a CPU or DSP, or a hardware system without instruction execution capabilities, such as an ASIC or FPGA, or a combination of the aforementioned hardware systems without instruction execution capabilities and hardware systems with instruction execution capabilities.

[0114] It should be understood that the steps related to the model inference process in the embodiments of this application involve AI-related operations. When performing AI operations, the instruction execution architecture of the terminal device and the server is not limited to the processor-memory architecture described above. The system architecture provided in the embodiments of this application will be described in detail below with reference to Figure 5.

[0115] Figure 5 is a schematic diagram of the system architecture provided in an embodiment of this application. As shown in Figure 5, the system architecture 500 includes an execution device 510, a training device 520, a database 530, a client device 540, a data storage system 550, and a data acquisition system 560.

[0116] The execution device 510 includes a calculation module 511, an I / O interface 512, a preprocessing module 513, and a preprocessing module 514. The calculation module 511 may include a target model / rule 501, while the preprocessing modules 513 and 514 are optional.

[0117] The execution device 510 can be a terminal device or a server that runs the aforementioned synthetic application.

[0118] The data acquisition device 560 is used to collect training samples. Training samples can be program files (including program code and program input data), etc. After collecting the training samples, the data acquisition device 560 stores these training samples in the database 530.

[0119] The training device 520 can maintain training samples in the database 530 to obtain the target model / rule 501 from the neural network to be trained.

[0120] It should be noted that in practical applications, the training samples maintained in database 530 may not all come from the data acquisition device 560; they may also be received from other devices. Furthermore, it should be noted that training device 520 may not necessarily train the target model / rule 501 entirely based on the training samples maintained in database 530; it may also obtain training samples from the cloud or other sources for model training. The above description should not be construed as limiting the embodiments of this application.

[0121] The target model / rule 501 trained by the training device 520 can be applied to different systems or devices, such as the execution device 510 shown in Figure 5. The execution device 510 can be a terminal, such as a mobile terminal, tablet computer, laptop computer, augmented reality (AR) / virtual reality (VR) device, vehicle terminal, etc., or it can be a server, etc.

[0122] Specifically, the training device 520 can transfer the trained model to the execution device 510.

[0123] In Figure 5, the execution device 510 is configured with an input / output (I / O) interface 512 for data interaction with external devices. Users can input data to the I / O interface 512 through the client device 540 (e.g., input data in the embodiment of this application).

[0124] Preprocessing modules 513 and 514 are used to preprocess the input data received from the I / O interface 512. It should be understood that preprocessing modules 513 and 514 may be absent, or only one preprocessing module may be used. When preprocessing modules 513 and 514 are absent, the calculation module 511 can be used directly to process the input data.

[0125] During the preprocessing of input data by the execution device 510, or during the calculation module 511 of the execution device 510 performing calculations and other related processes, the execution device 510 can call data, code, etc. in the data storage system 550 for corresponding processing, or store the data, instructions, etc. obtained from the corresponding processing into the data storage system 550.

[0126] Finally, the I / O interface 512 provides the processing results (such as generated data) to the client device 540, thereby providing them to the user.

[0127] In the scenario shown in Figure 5, the user can manually provide input data, which can be done through the interface provided by I / O interface 512. Alternatively, the client device 540 can automatically send input data to I / O interface 512. If user authorization is required for the client device 540 to automatically send input data, the user can set the corresponding permissions in the client device 540. The user can view the output results of the execution device 510 on the client device 540, which can be presented in various forms such as display, sound, or animation. The client device 540 can also act as a data acquisition terminal, collecting the input data and output results of the input I / O interface 512 as shown in the figure, and storing them as new sample data in database 530. Alternatively, data can be collected directly from the I / O interface 512 without going through the client device 540, using the input data and output results of the input I / O interface 512 as shown in the figure, and storing them as new sample data in database 530.

[0128] It is worth noting that Figure 5 is merely a schematic diagram of a system architecture provided in an embodiment of this application. The positional relationships between the devices, components, modules, etc., shown in the figure do not constitute any limitation. For example, in Figure 5, the data storage system 550 is an external memory relative to the execution device 510. In other cases, the data storage system 550 can also be placed in the execution device 510. It should be understood that the aforementioned execution device 510 can be deployed in the client device 540.

[0129] From the inference side of the model:

[0130] In this embodiment, the computing module 511 of the execution device 510 can obtain the code stored in the data storage system 550 to implement the steps related to the model reasoning process in this embodiment.

[0131] In this embodiment of the application, the computing module 511 of the execution device 510 may include hardware circuits (such as application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), general-purpose processors, digital signal processors (DSPs), microprocessors or microcontrollers, etc.) or combinations of these hardware circuits. For example, the training device 520 may be a hardware system with instruction execution capabilities, such as a CPU or DSP, or a hardware system without instruction execution capabilities, such as an ASIC or FPGA, or a combination of the aforementioned hardware systems without instruction execution capabilities and hardware systems with instruction execution capabilities.

[0132] Specifically, the computing module 511 of the execution device 510 can be a hardware system with the function of executing instructions. The steps related to the model inference process provided in this application embodiment can be software code stored in the memory. The computing module 511 of the execution device 510 can obtain the software code from the memory and execute the obtained software code to implement the steps related to the model inference process provided in this application embodiment.

[0133] It should be understood that the computing module 511 of the execution device 510 can be a combination of a hardware system without the function of executing instructions and a hardware system with the function of executing instructions. Some steps related to the model reasoning process provided in the embodiments of this application can also be implemented by the hardware system in the computing module 511 of the execution device 510 without the function of executing instructions, which is not limited here.

[0134] From the training side of the model:

[0135] In this embodiment, the training device 520 can obtain the code stored in the memory (not shown in Figure 5, which can be integrated into the training device 520 or deployed separately from the training device 520) to implement the steps related to model training in this embodiment.

[0136] In this embodiment of the application, the training device 520 may include hardware circuits (such as application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), general-purpose processors, digital signal processors (DSPs), microprocessors or microcontrollers, etc.) or combinations of these hardware circuits. For example, the training device 520 may be a hardware system with instruction execution capabilities, such as a CPU or DSP, or a hardware system without instruction execution capabilities, such as an ASIC or FPGA, or a combination of the aforementioned hardware systems without instruction execution capabilities and hardware systems with instruction execution capabilities.

[0137] It should be understood that the training device 520 can be a combination of a hardware system without the function of executing instructions and a hardware system with the function of executing instructions. Some steps related to the training of the neutralization model provided in the embodiments of this application can also be implemented by the hardware system in the training device 520 without the function of executing instructions, which is not limited here.

[0138] II. Cloud services providing synthesis functionality provided by the server:

[0139] In one possible implementation, the server can provide composition services to the client side through an application programming interface (API).

[0140] In this process, the terminal device can send relevant parameters (such as input data) to the server through the API provided by the cloud. The server can obtain the processing result (such as generated data) based on the received parameters and return the processing result to the terminal.

[0141] The description of the terminal and server can be found in the above embodiments, and will not be repeated here.

[0142] Figure 6 illustrates the process of using a synthetic function cloud service provided by a cloud platform.

[0143] 1. Activate and purchase content moderation services.

[0144] 2. Users can download the software development kit (SDK) corresponding to the content moderation service. Cloud platforms usually provide multiple development versions of the SDK for users to choose from according to their development environment needs, such as JAVA version SDK, Python version SDK, PHP version SDK, Android version SDK, etc.

[0145] 3. After downloading the corresponding version of the SDK to their local machine according to their needs, users can import the SDK project into their local development environment, configure and debug it in the local development environment, and develop other functions in the local development environment, thus forming an application that integrates the capabilities of composite functional classes.

[0146] 4. When a composition application is used, it can trigger an API call for the composition function when the composition function is required. When the application triggers the composition function, it sends an API request to the running instance of the composition function service in the cloud environment. The API request carries the input data, which is processed by the running instance in the cloud environment to obtain the processing result (such as generated data).

[0147] 5. The cloud environment returns the processing result to the application, thus completing a synthesis function service call.

[0148] In addition to applications and cloud services, the implementation of this application can also be in a large model inference acceleration library or a large model application SDK.

[0149] To better understand the solutions of the embodiments of this application, the following uses text generation as an example and combines Figures 2 to 4 to briefly introduce the possible application scenarios of the embodiments of this application.

[0150] Figure 3 illustrates a natural language processing (NLP) system, which includes user devices and data processing devices. The user devices include smart terminals such as mobile phones, personal computers, or information processing centers. The user devices are the initiators of natural language data processing, acting as the initiators of requests such as language question answering or queries; typically, users initiate requests through their user devices.

[0151] The aforementioned data processing equipment can be cloud servers, network servers, application servers, management servers, or other devices or servers with data processing capabilities. The data processing equipment receives queries / voice / text from smart terminals via an interactive interface, then performs language data processing through a storage device and a data processing processor, employing methods such as machine learning, deep learning, search, reasoning, and decision-making. The processing results are then fed back to the user device. The storage device in the data processing equipment can be a general term, including local storage and a database storing historical data. The database can be located on the data processing equipment or on other network servers.

[0152] In the natural language processing system shown in Figure 3, the user device can receive instructions from the user. For example, the user device can receive a piece of text input by the user and then send a request to the data processing device, so that the data processing device can perform natural language processing applications (such as natural language generation, text classification, text reasoning, named entity recognition, translation, etc.) on the piece of text obtained by the user device, thereby obtaining the processing results of the corresponding natural language processing applications on the piece of text (such as prediction results, classification results, reasoning results, named entity recognition results, translation results, etc.).

[0153] In this embodiment of the application, the user equipment can receive instructions from the user. For example, the user equipment can receive a piece of text input by the user (e.g., input data) and then send a request to the data processing device, so that the data processing device performs a natural language processing application (e.g., text synthesis) on the piece of text obtained by the user equipment, thereby obtaining the processing result (e.g., generated data) of the corresponding natural language processing application on the piece of text.

[0154] The text is shown in Figure 3. The data processing device can process the above-mentioned text data using the method provided in the embodiments of this application.

[0155] Figure 4 illustrates another natural language processing system. In Figure 4, the user equipment directly acts as a data processing device. This user equipment can directly receive input from the user and process it directly by the hardware of the user equipment itself. The specific process is similar to that in Figure 3, and can be referred to the description above, so it will not be repeated here.

[0156] The processors in Figures 3 and 4 can perform data training / machine learning / deep learning using neural network models or other models, and use the models finally trained or learned from the data (such as the natural language models in the embodiments of this application) to perform natural language processing applications (such as program synthesis, etc.) on text data (such as the input data text described in the embodiments of this application) to obtain the corresponding processing results.

[0157] Since the embodiments of this application involve a large number of neural network applications, for ease of understanding, the relevant terms and concepts such as neural networks involved in the embodiments of this application will be introduced below.

[0158] (1) Neural Network

[0159] A neural network can be composed of neural units, which can be defined as a computational unit that takes xs (i.e., input data) and an intercept of 1 as input. The output of this computational unit can be:

[0160] Where s = 1, 2, ..., n, where n is a natural number greater than 1, Ws is the weight of xs, and b is the bias of the neural unit. f is the activation function of the neural unit, used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into an output signal. The output signal of this activation function can be used as the input of the next convolutional layer, and the activation function can be the sigmoid function. A neural network is a network formed by connecting multiple of the above-mentioned individual neural units together, that is, the output of one neural unit can be the input of another neural unit. The input of each neural unit can be connected to the local receptive field of the previous layer to extract the features of the local receptive field, which can be a region composed of several neural units.

[0161] (2) Transformer layer

[0162] The neural network includes an embedding layer and at least one transformer layer. The at least one transformer layer can be N transformer layers (N being an integer greater than 0). Each transformer layer includes sequentially adjacent attention layers, add and normalize layers, feed-forward layers, and add and normalize layers. In the embedding layer, the current input is embedded to obtain multiple embedding vectors. In the attention layer, P input vectors are obtained from the layer above the first transformer layer. Using any first input vector among the P input vectors as the center, intermediate vectors corresponding to the first input vector are obtained based on the correlation between each input vector within a preset attention window and the first input vector. This process determines P intermediate vectors corresponding to the P input vectors. In the pooling layer, the P intermediate vectors are merged into Q output vectors, where the multiple output vectors obtained from the last transformer layer are used as feature representations of the current input.

[0163] (3) Attention mechanism

[0164] Attention mechanisms mimic the internal processes of biological observation—aligning internal experience with external senses to increase the precision of observation in specific areas. They enable the rapid sifting of high-value information from a large volume of data using limited attentional resources. Attention mechanisms can quickly extract important features from sparse data and are therefore widely used in natural language processing tasks, particularly machine translation. Self-attention mechanisms, an improvement on attention mechanisms, reduce reliance on external information and are better at capturing the internal correlations of data or features. The core idea of ​​attention mechanisms can be rewritten as follows:

[0165] In this formula, Lx = ||Source|| represents the length of the Source. The meaning is that the elements in the Source are imagined as a series of data pairs. Given a Query element in the Target, the similarity or relevance between the Query and each Key is calculated to obtain the weight coefficient of the Value corresponding to each Key. Then, the Values ​​are weighted and summed to obtain the final Attention value. Therefore, the Attention mechanism essentially performs a weighted sum of the Values ​​of the elements in the Source, while the Query and Key are used to calculate the weight coefficients of their corresponding Values. Conceptually, Attention can be understood as selectively filtering a small amount of important information from a large amount of information and focusing on this important information, ignoring most of the unimportant information. The focusing process is reflected in the calculation of the weight coefficients; the larger the weight, the more focused it is on its corresponding Value. That is, the weight represents the importance of the information, and the Value is the corresponding information. Self-attention can be understood as intra attention. The attention mechanism occurs between the elements of the Target (Query) and all elements of the Source. Self-attention refers to the attention mechanism that occurs between elements within the Source or between elements within the Target. It can also be understood as the attention calculation mechanism in the special case where Target = Source. The specific calculation process is the same, only the calculation object changes.

[0166] (4) Natural Language Processing (NLP)

[0167] Natural language is human language, and Natural Language Processing (NLP) is the processing of human language. NLP is a systematic process of analyzing, understanding, and extracting information from text data in an intelligent and efficient manner. By using NLP and its components, we can manage very large amounts of text data, perform numerous automated tasks, and solve a wide variety of problems, such as automatic summarization, machine translation (MT), named entity recognition (NER), relation extraction (RE), information extraction (IE), sentiment analysis, speech recognition, question answering systems, and topic segmentation, among others.

[0168] (5) Pre-trained language model

[0169] A pre-trained language model is a natural language sequence encoder that encodes each word in a natural language sequence into a vector representation for prediction tasks. Its training consists of two phases. In the pre-training phase, the model is trained on a large-scale unsupervised text environment to learn word representations. In the fine-tuning phase, the model is initialized using the parameters learned in the pre-training phase and then trained on downstream tasks such as text classification and sequence labeling with fewer steps, successfully transferring the semantic information obtained in pre-training to these downstream tasks.

[0170] (6) Autoregressive language model

[0171] Autoregressive language models are models that can predict the next word that might follow (e.g., "good") based on a given context (e.g., "the phone is good"). Typically, these models predict the word in the context on the right given the preceding text on the left, but they can also predict a word in the middle given the context on both the left and right sides.

[0172] (7) Reasoning / Deployment: The forward computation process of a neural network.

[0173] (8) Large Language Model: A large language model is a natural language processing model trained on large-scale data, typically with billions or tens of billions of parameters. These models learn the general features of language by studying a large amount of text data during the pre-training stage, and can then be fine-tuned on downstream tasks to adapt to the needs of specific tasks.

[0174] (9) Backpropagation algorithm

[0175] Convolutional neural networks can employ backpropagation (BP) to correct the parameters in the initial super-resolution model during training, thereby reducing the reconstruction error loss. Specifically, forward propagation of the input signal to the output generates an error loss; this error loss information is then propagated back to update the parameters in the initial super-resolution model, leading to convergence of the error loss. The backpropagation algorithm is an error-loss-driven backpropagation process aimed at obtaining the optimal parameters of the super-resolution model, such as the weight matrix.

[0176] (10) Loss Function

[0177] In training a deep neural network, to ensure the output closely approximates the desired predicted value, we compare the network's prediction with the target value. Based on the difference, we update the weight vector of each layer (usually pre-configuring parameters before the initial update). For example, if the prediction is too high, the weight vector is adjusted to predict a lower value. This adjustment continues until the deep neural network predicts the target value or a value very close to it. Therefore, we need to predefine "how to compare the difference between the predicted and target values," which is the loss function or objective function. These are important equations used to measure the difference between the predicted and target values. Taking the loss function as an example, a higher output value (loss) indicates a greater difference, and training the deep neural network becomes a process of minimizing this loss.

[0178] (11) Fine-tuning: a technique commonly used in transfer learning, mainly used to transfer knowledge learned from the source dataset to the target dataset.

[0179] (12) Prompt: A prompt is a command, question, or statement that can be used to guide or instruct a language model to generate specific text output. The prompt is the starting point for the user's interaction with the language model. It tells the model the user's intention and expects the model to respond in a meaningful and relevant way. The prompt of a large language model mainly includes prompts, contextual information, tasks, output format hints, constraints, sample output, and closing remarks.

[0180] (13) Knowledge Hallucination: This refers to the phenomenon where the content generated by the model is inconsistent with real-world facts or user input. Large model hallucinations can be divided into factual hallucinations and faithfulness hallucinations. Factual hallucinations refer to the inconsistency between the content generated by the model and verifiable real-world facts. Faithfulness hallucinations refer to the inconsistency between the content generated by the model and the user's instructions or context.

[0181] (14) Top-k search results: the top k search results.

[0182] (15) Query: The query statement entered by the user.

[0183] (16) Vector Recall: This means that both query and material are represented as vector patterns. During the retrieval process, this vector is used directly for recall, that is, to find the vector in the library that is closest to the query vector.

[0184] (17) Keyword Recall: Direct recall based on the keywords in the user's query. A widely used technique is the inverted index. Also known as a reverse index, inverted archive, or reverse archive, it is an indexing method used to store the mapping of a word's location within a document or set of documents in a full-text search. Through the inverted index, one can quickly locate the list of documents containing a word, its position within the document, word frequency, and other information for information analysis.

[0185] (18) Ranking: The recall results are reordered to obtain more accurate relevance ranking results.

[0186] (19) LLM+prompt: A common reasoning method for large language models. Based on the powerful few-shot and zero-shot learning capabilities of large language models, the model completes specific tasks by constructing a prompt.

[0187] (20) Textual implication: Natural language reasoning aims to determine the relationship between two input sentences. The corresponding relationships are implication, neutrality, and contradiction.

[0188] (21) Sigmoid: The sigmoid function is a common sigmoid function in biology, also known as the sigmoid growth curve. Due to its monotonically increasing and inverse monotonically increasing properties, the sigmoid function is often used as an activation function in neural networks to map variables to the range of 0 to 1.

[0189] (22) Robustness: refers to the characteristic of a control system to maintain certain other performances under certain (structural, size) parameter perturbations, which is a manifestation of the system's anti-interference ability.

[0190] With the advancement of technology and the accumulation of data, large language models (LLMs) have developed rapidly. Large language models have a massive number of parameters, typically reaching billions or even hundreds of billions, enabling them to learn richer and more complex language structures and semantic features.

[0191] Large language models possess powerful language understanding and generation capabilities, broad knowledge coverage, and good adaptability and scalability, and are widely used in scenarios such as text generation, dialogue systems, educational assistance, and content creation. However, due to limitations in training methods and costs, they still have problems such as, but not limited to, knowledge illusion, difficulty in updating knowledge, and insufficient knowledge in specific domains.

[0192] To address the aforementioned issues, the mainstream solution in the industry is retrieval augmented generation (RAG). This method effectively alleviates the problems of large language models by retrieving external knowledge bases. The RAG system can retrieve relevant knowledge fragments based on the user's query request and input the search results, query request, and instruction prompts into the LLM to generate a response.

[0193] However, due to the diversity of user input queries, there may be problems such as unclear intent and complex queries, and the search results may be irrelevant, incomplete, or unanswerable, resulting in poor LLM generation performance.

[0194] To address the aforementioned problems, this application provides a text generation method. The model training method of this application embodiment will be described in detail below with reference to the accompanying drawings.

[0195] Referring to Figure 7, which is a flowchart of a text generation method provided in an embodiment of this application, the text generation method provided in this application may include steps 701 to 704, which will be described in detail below.

[0196] 701. Obtain the first text;

[0197] The first text can be a question that needs to be answered.

[0198] For example, the problem of the first text user input.

[0199] For example, the first text is text described using natural language.

[0200] 702. Based on the first text, determine multiple first search results related to the first text;

[0201] In one possible implementation, retrieval augmented generation (RAG) can be used to retrieve text related to the first text from external sources (i.e., using capabilities and data outside of the LLM). For example, text that is highly relevant to the first text can be retrieved. This retrieval result can be used as auxiliary information for subsequent LLM processing of the first text (i.e., it is used as input to the LLM, just like the first text).

[0202] The retrieval process described above can also be described as a recall process. For example, based on a user-input question (the first text), relevant documents can be recalled from the document library. The recalled documents are then sorted, and the top-k documents are selected.

[0203] It should be understood that the first text can be modified and rewritten before the search is performed.

[0204] Optionally, the recall methods are not limited to vector recall, keyword recall, or a combination of vector and keyword recall. The document library is an external knowledge base, requiring pre-construction and the generation of the necessary indexes based on its documents. The recalled documents can be re-ranked, retaining the top-k documents. The number of recalled documents is generally greater than the final number of retained documents, ranging from tens to thousands. The ranking methods are not limited to tree models or deep model-based ranking such as BGEranker. Considering the latency of the ranking module and the pressure on the subsequent LLM generation module, the Top-k value is often relatively small, typically between 1 and 5.

[0205] For example, an offline document library and corresponding index can be built. Specifically, the latest encyclopedia webpage data can be downloaded, parsed, cleaned, and stored to obtain the encyclopedia document library. The open-source semantic representation model BGE-large-en-v1.5 is downloaded to build a vector index for the document library, and a keyword index is built based on the open-source retrieval framework Anserini. Based on the user's input question, relevant documents are retrieved from the document library, and the top-20 documents retrieved by keywords and the top-20 documents retrieved by vectors are selected. All retrieval results are transmitted to the ranking module, which uses the open-source ranking model BGE-reranker-large to select the top-5 documents with the highest scores.

[0206] In one possible implementation, the first search result can be obtained by optimizing the result of searching the first text. The optimization process will be described in subsequent embodiments.

[0207] 703. Obtain the first quality evaluation for each of the first search results;

[0208] Existing RAG systems rely on high-quality search results. When the search results are of poor quality, the final generated result is poor. In this embodiment, the search results can be quality evaluated, and the quality evaluation result is used as input to the language model. When processing the first text and the search results, the language model can know the quality evaluation of the search results. By allowing the language model to perceive the quality of the search results, the language model can more effectively use the information of the search results to generate responses, thereby improving the generation effect of the language model.

[0209] Furthermore, since the language model does not need to judge the quality of the retrieval results during the generation process (quality evaluation is used as input to the language model), the generation pressure on the language model is reduced.

[0210] The quality assessment of embodiments of this application will be described next.

[0211] In one possible implementation, the first quality assessment includes one or more of the following assessments: the answerability of the first search result as a response to the first text; the factuality, authority, or timeliness of the first search result; the timeliness of the first search result; whether there is a contradiction between the first search result and other first search results, or a contradiction between the first search result and other first search results.

[0212] In this context, factual accuracy assesses whether the search results violate common sense, facts, and relevant standards and norms. Authority assesses the factual accuracy, authority, and timeliness of the search results. Timeliness assesses whether the search results are outdated or belong to an obsolete version.

[0213] Quality assessment can be described from at least one of three dimensions: the relationship between the input question (first text) and the search results, a single search result, and the relationships between search results.

[0214] For example, the answerability of using the first search result as a response to the first text can be evaluated by examining the relationship between the input question and the search results.

[0215] For example, the scoring of search results by the reuse sorting module (that is, reusing the score of each search result to calculate responsiveness) can be converted into a score between 0 and 1 by adding a Sigmoid module. The responsiveness calculation of the input question and a single search result can be implemented based on LLM combined with a prompt. The prompt prompts LLM to score responsiveness, and the score range can be between 0 and 1.

[0216] For example, when evaluating a single search result, its factual validity can be assessed by searching a high-quality knowledge base, with a score of 0 or 1. The authority of a single search result is primarily determined by its source and comparison with results from general search engines; the authority score can be converted into a confidence level between 0 and 1. The timeliness of a single search result considers the document's date and version; the date score is obtained by comparing it with similar results from general search engines, and the timeliness score can be converted into a score between 0 and 1.

[0217] For example, when evaluating the relationships between search results, consistency is the primary consideration, i.e., whether there are contradictory statements. First, the corresponding documents are segmented into sentences to identify the statements that support the arguments. Then, a Textual Entailment Model (NLI model) is used to determine whether there are contradictions between the arguments. The consistency index score is 0 or 1; 0 indicates a contradiction, and 1 indicates otherwise. For instance, if a search result contradicts other search results, the search result with the lowest quality rating in other dimensions among those contradictory results can be removed (i.e., its score is set to 0).

[0218] In existing technologies, the quality assessment of search results only uses the relevance between the input question and the search results. When the search results are relevant but cannot answer the question, the generation effect of the language model will still be poor, especially in question-answering tasks, where considering only relevance is insufficient. The embodiments of this application, however, can evaluate the quality of search results from multiple dimensions, resulting in a more accurate assessment.

[0219] In one possible implementation, after obtaining a quality assessment of the search results, the search results can be optimized based on the quality assessment to obtain higher quality search results.

[0220] In one possible implementation, multiple second search results related to the first text can be determined based on the first text; a second quality evaluation can be obtained for each second search result; and the multiple second search results can be optimized based on the second quality evaluation to obtain the multiple first search results.

[0221] In one possible implementation, optimizing the plurality of second search results based on the second quality assessment includes:

[0222] Remove the second search results from the multiple second search results whose second quality evaluation does not meet the preset conditions.

[0223] Inappropriate search results are filtered out in the following ways: 1) If the relevance or responsiveness scores are low, the corresponding search results will be deleted; 2) Search results with poor factual accuracy, authority, or timeliness will be filtered to prevent them from affecting the final generated results; 3) If there are inconsistencies among multiple search results, the search results with relatively poor quality assessment will be removed.

[0224] When the number of filtered search results is small, a knowledge supplementation module can be executed to expand the relevant knowledge. Specifically, in one possible implementation, when the number of the multiple second search results after filtering is less than a preset value, the multiple second search results after filtering can be supplemented.

[0225] For example, as shown in Figure 11, a specific implementation method is illustrated below:

[0226] The relevance of search results to the input question is a fundamental metric. Only when the relevance score exceeds a set threshold of 0.8 can other metrics be further optimized; otherwise, the search result will be filtered. Once the relevance requirement is met, the answerability metric of the current search result will be considered. This embodiment prioritizes simple questions that can be answered with a single document, temporarily ignoring complex questions requiring multiple documents. Therefore, answerability primarily considers whether each search result helps answer the question, implemented using LLM+prompt. Search results that do not meet the answerability requirements will be deleted through the knowledge filtering module. For search results that meet the answerability requirements, further evaluation will determine if they conflict with other search results. If a conflict exists, the search result with the better evaluated metrics will be retained. Finally, the number of search results will be assessed. If the number is low, knowledge supplementation based on, but not limited to, search engines will be implemented.

[0227] The embodiments of this application can dynamically optimize search results based on evaluation information, promptly correct low-quality search results, and improve the fault tolerance and robustness of the question-answering system.

[0228] The above methods allow for targeted optimization of search results, encompassing capabilities such as knowledge supplementation, correction, simplification, and summarization. These optimizations can be performed in multiple rounds to improve the quality of search results and enhance the overall user experience of the RAG system. Furthermore, they can effectively improve the generation performance of large models in scenarios with poor search results.

[0229] It should be understood that the decision to terminate search result optimization can be based on the evaluation results. Search result optimization can be multi-round, and the termination conditions for the optimization process are not limited to the corresponding search metric reaching a threshold or the number of optimization rounds reaching a certain threshold. The evaluation information of the search results can be used to control the initiation and termination of self-optimization of search results.

[0230] When the search result optimization is terminated, the evaluation content of the multi-dimensional search results can be converted into a natural language description and used in the subsequent construction process of the LLM input prompt. The conversion method is not limited to template generation, fine-tuning of small models with generation capabilities, such as BART, T5, etc., or the method of combining LLM with prompt.

[0231] 704. Input the first text, the plurality of first search results, and the first quality assessment into the language model to obtain the response text of the first text.

[0232] In one possible implementation, the first quality assessment is described in natural language, and a prompt containing the first text, the plurality of first search results, and the first quality assessment is input into a language model to obtain a response text for the first text.

[0233] For example, quality assessments can be converted into natural language descriptions using LLM combined with prompts or templates and passed to the prompt building module. The resulting output (i.e., the response text) can then be presented to the user.

[0234] Referring to Figure 8, which is a specific flowchart of an embodiment of this application.

[0235] Figure 9 is a structural diagram of a question-answering system according to an embodiment of this application. The upper half of Figure 9 shows the structural diagram of the multi-dimensional retrieval result evaluation framework proposed in this embodiment, while the lower half shows the structural diagram of retrieval result knowledge refinement. This embodiment mainly improves the retrieval result optimization of the question-answering system. General RAG systems do not have this module; instead, they directly transmit the retrieval results to LLM.

[0236] The multi-dimensional retrieval result evaluation framework proposed in this application includes three dimensions: evaluation of the relationship between the input query (input question) and Top-k retrieval results, evaluation of individual retrieval results, and evaluation of the relationship between Top-k retrieval results. The evaluation of each dimension is explained below:

[0237] (1) Evaluation of the relationship between the input query (input question) and the Top-k search results: This mainly includes relevance and answerability. Relevance is an evaluation indicator considered by most general RAG systems. It mainly measures the degree of association between the input query and each search result and is the basis for evaluating search results. Answerability evaluates whether the search results can answer the user's input question. It can be evaluated for each search result to verify the contribution of each search result to answering the question. It can also be evaluated whether the entire Top-k search results can answer the input question, thereby verifying whether the search results meet the completeness requirement.

[0238] (2) Evaluation of individual search results: This mainly includes indicators such as factual accuracy, authority, and timeliness. Factual accuracy assesses whether the search results violate common sense, facts, and relevant standards and norms. Authority assesses the factual accuracy, authority, or timeliness of the search results. Timeliness assesses whether the search results are outdated or belong to an obsolete version.

[0239] (3) Evaluation of the relationship between Top-k search results: mainly consistency evaluation, that is, verifying whether there are contradictions or conflicts between the search results.

[0240] The knowledge refinement method for retrieval results proposed in this application can be optimized in a targeted manner by combining the evaluation information of the retrieval results. It mainly includes the following modules: knowledge simplification, knowledge supplementation, and knowledge filtering. The descriptions of each functional module are as follows:

[0241] (1) Knowledge simplification: Simplify a single search result, including removing parts with low relevance and summarizing the overall content. This is mainly used to further optimize the search results when they meet the requirements.

[0242] (2) Knowledge supplementation: Expand the search results by connecting to external knowledge graphs or search engines to solve problems such as irrelevant search results, incomplete answers, and few search results.

[0243] (3) Knowledge Filtering: Inappropriate search results are filtered out, mainly in the following situations: 1) Search results with low scores in relevance or responsiveness are deleted; 2) Search results with poor factual accuracy, authority, or timeliness are filtered to prevent them from affecting the final generated results; 3) Inconsistencies exist among multiple search results, those with relatively poor quality assessments are removed. When there are few filtered search results, the knowledge supplementation module can be executed to expand relevant knowledge.

[0244] One implementation of this application is a large-model-based RAG system, primarily used for question-and-answering of encyclopedic knowledge. As shown in Figure 10, it mainly includes user-input questions, a document library, a text retrieval module, a multi-dimensional retrieval result evaluation module, a retrieval result knowledge refinement module, a prompt construction module, and an LLM generation module. The user inputs their question into the RAG system. The text retrieval module retrieves relevant documents from the document library. Based on the multi-dimensional retrieval result evaluation module and the retrieval result knowledge refinement module, the retrieved content is optimized and its quality assessed. This information is then transmitted to the Prompt construction module to generate a prompt, and finally, the LLM generates the final answer.

[0245] Referring to Figure 12, which is a schematic diagram of the structure of a text generation device provided in an embodiment of this application, as shown in Figure 12, a text generation device 1200 provided in an embodiment of this application includes:

[0246] Module 1201 is used to acquire the first text;

[0247] For a detailed description of the acquisition module 1201, please refer to the description of the embodiment corresponding to Figure 7 in the above embodiments. The similarities will not be repeated here.

[0248] The processing module 1202 is configured to determine multiple first search results related to the first text based on the first text; obtain a first quality evaluation for each first search result; and input the first text, the multiple first search results, and the first quality evaluation into a language model to obtain a response text for the first text.

[0249] For a detailed description of the processing module 1202, please refer to the description of the embodiment corresponding to Figure 7 in the above embodiments. The similarities will not be repeated here.

[0250] In one possible implementation, the first quality assessment includes one or more of the following assessments:

[0251] The first search result is used as the answerability of the first text response;

[0252] The factual accuracy, authority, or timeliness of the first search result;

[0253] Is there a contradiction between the first search result and other first search results, or is there a contradiction between the first search result and other first search results?

[0254] In one possible implementation, the first quality assessment is described using natural language, and the processing module 1202 is specifically used for:

[0255] The prompt, which includes the first text, the plurality of first search results, and the first quality assessment, is input into the language model to obtain the response text for the first text.

[0256] In one possible implementation, the processing module 1202 is specifically used for:

[0257] Based on the first text, determine multiple second search results related to the first text;

[0258] Obtain a second quality assessment for each of the second search results;

[0259] Based on the second quality assessment, the plurality of second search results are optimized to obtain the plurality of first search results.

[0260] In one possible implementation, the processing module 1202 is specifically used for:

[0261] Remove the second search results from the multiple second search results whose second quality evaluation does not meet the preset conditions.

[0262] In one possible implementation, the processing module 1202 is further configured to:

[0263] If the number of the plurality of second search results after removal is less than a preset value, the plurality of second search results after removal will be supplemented.

[0264] The following describes an execution device provided in an embodiment of this application. Please refer to Figure 13, which is a schematic diagram of the structure of an execution device provided in an embodiment of this application. Specifically, the execution device 1300 includes: a receiver 1301, a transmitter 1302, a processor 1303, and a memory 1304 (the number of processors 1303 in the execution device 1300 can be one or more; Figure 13 shows one processor as an example). The processor 1303 may include an application processor 13031 and a communication processor 13032. In some embodiments of this application, the receiver 1301, transmitter 1302, processor 1303, and memory 1304 can be connected via a bus or other means.

[0265] Memory 1304 may include read-only memory and random access memory, and provides instructions and data to processor 1303. A portion of memory 1304 may also include non-volatile random access memory (NVRAM). Memory 1304 stores processor and operation instructions, executable modules, or data structures, or subsets thereof, or extended sets thereof, wherein the operation instructions may include various operation instructions for implementing various operations.

[0266] Processor 1303 controls the operation of the execution device. In specific applications, the various components of the execution device are coupled together through a bus system, which may include not only the data bus, but also power buses, control buses, and status signal buses. However, for clarity, all buses are referred to as the bus system in the diagram.

[0267] The methods disclosed in the embodiments of this application can be applied to or implemented by the processor 1303. The processor 1303 can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by the integrated logic circuits in the hardware of the processor 1303 or by instructions in software form. The processor 1303 can be a general-purpose processor, a digital signal processor (DSP), a microprocessor, or a microcontroller, and may further include an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The processor 1303 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 1304. Processor 1303 reads the information from memory 1304 and, in conjunction with its hardware, completes the steps involved in the model inference process described above.

[0268] Receiver 1301 can be used to receive input digital or character information, and to generate signal inputs related to the settings and function control of the execution device. Transmitter 1302 can be used to output digital or character information through the first interface; transmitter 1302 can also be used to send instructions to the disk group through the first interface to modify the data in the disk group; transmitter 1302 may also include a display device such as a display screen.

[0269] This application embodiment also provides a server device. Please refer to Figure 14. Figure 14 is a schematic diagram of a server structure provided in this application embodiment. Specifically, the server 1400 is implemented by one or more servers. The server 1400 can vary significantly due to different configurations or performance. It may include one or more central processing units (CPUs) 1414 (e.g., one or more processors) and memory 1432, and one or more storage media 1430 (e.g., one or more mass storage devices) for storing application programs 1442 or data 1444. The memory 1432 and storage media 1430 can be temporary or persistent storage. The program stored in the storage media 1430 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Furthermore, the CPU 1414 may be configured to communicate with the storage media 1430 and execute the series of instruction operations in the storage media 1430 on the server 1400.

[0270] Server 1400 may also include one or more power supplies 1426, one or more wired or wireless network interfaces 1450, one or more input / output interfaces 1458; or, one or more operating systems 1441, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.

[0271] In this embodiment, the central processing unit 1414 is used to execute the text generation method in the above embodiment.

[0272] This application also provides a computer program product that, when run on a computer, causes the computer to perform steps as performed by the aforementioned execution device, or causes the computer to perform steps as performed by the aforementioned training device.

[0273] This application also provides a computer-readable storage medium storing a program for signal processing, which, when run on a computer, causes the computer to perform steps as performed by the aforementioned execution device, or causes the computer to perform steps as performed by the aforementioned training device.

[0274] The execution device, training device, or terminal device provided in this application embodiment can specifically be a chip. The chip includes a processing unit and a communication unit. The processing unit can be, for example, a processor, and the communication unit can be, for example, an input / output interface, pins, or circuits. The processing unit can execute computer execution instructions stored in the storage unit to cause the chip within the execution device to execute the text generation method described in the above embodiments, or to cause the chip within the training device to execute the text generation method described in the above embodiments. Optionally, the storage unit can be a storage unit within the chip, such as a register or cache. Alternatively, the storage unit can be a storage unit located outside the chip within the wireless access device, such as a read-only memory (ROM) or other types of static storage devices capable of storing static information and instructions, such as random access memory (RAM).

[0275] Specifically, please refer to Figure 15, which is a schematic diagram of a chip structure provided in an embodiment of this application. The chip can be represented as a neural network processor (NPU) 1500. The NPU 1500 is mounted as a coprocessor on the host CPU, and tasks are assigned by the host CPU. The core part of the NPU is the arithmetic circuit 1503, which is controlled by the controller 1504 to extract matrix data from the memory and perform multiplication operations.

[0276] In some implementations, the arithmetic circuit 1503 internally includes multiple processing engines (PEs). In some implementations, the arithmetic circuit 1503 is a two-dimensional pulsating array. The arithmetic circuit 1503 can also be a one-dimensional pulsating array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit 1503 is a general-purpose matrix processor.

[0277] For example, suppose we have an input matrix A, a weight matrix B, and an output matrix C. The arithmetic circuit retrieves the corresponding data of matrix B from the weight memory 1502 and caches it in each PE of the arithmetic circuit. The arithmetic circuit retrieves the data of matrix A from the input memory 1501 and performs matrix operations with matrix B. The partial result or the final result of the obtained matrix is ​​stored in the accumulator 1508.

[0278] Unified memory 1506 is used to store input and output data. Weight data is directly transferred to weight memory 1502 via Direct Memory Access Controller (DMAC) 1505. Input data is also transferred to unified memory 1506 via DMAC.

[0279] BIU stands for Bus Interface Unit, which is used for interaction between the AXI bus and the DMAC and the Instruction Fetch Buffer (IFB) 1509.

[0280] The Bus Interface Unit (BIU) 1510 is used by the instruction fetch memory 1509 to fetch instructions from external memory, and also by the memory access controller 1505 to fetch the original data of the input matrix A or the weight matrix B from external memory.

[0281] The DMAC is mainly used to move input data from external memory DDR to unified memory 1506, or to weight data to weight memory 1502, or to input data to input memory 1501.

[0282] The vector computation unit 1507 includes multiple arithmetic processing units that, when needed, further process the output of the computation circuit 1503, such as vector multiplication, vector addition, exponential operations, logarithmic operations, size comparisons, etc. It is mainly used for computation in non-convolutional / fully connected layers of neural networks, such as batch normalization, pixel-level summation, and upsampling of feature planes.

[0283] In some implementations, the vector computation unit 1507 can store the processed output vector in the unified memory 1506. For example, the vector computation unit 1507 can apply a linear function, or a nonlinear function, to the output of the computation circuit 1503, such as linear interpolation of feature planes extracted by a convolutional layer, or, for example, a vector of accumulated values, to generate activation values. In some implementations, the vector computation unit 1507 generates normalized values, pixel-level summed values, or both. In some implementations, the processed output vector can be used as activation input to the computation circuit 1503, for example, for use in subsequent layers of the neural network.

[0284] The instruction fetch buffer 1509 connected to the controller 1504 is used to store the instructions used by the controller 1504;

[0285] Unified memory 1506, input memory 1501, weighted memory 1502, and instruction fetch memory 1509 are all on-chip memories. External memory is proprietary to this NPU hardware architecture.

[0286] The processor mentioned above can be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits used to control the execution of the above program.

[0287] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.

[0288] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0289] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.

[0290] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).

Claims

1. A text generation method, characterized in that, The method includes: Get the first text; Based on the first text, determine multiple first search results related to the first text; Obtain the first quality rating for each of the first search results; The first text, the plurality of first search results, and the first quality assessment are input into a language model to obtain the response text for the first text.

2. The method according to claim 1, characterized in that, The first quality assessment includes one or more of the following assessments: The first search result is used as the answerability of the first text response; The factual accuracy, authority, or timeliness of the first search result; Is there a contradiction between the first search result and other first search results, or is there a contradiction between the first search result and other first search results? 3. The method according to claim 1 or 2, characterized in that, The first quality assessment is described using natural language. The step of inputting the first text, the plurality of first search results, and the first quality assessment into a language model to obtain the response text for the first text includes: The prompt, which includes the first text, the plurality of first search results, and the first quality assessment, is input into the language model to obtain the response text for the first text.

4. The method according to any one of claims 1 to 3, characterized in that, The step of determining multiple first search results related to the first text based on the first text includes: Based on the first text, determine multiple second search results related to the first text; Obtain a second quality assessment for each of the second search results; Based on the second quality assessment, the plurality of second search results are optimized to obtain the plurality of first search results.

5. The method according to claim 4, characterized in that, The optimization of the plurality of second search results based on the second quality assessment includes: Remove the second search results from the multiple second search results whose second quality evaluation does not meet the preset conditions.

6. The method according to claim 5, characterized in that, The method further includes: If the number of the plurality of second search results after removal is less than a preset value, the plurality of second search results after removal will be supplemented.

7. A text generation device, characterized in that, The device includes: The acquisition module is used to acquire the first text. The processing module is used to determine multiple first search results related to the first text based on the first text; Obtain the first quality rating for each of the first search results; The first text, the plurality of first search results, and the first quality assessment are input into a language model to obtain the response text for the first text.

8. The apparatus according to claim 7, characterized in that, The first quality assessment includes one or more of the following assessments: The first search result is used as the answerability of the first text response; The factual accuracy, authority, or timeliness of the first search result; Is there a contradiction between the first search result and other first search results, or is there a contradiction between the first search result and other first search results? 9. The apparatus according to claim 7 or 8, characterized in that, The first quality assessment is described using natural language, and the processing module is specifically used for: The prompt, which includes the first text, the plurality of first search results, and the first quality assessment, is input into the language model to obtain the response text for the first text.

10. The apparatus according to any one of claims 7 to 9, characterized in that, The processing module is specifically used for: Based on the first text, determine multiple second search results related to the first text; Obtain a second quality assessment for each of the second search results; Based on the second quality assessment, the plurality of second search results are optimized to obtain the plurality of first search results.

11. The apparatus according to claim 10, characterized in that, The processing module is specifically used for: Remove the second search results from the multiple second search results whose second quality evaluation does not meet the preset conditions.

12. The apparatus according to claim 11, characterized in that, The processing module is further configured to: If the number of the plurality of second search results after removal is less than a preset value, the plurality of second search results after removal will be supplemented.

13. A computer storage medium, characterized in that, The computer storage medium stores one or more instructions that, when executed by one or more computers, cause the one or more computers to perform the operation of the method according to any one of claims 1 to 6.

14. A computer program product, characterized in that, Includes computer-readable instructions that, when executed on a computer device, cause the computer device to perform the method as described in any one of claims 1 to 6.

15. A system, characterized in that, It includes at least one processor and at least one memory; the processor and the memory are connected via a communication bus and communicate with each other. The at least one memory is used to store code; The at least one processor is used to execute the code to perform the method as described in any one of claims 1 to 6.

16. A chip, characterized in that, It includes at least one processing unit and an interface circuit, the interface circuit being used to provide program instructions or data to the at least one processing unit, the at least one processing unit being used to execute the program instructions to implement the method of any one of claims 1 to 6.

Citation Information

Patent Citations

  • Document question and answer method and system, electronic equipment and storage medium

    CN115905487A

  • Content retrieval method and device, equipment and medium

    CN116501960A

  • Document retrieval method and automatic question and answer method

    CN117573842A

  • Method and system for retrieving statements of information sources and associating a factuality assessment to the statements

    US20090265304A1