Question answering methods and devices based on large language models

By generating and executing data processing instructions in an intelligent dialogue system, the table-based question-and-answer task of a large language model is optimized, solving the problem of insufficient table understanding and processing capabilities in existing technologies, and achieving better performance in table-based question-and-answer tasks.

CN119621902BActive Publication Date: 2026-03-13ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-26
Publication Date
2026-03-13

AI Technical Summary

Technical Problem

Existing intelligent dialogue systems struggle to guarantee good performance in table-based question-and-answer tasks, relying primarily on the table understanding and processing capabilities of large language models.

Method used

By acquiring the query text input by the user, a prompt text containing data processing instructions is generated, and then input into a large language model for reasoning to generate and execute data processing instructions, thereby optimizing the answer text generation process.

Benefits of technology

This improves the performance of intelligent dialogue systems in table-based question-and-answer tasks, avoids complete reliance on the table understanding and processing capabilities of large language models, and ensures the accuracy and efficiency of answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119621902B_ABST
    Figure CN119621902B_ABST
Patent Text Reader

Abstract

This application provides one or more embodiments of a question-answering method and apparatus based on a large language model. The method includes: acquiring query text input by a user corresponding to tabular data to be processed, and generating 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 indicating that the answer text may contain data processing instructions corresponding to the tabular data; inputting the prompt text into the large language model, and generating an initial answer text corresponding to the query text under the guidance of the prompt text; wherein the initial answer text contains data processing instructions corresponding to the tabular data; executing the data processing instructions to obtain a data processing result corresponding to the data processing instructions; 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 this application relate to the field of artificial intelligence technology, and in particular to a question-answering method and apparatus based on a large language model. Background Technology

[0002] Today, intelligent dialogue systems are widely used in numerous fields such as customer service, legal aid, online education, and medical consultation. These systems simulate human communication to provide users with services such as question-and-answer and query functions. Specifically, an intelligent dialogue system is an interactive system developed using artificial intelligence technology. It aims to understand and answer questions posed by users in natural language and generate concise and clear answers. Intelligent dialogue systems are typically based on a Large Language Model (LLM), which understands and answers the user's questions and generates corresponding responses.

[0003] Table question answering refers to the ability to automatically answer user questions from structured data (such as Excel spreadsheets, database tables, etc.). Table question answering is crucial in various application scenarios, especially when information needs to be extracted from structured data.

[0004] In practical applications, how to enable intelligent dialogue systems to perform table-based question-and-answer tasks and achieve good results in these tasks is a highly anticipated issue. Summary of the Invention

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

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

[0007] Obtain the query text corresponding to the table 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 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;

[0008] The prompt text is input into the large language model, which, guided by the prompt text, performs inference based on the query text and generates data processing instructions corresponding to the table data during the inference process.

[0009] Execute the data processing instruction to obtain the data processing result corresponding to the data processing instruction, and further generate the answer text corresponding to the query text based on the data processing result.

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

[0011] The prompt generation module obtains the 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 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;

[0012] The answer generation module inputs the prompt text into the large language model, which, 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.

[0013] The table processing module executes the data processing instructions to obtain the data processing results corresponding to the data processing instructions, and further generates the answer text corresponding to the query text based on the data processing results.

[0014] This application also provides an electronic device, including:

[0015] processor;

[0016] Memory used to store processor-executable instructions;

[0017] The processor executes the executable instructions to implement the steps of the method as described in any of the preceding descriptions.

[0018] This application also provides a computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of the method as described in any of the preceding claims.

[0019] In the above technical solution, firstly, the query text input by the user corresponding to the table data to be processed can be obtained, and based on the query text, a prompt text corresponding to the large language model can be generated. The prompt text may include the query text and an instruction text 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, 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. Then, the data processing instructions in the initial answer text can be executed to obtain the data processing result corresponding to the data processing instruction, and based on the data processing result, the 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. Furthermore, since it can generate data processing instructions corresponding to the table data and use the data processing results corresponding to these instructions to optimize the answer text generated by the large language model in the intelligent dialogue system based on the query text, it can avoid the accuracy of table question-and-answer from relying entirely on the large language model's ability to understand and process tables. This ensures good performance in table question-and-answer tasks. Attached Figure Description

