Question and answer method and device based on large language model

By generating and executing data processing instructions in the intelligent dialogue system, the answer text of the table question and answer task is optimized, and the problem of correctness dependence on table understanding and processing capabilities in the existing technology is solved, and better table question and answer task execution effect is achieved.

CN119621902AActive Publication Date: 2025-03-14ALIPAY (HANGZHOU) INFORMATION TECH CO LTD

Patent Information

Application Number
CN202411708345.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-26
Publication Date
2025-03-14
Estimated Expiration
2044-11-26

AI Technical Summary

Technical Problem

When performing table question and answer tasks, the accuracy rate of existing intelligent dialogue systems depends on the table understanding and processing capabilities of large language models, resulting in poor results.

Method used

By obtaining the query text input by the user, generating prompt text containing the query text and data processing instructions, inputting a large language model for reasoning, generating data processing instructions, and executing these instructions to optimize the answer text.

Benefits of technology

The accuracy and effectiveness of the intelligent dialogue system in table question and answer tasks is improved, and excessive dependence on table understanding and processing capabilities of large language models is avoided.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119621902A_ABST
    Figure CN119621902A_ABST
Patent Text Reader

Abstract

One or more embodiments of the invention provide a question and answer method and device based on a large language model, and the method comprises the steps: obtaining a query text which is input by a user and corresponds to to-be-processed table data, and generating a prompt text corresponding to the large language model based on the query text; wherein the prompt text comprises a query text and an indication text used for indicating that the answer text can contain a data processing instruction corresponding to the table data; inputting the prompt text into a large language model, and generating an initial answer text corresponding to the query text by the large language model under the guidance of the prompt text; wherein the initial answer text comprises a data processing instruction corresponding to the table data; executing the data processing instruction to obtain a data processing result corresponding to the data processing instruction; and updating the initial answer text based on the data processing result to obtain a final answer text corresponding to the query text, and outputting the final answer text to the user.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] One or more embodiments of the present application relate to the field of artificial intelligence technology, and in particular, to a question-answering method and device based on a large language model. Background Art

[0002] Today, intelligent dialogue systems (IDSs) are widely used in a wide range of fields, including customer service, legal aid, online education, and medical consultation. By simulating human communication, IDSs provide users with services such as question-and-answer and inquiry. Specifically, an IDS is an interactive system developed using artificial intelligence technology. It is designed to understand and answer questions posed by users in natural language and generate concise and clear answers. IDSs are typically based on large language models (LLMs), which understand and answer user questions and generate corresponding answers.

[0003] Table Question Answering (TQA) refers to the ability to automatically answer user questions from structured data (such as Excel spreadsheets and database tables). TQA is very important in various application scenarios, especially when it is necessary to extract information from structured data.

[0004] In practical applications, how to enable intelligent dialogue systems to perform form question-answering tasks and achieve good performance in performing form question-answering tasks is a highly concerned issue. Summary of the Invention

[0005] One or more embodiments of the present application provide the following technical solutions:

[0006] This application provides a question-answering method based on a large language model, the method comprising:

[0007] Obtaining a query text corresponding to the tabular data to be processed, and generating a prompt text corresponding to the large language model based on the query text; wherein the prompt text includes the query text and instruction text for indicating that a data processing instruction corresponding to the tabular data can be generated during reasoning based on the query text;

[0008] Inputting the prompt text into a large language model, and having the large language model perform reasoning based on the query text under the guidance of the prompt text, and generating data processing instructions corresponding to the table data during the reasoning process;

[0009] The data processing instruction is executed to obtain a data processing result corresponding to the data processing instruction, and an answer text corresponding to the query text is further generated based on the data processing result.

[0010] The present application also provides a question-answering device based on a large language model, the device comprising:

[0011] a prompt generation module, which obtains a query text corresponding to the table data to be processed and generates a prompt text corresponding to the large language model based on the query text; wherein the prompt text includes the query text and an instruction text for indicating that a data processing instruction corresponding to the table data can be generated during the reasoning process based on the query text;

[0012] an answer generation module, inputting the prompt text into a large language model, wherein the large language model, under the guidance of the prompt text, performs reasoning based on the query text and generates data processing instructions corresponding to the table data during the reasoning process;

[0013] The table processing module executes the data processing instruction to obtain a data processing result corresponding to the data processing instruction, and further generates an answer text corresponding to the query text based on the data processing result.

[0014] The present application also provides an electronic device, comprising:

[0015] processor;

[0016] a memory for storing processor-executable instructions;

[0017] The processor implements the steps of any of the above methods by running the executable instructions.

[0018] The present application also provides a computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of any of the methods described above.

[0019] In the above technical solution, first, a query text corresponding to the table data to be processed input by the user can be obtained, and a prompt text corresponding to the large language model can be generated based on the query text. The prompt text can include the query text and an instruction text for indicating that data processing instructions corresponding to the table data can be generated in the process of reasoning based on the query text. Then, the prompt text can be input into the large language model, and the large language model, under the guidance of the prompt text, performs reasoning based on the query text and generates data processing instructions corresponding to the table data during the reasoning process. Then, the data processing instructions in the initial answer text can be executed to obtain a data processing result corresponding to the data processing instruction, and based on the data processing result, an answer text corresponding to the query text can be further generated.

[0020] By adopting the above method, the intelligent dialogue system can perform table question and answer tasks, and since data processing instructions corresponding to the table data can be generated, and the data processing results corresponding to the data processing instructions are used to optimize the answer text generated by the large language model in the intelligent dialogue system based on the query text through reasoning, it is possible to avoid the accuracy of table question and answer being completely dependent on the table understanding and processing capabilities of the large language model, thereby ensuring good execution results of the table question and answer task. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The following is a description of the accompanying drawings required for describing the exemplary embodiments, in which:

