A prompt word generation method, device, medium and electronic equipment
By constructing multi-level indexes and filtering table data to form a target table information set, the accuracy problem of generative models in processing structured table files is solved, the generative model's understanding of the mapping relationship between user query intent and table fields is improved, and the response accuracy of vertical domain question answering systems is enhanced.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HANGZHOU ANT KUAI TECHNOLOGY CO LTD
- Filing Date
- 2026-05-18
- Publication Date
- 2026-07-21
Smart Images

Figure CN122432200A_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of information retrieval technology, and in particular to a method, apparatus, medium and electronic device for generating prompt words. Background Technology
[0002] Currently, in the process of enterprise digital transformation, a large amount of core business data is stored in structured tabular form, such as financial statements, sales details, product catalogs, etc., in Excel or CSV files. These tabular files not only carry rich numerical and textual information, but also implicitly contain logical relationships and hierarchical structures between fields.
[0003] Traditional Retrieval Augmentation (RAG) systems typically flatten the content of tabular files into plain text fragments before performing vectorized retrieval and semantic matching. However, this approach severs the inherent structured semantic information within the tabular file, making it difficult to accurately understand the mapping relationship between query intent and table fields in practical applications. This is especially true in complex query scenarios involving alias referencing, synonym substitution, or cross-column semantic associations, potentially leading to issues such as missed or false recall of key data. Consequently, the accuracy of generative models in vertical domain question-answering systems decreases. Summary of the Invention
[0004] In view of the above, one or more embodiments of this specification provide the following technical solutions: According to a first aspect of one or more embodiments of this specification, a prompt word generation method is proposed. The method performs retrieval enhancement generation processing based on a target knowledge base, wherein the target knowledge base stores candidate table files, and the candidate table files are constructed with corresponding multi-level indexes. These multi-level indexes are constructed based on the hierarchical relationships between table data at different structural positions within the candidate table files. The method includes: Obtain initial prompt words for the large language model; For each index level in the multi-level index, table data that matches the initial prompt word is selected from the table data corresponding to that index level and used as the level retrieval table data; The target table information set is selected from the search table data at each level; the search table data at each level in the target table information set belongs to different index levels, and there is a hierarchical relationship between every two levels of search table data in the table file; Using the target table information set as context information, the initial prompt words are supplemented to obtain the target generated prompt words.
[0005] According to a second aspect of one or more embodiments of this specification, a prompt word generation apparatus is provided. The apparatus performs retrieval enhancement generation processing based on a target knowledge base, the target knowledge base storing candidate table files, the candidate table files having corresponding multi-level indexes constructed based on the hierarchical relationships between table data at different structural positions in the candidate table files. The apparatus includes: The acquisition module is used to acquire initial prompt words for the large language model; The retrieval module is used to filter out table data that matches the initial prompt word from the table data corresponding to each index level in the multi-level index, and use it as the level retrieval table data. The filtering module is used to filter out the target table information set from the table data at each level; the table data at each level in the target table information set belongs to different index levels, and there is a hierarchical relationship between every two levels of table data in the table file; The generation module is used to supplement the initial prompt words with the target table information set as context information to obtain the target generated prompt words.
[0006] According to a third aspect of one or more embodiments of this specification, an electronic device is provided, comprising: a processor; a memory for storing processor-executable instructions; wherein the processor performs the executable instructions to implement the steps of the prompt word generation method described above.
[0007] According to a fourth aspect of one or more embodiments of this specification, a computer-readable storage medium is provided that stores computer instructions thereon, which, when executed by a processor, implement the steps of the prompt word generation method described above.
[0008] According to a fifth aspect of one or more embodiments of this specification, a computer program product is provided, comprising a computer program / instructions that, when executed by a processor, implement the steps of the above-described prompt word generation method.
[0009] In this method, initial prompt words containing descriptive information about the content to be generated by a preset generation model are obtained. Then, for each preset index level, table data matching the initial prompt words is selected from the table data corresponding to that index level as hierarchical retrieval table data. Different index levels are constructed based on candidate table files in a preset target knowledge base, specifically based on the hierarchical relationship between table data in different structural positions within the candidate table files. Next, a target table information set is selected from the retrieval table data at each level. The retrieval table data at each level in this target table information set belongs to different index levels, and there is a hierarchical relationship between every two levels of retrieval table data in the table files. Finally, the target table information set is used as context information to supplement the initial prompt words, resulting in the target generation prompt words.
[0010] As can be seen from the above method, by dividing the table file into multiple index levels according to its table structure, after obtaining the initial prompt words, for each index level, the table data corresponding to that index level can be filtered to select the level retrieval table data that matches the initial prompt words. Furthermore, from the table data of each level, table data belonging to different levels and having a hierarchical relationship can be selected to form a target table information set. Since the table data belonging to different levels and having a hierarchical relationship in the target table information set can corroborate each other, the accuracy of the retrieved target table information set can be improved. This allows the target table information set to be used as context to supplement the initial prompt words, helping the generation model accurately understand the mapping relationship between the user's query intent and the table fields, thereby improving the accuracy of the final generated response text. Attached Figure Description
[0011] Figure 1 This is a schematic diagram of a first retrieval process provided in an exemplary embodiment.
[0012] Figure 2 This is a flowchart illustrating a prompt word generation method provided in an exemplary embodiment.
[0013] Figure 3 This is a schematic diagram of a second retrieval process provided in an exemplary embodiment.
[0014] Figure 4 This is a schematic diagram of a form file provided in an exemplary embodiment.
[0015] Figure 5 This is a schematic structural diagram of a device provided in an exemplary embodiment.
[0016] Figure 6 This is a block diagram of a prompt word generation apparatus provided in an exemplary embodiment. Detailed Implementation
[0017] To make the objectives, technical solutions, and advantages of this specification clearer, the technical solutions of this specification will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this specification, and not all of them. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this specification.
[0018] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this manual are all information and data authorized by the user or fully authorized by all parties. The collection, use and processing of related data shall comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals shall be provided for users to choose to authorize or refuse.
[0019] Currently, with the continuous development of natural language processing technology, generative models are widely used in fields such as intelligent customer service, financial investment research, medical diagnosis, and enterprise knowledge bases. However, in vertical domain question-answering systems, user-input questions often involve specialized knowledge within specific business scenarios. This can lead to inaccurate responses from generative models due to a lack of domain-specific expertise. To avoid this problem, it is often necessary to retrieve relevant professional knowledge data from a pre-defined knowledge base to provide contextual information for the user's input. This allows the generative model to reference this knowledge data when generating response text, thereby improving the accuracy of the response.
[0020] For example, in an intelligent customer service scenario, when a user asks "What is the warranty policy for a certain product?", if the generated model relies solely on general knowledge, it may not be able to provide the user with accurate warranty terms. In this case, it is necessary to retrieve the specific warranty policy of the product from the product knowledge base and then generate an answer based on the retrieval results.
[0021] In practical applications, a large amount of core business data in some professional knowledge bases is stored in structured tabular form, such as financial statements, sales details, and product catalogs in Excel or CSV files. These tabular files have clear field meanings, hierarchical relationships, and logical connections, and are an important source of information for vertical domain question answering. However, in related technologies, when processing tabular files, the content is usually flattened into plain text fragments before vectorized retrieval and semantic matching. This processing method severs the inherent structured semantic information in the tabular files, making it difficult to accurately understand the mapping relationship between the user's query intent and the table fields in practical applications. Especially in complex query scenarios involving alias referencing, synonym substitution, or cross-column semantic relationships, problems such as missed or false recall of key data may occur, leading to a decrease in the accuracy of generative models in vertical domain question answering systems. Specifically, for example... Figure 1 As shown.
[0022] Figure 1 This is a schematic diagram of a first retrieval process provided in an exemplary embodiment.
[0023] Combination Figure 1 It can be seen that in related technologies, when a user queries "What dishes can be made with persimmons?", if only the original long text such as recipes and vegetable prices is directly vectorized (embedding), the description of "method" in the text is too lengthy, causing the features of "dish name" and "ingredients" to be diluted by a large amount of non-critical information. This results in the low retrieval scores of recipe entries that are highly relevant to the user's query intent, ultimately preventing high-value recipe information from being prioritized for retrieval. Meanwhile, irrelevant information such as vegetable prices (e.g., "tomato price: ten yuan") will be mistakenly retrieved, causing interference items to be mixed into the reference context information provided to the generative model, thus reducing the accuracy of the response text generated by the generative model.
[0024] Furthermore, in practical applications, the alias "foreign persimmon" and "tomato" may be aliased, leading to the inability to retrieve the alias and further reducing the accuracy of the search.
[0025] Based on this, this specification provides a method for generating prompt words. By dividing a table file into multiple index levels according to its structure, and after obtaining the initial prompt words, for each index level, the method filters out the table data corresponding to that index level that matches the initial prompt words. Furthermore, it filters out table data belonging to different levels and having a hierarchical relationship from the table data at each level, forming a target table information set. Since the table data belonging to different levels and having a hierarchical relationship can corroborate each other, the accuracy of the retrieved target table information set can be improved. This target table information set can then be used as context to supplement the initial prompt words, helping the generation model accurately understand the mapping relationship between the user's query intent and the table fields, thereby improving the accuracy of the final generated response text.
[0026] The technical solutions provided in the various embodiments of this specification are described in detail below with reference to the accompanying drawings.
[0027] Figure 2 This is a flowchart illustrating a prompt word generation method provided in an exemplary embodiment, including: S200: Obtain initial prompt words for the large language model.
[0028] In this specification, the executing entity for implementing the prompt word generation method can refer to computing devices located at the back end of a business process, such as servers or cloud computing clusters, or terminal devices with data processing capabilities, such as personal computers or mobile terminals. For ease of description, the following explanation uses a server as the executing entity.
[0029] Specifically, in practical applications, the server can act as a backend processing device, communicating with the frontend interactive interface (e.g., web pages, mobile applications, instant messaging tools, etc.) so that users can input query content through the frontend interactive interface, and the frontend interactive interface encapsulates the user's input query content into a generated prompt word and sends it to the server. The server uses the generated prompt word as the initial prompt word to perform subsequent processing.
[0030] The generated prompts can be user-written question description text, user-selected question description text from a preset candidate question list, or voice text converted from user voice input.
[0031] S202: For each index level in the multi-level index, select the table data that matches the initial prompt word from the table data corresponding to that index level, and use it as the level retrieval table data.
[0032] In practical applications, table files can be divided into different structural levels according to their table structure, such as file level, table level, header level, and content block level. These different structural levels have clear hierarchical relationships and semantic connections. Therefore, if a multi-level index for table files can be built based on these levels, and the table data under each level of the index is matched for cross-verification during retrieval, the inherent structured semantics of table files can be utilized to more accurately retrieve table data from a pre-defined professional knowledge base. Specifically, for example... Figure 3 As shown.
[0033] Figure 3 This is a schematic diagram of a second retrieval process provided in an exemplary embodiment.
[0034] Combination Figure 3 As can be seen, the server can select table data that matches the initial prompt words from the table data corresponding to each index level in the preset multi-level index, and use it as the level retrieval table data.
[0035] In one embodiment, the server can perform word segmentation on the initial prompt words, extract the keywords, and match these keywords with the text content in the table data corresponding to each index level, so as to use the table data containing the keywords as the hierarchical retrieval table data.
[0036] In practical applications, in order to improve the accuracy of the retrieved hierarchical table data, the server can also extract the feature representation of the initial prompt word as the first feature representation. Then, for each preset index level, based on the similarity between the first feature representation and the second feature representation of each table data corresponding to the index level, the server can filter out the table data that matches the initial prompt word from each table data corresponding to the index level.
[0037] The second feature mentioned above can be obtained by the server pre-extracting features from each table data corresponding to the index level.
[0038] It should be noted that, based on the similarity between the first feature representation and the second feature representation of each table data corresponding to the index level, there can be multiple methods to filter out the table data that matches the initial prompt word from each table data corresponding to the index level.
[0039] For example, the server can filter out the table data corresponding to the index level from the table data where the similarity between the first feature representation and the second feature representation of the table data corresponding to the index level is higher than a preset similarity threshold, and use them as the table data to match the initial prompt words.
[0040] For example, the server can sort the table data corresponding to the index level based on the similarity between the first feature representation and the second feature representation of each table data corresponding to the index level. Then, it can select a preset number of table data (e.g., the first K table data, where K can be set according to actual needs) from the sorted table data as the table data that matches the initial prompt word.
[0041] For ease of understanding, the following is combined with Figure 4 The provided table files provide detailed descriptions of the table data corresponding to each of the above index levels.
[0042] Figure 4 This is a schematic diagram of a form file provided in an exemplary embodiment.
[0043] The server can determine the professional field to which the initial prompt word entered by the user belongs, and then use the professional knowledge base that matches the professional field to which the initial prompt word belongs as the target knowledge base. The target knowledge base stores various table files under that professional field, and pre-constructs corresponding multi-level indexes according to the hierarchical relationship between the table data in different structural positions within each table file, such as according to... Figure 4 At least one of the structural levels shown—file level, table level, header level, and content block level—is used to construct a corresponding index level. Furthermore, for each structural level, the structure of each table file can be parsed to extract the table data located at the corresponding structural position within that table file, which serves as the table data corresponding to the respective index level.
[0044] Based on this, the server can obtain the second feature representation corresponding to each table data contained in the table file after feature extraction, and store the second feature representation of each table data in a preset multi-level index library for subsequent use.
[0045] Among them, the table data corresponding to the above file level is the name of the table file, the table data corresponding to the table level is the name of the table in the table file (or the worksheet name), the table data corresponding to the header level is the column headers and / or row headers of the table in the table file, and the table data corresponding to the content block level is the data segment of each column of the table in the table file after being divided by row.
[0046] For example, the server can Figure 4 In the policy table shown, the annual premium column is divided into three content blocks, such as dividing 24500, 25500, and 26500 into the first content block, ..., dividing 122500, 34200, and 34300 into the nth content block, and so on.
[0047] Specifically, the table data corresponding to the above file hierarchy can be as follows: { "id": "table_id", "content": "file_name", "embeddings": [vector1, vector2, vector3, ...], ... } Here, id is the unique identifier of the table in the table file to which the table data belongs; content is the content of the table data, i.e., the name of the table file; and embeddings is the second feature representation of the table data obtained by feature extraction from the content of the table data. vector1, vector2, ... are each feature dimension in the second feature representation of the table data.
[0048] The table data corresponding to the above table levels can be shown below: { "id": "table_id", "content": "table_titles", "embeddings": [vector1, vector2, vector3, ...], ... } Here, "content" refers to the content of the table data, that is, the name of the table in the table file.
[0049] The table data corresponding to the above header hierarchy can be shown below: { "id": "table_id", "content": "name, type, desc, ...", "embeddings": [vector1, vector2, vector3, ...], "id": "table_id", "content": "age, type, desc, ...", "embeddings": [vector1, vector2, vector3, ...], "id": "table_id", "content": "gender, type, desc, ...", "embeddings": [vector1, vector2, vector3, ...], ... } The "content" mentioned above refers to the content of the table data, namely, the column headers and / or row headers of the table in the table file (such as: name, age, gender, etc.).
[0050] It should be noted that the table data corresponding to the above header level can also include the attribute information of the columns in the table. This attribute information includes: data type (type), sorting method (e.g., ascending order (esc), descending order (sesc), etc.). For each column, the above embeddings are the second feature representation obtained after extracting features from the content of the table data corresponding to that column as an independent text fragment.
[0051] The table data corresponding to the above content block hierarchy can be shown below: { "id": "table_id", "content": "Zhang San, Li Si, ...", "embeddings": [vector1, vector2, vector3, ...], "id": "table_id", "content": "Wang Wu, Zhao Liu, ...", "embeddings": [vector1, vector2, vector3, ...], ... } Here, "content" refers to the content of the table data. For example, a column of data in a table file is divided into data segments by row, i.e., content blocks (e.g., Zhang San, Li Si, ... are the data segments corresponding to the first table data, Wang Wu, Zhao Liu, ... are the data segments corresponding to the second table data). The "embeddings" mentioned above are the second feature representations obtained after extracting features from each content block as an independent text segment.
[0052] It should be noted that, in order to maintain the association between each content block and the table header, the column header of each column or the row header of each row can be added to the header of each content block. This ensures that the second feature representation of each extracted content block carries the semantic information of its row and column headers, thereby improving the accuracy of the hierarchical table data retrieved when searching by content block level, as shown below: { "id": "table_id", "content": "name, Zhang San, Li Si, ...", "embeddings": [vector1, vector2, vector3, ...], "id": "table_id", "content": " name, Wang Wu, Zhao Liu, ...", "embeddings": [vector1, vector2, vector3, ...], ... } The aforementioned embeddings are the second feature representations obtained by extracting features from each content block carrying its respective row header and / or column header as an independent text segment.
[0053] Based on this, the server divides each table file in the professional knowledge base into table data under each index level according to the above method, and extracts the second feature representation corresponding to each table data. Then, the server can determine the table data of each level obtained after searching according to each index level by the above method.
[0054] S204: Select the target table information set from the retrieval table data at each level; the retrieval table data at each level in the target table information set belongs to different index levels, and there is a hierarchical relationship between every two levels of retrieval table data in the table file.
[0055] In this specification, after obtaining the hierarchical retrieval table data corresponding to each index level, the server can cross-validate the retrieval table data at each level, filtering out the mutually corroborating retrieval table data at each level as the target table information set. This target table information set not only contains the key table data involved in the user query, but also the hierarchical relationship and logical association of this table data in the original table files, thereby providing accurate and structured contextual information for the generated model.
[0056] In the above content, the retrieved table data at each level of the target table information set belongs to different index levels, and there is a hierarchical relationship between every two levels of retrieved table data in the table file. This hierarchical relationship can be such as: the inclusion relationship between file and worksheet, the inclusion relationship between worksheet and table header, the mapping relationship between table header and content block, the inclusion relationship between file and table header, the inclusion relationship between file and content block, the inclusion relationship between worksheet and content block, etc.
[0057] The above content describes two methods for the server to filter the target table information set from the table data retrieved at each level. The following sections will provide a detailed explanation of each method for obtaining the target table information set.
[0058] The first method for obtaining the target table information set is as follows: The server can retrieve table data for each level, determine the table data in the table file that has a hierarchical relationship with the retrieved table data at that level, and use it as at least one associated table information of the retrieved table data at that level. Then, based on the number of the identified associated table information that is also selected as the retrieved table data at that level, the weight of the retrieved table data at that level can be determined. The weight of the retrieved table data at that level is positively correlated with the number of the identified associated table information that is also selected as the retrieved table data at that level.
[0059] For example, suppose a spreadsheet file contains the filename "Sales Report.xlsx", the worksheet "2025 Sales", the header "Department Sales Amount", and the content blocks "Sales Department: 1 million, Marketing Department: 2 million". During a search, the server might retrieve "Sales Report.xlsx" at the filename level, "2025 Sales" at the worksheet name level, "Department Sales Amount" at the header level, and "Sales Department: 1 million" at the content block level. For the content block "Sales Department: 1 million", its associated table information includes the header "Department Sales Amount", the worksheet name "2025 Sales", and the filename "Sales Report.xlsx". The content block with higher weight has a higher confidence level because it cross-validates with hierarchical search table data from multiple index levels. For example, if a content block is identified as related to the initial prompt after retrieval, and the table header to which the content block belongs is also identified as related to the initial prompt, a mutually reinforcing relationship is formed, thus increasing the confidence level of the content block. Conversely, if a content block is retrieved, but its associated higher-level information (such as table headers) is not selected as hierarchical search table data, the content block has a lower weight and may be a false positive.
[0060] Furthermore, for any index level, the server can select at least a portion of the retrieved table data from each level of the index level based on the weight of the retrieved table data for each level of the index level, and use this as the target level retrieved table data. Then, based on the target level retrieved table data and the associated table information of the target level retrieved table data, the target table information set can be obtained.
[0061] In addition, in practical applications, besides determining the weight of a retrieval table data level solely based on the number of data points selected as retrieval tables in the identified associated table information, the server can also combine the similarity during retrieval to determine the weight of the retrieval table data level.
[0062] For example: the weight of the hierarchical retrieval table data is w=ω·num, where ω is the similarity between the second feature representation and the first feature representation of the hierarchical retrieval table data during the retrieval process, and num is the number of hierarchical retrieval table data selected from its associated table information.
[0063] For example, the weight of the table data retrieved at this level is w = α·ω1 + β1·ω2 + β2·ω3 + ... + βn·ω(n+1), where ω1 is the similarity between the second feature representation and the first feature representation of the table data retrieved at this level during the retrieval process, ω2 to ω(n+1) are the similarity between the second feature representation and the first feature representation of the first to nth related table information of the table data retrieved at this level, and α and β1 to βn are weight coefficients, which can be set according to the importance of different index levels in the actual application scenario, such as: the weight coefficient of the file level is 0.1, the weight coefficient of the table level is 0.2, the weight coefficient of the table header level is 0.3, and the weight coefficient of the content block level is 0.4, etc.
[0064] In practical applications, there are various methods for determining the weight of each level of the server's retrieval table data and selecting at least a portion of the retrieval table data from each level of the index as the target level retrieval table data.
[0065] For example, the search table data of each level of the index that has a weight greater than a preset weight threshold is used as the target level search table data.
[0066] For example: based on the weight of the search table data at each level of the index, sort the search table data at each level of the index, and select at least a portion of the top-ranked search table data from the search table data at each level of the index as the target level search table data.
[0067] The second method for obtaining the target table information set is as follows: The server can organize the hierarchical retrieval table data belonging to different index levels and having a hierarchical relationship into various table information sets, and then filter out the target table information set from each table information set based on the number of hierarchical retrieval table data contained in each table information set.
[0068] Specifically, the server can adopt a top-down approach, starting from the lowest index level (e.g., the content block level) and searching for the search table data of each level corresponding to the lowest index level (e.g., the header level) in turn, and searching for the search table data of each level corresponding to the previous index level (e.g., the header level) that has a hierarchical relationship with the search table data of that level, until the highest level (e.g., the file level), thus forming a set of table information. Then, based on the number of search table data contained in each set of table information, the target set of table information can be selected from each set of table information.
[0069] For example, using the sales report example above, suppose that at the file level, two levels of table data are retrieved: "Sales Report.xlsx" and "Product Catalog.xlsx"; at the table level, two levels of table data are retrieved: "2025 Sales" and "2026 Budget"; at the header level, two levels of table data are retrieved: "Department Sales Amount" and "Product Name Unit Price"; and at the content block level, three levels of table data are retrieved: "Sales Department: 1 million", "Marketing Department: 2 million", and "Mobile Phone: 5,000". The server uses a bottom-up approach, starting with the content block "Sales Department: 1 million", searching upwards for its corresponding table header, finding "Department Sales Amount", then searching upwards for its corresponding table name, finding "2025 Sales", and then searching upwards for its corresponding file name, finding "Sales Report.xlsx", thus forming a table information set A containing four levels of retrieved table data. Similarly, starting with the content block "Mobile Phone: 5000 yuan", searching upwards for the table header "Product Name Unit Price", and then searching upwards for its corresponding table name, no table name or file name can be found (i.e., the table name of the table to which this content block belongs is not a level of retrieved table data in the table index level, and the file name of the file to which this content block belongs is not a level of retrieved table data in the file index level). The retrieved content block "Mobile Phone: 5000 yuan" and the table header "Product Name Unit Price" form table information set B. At this point, table information set A contains four index levels, while B only contains two levels. Therefore, table information set A has a higher weight, and the server can prioritize A as the target table information set.
[0070] In practical applications, if there is a table information set C that contains 4 index levels, just like table information set A, the server can use both table information set A and table information set C as target table information sets, or it can further filter them (for example, select the table information set with higher similarity between the second feature representation of the content block and the first feature representation corresponding to the initial prompt word as the target table information set).
[0071] It should be noted that, in this application, to ensure that the first feature representation of the initial prompt word and the second feature representation of each table data corresponding to each index level are in the same semantic space, the embedding model used by the server when extracting features from the initial prompt word and each table data corresponding to each index level can be a unified embedding model. The embedding model can be selected according to actual needs, such as: Sentence Bidirectional Encoder Representations from Transformers (Sentence-BERT), Dense Passage Retrieval (DPR), etc. Furthermore, considering the characteristics of table files in vertical domains, specialized embedding models pre-trained on table files can also be used.
[0072] S206: Using the target table information set as context information, supplement the initial prompt words to obtain target generated prompt words.
[0073] Furthermore, the server can organize the search table data of each level in the target table information set according to their hierarchical relationship in the original table file to form a structured text description. Then, the structured text description is concatenated with the initial prompt words to obtain the target generated prompt words.
[0074] It should be noted that when the server supplements the target table information set as context information, it can format the information in the target table information set according to the needs of the actual application scenario.
[0075] For example, the server can use different representation methods such as JSON format and Markdown table format to convert the search table data of each level in the target table information set into structured text and concatenate it with the original generated prompt words to obtain the target generated prompt words.
[0076] Furthermore, if the target table information set contains multiple table information sets (such as the aforementioned table information sets A and C), the server can use these table information sets together as context information to supplement the initial prompt words and obtain the target generated prompt words.
[0077] As can be seen from the above, the server can divide the table file into multiple index levels according to the table structure. After obtaining the initial prompt, for each index level, it can filter out the table data that matches the initial prompt from the corresponding table data. Furthermore, it can filter out table data belonging to different levels and having a hierarchical relationship from the table data at each level, forming a target table information set. Because the table data belonging to different levels and having a hierarchical relationship can corroborate each other, the accuracy of the retrieved target table information set can be improved. This target table information set can then be used as context to supplement the initial prompt, helping the generation model accurately understand the mapping relationship between the user's query intent and the table fields, thereby improving the accuracy of the final generated response text.
[0078] Figure 5 This is a schematic structural diagram of a device provided in an exemplary embodiment. For example... Figure 5 As shown, device 500 mainly consists of a communication interface 502, a user interface 504, a processor 506, and a data storage 508. These components are interconnected and communicate with each other via a system bus, network, or other connection mechanism 510. The communication interface 502 enables device 500 to communicate with other devices, access networks, and transmission networks via analog or digital modulation. For example, the communication interface 502 may include a chipset and antenna for wireless communication with a radio access network or access point. Furthermore, the communication interface 502 can be a wired interface such as Ethernet, Token Ring, or a USB port, or a wireless interface such as Wi-Fi, Bluetooth, Global Positioning System (GPS), or a wide-area wireless interface (e.g., WiMAX or LTE). Of course, the communication interface 502 can also support other forms of physical layer interfaces and standard or proprietary communication protocols. The communication interface 502 may also include multiple physical communication interfaces, such as Wi-Fi interfaces, Bluetooth interfaces, and wide-area wireless interfaces.
[0079] User interface 504 includes receiving user input and providing output to the user. Therefore, user interface 504 may include input components such as a keypad, keyboard, touch-sensitive or presence-sensitive panel, computer mouse, trackball, joystick, microphone, still camera, and video camera, and output components such as a display screen (which may be combined with a touch-sensitive panel), CRT, LCD, LED, display using DLP technology, printer, and other similar devices known or developed in the future. User interface 504 may also generate auditory output via speakers, speaker jacks, audio output ports, audio output devices, headphones, and other similar devices known or developed in the future. In some embodiments, user interface 504 may include software, circuitry, or other forms of logic capable of transmitting and receiving data from external user input / output devices. Additionally or alternatively, device 500 may support remote access from other devices via communication interface 502 or another physical interface (not shown). User interface 504 may be configured to receive user input, the position and movement of which may be indicated by indicators or cursors described herein. User interface 504 may also be configured as a display device for rendering or displaying text fragments.
[0080] Processor 506 may contain one or more general-purpose processors and / or special-purpose processors.
[0081] Data storage 508 may include one or more volatile and / or non-volatile storage components and may be integrated wholly or partially with processor 506. Data storage 508 may include removable and non-removable components.
[0082] Processor 506 is capable of executing program instructions 518 (e.g., compiled or uncompiled program logic and / or machine code) stored in data storage 508 to perform the various functions described herein. Data storage 508 may contain a non-transitory computer-readable medium on which program instructions are stored, which, when executed by device 500, enable device 500 to perform any methods, processes, or functions disclosed in this specification and / or the accompanying drawings. Execution of program instructions 518 by processor 506 may result in processor 506 using data 512.
[0083] For example, program instructions 518 may include an operating system 522 (e.g., an operating system kernel, device drivers, and / or other modules) installed on device 500 and one or more applications 520 (e.g., a browser, social application, or game application). Similarly, data 512 may include operating system data 516 and application data 514. Operating system data 516 is primarily accessible to the operating system 522, while application data 514 is primarily accessible to one or more applications 520. Application data 514 may reside in a file system visible or hidden from the user of device 500.
[0084] Application 520 can communicate with operating system 522 through one or more application programming interfaces (APIs). These APIs help application 520 read and / or write application data 514, transmit or receive information via communication interface 502, receive or display information on user interface 504, etc.
[0085] In some terminology, application 520 may be simply referred to as "app". Furthermore, application 520 can be downloaded to device 500 through one or more online app stores or app markets. However, applications can also be installed on device 500 in other ways, such as through a web browser or a physical interface on device 500 (e.g., a USB port).
[0086] Please refer to Figure 6 The prompt word generation device can be applied to, for example, Figure 5 The device shown implements the technical solution of this specification. The prompt word generation device can perform retrieval enhancement generation processing based on a target knowledge base. The target knowledge base stores candidate table files, which are constructed with corresponding multi-level indexes. These multi-level indexes are built based on the hierarchical relationships between table data in different structural positions within the candidate table files. The device may include: The acquisition module 601 is used to acquire the initial prompt words for the large language model; The retrieval module 602 is used to filter out table data that matches the initial prompt word from the table data corresponding to each index level in the multi-level index, and use it as the level retrieval table data. The filtering module 603 is used to filter out the target table information set from the table data of each level of retrieval; the table data of each level of retrieval in the target table information set belongs to different index levels, and there is a hierarchical relationship between every two levels of retrieval table data in the table file; The generation module 604 is used to supplement the initial prompt words with the target table information set as context information to obtain the target generated prompt words.
[0087] Optionally, the retrieval module 602 is specifically used to: extract the feature representation of the initial prompt word as a first feature representation; and for each index level in the multi-level index, filter out the table data that matches the initial prompt word from each table data corresponding to the index level based on the similarity between the first feature representation and the second feature representation of each table data corresponding to the index level.
[0088] Optionally, the filtering module 603 is specifically used to: for each level of search table data, determine the table data in the table file that has a hierarchical relationship with the search table data of that level, and use it as at least one associated table information of that level of search table data; determine the weight of the search table data of that level based on the number of the at least one associated table information that is also selected as the search table data of that level; wherein, the weight of the search table data of that level is positively correlated with the number; and filter out the target table information set from each level of search table data based on the weight.
[0089] Optionally, the filtering module 603 is specifically used to: for any index level, select target level retrieval table data from the retrieval table data of each level of the index level according to the weight; and obtain a target table information set based on the target level retrieval table data and the associated table information of the target level retrieval table data.
[0090] Optionally, the filtering module 603 is specifically used to sort the search table data of each level of the index level according to the weight of the search table data of each level of the index level; and select at least a portion of the search table data of the first level of the index level as the target level search table data.
[0091] Optionally, the index hierarchy includes at least one of the following: file hierarchy, table hierarchy, header hierarchy, and content block hierarchy; wherein, the table data corresponding to the file hierarchy is the name of the table file; the table data corresponding to the table hierarchy is the name of the table in the table file; the table data corresponding to the header hierarchy is the column headers and / or row headers of the table in the table file; and the table data corresponding to the content block hierarchy is a data segment of each column of the table in the table file after being divided by row.
[0092] For ease of description, the above devices are described by dividing them into various modules or units based on their functions. Of course, when implementing one or more of these specifications, the functions of each module or unit can be implemented in the same or different software and / or hardware, or a module that performs the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.
[0093] Based on the same concept as the methods described above, this specification also provides an electronic device, including: a processor; a memory for storing processor-executable instructions; wherein the processor performs the steps of the method as described in any of the above embodiments by executing the executable instructions.
[0094] Based on the same concept as the methods described above, this specification also provides a computer-readable storage medium having computer instructions stored thereon that, when executed by a processor, implement the steps of the methods as described in any of the above embodiments.
[0095] Based on the same concept as the methods described above, this specification also provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of the methods as described in any of the above embodiments.
[0096] What those skilled in the art will understand is: In this specification, the terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, product, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, product, or apparatus. Without further limitation, the presence of additional identical or equivalent elements in a process, method, product, or apparatus that includes said elements is not excluded.
[0097] In this specification, “a,” “an,” and “the” do not specifically refer to the singular, but may also include the plural.
[0098] In this specification, ordinal numbers such as "first," "second," etc., do not necessarily indicate order; they are often used to distinguish between objects. For example, "first server" and "second server" usually refer to two servers. To differentiate between these two servers, they are described as "first server" and "second server." Of course, sometimes these two servers may be the same server.
[0099] In this specification, unless explicitly stated otherwise, "receiving and sending data" does not necessarily mean direct receiving and sending; it can also mean indirect receiving and sending. For example, A receiving data sent by B can be understood as A directly receiving the data sent by B, or it can be understood as A indirectly receiving the data sent by B through other entities such as C. Similarly, B sending data to A can be understood as B sending the data directly to A, or it can be understood as B indirectly sending the data to A through other entities such as C. Here, C can be one entity, or it can be two or more entities.
[0100] In this specification, unless explicitly stated otherwise, the relationships between structures can be direct or indirect. For example, when describing "A is connected to B," unless it is explicitly stated that A and B are directly connected, it should be understood that A can be directly connected to B or indirectly connected to B. Similarly, when describing "A is on top of B," unless it is explicitly stated that A is directly above B (AB is adjacent and A is above B), it should be understood that A can be directly above B or indirectly above B (AB is separated by other elements, and A is above B). And so on.
[0101] This specification uses specific terms to describe embodiments thereof. Terms such as "an embodiment," "one embodiment," and / or "some embodiments" refer to a particular feature, structure, or characteristic associated with at least one embodiment of this specification. Therefore, it should be emphasized and noted that references to "an embodiment," "one embodiment," or "an alternative embodiment" in different locations throughout this specification do not necessarily refer to the same embodiment. Furthermore, those skilled in the art can combine and integrate the different embodiments or examples described herein, as well as the features of those different embodiments or examples, without contradiction.
[0102] Although one or more embodiments of this specification provide method steps as described in the embodiments or flowcharts, it is understood that the order of steps listed in the embodiments or flowcharts is only one of many possible execution orders and does not represent the only execution order. Therefore, when the claims involve method steps, any changes or adjustments to the order of such steps, or the parallelism between steps, are also within the scope of protection of the claims.
Claims
1. A method for generating prompt words, the method performing retrieval enhancement generation processing based on a target knowledge base, wherein the target knowledge base stores candidate table files, the candidate table files are constructed with corresponding multi-level indexes, the multi-level indexes are constructed based on the hierarchical relationship between table data in different structural positions in the candidate table files, the method comprising: Obtain initial prompt words for the large language model; For each index level in the multi-level index, table data that matches the initial prompt word is selected from the table data corresponding to that index level and used as the level retrieval table data; The target table information set is selected from the search table data at each level; the search table data at each level in the target table information set belongs to different index levels, and there is a hierarchical relationship between every two levels of search table data in the table file; Using the target table information set as context information, the initial prompt words are supplemented to obtain the target generated prompt words.
2. The method as described in claim 1, wherein for each index level in the multi-level index, table data matching the initial prompt word is filtered from the table data corresponding to that index level, specifically including: Extract the feature representation of the initial prompt word and use it as the first feature representation; For each index level in the multi-level index, based on the similarity between the first feature representation and the second feature representation of each table data corresponding to that index level, table data matching the initial prompt word is selected from each table data corresponding to that index level.
3. The method as described in claim 1, specifically including: filtering the target table information set from the table data retrieved at each level, includes: For each level of retrieved table data, identify the table data in the table file that has a hierarchical relationship with the retrieved table data of that level, and use it as at least one related table information of the retrieved table data of that level. The weight of a hierarchical retrieval table data is determined based on the number of data selected as hierarchical retrieval table data in the at least one associated table information; wherein, the weight of the hierarchical retrieval table data is positively correlated with the number of data. Based on the weights, the target table information set is selected from the table data retrieved at each level.
4. The method as described in claim 3, wherein the target table information set is selected from the table data at each level based on the weights, specifically includes: For any index level, based on the weight, the target level retrieval table data is selected from the retrieval table data of each level of that index level. Based on the target level retrieval table data and the associated table information of the target level retrieval table data, a target table information set is obtained.
5. The method as described in claim 4, wherein the target level retrieval table data is selected from the retrieval table data of each level of the index hierarchy according to the weight, specifically includes: The retrieved table data at each level of the index hierarchy is sorted according to the weights of the retrieved table data at each level of the index hierarchy. Select at least a portion of the search table data from the top-ranked levels of the index hierarchy as the target level search table data.
6. The method of claim 1, wherein the index hierarchy comprises: At least one of the following: file level, table level, table header level, and content block level; wherein, the table data corresponding to the file level is the name of the table file; the table data corresponding to the table level is the name of the table in the table file; the table data corresponding to the table header level is the column headers and / or row headers of the table in the table file; and the table data corresponding to the content block level is a data segment of each column of the table in the table file after being divided by row.
7. A prompt word generation device, wherein the device performs retrieval enhancement generation processing based on a target knowledge base, the target knowledge base storing candidate table files, the candidate table files having corresponding multi-level indexes, the multi-level indexes being constructed based on the hierarchical relationships between table data in different structural positions within the candidate table files, the device comprising: The acquisition module is used to acquire initial prompt words for the large language model; The retrieval module is used to filter out table data that matches the initial prompt word from the table data corresponding to each index level in the multi-level index, and use it as the level retrieval table data. The filtering module is used to filter out the target table information set from the table data at each level; the table data at each level in the target table information set belongs to different index levels, and there is a hierarchical relationship between every two levels of table data in the table file; The generation module is used to supplement the initial prompt words with the target table information set as context information to obtain the target generated prompt words.
8. An electronic device, comprising: processor; A memory for storing processor-executable instructions; wherein the processor implements the steps of the method as described in any one of claims 1-6 by executing the executable instructions.
9. A computer-readable storage medium having stored thereon computer instructions that, when executed by a processor, implement the steps of the method as claimed in any one of claims 1-6.
10. A computer program product comprising a computer program / instructions that, when executed by a processor, implement the steps of the method as claimed in any one of claims 1-6.