[0021] The accompanying drawings used in the description of the exemplary embodiments will now be explained, wherein:

[0022] Figure 1 This is a schematic diagram illustrating an intelligent dialogue system according to an exemplary embodiment of this application.

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

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

[0025] Figure 4 This is a schematic diagram of the structure of a device shown in an exemplary embodiment of this application.

[0026] Figure 5 This is a block diagram illustrating a question-answering device based on a large language model, as shown in an exemplary embodiment of this application. Detailed Implementation

[0027] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with one or more embodiments of this application. Rather, they are merely examples consistent with some aspects of one or more embodiments of this application.

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

[0029] Intelligent dialogue systems provide users with services such as question-and-answer and query functions by simulating human communication. Specifically, an intelligent dialogue system is an interactive system developed using artificial intelligence technology. It aims 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 the user's questions and generate corresponding responses.

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

[0031] In the field of natural language processing, large-scale text datasets are often referred to as corpora. Corpora can contain various types 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 corpora, large language models can acquire and understand the rules and patterns of natural language, thereby achieving effective processing and generation of human language.

[0032] Large language models typically employ the Transformer architecture; that is, large language models are usually deep learning models based on the Transformer architecture. Deep learning models based on the Transformer architecture are a class of neural network models that utilize the Transformer architecture, and these models perform exceptionally well in fields such as natural language processing.

[0033] The Transformer is a neural network model used for sequence-to-sequence modeling. It does not rely on recursive structures, enabling parallel training and inference, thus accelerating model processing. Deep learning models based on the Transformer architecture typically use multi-layered Transformer encoders to extract features from the input sequence and a Transformer decoder to transform the extracted features into an output sequence. These models also often employ self-attention mechanisms to capture long-range dependencies in the input sequence, and residual connections and normalization methods to accelerate training and improve model performance.

[0034] Pre-trained models are large language models pre-trained on massive amounts of unlabeled text data. Pre-trained models are general-purpose models, not designed or optimized for specific tasks. To adapt pre-trained models to specific application scenarios and task requirements, fine-tuning is needed to improve the model's performance on specific tasks. The final large language model deployed is usually a model that has undergone further fine-tuning based on the pre-trained model, using supervised learning on labeled text data. Pre-training and fine-tuning are complementary processes; pre-training enables the model to possess 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. In the pre-training stage, unsupervised learning (e.g., self-supervised learning) can be used to pre-train on large-scale, unlabeled text datasets (e.g., online encyclopedias, online articles, books, etc.). Specifically, it can predict missing parts or the next word based on context, learn semantic, syntactic, and other statistical rules and language structures, and minimize the prediction loss through backpropagation and optimization algorithms (e.g., gradient descent), iteratively updating the model parameters and gradually improving the model's ability to understand language. During the fine-tuning phase, a suitable supervised learning task (e.g., text classification, named entity recognition, question answering systems, dialogue systems, etc.) can be selected based on the specific application scenario and task requirements. A task-specific text dataset is prepared, allowing the pre-trained model to serve as the starting point for fine-tuning. Supervised learning is then employed on this task-specific text dataset, where the task can be executed. Backpropagation and optimization algorithms (e.g., gradient descent) are used to minimize the loss used to measure the model's performance on the specific task, iteratively updating the model parameters to gradually improve its performance. In practical applications, fine-tuning can flexibly choose supervised, unsupervised, or semi-supervised learning methods based on the specific application scenario and the type of available data.

[0036] It should be noted that the pre-trained large language model is usually referred to as the base model of the large language model, while the fine-tuned large language model is referred to as the service model of the large language model. The language understanding ability learned by the large language model in the pre-training and fine-tuning stages enables it to perform logical inference, knowledge reasoning, or problem-solving by understanding, analyzing, and synthesizing textual information when faced with complex problems or tasks. This ability is usually referred to as the reasoning ability of the large language model.