[0022] Figure 1 It is a schematic diagram of an intelligent dialogue system shown in an exemplary embodiment of the present application.

[0023] Figure 2 This is a schematic diagram of a question-answering process based on a large language model, shown as an exemplary embodiment of the present application.

[0024] Figure 3 This is a flowchart of a question-answering method based on a large language model, shown as an exemplary embodiment of the present application.

[0025] Figure 4 It is a structural diagram of a device shown in an exemplary embodiment of the present application.

[0026] Figure 5 This is a block diagram of a question-answering device based on a large language model, shown as an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0027] The exemplary embodiments will be described in detail herein, with examples thereof being illustrated in the accompanying drawings. When the following description refers to the drawings, identical numbers in different drawings represent identical or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with one or more embodiments of the present application. Instead, they are merely examples consistent with some aspects of one or more embodiments of the present application.

[0028] It should be noted that, in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this application. In some other embodiments, the method may include more or fewer steps than those described in this application. In addition, a single step described in this application may be broken down into multiple steps for description in other embodiments; and multiple steps described in this application may be combined into a single step for description in other embodiments.

[0029] Intelligent dialogue systems simulate human communication to provide users with services such as question-and-answer and query services. Specifically, an intelligent dialogue system is an interactive system developed using artificial intelligence technology. It is designed to understand and answer questions posed by users in natural language and generate concise and clear answers. Intelligent dialogue systems are typically based on large language models, which understand and answer user questions and generate corresponding answers.

[0030] Large language models are deep learning models trained using large amounts of text data. They can be used to generate natural language text or understand its meaning. Large language models can handle a variety of natural language tasks, such as text classification, named entity recognition, question-answering, and conversation, and are an important path to artificial intelligence.

[0031] In the field of natural language processing, large-scale text datasets are often referred to as corpuses. Corpuses can contain a variety of text data, such as literary works, academic papers, legal documents, news reports, everyday conversations, emails, and online forum posts. By learning from the text data in a corpus, large language models can acquire and understand the patterns and regularities of natural language, enabling effective processing and generation of human language.

[0032] Large language models typically use the Transformer architecture, meaning they are deep learning models based on the Transformer architecture. Transformer-based deep learning models are a type of neural network model that excels in fields like natural language processing.

[0033] Transformer is a neural network model used for sequence-to-sequence modeling. Transformer does not rely on recursive structures and can parallelize training and inference, speeding up model processing. In deep learning models based on the Transformer architecture, a multi-layer Transformer encoder is typically used to extract features from the input sequence, and a Transformer decoder is used to convert the extracted features into an output sequence. At the same time, such models typically also use a self-attention mechanism to capture long-distance dependencies in the input sequence, as well as residual connections and regularization methods to accelerate training and improve model performance.

[0034] A pretrained model is a large language model pretrained on large amounts of unlabeled text data. Pretrained models are general-purpose models; they are not designed or optimized for specific tasks. To adapt pretrained models to specific application scenarios and task requirements, they require fine-tuning to improve their performance on specific tasks. The large language model that is ultimately put into use is typically a pretrained model that has been further fine-tuned, performing supervised learning on labeled text data. Pretraining and fine-tuning are complementary processes: pretraining enables the model to acquire broad language understanding capabilities, while fine-tuning makes the model more specialized and accurate for specific tasks.

[0035] In other words, the training process of a large language model can be divided into two stages: pre-training and fine-tuning. During the pre-training stage, unsupervised learning (e.g., self-supervised learning) can be used on large-scale, unlabeled text datasets (e.g., online encyclopedias, online articles, books, etc.). Specifically, the model can predict missing parts or the next word based on the context, learn statistical laws such as semantics and syntax, and language structure. Backpropagation and optimization algorithms (e.g., gradient descent) are used to minimize prediction losses, iteratively update model parameters, and gradually improve the model's understanding of language. During the fine-tuning phase, you can select corresponding supervised learning tasks (for example, text classification, named entity recognition, question-answering systems, dialogue systems, etc.) based on the specific application scenarios and task requirements, and prepare task-specific text datasets. This allows you to use the pre-trained model as the starting point for fine-tuning, and fine-tune it on the task-specific text dataset using a supervised learning approach. Specifically, you can perform the task based on the text dataset, and minimize the loss used to measure the performance of the model in processing specific tasks through backpropagation and optimization algorithms (for example, gradient descent). The model parameters are iteratively updated to gradually improve the model's performance on specific tasks. In practical applications, fine-tuning can flexibly choose supervised learning, unsupervised learning, or semi-supervised learning methods based on the specific application scenarios and the type of available data.

[0036] It's important to note that a pre-trained large language model is typically referred to as the large language model's base model, and a fine-tuned large language model is referred to as the large language model's serving model. The language comprehension capabilities acquired by the large language model during pre-training and fine-tuning enable it to understand, analyze, and synthesize text information to perform logical inference, knowledge reasoning, and problem-solving when faced with complex problems or tasks. This capability is often referred to as the large language model's reasoning ability.

[0037] Large language models typically perform specific tasks under the guidance of prompt text (which can be called prompts). Prompt text is an initial text or text fragment provided to the large language model, intended to stimulate the model to produce corresponding output. Through prompt text, you can clearly tell the large language model what task you expect it to perform, such as: answering a question, simulating a conversation, writing an article, translating text, etc. At the same time, prompt text can provide the large language model with the necessary background information and context, enabling the large language model to understand the logic, style, theme or position that should be followed when generating content. In addition, prompt text can also inspire the large language model to demonstrate its inherent knowledge reserves or specific language capabilities, such as: explaining complex concepts, citing laws and regulations, imitating the writing style of a specific author, etc.

