Data query method and device, computer equipment and storage medium

By combining natural language processing models and large language models, the problem of inaccurate understanding of user intent in existing technologies is solved, and efficient and accurate data query is achieved, making it applicable to data query methods on various terminal devices and servers.

CN122019562APending Publication Date: 2026-05-12SHENZHEN SIYUAN ELECTRONICS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN SIYUAN ELECTRONICS TECH CO LTD
Filing Date
2025-12-09
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

Existing technologies struggle to accurately understand users' natural language query intent, leading to inaccurate or incomplete query results. This is especially true for non-professional users, for whom traditional structured query statements present significant challenges.

Method used

The semantic features of the data query text are extracted using a natural language processing model, candidate business tables are indexed using a vector database, and intent reasoning is performed using a large language model to generate structured query statements, which are then retrieved in the system database.

Benefits of technology

It enables automatic understanding and accurate inference of users' natural language queries, generating structured query statements suitable for the system database, improving the efficiency and accuracy of data retrieval, and lowering the query threshold for users.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122019562A_ABST
    Figure CN122019562A_ABST
Patent Text Reader

Abstract

The embodiment of the invention belongs to the technical field of data processing and query, and relates to a data query method and device, computer equipment and a storage medium. Performing semantic feature extraction operation on the data query text according to the natural language processing model to obtain a semantic query vector; reading the constructed vector database, and indexing a candidate service table corresponding to the semantic query vector in the constructed vector database; performing cue word integration operation on the data query text according to the structured cue word template to obtain a current query intention; inputting the candidate service table and the current query intention into a large language model for intention reasoning operation to obtain a structured query statement; and reading a system database, and performing statement retrieval operation on the structured query statement in the system database to obtain a target retrieval result. According to the method, efficient and accurate data retrieval can be realized, the user query threshold is reduced, and the query efficiency and accuracy are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing and query technology, and in particular to a data query method, apparatus, computer equipment and storage medium. Background Technology

[0002] In today's digital age, data volume is exploding, and various business systems have accumulated massive amounts of data. Traditional data query methods mainly rely on users accurately inputting structured query statements, such as SQL (Structured Query Language) statements. This poses a significant challenge for non-professional users, as they may not be familiar with complex syntax rules and database structures.

[0003] However, the applicant found that, despite the continuous development of natural language processing technology and the emergence of some preliminary attempts to understand natural language queries, these methods still have many shortcomings in handling complex semantics, understanding users' true intentions, and generating accurate query statements. For example, for query texts with implicit semantics or ambiguous expressions, traditional methods struggle to accurately parse and transform them into valid query instructions, resulting in inaccurate or incomplete query results that fail to meet users' actual needs. Summary of the Invention

[0004] The purpose of this application is to provide a data query method, apparatus, computer device, and storage medium to solve the problem of inaccurate query results in the prior art.

[0005] To address the aforementioned technical problems, this application provides a data query method, employing the following technical solution: Retrieve data query text; The semantic feature extraction operation is performed on the data query text according to the natural language processing model to obtain the semantic query vector; Read the constructed vector database and index the candidate business table corresponding to the semantic query vector in the constructed vector database; The data query text is integrated with the structured prompt word template to obtain the current query intent; The candidate business table and the current query intent are input into the large language model for intent reasoning to obtain a structured query statement; The system database is read, and the structured query statement is retrieved in the system database to obtain the target retrieval result.

[0006] To address the aforementioned technical problems, this application also provides a data query device, which employs the following technical solution: The data query text acquisition module is used to acquire data query text; The semantic feature extraction module is used to perform semantic feature extraction on the data query text according to the natural language processing model to obtain a semantic query vector. The candidate business table acquisition module is used to read the constructed vector database and index the candidate business table corresponding to the semantic query vector in the constructed vector database; The prompt word integration module is used to perform prompt word integration on the data query text based on the structured prompt word template to obtain the current query intent; The intent reasoning module is used to input the candidate business table and the current query intent into the large language model to perform intent reasoning operations and obtain a structured query statement; The statement retrieval module is used to read the system database and perform statement retrieval operations on the structured query statement in the system database to obtain the target retrieval results.

[0007] To address the aforementioned technical problems, this application also provides a computer device that employs the following technical solution: It includes a memory and a processor, wherein the memory stores computer-readable instructions, and the processor executes the computer-readable instructions to implement the steps of the data query method described above.

[0008] To address the aforementioned technical problems, this application also provides a computer-readable storage medium, employing the technical solution described below: The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the data query method described above.

[0009] This application provides a data query method, comprising: acquiring data query text; performing semantic feature extraction on the data query text according to a natural language processing model to obtain a semantic query vector; reading a constructed vector database and indexing a candidate business table corresponding to the semantic query vector in the constructed vector database; performing prompt word integration on the data query text according to a structured prompt word template to obtain the current query intent; inputting the candidate business table and the current query intent into a large language model for intent reasoning to obtain a structured query statement; reading a system database and performing a statement retrieval operation on the structured query statement in the system database to obtain the target retrieval result. Compared with the prior art, this application can automatically understand the semantics of the natural language data query text input by the user, accurately infer the user's query intent, and generate a structured query statement suitable for the system database, thereby achieving efficient and accurate data retrieval, reducing the user's query threshold, and improving query efficiency and accuracy. Attached Figure Description