[0037] Large language models typically perform specific tasks under the guidance of prompt text. Prompt text is an initial text or text fragment provided to the large language model to elicit a corresponding output. Through prompt text, the expected task can be explicitly told to the large language model, such as answering a question, simulating a dialogue, writing an article, or translating text. Simultaneously, prompt text can provide the large language model with necessary background information and context, enabling it to understand the logic, style, theme, or stance that should be followed when generating content. Furthermore, prompt text can also stimulate the large language model to demonstrate its inherent knowledge or specific language abilities, such as explaining complex concepts, citing rules, or mimicking the writing style of a particular author.

[0038] Table-based question answering refers to the ability to automatically answer user questions from structured data (such as Excel spreadsheets, database tables, etc.). Table-based question answering is crucial in various application scenarios, especially when information needs to be extracted from structured data.

[0039] Table-based question answering tasks typically include various types such as Table Information Seeking (TIS) and Aggregation Q&A. Table Information Seeking refers to the process by which users search for specific information from tabular data. This type of task typically includes, but is not limited to: finding data within a specific cell; comparing data in different rows or columns; filtering or selecting data based on certain criteria; and sorting tabular data to discover patterns or trends. Aggregation Q&A tasks refer to those that require summarizing or statistically analyzing information within a dataset. These tasks typically require the model 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 analyses, such as standard deviation calculation and percentile determination.

[0040] In practical applications, it is generally expected that intelligent dialogue systems can perform table-based question-and-answer tasks and have good performance in these tasks.

[0041] This application provides one or more embodiments of a question-answering technical solution based on a large language model. In this solution, a query text corresponding to table data to be processed, input by the user, is first obtained. Based on the query text, a prompt text corresponding to the large language model is generated. This prompt text may include the query text and an instruction text indicating that data processing commands corresponding to the table data can be generated during reasoning based on the query text. Then, the prompt text is input into the large language model, which, guided by the prompt text, performs reasoning based on the query text and generates data processing commands corresponding to the table data during the reasoning process. Finally, the data processing commands in the initial answer text are executed to obtain a data processing result corresponding to the data processing command, and an answer text corresponding to the query text is 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. Furthermore, since it can generate data processing instructions corresponding to the table data and use the data processing results corresponding to these instructions to optimize the answer text generated by the large language model in the intelligent dialogue system based on the query text, it can avoid the accuracy of table question-and-answer from relying entirely on the large language model's ability to understand and process tables. This ensures good performance in table question-and-answer tasks.

[0043] Please refer to Figure 1 , Figure 1 This is a schematic diagram illustrating an intelligent dialogue system according to an exemplary embodiment of this application.

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

[0045] The aforementioned server can correspond to a server containing a single physical host, or a server cluster consisting of multiple independent physical hosts; alternatively, it can correspond to a virtual server, cloud server, etc., hosted by a host cluster.

[0046] The aforementioned client can correspond to terminal devices such as smartphones, tablets, laptops, desktop computers, PCs (Personal Computers), PDAs (Personal Digital Assistants), wearable devices (e.g., smart glasses, smartwatches), smart in-vehicle devices, or game consoles.

[0047] Users can access the intelligent question-and-answer service provided by the intelligent dialogue system through the aforementioned client; the aforementioned client and server can achieve user-oriented intelligent question-and-answer service through data interaction with each other.

[0048] For example, the client can display a user interface, allowing the user to input question text (a query or question), upload documents or images to assist in answering the question, and so on, to ask questions to the intelligent dialogue system and use its intelligent question-and-answer service. The client can also send the user-input question text to the server, which generates a corresponding answer text (an answer) and returns it to the client. The client then displays the answer text to the user through the user interface, allowing the user to view the answer generated by the intelligent dialogue system, thus realizing a user-facing intelligent question-and-answer service.

[0049] Specifically, the aforementioned server can be equipped with a large language model, and the aforementioned intelligent dialogue system can be based on this large language model, which can understand and answer the user's input question text and generate the answer text corresponding to the question text.

[0050] At this point, the aforementioned large language model can refer to its service model. In practical applications, the constructed large language model can be pre-trained on a large-scale, unlabeled text dataset using unsupervised learning to obtain its base model. Furthermore, the dialogue task can be used as a supervised learning task for fine-tuning, and a dialogue task-specific text dataset can be prepared. Thus, the base model of the large language model can be used as the starting point for fine-tuning, and supervised learning can be used to fine-tune it on the dialogue task-specific text dataset to obtain the service model of 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 on the server to jointly generate answer text corresponding to the user's input question text.