[0038] Table Q&A refers to the ability to automatically answer user questions from structured data (such as Excel spreadsheets, database tables, etc.). Table Q&A is very important in various application scenarios, especially when it is necessary to extract information from structured data.

[0039] Table Q&A tasks typically include various types of tasks, such as Table Information Seeking (TIS) and Aggregation Q&A tasks. Table Information Seeking refers to the process by which users seek specific information from data in a tabular form. This type of task typically includes, but is not limited to: finding data within a specific cell; comparing data in different rows or columns; screening or filtering data based on certain conditions; and sorting tabular data to discover patterns or trends. Aggregation Q&A tasks refer to those that require summarizing or statistically analyzing the information in a dataset. These tasks typically require the model to be able to: calculate averages, sums, or other statistical data; group data according to certain rules and calculate statistics for each group; identify maximum, minimum, or other extreme cases; and perform more complex statistical analysis, such as standard deviation calculation and percentile determination.

[0040] In practical applications, it is usually expected that intelligent dialogue systems can perform form question answering tasks and have good performance in performing form question answering tasks.

[0041] One or more embodiments of the present application provide a technical solution for question-answering based on a large language model. In this technical solution, a query text corresponding to the table data to be processed input by the user can be first obtained, and a prompt text corresponding to the large language model can be generated based on the query text. The prompt text can include the query text and an instruction text for indicating that data processing instructions corresponding to the table data can be generated during the reasoning process based on the query text. Then, the prompt text can be input into the large language model, and the large language model, under the guidance of the prompt text, performs reasoning based on the query text and generates data processing instructions corresponding to the table data during the reasoning process. Then, the data processing instructions in the initial answer text can be executed to obtain a data processing result corresponding to the data processing instruction, and an answer text corresponding to the query text can be further generated based on the data processing result.

[0042] By adopting the above method, the intelligent dialogue system can perform table question and answer tasks, and since data processing instructions corresponding to the table data can be generated, and the data processing results corresponding to the data processing instructions are used to optimize the answer text generated by the large language model in the intelligent dialogue system based on the query text through reasoning, it is possible to avoid the accuracy of table question and answer being completely dependent on the table understanding and processing capabilities of the large language model, thereby ensuring good execution results of the table question and answer task.

[0043] Please refer to Figure 1 , Figure 1 It is a schematic diagram of an intelligent dialogue system shown in an exemplary embodiment of the present application.

[0044] like Figure 1 As shown, the intelligent dialogue system may include a server and at least one client accessing the server via any type of wired or wireless network.

[0045] Among them, the above-mentioned server can correspond to a server including an independent physical host, or a server cluster composed of multiple independent physical hosts; or, it can correspond to a virtual server, cloud server, etc. carried by a host cluster.

[0046] The above-mentioned client can correspond to terminal devices such as smart phones, tablet computers, laptops, desktop computers, PCs (Personal Computers), PDAs (Personal Digital Assistants), wearable devices (such as smart glasses, smart watches, etc.), smart car devices or game consoles.

[0047] Users can use the intelligent question-and-answer service provided by the intelligent dialogue system through the client; the client and the server can implement user-oriented intelligent question-and-answer services through data interaction between each other.

[0048] For example, the client can output a corresponding user interface to the user, so that the user can perform operations such as inputting question text (which can be called a query or question) and uploading documents or pictures used to assist in answering questions in the user interface, so as to ask questions to the intelligent dialogue system and use the intelligent question-answering service provided by the intelligent dialogue system. The client can send the question text input by the user to the server, and the server will generate a corresponding answer text (which can be called an answer) for the question text and output the answer text to the user, that is, return the answer text to the client, and the client will display the answer text to the user through the user interface so that the user can view the corresponding answer generated by the intelligent dialogue system, thereby realizing a user-oriented intelligent question-answering service.

[0049] Specifically, the server can be equipped with a large language model, and the intelligent dialogue system can be based on the large language model. The large language model can understand and answer the question text input by the user and generate an answer text corresponding to the question text.

[0050] The large language model mentioned here can refer to its serving model. In practical applications, the constructed large language model can be pre-trained using unsupervised learning on a large, unlabeled text dataset to obtain a base model for the large language model. Furthermore, a dialogue task can be used as a supervised learning task for fine-tuning, and a text dataset specific to the dialogue task can be prepared. This base model can then be used as the starting point for fine-tuning, using supervised learning on the text dataset specific to the dialogue task to obtain a serving model for the large language model.

[0051] In addition, the aforementioned server can also be equipped with other functional components or subsystems, such as prompt text generation components and knowledge base retrieval components. These components or subsystems can work in conjunction with the large language model installed on the server to jointly generate answer text corresponding to the question text entered by the user.

[0052] To improve the adaptability and response accuracy of the intelligent dialogue system, the server can also be equipped with a knowledge base. The data in the knowledge base can be in tabular form. This tabular data can be divided into relational table data, flat files, hierarchical tables, multidimensional tables, NoSQL tables, Excel tables, and other types of tabular data.

[0053] In practical applications, data in relational tables is structured, typically consisting of rows (records) and columns (fields). Each row represents a separate entity, and each column represents the attributes of that entity. Data organization in relational tables adheres to the principles of the relational model, ensuring data consistency and integrity. Relational tables support constraints such as primary keys and foreign keys. Relational tables represent tabular data in relational databases and support indexing, which accelerates data retrieval. Relational tables can be used to add, delete, modify, and query data using SQL (Structured Query Language).