[0010] To more clearly illustrate the solutions in this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0011] Figure 1 This is an exemplary system architecture diagram to which this application can be applied; Figure 2 This is a flowchart illustrating the implementation of the data query method provided in the embodiments of this application; Figure 3 This is a schematic diagram of the structure of the data query device provided in the embodiments of this application; Figure 4 This is a schematic diagram of the structure of one embodiment of the computer device according to this application. Detailed Implementation

[0012] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the terminology used herein in the specification of the application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "comprising" and "having," and any variations thereof, in the specification, claims, and foregoing drawings of this application, are intended to cover non-exclusive inclusion. The terms "first," "second," etc., in the specification, claims, or foregoing drawings of this application are used to distinguish different objects, not to describe a particular order.

[0013] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

[0014] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.

[0015] like Figure 1As shown, system architecture 100 may include terminal device 101, network 102, and server 103. Terminal device 101 may be a laptop 1011, tablet 1012, or mobile phone 1013. Network 102 is used as a medium to provide a communication link between terminal device 101 and server 103. Network 102 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.

[0016] Users can use terminal device 101 to interact with server 103 via network 102 to receive or send messages, etc. Various communication client applications can be installed on terminal device 101, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social media platform software, etc.

[0017] Terminal device 101 can be various electronic devices with a display screen and support web browsing. In addition to laptops 1011, tablets 1012, or mobile phones 1013, terminal device 101 can also be an e-book reader, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 player (Moving Picture Experts Group Audio Layer IV), a laptop computer, and a desktop computer, etc.

[0018] Server 103 can be a server that provides various services, such as a backend server that provides support for the pages displayed on terminal device 101.

[0019] It should be noted that the data query method provided in this application embodiment is generally executed by a server / terminal device, and correspondingly, the data query device is generally set in the server / terminal device.

[0020] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.

[0021] Continue to refer to Figure 2 The diagram illustrates a flowchart of an embodiment of the data query method according to this application. The data query method includes steps S201, S202, S203, S204, S205, S206, and S207.

[0022] In step S201, the data query text is obtained.

[0023] In this embodiment of the application, a user can input a request carrying data query text through their terminal device. This request is received by the system for subsequent related data query operations. The terminal device can be a mobile terminal such as a mobile phone, smartphone, laptop, digital broadcast receiver, PDA (personal digital assistant), PAD (tablet computer), PMP (portable multimedia player), navigation device, etc., or a fixed terminal such as a digital TV, desktop computer, etc. It should be understood that the examples of terminal devices given herein are for convenience of understanding only and are not intended to limit this application.

[0024] In this application embodiment, the data query text refers to the data-related information that the user wants to query. The data query text can also be query conditions and the expected query result format, etc.

[0025] In practical applications, this application uses the data query text "Query product information with sales exceeding 10,000 yuan in the most recent month" as an example for illustration.

[0026] In step S202, semantic feature extraction is performed on the data query text according to the natural language processing model to obtain the semantic query vector.

[0027] In this embodiment of the application, the semantic feature extraction operation can use a pre-trained natural language processing model (such as BERT, GPT and other series of models) to convert the input data query text into a vector representation with rich semantic information, namely the semantic query vector mentioned above.

[0028] In the embodiments of this application, the natural language processing model is pre-trained on a large-scale corpus, which can capture the semantics in the text and map complex natural language to a high-dimensional vector space, so that semantically similar texts are closer in the vector space, thereby providing a foundation for subsequent vector matching and intent understanding.

[0029] In practical applications, this application loads a natural language processing model and inputs the query "query product information with sales exceeding 10,000 yuan in the most recent month" into the natural language processing model. The natural language processing model processes the query "query product information with sales exceeding 10,000 yuan in the most recent month" layer by layer, extracts the semantic features of the text, and finally outputs a fixed-dimensional vector. This vector contains vector representations of key semantic elements such as "most recent month", "sales exceeding 10,000 yuan", and "product information".

[0030] In step S203, the constructed vector database is read, and the candidate business table corresponding to the semantic query vector is indexed in the constructed vector database.

[0031] In this embodiment, a vector database is pre-constructed, which stores the semantic vector representations of various business tables in the business system. These business table vectors are obtained by extracting semantic features from the table identifier, field identifier, field type, field description, default value, primary key information, and mapping relationships between fields, while selecting some representative sample records as data.

[0032] In this embodiment, after obtaining the semantic query vector, the system uses an efficient similarity search algorithm (such as cosine similarity algorithm, Euclidean distance algorithm, etc.) to index the vector database and find several business table vectors with the highest similarity to the semantic query vector. The corresponding business tables are the candidate business tables. These candidate business tables are semantically highly relevant to the user's query text and are target tables that may contain the data required by the user.

[0033] In practical applications, after obtaining the vector representation containing key semantic elements such as "the most recent month", "sales exceeding 10,000 yuan", and "product information", this application calculates the similarity between the semantic query vector and each business table vector in the vector database, and filters out business table vectors with similarity higher than the set similarity threshold (e.g., 0.8) according to the set similarity threshold, and uses the business table corresponding to the business table vector as the above-mentioned candidate business table.

[0034] In step S204, the data query text is integrated with the structured prompt word template to obtain the current query intent.