[0052] To improve the adaptability and response accuracy of the intelligent dialogue system, a knowledge base can also be mounted on the aforementioned server. The data in this knowledge base can be in tabular format, and this tabular data can be categorized by table type, including relational tables, as well as other types of tabular data such as flat files, hierarchical tables, multidimensional tables, NoSQL tables, and Excel spreadsheets.

[0053] In practical applications, data in relational tables is structured, typically consisting of rows (records) and columns (fields). Each row represents an independent entity, and each column represents the entity's attributes. Relational tables organize data according to the principles of the relational model, ensuring data consistency and integrity. Relational tables support constraints such as primary keys and foreign keys. As tabular data within a relational database, relational tables support indexing mechanisms, which can accelerate data retrieval. Relational tables can be used for CRUD operations (Create, Read, Update, Delete) using SQL (Structured Query Language).

[0054] Flat files contain unstructured or only minimally structured data, typically stored in simple formats such as CSV and TSV, without complex relationships. Flat files are easy to create and read, making them suitable for small projects or temporary data exchange. CSV (Comma-Separated Values) files, in particular, are simple text file formats used to store tabular data.

[0055] It's important to note that while CSV files can be used to store data similar to relational tables, they are not strictly relational tables. 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; even when storing numerical values, they are stored as text. CSV files do not define primary keys, foreign keys, or other structural constraints found in relational databases. CSV files do not support indexing mechanisms, and finding data usually requires traversing the entire file.

[0056] Hierarchical tables contain data with a tree-like structure, organized according to hierarchical relationships, and are commonly found in XML or JSON formats. Each parent node can have multiple child nodes, but each child node has only one parent node.

[0057] Data in a multidimensional table is typically viewed as a multidimensional array, organized in a multidimensional manner. Multidimensional tables can be used for data analysis, enabling rapid aggregation and slicing operations.

[0058] NoSQL tables are tabular data types within non-relational databases. Their data model can be non-relational, such as key-value pairs, document storage, or graph databases. The data schema of NoSQL tables can be dynamically changed, 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 illustrating a question-answering process based on a large language model, as shown in an exemplary embodiment of this application.

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

[0062] Specifically, the tabular data can be input into a large language model, which will then classify the data to determine its type. If the model's output determines the data is a relational table, it can be converted into a CSV file, reducing storage space. If the model's output determines the data is not a relational table, row, column, and cell keyword indexes can be created.

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

[0064] Given the query text, prompt text corresponding to the large language model can be generated based on it. 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 can contain data processing commands corresponding to the data in the aforementioned table.

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

[0066] Once the above prompt text has been generated, it can be input into a large language model, which will then perform a specific task under the guidance of the prompt text.

[0067] Specifically, on the one hand, since the prompt text contains the aforementioned query text, the large language model can perform a question-and-answer task under the guidance of the prompt text, that is, generate an answer text corresponding to the query text. On the other hand, since the prompt text also contains instruction text indicating that the answer text may contain data processing instructions corresponding to the aforementioned 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 requires specific processing of the table data, it can first replace this content with the corresponding data processing instructions. When these data processing instructions are executed, the specific processing of the table data can be achieved. In this case, the answer text generated by the large language model that corresponds to the query text and contains data processing instructions corresponding to the table data can be called the initial answer text.

[0068] Having generated the initial answer text, the data processing instructions contained in the initial answer text can be further executed to obtain the data processing result corresponding to the data processing instructions.

[0069] Specifically, an SQL instruction, serving as a data processing command, can be executed on the aforementioned table data to obtain the corresponding data processing result. Alternatively, based on the row identifier (e.g., row number) and / or column identifier (e.g., column name) included in the row and column data location command serving as the data processing command, the corresponding data can be extracted from the table data using the row index, column index, and / or cell keyword index created for the aforementioned table data. Or, a keyword search command, serving as the data processing command, can be executed to extract cell data matching the keyword in the keyword search command from the table data based on the cell keyword index created for the aforementioned table data.

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

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

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

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

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