[0054] Flat files contain data that is unstructured or has only a simple structure. Data is typically stored in simple formats like CSV and TSV, without complex relationships. Flat files are easy to generate and read, making them suitable for small projects or temporary data exchanges. CSV (Comma-Separated Values) files are a simple text file format used to store tabular data.

[0055] It's important to note that CSV files can be used to store data similar to relational tables, but they aren't strictly relational. CSV files store data in plain text format, with each row representing a record and each column representing a segment. CSV files typically contain only text data, and even when storing numeric values, they are stored as text. CSV files themselves don't define the structural constraints found in relational databases, such as primary keys and foreign keys. CSV files don't support indexing, so searching for data typically requires traversing the entire file.

[0056] Hierarchical tables have a tree-like structure, where data is organized hierarchically. This structure is commonly found in XML or JSON formats. Each parent node can have multiple child nodes, but each child node can only have one parent node.

[0057] Data in a multidimensional table is typically viewed as a multidimensional array, organized along multiple dimensions. Multidimensional tables can be used for data analysis, allowing for fast aggregation and slicing operations.

[0058] NoSQL tables are tabular data in non-relational databases. Their data models can be non-relational, such as key-value pairs, document stores, and graph databases. The data model of NoSQL tables can change dynamically, making them suitable for big data processing and real-time applications.

[0059] Excel is a spreadsheet software. Spreadsheet tools such as Excel provide flexible data display and processing functions, and support complex formula calculations and data visualization.

[0060] Please refer to Figure 2 , Figure 2 This is a schematic diagram of a question-answering process based on a large language model, shown as an exemplary embodiment of the present application.

[0061] like Figure 2 As shown, in the above-mentioned question-answering process based on the large language model, before the intelligent dialogue system performs the table question-answering task based on the table data, the table data can be preprocessed differently according to the different types of the table data.

[0062] Specifically, the above-mentioned table data can be input into a large language model, and the large language model can perform classification processing on the table data to determine the type of the table data. If the output of the large language model determines that the table data is relational table data, the table data can be converted into table data stored in CSV format, thereby reducing the storage space required for the table data. If the output of the large language model determines that the table data is not relational table data, a row index, column index, and cell keyword index can be created for the table data.

[0063] The intelligent dialogue system can obtain a query text input by a user for asking a question. The query text may correspond to tabular data to be processed; that is, the question described in the query text requires specific processing (e.g., retrieval, statistical analysis, etc.) of the tabular data to be answered.

[0064] When the query text is obtained, a prompt text corresponding to the large language model can be generated based on the query text. It should be noted that the generated prompt text may include not only the query text itself, but also instruction text indicating that the answer text may contain data processing instructions corresponding to the table data.

[0065] The above-mentioned data processing instructions may include one or more of the following: SQL instructions; row and column data positioning instructions; and keyword search instructions.

[0066] When the prompt text is generated, the prompt text may be input into a large language model, and the large language model performs a specific task under the guidance of the prompt text.

[0067] Specifically, on the one hand, because the prompt text contains the query text, the large language model can perform the question-answering task under the guidance of the prompt text, that is, generate an answer text corresponding to the query text. On the other hand, because the prompt text also contains instruction text indicating that the answer text may contain data processing instructions corresponding to the table data, when the large language model generates the answer text corresponding to the query text, if it finds that the generated answer text should contain content that can only be obtained by performing specific processing on the table data, it can first replace these contents with corresponding data processing instructions. When these data processing instructions are executed, specific processing of the table data can be achieved. In this case, the answer text corresponding to the query text and containing the data processing instructions corresponding to the table data generated by the large language model can be called the initial answer text.

[0068] When the above-mentioned initial answer text is generated, the above-mentioned data processing instructions contained in the initial answer text can be further executed to obtain the data processing results corresponding to the data processing instructions.

[0069] Specifically, the SQL instruction as the above-mentioned data processing instruction can be executed on the above-mentioned table data to obtain the data processing result corresponding to the SQL instruction. Alternatively, the row identifier (for example: row number) and / or column identifier (for example: column name) contained in the row and column data positioning instruction as the data processing instruction can be used to extract the corresponding data from the table data based on the row index, column index and / or cell keyword index created for the above-mentioned table data. Alternatively, the keyword search instruction as the data processing instruction can be executed to extract the cell data matching the keyword in the keyword search instruction from the table data based on the cell keyword index created for the above-mentioned table data.

[0070] When the above data processing results are obtained, the above initial answer text can be updated based on the data processing results. The updated initial answer text can be used as the final answer text corresponding to the above query text, and the final answer text can be output to the user.

[0071] The following is Figure 2 The question-answering process based on the large language model shown is described in detail.

[0072] Please refer to Figure 3 , Figure 3 This is a flowchart of a question-answering method based on a large language model, shown as an exemplary embodiment of the present application.

[0073] In this embodiment, the above-mentioned question answering method based on the large language model can be applied to Figure 1 The server side is shown.

[0074] like Figure 3 As shown, the above-mentioned question answering method based on the large language model may include the following steps:

[0075] Step 302: Obtain query text corresponding to the tabular data to be processed, and generate prompt text corresponding to the large language model based on the query text; wherein the prompt text includes the query text and instruction text for indicating that data processing instructions corresponding to the tabular data can be generated during the process of reasoning based on the query text.

[0076] In this embodiment, a query text corresponding to the table data to be processed may first be obtained. The query text may correspond to the table data to be processed; that is, the question described in the query text requires specific processing (e.g., retrieval, statistical analysis, etc.) of the table data to be answered.