[0035] In this application embodiment, a series of structured prompt word templates are pre-designed based on business needs and common query scenarios. These templates contain different query dimensions and conditions, such as time range, query object, query indicator, and filtering conditions. As an example, a prompt word template for sales data analysis can be designed as: "Query [sales indicators] for [product name] within [time range], with [filter conditions]".

[0036] In this embodiment, the prompt word integration operation refers to matching and integrating the data query text with a structured prompt word template. Using natural language processing technology, key information in the data query text, such as time, product name, and sales metrics, is identified and populated into the corresponding positions in the structured prompt word template. After integration, a structured representation of the current query intent is obtained, which more clearly expresses the user's query needs and conditions.

[0037] In step S205, the candidate business table and the current query intent are input into the large language model for intent reasoning to obtain a structured query statement.

[0038] In this embodiment, the intent reasoning operation can utilize a high-performance large language model (such as GPT-3, Wenxin Yiyan, etc.). The table structure information of the candidate business table and the integrated current query intent are input as input prompts into the large language model. Leveraging its powerful language understanding and generation capabilities, the large language model performs in-depth analysis and reasoning on the input table structure information and prompt information, understanding the data content, query conditions, and expected query result format that the user wants to query, and generates structured query statements according to the query language specifications (such as SQL) supported by the system database.

[0039] In this embodiment, the structured query statement is mainly used to accurately express the user's query requirements and can be executed directly in the system database.

[0040] In practical applications, the table structure information and the integrated current query intent text are input as prompts into the large language model. The large language model performs in-depth analysis and reasoning on the input text to understand the user's desired data range (sales data for the most recent month), query conditions (sales exceeding 10,000 yuan), and expected query results (detailed information such as product name and product category). Based on the SQL language specifications supported by the system database, the following structured query statement is generated: SELECT p.product_name, s.product_category FROM Product Sales Table p JOIN Sales Statistics Table s ON p.Product Category = s.Product Category WHERE p.SalesDate>= DATE_SUB(CURRENT_DATE(), INTERVAL 1 MONTH) AND p. Sales revenue > 10,000.

[0041] In step S206, the system database is read, and a statement retrieval operation is performed on the structured query statement in the system database to obtain the target retrieval result.

[0042] In this embodiment, after obtaining the structured query statement, a query retrieval operation can be performed. This application connects to the target system's database and sends the generated structured query statement to the database management system for execution. The database management system retrieves data matching the conditions from the database according to the query statement's instructions and returns the retrieval results to the system.

[0043] In this embodiment of the application, the system can perform necessary processing and formatting on the returned search results, such as data sorting and format conversion, and finally present the target search results to the user to complete the entire data query process.

[0044] In practical applications, this application connects to the target system's database (assuming it's a MySQL database) and uses a database connection library (such as Python's PyMySQL library) to send the generated structured query statement to the database management system. The database management system executes the query statement, retrieving data that meets the criteria from the "Product Sales Table" and "Sales Statistics Table," specifically the product names and product category information for products with sales exceeding 10,000 yuan in the most recent month. The search results are returned to the system, which performs necessary processing, such as sorting by product name, and then presents the final target search results to the user in tabular form for easy viewing and analysis.

[0045] This application provides a data query method, comprising: acquiring data query text; performing semantic feature extraction on the data query text according to a natural language processing model to obtain a semantic query vector; reading a constructed vector database and indexing a candidate business table corresponding to the semantic query vector in the constructed vector database; performing prompt word integration on the data query text according to a structured prompt word template to obtain the current query intent; inputting the candidate business table and the current query intent into a large language model for intent reasoning to obtain a structured query statement; reading a system database and performing a statement retrieval operation on the structured query statement in the system database to obtain the target retrieval result. Compared with the prior art, this application can automatically understand the semantics of the natural language data query text input by the user, accurately infer the user's query intent, and generate a structured query statement suitable for the system database, thereby achieving efficient and accurate data retrieval, reducing the user's query threshold, and improving query efficiency and accuracy.

[0046] In some optional implementations of the embodiments of this application, the step of extracting semantic features from the data query text based on the natural language processing model to obtain the semantic query vector specifically includes the following steps: Perform lexical analysis on the data query text to obtain the data query terms; Perform syntactic analysis on the data query terms to obtain the data query syntax; Perform semantic role labeling on the data query syntax to obtain the data query roles; Semantic understanding operations are performed on the data query roles based on a natural language processing model to obtain semantic query text; Perform vector transformation on the semantic query text to obtain the semantic query vector.

[0047] In this embodiment of the application, after obtaining the data query text, due to the ambiguity and other problems of the data query text, the computer has difficulty directly understanding the accurate intent of the data query text. Therefore, it is necessary to perform semantic recognition operations on the data query text. Specifically, the semantic recognition operations include lexical analysis, syntactic analysis, semantic role labeling, and semantic understanding. 1) Lexical analysis: The data query text is segmented into words, breaking down continuous text into meaningful word units. For example, the query "Find which products have sales exceeding 1 million in the past month" can be segmented into "Find / past / month / within / sales / exceed / 1 million / of / products / which". Through lexical analysis, the basic vocabulary structure of the text can be clearly identified, laying the foundation for subsequent semantic understanding.

