Index query method and device, electronic equipment and storage medium
By using preset custom dictionary and vector databases in the energy index query platform, and combining with large language models, the problem of large language models insufficient understanding of specific fields is solved, query efficiency and accuracy are improved, and the query efficiency and accuracy are reduced. cost.
Patent Information
- Application Number
- CN202411309776.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2025-01-14
AI Technical Summary
When large language models process user input involving specific cultural backgrounds, industry knowledge or social contexts, it is difficult to accurately analyze indicator data in the energy field, resulting in inaccurate keyword recognition, low processing efficiency and high cost.
Preset custom dictionary and vector database are used to prioritize the extraction of keywords in professional vocabulary and historical query text in the energy field. If the conditions do not meet the requirements, keywords will be extracted through a large language model and data query will be conducted in combination with TEXT-to-SQL technology.
It improves the recognition effect of proprietary vocabulary in the energy field, improves processing efficiency, reduces the cost of using large language models, and facilitates users to query corresponding indicator data through natural language.
Smart Images

Figure CN119311819A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data query technology, and in particular to an indicator query method, device, electronic equipment and storage medium. Background Art
[0002] In today's big data era, data analysis has become an important support for corporate decision-making and business operations. However, for many non-technical users, traditional data analysis tools have a high threshold for use, are complex to operate, and are difficult to quickly obtain valuable information. Therefore, question-answering systems based on natural language processing and knowledge graphs have become an effective way to solve this problem.
[0003] Large Language Models (LLM), such as ChatGPT (Chat Generative Pre-trained Transformer, a chatbot model), train models by connecting a large number of corpora that contain real-world conversations, so that LLM models have excellent Q&A capabilities with users. However, there is currently no intelligent Q&A interaction capability for indicator data based on the LLM model applicable to the gas energy field in the relevant technology. When the text input by the user involves specific cultural background, industry knowledge or social context information, this information may cause certain difficulties for the LLM model to understand, making the indicator platform use the LLM model to perform semantic analysis of the user input questions, and the keywords obtained by the analysis are not accurate enough. Summary of the invention
[0004] In view of the above problems, embodiments of the present invention are proposed to provide an indicator query method, device, electronic device and storage medium that overcome the above problems or at least partially solve the above problems.
[0005] In a first aspect, an embodiment of the present invention discloses an indicator query method, comprising:
[0006] Obtaining a first query text input by a user on an energy index query platform;
[0007] Determine the first keyword in the first query text according to a first preset database; wherein the first preset database includes at least one of a preset custom dictionary and a preset vector database; the preset custom dictionary includes professional vocabulary in the energy field; the preset vector database includes at least one of historical query texts input by users on the energy index query platform and text data extracted from an energy data statistical table;
[0008] Determine whether the first keyword meets a preset condition; the preset condition includes that there is target data matching the first keyword in a preset indicator database, or the first keyword includes at least one of a time keyword, an indicator keyword, and a dimension keyword;
[0009] If the first keyword meets the preset condition, determining target data matching the first keyword in the preset indicator database;
[0010] If the first keyword does not meet the preset condition, extracting a second keyword from the first query text by using a preset large language model, and determining target data matching the second keyword in the preset indicator database;
[0011] A reply text is output according to the target data.
[0012] Optionally, determining the first keyword in the first query text according to the first preset database includes:
[0013] Performing word segmentation processing on the first query text according to the preset custom dictionary to obtain at least one first word;
[0014] Determine a second word in the preset vector database, the second word having a similarity with the first word greater than a first similarity threshold;
[0015] The first word and the second word are used as first keywords.
[0016] Optionally, determining the target data matching the first keyword in the preset indicator database includes:
[0017] Extracting a third keyword from the first vocabulary and the second vocabulary, wherein the third keyword includes at least one of a time keyword, an indicator keyword, and a dimension keyword;
[0018] In the preset indicator database, target data matching the third keyword is determined.
[0019] Optionally, performing word segmentation processing on the first query text according to the preset custom dictionary includes:
[0020] The first query text is segmented by using a HanLp tool; wherein the HanLp tool includes the preset custom dictionary.
[0021] Optionally, the preset vector database includes the query result of the historical query text and the user's satisfaction with the reply text corresponding to the historical query text, and the query result includes a successful return; then, the method further includes:
[0022] Determine whether a second query text exists in the vector database; wherein the second query text is a historical query text in the historical query text whose similarity with the first query text is greater than a second similarity threshold, and the query result of the second query text is successfully returned, and the user's satisfaction with the reply text corresponding to the second query text is greater than the satisfaction threshold;
[0023] The determining the first keyword in the first query text according to the first preset database includes:
[0024] If the second query text does not exist in the preset vector database, the first keyword in the first query text is determined according to the first preset database.
[0025] Optionally, the method further comprises:
[0026] If the second query text exists in the preset vector database, target data matching the second query text is determined in the preset index database.
[0027] Optionally, the method further comprises:
[0028] Determining whether the first query text is a query text for a specified scenario;
[0029] If the first query text is a query text for a specified scenario, determining a reply text according to a mapping relationship between the specified scenario and the reply text;
[0030] The determining whether the second query text exists in the preset vector database includes:
[0031] If the first query text is not a query text for a specified scenario, it is determined whether a second query text exists in the preset vector database.
[0032] In a second aspect, an embodiment of the present invention discloses an indicator query device, including:
[0033] A first query text acquisition module, used to acquire a first query text input by a user on the energy index query platform;
[0034] A first keyword extraction module is used to determine the first keyword in the first query text according to a first preset database; wherein the first preset database includes at least one of a preset custom dictionary and a preset vector database; the preset custom dictionary includes professional vocabulary in the energy field; the preset vector database includes at least one of historical query texts input by users on the energy index query platform and text data extracted from an energy data statistical table;
[0035] A first keyword judgment module is used to judge whether the first keyword meets a preset condition; the preset condition includes that there is target data matching the first keyword in a preset indicator database, or the first keyword includes at least one of a time keyword, an indicator keyword, and a dimension keyword;
[0036] A first target data determination module, configured to determine target data matching the first keyword in the preset indicator database if the first keyword meets the preset condition;
[0037] A second target data determination module, configured to extract a second keyword from the first query text by using a preset large language model if the first keyword does not meet the preset condition, and determine target data matching the second keyword in the preset indicator database;
[0038] An output module is used to output a reply text according to the target data.
[0039] In a third aspect, an embodiment of the present invention discloses an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the steps of the above-mentioned indicator query method when executed by the processor.
[0040] In a fourth aspect, an embodiment of the present invention discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the indicator query method as described above are implemented.
[0041] The embodiments of the present invention include the following advantages:
[0042] Users can enter query text on the energy index query platform and the reply text will be returned. Users do not need to learn specific commands or syntax. The corresponding index data information can be queried through natural language dialogue, which facilitates users' query operations.
[0043] Priority is given to using a preset custom dictionary that stores professional vocabulary in the energy field, and / or a preset vector database that stores historical query texts and text data extracted from energy data statistics tables to extract keywords from the query text entered by the user. This can more accurately identify keywords related to the energy field, solve the problem of insufficient understanding of specific field knowledge by large language models, and improve the effect of language processing.
[0044] When the keywords extracted by the preset custom dictionary and / or the preset vector database do not meet the preset conditions, the keywords in the query text input by the user are extracted by the large language model. Compared with only performing semantic analysis and keyword recognition on the query text input by the user by the large language model, the processing efficiency is higher and the cost of using the large language model can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 This is a schematic diagram of an indicator query in a related technology provided by the present invention;
[0046] Figure 2 It is a flowchart of the steps of an indicator query method provided by an embodiment of the present invention;
[0047] Figure 3 is a flowchart of another index query method provided by an embodiment of the present invention;
[0048] Figure 4 is a flow chart of an indicator query method provided by an embodiment of the present invention;
[0049] Figure 5 It is a structural block diagram of an indicator query device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0050] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0051] Reference Figure 1 , shows a schematic diagram of an indicator query in a related technology provided by the present invention. The user inputs natural language, and the LLM model performs semantic analysis and keyword extraction on the natural language input by the user, and converts the keywords into structured query language (SQL) to query in the database. However, the related technology has the following problems:
[0052] (1) The LLM model has a poor recognition effect on the natural language input by users that involves specific cultural backgrounds, industry knowledge, social contexts, etc., and there are situations where the semantics are vague or ambiguous. For example, for the indicator "hazard rectification rate" which is a special term in the energy field, the LLM model may not be able to accurately parse out the true meaning.
[0053] (2) The processing efficiency of LLM models such as chatGPT is low: Although the current large language model supports interactive capabilities, its reasoning speed is slow and it takes more than ten seconds to respond. Every time a user inputs an additional question, it takes more waiting time, which reduces the service quality. At the same time, the large language model is charged in tokens as a whole, and the platform cost will increase as the usage increases.
[0054] (3) We tried to send the table structure to chatGPT first and then send the query text entered by the user, trying to generate SQL directly through chatGPT. However, after multiple rounds of prompt optimization and adjustment, we still could not meet the requirements of production availability in terms of stability and accuracy. The main reasons include: In order for LLM to understand the database model (schema, the organization and structure of the database), the names and descriptions of all fields need to be entered as the query context (context). If the schema has a large number of fields, it may exceed the token limit. Also, due to the token limitation, field values with a large cardinality are generally not all put into the context, making LLM unable to recognize some terms in proprietary fields. In addition, even if the entire schema is entered and LLM is told not to guess arbitrarily, there is still a certain probability that the wrong field will be inferred, and even non-existent fields may be obtained.
[0055] In view of the above problems, one of the core concepts of the embodiment of the present invention is to preferentially use a preset custom dictionary storing professional vocabulary in the energy field, and / or a preset vector database storing historical query texts and text data extracted from energy data statistics tables to extract keywords in the query text input by the user. When the keywords extracted by the preset custom dictionary and / or the preset vector database do not meet the preset conditions, the keywords in the query text input by the user are extracted by a large language model. Thereby, the recognition effect of the specialized vocabulary in the energy field is improved, the processing efficiency is improved, and the cost of using a large language model is reduced.
[0056] Reference Figure 2 , shows a flowchart of a method for querying an indicator provided by an embodiment of the present invention, and the method may specifically include the following steps:
[0057] Step 101: obtaining a first query text input by a user on an energy index query platform.
[0058] Energy refers to resources that can provide energy, including primary energy such as coal, crude oil, natural gas, coal-bed methane, hydropower, nuclear energy, wind energy, solar energy, geothermal energy, biomass energy, and secondary energy such as electricity, heat, refined oil, and other new energy and renewable energy.
[0059] An indicator is a concept that describes the overall comprehensive quantitative characteristics. A complete indicator generally consists of two parts: the indicator name and the indicator value, which embodies the characteristics of both the material and quantitative characteristics of things.
[0060] Energy index query platform refers to a port that provides energy-related index query functions. For example, gas index query platform.
[0061] The user can enter the first query text on the energy index query platform, such as "the hidden danger rectification rate of gas in A area in June 2023", or can enter the first query voice. After receiving the first query voice, the energy index query platform can convert the first query voice into the first query text.
[0062] The first query text may include numbers, Chinese, English, etc. The present invention does not limit the language included in the first text.
[0063] Step 102, determining a first keyword in a first query text according to a first preset database; wherein the first preset database includes at least one of a preset custom dictionary and a preset vector database; the preset custom dictionary includes professional vocabulary in the energy field; the preset vector database includes at least one of historical query texts input by users on an energy index query platform, and text data extracted from an energy data statistics table.
[0064] The professional vocabulary in the preset custom dictionary can be selected and imported from professional books in the energy field, or can be selected and imported from energy data statistical tables, or can be supplemented by users. Among them, energy data statistical tables can include fact tables, dimension tables, indicator tables, etc.
[0065] After obtaining the first query text, the first query text may be segmented according to a preset custom dictionary to obtain at least one first word, and the first word is used as the first keyword.
[0066] Natural Language Processing (NLP) is a subset of the field of artificial intelligence that enables computers to understand and process human language. This understanding includes parsing the vocabulary, grammar, and contextual meaning of text, and converting words, phrases, or text into continuous vector representations to capture the semantic information of the language.
[0067] HanLp is an NLP toolkit composed of a series of models and algorithms. It has good support for Chinese, few dependencies, is ready to use out of the box, has complete basic tools, neat interfaces, is easy to develop, is relatively mature for word segmentation, and provides custom dictionaries. Based on custom dictionaries, specific words in specific fields can be marked with parts of speech, so that word segmentation can be performed according to the natural language input by the user and the meaning of each word can be correctly identified, which can provide a basis for subsequent work.
[0068] Then, the step of performing word segmentation processing on the first query text according to the preset custom dictionary may specifically include: performing word segmentation processing on the first query text by using a HanLp tool; wherein the HanLp tool includes a preset custom dictionary.
[0069] The vector database is a special database that stores information in the form of multidimensional vectors. The preset vector database is a vector database that stores the historical query texts entered by users on the energy index query platform and / or the text data extracted from the energy data statistical table. The energy data statistical table may include a fact table of energy data, a dimension table of energy data, and an indicator table of energy data.
[0070] The historical query text is the query text that the user has entered in the energy index query platform in the past.
[0071] Then, after obtaining the first query text, the first keyword in the first query text can also be determined by combining the preset custom dictionary and the preset vector database. For example, the first query text can be segmented according to the preset custom dictionary to obtain at least one first word; a second word in the preset vector database whose similarity to the first word is greater than a first similarity threshold is determined; and the first word and the second word are used as the first keyword.
[0072] The biggest feature of the vector database is that it can calculate the numerical vector of the word according to the input word through the algorithm. Therefore, when the user asks questions, different words described in natural language may correspond to the same word in the energy index query platform. Therefore, a tool is needed to determine which words can be replaced with words with the same meaning, so that the index platform can recognize them and meet the data content that the user wants to query. Therefore, the similarity between words is determined by the difference in the numerical vectors between words in the preset vector database. For example, the name of the region stored in the index database and the custom dictionary is "A Regional Business Coordination Group", but when the user queries, he may enter "A Region". At this time, the custom dictionary cannot match it, resulting in the inability to return data to the user. Therefore, the preset vector database is used to calculate the vector value of the "A Region" entered by the user, and match it to the word "A Regional Business Coordination Group" in the vector database with the closest vector value, that is, the most similar word. Query data in the "A Regional Business Coordination Group" index database to query the data, and you can query the data the user wants.
[0073] For users, data with the same meaning may have many different names, and there is no guarantee of an exact match. Therefore, a vector database is used to match the text closest to the word, but a custom dictionary does not have this function, so the two need to be used together.
[0074] Step 103, determining whether the first keyword meets preset conditions; the preset conditions include the existence of target data matching the first keyword in a preset indicator database, or the first keyword includes at least one of a time keyword, an indicator keyword, and a dimension keyword.
[0075] Determine whether the first keyword includes at least one of a time keyword, an indicator keyword, and a dimension keyword, or determine whether there is target data matching the first keyword in a preset indicator database.
[0076] The time keyword is a keyword containing time, for example, the time keyword is "2023".
[0077] Dimension keywords are keywords that contain dimensions. Dimensions are certain characteristics of things or phenomena. Specifically, dimensions may include geographical dimensions, organizational structure dimensions, corporate entity dimensions, etc. For example, dimensional keywords include "Region A", "Company A", etc.
[0078] Indicator keywords are keywords that contain indicators. Indicators are units or methods used to measure the degree of development of things. For example, indicator keywords are "hidden danger rectification rate", "gas volume", "monthly average gas volume", "monthly sales volume", etc.
[0079] The indicator database is a database storing indicator data. The indicator data can be stored in a table format.
[0080] Step 104: If the first keyword meets the preset condition, target data matching the first keyword is determined in the preset indicator database.
[0081] When the first keyword is determined only through the preset custom dictionary and the first keyword meets the preset conditions, the third keyword can be extracted from the first vocabulary, and the third keyword includes at least one of a time keyword, an indicator keyword, and a dimension keyword. For example, the third keyword can include a dimension keyword "A gas", a time keyword "June 2023", and an indicator keyword "hazard rectification rate".
[0082] When the first keyword is determined in combination with the preset custom dictionary and the preset vector database, and the first keyword meets the preset conditions, the third keyword can be extracted from the first vocabulary and the second vocabulary. The third keyword can be extracted from the first vocabulary first. If all the required third keywords cannot be extracted from the first vocabulary, they can be extracted from the second vocabulary without omission. For example, the first query text is "Hazard rectification rate of Region A in June 2023". The first query text is segmented to obtain the first vocabulary "Region A", "June 2023", and "Hazard rectification rate". The third keyword time keyword "June 2023" and the indicator keyword "Hazard rectification rate" are extracted from the first vocabulary, but according to the fact that no dimension keywords are extracted, it can be known from the preset vector database that the second vocabulary corresponding to the first vocabulary "Region A" is "Region A", and according to the second vocabulary "Region A", the third key dimension keyword "Region A" is extracted.
[0083] TEXT-to-SQL technology: a technology that can convert natural language into SQL, making it easier to interact with and retrieve structured data in a database or knowledge base through SQL.
[0084] After obtaining the third keyword, the third keyword can be converted into SQL language through TEXT-to-SQL technology. For example, the converted SQL language can be: "select hidden danger rectification rate from tbl where calculation time = 'June 2023' and dimension = 'Langfang Gas' and indicator name = 'Hidden danger rectification rate'".
[0085] The SQL language obtained by the conversion is queried in a preset indicator database to determine the target data matching the third keyword. The target data may be an indicator data table matching the third keyword.
[0086] Step 105: If the first keyword does not meet the preset condition, a second keyword is extracted from the first query text by using a preset large language model, and target data matching the second keyword is determined in a preset indicator database.
[0087] If the first keyword does not meet the preset condition, a second keyword may be extracted from the first query text through a preset large language model, and the second keyword may include at least one of a time keyword, an indicator keyword, and a dimension keyword. The preset large language model may be a GPT model.
[0088] After obtaining the second keyword, the second keyword can be converted into SQL language through TEXT-to-SQL, and the converted SQL language is used to query in the preset indicator database to determine the target data matching the second keyword.
[0089] Step 106, outputting a reply text according to the target data.
[0090] The target data may be directly output, or may be converted before output. For example, if the target data is an indicator data table, the indicator data table may be converted into text or graphics before output.
[0091] In the embodiment of the present invention, a user can enter a query text on the energy index query platform to return a reply text. The user does not need to learn specific commands or grammars, and can query the corresponding index data information through natural language dialogue, which facilitates the user's query operation.
[0092] Priority is given to using a preset custom dictionary that stores professional vocabulary in the energy field, and / or a preset vector database that stores historical query texts and text data extracted from energy data statistics tables to extract keywords from the query text entered by the user. This can more accurately identify keywords related to the energy field, solve the problem of insufficient understanding of specific field knowledge by large language models, and improve the effect of language processing.
[0093] When the keywords extracted by the preset custom dictionary and / or the preset vector database do not meet the preset conditions, the keywords in the query text input by the user are extracted by the large language model. Compared with only performing semantic analysis and keyword recognition on the query text input by the user by the large language model, the processing efficiency is higher and the cost of using the large language model can be reduced.
[0094] Reference Figure 3 , shows a flowchart of another index query method provided by an embodiment of the present invention, wherein the preset vector database includes query results of historical query texts and user satisfaction with the reply texts corresponding to the historical query texts, and the query results include successful returns; the method may specifically include the following steps:
[0095] Step 201: obtaining a first query text input by a user on an energy index query platform.
[0096] Step 202, determine whether there is a second query text in the preset vector database; wherein the second query text is a historical query text whose similarity with the first query text is greater than a second similarity threshold in the historical query text, and the query result of the second query text is successfully returned, and the user's satisfaction with the reply text corresponding to the second query text is greater than the satisfaction threshold.
[0097] After obtaining the first query text, the first query text is not segmented, and the first query text is directly matched with the historical query text in the preset vector database to determine whether the second query text exists in the preset vector database. The second query text meets the following three conditions: ① The similarity with the first query text is greater than the second similarity threshold; ② The query result of the second query text is successfully returned; ③ The user's satisfaction with the reply text corresponding to the second query text is greater than the satisfaction threshold.
[0098] Step 203: If the second query text exists in the preset vector database, target data matching the second query text is determined in the preset index database.
[0099] If the second query text exists in the preset vector database, keywords are directly extracted from the second query text, and target data matching the second query text is determined according to the keywords extracted from the second query text.
[0100] Step 204: If the second query text does not exist in the preset vector database, determine the first keyword in the first query text according to the first preset database.
[0101] If the second query text does not exist in the preset vector database, the second query text is segmented, and the first word and / or the second word obtained by the segmentation are used as the first keyword.
[0102] Step 205: determine whether the first keyword meets the preset conditions.
[0103] Step 206: If the first keyword meets the preset condition, target data matching the first keyword is determined in the preset indicator database.
[0104] Step 207, outputting a reply text according to the target data.
[0105] Step 205 to step 207 are similar to steps 104 to 106 and are not described in detail here.
[0106] In the embodiment of the present invention, when the second query text is matched, the keyword is directly determined according to the second query text, which can improve the query efficiency. And because the index database is constantly updated, even if the second query text, that is, the query text previously input by the user, is queried, the reply text corresponding to the query text previously input by the user cannot be directly used, but needs to be queried again in the index database according to the second query text.
[0107] In one embodiment, before step 202, the indicator query method may also include: determining whether the first query text is a query text for a specified scenario; if the first query text is a query text for a specified scenario, determining the reply text according to a mapping relationship between the specified scenario and the reply text; then step 202 may specifically include: if the first query text is not a query text for the specified scenario, determining whether a second query text exists in a preset vector database.
[0108] The energy index query platform may store a mapping relationship between a specified scenario and a reply text. To determine whether the first query text is a query text for a specified scenario, it may be to determine whether the first query text contains specific keywords, or to determine whether the sentence structure of the first query text conforms to a specific structure. If it is determined that the first query text is a query text for a specified scenario, the energy index query platform may determine the reply text based on the mapping relationship between the specified scenario and the reply text. If the first query text is not a query text for a specified scenario, it is determined whether the second query text exists in the preset vector database.
[0109] Determining the corresponding reply text according to the scenario can improve query efficiency and ensure the accuracy of query results.
[0110] After receiving the reply text, the user can evaluate the satisfaction with the reply text.
[0111] Reference Figure 4 , showing a flow chart of an indicator query method provided by an embodiment of the present invention. The user inputs a first query text, and first determines whether the first query text is a query text for a specified scenario. If so, a reply text is returned according to the specified scenario. If not, a similar question is matched from the vector database. When the second query text is matched, data query is performed according to the second query text; when the second query text is not matched, the first query text is segmented according to the Hanlp tool, and the first keyword is determined in combination with the preset vector database. If the first keyword meets the preset conditions, data query is performed according to the first keyword. If the first keyword does not meet the preset conditions, the first query text is keyword extracted through the LLM model to obtain the second keyword, and data query is performed according to the second keyword.
[0112] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, 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 involved are not necessarily required by the embodiments of the present invention.
[0113] Reference Figure 5 , shows a structural block diagram of an indicator query device provided by an embodiment of the present invention, which may specifically include the following modules:
[0114] The first query text acquisition module 301 is used to acquire the first query text input by the user on the energy index query platform;
[0115] A first keyword extraction module 302 is used to determine the first keyword in the first query text according to a first preset database; wherein the first preset database includes at least one of a preset custom dictionary and a preset vector database; the preset custom dictionary includes professional vocabulary in the energy field; the preset vector database includes at least one of historical query texts input by users in the energy index query platform and text data extracted from the energy data statistical table;
[0116] A first keyword determination module 303 is used to determine whether the first keyword meets a preset condition; the preset condition includes that there is target data matching the first keyword in a preset indicator database, or the first keyword includes at least one of a time keyword, an indicator keyword, and a dimension keyword;
[0117] A first target data determination module 304, configured to determine target data matching the first keyword in the preset indicator database if the first keyword meets the preset condition;
[0118] A second target data determination module 305 is configured to extract a second keyword from the first query text by using a preset large language model if the first keyword does not meet the preset condition, and determine target data matching the second keyword in the preset indicator database;
[0119] The output module 306 is used to output a reply text according to the target data.
[0120] Optionally, the first keyword extraction module 302 is specifically used to: perform word segmentation processing on the first query text according to the preset custom dictionary to obtain at least one first word; determine a second word in the preset vector database whose similarity with the first word is greater than a second similarity threshold; and use the first word and the second word as first keywords.
[0121] Optionally, the first target data determination module 304 includes:
[0122] A third keyword extraction submodule, configured to extract a third keyword from the first vocabulary and the second vocabulary, wherein the third keyword includes at least one of a time keyword, an indicator keyword, and a dimension keyword;
[0123] The first target data determination submodule is used to determine the target data matching the third keyword in the preset indicator database.
[0124] Optionally, the first keyword extraction module 302 is specifically used to: perform word segmentation processing on the first query text through a HanLp tool; wherein the HanLp tool includes the preset custom dictionary.
[0125] Optionally, the preset vector database includes the query result of the historical query text and the user's satisfaction with the reply text corresponding to the historical query text, and the query result includes a successful return; then, the device further includes:
[0126] A second query text determination module is used to determine whether a second query text exists in the preset vector database; wherein the second query text is a historical query text in the historical query text whose similarity with the first query text is greater than a first similarity threshold, and the query result of the second query text is successfully returned, and the user's satisfaction with the reply text corresponding to the second query text is greater than a satisfaction threshold;
[0127] The first keyword extraction module 302 is specifically configured to: if the second query text does not exist in the preset vector database, determine the first keyword in the first query text according to the first preset database.
[0128] Optionally, the device further comprises:
[0129] The third target data determination module is used to determine the target data matching the second query text in a preset index database if the second query text exists in the preset vector database.
[0130] Optionally, the device further comprises:
[0131] A scene judgment module, used to judge whether the first query text is a query text for a specified scene; if the first query text is a query text for a specified scene, determining a reply text according to a mapping relationship between the specified scene and the reply text;
[0132] The second query text determination module is specifically configured to: if the first query text is not a query text for a specified scenario, determine whether a second query text exists in the preset vector database.
[0133] A query option display module, used to display semantic query options and specified scenario query options on the energy index query platform;
[0134] A first query module, used for obtaining the indicator query scenario input by the user when the user triggers the specified scenario query option, and displaying the reply text corresponding to the indicator query scenario input by the user according to the mapping relationship between the indicator query scenario and the reply text;
[0135] The first query text acquisition module 301 is specifically used to: when the user triggers the semantic query option, acquire the first query text input by the user on the energy index query platform.
[0136] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0137] An embodiment of the present invention further provides an electronic device, including:
[0138] It includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned indicator query method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0139] An embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the various processes of the above-mentioned indicator query method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0140] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0141] It will be appreciated by those skilled in the art that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0142] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0143] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0144] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0145] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0146] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0147] The above is a detailed introduction to an indicator query method, device, electronic device and storage medium provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. An indicator query method, characterized in that: include: Obtaining a first query text input by a user on an energy index query platform; Determine the first keyword in the first query text according to a first preset database; wherein the first preset database includes at least one of a preset custom dictionary and a preset vector database; the preset custom dictionary includes professional vocabulary in the energy field; the preset vector database includes at least one of historical query texts input by users on the energy index query platform and text data extracted from an energy data statistical table; Determine whether the first keyword meets a preset condition; the preset condition includes that there is target data matching the first keyword in a preset indicator database, or the first keyword includes at least one of a time keyword, an indicator keyword, and a dimension keyword; If the first keyword meets the preset condition, determining target data matching the first keyword in the preset indicator database; If the first keyword does not meet the preset condition, extracting a second keyword from the first query text by using a preset large language model, and determining target data matching the second keyword in the preset indicator database; A reply text is output according to the target data.
2. The index query method according to claim 1, characterized in that: The determining the first keyword in the first query text according to the first preset database includes: Performing word segmentation processing on the first query text according to the preset custom dictionary to obtain at least one first word; Determine a second word in the preset vector database, the second word having a similarity with the first word greater than a first similarity threshold; The first word and the second word are used as first keywords.
3. The index query method according to claim 2, characterized in that: Determining the target data matching the first keyword in the preset indicator database includes: Extracting a third keyword from the first vocabulary and the second vocabulary, the third keyword including at least one of a time keyword, an indicator keyword, and a dimension keyword; In the preset indicator database, target data matching the third keyword is determined.
4. The index query method according to claim 2, characterized in that: The performing word segmentation processing on the first query text according to the preset custom dictionary includes: The first query text is segmented by using a HanLp tool; wherein the HanLp tool includes the preset custom dictionary.
5. The index query method according to claim 1, characterized in that: The preset vector database includes the query result of the historical query text and the user's satisfaction with the reply text corresponding to the historical query text, and the query result includes a successful return; then, the method further includes: Determine whether a second query text exists in the preset vector database; wherein the second query text is a historical query text in the historical query text whose similarity with the first query text is greater than a second similarity threshold, and the query result of the second query text is successfully returned, and the user's satisfaction with the reply text corresponding to the second query text is greater than the satisfaction threshold; The determining the first keyword in the first query text according to the first preset database includes: If the second query text does not exist in the preset vector database, the first keyword in the first query text is determined according to the first preset database.
6. The index query method according to claim 5, characterized in that: The method further comprises: If the second query text exists in the preset vector database, target data matching the second query text is determined in the preset index database.
7. The index query method according to claim 5, characterized in that: The method further comprises: Determining whether the first query text is a query text for a specified scenario; If the first query text is a query text for a specified scenario, determining a reply text according to a mapping relationship between the specified scenario and the reply text; The determining whether the second query text exists in the preset vector database includes: If the first query text is not a query text for a specified scenario, it is determined whether a second query text exists in the preset vector database.
8. An indicator query device, characterized in that: include: A first query text acquisition module, used to acquire a first query text input by a user on the energy index query platform; A first keyword extraction module is used to determine the first keyword in the first query text according to a first preset database; wherein the first preset database includes at least one of a preset custom dictionary and a preset vector database; the preset custom dictionary includes professional vocabulary in the energy field; the preset vector database includes at least one of historical query texts input by users on the energy index query platform and text data extracted from an energy data statistical table; A first keyword judgment module is used to judge whether the first keyword meets a preset condition; the preset condition includes that there is target data matching the first keyword in a preset indicator database, or the first keyword includes at least one of a time keyword, an indicator keyword, and a dimension keyword; A first target data determination module, configured to determine target data matching the first keyword in the preset indicator database if the first keyword meets the preset condition; A second target data determination module, configured to extract a second keyword from the first query text by using a preset large language model if the first keyword does not meet the preset condition, and determine target data matching the second keyword in the preset indicator database; An output module is used to output a reply text according to the target data.
9. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the steps of the indicator query method as described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the indicator query method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Data query method and device, medium and equipment
CN120277092A