[0077] For example, assuming that the table data to be processed is data in tabular form for recording the monthly attendance days of company employees, the query text corresponding to the table data can be "How many monthly attendance days does a certain employee in the company have?", "How many employees in the company have a monthly attendance day of more than 15 days?", "What is the total number of employees in the company?", etc.

[0078] In practical applications, the client included in the intelligent dialogue system can display a specific user interface to the user, allowing the user to enter query text for the question. Furthermore, the user can also upload tabular data to assist in answering the question through the user interface. In this case, the query text entered by the user can be obtained.

[0079] In some embodiments, the tabular data may be tabular data uploaded by the user to the intelligent dialogue system when using the intelligent dialogue system, stored in the server included in the intelligent dialogue system and used for subsequent question answering by the intelligent dialogue system; or, the tabular data may be tabular data pre-stored in the server included in the intelligent dialogue system as existing data; this application does not impose any special restrictions on this.

[0080] In some embodiments, in order to facilitate subsequent data processing on the table data, before the intelligent dialogue system performs the table question and answer task based on the table data, the table data can be preprocessed differently according to the different types of the table data.

[0081] Specifically, the above-mentioned table data can be input into a large language model, and the large language model can perform classification processing on the table data to determine the type of the table data. If the output of the large language model determines that the table data is relational table data, the table data can be converted into table data stored in CSV format, thereby reducing the storage space required for the table data. If the output of the large language model determines that the table data is not relational table data, a row index, column index, and cell keyword index can be created for the table data.

[0082] The aforementioned large language model can refer to the serving model of the large language model. In practical applications, the constructed large language model can be pre-trained on a large, unlabeled text dataset using unsupervised learning to obtain the base model of the large language model. Furthermore, the table classification task can be used as a supervised learning task for fine-tuning, and a text dataset specific to the table classification task can be prepared. This base model of the large language model can then be used as the starting point for fine-tuning, using supervised learning to fine-tune the data on the text dataset specific to the table classification task, resulting in the serving model of the large language model.

[0083] It should be noted that the large language model used to classify tabular data and the large language model used to perform tabular question-answering tasks based on tabular data can be the same large language model or different large language models, and this application does not impose any special restrictions on this.

[0084] In addition to being able to Figure 1 In addition to completing the preprocessing of the table data on the server shown in the figure, other electronic devices with certain computing capabilities can also complete the preprocessing of the table data and store the preprocessed table data in a manner such as Figure 1 In the server shown.

[0085] In this embodiment, when the query text is obtained, prompt text corresponding to the large language model can be generated based on the query text. It should be noted that the generated prompt text may include not only the query text itself, but also instruction text indicating that data processing instructions corresponding to the tabular data can be generated during the inference process based on the query text.

[0086] In practical applications, it can be Figure 1 The prompt text generation component shown generates prompt text corresponding to the large language model based on the query text.

[0087] In some embodiments, the above-mentioned data processing instructions may include one or more of the following: SQL instructions; row and column data positioning instructions; and keyword search instructions.

[0088] Among them, SQL instructions are instructions based on structured query language; row and column data positioning instructions refer to instructions used to locate or filter specific rows or columns in a table, for example: row data can be obtained through row and column data positioning instructions containing row numbers, column data can be obtained through row and column data positioning instructions containing column names, and cell data can be obtained through row and column data positioning instructions containing a combination of row numbers and column names; keyword search instructions refer to instructions used to search for cells in a table containing specific keywords, as well as N-degree data around the cell (that is, data in N rows or N columns around the cell).

[0089] For example, suppose the table data above is used to record the monthly attendance days of a company's employees, and the query text is "What is the total number of employees in the company?" Since each row in the table data is generally considered a record, and this record records the monthly attendance days of a company employee, the question described in the query text can be transformed into counting the total number of rows in the table, that is, counting the total number of records in the table data. In this case, the question can be answered by executing the SQL instruction "SELECT COUNT(*) FROM table" (an SQL instruction used to count the total number of records in a given table).

[0090] Step 304: Input the prompt text into a large language model. Under the guidance of the prompt text, the large language model performs reasoning based on the query text and generates data processing instructions corresponding to the table data during the reasoning process.

[0091] In this embodiment, when the prompt text is generated, the prompt text can be input into the large language model, and the large language model performs a specific task under the guidance of the prompt text.

[0092] Specifically, on the one hand, since the prompt text contains the above-mentioned query text, the large language model can perform the dialogue task under the guidance of the prompt text, that is, generate an answer text corresponding to the query text by reasoning based on the query text; on the other hand, since the prompt text also contains an instruction text for indicating that data processing instructions corresponding to the above-mentioned table data can be generated in the process of reasoning based on the query text, when the large language model tries to generate an answer text corresponding to the query text, if it is found that the generated answer text should contain content that can only be obtained by performing specific processing on the table data, the corresponding data processing instructions can be generated first, and when the data processing instructions are executed, specific processing of the table data can be achieved.

[0093] It should be noted that the number of the above-mentioned data processing instructions generated can be only one or more, and this application does not impose any special restrictions on this.

[0094] The large language model mentioned above can refer to its serving model. In practical applications, the constructed large language model can be pre-trained using unsupervised learning on a large, unlabeled text dataset to obtain a base model for the large language model. Furthermore, a dialogue task can be used as a supervised learning task for fine-tuning, and a text dataset specific to the dialogue task can be prepared. This base model can then be used as the starting point for fine-tuning using supervised learning on the text dataset specific to the dialogue task to obtain the serving model for the large language model.