[0075] Step 302: Obtain the 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 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.

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

[0077] For example, suppose the table data to be processed is in tabular form, used to record the monthly attendance days of company employees. The corresponding query text could be "How many monthly attendance days does a certain employee in the company have?", "How many employees in the company have more than 15 monthly attendance days?", "What is the total number of employees in the company?", etc.

[0078] In practical applications, the client component of the aforementioned intelligent dialogue system can output a specific user interface to the user, allowing the user to input query text for their questions. Furthermore, the user can also upload tabular data to assist in answering questions through this user interface. In this case, the user-input query text can be retrieved.

[0079] In some embodiments, the table data may be table 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 answers in the intelligent dialogue system; or, the table data may be table data that is pre-stored as existing data in the server included in the intelligent dialogue system; this application does not impose any special limitations on this.

[0080] In some embodiments, to facilitate subsequent data processing of the tabular data, before the intelligent dialogue system performs a tabular question-and-answer task based on the tabular data, different preprocessing can be performed on the tabular data according to the different types to which the different tabular data belong.

[0081] Specifically, the tabular data can be input into a large language model, which will then classify the data to determine its type. If the model's output determines the data is a relational table, it can be converted into a CSV file, reducing storage space. If the model's output determines the data is not a relational table, row, column, and cell keyword indexes can be created.

[0082] At this point, the aforementioned large language model can refer to its service model. In practical applications, the constructed large language model can be pre-trained on a large-scale, unlabeled text dataset using unsupervised learning to obtain its base model. Furthermore, a 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. Thus, the base model of the large language model can be used as the starting point for fine-tuning, and supervised learning can be employed to fine-tune it on the text dataset specific to the table classification task to obtain the service 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. This application does not impose any special restrictions on this.

[0084] In addition to being able to Figure 1 In addition to the server-side preprocessing of the table data shown, other electronic devices with certain computing capabilities can also perform the preprocessing of the table data and store the preprocessed table data in a storage device such as... Figure 1 In the server shown.

[0085] In this embodiment, upon obtaining the aforementioned query text, 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 commands corresponding to the aforementioned table data can be generated during the reasoning process based on the query text.

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

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

[0088] Among them, SQL commands are commands based on the Structured Query Language; row and column data locating commands are used to locate or filter specific rows or columns in a table. For example, row data can be retrieved using a row and column data locating command that includes row numbers, column data can be retrieved using a row and column data locating command that includes column names, and cell data can be retrieved using a row and column data locating command that includes a combination of row numbers and column names; keyword search commands are used to search for cells in a table that contain specific keywords, as well as the N-degree data around that cell (i.e., the data in the N rows or N columns around that cell).

[0089] For example, suppose the table data above is in tabular form, used to record the monthly attendance days of company employees, and suppose the query text is "What is the total number of company employees?". Since each row in this table is typically considered a record, and this record records the monthly attendance days of one company employee, the query can be transformed into counting the total number of rows in the table, i.e., counting the total number of records in the table. In this case, the problem can be solved by executing the SQL command "SELECT COUNT(*) FROM table" (an SQL command used to count the total number of records in a given table).

[0090] Step 304: Input the prompt text into the large language model. Guided by the prompt text, the large language model performs inference based on the query text and generates data processing instructions corresponding to the table data during the inference process.

[0091] In this embodiment, after generating the aforementioned prompt text, the prompt text can be input into a large language model, which will then perform a specific task under the guidance of the prompt text.

[0092] Specifically, on the one hand, since the prompt text contains the aforementioned query text, the large language model can perform a 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 instruction text indicating that data processing instructions corresponding to the aforementioned table data can be generated during the reasoning process based on the query text, if the large language model finds that the generated answer text should contain content that can only be obtained by specific processing of the table data when attempting to generate an answer text corresponding to the query text, it can first generate the corresponding data processing instructions, and when the data processing instructions are executed, the specific processing of the table data can be achieved.

[0093] It should be noted that the number of the aforementioned data processing instructions generated may be only one or multiple, and this application does not impose any special restrictions on this.