[0048] 2) Syntactic analysis: Analyzing the grammatical relationships between words helps determine the sentence structure, such as the division of components like subject, verb, object, attributive, adverbial, and complement. For example, taking "products with sales exceeding 1 million" as an example, syntactic analysis can identify that "sales exceeding 1 million" is an attributive modifying "products," thus clarifying the logical relationships between the various parts of the sentence and contributing to a more accurate understanding of the text's semantics.

[0049] 3) Semantic role labeling: This involves identifying the semantic roles of each component in a sentence, such as agent, patient, instrument, time, and place. For example, in the sentence "Find products with sales exceeding 1 million in the past month," "in the past month" is a time role, while "sales exceeding 1 million" is a descriptive role for "products." By annotating semantic roles, we can more clearly grasp the semantic information expressed in the sentence.

[0050] 4) Semantic understanding: This application utilizes a natural language processing model capable of capturing semantics within text to perform deep semantic understanding of the input text, capturing implicit information and contextual relationships. By applying the natural language processing model to data query text, this application can more accurately identify the core intent and key information of the user's query.

[0051] In this embodiment, after the semantic recognition operation described above, the original data query text is transformed into a semantic representation that is easier for computers to understand and process, namely, semantic query text. This semantic query text is no longer just a combination of characters, but contains rich semantic information and can accurately reflect the user's query intent and requirements. For example, the original query text "Find products with sales exceeding 1 million in the past month" may be presented in a structured form after semantic recognition, clearly indicating that the time range of the query is "within the past month", the query condition is "sales exceeding 1 million", the query target is "products", and this information is organized in a way that computers can understand and operate.

[0052] In the embodiments of this application, vector transformation operation refers to the process of mapping semantic query text to a vector space, so that each semantic query text corresponds to a unique vector representation.

[0053] Compared with existing technologies, this application first performs semantic recognition on the input data query text, transforming it into semantic query text containing rich semantic information; then it performs vector transformation on the semantic query text to obtain a fixed-dimensional semantic query vector, so that the computer can process and analyze semantic query information more efficiently.

[0054] In some optional implementations of the embodiments of this application, before the steps of reading the constructed vector database and indexing the candidate business table corresponding to the semantic query vector in the constructed vector database, the following steps are further included: Read the system database and retrieve the stored business data tables from the system database; Extract the key attributes from each business data table; Perform vector transformation on key attributes to obtain data table vectors corresponding to each business data table; Create an initialization vector database and store the data table vectors into the initialization vector database to obtain the constructed vector database.

[0055] In this embodiment of the application, the system database pre-stores business data tables related to the business. The system database can be a relational database, such as MySQL, Oracle, SQL Server, etc., or a non-relational database, such as MongoDB, etc.

[0056] In this embodiment of the application, each acquired business data table is analyzed in detail to extract key attributes. Key attributes are information that can represent the core content and characteristics of the business data table, including table identifier, field identifier, field type, field description, default value, primary key information, and mapping relationship between fields. At the same time, some representative sample records are selected as data samples.

[0057] In this embodiment, the same natural language processing model described above can be used to perform vector transformation on the extracted key attributes. In practical applications, taking the BERT model as an example, the extracted key attributes are concatenated and organized in text form to form a text format suitable for model input. For example, "Customer Information Table, Customer Number, Customer Name, Contact Information, Customer Level" can be used as input text. The input text is fed into the BERT model, which processes it through multiple layers of Transformer encoders to extract the semantic features of the text and finally outputs a fixed-dimensional vector, such as a 768-dimensional vector. This vector is the data table vector corresponding to the "Customer Information Table". The same operation is performed on each business data table in the database to obtain the data table vectors of all business data tables.

[0058] In this application embodiment, the application can create an initial vector database based on a vector database management system, such as Faiss (Facebook AI Similarity Search), Milvus, etc., to provide efficient vector storage and indexing functions and to quickly process large-scale vector data.

[0059] In this embodiment of the application, after the index is created, all the generated data table vectors are stored in the initialization vector database according to the specified storage format.

[0060] In the storage process of this application embodiment, vectors can be batch inserted as needed to improve storage efficiency. After the data table vectors are inserted into the database, the constructed vector database is obtained.

[0061] Compared with existing technologies, this application can efficiently and accurately convert business data tables in the system database into vector form and construct a well-structured and high-performance vector database, providing a solid foundation for subsequent semantic-based query operations. This solves the shortcomings of traditional database retrieval methods in semantic understanding and fuzzy query, and improves the efficiency and accuracy of data retrieval.

[0062] In some optional implementations of the embodiments of this application, the step of performing prompt word integration on the data query text based on the structured prompt word template to obtain the current query intent specifically includes the following steps: Perform text cleaning operations on the data query text to obtain a clear query text; Perform word segmentation and词性 annotation operations on the clear query text to obtain a词性 annotated text; Perform keyword extraction operations on the词性 annotated text to obtain query keywords; Obtain the business scenario corresponding to the data query text, and obtain the structured prompt word template corresponding to the business scenario; Perform placeholder matching operations between the query keywords and the placeholders of the structured prompt word template to obtain successfully matched query keywords; Replace the successfully matched query keywords to the corresponding placeholder positions of the structured prompt word template to obtain the current query intention.

