Index query method and device based on large language model and storage medium
By performing semantic segmentation and large language model matching on the indicator query commands, generating query statements and verifying them, the problem of low accuracy in indicator data query in existing technologies is solved, and more accurate and flexible query results are achieved.
Patent Information
- Application Number
- CN202510396530.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-31
- Publication Date
- 2025-08-08
AI Technical Summary
When users query metric data, they rely solely on literal matching while ignoring semantic relevance, resulting in low accuracy of query results.
By performing semantic word segmentation on the indicator query commands, using a large language model to match indicator vectors and keywords, generating query statements, and performing functional verification, the accuracy and security of the query are ensured.
It improves the accuracy and flexibility of indicator data queries, can understand non-standard or ambiguous expressions, and ensures the accuracy and security of query results.
Smart Images

Figure CN120448399A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and more specifically, to an indicator query method, device, and storage medium based on a large language model. Background Art
[0002] When users query indicator data, they often rely solely on literal matches of query terms, ignoring the semantic relevance and context of the terms. This limits the accuracy of query results and can result in irrelevant or erroneous data being returned. Consequently, the accuracy of indicator data queries is low.
[0003] To address the above issues, no effective solutions have been proposed so far. Summary of the Invention
[0004] The embodiments of the present application provide an indicator query method, device, and storage medium based on a large language model to at least solve the technical problem of low accuracy in indicator data query.
[0005] According to one aspect of an embodiment of the present application, an indicator query method based on a large language model is provided, comprising: performing a semantic word segmentation operation on an indicator query instruction to obtain at least one indicator query keyword, wherein the at least one indicator query keyword is used to query indicator data; performing a first matching operation on an indicator vector corresponding to the at least one indicator query keyword in an indicator vector knowledge base to obtain a target vector that matches the indicator vector, wherein the target vector includes a reference indicator vector that matches the indicator vector and a reference dimension vector that matches the indicator vector; performing a second matching operation on the at least one indicator query keyword in a keyword knowledge base to obtain a target keyword that matches the at least one indicator query keyword; when query information for querying indicator data is determined based on the target vector and / or target keyword, generating a query statement corresponding to the query information through a pre-trained large language model, and performing functional verification on the query statement, wherein the pre-trained large language model is a pre-trained neural network model for identifying query information and outputting query results; when the query statement passes the functional verification, executing the query statement to obtain indicator data that matches the query information.
[0006] According to another aspect of an embodiment of the present application, an indicator query management device based on a large language model is also provided, including: a word segmentation unit, configured to perform a semantic word segmentation operation on an indicator query instruction to obtain at least one indicator query keyword, wherein the at least one indicator query keyword is used to query indicator data; a first matching unit, configured to perform a first matching operation on an indicator vector corresponding to the at least one indicator query keyword in an indicator vector knowledge base to obtain a target vector that matches the indicator vector, wherein the target vector includes a reference indicator vector that matches the indicator vector and a reference dimension vector that matches the indicator vector; a second matching unit, configured to perform a second matching operation on the at least one indicator query keyword in a keyword knowledge base to obtain a target keyword that matches the at least one indicator query keyword; a generation unit, configured to, when query information for querying indicator data is determined based on the target vector and / or target keyword, generate a query statement corresponding to the query information through a pre-trained large language model, and perform functional verification on the query statement, wherein the pre-trained large language model is a pre-trained neural network model for identifying query information and outputting query results; and an execution unit, configured to, when the query statement passes the functional verification, execute the query statement to obtain indicator data that matches the query information.
[0007] According to another aspect of the embodiments of the present application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform the above-described large language model-based indicator query method.
[0008] According to another aspect of an embodiment of the present application, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the large language model-based indicator query method through the computer program.
[0009] Through the embodiment of the present application, when a semantic word segmentation operation is performed on an indicator query instruction to obtain at least one indicator query keyword, a first matching operation is performed in the indicator vector knowledge base using the vector representation (indicator vector) of at least one indicator query keyword to obtain a target vector including a reference indicator vector and a reference dimension vector, thereby being able to understand the semantic association of the vocabulary. Even if the user uses a non-standard or ambiguous expression, the indicator data that best matches the user's intention can be accurately identified. At the same time, a second matching operation is performed on at least one indicator query keyword in the keyword knowledge base to obtain a target keyword, which can make up for the shortcomings of vector matching in processing precise vocabulary and ensure that it can quickly respond to user queries using precise indicator names. By combining the strategies of indicator vector matching, dimension vector matching, and keyword matching, not only the flexibility of the query is enhanced, but also the semantic relevance of the vocabulary and contextual information can be fully guaranteed, thereby achieving the technical effect of improving the accuracy of indicator data queries. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0011] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0012] Figure 1 This is a schematic diagram of the hardware environment of an optional indicator query method based on a large language model according to an embodiment of the present application;
[0013] Figure 2 This is a flow chart of an optional indicator query method based on a large language model according to an embodiment of the present application;
[0014] Figure 3 This is a flowchart of another optional indicator query method based on a large language model according to an embodiment of the present application;
[0015] Figure 4 is a schematic diagram of an optional indicator query device based on a large language model according to an embodiment of the present application;
[0016] Figure 5 It is a schematic structural diagram of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0017] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0018] It should be noted that the terms "first", "second", etc. in the specification and claims 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 sequential order. 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 a sequence 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.
[0019] According to one aspect of the embodiment of the present application, a method for querying indicators based on a large language model is provided. The method for querying indicators based on a large language model is widely used in smart home (Smart Home), smart home, smart home device ecology, smart home (IntelligenceHouse) ecology and other whole-house intelligent digital control application scenarios. Optionally, in this embodiment, the above-mentioned method for querying indicators based on a large language model can be applied to Figure 1 In the hardware environment shown in FIG. 1 , which is composed of a terminal device 102 and a server 104. Figure 1 As shown, the server 104 is connected to the terminal device 102 via a network, and can be used to provide services (such as application services, etc.) for the terminal or the client installed on the terminal. A database can be set on the server or independently of the server to provide data storage services for the server 104. A large language model, cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data computing services for the server 104.
[0020] The aforementioned network may include, but is not limited to, at least one of the following: a wired network and a wireless network. The aforementioned wired network may include, but is not limited to, at least one of the following: a wide area network, a metropolitan area network, and a local area network. The aforementioned wireless network may include, but is not limited to, at least one of the following: Wi-Fi (Wireless Fidelity) and Bluetooth. The terminal device 102 may be, but is not limited to, a PC, a mobile phone, a tablet computer, a smart watch, a smart air conditioner, a smart range hood, a smart refrigerator, a smart oven, a smart stove, a smart washing machine, a smart water heater, a smart washing machine, a smart dishwasher, a smart projection device, a smart TV, a smart clothes drying rack, smart curtains, smart audio and video, a smart socket, a smart speaker, a smart fresh air device, smart kitchen and bathroom equipment, smart bathroom equipment, a smart sweeping robot, a smart window cleaning robot, a smart mopping robot, a smart air purifier, a smart steamer, a smart microwave oven, a smart kitchen treasure, a smart purifier, a smart water dispenser, a smart door lock, etc.
[0021] Alternatively, as an optional implementation, Figure 2 As shown in the figure, the indicator query method based on the large language model includes:
[0022] S202, performing a semantic word segmentation operation on the indicator query instruction to obtain at least one indicator query keyword, wherein the at least one indicator query keyword is used to query indicator data;
[0023] S204: Perform a first matching operation on the indicator vector corresponding to the at least one indicator query keyword in the indicator vector knowledge base to obtain a target vector that matches the indicator vector, wherein the target vector includes a reference indicator vector that matches the indicator vector and a reference dimension vector that matches the indicator vector.
[0024] S206, performing a second matching operation on the at least one indicator query keyword in the keyword knowledge base to obtain a target keyword that matches the at least one indicator query keyword;
[0025] S208: When query information for querying indicator data is determined based on the target vector and / or target keyword, a query statement corresponding to the query information is generated using a pre-trained large language model, and a functional verification is performed on the query statement. The pre-trained large language model is a pre-trained neural network model for recognizing query information and outputting query results.
[0026] S210: If the query statement passes the functional verification, execute the query statement to obtain indicator data matching the query information.
[0027] Optionally, the indicator query instruction may be, but is not limited to, a data query request input by a user via natural language, such as "query last quarter's sales" or "display the sales quantity of each product this year." The indicator query keywords may be, but are not limited to, key words extracted from the user's indicator query instruction, which contain the subject information of the query, such as "sales," "last quarter," "product," "sales quantity," etc.
[0028] Optionally, the indicator vector may be, but is not limited to, a vector representation obtained by converting indicator query keywords, which is used to perform similarity matching in an indicator vector knowledge base, thereby identifying indicator data that the user may be interested in. It is understood that vector representation is the process of converting vocabulary into vectors in a high-dimensional space using a deep learning model (such as a word embedding model). This representation method can capture the semantic information of the vocabulary.
[0029] Optionally, the indicator vector knowledge base may be, but is not limited to, a pre-built database containing vector representations of all indicator data, which is used to match the indicator vector of the user's query to obtain the indicator data most relevant to the user's query. The keyword knowledge base may be, but is not limited to, a set of pre-stored indicator query keywords. When a user issues a query command, the database will directly search for indicator data matching the keywords.
[0030] Alternatively, the pre-trained large language model can be, but is not limited to, a neural network model trained on a large amount of text data, such as a GPT (Generative Pre-trained Transformer) model. This model can understand the complex structure and semantics of natural language and is used to generate SQL queries or directly retrieve information from the indicator data domain.
[0031] Optionally, the query information may be, but is not limited to, detailed information comprehensively determined based on the target vector and / or target keywords, may be, but is not limited to, used to guide the pre-trained large language model to perform specific data queries, and may include query indicators, time ranges, conditions, etc.
[0032] Optionally, semantic word segmentation is performed on the indicator query instruction. This may be used, but is not limited to, to indicate that upon receiving the user's indicator query instruction, natural language processing (NLP) technology (e.g., word segmentation, part-of-speech tagging, etc.) is used to parse the instruction, extract keywords and phrases from it, and generate at least one indicator query keyword. These keywords are the basis for understanding the user's query intent and are used for subsequent indicator data queries.
[0033] Alternatively, NLP techniques can be used, but are not limited to, rule-based approaches (relying on dictionaries and predefined rules), statistical approaches (leveraging the statistical properties of language to analyze large corpora to learn word frequency and contextual relationships for word segmentation), and deep learning approaches (using neural network models such as recurrent neural networks (RNNs), long short-term memory (LSTMs), bidirectional long short-term memory (BiLSTMs), and Transformer models to learn word boundaries and contextual relationships). These algorithms or models understand language structure, identify character sequences that constitute words, and decompose user-generated metric queries, converting continuous natural language text into a series of independently meaningful words, such as "sales" and "second quarter." These words are then used in subsequent processing steps such as vector recall and keyword matching to help the system understand query intent and accurately generate SQL queries. The choice and implementation of word segmentation technology directly impacts the system's understanding of user intent, as well as the accuracy and efficiency of subsequent operations.
[0034] To further illustrate, when a user enters a query command in natural language, such as "Get the sales of each region in the second quarter of 2023", it will first be decomposed into keywords such as "2023", "second quarter", "each region" and "sales" through NLP technology. These keywords will be used for subsequent query matching.
[0035] Furthermore, the above keywords are converted into semantic vectors, and then vector recall is performed in the indicator vector knowledge base to find the reference indicator vectors and reference dimension vectors that are most similar to the keyword vectors, such as the "sales" vector and the "region" vector. These vectors will be integrated into part of the query information.
[0036] In addition to vector recall, keywords are directly matched in the keyword knowledge base to ensure that the indicators and dimension names contained in the query information are exactly the same, enhancing the accuracy of the query.
[0037] It should be noted that this embodiment does not limit the execution order of the above-mentioned first matching operation and the second matching operation. The first matching operation may be executed first, but is not limited to, or the second matching operation may be executed first. The first matching operation and the second matching operation may also be executed simultaneously, but is not limited to.
[0038] Optionally, the results obtained from the first matching operation and the second matching operation are integrated into query information, and then a pre-trained GPT large language model is used to generate an SQL query statement. The statement will undergo functional verification to ensure that the syntax is correct, the logic is reasonable and safe, and to prevent security issues such as SQL injection.
[0039] Once the query statement passes the verification, it will be executed to accurately retrieve the indicator data required by the user from the database to complete the data query task.
[0040] It's understandable that after the user's query intent is accurately identified and converted into query information, a pre-trained large language model is used to structure and grammatically transform the query information, generating a query statement to be executed that conforms to the database query language specification. This process involves converting the natural language query intent into computer-executable query instructions, ensuring the syntactic correctness and logical rationality of the query statement.
[0041] Optionally, generated queries must pass functional validation before execution. This step checks the query's syntax, logical rationality, and security. Only after the query successfully passes validation is the query executed, leveraging the intelligent analysis capabilities of the large language model to retrieve indicator data from the indicator data domain that fully matches the query information. This functional validation step effectively prevents query failures due to syntax errors or logical errors, ensuring the accuracy and security of data queries.
[0042] By pre-packaging query statements and performing functional verification on them, the quality and security of query statements are further guaranteed, the efficiency and accuracy of data queries are improved, and users are provided with an intelligent, secure and efficient data query service.
[0043] By leveraging a pre-trained large language model, we can understand user queries in natural language, eliminating the need for SQL query expertise. Furthermore, by combining the matching results of the indicator vector knowledge base and the keyword knowledge base, we can effectively identify and understand the semantics of user queries. Even if the query uses industry jargon, abbreviations, or non-standard expressions, we can accurately find the corresponding indicator data through vector matching. Furthermore, direct word matching can quickly locate the specific indicator in the user's query, ensuring the accuracy of the query results.
[0044] It should be noted that the use of pre-trained large language models combined with vector matching and direct vocabulary matching technology provides an intelligent, efficient and user-friendly indicator data query method, which solves the problems of high user threshold, low query efficiency and limited query result accuracy in traditional query methods.
[0045] Through the embodiment of the present application, when a semantic word segmentation operation is performed on an indicator query instruction to obtain at least one indicator query keyword, a first matching operation is performed in the indicator vector knowledge base using the vector representation (indicator vector) of at least one indicator query keyword to obtain a target vector including a reference indicator vector and a reference dimension vector, thereby being able to understand the semantic association of the vocabulary. Even if the user uses a non-standard or ambiguous expression, the indicator data that best matches the user's intention can be accurately identified. At the same time, a second matching operation is performed on at least one indicator query keyword in the keyword knowledge base to obtain a target keyword, which can make up for the shortcomings of vector matching in processing precise vocabulary and ensure that it can quickly respond to user queries using precise indicator names. By combining the strategies of indicator vector matching, dimension vector matching, and keyword matching, not only the flexibility of the query is enhanced, but also the semantic relevance of the vocabulary and contextual information can be fully guaranteed, thereby achieving the technical effect of improving the accuracy of indicator data queries.
[0046] As an optional solution, performing a first matching operation on an indicator vector corresponding to at least one indicator query keyword to obtain a target vector matching the indicator vector includes:
[0047] In the indicator vector knowledge base, a reference indicator vector having the highest matching degree with the indicator vector and a reference matching degree of the reference indicator vector are determined, wherein the target vector includes the reference indicator vector, and the reference matching degree is used to indicate the matching degree between the reference indicator vector and the indicator vector.
[0048] Optionally, the reference indicator vector is used to indicate a vector representation in the indicator vector knowledge base that is most similar to the indicator vector generated by the user query instruction, and the vector corresponds to specific indicator data in the database.
[0049] Optionally, the reference matching degree is used to indicate the similarity between the indicator vector and the reference indicator vector, and is typically a value between 0 and 1, where 1 indicates a perfect match and 0 indicates no correlation.
[0050] As an optional solution, before generating a query statement corresponding to the query information using the pre-trained large language model and performing functional verification on the query statement, the method further includes:
[0051] If the reference matching degree is greater than or equal to a first preset threshold, determining the target vector as query information for querying the indicator data;
[0052] When the reference matching degree is less than or equal to the second preset threshold, the target keyword is determined as query information for querying the index data.
[0053] Optionally, the first preset threshold and the second preset threshold are pre-set numerical standards for judging whether the degree of index vector matching is sufficiently accurate. A matching result not lower than the first preset threshold will be considered reliable, and a matching result not higher than the second preset threshold will be considered unreliable.
[0054] When matching in the indicator vector knowledge base, if the degree of matching between the reference indicator vector and the indicator vector generated by the user query instruction (i.e., the reference matching degree) is greater than or equal to a first preset threshold, then the vector-based matching result is considered to be sufficiently accurate and reliable, and the target vector will be directly used as query information for querying indicator data from the indicator data domain.
[0055] If the reference match level is less than or equal to a second preset threshold, the vector-based matching result is deemed inaccurate. In this case, the target keyword is determined as query information for use in querying the index data. This means that the accuracy of direct word matching will be more heavily relied upon to ensure query reliability.
[0056] It should be noted that, when the reference matching degree is less than the first preset threshold and greater than the second preset threshold, an information integration operation is performed on the target vector and the target keyword to obtain query information for querying index data.
[0057] Through the embodiments of the present application, by combining the dual-channel matching strategy with the dual-threshold mechanism, it is possible to flexibly select the matching method that best suits the current query needs while ensuring query accuracy, thereby improving the flexibility and efficiency of the query.
[0058] As an optional solution, before generating a query statement corresponding to the query information using the pre-trained large language model and performing functional verification on the query statement, the method further includes:
[0059] If the reference match degree is less than a first preset threshold but greater than a second preset threshold, information integration is performed on the target vector and target keyword to obtain query information for querying the index data. Optionally, if the reference match degree is less than the first preset threshold but greater than the second preset threshold, additional processing is performed to improve the accuracy and completeness of the query information. This may include, but is not limited to, comprehensive analysis of the target vector and target keyword, introduction of contextual information, application of business rules, or incorporation of user preference information to more precisely define the query information.
[0060] It is understandable that when the reference matching degree does not reach the first preset threshold, it means that there may be a large uncertainty in the understanding of the query intent, which is not enough to directly generate a query statement. However, if the matching degree exceeds the second preset threshold, it means that although the understanding is not completely accurate, there is still a certain basis for matching, and the quality of the query information can be improved through additional information integration operations. In this case, the information integration operation plays a key role. It combines all the information of the target vector (including the reference indicator vector and the reference dimension vector) and the target keyword, while taking into account the query context, business rules, or the user's query history and preferences to generate more accurate and complete query information.
[0061] This dynamic adjustment strategy allows for the generation of reasonable query statements, even for difficult-to-match queries, ensuring query accuracy and reliability. Furthermore, the implementation of information integration further enhances the system's intelligence and user experience, enabling it to provide high-quality data query services under various query conditions, meeting diverse user needs.
[0062] By setting a reference matching degree and a dual-threshold mechanism, we ensure that the query information generation strategy balances accuracy and query success rate in different matching scenarios. Regardless of whether the user's query instruction is strictly formulated, query information that meets business needs can be generated, effectively improving the efficiency and accuracy of data queries and providing users with more intelligent and flexible data query services.
[0063] As an optional solution, in the process of matching the indicator vector in the indicator vector knowledge base, the method further includes:
[0064] According to at least one indicator query keyword, a reference dimension vector associated with a reference indicator vector is determined, wherein the target vector includes the reference dimension vector, and the reference dimension vector is used to indicate the business type to which the reference indicator vector belongs during the process of querying indicator data.
[0065] Optionally, the business type is used to indicate the specific business field to which the indicator data belongs, such as sales, production, finance, etc., and is used to define the scope and application scenarios of the indicator data. It may include, but is not limited to, the type and time information of the specific indicator data, such as a certain type of indicator data in a specific month.
[0066] Optionally, after the pre-trained large language model parses the user's query and generates indicator query keywords, in addition to searching for matching reference indicator vectors in the indicator vector knowledge base, the system further analyzes the reference dimension vectors associated with the reference indicator vectors. These reference dimension vectors contain information about the business type associated with the reference indicator vector, enabling more precise definition of the query scope and context, ensuring that the returned data matches the business domain of the user's query intent.
[0067] Optionally, the target vector includes not only the reference metric vector that best matches the user's query and the degree of match between them, but also a reference dimension vector. Including the reference dimension vector in the first matching result enables a more comprehensive understanding of the user's query intent, ensuring that the query information is not only accurate at the metric level but also highly consistent with the user's query requirements in terms of business type and context.
[0068] Through the embodiments of the present application, after parsing the user query instruction and generating the indicator query keyword, not only will the reference indicator vector with the highest matching degree be searched in the indicator vector knowledge base, but the reference dimension vector associated with the reference indicator vector will also be determined. The latter is used to indicate the business type to which the reference indicator vector belongs. By combining the reference indicator vector, the reference matching degree, and the reference dimension vector, it is possible to more accurately understand the user's query intent and specific needs, including the role of the query indicator in the business scenario and the associated dimensions, thereby ensuring the accuracy and applicability of the query results at the business level.
[0069] As an optional solution, after searching the indicator data domain for indicator data matching the query information using the pre-trained large language model, the method further includes:
[0070] The indicator data is displayed to the querying user in a first display style, and the business type is displayed to the querying user in a second display style, wherein the second display style is different from the first display style, and the querying user is the user who triggers the indicator query instruction.
[0071] Optionally, the first display style may be, but is not limited to, a visual interface or format for displaying indicator data, capable of intuitively presenting the numerical values and trends of the indicator data, typically in the form of charts, tables, digital dashboards, etc. The second display style, different from the first display style, is an interface or format specifically used to display business type information, for example, through color coding, icons, text labels, etc., to help users understand the business environment and application scenarios of the indicator data.
[0072] It is understandable that after the pre-trained large language model completes the query of the indicator data domain, the query results will be presented to the querying user in a preset first display style. This display style focuses on the visualization of the data, allowing users to intuitively understand the indicator values and changing trends. In addition to displaying the indicator data, the associated business type information will also be displayed to the querying user in a second display style. Unlike the first display style, the second display style focuses more on expressing business types and contextual information. Through colors, icons or other visual elements, users can quickly identify the business field to which the indicator data belongs, thereby better understanding the business meaning and application scenarios of the data.
[0073] Through the embodiments of the present application, the results are presented to the querying user in a first display style. This style focuses on the data itself and uses intuitive visualization methods such as charts and dashboards to enable users to clearly see the indicator values and changing trends, making it convenient for users to quickly analyze and interpret the data.
[0074] To enhance the business relevance and understandability of query results, a second display style is also adopted to display the business type information associated with the indicator data. This second display style is differentiated from the first one, using visual elements such as color coding, icons, and text labels to clearly identify the business type of the indicator data. This helps users quickly identify the business context and application scenarios of the data, thereby better understanding the business significance of the query results and accurately linking the data to specific business decisions.
[0075] As an optional solution, performing a second matching operation on at least one indicator query keyword in the keyword knowledge base to obtain a target keyword that matches the at least one indicator query keyword includes:
[0076] When there are at least two keywords matching the at least one indicator query keyword in the keyword knowledge base, obtaining time information of triggering the indicator query instruction;
[0077] Based on the time information, use the pre-trained large language model to predict at least two keywords and obtain the degree of temporal matching between each keyword and the time information;
[0078] The keyword with the highest time matching degree is determined as the reference keyword.
[0079] Optionally, the keyword knowledge base may be, but is not limited to, a pre-built database containing a large number of indicator query-related keywords, which is used for direct vocabulary matching to quickly locate key indicators and dimensions in user query intent.
[0080] Optionally, the time information may include, but is not limited to, the time parameter included in a user's indicator query instruction, such as "this year," "last quarter," or "2023," to limit the query time range for indicator data. The time match degree indicates the correlation and consistency between the keyword and the time information in the user's query instruction, and is used to evaluate the applicability and accuracy of the keyword within a specific time range.
[0081] Optionally, when multiple keywords that match the indicator query keywords in the user query instruction are found in the keyword knowledge base, the user query instruction will be further analyzed to obtain the time information contained therein for subsequent time matching degree calculation. Using the pre-trained large language model, each matched keyword is predicted based on the obtained time information, and the correlation and consistency between them and the time information are calculated. This measurement is called the time matching degree. By calculating the time matching degree, the applicability of each keyword within a specific time range can be evaluated, thereby more accurately determining the intention of the user query. Finally, from all the keywords that match the time information, the one with the highest time matching degree is selected as the reference keyword to further determine the query information and query the indicator data. This screening mechanism based on the time matching degree ensures that the indicator and dimension information that best meets the current query requirements can be selected based on the time parameters in the user query instruction.
[0082] To further illustrate, at least one indicator query keyword includes the indicator query keyword "quota", and there are multiple matching keywords, including "annual quota", "monthly quota", and "daily quota". It is further obtained that the indicator query is triggered on "January 1", then the time information indicates that the indicator query keyword "quota" has a higher probability of corresponding to "daily quota", and "daily quota" is determined as the reference keyword.
[0083] It should be noted that under different matching strategies, the strategies / methods for determining reference keywords may be different, and this embodiment does not impose any limitation on this.
[0084] Through the embodiments of the present application, the deep understanding ability of the large language model for natural language is utilized, combined with the precise screening of time information, which significantly improves the timeliness and accuracy of the query results, ensuring that users can obtain indicator data that best matches the query instructions and best meets time requirements, thereby enhancing the practical value and user experience of data analysis services.
[0085] As an optional solution, the aforementioned indicator query method based on a large language model is applied to indicator data query scenarios. In this scenario, intelligent data analysis scenarios are developing rapidly, and data analysis products and services are gradually providing users with richer, higher-quality, and more effective experiences and services. In order to accurately identify user intent and provide more personalized data analysis services, this embodiment, based on the aforementioned indicator query method based on a large language model, continuously explores and researches intelligent data analysis applications to meet the precision needs of various users.
[0086] Optionally, based on the aforementioned large language model-based indicator query method, after word segmentation of the acquired user questions, the vector model is used to retrieve indicators and indicator dimensions, while keyword matching is performed on the indicators. The recall and matching results are fed into the large language model, and SQL statements are generated and validated based on the configured prompt template. The query results are then presented to the user in the BI system, supporting operations such as data filtering, drill-down, and autonomous analysis, as well as data insights and report generation.
[0087] Optionally, after the user question is segmented based on NLP word segmentation technology, the indicators and indicator dimensions are recalled through the vector model, and the indicators are matched with keywords.
[0088] Optionally, the query results are given to the BI system for display to users, and data filtering, drilling down, independent analysis and other operations can be performed, as well as supporting data insights and data report generation functions.
[0089] Specifically, the detailed steps are as follows: Figure 3 Shown, including:
[0090] (1) Application input: Figure 3 As shown in the user input module 302 in FIG, the user raises relevant questions (ie, user queries) in the interactive system according to actual needs.
[0091] (2) Data processing: Figure 3As shown in the data processing module 304, in the NLP word segmentation link, when the user inputs a question, word segmentation processing is performed according to the NLP model. In the indicator vector recall + dimension vector recall + keyword matching link, based on the word segmentation results, the indicators and indicator dimensions are recalled through the vector model, and the indicators are matched with keywords. At the knowledge base level, based on the business knowledge and business experience of different application parties and different positions, basic information and associations such as indicators and dimensions, as well as the dictionary information of the data table in the database corresponding to the data to be queried, are sorted out to build a knowledge base. In the NL2SQL+SQL verification link, the recall results and matching results are given to the GPT model, and the SQL statement to be executed is generated according to the set prompt template, and the generated SQL statement is verified.
[0092] (3) Data output: Figure 3 As shown in the data output module 306, in the SQL (script) execution link, the verified SQL script is executed to obtain the data set result information after the query. In the intelligent BI display link, the generated data set result information is displayed in the interactive system according to the agreed format. In the data screening + drill-down + autonomous analysis link, the display content supports data screening, data drill-down, and autonomous analysis according to data cycle, dimension, etc. In the intelligent insight + intelligent report link, the generated SQL or task script is verified based on the large language model technology to ensure that the generated SQL or task script can be effectively executed.
[0093] Through the embodiments of the present application, after word segmentation of the acquired user questions, the vector model is used to recall indicators and indicator dimensions, and keyword matching is performed on the indicators. For the SQL scripts that need to be executed, the generated SQL scripts are verified based on the large language model to ensure that the scripts can be effectively executed. For the indicator data results after the query, further data insights and data report generation functions are supported.
[0094] It is understandable that in the specific implementation of this application, related data such as user information is involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0095] It should be noted that for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0096] According to another aspect of the embodiment of the present application, there is also provided an indicator query device based on a large language model for implementing the above-mentioned indicator query method based on a large language model. Figure 4 As shown, the device includes:
[0097] A word segmentation unit 402 is configured to perform a semantic word segmentation operation on the indicator query instruction to obtain at least one indicator query keyword, wherein the at least one indicator query keyword is used to query indicator data;
[0098] A first matching unit 404 is configured to perform a first matching operation on the indicator vector corresponding to at least one indicator query keyword in the indicator vector knowledge base to obtain a target vector that matches the indicator vector, wherein the target vector includes a reference indicator vector that matches the indicator vector and a reference dimension vector that matches the indicator vector;
[0099] A second matching unit 406 is configured to perform a second matching operation on the at least one indicator query keyword in the keyword knowledge base to obtain a target keyword that matches the at least one indicator query keyword;
[0100] A generation unit 408 is configured to, when query information for querying indicator data is determined based on the target vector and / or target keyword, generate a query statement corresponding to the query information using a pre-trained large language model, and perform functional verification on the query statement. The pre-trained large language model is a pre-trained neural network model for recognizing query information and outputting query results.
[0101] The execution unit 410 is used to execute the query statement when the query statement passes the functional verification, and obtain indicator data matching the query information.
[0102] As an optional solution, the first matching unit 404 includes:
[0103] The first determination module is used to determine the reference indicator vector with the highest matching degree with the indicator vector and the reference matching degree of the reference indicator vector in the indicator vector knowledge base, wherein the target vector includes the reference indicator vector, and the reference matching degree is used to indicate the matching degree between the reference indicator vector and the indicator vector.
[0104] As an optional solution, the device further includes:
[0105] a second determination module, configured to, before generating a query statement corresponding to the query information using the pre-trained large language model and performing a functional verification on the query statement, determine the target vector as query information for querying the indicator data if the reference matching degree is greater than or equal to a first preset threshold;
[0106] The third determination module is used to determine the target keyword as the query information for querying indicator data when the reference matching degree is less than or equal to the second preset threshold before generating a query statement corresponding to the query information through a pre-trained large language model and performing functional verification on the query statement.
[0107] As an optional solution, the device further includes:
[0108] The fourth determination module is used to generate a query statement corresponding to the query information through a pre-trained large language model and before performing functional verification on the query statement, when the reference matching degree is less than a first preset threshold and greater than a second preset threshold, perform an information integration operation on the target vector and the target keyword to obtain query information for querying indicator data.
[0109] As an optional solution, the first matching unit 404 includes:
[0110] The fifth determination module is used to determine the reference dimension vector associated with the reference indicator vector based on at least one indicator query keyword, wherein the target vector includes the reference dimension vector, and the reference dimension vector is used to indicate the business type to which the reference indicator vector belongs during the query of indicator data.
[0111] As an optional solution, the device further includes:
[0112] The display module is used to display the indicator data to the query user in a first display style after querying the indicator data matching the query information from the indicator data domain through a pre-trained large language model, and to display the business type to the query user in a second display style, wherein the second display style is different from the first display style, and the query user is the user who triggers the indicator query instruction.
[0113] As an optional solution, the second matching unit 406 includes:
[0114] an acquisition module, configured to acquire time information of triggering the indicator query instruction when at least two keywords matching at least one indicator query keyword exist in the prompt word knowledge base;
[0115] A prediction module is used to predict at least two keywords based on the time information using a pre-trained large language model to obtain the degree of temporal matching between each keyword and the time information;
[0116] The sixth determining module is configured to determine the keyword with the highest time matching degree as a reference prompt word.
[0117] For a specific embodiment, reference may be made to the example shown in the above-mentioned indicator query method based on a large language model, which will not be described in detail in this example.
[0118] According to another aspect of the embodiment of the present application, an electronic device for implementing the above-mentioned indicator query method based on a large language model is also provided. Figure 5 As shown, the electronic device includes a memory 502 and a processor 504. The memory 502 stores a computer program, and the processor 504 is configured to execute the steps in any of the above method embodiments through the computer program.
[0119] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.
[0120] Optionally, in this embodiment, the processor may be configured to execute the following steps through a computer program:
[0121] S1, performing a semantic word segmentation operation on the indicator query instruction to obtain at least one indicator query keyword, wherein the at least one indicator query keyword is used to query indicator data;
[0122] S2. Performing a first matching operation on the indicator vector corresponding to the at least one indicator query keyword in the indicator vector knowledge base to obtain a target vector that matches the indicator vector, wherein the target vector includes a reference indicator vector that matches the indicator vector and a reference dimension vector that matches the indicator vector;
[0123] S3, performing a second matching operation on the at least one indicator query keyword in the keyword knowledge base to obtain a target keyword that matches the at least one indicator query keyword;
[0124] S4, when query information for querying indicator data is determined based on the target vector and / or target keyword, generating a query statement corresponding to the query information using a pre-trained large language model, and performing a functional verification on the query statement, wherein the pre-trained large language model is a pre-trained neural network model for recognizing query information and outputting query results;
[0125] S5. If the query statement passes the functional verification, the query statement is executed to obtain indicator data that matches the query information.
[0126] Alternatively, those skilled in the art will appreciate that Figure 5 The structure shown is for illustration only, and the electronic device may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (MID), a PAD, or other terminal devices. Figure 5 It does not limit the structure of the above electronic device. For example, the electronic device may also include Figure 5More or fewer components (such as network interfaces, etc.) as shown in, or with Figure 5 Different configurations shown.
[0127] Among them, the memory 502 can be used to store software programs and modules, such as the program instructions / modules corresponding to the indicator query method and device based on the large language model in the embodiment of the present application. The processor 504 executes various functional applications and data processing by running the software programs and modules stored in the memory 502, that is, realizing the above-mentioned indicator query method based on the large language model. The memory 502 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 502 may further include a memory remotely located relative to the processor 504, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned networks include but are not limited to the Internet, corporate intranets, local area networks, mobile communication networks and combinations thereof. Among them, the memory 502 can be used specifically but not limited to store information such as indicator query keywords. As an example, such as Figure 5 As shown, the memory 502 may include, but is not limited to, the word segmentation unit 402, the first matching unit 404, the second matching unit 406, the generation unit 408, and the execution unit 410 in the indicator query device based on the large language model. In addition, it may also include, but is not limited to, other module units in the indicator query device based on the large language model, which will not be repeated in this example.
[0128] Optionally, the transmission device 506 is configured to receive or send data via a network. Specific examples of the network may include a wired network and a wireless network. In one embodiment, the transmission device 506 includes a network interface controller (NIC), which can be connected to other network devices and a router via a network cable to communicate with the Internet or a local area network. In one embodiment, the transmission device 506 is a radio frequency (RF) module, which is configured to communicate with the Internet wirelessly.
[0129] In addition, the electronic device further includes: a display 508 for displaying the stored index query keywords and other information; and a connection bus 510 for connecting various module components in the electronic device.
[0130] In other embodiments, the terminal device or server may be a node in a distributed system, wherein the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting multiple nodes via network communication. The nodes may form a peer-to-peer (P2P) network, and any computing device, such as a server, terminal, or other electronic device, may become a node in the blockchain system by joining the peer-to-peer network.
[0131] According to one aspect of the present application, a computer program product is provided, comprising a computer program / instructions containing program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via a communication component and / or installed from a removable medium. When the computer program is executed by a central processing unit, the various functions provided in the embodiments of the present application are performed.
[0132] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0133] It should be noted that the computer system of the electronic device is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0134] A computer system includes a central processing unit (CPU), which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) or programs loaded from the storage unit into random access memory (RAM). The RAM also stores various programs and data required for system operation. The CPU, the read-only memory, and the RAM are connected to each other via a bus. Input / output interfaces (I / O interfaces) are also connected to the bus.
[0135] The following components are connected to the input / output interface: an input section including a keyboard, mouse, etc.; an output section including a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage section including a hard disk; and a communication section including a network interface card such as a local area network card and a modem. The communication section performs communication processing via a network such as the Internet. A drive is also connected to the input / output interface as needed. Removable media such as magnetic disks, optical disks, magneto-optical disks, semiconductor memories, etc. are installed in the drive as needed so that computer programs read from them can be installed into the storage section as needed.
[0136] In particular, according to an embodiment of the present application, the processes described in the various method flow charts can be implemented as computer software programs. For example, an embodiment of the present application includes a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for executing the methods shown in the flow charts. In such an embodiment, the computer program can be downloaded and installed from a network via a communication portion, and / or installed from a removable medium. When the computer program is executed by a central processing unit, the various functions defined in the system of the present application are performed.
[0137] According to one aspect of the present application, a computer-readable storage medium is provided, and a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the methods provided in the various optional implementations described above.
[0138] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0139] S1, performing a semantic word segmentation operation on the indicator query instruction to obtain at least one indicator query keyword, wherein the at least one indicator query keyword is used to query indicator data;
[0140] S2. Performing a first matching operation on the indicator vector corresponding to the at least one indicator query keyword in the indicator vector knowledge base to obtain a target vector that matches the indicator vector, wherein the target vector includes a reference indicator vector that matches the indicator vector and a reference dimension vector that matches the indicator vector;
[0141] S3, performing a second matching operation on the at least one indicator query keyword in the keyword knowledge base to obtain a target keyword that matches the at least one indicator query keyword;
[0142] S4, when query information for querying indicator data is determined based on the target vector and / or target keyword, generating a query statement corresponding to the query information using a pre-trained large language model, and performing a functional verification on the query statement, wherein the pre-trained large language model is a pre-trained neural network model for recognizing query information and outputting query results;
[0143] S5. If the query statement passes the functional verification, the query statement is executed to obtain indicator data that matches the query information.
[0144] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing the hardware related to the terminal device through a program, and the program may be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0145] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0146] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above-mentioned 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, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which can be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods of each embodiment of the present application.
[0147] In the above embodiments of the present application, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0148] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is merely a logical functional division. In actual implementation, there may be other division methods, such as combining or integrating multiple units or components into another system, or ignoring or not implementing some features. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interface, indirect coupling or communication connection of units or modules, and may be electrical or other forms.
[0149] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0150] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0151] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A large language model-based index query method, characterized in that: include: Performing a semantic word segmentation operation on the indicator query instruction to obtain at least one indicator query keyword, wherein the at least one indicator query keyword is used to query indicator data; performing a first matching operation on the indicator vector corresponding to the at least one indicator query keyword in an indicator vector knowledge base to obtain a target vector that matches the indicator vector, wherein the target vector includes a reference indicator vector that matches the indicator vector and a reference dimension vector that matches the indicator vector; performing a second matching operation on the at least one indicator query keyword in the keyword knowledge base to obtain a target keyword that matches the at least one indicator query keyword; When query information for querying the indicator data is determined based on the target vector and / or the target keyword, a query statement corresponding to the query information is generated using a pre-trained large language model, and a functional verification is performed on the query statement, wherein the pre-trained large language model is a neural network model pre-trained to recognize the query information and output a query result; When the query statement passes the functional verification, the query statement is executed to obtain the indicator data matching the query information.
2. The method according to claim 1, characterized in that The performing a first matching operation on the indicator vector corresponding to the at least one indicator query keyword to obtain a target vector matching the indicator vector includes: In the indicator vector knowledge base, the reference indicator vector having the highest degree of matching with the indicator vector and the reference matching degree of the reference indicator vector are determined, wherein the target vector includes the reference indicator vector, and the reference matching degree is used to indicate the degree of matching between the reference indicator vector and the indicator vector.
3. The method according to claim 2, characterized in that Before generating a query statement corresponding to the query information using the pre-trained large language model and performing functional verification on the query statement, the method further includes: When the reference matching degree is greater than or equal to a first preset threshold, determining the target vector as the query information for querying the indicator data; In a case where the reference matching degree is less than or equal to a second preset threshold, the target keyword is determined as the query information for querying the indicator data.
4. The method according to claim 3, characterized in that Before generating a query statement corresponding to the query information using the pre-trained large language model and performing functional verification on the query statement, the method further includes: When the reference matching degree is less than the first preset threshold and greater than the second preset threshold, an information integration operation is performed on the target vector and the target keyword to obtain the query information for querying the indicator data.
5. The method according to claim 1, wherein The performing a first matching operation on the indicator vector corresponding to the at least one indicator query keyword to obtain a target vector matching the indicator vector includes: According to the at least one indicator query keyword, a reference dimension vector associated with the reference indicator vector is determined, wherein the target vector includes the reference dimension vector, and the reference dimension vector is used to indicate the business type to which the reference indicator vector belongs in the process of querying indicator data.
6. The method according to claim 5, characterized in that After querying the indicator data matching the query information from the indicator data domain through the pre-trained large language model, the method further includes: displaying the indicator data to the querying user in a first display style, and displaying the business type to the querying user in a second display style, wherein the second display style is different from the first display style, and the querying user is the user who triggers the indicator query instruction.
7. The method according to any one of claims 1 to 6, characterized in that The performing a second matching operation on the at least one indicator query keyword in the keyword knowledge base to obtain a target keyword matching the at least one indicator query keyword includes: When there are at least two keywords matching the at least one indicator query keyword in the prompt word knowledge base, obtaining time information of triggering the indicator query instruction; According to the time information, using the pre-trained large language model, predicting the at least two keywords to obtain a degree of temporal matching between each keyword and the time information; The keyword with the highest time matching degree is determined as the reference prompt word.
8. An indicator query device based on a large language model, characterized in that: include: a word segmentation unit, configured to perform a semantic word segmentation operation on the indicator query instruction to obtain at least one indicator query keyword, wherein the at least one indicator query keyword is used to query indicator data; a first matching unit, configured to perform a first matching operation on an indicator vector corresponding to at least one indicator query keyword in an indicator vector knowledge base to obtain a target vector that matches the indicator vector, wherein the target vector includes a reference indicator vector that matches the indicator vector and a reference dimension vector that matches the indicator vector; A second matching unit is configured to perform a second matching operation on the at least one indicator query keyword in the keyword knowledge base to obtain a target keyword that matches the at least one indicator query keyword; a generation unit for, when query information for querying indicator data is determined based on the target vector and / or target keyword, generating a query statement corresponding to the query information using a pre-trained large language model, and performing functional verification on the query statement, wherein the pre-trained large language model is a pre-trained neural network model for recognizing query information and outputting query results; The execution unit is used to execute the query statement when the query statement passes the functional verification, and obtain indicator data matching the query information.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program executes the method according to any one of claims 1 to 7 when executed.
10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 7 through the computer program.
Citation Information
Patent Citations
Health information processing method and device, electronic equipment and storage medium
CN116779163A
Question and answer method and device and electronic equipment
CN117194646A
Knowledge question-answering method and device, equipment and storage medium
CN117828057A
Multi-document intelligent question and answer method and system based on large language model
CN118394897A
Data processing method and device based on large model, electronic equipment and storage medium
CN118467695A
Cited By
State information query method and device of smart home equipment
CN121301417A