Prompt method and system for automatically generating large model based on table and electronic equipment

By automatically generating large model prompts, the problem of difficulty in using unstructured tables is solved, the flexibility and effect of form question and answer are improved, and the effective extraction and prompting of the overall content of the form is achieved.

CN118733588APending Publication Date: 2024-10-01GUANGZHOU YUNCONG INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410832706.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-26
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

In the existing table question and answer technology based on large models, it is difficult to use database patterns as prompts for unstructured tables (such as xlsx files), resulting in low flexibility of question and answer and incomplete prompt information.

Method used

Through the automatic generation of large model prompt methods, table data and column information are obtained, the information extraction strategy and description template are determined according to the column data format, the target information of the table columns is extracted, and a global text description is formed as the input of the large model.

Benefits of technology

The flexibility and effect of form Q&A are improved, and it can handle various form forms, including structured databases and unstructured files, and generate prompt information containing the overall content.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118733588A_ABST
    Figure CN118733588A_ABST
Patent Text Reader

Abstract

The invention relates to the field of artificial intelligence, particularly provides a table-based automatic generation large model prompt method and system and electronic equipment, and aims to solve or at least partially solve the technical problems of low table question and answer flexibility, incomplete table question and answer prompt information and the like caused by limitation of a table storage mode and a prompt representation mode. According to the scheme, the method comprises the steps of obtaining table data corresponding to a table storage mode, obtaining a table column name and a table column data format, and determining an information extraction strategy and a column information description template of a corresponding table column; and extracting the target information of the corresponding table column, obtaining the text description of the corresponding table column, and further obtaining the text description of the table as table question and answer prompt information for large model input. The technical scheme can be applied to various forms of tables, and the table question and answer flexibility is greatly improved; meanwhile, the overall content information of the table can be extracted, and the table question-answering effect can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence, and specifically provides a table-based automatic generation of a large model prompt method, system and electronic equipment. Background Art

[0002] In the existing large language model-based form question answering technology, people often use the database schema as part of the large model prompt, so that the large model can learn the relevant information of the database and then perform form question answering.

[0003] However, in actual scenarios, not all tables are stored in structured databases (such as MySQL). There are also a large number of tables stored in xlsx or similar format files. It is difficult to use database schemas as prompts for large models for such tables, because specialized technicians are required to write corresponding database schemas based on the tables.

[0004] On the other hand, in order to enhance the large model's understanding of the table content, in addition to the database model, existing prompting techniques also include some specific database content, usually the first n (e.g., n=3) rows of the database. However, such prompting methods only allow the large model to learn partial table content and lack a grasp of the overall table content.

[0005] Accordingly, the art needs a table-based automatic generation of large model prompting solutions to solve the above technical problems. Summary of the invention

[0006] In order to overcome the above-mentioned defects, the present invention is proposed to provide a solution or at least partially solve the technical problems such as low flexibility of form question and answer and incomplete form question and answer prompt information caused by the limitations of table storage method and prompt representation method.

[0007] In a first aspect, the present invention provides a table-based automatic generation method for large model prompts, comprising:

[0008] Acquire table data corresponding to the table storage mode, and acquire table column names and table column data formats, and determine corresponding table column information extraction strategies and column information description templates based on the types of the table column data formats;

[0009] Based on the information extraction strategy, extract the target information of the corresponding table column, and obtain the text description of the corresponding table column according to the column information description template;

[0010] Based on the text description of each table column, the text description of the table is obtained as table question and answer prompt information for large model input.

[0011] In one embodiment, the table storage method includes at least one of the following: storing in a database, storing in a file in xlsx format, and storing in a file in csv format.

[0012] In one embodiment, Pandas is used to read table data in different file formats, and obtain table column names and table column data formats.

[0013] In one embodiment, the type of the table column data format includes at least one of the following: a numeric column and a text column.