[0063] In the embodiments of the present application, before performing prompt word integration operations, the present application needs to perform preprocessing operations on the data query text. Among them, the preprocessing operations include text cleaning, word segmentation and词性 annotation, and keyword extraction. Specifically: 1) Text cleaning: Remove irrelevant characters in the data query text, such as punctuation marks, special symbols, etc. For example, for the query text "Query: Apple, price < 10 yuan", after cleaning, it becomes "Query Apple price < 10 yuan"; 2) Word segmentation and词性 annotation: Use a word segmentation tool to perform word segmentation on the cleaned text and perform词性 annotation on each word. For example, after word segmentation of "Query Apple price < 10 yuan", it becomes "Query / v Apple / n price / n< / p10 / m yuan / q", where "v" represents a verb, "n" represents a noun, "p" represents a preposition, "m" represents a numeral, and "q" represents a measure word; 3) Keyword extraction: 4) According to the词性 annotation results and business knowledge, extract the keywords in the data query text. In the above example, the keywords are "Apple", "price", and "10 yuan".

[0064] In the embodiments of the present application, after performing preprocessing operations on the data query text, the present application needs to select a suitable template from a pre-constructed structured prompt word template library according to the business scenario involved in the data query text. As an example, for example, if the query text is about commodity price query, then select a prompt word template related to commodity query.

[0065] In this embodiment, after selecting a suitable template, the extracted keywords are matched with placeholders in the selected template. For example, in the product query template "Query [product name], category is [product category], price is between [price lower limit] and [price upper limit]", "apple" is matched to the placeholder "[product name]". "10 yuan" requires further analysis. If the query intent is a price less than 10 yuan, then 0 can be matched to "[price lower limit]" and 10 to "[price upper limit]" (this can be flexibly handled according to the actual situation, or a more suitable template logic can be redesigned).

[0066] In this embodiment of the application, the successfully matched keywords are replaced with the corresponding placeholder positions in the template to generate preliminary prompt word integration results. For example, replacing "apple" with "[product name]", "0" with "[price lower limit]", and "10" with "[price upper limit]" yields "Query apple, category is [product category], price is between 0 and 10 yuan".

[0067] In some optional implementations of this application's embodiments, for placeholders in the template that are optional but do not match keywords, default values ​​are added or reasonable inferences are made based on business rules and context information. If the product category is not mentioned in the query text and is optional, the default value "all categories" can be added, resulting in "Query apples, category is all categories, price is between 0 and 10 yuan".

[0068] Compared with existing technologies, this application can efficiently and accurately clean, analyze and process user-input data query text, and combine it with structured prompt word templates for business scenarios to quickly and accurately identify the user's query intent, thereby improving the quality and efficiency of data services.

[0069] In some optional implementations of the embodiments of this application, the step of performing a statement retrieval operation on the structured query statement in the system database to obtain the target retrieval result specifically includes the following steps: The system database performs an initial retrieval operation on the structured query statement to obtain initial retrieval results; Based on the initial search results, perform intent optimization operations on the current query intent to obtain the optimized query intent; Repeat the intent reasoning, initial retrieval, and intent optimization operations for the optimized query intent until the preset number of repetitions is met, and the target retrieval result is obtained.

[0070] In this embodiment, the system database performs an initial retrieval operation on the input structured query statement. The structured query statement typically has specific syntax and format to precisely express the user's query requirements, while the system database stores a large amount of data resources. By performing the retrieval operation, information related to the query statement can be initially filtered from this data. For example, suppose in an e-commerce platform's database, the user inputs a structured query statement of "finding laptops priced between 500-1000 yuan with a rating higher than 4 stars". The system database will retrieve laptop records that meet the price and rating criteria from the product information table based on this query statement, forming the initial retrieval results.

[0071] In this embodiment, the intent optimization operation can be achieved by analyzing the initial search results. The system can understand the user's initial feedback on the query, identify potential ambiguities, inaccuracies, or incompleteness in the query statement, and then adjust and optimize the query intent. As an example, continuing with the e-commerce platform example mentioned above, the initial search results might show that most laptops matching the price and rating criteria are thin and light laptops, while the user might actually prefer gaming laptops. By analyzing the product type distribution in the initial search results, the system identifies the user's potential needs and optimizes the query intent to "find gaming laptops priced between 500-1000 yuan with a rating higher than 4 stars."

[0072] In this embodiment, the optimized query intent is repeatedly subjected to intent reasoning, initial retrieval, and intent optimization operations until the number of repetitions meets the preset optimization count. This is a continuous iterative and improvement process. By repeatedly executing the three key steps of intent reasoning, initial retrieval, and intent optimization, the system can gradually gain a deeper understanding of the user's query intent, continuously optimize the retrieval strategy, and thus obtain better target retrieval results.

[0073] In this embodiment, the final search result obtained after multiple iterations of optimization is the target search result. It is obtained by fully considering the user's query intent, the characteristics of the system database, and feedback information from multiple iterations, and has high accuracy and relevance.

[0074] Compared with existing technologies, this application, through multiple iterations of optimization, can continuously adjust and improve query intent, gradually improve the quality of search results, and better adapt to complex and ever-changing user needs and database environments.

[0075] In some optional implementations of the embodiments of this application, the step of performing intent optimization operation on the current query intent based on the initial search results to obtain optimized query intent specifically includes the following steps: Obtain the data distribution attributes of the initial search results; Determine if the current query intent contains keywords that correspond to the data distribution attributes; When there are no keywords corresponding to the data distribution attributes, keyword expansion and simplification operations are performed on the initial detection results based on the data distribution attributes to obtain the optimized query intent.

