Table-to-text conversion method, system and device and medium
By obtaining and updating the dictionary in the table text conversion method and using the language model to generate text, the problems of high computing resources, long inference and low generation accuracy in the existing methods are solved, and more efficient and accurate table conversion is achieved Text-making process.
Patent Information
- Application Number
- CN202411426173.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-12
- Publication Date
- 2025-02-11
AI Technical Summary
The existing pseudo-text conversion methods are relatively time-consuming in computing resources and inference, and the generated natural language description text is not very accurate.
By obtaining the first dictionary that records the key query information, the data table to be converted and the corresponding prompt, the target table type data is retrieved using the language model, and the dictionary is updated based on the data, and finally the target generated text is generated.
This method effectively reduces the computing resources and inference time required for converting tables into text, improves generation accuracy, and alleviates the illusion problem of large language models.
Smart Images

Figure CN119416741A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method, system, device and medium for converting table-to-text. Background Art
[0002] With the advent of the big data era, the amount of information is growing exponentially, and a large amount of data exists in the form of tables. Although tables provide users with a clear way to organize data, it is still difficult for the majority of users who do not have professional background knowledge to directly read and understand the table content. Therefore, converting tabular data into easy-to-understand natural language descriptions has become one of the key issues that people are concerned about.
[0003] At present, traditional table-to-text conversion methods can be roughly divided into two categories. The first type of conversion method mainly uses a pre-trained large language model to directly generate natural language description text corresponding to the tabular data. This method requires more computing resources and takes a long time to infer and generate. The second type of conversion method mainly directly inputs the tabular data and the corresponding prompts into the large language model, and the large language model generates natural language description text corresponding to the tabular data. The accuracy of the natural language description text generated by this method is not high.
[0004] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the invention
[0005] The purpose of the present invention is to solve one of the technical problems existing in the related art to at least a certain extent.
[0006] The main purpose of the embodiments of the present application is to propose a table-to-text conversion method, which can reduce the computing resources and reasoning time required for converting tables into text, and improve the generation accuracy of converting tables into text.
[0007] To achieve the above purpose, an embodiment of the present application provides a method for converting table-to-text, the method comprising:
[0008] Acquire a first dictionary recording key query information, a data table to be converted, and a first prompt corresponding to the key query information, wherein the first prompt is used to instruct to retrieve table type data corresponding to the key query information in the data table;
[0009] Inputting the data table and the first prompt into a language model, and obtaining target table type data through the language model;
[0010] According to the target table type data, the first dictionary is stored and updated to obtain a second dictionary;
[0011] The second dictionary and the second prompt are input into the language model to obtain a target generated text, wherein the second prompt is used to instruct to retrieve the dictionary structure data corresponding to the key query information in the second dictionary.
[0012] In some embodiments, obtaining a first dictionary recording key query information includes:
[0013] Get the user query statement and initial dictionary input by the user;
[0014] Extract key information from at least one query question in the user query statement to obtain the key query information, where each query question corresponds to one key query information;
[0015] The initial dictionary is updated with key information according to the key query information to obtain the first dictionary.
[0016] In some embodiments, extracting key information from at least one query question in the user query statement to obtain the key query information includes:
[0017] Acquire a third prompt corresponding to at least one of the query questions;
[0018] The user query statement and the third prompt are input into the language model to obtain the key query information output by the language model.
[0019] In some embodiments, storing and updating the first dictionary according to the target table type data, and obtaining the second dictionary through the language model includes:
[0020] Obtaining the dictionary structure of the first dictionary;
[0021] Based on the dictionary structure, the target table type data is classified into a dictionary structure to obtain a table data key and a table data value, wherein the table data key is used to indicate a table attribute corresponding to the key query information in the target table type data, and the table data value is used to indicate a table value corresponding to the table attribute in the target table type data;
[0022] The first dictionary is updated by performing key-value storage according to the table data key and the table data value to obtain the second dictionary.
[0023] In some embodiments, performing key-value storage update on the first dictionary according to the table data key and the table data value to obtain the second dictionary includes:
[0024] According to the table data key, performing a key value query verification on the first dictionary to obtain a query verification result, wherein the query verification result is used to indicate whether the first dictionary has an attribute key corresponding to the table data key;
[0025] If the query verification result indicates that the first dictionary does not have an attribute key corresponding to the table data key, then the first dictionary is updated with key values according to the table data key and the table data value to obtain the second dictionary; or, if the query verification result indicates that the first dictionary has an attribute key corresponding to the table data key, a preset dictionary update condition is obtained, and the first dictionary is conditionally updated according to the dictionary update condition, the table data key and the table data value to obtain the second dictionary.
[0026] In some embodiments, storing and updating the first dictionary according to the target table type data to obtain the second dictionary includes:
[0027] Acquire a third prompt corresponding to the target table type data, wherein the third prompt is used to instruct to generate dictionary structure data corresponding to the target table type data;
[0028] Inputting the third prompt and the target table type data into the language model, and generating first dictionary structure data through the language model;
[0029] The first dictionary is updated according to the first dictionary structure data to obtain the second dictionary.
[0030] In some embodiments, the step of inputting the second dictionary and the second prompt into the language model to obtain the target generated text includes:
[0031] Inputting the second dictionary and the second prompt into the language model, and obtaining second dictionary structure data through the language model;
[0032] The fourth prompt and all the second dictionary structure data are input into the language model, and the target generated text is obtained through the language model, wherein the fourth prompt is used to instruct the generation of a natural language text corresponding to the user query statement.
[0033] To achieve the above purpose, another aspect of the present application provides a table-to-text conversion system, including:
[0034] A first processing unit is used to obtain a first dictionary recording key query information, a data table to be converted, and a first prompt corresponding to the key query information, wherein the first prompt is used to instruct to retrieve table type data corresponding to the key query information in the data table;
[0035] A second processing unit, configured to input the data table and the first prompt into a language model, and obtain target table type data through the language model;
[0036] A third processing unit, configured to store and update the first dictionary according to the target table type data to obtain a second dictionary;
[0037] The fourth processing unit is used to input the second dictionary and the second prompt into the language model to obtain a target generated text, wherein the second prompt is used to instruct to retrieve the dictionary structure data corresponding to the key query information in the second dictionary.
[0038] To achieve the above-mentioned purpose, another aspect of an embodiment of the present application provides an electronic device, the electronic device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the above-mentioned method when executing the computer program.
[0039] To achieve the above objective, another aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described above is implemented.
[0040] The embodiments of the present application include at least the following beneficial effects:
[0041] The present application provides a method, system, device and medium for converting table-generated text, wherein the conversion method obtains a first dictionary recording key query information, a data table to be converted and a first prompt corresponding to the key query information, wherein the first prompt is used to indicate the retrieval of table type data corresponding to the key query information in the data table; the data table and the first prompt are input into a language model, and the target table type data is obtained through the language model; according to the target table type data, the first dictionary is stored and updated to obtain a second dictionary; the second dictionary and the second prompt are input into the language model to obtain the target generated text, wherein the second prompt is used to indicate the retrieval of the dictionary structure data corresponding to the key query information in the second dictionary. The conversion method determines the target table type data based on the data table, and constructs a dictionary data structure based on the attributes and values of the target table type data, which can reduce the scale of the table data used to generate the text, and can effectively reduce the required computing resources and reasoning time; in addition, the conversion method also outputs the corresponding natural language text based on the second dictionary related to the user query statement, which can effectively alleviate the hallucination problem of the large language model and improve the generation accuracy of the table conversion text. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 It is a flowchart of a table-to-text conversion method provided in an embodiment of the present application;
[0043] Figure 2 is a detailed flow chart of step S110 provided in an embodiment of the present application;
[0044] Figure 3 is a detailed flow chart of step A2 provided in an embodiment of the present application;
[0045] Figure 4 is a detailed flow chart of step S130 provided in an embodiment of the present application;
[0046] Figure 5 is a detailed flow chart of step B3 provided in an embodiment of the present application;
[0047] Figure 6 is a logic diagram of step B3 provided in an embodiment of the present application;
[0048] Figure 7 is a detailed flow chart of step S130 provided in an embodiment of the present application;
[0049] Figure 8 is a detailed flow chart of step S140 provided in an embodiment of the present application;
[0050] Fig. 9 It is a schematic diagram of a framework of a table-to-text conversion system provided in an embodiment of the present application;
[0051] Fig.10 It is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers 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 the embodiments of the present application. They are only examples of devices / equipment and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.
[0053] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment 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 words "if" and "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determination".
[0054] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.
[0055] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0056] Before describing the embodiments of the present application in detail, the terms involved in the embodiments of the present application are first explained:
[0057] Table-to-Text Generation, that is, table-based text generation, refers to the process of converting structured tabular data into coherent and organized natural language description text, which can present data information in a human-readable way and improve the efficiency of human understanding of information.
[0058] The hallucination problem usually refers to the situation where the information or statements generated by the language model, although they appear confident and reasonable, are actually inaccurate, unreasonable or even completely wrong.
[0059] At present, the traditional table-to-text conversion methods can be roughly divided into two categories. The first type of conversion method mainly generates natural language description text corresponding to the table data directly through a pre-trained large language model. The pre-trained large language model can be trained based on a language model fine-tuning method for a specific task, an instruction fine-tuning method on multiple data sets, and a fine-tuning method based on retrieval enhancement. However, since it is difficult to obtain a data set for fine-tuning a large language model, and the data set size requirements for fine-tuning a large language model are relatively high, the computing resources required for fine-tuning a large language model are relatively large, the cost is high, and the time required for inference generation is long.
[0060] The second conversion method is mainly based on direct prompts, which is to input the table data and the corresponding prompts into the large language model, and the large language model generates natural language description text corresponding to the table data. However, since large-scale table data often contains data relationships of multiple dimensions and levels, the large language model lacks in-depth understanding and utilization of the internal logical relationship of the table data based on the direct prompt method, and cannot accurately capture and express the complex relationship between large-scale table data. It is easy to have hallucination problems, resulting in the loss of information of large-scale table data or incorrect text descriptions, and the accuracy of table conversion text generation is unsatisfactory.
[0061] In view of this, the embodiments of the present application provide a table-to-text conversion method, system, device and medium, wherein the conversion method determines the target table type data based on the data table, and constructs a dictionary data structure based on the attributes and values of the target table type data, which can reduce the scale of the table data used to generate the text, and can effectively reduce the required computing resources and reasoning time; in addition, the conversion method also outputs the corresponding natural language text based on the second dictionary related to the user query statement, which can effectively alleviate the hallucination problem of the large language model and improve the generation accuracy of the table conversion text.
[0062] Specifically, the embodiment of the present application can query only the key information in the user input through the first dictionary that records the key query information, thereby preventing redundant information from interfering with the model-generated text; in addition, the embodiment of the present application uses the second dictionary data structure as an intermediate transition data structure between the table and the natural language text, fills the data content in the table into the dictionary data structure, and intuitively reflects the meaning of the data through key-value pairs and key names, which facilitates the rapid positioning and understanding of data items, and greatly reduces the illusion and difficulty of the language model generating text based only on structured tabular data.
[0063] In addition, the language model in the embodiment of the present application only outputs answers based on a dictionary consisting of key information and corresponding data content, which is significantly smaller than the size of the original table, thereby greatly reducing the difficulty of reasoning based on the dictionary and reducing the reasoning delay. There is no need to understand the specific structure or index of the table. The keys in the dictionary data structure are highly correlated with the user questions and are easier to convert into natural language text, which can effectively reduce the difficulty of reasoning and thus improve the accuracy of natural language text generation.
[0064] The table-to-text conversion method provided in the embodiment of the present application can be applied to the table data processing application scenario. In the table data processing application scenario, the data processing service provider can use the table-to-text conversion method provided in the embodiment of the present application to convert the table data to be processed into the natural language description text required by the user based on the query statement provided by the user, which helps the user understand the content of the table data, reduces the computing resources and time required for converting the table into text, and improves the generation accuracy of the table conversion text.
[0065] A table-to-text conversion method provided in an embodiment of the present application can be applied to a terminal, a server, or software running in a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and a car terminal, etc., but is not limited to this; the server side can be configured as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The server can also be a node server in a blockchain network; the software can be an application that implements the method, etc., but is not limited to the above forms.
[0066] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0067] Reference Figure 1 , Figure 1 is an optional flow chart of a table-to-text conversion method provided in an embodiment of the present application. Figure 1 The conversion method may include but is not limited to steps S110 to S140.
[0068] Step S110, obtaining a first dictionary recording key query information, a data table to be converted, and a first prompt corresponding to the key query information, wherein the first prompt is used to instruct to retrieve table type data corresponding to the key query information in the data table;
[0069] Reference Figure 2 In some embodiments, the step S110 of obtaining a first dictionary recording key query information includes:
[0070] A1. Obtaining a user query statement and an initial dictionary input by the user;
[0071] In the embodiment of the present application, the data table to be converted can be a data table used for querying the language model, and the data table contains a large number of multi-column field information, and the specific field information can include any one of the item name attribute, type attribute, time attribute, location attribute, etc. Specifically, the embodiment of the present application takes a data table that records the unique attribute values of items at different times and places as an example, and the column attributes in the data table can specifically include item type, time, location, attribute A, attribute B, attribute C, attribute D, etc., wherein attribute A, attribute B, attribute C and attribute D are the unique attribute values of items at different times and places, and the specific unique attribute values can be determined according to the item type or obtained according to the actual situation. For example, if the item type of a certain item is a broadband network cable, then its corresponding unique attribute value can be at least one of the transmission frequency, transmission rate, wire type, number of wire cores, etc. The example of the present application is for illustration only and does not limit the present application.
[0072] It can be understood that the first prompt is used to instruct the language model to retrieve table-type data corresponding to the key query information in the data table, and the first prompt can be obtained based on prompt engineering technology by constructing a prompt corresponding to the key query information in the first dictionary. Specifically, the first prompt in the embodiment of the present application can be "query corresponding data in the data table based on the key query information".
[0073] It should be noted that the initial dictionary can be determined by initializing a blank dictionary data structure, and the initial dictionary can store data in the form of key-value pairs. In actual applications, the initial dictionary can initialize a blank dictionary data structure in each table-to-text conversion process to obtain an initial dictionary corresponding to each table-to-text conversion process; or, for the first table-to-text conversion process, the initial dictionary can be determined by initializing a blank dictionary data structure, and for the second and subsequent table-to-text conversion processes, the second dictionary in the previous table-to-text conversion process can be determined as the initial dictionary in the current table-to-text conversion process.
[0074] It is worth mentioning that the user query statement input by the user is used to make clear requirements for specific fields in the data table. The user query statement can specifically be a user's query on the unique attribute value of an item at a certain time and place, such as "What is the value of attribute C of the broadband network cable at time T1 and location S1". In addition, in actual applications, the user query statement input by the user may also contain multiple query questions, such as "What is the value of attribute C of the broadband network cable at time T1 and location S1? What are the values of each attribute of the router at time TI and location S2?", etc. This application only illustrates specific examples of user query statements. The specific query questions input by the user and the specific input format of the user query statement can be flexibly changed according to actual conditions, and this application does not limit them here.
[0075] A2. Extract key information from at least one query question in the user query statement to obtain the key query information, where each query question corresponds to one key query information;
[0076] Reference Figure 3 Further, the step A2, extracting key information from at least one query question in the user query statement to obtain the key query information, includes:
[0077] A21, obtaining a third prompt corresponding to at least one of the query questions;
[0078] A22. Input the user query statement and the third prompt into the language model to obtain the key query information output by the language model.
[0079] In the embodiments of the present application, the language model may specifically be a large language model (LLM), which may specifically be an offline large language model, such as the Xingchen Semantic Large Language Model telechat, or a web-based large language model, such as kimi, Tongyi Qianwen, etc. The large language model in the examples of the present application is for illustration only and is not intended to limit the present application.
[0080] It is understandable that a third prompt corresponding to at least one query question in the user's query statement can be constructed based on the prompt project. The third prompt is used to instruct the language model to generate key query information corresponding to at least one query question. The third prompt can be "Extract the key information corresponding to the first query question in the user input", "Extract the key information corresponding to the third query question in the user input", "Please extract the key information in the query statement entered by the user", etc.
[0081] It should be noted that step A22 can be to input the third prompt and the user query statement into the language model, and guide the language model to extract key information in the input user query statement through the third prompt to obtain key query information output by the language model. The key query information can be the key query information corresponding to a query question in the user query statement, or it can be the key query information corresponding to all query questions in the user query statement.
[0082] A3. Update the key information of the initial dictionary according to the key query information to obtain the first dictionary.
[0083] In an embodiment of the present application, if the initial dictionary is obtained based on initializing a blank dictionary data structure, the key information update in step A3 can directly store the extracted key query information in the initial dictionary, thereby obtaining a first dictionary recording the key query information. The first dictionary only retains the key information corresponding to the query question of the user's query statement, which can reduce the interference of redundant information on the language model, so that the language model can answer based on the dictionary corresponding to the query question one by one, which can reduce information confusion, reduce the possibility of hallucinations in the language model, and improve the quality of converting tables into text.
[0084] It can be understood that if the initial dictionary is obtained based on the second dictionary in the last table-to-text conversion process, the key information update in step A3 can be to store the key query information in the initial dictionary and, after at least one of deletion, annotation, replacement, and addition, obtain the first dictionary recording the key query information.
[0085] Specifically, in a first feasible implementation manner, step A3 may be to delete the dictionary structure data contained in the initial dictionary (i.e., the second dictionary in the last table-to-text conversion process) and the key query information corresponding to the last table-to-text conversion process, and then add the key query information corresponding to the current table-to-text conversion process to the initial dictionary; or, in a second feasible implementation manner, step A3 may be to annotate the dictionary structure data contained in the initial dictionary (i.e., the second dictionary in the last table-to-text conversion process) and the key query information corresponding to the last table-to-text conversion process, so that the dictionary structure data and the key query information in the last table-to-text conversion process do not affect the current table-to-text conversion process, and then add the key query information corresponding to the current table-to-text conversion process to the initial dictionary; or, in a third feasible implementation manner, for the user's continuous table-to-text conversion process, the key query information corresponding to the last table-to-text conversion process in the initial dictionary can be replaced and updated based on the key query information of the current table-to-text conversion process, so as to obtain the first dictionary. The examples in this application are for illustration only.
[0086] Step S120, inputting the data table and the first prompt into a language model, and obtaining target table type data through the language model;
[0087] In an embodiment of the present application, step S120 may be to input the data table and the first prompt into the language model, guide the language model through the first prompt to retrieve the data corresponding to the key query information in the data table, and then determine the retrieved data values and the attributes corresponding to the key query information as the target table type data.
[0088] It is understandable that the attribute corresponding to the key query information in the embodiment of the present application may be a column attribute in the aforementioned data table, and the retrieved data value may be a data value corresponding to the column attribute. For example, in a certain data table, the location attribute may be a column attribute in the data table, and S1 or S2 corresponding to the location attribute may be a data value corresponding to the time attribute, which is not elaborated in this application.
[0089] Step S130, storing and updating the first dictionary according to the target table type data to obtain a second dictionary;
[0090] Reference Figure 4 In some embodiments, the step S130, storing and updating the first dictionary according to the target table type data, and obtaining the second dictionary through the language model, includes:
[0091] B1. Obtaining the dictionary structure of the first dictionary;
[0092] B2. Based on the dictionary structure, the target table type data is classified into a dictionary structure to obtain a table data key and a table data value, wherein the table data key is used to indicate a table attribute corresponding to the key query information in the target table type data, and the table data value is used to indicate a table value corresponding to the table attribute in the target table type data;
[0093] In an embodiment of the present application, the dictionary structure of the first dictionary may be a dictionary data structure adopted by the first dictionary, which may specifically be a key-value pair structure; the dictionary structure classification of step B2 may be based on the key-value pair structure, and dictionary structure classification of the target table type data may be performed, specifically, the attribute corresponding to the key query information in the target table type data may be determined as a key structure in the key-value pair structure, thereby obtaining the table data key, and at the same time, the retrieved data value may be determined as a value structure of the key-value pair structure, thereby obtaining the table data value.
[0094] B3. Perform key-value storage update on the first dictionary according to the table data key and the table data value to obtain the second dictionary.
[0095] Reference Figure 5 and Figure 6 Further, the step B3, performing key-value storage update on the first dictionary according to the table data key and the table data value to obtain the second dictionary, includes:
[0096] B31. Perform a key value query verification on the first dictionary according to the table data key to obtain a query verification result, where the query verification result is used to indicate whether the first dictionary has an attribute key corresponding to the table data key;
[0097] B32. If the query verification result indicates that the first dictionary does not have an attribute key corresponding to the table data key, then according to the table data key and the table data value, key values are added and updated to the first dictionary to obtain the second dictionary;
[0098] Alternatively, B33, if the query verification result indicates that the first dictionary has an attribute key corresponding to the table data key, then obtain a preset dictionary update condition, and perform conditional update on the first dictionary according to the dictionary update condition, the table data key and the table data value to obtain the second dictionary.
[0099] In an embodiment of the present application, for a certain table data key and the table data value corresponding to the table data key, the key value query verification in step B31 can be to retrieve whether there is dictionary structure data (i.e., attribute key) corresponding to the table data key in the first dictionary. If the first dictionary does not have dictionary structure data corresponding to the table data key, a query verification result indicating that there is no dictionary structure data corresponding to the table data key can be obtained; or, if the first dictionary has dictionary structure data corresponding to the table data key, a query verification result indicating that there is dictionary structure data corresponding to the table data key can be obtained.
[0100] It can be understood that if the query verification result is that there is no dictionary structure data corresponding to the table data key, step B32 can be in the form of a key-value pair, directly adding the table data key and the table data value to the first dictionary, and determining the added first dictionary as the second dictionary; or, if the query verification result is that there is a dictionary structure data corresponding to the table data key, step B32 can be based on a preset dictionary update adjustment, and the first dictionary is updated based on the table data key and the table data value, so as to obtain the second dictionary.
[0101] It should be noted that the dictionary update condition in step B33 can be an update condition such as replacement or addition. The specific dictionary update condition can be set according to actual conditions. For example, when the dictionary update condition is replacement, the original dictionary structure data of the first dictionary can be replaced based on the current table data key and table data value, so as to achieve replacement update and obtain the second dictionary; or, when the dictionary update condition is addition, the current table data key and table data value can be added to the original dictionary structure data of the first dictionary, so as to achieve addition update and obtain the second dictionary. The example of this application is only for illustration and does not limit the present application. For the remaining table data keys and the table data keys, they are similar to the above content and can be simply deduced by analogy.
[0102] Reference Figure 7 In some other embodiments, the step S130, storing and updating the first dictionary according to the target table type data to obtain a second dictionary, includes:
[0103] C1. Acquire a third prompt corresponding to the target table type data, wherein the third prompt is used to instruct to generate dictionary structure data corresponding to the target table type data;
[0104] C2, inputting the third prompt and the target table type data into the language model, and generating first dictionary structure data through the language model;
[0105] C3. Update the first dictionary according to the first dictionary structure data to obtain the second dictionary.
[0106] In the embodiment of the present application, the third prompt is used to instruct the language model to generate dictionary structure data corresponding to the target table type data. The third prompt may be "construct dictionary structure data based on the acquired target table type data".
[0107] It is understandable that step C2 may be to input the third prompt and the target table type data into the language model, and guide the language model through the third prompt to identify and output the column attributes and data values in the target table type data, so as to obtain the first dictionary structure data.
[0108] It should be noted that, in a first feasible implementation manner, the dictionary update in step C3 may first be to obtain a fifth prompt, where the fifth prompt is used to instruct the language model to update the first dictionary according to the first dictionary structure data; then the fifth prompt, the first dictionary structure and the first dictionary are input into the language model, and the language model is guided by the fifth prompt to update the first dictionary based on the first dictionary structure, so as to obtain a second dictionary output by the language model; or, in a second feasible implementation manner, the dictionary update in step C3 may be similar to the aforementioned step B3, and may be simply deduced, and this application will not elaborate on this.
[0109] Step S140: input the second dictionary and the second prompt into the language model to obtain a target generated text, wherein the second prompt is used to instruct to retrieve dictionary structure data corresponding to the key query information in the second dictionary.
[0110] Reference Figure 8 In some embodiments, the step S140 of inputting the second dictionary and the second prompt into the language model to obtain the target generated text includes:
[0111] D1, inputting the second dictionary and the second prompt into the language model, and obtaining second dictionary structure data through the language model;
[0112] D2. Inputting a fourth prompt and all the second dictionary structure data into the language model, and obtaining the target generated text through the language model, wherein the fourth prompt is used to instruct the generation of a natural language text corresponding to the user query statement.
[0113] In an embodiment of the present application, the second prompt is used to instruct the language model to retrieve dictionary structure data corresponding to the key query information in the second dictionary, and the fourth prompt is used to instruct the language model to generate natural language text corresponding to the user query statement based on the second dictionary structure data in the second dictionary.
[0114] It can be understood that step D1 can be to input the second dictionary and the second prompt into the language model, and guide the language model through the second prompt to extract the second dictionary structure data corresponding to the key query information from the constructed second dictionary; then input the fourth prompt and all the extracted second dictionary structure data into the language model, and guide the language model through the fourth prompt to generate a natural language text (i.e., the target generated text) that can answer the user's query statement based on all the second dictionary structure data.
[0115] See also Fig. 9 The embodiment of the present application also provides a table-to-text conversion system, the conversion system comprising:
[0116] The first processing unit 810 is used to obtain a first dictionary recording key query information, a data table to be converted, and a first prompt corresponding to the key query information, wherein the first prompt is used to instruct to retrieve table type data corresponding to the key query information in the data table;
[0117] A second processing unit 820 is used to input the data table and the first prompt into a language model, and obtain target table type data through the language model;
[0118] A third processing unit 830 is used to store and update the first dictionary according to the target table type data to obtain a second dictionary;
[0119] The fourth processing unit 840 is configured to input the second dictionary and the second prompt into the language model to obtain a target generated text, wherein the second prompt is used to instruct to retrieve the dictionary structure data corresponding to the key query information in the second dictionary.
[0120] It can be understood that the contents of the above method embodiments are all applicable to the present system embodiments, the functions specifically implemented by the present system embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0121] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0122] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0123] See also Fig.10 , Fig.10 The hardware structure of an electronic device of an embodiment is illustrated, and the electronic device includes:
[0124] The processor 901 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0125] The memory 902 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 902 can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 902, and the processor 901 calls and executes the methods of the embodiments of this application;
[0126] Input / output interface 903, used to implement information input and output;
[0127] Communication interface 904, used to realize communication interaction between the device and other devices, which can be realized by wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);
[0128] A bus 905 that transmits information between various components of the device (e.g., the processor 901, the memory 902, the input / output interface 903, and the communication interface 904);
[0129] The processor 901 , the memory 902 , the input / output interface 903 and the communication interface 904 are connected to each other in communication within the device via a bus 905 .
[0130] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program, and the computer program implements the above method when executed by a processor.
[0131] It can be understood that the contents of the above method embodiments are all applicable to the present storage medium embodiments, the functions specifically implemented by the present storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0132] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0133] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0134] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0135] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0136] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0137] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0138] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0139] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0140] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0141] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0142] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0143] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A method for converting table-to-text, characterized in that: include: Acquire a first dictionary recording key query information, a data table to be converted, and a first prompt corresponding to the key query information, wherein the first prompt is used to instruct to retrieve table type data corresponding to the key query information in the data table; Inputting the data table and the first prompt into a language model, and obtaining target table type data through the language model; According to the target table type data, the first dictionary is stored and updated to obtain a second dictionary; The second dictionary and the second prompt are input into the language model to obtain a target generated text, wherein the second prompt is used to instruct to retrieve the dictionary structure data corresponding to the key query information in the second dictionary.
2. The method for converting table-to-text according to claim 1, characterized in that: The obtaining of the first dictionary having key query information includes: Get the user query statement and initial dictionary input by the user; Extract key information from at least one query question in the user query statement to obtain the key query information, where each query question corresponds to one key query information; The initial dictionary is updated with key information according to the key query information to obtain the first dictionary.
3. The method for converting table-to-text according to claim 2, characterized in that: The step of extracting key information from at least one query question in the user query statement to obtain the key query information includes: Acquire a third prompt corresponding to at least one of the query questions; The user query statement and the third prompt are input into the language model to obtain the key query information output by the language model.
4. The method for converting table-to-text according to claim 1, characterized in that: The storing and updating the first dictionary according to the target table type data, and obtaining the second dictionary through the language model, comprises: Obtaining the dictionary structure of the first dictionary; Based on the dictionary structure, the target table type data is classified into a dictionary structure to obtain a table data key and a table data value, wherein the table data key is used to indicate a table attribute corresponding to the key query information in the target table type data, and the table data value is used to indicate a table value corresponding to the table attribute in the target table type data; The first dictionary is updated by performing key-value storage according to the table data key and the table data value to obtain the second dictionary.
5. The method for converting table-to-text according to claim 4, characterized in that: The step of performing key-value storage update on the first dictionary according to the table data key and the table data value to obtain the second dictionary includes: According to the table data key, performing a key value query verification on the first dictionary to obtain a query verification result, wherein the query verification result is used to indicate whether the first dictionary has an attribute key corresponding to the table data key; If the query verification result indicates that the first dictionary does not have an attribute key corresponding to the table data key, then the first dictionary is updated with key values according to the table data key and the table data value to obtain the second dictionary; or, if the query verification result indicates that the first dictionary has an attribute key corresponding to the table data key, a preset dictionary update condition is obtained, and the first dictionary is conditionally updated according to the dictionary update condition, the table data key and the table data value to obtain the second dictionary.
6. The method for converting table-to-text according to claim 1, characterized in that: The storing and updating the first dictionary according to the target table type data to obtain a second dictionary includes: Acquire a third prompt corresponding to the target table type data, wherein the third prompt is used to instruct to generate dictionary structure data corresponding to the target table type data; Inputting the third prompt and the target table type data into the language model, and generating first dictionary structure data through the language model; The first dictionary is updated according to the first dictionary structure data to obtain the second dictionary.
7. The method for converting table-to-text according to any one of claims 1 to 6, characterized in that: The step of inputting the second dictionary and the second prompt into the language model to obtain a target generated text includes: Inputting the second dictionary and the second prompt into the language model, and obtaining second dictionary structure data through the language model; The fourth prompt and all the second dictionary structure data are input into the language model, and the target generated text is obtained through the language model, wherein the fourth prompt is used to instruct the generation of a natural language text corresponding to the user query statement.
8. A table-to-text conversion system, characterized in that: include: A first processing unit is used to obtain a first dictionary recording key query information, a data table to be converted, and a first prompt corresponding to the key query information, wherein the first prompt is used to instruct to retrieve table type data corresponding to the key query information in the data table; A second processing unit, configured to input the data table and the first prompt into a language model, and obtain target table type data through the language model; A third processing unit, configured to store and update the first dictionary according to the target table type data to obtain a second dictionary; The fourth processing unit is used to input the second dictionary and the second prompt into the language model to obtain a target generated text, wherein the second prompt is used to instruct to retrieve the dictionary structure data corresponding to the key query information in the second dictionary.
9. An electronic device, characterized in that: include: at least one processor; at least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements the method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Cell type acquisition method and system
CN120724287A