[0094] At this point, the aforementioned large language model can refer to its service model. In practical applications, the constructed large language model can be pre-trained on a large-scale, unlabeled text dataset using unsupervised learning to obtain its base model. Furthermore, the dialogue task can be used as a supervised learning task for fine-tuning, and a dialogue task-specific text dataset can be prepared. Thus, the base model of the large language model can be used as the starting point for fine-tuning, and supervised learning can be used to fine-tune it on the dialogue task-specific text dataset to obtain the service model of the large language model.

[0095] In practical applications, it can be achieved by, for example Figure 1 The prompt text generation component shown above will generate the prompt text as input. Figure 1 The large language model shown, guided by the prompt text, performs inference based on the query text in the prompt text, and generates data processing instructions corresponding to the table data in the above-mentioned process.

[0096] For example, suppose the table data above is in tabular form used to record the number of monthly attendance days of company employees, and suppose the query text above is "What is the total number of company employees?", then because the above large language model will find 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 during the reasoning process based on the query text, 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, in attempting to generate the 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 can first generate corresponding data processing instructions. When these instructions are executed, they can perform the specific processing of the table data and continue generating the answer text. After generating the answer text, these data processing instructions can be used to replace the content in the answer text that requires specific processing of the table data. In this case, the answer text generated by the large language model that corresponds to the query text and contains data processing instructions corresponding to the table data can be called the initial answer text.

[0098] For example, suppose the table data above is in tabular form used to record the number of monthly attendance days of company employees, and suppose the query text above is "What is the total number of company employees?", then the initial answer text generated by the above large language model corresponding to the query text could be "The total number of company employees is SELECT COUNT(*) FROM table", where "" represents the start and end positions of the SQL command.

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

[0100] In this embodiment, after generating the initial answer text, the data processing instructions contained in the initial answer text can be further executed to obtain the data processing result corresponding to the data processing instructions, and the answer text corresponding to the query text can be further generated based on the data processing result.

[0101] In practical applications, it can be achieved by, for example Figure 1 The knowledge base retrieval component shown retrieves information from sources such as... 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 the data processing result corresponding to the data processing instructions.

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

[0103] In other words, when the large language model is reasoning based on the query text to try to generate 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 specific processing of the table data, it can pause the reasoning and generate the corresponding data processing instruction to obtain the data processing result corresponding to the data processing instruction. Then, it can continue to reason based on the query text and the data processing result, thereby generating the 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 corresponding to the query text generated by the large language model. In this case, when further generating the answer text corresponding to the query text based on the data processing results, the initial answer text can be updated based on the data processing results. Specifically, the data processing results can be filled into the positions in the initial answer text corresponding to the data processing instructions, and the data processing instructions in the initial answer text can be deleted to obtain the final answer text corresponding to the query text.

[0105] For example, suppose the table data above is in tabular form used to record the monthly attendance days of company employees, and suppose the query text above is "What is the total number of company employees?", then the initial answer text generated by the above large language model corresponding to this query text could be "The total number of company employees is SELECT COUNT(*) FROM table"; further suppose that executing the SQL command "SELECT COUNT(*) FROM table" returns 100, then it means that the data processing result corresponding to this SQL command is 100. Based on this data processing result, the initial answer text is updated, and the final answer text corresponding to this query text could be "The total number of company employees is 100".

[0106] In practical applications, once the answer text corresponding to the above query text is obtained, the answer text can be further output to the user (e.g., the user who entered the query text).

[0107] In some embodiments, the data processing instructions may include SQL instructions. In this case, when executing the data processing instructions to obtain the data processing results corresponding to the data processing instructions, the SQL instructions may be executed on the table data to obtain the data processing results corresponding to the SQL instructions.