[0014] In one embodiment, if the data format of the table column is a numeric column, the corresponding information extraction strategy is: obtain the value range of all numbers in the column; if the data format of the table column is a numeric column, the corresponding column information description template is: <n>The column name is <column name>, and the value range of the column is [<minimum value>, <maximum value>].

[0015] In one embodiment, if the table column data format type is a text column, the corresponding information extraction strategy is: obtain the M values ​​with the highest frequency of occurrence in the column; if the table column data format type is a text column, the corresponding column information description template is: <n>The column name is <name of column> and the values ​​of this column contain <value_1>,<value_2>…<value_M>.

[0016] In a second aspect, the present invention provides a table-based automatic generation of large model prompt system, including: a determination module, an extraction module, and a prompt module;

[0017] in,

[0018] The determination module is used to obtain table data corresponding to the table storage mode, and obtain the table column name and table column data format, and determine the corresponding table column information extraction strategy and column information description template based on the type of the table column data format;

[0019] The extraction module is used to extract the target information of the corresponding table column based on the information extraction strategy, and obtain the text description of the corresponding table column according to the column information description template;

[0020] The prompt module is used to obtain the text description of the table based on the text description of each table column as table question and answer prompt information for large model input.

[0021] In a third aspect, an electronic device is provided, comprising a processor and a memory, wherein the memory stores a program, and when the processor executes the program, the table-based automatic generation of large model prompts method described in any one of the technical solutions of the above method is implemented.

[0022] In a fourth aspect, a readable storage medium is provided, storing a program, which, when executed, implements the table-based automatic generation of large model prompts method described in any one of the technical solutions of the above method.

[0023] The above one or more technical solutions of the present invention have at least one or more of the following

[0024] Beneficial effects:

[0025] The technical solution of the present invention is as follows: obtaining table data corresponding to the table storage method, and obtaining the table column name, the table column data format, and based on the type of the table column data format, determining the corresponding table column information extraction strategy and the column information description template; based on the information extraction strategy, extracting the target information of the corresponding table column, and according to the column information description template, obtaining the text description of the corresponding table column; based on the text description of each table column, obtaining the text description of the table as table question and answer prompt information for large model input.

[0026] The above scheme can be applied to various forms of tables (such as structured databases, Excel), which greatly improves the flexibility of table questions and answers. At the same time, based on the type of table column data format, the corresponding table column information extraction strategy and column information description template are determined to extract the overall content information of the table, which is conducive to improving the effect of table questions and answers. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] The disclosure of the present invention will become more easily understood with reference to the accompanying drawings. It is easy for those skilled in the art to understand that these drawings are only for illustrative purposes and are not intended to limit the scope of protection of the present invention. In addition, similar numbers in the figures are used to represent similar components, among which:

[0028] Figure 1 It is a flowchart of the main steps of a method for automatically generating a large model prompt based on a table according to an embodiment of the present invention;

[0029] Figure 2 It is a flowchart of the main steps of a method for automatically generating a large model prompt based on a table according to an embodiment of the present invention;

[0030] Figure 3 It is a schematic diagram of the main structural block diagram of a table-based automatic generation of large model prompt system according to an embodiment of the present invention. DETAILED DESCRIPTION

[0031] Some embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention.

[0032] In the description of the present invention, "module" and "processor" may include hardware, software or a combination of the two. A module may include hardware circuits, various suitable sensors, communication ports, and memory, and may also include software parts, such as program code, or a combination of software and hardware. The processor may be a central processing unit, a microprocessor, an image processor, a digital signal processor, or any other suitable processor. The processor has data and / or signal processing functions. The processor may be implemented in software, hardware, or a combination of the two. Non-temporary computer-readable storage media include any suitable medium that can store program code, such as a magnetic disk, a hard disk, an optical disk, a flash memory, a read-only memory, a random access memory, and the like. The term "A and / or B" means all possible combinations of A and B, such as only A, only B, or A and B. The term "at least one A or B" or "at least one of A and B" has a similar meaning to "A and / or B", and may include only A, only B, or A and B. The singular terms "one" and "the" may also include plural forms.