[0095] In practical applications, it can be Figure 1 The prompt text generation component shown in the figure generates the above prompt text as follows Figure 1 The large language model shown is guided by the prompt text and performs reasoning based on the query text in the prompt text, and generates data processing instructions corresponding to the above-mentioned table data during the reasoning process.

[0096] For example, assuming that the above table data is a table data used to record the monthly attendance days of the company's employees, and assuming that the above query text is "What is the total number of employees in the company?", then because the above large language model will find in the process of reasoning based on the query text that the answer text corresponding to the query text should contain content that can only be obtained by counting the total number of records in the table data, it can generate a data processing instruction corresponding to the table data, specifically the SQL instruction "SELECT COUNT(*) FROM table".

[0097] Alternatively, if the large language model, while attempting to generate an answer text corresponding to the query text, discovers that the generated answer text should contain content that requires specific processing of the table data, it may first generate corresponding data processing instructions. These data processing instructions, when executed, implement the specific processing of the table data and continue to complete the generation of the answer text. After the answer text is generated, the data processing instructions may be used to replace the content contained in the answer text that requires specific processing of the table data. In this case, the answer text generated by the large language model corresponding to the query text and containing the data processing instructions corresponding to the table data can be referred to as the initial answer text.

[0098] For example, assuming that the above table data is a tabular data used to record the monthly attendance days of the company's employees, and assuming that the above query text is "What is the total number of employees in the company?", then the initial answer text corresponding to the query text generated by the above large language model can be "The total number of employees in the company is SELECT COUNT(*)FROMtable", where "" represents the starting and ending positions of the SQL instruction.

[0099] Step 306: Execute the data processing instruction to obtain a data processing result corresponding to the data processing instruction, and further generate an answer text corresponding to the query text based on the data processing result.

[0100] In this embodiment, when the above-mentioned initial answer text is generated, the above-mentioned data processing instructions contained in the initial answer text can be further executed to obtain the data processing results corresponding to the data processing instructions, and based on the data processing results, an answer text corresponding to the above-mentioned query text can be further generated.

[0101] In practical applications, it can be Figure 1 The knowledge base retrieval component shown in the figure obtains Figure 1 The large language model shown generates an initial answer text, and executes the data processing instructions in the initial answer text to obtain a data processing result corresponding to the data processing instructions.

[0102] In some embodiments, when further generating an answer text corresponding to the above-mentioned query text based on the above-mentioned data processing results, the data processing results can be input into the above-mentioned large language model, and the large language model can perform further inference based on the query text and the data processing results to generate an answer text corresponding to the query text.

[0103] That is, when the above-mentioned large language model is performing reasoning based on the query text to try to generate an answer text corresponding to the query text, if it is found that the generated answer text should contain content that requires specific processing of the table data, it can first pause the reasoning and generate corresponding data processing instructions to obtain a data processing result corresponding to the data processing instruction, and then continue to reason based on the query text and the data processing result, so as to generate an answer text corresponding to the query text.

[0104] In some embodiments, as described above, the data processing instructions may be included in the initial answer text generated by the large language model and corresponding to the query text. In this case, when further generating the answer text corresponding to the query text based on the data processing results, the initial answer text may be updated based on the data processing results. Specifically, the data processing results may be added to the position in the initial answer text corresponding to the data processing instructions, and the data processing instructions in the initial answer text may be deleted to obtain the final answer text corresponding to the query text.

[0105] For example, assuming that the above-mentioned table data is a tabular data used to record the monthly attendance days of the company's employees, and assuming that the above-mentioned query text is "What is the total number of employees in the company?", then the initial answer text corresponding to the query text generated by the above-mentioned large language model can be "The total number of employees in the company is SELECT COUNT(*)FROMtable"; further assuming that the result obtained by executing the SQL instruction "SELECT COUNT(*)FROM table" is 100, then it means that the data processing result corresponding to the SQL instruction is 100, and the initial answer text is updated based on the data processing result, and the final answer text corresponding to the query text can be "The total number of employees in the company is 100".

[0106] In actual applications, when an answer text corresponding to the query text is obtained, the answer text can be further output to the user (eg, the user who input the query text).

[0107] In some embodiments, the data processing instruction may include an SQL instruction. In this case, when executing the data processing instruction and obtaining the data processing result corresponding to the data processing instruction, the SQL instruction may be executed on the table data to obtain the data processing result corresponding to the SQL instruction.

[0108] In some embodiments, the data processing instructions may include row and column data location instructions. In this case, when executing the data processing instructions and obtaining the data processing results corresponding to the data processing instructions, the corresponding data may be extracted from the table data based on the row identifier (e.g., row number) and / or column identifier (e.g., column name) contained in the row and column data location instructions.

[0109] Specifically, if the row-column data locating instruction only includes a row identifier, the row-column data locating instruction can be executed to extract the row data corresponding to the row identifier in the row-column data locating instruction from the table data based on the row index created for the table data. If the row-column data locating instruction only includes a column identifier, the row-column data locating instruction can be executed to extract the column data corresponding to the column identifier in the row-column data locating instruction from the table data based on the column index created for the table data. If the row-column data locating instruction includes both a row identifier and a column identifier, the row-column data locating instruction can be executed to extract the cell data corresponding to the row identifier and column identifier in the row-column data locating instruction from the table data based on the row index and column index created for the table data.