[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 to obtain the data processing results corresponding to the data processing instructions, the corresponding data can be extracted from the table data based on the row identifier (e.g., row number) and / or column identifier (e.g., column name) included in the row and column data location instructions.

[0109] Specifically, if the aforementioned row and column data locating instruction contains only row identifiers, it can be executed to extract the row data corresponding to the row identifiers in the table data, based on the row indexes created for the table data. If the aforementioned row and column data locating instruction contains only column identifiers, it can be executed to extract the column data corresponding to the column identifiers in the table data, based on the column indexes created for the table data. If the aforementioned row and column data locating instruction contains both row and column identifiers, it can be executed to extract the cell data corresponding to the row and column identifiers in the table data, based on the row and column indexes created for the table data.

[0110] In some embodiments, the data processing instructions may include keyword search instructions. In this case, when executing the data processing instruction to obtain the corresponding data processing result, the keyword search instruction may be specifically executed to extract cell data matching the keywords in the keyword search instruction from the table data, based on the cell keyword index created for the table data. Furthermore, the N-degree data surrounding the cell matching the keywords in the keyword search instruction can also be extracted from the table data based on the cell data matching the keywords in the keyword search instruction.

[0111] In one or more embodiments of the present application, the technical solution first obtains the query text input by the user corresponding to the table data to be processed, and generates a prompt text corresponding to the large language model based on the query text. The prompt text may include the query text and an instruction text indicating that a data processing instruction 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, which, guided by the prompt text, performs reasoning based on the query text and generates a data processing instruction corresponding to the table data during the reasoning process. Then, the data processing instruction in the initial answer text can be executed to obtain the 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.

[0112] By adopting the above method, the intelligent dialogue system can perform table question-and-answer tasks. Furthermore, since it can generate data processing instructions corresponding to the table data and use the data processing results corresponding to these instructions to optimize the answer text generated by the large language model in the intelligent dialogue system based on the query text, it can avoid the accuracy of table question-and-answer from relying entirely on the large language model's ability to understand and process tables. This ensures good performance in table question-and-answer tasks.

[0113] Corresponding to the embodiments of the methods described above, this application also provides embodiments of the apparatus.

[0114] Please refer to Figure 4 , Figure 4 This is a schematic diagram illustrating the structure of a device according to an exemplary embodiment of this application. At the hardware level, the device includes a processor 402, an internal bus 404, a network interface 406, memory 408, and non-volatile memory 410, and may also include other necessary hardware. One or more embodiments of this application can be implemented in software, for example, the processor 402 reads the corresponding computer program from the non-volatile memory 410 into memory 408 and then runs it. Of course, besides software implementation, one or more embodiments of this application do not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. That is to say, the execution entity of the following processing flow is not limited to individual logic modules, but can also be hardware or logic devices.

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

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

[0117] The prompt generation module 502 obtains the 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 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;

[0118] The answer generation module 504 inputs the prompt text into the large language model, which, 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 the data processing result corresponding to the data processing instruction, and further generates the answer text corresponding to the query text based on the data processing result.

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

[0121] The data processing results are input into the large language model, which then performs further reasoning based on the query text and the data processing results to generate the answer text corresponding to the query text.

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

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

[0124] 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 the final answer text corresponding to the query text.

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

[0126] The table determination module inputs the table data into the large language model, and the large language model determines the type of the table data.

[0127] The table conversion module converts the table data into comma-separated CSV format table data 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, create row indexes, column indexes, and cell keyword indexes for the table data.

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

[0131] The execution of the data processing instruction to obtain the data processing result corresponding to the data processing instruction includes:

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

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

[0134] The execution of the data processing instruction to obtain the data processing result corresponding to the data processing instruction includes:

[0135] Execute the row and column data positioning instruction, and extract the row data corresponding to the row identifier in the row and column data positioning instruction from the table data based on the row index;

[0136] Execute the row and column data location instruction, and extract the column data corresponding to the column identifier in the row and column data location instruction from the table data based on the column index; or,

[0137] Execute the row and column data location instruction, and extract the cell data corresponding to the row identifier and column identifier in the row and column data location instruction from the table data based on the row index and the column index.

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

[0139] The execution of the data processing instruction to obtain the data processing result corresponding to the data processing instruction includes:

[0140] Execute the keyword search instruction, and extract cell data that matches the keyword in the keyword search instruction from the table data based on the cell keyword index.

[0141] For the device embodiments, they basically correspond to the method embodiments; therefore, relevant details can be found in the descriptions of the method embodiments. The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate, and the components shown 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 can be selected to achieve the purpose of the technical solution of this application according to actual needs.

[0142] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or physical entities, or by products with certain functions. A typical implementation device is a computer, which can take the form of a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email sending and receiving device, 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-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0145] Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can store information using 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 technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0146] It should be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0147] The foregoing has described specific embodiments of this application. Other embodiments are within the scope of this application. In some cases, the actions or steps described in this application may be performed in a different order than those shown in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require a specific or sequential order to achieve the desired results. In some implementations, multitasking and parallel processing are also possible or may be advantageous.