[0033] Glossary:

[0034] Large model: refers to an artificial intelligence model with super-large-scale parameters and usually super-powerful capabilities.

[0035] Table question and answer: refers to querying, reasoning, and answering related questions based on a given table.

[0036] The present invention designs a set of automatic processes for generating table question and answer prompts based on large models. This prompt method can be applied to tables of various forms, such as structured databases, Excel, etc.; it can also include the overall content information of the table, which is conducive to improving the effect of table question and answer.

[0037] The workflow of the present invention is:

[0038] Prepare the table file and make sure the name of the table file and the naming of the relevant columns are reasonable;

[0039] Start the process, the automated prompt process mentioned in the present invention will automatically read the table information, including the name of each column of the table and the format of each column of data;

[0040] For numeric columns, find the maximum and minimum values, and use relevant templates to form a description of the numeric column; for text columns, find the most common n (for example, n=3) values, and use relevant templates to form a description of the text column;

[0041] Based on the extracted column information, supplemented by the basic template, a table description is formed, which can be used as a prompt for large model table questions and answers.

[0042] The present invention mainly achieves the following four technical effects:

[0043] Expand the prompts of Table Question and Answer from structured databases to other readable formats, such as Excel files;

[0044] Make the prompts of the table questions include the global content of the table, not just the local information;

[0045] With the help of standardized templates, prompts for form questions and answers are automatically generated;

[0046] The prompts for form questions and answers are generated in an automated manner, without the need for manual human involvement or technical background.

[0047] See attached Figure 1 , Figure 1 FIG. 1 is a flow chart of the main steps of a table-based automatic generation of large model prompts according to an embodiment of the present invention. Figure 1 As shown, it mainly includes the following steps S20-S40:

[0048] S20, acquiring table data corresponding to the table storage mode, and acquiring a table column name and a table column data format, and determining an information extraction strategy and a column information description template of the corresponding table column based on the type of the table column data format;

[0049] In this embodiment, the table storage method includes at least one of the following: storing in a database, storing in a file in xlsx format, and storing in a file in csv format.

[0050] In this embodiment, Pandas is used to read table data in different file formats, and obtain table column names and table column data formats.

[0051] In this embodiment, the type of the table column data format includes at least one of the following: a numeric column and a text column.

[0052] In this embodiment, if the table column data format type is a numeric column, the corresponding information extraction strategy is: obtain the value range of all numbers in the column; if the table column data format type is a numeric column, the corresponding column information description template is: <n>The column name is <column name>, and the value range of the column is [<minimum value>, <maximum value>].

[0053] In this embodiment, if the table column data format type is a text column, the corresponding information extraction strategy is: obtain the M values ​​with the highest frequency of occurrence in the column; if the table column data format type is a text column, the corresponding column information description template is: <n>The column name is <name of column> and the values ​​of this column contain <value_1>,<value_2>…<value_M>.

[0054] S30, extracting target information of a corresponding table column based on the information extraction strategy, and acquiring a text description of the corresponding table column according to the column information description template;

[0055] S40, based on the text description of each table column, obtain the text description of the table as table question and answer prompt information for large model input.

[0056] Figure 2 The main steps of the method for automatically generating a large model prompt based on a table according to an embodiment of the present invention are shown in the flowchart, including the following steps:

[0057] Step S201, read the table name and column data format

[0058] Use appropriate methods to read table data in different file formats. For example, files in xlsx or csv format will be read using Pandas, and the names and data formats of all columns in the table will be obtained. The data formats here are roughly divided into two categories, numeric columns and text columns.

[0059] Step S202: Generate a description of a numeric column

[0060] For a numeric column, this embodiment will obtain the value range of all numbers in the column, so that it contains both global information and local information. With the help of relevant templates, a text description of the numeric column can be obtained.

[0061] The template can be adjusted as needed, an example is as follows:

[0062] No. <n>The column name is <column name>, and the value range of the column is [<minimum value>, <maximum value>].

[0063] Step S203: Generate a description of a text column