[0076] In this embodiment of the application, the intent optimization operation may be carried out by viewing the quantity distribution of various types of data in the initial search results, and then expanding or simplifying the keywords in the query intent based on the analysis of the initial search results.

[0077] In practical applications, in a book retrieval system, when a user enters "recommended history books," the initial search results may include history books from different dynasties and on different topics. Analysis reveals that the number of books on ancient Chinese history is significantly higher than that on world history and other specific historical periods. This may suggest that the user is more interested in ancient history, or that their original query intent did not explicitly reflect a preference for ancient history. If certain relevant keywords in the initial search results are not included in the query intent, these keywords can be added to the query to broaden the search scope and obtain more relevant information. For example, if a user searches for "apple," the initial search results may include information related to Apple Inc.'s products in addition to the fruit apple. If the user actually wants the fruit apple, the query intent can be optimized to "fruit apple"; if the user is also interested in Apple Inc.'s products, the query intent can be expanded to "apple (fruit and Apple Inc. related)." Conversely, if the initial search results contain a large amount of irrelevant information, it may be because the keywords in the query intent are too broad. In this case, the keywords can be simplified to improve the accuracy of the search.

[0078] Compared with existing technologies, the optimized query intent obtained by this application after intent optimization more accurately reflects the user's actual needs, enabling the system to retrieve more relevant information from the database, reducing interference from irrelevant results, and thus improving the accuracy of search results.

[0079] In some optional implementations of the embodiments of this application, the step of performing intent optimization operation on the current query intent based on the initial search results to obtain optimized query intent specifically includes the following steps: Calculate the relevance score between the initial search results and the current query intent; Determine whether the relevance score meets the preset relevance threshold; If the preset relevance threshold is not met, the current query intent is semantically refined and clarified to obtain an optimized query intent.

[0080] In this embodiment of the application, the intent optimization operation may also be to evaluate the relevance between the initial search results and the user's query intent, and then refine and clarify the semantics of the query intent based on the relevance.

[0081] In this embodiment, the application may use relevance scoring algorithms, such as cosine similarity, to calculate the similarity score between the search results and the query intent. For results with low scores, the reasons for the mismatch with the query intent are analyzed, including keyword mismatch, semantic comprehension bias, or other factors. For example, if a user queries "sci-fi books suitable for children," the initial search results may contain a large number of highly specialized and complex science books. These results are clearly mismatched with the user's needs, possibly because the query intent does not clearly specify key information such as the age range and cognitive level corresponding to "children." In this embodiment of the application, when the initial search results show that the user's query intent is semantically ambiguous or unclear, it is necessary to further clarify the specific meaning of the query. For example, a user might query "large-scale events," a rather broad term. The initial search results could include various types of large-scale events, such as sporting events, cultural performances, and trade shows. By analyzing the initial search results, if it is found that the user is more interested in large-scale events like trade shows, then the query intent can be optimized to "large-scale trade shows."

[0082] Compared with existing technologies, the optimized query intent obtained by this application after intent optimization more accurately reflects the user's actual needs, enabling the system to retrieve more relevant information from the database, reducing interference from irrelevant results, and thus improving the accuracy of search results.

[0083] The embodiments of this application can acquire and process relevant data based on artificial intelligence technology. Artificial intelligence (AI) refers to the theories, methods, technologies, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to obtain optimal results.

[0084] Foundational technologies for artificial intelligence generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies mainly encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.

[0085] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by instructing related hardware through computer-readable instructions. These computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. The aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, optical disk, or read-only memory (ROM), or random access memory (RAM).

[0086] It should be understood that although the steps in the flowcharts of the accompanying figures are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the accompanying figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.

[0087] Further reference Figure 3 As a response to the above Figure 2 To implement the method shown, this application provides an embodiment of a data query device, which is similar to... Figure 2 Corresponding to the method embodiments shown, this device can be specifically applied to various electronic devices.

[0088] like Figure 3 As shown, the data query device 200 of this application embodiment includes: The data query text acquisition module 210 is used to acquire data query text. The semantic feature extraction module 220 is used to perform semantic feature extraction on the data query text according to the natural language processing model to obtain the semantic query vector. The candidate business table acquisition module 230 is used to read the constructed vector database and index the candidate business table corresponding to the semantic query vector in the constructed vector database; The prompt word integration module 240 is used to perform prompt word integration on the data query text based on the structured prompt word template to obtain the current query intent; The intent reasoning module 250 is used to input the candidate business table and the current query intent into the large language model for intent reasoning operations to obtain a structured query statement; The statement retrieval module 260 is used to read the system database and perform statement retrieval operations on the structured query statements in the system database to obtain the target retrieval results.

[0089] In this application embodiment, a data query device 200 is provided. Compared with the prior art, this application can automatically understand the semantics of the natural language data query text input by the user, accurately infer the user's query intent, and generate a structured query statement suitable for the system database, thereby achieving efficient and accurate data retrieval, reducing the query threshold for users, and improving query efficiency and accuracy.