[0148] The terminology used in one or more embodiments of this application is for the purpose of describing particular embodiments only and is not intended to limit the scope of one or more embodiments of this 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 associated listed items.

[0149] The terms "an embodiment," "some embodiments," "example," "specific example," or "one implementation," as used in one or more embodiments of this application, refer to specific features or characteristics described in connection with that embodiment, which are included in at least one embodiment of this application. Illustrative descriptions of these terms do not necessarily refer to the same embodiment. Furthermore, the described specific features or characteristics may be combined in a suitable manner in one or more embodiments of this application. In addition, different embodiments and specific features or characteristics from different embodiments may be combined without contradiction.

[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 this application, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of one or more embodiments of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."

[0151] The above description is merely a preferred embodiment of one or more embodiments of this application and is not intended to limit the scope of one or more embodiments of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of one or more embodiments of this application should be included within the protection scope of one or more embodiments of this 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, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.

Claims

1. A question-answering method based on a large language model, the method comprising: Obtain the query text corresponding to the table 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 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; The prompt text is input into the large language model, which, guided by the prompt text, performs inference based on the query text and generates data processing instructions corresponding to the table data and an initial answer text corresponding to the query text during the inference process. Execute the data processing instruction to obtain the data processing result corresponding to the data processing instruction, and update the initial answer text based on the data processing result to obtain the final answer text corresponding to the query text.

2. The method according to claim 1, wherein updating the initial answer text based on the data processing result to obtain the final answer text corresponding to the query text includes: The data processing results are input into the large language model, which then performs further reasoning based on the query text, the data processing results, and the initial answer text to generate the answer text corresponding to the query text.

3. The method according to claim 1, wherein the data processing instructions are included in the initial answer text corresponding to the query text generated by the large language model; The step of updating the initial answer text based on the data processing result to obtain the final answer text corresponding to the query text 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 the final answer text corresponding to the query text.

4. The method according to claim 1, further comprising: The tabular data is input into a large language model, which determines the type of the tabular data. If the table data is relational table data, convert the table data into table data stored in comma-separated CSV format.

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

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

7. The method according to claim 5, wherein the data processing instructions include row and column data positioning instructions; The execution of the data processing instruction to obtain the data processing result corresponding to the data processing instruction includes: Execute the row and column data positioning instruction, and extract the 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 location instruction, and extract the column data corresponding to the column identifier in the row and column data location instruction from the table data based on the column index; or, Execute the row and column data location instruction, and extract the cell data corresponding to the row identifier and column identifier in the row and column data location instruction from the table data based on the row index and the column index.

8. The method according to claim 5, wherein the data processing instruction includes a keyword search instruction; The execution of the data processing instruction to obtain the data processing result corresponding to the data processing instruction includes: Execute the keyword search instruction, and extract cell data that matches the keyword in the keyword search instruction from the table data based on the cell keyword index.

9. A question-answering device based on a large language model, the device comprising: The prompt generation module obtains the 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 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; The answer generation module inputs the prompt text into the large language model, which, guided by the prompt text, performs reasoning based on the query text and generates data processing instructions corresponding to the table data, as well as initial answer text corresponding to the query text during the reasoning process. The table processing module executes the data processing instructions to obtain the data processing results corresponding to the data processing instructions, and updates the initial answer text based on the data processing results to obtain the final answer text corresponding to the query text.

10. An electronic device, comprising: processor; Memory used to store processor-executable instructions; The processor implements the method as described in any one of claims 1 to 8 by executing the executable instructions.

11. A computer-readable storage medium having stored thereon computer instructions that, when executed by a processor, implement the method as described in 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