[0064] For a text column, this embodiment will obtain the M values ​​with the highest frequency of occurrence in the column, and the value of M can be changed according to the needs. This will allow the prompt of the table question and answer to obtain more information. Finally, with the help of relevant templates, the description of the entire text column is obtained.

[0065] The template can be adjusted as needed, an example is as follows:

[0066] No. <n>The column name is <column name> and the values ​​of this column include <value_1>, <value_2>,…<value_M> and so on.

[0067] Step S204: Comprehensively form a table description

[0068] Finally, after obtaining the descriptions of all the columns, they are combined together to form a text description of the table and the final table question and answer prompt.

[0069] The following example illustrates this:

[0070] Example:

[0071] Clothing Name price size Supply Is it available? Children's Wear 280 M Beijing yes Suits 1000 L Beijing no t-shirt 75 L Shanghai yes skirt 300 S Nanjing no jeans 200 XL Shanghai yes

[0072] The number column is column 2, and the text column is column 1 and columns 3-5.

[0073] The overall description of the table is as follows (take n=3):

[0074] The name of the first column is the name of the clothing, and the values ​​of this column include children's clothing, suits, and T-shirts;

[0075] The name of the second column is price, and the value range of this column is [75,1000];

[0076] The third column name is size, and the values ​​of this column include L, M, S;

[0077] The name of the fourth column is the source of goods. The values ​​of this column include Beijing, Shanghai, Nanjing, etc.

[0078] The name of the fifth column is "Is it on the shelf?", and the values ​​of this column include "yes" and "no".

[0079] The innovative part of this embodiment is the use of a unique prompt method, which allows the form question and answer to be expanded to databases of different formats other than structured databases, while creatively customizing the processing of numeric columns and text columns, striving to include local information as well as global information in the prompt; finally, with the assistance of relevant templates, the generation of the entire prompt can be automated.

[0080] Figure 3 FIG. 1 is a schematic diagram of the main structural block diagram of a table-based automatic generation of a large model prompt system according to an embodiment of the present invention. Figure 3 As shown, it includes: a determination module 301, an extraction module 302, and a prompt module 303;

[0081] in,

[0082] The determination module 301 is used to obtain table data corresponding to the table storage mode, and obtain the table column name and table column data format, and determine the corresponding table column information extraction strategy and column information description template based on the type of the table column data format;

[0083] The extraction module 302 is used to extract the target information of the corresponding table column based on the information extraction strategy, and obtain the text description of the corresponding table column according to the column information description template;

[0084] The prompt module 303 is used to obtain the text description of the table based on the text description of each table column as table question and answer prompt information for large model input.

[0085] In some embodiments, one or more of the determination module 301, the extraction module 302, and the prompt module 303 may be combined into one module. In one implementation, the description of the specific implementation functions may refer to the steps in the above embodiment.

[0086] The above scheme can be applied to various forms of tables (such as structured databases, Excel), which greatly improves the flexibility of table questions and answers. At the same time, based on the type of table column data format, the corresponding table column information extraction strategy and column information description template are determined to extract the overall content information of the table, which is conducive to improving the effect of table questions and answers.

[0087] The above table-based automatic generation of large model prompt system is used to execute Figure 1 The embodiment of the table-based automatic generation of large model prompt method shown in the figure has similar technical principles, technical problems solved and technical effects produced. Technical personnel in this technical field can clearly understand that for the convenience and conciseness of description, the specific working process and related instructions of the table-based automatic generation of large model prompt system can refer to the contents described in the embodiment of the table-based automatic generation of large model prompt method, which will not be repeated here.

[0088] It is understood by those skilled in the art that the present invention implements all or part of the processes in the method of the above embodiment, and can also be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable storage medium may include: any entity or device, medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory, random access memory, electric carrier signal, telecommunication signal and software distribution medium that can carry the computer program code. It should be noted that the content contained in the computer-readable storage medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable storage media do not include electric carrier signals and telecommunication signals.