[0110] In some embodiments, the data processing instruction may include a keyword search instruction. In this case, when executing the data processing instruction and obtaining a data processing result corresponding to the data processing instruction, the keyword search instruction may be specifically executed to extract, from the table data, cell data that matches the keyword in the keyword search instruction based on the cell keyword index created for the table data. Furthermore, based on the cell data that matches the keyword in the keyword search instruction, N-degree data surrounding the cell in which the cell is located may be extracted from the table data.

[0111] In the technical solution provided by one or more embodiments of the present application, a query text corresponding to the table data to be processed input by the user can be first obtained, and a prompt text corresponding to the large language model can be generated based on the query text. The prompt text can include the query text and an instruction text for indicating that data processing instructions corresponding to the table data can be generated during the reasoning process based on the query text. Then, the prompt text can be input into the large language model, and the large language model, under the guidance of the prompt text, performs reasoning based on the query text and generates data processing instructions corresponding to the table data during the reasoning process. Then, the data processing instructions in the initial answer text can be executed to obtain a data processing result corresponding to the data processing instruction, and based on the data processing result, an answer text corresponding to the query text can be further generated.

[0112] By adopting the above method, the intelligent dialogue system can perform table question and answer tasks, and since data processing instructions corresponding to the table data can be generated, and the data processing results corresponding to the data processing instructions are used to optimize the answer text generated by the large language model in the intelligent dialogue system based on the query text through reasoning, it is possible to avoid the accuracy of table question and answer being completely dependent on the table understanding and processing capabilities of the large language model, thereby ensuring good execution results of the table question and answer task.

[0113] Corresponding to the aforementioned method embodiments, the present application also provides device embodiments.

[0114] Please refer to Figure 4 , Figure 4 4 is a structural diagram of a device shown in an exemplary embodiment of the present application. At the hardware level, the device includes a processor 402, an internal bus 404, a network interface 406, a memory 408 and a non-volatile memory 410, and of course may also include other required hardware. One or more embodiments of the present application can be implemented based on software, such as the processor 402 reading the corresponding computer program from the non-volatile memory 410 into the memory 408 and then running it. Of course, in addition to software implementation, one or more embodiments of the present application do not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic module, but can also be hardware or logic devices.

[0115] Please refer to Figure 5 , Figure 5 This is a block diagram of a question-answering device based on a large language model, shown as an exemplary embodiment of the present application.

[0116] The above-mentioned question-answering device based on the large language model can be applied to Figure 4 The device shown in the figure is used to implement the technical solution of this application. The device includes:

[0117] A prompt generation module 502 acquires a query text corresponding to the table data to be processed, and generates prompt text corresponding to the large language model based on the query text; wherein the prompt text includes the query text and instruction text for indicating that data processing instructions corresponding to the table data can be generated during reasoning based on the query text;

[0118] The answer generation module 504 inputs the prompt text into a large language model, and the large language model, guided by the prompt text, performs reasoning based on the query text and generates data processing instructions corresponding to the table data during the reasoning process;

[0119] The table processing module 506 executes the data processing instruction to obtain a data processing result corresponding to the data processing instruction, and further generates an answer text corresponding to the query text based on the data processing result.

[0120] In some embodiments, further generating an answer text corresponding to the query text based on the data processing result includes:

[0121] The data processing result is input into the large language model, and the large language model performs further reasoning based on the query text and the data processing result to generate an answer text corresponding to the query text.

[0122] In some embodiments, the data processing instruction is included in an initial answer text corresponding to the query text generated by the large language model;

[0123] The further generating of an answer text corresponding to the query text based on the data processing result includes:

[0124] The data processing result is filled into the position corresponding to the data processing instruction in the initial answer text, and the data processing instruction in the initial answer text is deleted to obtain a final answer text corresponding to the query text.

[0125] In some embodiments, the apparatus further comprises:

[0126] a table determination module, inputting the table data into a large language model, and determining the type of the table data by the large language model;

[0127] The table conversion module converts the table data into table data stored in a comma-separated value (CSV) format if the table data is relational table data.

[0128] In some embodiments, the table conversion module is further configured to:

[0129] If the table data is not relational table data, a row index, a column index, and a cell key index are created for the table data.

[0130] In some embodiments, the data processing instructions include SQL instructions;

[0131] The executing the data processing instruction to obtain a data processing result corresponding to the data processing instruction includes:

[0132] Execute the SQL instruction to obtain a data processing result corresponding to the SQL instruction.

[0133] In some embodiments, the data processing instructions include row and column data positioning instructions;

[0134] The executing the data processing instruction to obtain a data processing result corresponding to the data processing instruction includes:

[0135] Executing the row and column data locating instruction, and extracting row data corresponding to the row identifier in the row and column data locating instruction from the table data based on the row index;

[0136] Executing the row and column data positioning instruction, and extracting the column data corresponding to the column identifier in the row and column data positioning instruction from the table data based on the column index; or

[0137] The row and column data locating instruction is executed, and based on the row index and the column index, cell data corresponding to the row identifier and the column identifier in the row and column data locating instruction is extracted from the table data.

[0138] In some embodiments, the data processing instructions include keyword search instructions;

[0139] The executing the data processing instruction to obtain a data processing result corresponding to the data processing instruction includes:

[0140] The keyword search instruction is executed, and based on the cell keyword index, cell data matching the keyword in the keyword search instruction is extracted from the table data.

[0141] For the device embodiments, they basically correspond to the method embodiments, so for relevant details, please refer to the partial description of the method embodiments. The device embodiments described above are merely illustrative, wherein the modules described as separate components may or may not be physically separate, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the technical solution of this application.

[0142] The systems, devices, modules, or units described in the above embodiments may be implemented by computer chips or physical devices, or by products having certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email transceiver, game console, tablet computer, wearable device, or any combination of these devices.