[0090] In some optional implementations of the embodiments of this application, the semantic feature extraction module includes the following steps: The lexical analysis submodule is used to perform lexical analysis on the data query text to obtain the data query terms; The syntactic analysis submodule is used to perform syntactic analysis on data query terms to obtain the data query syntax. The semantic role labeling submodule is used to perform semantic role labeling on the data query syntax to obtain the data query roles; The semantic understanding submodule is used to perform semantic understanding operations on the data query role based on the natural language processing model to obtain the semantic query text. The vector transformation submodule is used to perform vector transformation operations on semantic query text to obtain semantic query vectors.

[0091] In some optional implementations of the embodiments of this application, the data query device 200 further includes: The business data table acquisition module is used to read the system database and retrieve the stored business data tables from the system database. The key attribute extraction module is used to extract key attributes from each business data table; The vector transformation module is used to perform vector transformation operations on key attributes to obtain data table vectors corresponding to each business data table. The vector database construction module is used to create an initial vector database and store data table vectors into the initial vector database to obtain the constructed vector database.

[0092] In some optional implementations of the embodiments of this application, the above-mentioned prompt word integration module includes the following steps: The text cleaning submodule is used to perform text cleaning operations on the data query text to obtain clear query text; The word segmentation and part-of-speech tagging submodule is used to perform word segmentation and part-of-speech tagging operations on clear query text to obtain part-of-speech tagged text. The keyword extraction submodule is used to extract keywords from part-of-speech tagged text to obtain query keywords. The prompt word template acquisition submodule is used to obtain the business scenario corresponding to the data query text and obtain the structured prompt word template corresponding to the business scenario; The placeholder matching submodule is used to perform placeholder matching operations between query keywords and placeholders in the structured prompt word template to obtain successfully matched query keywords; The placeholder replacement submodule is used to replace the successfully matched query keywords with the corresponding placeholder positions in the structured prompt word template to obtain the current query intent.

[0093] In some optional implementations of the embodiments of this application, the above-mentioned statement retrieval module includes the following steps: The initial retrieval submodule is used to perform initial retrieval operations on structured query statements in the system database and obtain initial retrieval results; The intent optimization submodule is used to perform intent optimization operations on the current query intent based on the initial search results, so as to obtain an optimized query intent. The iterative repetition submodule is used to repeatedly perform intent reasoning, initial retrieval, and intent optimization operations on the optimized query intent until the number of repetitions meets the preset number of optimizations, and then obtain the target retrieval result.

[0094] In some optional implementations of the embodiments of this application, the above-mentioned intention to optimize the submodule includes the following steps: The data distribution acquisition submodule is used to obtain the data distribution attributes of the initial search results; The keyword judgment submodule is used to determine whether the current query intent contains keywords that correspond to the data distribution attributes; The keyword expansion and simplification submodule is used to expand and simplify the initial detection results based on the data distribution attributes when no keywords corresponding to the data distribution attributes exist, thereby obtaining an optimized query intent.

[0095] In some optional implementations of the embodiments of this application, the step of performing intent optimization operation on the current query intent based on the initial search results to obtain optimized query intent specifically includes the following steps: The relevance score calculation submodule is used to calculate the relevance score between the initial search results and the current query intent; The relevance score determination submodule is used to determine whether the relevance score meets the preset relevance threshold. The semantic refinement and clarification submodule is used to refine and clarify the semantic intent of the current query intent when the preset relevance threshold is not met, so as to obtain an optimized query intent.

[0096] To address the aforementioned technical problems, embodiments of this application also provide a computer device. Please refer to [link / reference needed]. Figure 4 , Figure 4 This is a basic structural block diagram of a computer device according to an embodiment of this application.

[0097] Computer device 300 includes a memory 310, a processor 320, and a network interface 330 that are interconnected via a system bus. It should be noted that only computer device 300 with components 310-330 is shown in the figure; however, it should be understood that it is not required to implement all the shown components, and more or fewer components can be implemented alternatively. Those skilled in the art will understand that the computer device described here is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0098] Computer devices can include desktop computers, laptops, handheld computers, and cloud servers. These devices allow for human-computer interaction with users through keyboards, mice, remote controls, touchpads, or voice-activated devices.

[0099] The memory 310 includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 310 may be an internal storage unit of the computer device 300, such as the hard disk or memory of the computer device 300. In other embodiments, the memory 310 may also be an external storage device of the computer device 300, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc. Of course, the memory 310 may include both internal storage units and external storage devices of the computer device 300. In the embodiments of this application, the memory 310 is typically used to store the operating system and various application software installed on the computer device 300, such as computer-readable instructions for data query methods. In addition, the memory 310 can also be used to temporarily store various types of data that have been output or will be output.

[0100] In some embodiments, processor 320 may be a central processing unit (CPU), controller, microcontroller, microprocessor, or other data processing chip. Processor 320 is typically used to control the overall operation of computer device 300. In embodiments of this application, processor 320 is used to execute computer-readable instructions stored in memory 310 or to process data, such as computer-readable instructions for executing data query methods.

[0101] The network interface 330 may include a wireless network interface or a wired network interface, which is typically used to establish a communication connection between the computer device 300 and other electronic devices.

[0102] The computer equipment provided in this application can automatically understand the semantics of natural language data query text input by the user, accurately infer the user's query intent, and generate structured query statements suitable for the system database, thereby achieving efficient and accurate data retrieval, reducing the query threshold for users, and improving query efficiency and accuracy.

[0103] This application also provides another embodiment, namely, providing a computer-readable storage medium storing computer-readable instructions that can be executed by at least one processor to cause the at least one processor to perform the steps of the data query method described above.