[0089] Furthermore, the present invention also provides an electronic device, the electronic device includes a processor and a memory, the memory can be configured to store a program for executing the table-based automatic generation of a large model prompt method of the above method embodiment, and the processor can be configured to execute the program in the memory, the program including but not limited to the program for executing the table-based automatic generation of a large model prompt method of the above method embodiment. For ease of explanation, only the parts related to the embodiment of the present invention are shown, and for specific technical details not disclosed, please refer to the method part of the embodiment of the present invention.

[0090] Furthermore, the present invention also provides a readable storage medium. In a readable storage medium embodiment according to the present invention, the readable storage medium can be configured to store a program for executing the table-based automatic generation of large model prompts of the above method embodiment, and the program can be loaded and run by the processor to implement the above table-based automatic generation of large model prompts. For ease of explanation, only the parts related to the embodiment of the present invention are shown. For specific technical details not disclosed, please refer to the method part of the embodiment of the present invention. The readable storage medium can be a storage device formed by various electronic devices. Optionally, the readable storage medium in the embodiment of the present invention is a non-temporary readable storage medium.

[0091] Further, it should be understood that since the setting of each module is only for illustrating the functional units of the system of the present invention, the physical devices corresponding to these modules can be the processor itself, or a part of the software in the processor, a part of the hardware, or a part of the combination of software and hardware. Therefore, the number of each module in the figure is only schematic.

[0092] Those skilled in the art will appreciate that the modules in the system may be adaptively split or merged. Such splitting or merging of specific modules will not cause the technical solution to deviate from the principle of the present invention, and therefore, the technical solutions after splitting or merging will fall within the protection scope of the present invention.

[0093] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.< / n> < / n> < / n> < / n> < / n> < / n>

Claims

1. A table-based automatic generation of large model prompt method, characterized in that: include: Acquire table data corresponding to the table storage mode, and acquire table column names and table column data formats, and determine corresponding table column information extraction strategies and column information description templates based on the types of the table column data formats; Based on the information extraction strategy, extract the target information of the corresponding table column, and obtain the text description of the corresponding table column according to the column information description template; Based on the text description of each table column, the text description of the table is obtained as table question and answer prompt information for large model input.

2. The method according to claim 1, characterized in that The table storage method includes at least one of the following: storing in a database, storing in a file in xlsx format, and storing in a file in csv format.

3. The method according to claim 2, characterized in that Use Pandas to read table data in different file formats and obtain table column names and table column data formats.

4. The method according to claim 1, characterized in that: The type of the table column data format includes at least one of the following: a numeric column and a text column.

5. The method according to claim 4, characterized in that If the table column data format type is a numeric column, the corresponding information extraction strategy is: obtain the value range of all numbers in the column; if the table column data format type is a numeric column, the corresponding column information description template is: <n> The column name is <column name>, and the value range of the column is [<minimum value>, <maximum value>].< / n> 6. The method according to claim 4, characterized in that If the table column data format type is a text column, the corresponding information extraction strategy is: obtain the M values ​​with the highest frequency of occurrence in the column; if the table column data format type is a text column, the corresponding column information description template is: <n> The column name is <name of column> and the values ​​of this column contain <value_1>,<value_2>…<value_M>.< / n> 7. A table-based automatic generation of large model prompt system, characterized in that: include: Determination module, extraction module, prompt module; in, The determination module is used to obtain table data corresponding to the table storage mode, and obtain the table column name and table column data format, and determine the corresponding table column information extraction strategy and column information description template based on the type of the table column data format; The extraction module is used to extract the target information of the corresponding table column based on the information extraction strategy, and obtain the text description of the corresponding table column according to the column information description template; The prompt module is used to obtain the text description of the table based on the text description of each table column as table question and answer prompt information for large model input.

8. An electronic device comprising a processor and a memory, wherein the memory stores a program, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 6 is implemented.

9. A readable storage medium storing a program, characterized in that: When the program is executed, the method according to any one of claims 1 to 6 is implemented.