[0143] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0144] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0145] Computer-readable media include permanent and non-permanent, removable and non-removable media that can implement information storage by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0146] It should be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0147] The above description is of specific embodiments of the present application. Other embodiments are within the scope of this application. In some cases, the actions or steps described in this application can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0148] The terms used in one or more embodiments of the present application are for the purpose of describing specific embodiments only and are not intended to limit one or more embodiments of the present application. The singular forms "a," "the," and "the" are also intended to include the plural forms unless the context clearly indicates otherwise. The term "and / or" refers to and includes any or all possible combinations of one or more of the associated listed items.

[0149] The terms "one embodiment," "some embodiments," "example," "specific example," or "one implementation" used in one or more embodiments of the present application mean that the specific features or characteristics described in conjunction with the embodiment are included in at least one embodiment of the present application. The schematic descriptions of these terms do not necessarily refer to the same embodiment. Moreover, the specific features or characteristics described can be combined in an appropriate manner in one or more embodiments of the present application. In addition, different embodiments and specific features or characteristics in different embodiments can be combined without conflict.

[0150] It should be understood that although the terms first, second, third, etc. may be used to describe various information in one or more embodiments of the present application, these information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other. For example, without departing from the scope of one or more embodiments of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0151] The above description is merely a preferred embodiment of one or more embodiments of the present application and is not intended to limit one or more embodiments of the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present application shall be included in the scope of protection of one or more embodiments of the present application.

[0152] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

Claims

1. A question answering method based on a large language model, the method comprising: Acquire a query text corresponding to the table data to be processed, and generate a prompt text corresponding to the large language model based on the query text; wherein the prompt text includes the query text and an indication text for indicating that a data processing instruction corresponding to the table data can be generated in the process of reasoning based on the query text; Inputting the prompt text into a large language model, and the large language model, under the guidance of the prompt text, performs reasoning based on the query text, and generates data processing instructions corresponding to the table data during the reasoning process; The data processing instruction is executed to obtain a data processing result corresponding to the data processing instruction, and an answer text corresponding to the query text is further generated based on the data processing result.

2. The method according to claim 1, further generating an answer text corresponding to the query text based on the data processing result, comprising: The data processing result is input into the large language model, and the large language model performs further reasoning based on the query text and the data processing result to generate an answer text corresponding to the query text.

3. The method according to claim 1, wherein the data processing instruction is included in an initial answer text corresponding to the query text generated by the large language model; The further generating an answer text corresponding to the query text based on the data processing result includes: The data processing result is filled into the position in the initial answer text corresponding to the data processing instruction, and the data processing instruction in the initial answer text is deleted to obtain a final answer text corresponding to the query text.

4. The method according to claim 1, further comprising: Inputting the table data into a large language model, and determining the type of the table data by the large language model; If the table data is relational table data, the table data is converted into table data stored in a comma separated value (CSV) format.

5. The method according to claim 4, further comprising: If the table data is not relational table data, a row index, a column index and a cell keyword index are created for the table data.

6. The method according to claim 4, wherein the data processing instructions include SQL instructions; The executing the data processing instruction to obtain a data processing result corresponding to the data processing instruction includes: Execute the SQL instruction to obtain a data processing result corresponding to the SQL instruction.

7. The method according to claim 5, wherein the data processing instructions include row and column data positioning instructions; The executing the data processing instruction to obtain a data processing result corresponding to the data processing instruction includes: Execute the row and column data positioning instruction, and extract row data corresponding to the row identifier in the row and column data positioning instruction from the table data based on the row index; Execute the row and column data positioning instruction, and extract the column data corresponding to the column identifier in the row and column data positioning instruction from the table data based on the column index; or, The row and column data positioning instruction is executed, and based on the row index and the column index, cell data corresponding to the row identifier and the column identifier in the row and column data positioning instruction is extracted from the table data.

8. The method according to claim 5, wherein the data processing instruction comprises a keyword search instruction; The executing the data processing instruction to obtain a data processing result corresponding to the data processing instruction includes: The keyword search instruction is executed, and based on the cell keyword index, cell data matching the keyword in the keyword search instruction is extracted from the table data.

9. A question-answering device based on a large language model, the device comprising: A prompt generation module, which obtains a query text corresponding to the table data to be processed, and generates a prompt text corresponding to the large language model based on the query text; wherein the prompt text includes the query text and an indication text for indicating that a data processing instruction corresponding to the table data can be generated in the process of reasoning based on the query text; an answer generation module, inputting the prompt text into a large language model, wherein the large language model performs reasoning based on the query text under the guidance of the prompt text, and generates data processing instructions corresponding to the table data during the reasoning process; The table processing module executes the data processing instruction to obtain a data processing result corresponding to the data processing instruction, and further generates an answer text corresponding to the query text based on the data processing result.

10. An electronic device, comprising: processor; a memory for storing processor-executable instructions; The processor implements the method according to any one of claims 1 to 8 by running the executable instructions.

11. A computer-readable storage medium having computer instructions stored thereon, wherein the instructions are executed by a processor to implement the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Posted document identification analysis method and system based on natural language processing, and storage medium

    CN117539980A

  • Method and system for correcting database query statement, electronic equipment and storage medium

    CN117633149A

  • Method and system for solving alignment of complex table and entity by using LLM-driven NL2SQL converter

    CN118410059A

  • Data processing method and device, storage medium and computer program product

    CN118820570A

  • Method, device and equipment for carrying out business operation by utilizing large language model and medium

    CN118939346A

Cited By

  • Tourism intelligent question and answer method and system based on large language model

    CN121979984A