[0104] The computer-readable storage medium provided in this application can automatically understand the semantics of natural language data query text input by the user, accurately infer the user's query intent, and generate structured query statements suitable for the system database, thereby achieving efficient and accurate data retrieval, reducing the user's query threshold, and improving query efficiency and accuracy.

[0105] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods of the various embodiments of this application.

[0106] Obviously, the embodiments described above are only some embodiments of this application, not all embodiments. The accompanying drawings show preferred embodiments of this application, but do not limit the patent scope of this application. This application can be implemented in many different forms; rather, the purpose of providing these embodiments is to provide a more thorough and comprehensive understanding of the disclosure of this application. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing specific embodiments, or make equivalent substitutions for some of the technical features. Any equivalent structures made using the content of this application's specification and drawings, directly or indirectly applied to other related technical fields, are similarly within the scope of patent protection of this application.

Claims

1. A data query method, characterized in that, Includes the following steps: Retrieve data query text; The semantic feature extraction operation is performed on the data query text according to the natural language processing model to obtain the semantic query vector; Read the constructed vector database and index the candidate business table corresponding to the semantic query vector in the constructed vector database; The data query text is integrated with the structured prompt word template to obtain the current query intent; The candidate business table and the current query intent are input into the large language model for intent reasoning to obtain a structured query statement; The system database is read, and the structured query statement is retrieved in the system database to obtain the target retrieval result.

2. The data query method according to claim 1, characterized in that, The step of extracting semantic features from the data query text using a natural language processing model to obtain a semantic query vector specifically includes the following steps: Perform lexical analysis on the data query text to obtain the data query terms; Perform syntactic analysis on the data query terms to obtain the data query syntax; Semantic role labeling is performed on the data query syntax to obtain data query roles; The semantic understanding operation is performed on the data query role according to the natural language processing model to obtain the semantic query text; The semantic query text is transformed into a vector to obtain the semantic query vector.

3. The data query method according to claim 1, characterized in that, Before the steps of reading the constructed vector database and indexing the candidate business table corresponding to the semantic query vector in the constructed vector database, the following steps are also included: Read the system database and retrieve the stored business data table from the system database; Extract the key attributes of each of the aforementioned business data tables; Perform vector transformation on the key attributes to obtain a data table vector corresponding to each of the business data tables; An initialization vector database is created, and the data table vectors are stored in the initialization vector database to obtain the constructed vector database.

4. The data query method according to claim 1, characterized in that, The step of integrating prompts into the data query text based on the structured prompt template to obtain the current query intent specifically includes the following steps: The data query text is cleaned to obtain a clear query text; The clear query text is segmented and tagged with parts of speech to obtain tagged text. The part-of-speech-tagged text is subjected to keyword extraction to obtain the query keywords; Obtain the business scenario corresponding to the data query text, and obtain the structured prompt word template corresponding to the business scenario; The query keywords are matched with the placeholders in the structured prompt template to obtain the successfully matched query keywords. The successfully matched query keywords are replaced with the corresponding placeholders in the structured prompt template to obtain the current query intent.

5. The data query method according to claim 1, characterized in that, The step of performing a statement retrieval operation on the structured query statement in the system database to obtain the target retrieval result specifically includes the following steps: An initial retrieval operation is performed on the structured query statement in the system database to obtain initial retrieval results; Based on the initial search results, perform intent optimization operations on the current query intent to obtain an optimized query intent; The intent reasoning, initial retrieval, and intent optimization operations are repeatedly performed on the optimized query intent until the number of repetitions meets the preset number of optimizations, and the target retrieval result is obtained.

6. The data query method according to claim 5, characterized in that, The step of performing intent optimization operation on the current query intent based on the initial search results to obtain an optimized query intent specifically includes the following steps: Obtain the data distribution attributes of the initial search results; Determine whether the current query intent contains keywords corresponding to the data distribution attributes; When no keyword corresponding to the data distribution attribute exists, the keyword expansion and simplification operations are performed on the initial detection result based on the data distribution attribute to obtain the optimized query intent.

7. The data query method according to claim 5, characterized in that, The step of performing intent optimization operation on the current query intent based on the initial search results to obtain an optimized query intent specifically includes the following steps: Calculate the relevance score between the initial search results and the current query intent; Determine whether the relevance score meets a preset relevance threshold; If the preset relevance threshold is not met, the current query intent is semantically refined and clarified to obtain the optimized query intent.

8. A data query device, characterized in that, include: The data query text acquisition module is used to acquire data query text; The semantic feature extraction module is used to perform semantic feature extraction on the data query text according to the natural language processing model to obtain a semantic query vector. The candidate business table acquisition module is used to read the constructed vector database and index the candidate business table corresponding to the semantic query vector in the constructed vector database; The prompt word integration module is used to perform prompt word integration on the data query text based on the structured prompt word template to obtain the current query intent; The intent reasoning module is used to input the candidate business table and the current query intent into the large language model to perform intent reasoning operations and obtain a structured query statement; The statement retrieval module is used to read the system database and perform statement retrieval operations on the structured query statement in the system database to obtain the target retrieval results.

9. A computer device, comprising a memory and a processor, characterized in that, The memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, it implements the steps of the data query method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the data query method as described in any one of claims 1 to 7.