Retrieval method, device and readable storage medium based on hybrid vector model

Through the retrieval method of the hybrid vector model, natural language queries are processed to generate query vectors, candidate results are recalled and screened, SQL is generated and natural language answers are output. This solves the problems of inaccurate retrieval and unexplainable results in the existing technology, and achieves efficient automation and robustness.

CN120508573BActive Publication Date: 2025-09-19XUNTU TECH (SHANGHAI) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511000971.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-21
Publication Date
2025-09-19
Estimated Expiration
2045-07-21

AI Technical Summary

Technical Problem

In existing technologies, end-to-end SQL generation using pure large models is prone to knowledge illusions and query errors due to insufficient understanding of indicator details. Traditional search enhancement generation relies on static documents, making it difficult to synchronize indicator updates in real time. Fixed rule templates have weak generalization capabilities and cannot cover diverse questions, resulting in low retrieval accuracy, poor SQL generation reliability, and unexplainable results.

Method used

A retrieval method based on a hybrid vector model is adopted. Query vectors are generated by processing natural language queries. Candidate results are recalled from the indicator library based on the query vectors. A large language model is combined for screening and SQL generation. A reflection mechanism is introduced to ensure robustness. Natural language answers and explanations of the results are output.

Benefits of technology

It improves retrieval accuracy, reduces model reasoning complexity, ensures the interpretability and compliance of output, and achieves efficient automation of complex queries.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120508573B_ABST
    Figure CN120508573B_ABST
Patent Text Reader

Abstract

The present invention discloses a retrieval method, device, and readable storage medium based on a hybrid vector model, relating to the field of artificial intelligence. The method comprises: first responding to a natural language query and processing to generate a query vector; recalling candidate results from an indicator library based on the query vector and screening to obtain a refined set of relevant information; generating and executing SQL based on the refined information set to obtain result data and generate a natural language answer; and outputting the answer and an explanation of the basis for the result. The present invention improves retrieval accuracy through hybrid vector recall, reduces model inference complexity through multi-stage processing, and ensures robustness through a reflection mechanism. The interpretable output meets compliance requirements, effectively resolving issues such as inaccurate retrieval, unreliable generation, and uninterpretable results, thereby achieving efficient automation of complex Text2SQL queries.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence, and in particular to a retrieval method, device and readable storage medium based on a hybrid vector model. Background Art

[0002] Existing technologies, using purely large models to generate SQL end-to-end can easily lead to knowledge illusions due to insufficient understanding of metric details, resulting in query errors. Traditional search-enhanced generation relies on static documents, making it difficult to synchronize metric updates in real time. Furthermore, fixed rule templates have weak generalization capabilities and cannot cover diverse queries. Existing methods suffer from low retrieval accuracy, poor SQL generation reliability, and uninterpretable results, making them difficult to meet complex query requirements. Summary of the Invention

[0003] The object of the present invention is to provide a retrieval method, device and readable storage medium based on a hybrid vector model.

[0004] In a first aspect, an embodiment of the present invention provides a retrieval method based on a hybrid vector model, comprising:

[0005] In response to a natural language query input by a user, processing the natural language query to generate a query vector;

[0006] Recalling candidate results from an indicator library based on the query vector, screening the candidate results, and obtaining a refined relevant information set;

[0007] Generate and execute SQL query statements based on the refined relevant information set, obtain query result data and generate natural language answers;

[0008] Output the natural language answer and the explanation of the result.

[0009] In a possible implementation, processing the natural language query to generate a query vector includes:

[0010] Perform word segmentation and intent recognition on the natural language query to extract key indicator names, filtering conditions, and general terms;

[0011] Performing alias replacement and semantic expansion on the key indicator names and general terms based on financial domain knowledge to obtain expanded query elements;

[0012] A pre-trained financial domain word vector model and a large language model are used to perform vectorization processing, and the expanded query elements are converted into the query vectors.

[0013] In a possible implementation, recalling candidate results from an indicator library based on the query vector includes:

[0014] Using the original query recall channel, perform a top-N similarity search in the vector index using the query vector to obtain a first candidate subset;

[0015] Performing semantic expansion on the natural language query to generate a derived query vector through a query expansion and recall channel, and performing a top-N similarity search in the vector index using the derived query vector to obtain a second candidate subset;

[0016] Performing top M precision recalls using the query vector from a predefined set of important indicators through a key indicator enhancement channel to obtain a third candidate subset, wherein M is less than N;

[0017] For complex queries, the natural language query is split into multiple feature dimensions, feature vectors are generated for each dimension, and vector retrieval is performed to obtain a fourth candidate subset;

[0018] The first candidate subset, the second candidate subset, the third candidate subset and the fourth candidate subset are integrated to obtain the candidate result.

[0019] In a possible implementation, screening the candidate results includes:

[0020] Expert prompts are input into the large language model to guide the large language model to select the indicator names and table names most relevant to the natural language query from the candidate results; the expert prompts include financial domain knowledge, project context and screening rules, and the large language model combines semantic understanding and financial common sense to score the relevance of the candidate results, eliminate irrelevant items, and output the refined relevant information set.

[0021] In a possible implementation, generating and executing an SQL query statement based on the refined relevant information set, obtaining query result data, and generating a natural language answer includes:

[0022] Based on the indicator names, table names and filtering conditions in the refined relevant information set, combined with financial professional prompt words, the large language model is guided to generate SQL query statements that conform to the database syntax;

[0023] Executing the SQL query statement on the enterprise database to obtain the query result data;

[0024] The natural language answer is generated by combining the query result data and financial expertise, and the natural language answer includes the result value and the corresponding indicator description.

[0025] In a possible implementation, after obtaining the query result data and generating a natural language answer, the method further includes:

[0026] If the SQL query statement fails to execute, returns an empty result, contradicts known common sense, or the confidence level of the generated result is insufficient, the reflection mechanism is triggered;

[0027] If it is determined that there is an omission or an incorrect match in the retrieval stage, the retrieval strategy is adjusted or the query conditions are expanded, and the steps of recalling candidate results from the index library based on the query vector and screening the candidate results are re-executed;

[0028] If it is determined that the query parsing is ambiguous or the user intention is misunderstood, the processing result of the query parsing and expansion module is modified and the query vector is regenerated.

[0029] In one possible implementation, outputting the natural language answer and the result basis description includes:

[0030] Desensitizing sensitive information contained in the query result data;

[0031] Output the natural language answer and attach a description of the result basis, which includes the name of the indicator involved, the data year, the SQL query fragment and the statistical caliber description.

[0032] In a second aspect, an embodiment of the present invention provides a retrieval device based on a hybrid vector model, comprising:

[0033] an acquisition module configured to process a natural language query input by a user to generate a query vector; retrieve candidate results from an indicator library based on the query vector, and screen the candidate results to obtain a refined relevant information set;

[0034] The retrieval module is used to generate and execute SQL query statements based on the refined relevant information set, obtain query result data and generate natural language answers; and output the natural language answers and result basis descriptions.

[0035] In a third aspect, an embodiment of the present invention provides a computer device, comprising a processor and a non-volatile memory storing computer instructions, wherein when the computer instructions are executed by the processor, the computer device executes the method described in the first aspect.

[0036] In a fourth aspect, the present invention is implemented to provide a readable storage medium, which includes a computer program. When the computer program is executed, it controls the computer device where the readable storage medium is located to execute the method described in the first aspect.

[0037] Compared to existing technologies, the present invention offers the following advantages: Using the disclosed hybrid vector model-based retrieval method, device, and readable storage medium, the present invention generates a query vector in response to a natural language query; recalls candidate results from an indicator database based on the query vector and filters them to obtain a refined set of relevant information; generates and executes SQL based on the refined information set, obtaining result data and generating a natural language answer; and outputs the answer and an explanation of the answer's basis. This invention improves retrieval accuracy through hybrid vector recall, reduces model inference complexity through multi-stage processing, and incorporates a reflection mechanism to ensure robustness. The interpretable output meets compliance requirements, effectively addressing issues such as inaccurate retrieval, unreliable generation, and uninterpretable results, achieving efficient automation of complex Text2SQL queries. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly describes the drawings required for use in the embodiments. It should be understood that the following drawings illustrate only certain embodiments of the present invention and should not be construed as limiting the scope of the present invention. Those skilled in the art can, without inventive effort, derive other relevant drawings from these drawings.

[0039] Figure 1 A schematic flow chart of the steps of a retrieval method based on a hybrid vector model provided in an embodiment of the present invention;

[0040] Figure 2 A schematic block diagram of the structure of a retrieval device based on a hybrid vector model provided in an embodiment of the present invention;

[0041] Figure 3 A schematic block diagram of the structure of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0042] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings of the embodiments of the present invention. It should be understood that the described embodiments are only a portion of the embodiments of the present invention, not all of them. Generally, the components of the embodiments of the present invention described and illustrated in the drawings herein may be arranged and designed in a variety of different configurations.

[0043] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0044] In order to solve the technical problems in the above background technology, Figure 1 This is a flow chart of a retrieval method based on a hybrid vector model provided in an embodiment of the present disclosure. The retrieval method based on a hybrid vector model is introduced in detail below.

[0045] Step S201, in response to a natural language query input by a user, processing the natural language query to generate a query vector;

[0046] Step S202: recall candidate results from the index library based on the query vector, and screen the candidate results to obtain a refined relevant information set;

[0047] Step S203, generating and executing an SQL query statement based on the refined relevant information set, obtaining query result data and generating a natural language answer;

[0048] Step S204: output the natural language answer and the explanation of the result.

[0049] In an embodiment of the present invention, for example, after receiving a natural language query input by a user, the server first enters the query parsing and expansion module to convert the unstructured query into a structured vector representation through semantic analysis and preprocessing. The specific process is as follows:

[0050] A user enters the query "Please analyze the market share of the top three smart wearable brands over the past three years" through the client interface. The server first performs word segmentation on the query, using consumer electronics word segmentation tools (such as a customized BERT-based model) to break the text into core terms such as "smart wearable," "top three," "over the past three years," and "market share." The server then uses an intent recognition model to determine that the user's intent is an "indicator analysis query." The server then retrieves market share data for relevant companies from the database and performs trend analysis.

[0051] The server then uses domain knowledge-driven semantic expansion to extract key elements. "Smart wearables" is expanded to include three categories: "smartwatches, fitness trackers, and sports headphones," based on a consumer electronics industry terminology database. "Top three" is mapped to "Company A, Company B, and Company C" using a company directory. "Market share" is linked to the predefined formula "Market share = Company shipments / Industry total shipments × 100%." ​​Related indicators such as "shipments," "sales," and "industry total shipments" are also added. The expanded element set becomes {smartwatches, fitness trackers, sports headphones, Company A, Company B, Company C, market share, shipments, sales, and industry total shipments}.

[0052] The server then combines the original query and the expanded elements into a composite text: "Query: smartwatch, health band, sports earphones, company A, company B, company C, top three smart wearables, market share, shipments, sales, industry total shipments." The query is then encoded into a 1024-dimensional query vector using a pre-trained consumer electronics domain vector model (e.g., an industry word vector model fine-tuned with RoBERTa). This vector incorporates not only literal semantics but also deeper semantic information, such as the hierarchical relationship between concepts like "smart wearable" and "smartwatch," and the calculation logic for "market share," providing a precise semantic matching foundation for subsequent searches.

[0053] The server obtains candidate results from the indicator library through a hybrid multi-way vector recall mechanism and filters them through a large model to obtain a refined set of relevant information. The specific process is as follows:

[0054] Multi-way vector recall phase: The server simultaneously inputs the generated query vector into three parallel recall channels:

[0055] The original query recall channel directly uses the original query vector to perform a top-100 similarity search in the Faiss vector index. This index is built on a vector library containing millions of consumer electronics metrics, each pre-encoded into a vector using the same industry-specific word embedding model. This channel ensures that metrics that directly match the user's query are retrieved, such as "Company B's smartwatch shipments (monthly)" or "Total sales of the smart wearable industry (annual)."

[0056] Expanded query recall channel: This channel performs semantic derivation on the original query vector, generating sub-vectors such as "Query+smartwatch," "Query+Company A," and "Query+market share calculation formula," and performs top-100 searches on each. For example, the "Query+health band" vector can retrieve highly relevant metrics such as "Company A's health band shipments (quarterly)" and "Average unit price of health bands in the health band industry," mitigating matching errors caused by abbreviations or aliases in user queries.

[0057] Key indicator enhancement channel: Use the original query vector to perform top-50 precise matching from a predefined set of core indicators (such as "brand shipment volume" and "industry concentration"), ensuring that high-frequency core indicators such as "market share (%)" and "enterprise shipment volume (10,000 units)" are prioritized to avoid being overwhelmed by long-tail indicators.

[0058] After deduplication and fusion, the three-way recall results form a set of 200-300 candidate indicators, covering direct matching indicators, semantically related indicators and core business indicators.

[0059] During the large-scale model filtering phase, the server inputs a set of candidate indicators into a large-scale model (such as GPT-4 Turbo) and guides it through relevance screening using expert prompts. The prompts are designed as follows: "You are an expert in consumer electronics data analysis. From the candidate list, select the most relevant indicator and table name for 'Market Share of the Top Three Smart Wearable Companies in the Past Three Years.' Ignore irrelevant entries and explain the reasons for retaining them. Selection criteria: 1. The indicator must include any of 'Company A / Company B / Company C'; 2. The timeframe must cover the past three years; 3. The data dimension must include 'Shipments' or 'Sales'; 4. It must be linked to 'Smart Wearable Industry Total' data." The large-scale model scores candidate indicators based on industry common sense and contextual semantics. For example, "Company C's 2021 Sports Headphones Shipments" is retained because it includes the company name and shipment data; "Global Wearable Device Export Value" is eliminated because it does not limit it to the smart wearable category; and "Company B's 2023 R&D Investment" is filtered out because it is irrelevant to the market share calculation. The final output is a refined related information set, including 15 core indicators, such as "Company A's smart wearable shipments (2021-2023, quarterly)", "Company B's health bracelet sales (2021-2023, annual)", "Total shipments of the smart wearable industry (2021-2023, annual)", etc., and attached with the data table name (such as "brand_shipment", "industry_summary") and the reason for the screening.

[0060] Based on the refined relevant information set, the server generates SQL queries through the large-scale Oracle module, executes them, and generates natural language answers. At the same time, a reflection mechanism is introduced to ensure accuracy. The specific process is as follows:

[0061] SQL generation and execution: The server inputs the refined information set (indicator name, table name, time range) into the large model Oracle module and provides a structured prompt: "Generate an enterprise-level relational database-compatible SQL query based on the following information: 1. Obtain the quarterly smart wearable shipments of Company A, Company B, and Company C from 2021 to 2023 from the brand_shipment table; 2. Obtain the total smart wearable industry shipments for the same period from the industry_summary table; 3. Calculate each company's market share (company shipments / industry total shipments × 100%); 4. Group by company and year, retaining two decimal places." The large model combines the electronic consumption indicator calculation logic with SQL syntax rules to generate the following query statement:

[0062] {SELECT

[0063] t1.brand_name,

[0064] t1.year,

[0065] ROUND((t1.quarterly_shipment / t2.annual_total)*100,2)ASmarket_share_pct FROM

[0066] brand_shipment t1 JOIN

[0067] industry_summary t2 ON

[0068] t1.year = t2.year WHERE

[0069] t1.brand_name IN ('Company A', 'Company B', 'Company C')

[0070] AND t1.product_type IN ('Smart Watch', 'Health Bracelet', 'Sports Headphones')

[0071] AND t1.year BETWEEN 2021 AND 2023;}

[0072] The server submits the SQL to the enterprise-level relational database for execution and obtains the return results: structured data including the market share of Company A, Company B, and Company C in each quarter from 2021 to 2023 (such as "Company A's market share in Q1 2021 is 11.25%").

[0073] Natural language generation and reflection mechanism: The large model Oracle module generates natural language answers based on execution results: "The market share of the top three smart wearable manufacturers in the past three years is as follows: Company A's market share in 2021-2023 was 11.25%, 12.10%, and 12.85%, respectively, showing an upward trend year by year; Company B's market share was 14.20%, 13.80%, and 13.50%, respectively, showing a slight decline; Company C's market share was 9.50%, 8.80%, and 8.20%, respectively, showing a continued decline. The industry's total shipments will increase from 120 million units in 2021 to 150 million units in 2023."

[0074] If SQL execution fails (for example, due to a syntax error or table structure change), the server triggers a reflection mechanism: Assuming a syntax error occurs in the generated SQL, such as "using a SELECT alias in the HAVING clause," the system automatically analyzes the error log and identifies the cause as "the database does not support referencing a SELECT alias in the HAVING clause." It then adjusts the SQL generation logic, replacing the alias with the original field calculation (for example, "ROUND ((t1.quarterly_shipment / t2.annual_total) * 100, 2)" is written directly into the HAVING clause), regenerates, and executes the SQL until the result is successfully returned.

[0075] When outputting the final results, the server strictly adheres to the compliance requirements of the consumer electronics industry to ensure security and explainability:

[0076] The natural language answers present annual market share data for the three companies in tabular format, along with trend analysis. The explanation of the results includes the following: 1. Data Source: Metrics are clearly labeled from the "brand_shipment" table (brand shipments) and the "industry_summary" table (industry summary); 2. Calculation Principle: The market share calculation formula is "Company's smart wearable shipments / Industry's total smart wearable shipments × 100%." ​​"Smart wearables" includes smartwatches, fitness trackers, and sports headphones. 3. SQL Snippets: Key parts of the simplified query (such as JOIN conditions and WHERE clauses) are provided to facilitate user tracing of data extraction logic. 4. Desensitization: For internal, undisclosed monthly data, only quarterly aggregate results are displayed to prevent the disclosure of sensitive information.

[0077] Finally, the server integrates the above content into an HTML page and returns it to the user through the client, completing the entire closed loop from natural language query to interpretable results.

[0078] In the embodiment of the present invention, the processing of the natural language query to generate a query vector may be implemented through the following example.

[0079] Perform word segmentation and intent recognition on the natural language query to extract key indicator names, filtering conditions, and general terms;

[0080] Performing alias replacement and semantic expansion on the key indicator names and general terms based on financial domain knowledge to obtain expanded query elements;

[0081] A pre-trained financial domain word vector model and a large language model are used to perform vectorization processing to convert the expanded query elements into the query vectors.

[0082] In an embodiment of the present invention, for example, upon receiving a user's natural language query "Analyze the R&D investment percentage of leading new energy vehicle manufacturers over the past three years," the server first initiates a text preprocessing process. The server then uses a financial domain word segmentation model based on the Transformer architecture to perform word segmentation on the query, breaking the continuous text sequence into independent semantic units such as "analysis," "new energy vehicles," "leading manufacturers," "over the past three years," and "R&D investment percentage." Part-of-speech tagging determines the grammatical role of each unit, with "R&D investment percentage" being labeled as a noun phrase and "over the past three years" as a temporal adverbial. Next, the intent recognition module uses a deep learning model to contextualize the word segmentation results and determines that the user's core intent is "indicator analysis," specifically requesting data on the R&D investment percentage of a specific object within a specific timeframe and its changes. In the key element extraction phase, the server utilizes named entity recognition (NER) technology combined with a financial domain dictionary to accurately extract the key indicator name "R&D investment percentage," the time filter "over the past three years," the industry term "new energy vehicles," and the company term "leading manufacturers" from the word segmentation results, forming a preliminary set of structured elements.

[0083] Based on the extracted key elements, the server uses the financial domain knowledge graph to perform semantic expansion and standardization. For the key indicator name "R&D investment ratio," the server queries the indicator mapping library, standardizes it to "R&D expenses as a percentage of operating revenue," and adds the calculation formula for this indicator: "R&D expenses / operating revenue × 100%." ​​It also associates related basic indicators such as "absolute value of R&D expenses" and "total operating revenue." For the industry umbrella term "new energy vehicles," the server uses the industry classification system to perform hierarchical expansion, breaking it down into three subcategories: "pure electric vehicles," "plug-in hybrid electric vehicles," and "fuel cell vehicles," and associates the corresponding industry codes and statistical caliber descriptions. For the enterprise umbrella term "leading manufacturers," the server uses a pre-set enterprise filtering rule library to convert it into quantifiable filtering criteria, namely, "top five companies by market share" or "companies with annual operating revenue exceeding 50 billion yuan," and associates relevant tags from the enterprise directory database. After this alias replacement and semantic expansion, the original query is expanded into a multidimensional query element set consisting of standardized indicators, sub-industries, quantitative enterprise filtering criteria, and associated indicators.

[0084] After expanding and standardizing the query elements, the server uses a hybrid vectorization strategy to convert the textual query elements into vector representations. First, the server encodes the expanded structured terms using a pre-trained word vector model from the financial domain. For example, terms like "R&D expenses as a percentage of operating income," "pure electric vehicles," and "market share" are converted into 300-dimensional word vectors, which reflect the strength of the semantic associations between the terms in the financial context. The server then concatenates all expanded query elements into a unified text sequence: "Query: New energy vehicles, pure electric vehicles, plug-in hybrid vehicles, fuel cell vehicles, leading manufacturers, market share, top five, R&D investment ratio, R&D expenses as a percentage of operating income, R&D expenses, operating income over the past three years." This text sequence is then fed into a large language model (LLM) fine-tuned with financial corpus data. Using the model's last hidden state, the server extracts a 768-dimensional contextual semantic vector corresponding to the [CLS] position. This vector integrates the contextual information of the entire query and the relationships between elements. Finally, the server performs a weighted fusion of the word vector and the contextual semantic vector, dynamically adjusts the weights of each part through the attention mechanism, and generates a final 1024-dimensional query vector. This vector not only retains the precise semantics of the key terms, but also integrates the overall contextual information of the query, providing a precise semantic representation basis for subsequent vector retrieval.

[0085] In the embodiment of the present invention, recalling candidate results from the indicator library based on the query vector can be implemented through the following examples.

[0086] Using the original query recall channel, perform a top-N similarity search in the vector index using the query vector to obtain a first candidate subset;

[0087] Performing semantic expansion on the natural language query to generate a derived query vector through a query expansion and recall channel, and performing a top-N similarity search in the vector index using the derived query vector to obtain a second candidate subset;

[0088] Performing top M precision recalls using the query vector from a predefined set of important indicators through a key indicator enhancement channel to obtain a third candidate subset, wherein M is less than N;

[0089] For complex queries, the natural language query is split into multiple feature dimensions, feature vectors are generated for each dimension, and vector retrieval is performed to obtain a fourth candidate subset;

[0090] The first candidate subset, the second candidate subset, the third candidate subset and the fourth candidate subset are integrated to obtain the candidate result.

[0091] In this embodiment of the present invention, for example, after generating a query vector for "Analyze the R&D investment share of leading new energy vehicle manufacturers over the past three years," the server initiates a multi-channel recall mechanism to retrieve candidate results from a metric library. This metric library contains tens of millions of standardized metrics for the consumer electronics sector. Each metric is encoded into a 1024-dimensional vector using a financial domain word embedding model. A Faiss hybrid index (IVF-Flat + SQ8) is then constructed to support efficient approximate nearest neighbor retrieval.

[0092] In the original query recall channel, the server directly inputs the 1024-dimensional query vector into the vector index and performs a top-200 similarity search. During the search, the vector index uses an inverted index file (IVF) to assign the query vector to the 1024 most similar cluster centers. Within each cluster center, the similarity with the index vector is calculated using Euclidean distance, and the top 200 most similar metrics are returned. This channel focuses on metrics that directly match the original query, such as "R&D expenses as a percentage of operating revenue of leading new energy vehicle manufacturers (quarterly)," "Total R&D investment of leading manufacturers in the past three years (annual)," and "Average R&D expenses of the new energy vehicle industry (quarterly)." This forms the first candidate subset, which includes 120 enterprise-level metrics and 80 industry-level metrics.

[0093] In the query expansion and recall channel, the server generates derived query vectors based on the semantically expanded query elements. Specifically, it extracts three core derived directions from the expanded element set: "Ratio of pure electric vehicle R&D investment," "R&D expenses of plug-in hybrid vehicles," and "R&D intensity of the top five manufacturers by market share." The elements in each direction are concatenated into independent text (e.g., "R&D investment percentage of pure electric vehicles over the past three years"). Three derived query vectors are generated using the same hybrid vectorization strategy as the original query vector. Each derived vector is independently subjected to a top-150 similarity search, and duplicates are removed to produce a second candidate subset. For example, the derived vector for "R&D investment percentage of pure electric vehicle manufacturer A (quarterly)" and "R&D expense rate of the pure electric vehicle industry (annual)" are recalled. The derived vector for "R&D expenses of plug-in hybrid vehicles by leading manufacturers (quarterly)" and "Number of plug-in hybrid vehicle R&D personnel (annual)" are recalled. The final second candidate subset contains 280 indicators, covering subcategories and related dimensions.

[0094] In the key indicator enhancement channel, the server calls a predefined set of key indicators for the consumer electronics sector. This set includes 1,000 core indicators annotated by industry experts (such as "R&D expense ratio," "total operating revenue," and "market share"). Each indicator is assigned a weight (1-5 points). The server performs an exact cosine similarity calculation between the original query vector and the vectors in the key indicator set, selecting the top 50 indicators with a similarity greater than 0.85 and a weight ≥ 4 points to form the third candidate subset. For example, "R&D expense ratio to operating revenue (standardized indicator)" is prioritized due to its 0.92 similarity to the query vector and a weight of 5 points. "Compound growth rate of R&D investment of leading enterprises" is included due to its weight of 4 points and a correlation of 0.87, ensuring that no core business indicators are overlooked.

[0095] In the complex query splitting channel, the server recognizes that the query contains four feature dimensions: "Industry (New Energy Vehicles)", "Company (Top Manufacturers)", "Indicator (R&D Investment Percentage)", and "Time (Last Three Years)". Using semantic role annotation, the natural language query is split into four independent feature phrases. A feature vector is generated for each feature phrase: the "New Energy Vehicles" feature vector is generated using industry classification tree encoding, focusing on industry attributes; the "Top Manufacturers" feature vector associates company size and market position labels; the "R&D Investment Percentage" feature vector reinforces the semantics of the indicator calculation formula; and the "Last Three Years" feature vector binds time granularity (quarterly / annual) information. For each feature vector, a top-100 search is performed in the vector index, resulting in a fourth candidate subset containing industry-specific indicators, company-specific indicators, indicator-specific indicators, and time-specific indicators. Examples include "Time Series of R&D Expenditure in the New Energy Vehicle Industry (2021-2023)" and "Correlation Indicator between Size and R&D Investment of Top Manufacturers," totaling 320 indicators.

[0096] Finally, the server performs a fusion process on the four candidate subsets: It removes duplicate indicators using indicator unique identifiers (UUIDs); retains the top 50 highly similar indicators from each subset to control the total number; and assigns weights to the remaining indicators based on their source channels (0.3 for the original query channel, 0.3 for the expanded channel, 0.3 for the key indicator channel, and 0.1 for the split channel) to calculate a comprehensive similarity score. This ultimately generates a candidate result containing 450 indicators, encompassing direct match indicators, category-specific indicators, core business indicators, and multi-dimensional feature indicators, providing a comprehensive indicator pool for subsequent screening and refinement.

[0097] In the embodiment of the present invention, the screening of the candidate results may be performed through the following examples.

[0098] Expert prompts are input into the large language model to guide the large language model to select the indicator names and table names most relevant to the natural language query from the candidate results; the expert prompts include financial domain knowledge, project context and screening rules, and the large language model combines semantic understanding and financial common sense to score the relevance of the candidate results, eliminate irrelevant items, and output the refined relevant information set.

[0099] In an embodiment of the present invention, for example, after obtaining candidate results containing 450 indicators, the server starts a relevance screening process based on a large language model to accurately extract core information that is highly relevant to the user's query "analyze the proportion of R&D investment of leading new energy vehicle manufacturers in the past three years" from massive candidate indicators.

[0100] First, the server constructs expert prompts that integrate financial domain knowledge, project context, and clear screening rules to ensure that the large model can accurately understand the screening targets. The specific content of the prompt words includes: "You are a data analysis expert in the consumer electronics industry. You need to filter the indicators and table names that are most relevant to the 'R&D investment ratio of leading new energy vehicle manufacturers in the past three years' from the list of candidate indicators. The screening criteria are as follows: 1. Financial field knowledge: The standard definition of R&D investment ratio is 'R&D expenses / operating income × 100%', which needs to be associated with the basic indicators of 'R&D expenses' and 'operating income'; leading manufacturers refer to 'the top five new energy vehicle companies in terms of market share' (based on the industry statistical caliber); the past three years refer to '2021-2023', and the time granularity is prioritized to the quarter (when there is no quarterly data, annual data is used). 2. Project context: The user needs to analyze the changing trend of the R&D investment ratio of leading manufacturers, which must include both enterprise-level indicators (by manufacturer) and industry-level indicators (overview comparison). 3. Screening rules: The retained indicators must meet the following requirements at the same time: ① The indicator name contains 'R&D expenses', 'operating income', or 'R&D investment ratio'; ② The enterprise is limited to 'leading manufacturers' (the manufacturer logo must be clearly marked) or industry totals; ③ The time range covers 2021-2023. Year; ④ The data source table must include manufacturer attributes, time attributes, and amount fields. Exclusion rules: ① Indicator names such as "advertising expenses" and "sales expenses" are non-R&D indicators; ② The enterprise scope is "second-tier manufacturers" or "regional brands" and other non-leading enterprises; ③ The time range is earlier than 2021 or later than 2023; ④ Indicators without clear manufacturer identification or with a monthly time granularity (too detailed). Please provide the retained indicator name, the table name, and the reason for retention.

[0101] The server then fed the 450 candidate indicators (including metadata such as indicator name, table name, time range, and company logo) along with the aforementioned expert prompts into a large-scale language model (such as LLaMA-270B), fine-tuned for the consumer electronics sector. The large-scale model first performed a structured analysis of each candidate indicator, extracting key attributes (indicator type, company scope, time range, data granularity, and associated table names). It then combined the financial domain knowledge contained in the prompts with screening rules to generate a multi-dimensional relevance score.

[0102] During the specific screening process, the big model handles typical indicators as follows: For the indicator "R&D expenses of pure electric vehicles of leading manufacturer A (2021-2023, quarterly)", the big model recognizes that it contains "leading manufacturer A" (in line with the enterprise scope), "R&D expenses" (basic indicators), "2021-2023" (time range), "quarterly" (data granularity), and the table "ev_enterprise_finance" to which it belongs contains manufacturer identification and amount fields, and is determined to be a core-related indicator, with the reason for retention marked as "meeting the basic indicator requirements of R&D expenses, covering leading manufacturers and target time range"; for the indicator "R&D investment share of new energy vehicle industry (2021-2023, annual)", because it is an industry-level total indicator, it can be used for comparative analysis and meets the time range and indicator name requirements, and is also retained; for the indicator "Second-tier manufacturer B For the indicator "Proportion of advertising expenses of plug-in hybrid models (2020-2022, annual)", the large model identified its "second-tier manufacturers" (non-leading manufacturers), "advertising expenses" (non-R&D category), and "2020-2022" (time range does not match), and determined it to be irrelevant. The reason for exclusion was marked as "the enterprise scope, indicator type and time range do not match"; for the indicator "Number of R&D personnel of fuel cell vehicles of leading manufacturer C (2021-2023, monthly)", it was also excluded because the "number of R&D personnel" is not a basic indicator required for calculating the proportion of R&D investment, and the "monthly" granularity is too detailed.

[0103] After screening by the large model, 128 of the original 450 candidate indicators were eliminated due to inconsistent indicator types (such as sales expenses, production costs), 95 were eliminated due to inconsistent enterprise scope (such as second-tier manufacturers, parts suppliers), and 82 were eliminated due to time range or granularity issues (such as 2020 data, monthly data). Finally, 45 core indicators were retained to form a refined relevant information set. This set includes 28 enterprise-level indicators (such as "R&D expenses of leading manufacturer A (2021Q1-2023Q4, quarterly)" and "Operating income of leading manufacturer B (2021-2023, annual)") and 17 industry-level indicators (such as "Total R&D expenses of the new energy vehicle industry (2021-2023, annual)" and "Average R&D investment share of the top five manufacturers (quarterly)"). Each indicator is accompanied by the table name (such as "ev_enterprise_finance" and "ev_industry_aggregate") and a clear reason for retention, providing accurate indicators and data source basis for subsequent SQL generation.

[0104] In an embodiment of the present invention, the generation and execution of SQL query statements based on the refined relevant information set, obtaining query result data and generating natural language answers can be implemented through the following examples.

[0105] Based on the indicator names, table names and filtering conditions in the refined relevant information set, combined with financial professional prompt words, the large language model is guided to generate SQL query statements that conform to the database syntax;

[0106] Executing the SQL query statement on the enterprise database to obtain the query result data;

[0107] The natural language answer is generated by combining the query result data and financial expertise, and the natural language answer includes the result value and the corresponding indicator description.

[0108] In an embodiment of the present invention, illustratively, after obtaining a refined relevant information set containing 45 core indicators, the server starts the SQL generation, execution and natural language answer generation process to complete the user's query requirement of "analyzing the proportion of R&D investment of leading new energy vehicle manufacturers in the past three years."

[0109] The server first performs structured analysis on the refined relevant information set and extracts key elements: enterprise-level indicators involve "R&D expenses" (quarterly data, 2021Q1-2023Q4) and "operating income" (annual data, 2021-2023) of "leading manufacturer A", "leading manufacturer B", "leading manufacturer C", "leading manufacturer D" and "leading manufacturer E" (top five in market share), stored in the table "ev_enterprise_finance" (containing fields: enterprise_id, enterprise_name, quarter, year, R&D expenses, operating income, product_type); industry-level indicators include "total R&D expenses of the new energy vehicle industry" and "total operating income of the industry" (annual data, 2021-2023), stored in the table "ev_industry_aggregate" (containing fields: year, industry R&D expenses, industry operating income).

[0110] Based on the above elements, the server constructs a financial-specific prompt to guide the large-scale language model in generating SQL queries. The prompt reads: "As a database engineer in the consumer electronics industry, please generate an enterprise-level relational database-compatible SQL query based on the following information: 1. Data source: Enterprise-level metrics come from the ev_enterprise_finance table (Enterprise Finance), and industry-level metrics come from the ev_industry_aggregate table (Industry Aggregate); 2. Query objective: Calculate the annual R&D investment percentage of leading manufacturer AE from 2021 to 2023 (R&D expenses / operating income × 100%), and correlate it with the industry average R&D investment percentage for the same period; 3. Filter condition: enterprise_name IN ('Leading Manufacturer A', 'Leading Manufacturer B', 'Leading Manufacturer C', 'Leading Manufacturer D', 'Leading Manufacturer E'), year BETWEEN 2021 AND 2023; 4. Calculation logic: R&D investment percentage is rounded to two decimal places, annual R&D expenses are calculated by summing quarterly data, and operating income is calculated directly from the year field; 5. Output fields: Company name, year, R&D expenses (100 million yuan), operating income (100 million yuan), R&D investment percentage (%), industry average R&D investment percentage (%); 6. Syntax requirements: Use LEFT JOIN to join the two tables (join key: year), GROUP BY company name and year, ORDER BY year in ascending order, company name in alphabetical order.

[0111] The server inputs the above prompt words and refined information set metadata into a large language model (such as GPT-4 Turbo) that has been fine-tuned through financial database operations. The large model combines table structure information with financial indicator calculation logic to generate the following SQL query statement:

[0112] {SELECT

[0113] t1.enterprise_name AS enterprise name,

[0114] t1.year AS year,

[0115] SUM(t1. R&D expenses) AS R&D expenses_100 million yuan,

[0116] t1. Operating income AS Operating income_100 million yuan,

[0117] ROUND((SUM(t1.R&D expenses) / t1.Operating income)*100, 2) AS R&D investment proportion_pct,

[0118] ROUND((t2.Industry R&D expenses / t2.Industry operating income)*100, 2) AS Industry R&D investment percentage average_pct FROM

[0119] ev_enterprise_finance t1 LEFT JOIN

[0120] ev_industry_aggregate t2 ON

[0121] t1.year = t2.year WHERE

[0122] t1.enterprise_name IN ('Top Manufacturer A', 'Top Manufacturer B', 'Top Manufacturer C', 'Top Manufacturer D', 'Top Manufacturer E')

[0123] AND t1.year BETWEEN 2021 AND 2023 GROUP BY

[0124] t1.enterprise_name, t1.year, t1.operating income, t2.industry R&D expenses, t2.industry operating income ORDER BY

[0125] t1.year ASC, t1.enterprise_name ASC;}

[0126] The server connects to an enterprise-level relational database (such as Oracle 19c) via JDBC and submits the generated SQL statements to the database execution engine. The database first filters the "ev_enterprise_finance" table, selecting records whose enterprise_name is "leading manufacturer AE" and whose year is between 2021 and 2023. After grouping by company and year, the SUM() function is used to sum each quarter's R&D expenses and join them with the annual operating income field. The result is then joined with the "ev_industry_aggregate" table by the year field using a LEFT JOIN to obtain the industry's R&D expenses and operating income totals for the same period. Finally, the company's R&D investment percentage (company R&D expenses / company operating income × 100%) and the industry average (industry R&D expenses / industry operating income × 100%) are calculated, rounded to two decimal places, and sorted.

[0127] After the execution is complete, the database returns structured query result data, which contains 15 records (5 manufacturers × 3 years). The sample data is as follows:

[0128] Leading manufacturer A, in 2021, R&D expenses were 5.23 billion yuan, operating income was 48.56 billion yuan, and R&D investment accounted for 10.77%, while the industry average was 9.25%;

[0129] Leading manufacturer B, in 2021, R&D expenses were 4.89 billion yuan, operating income was 51.23 billion yuan, and R&D investment accounted for 9.55%, while the industry average was 9.25%;

[0130] Leading manufacturer A, in 2022, had R&D expenses of 5.87 billion yuan and operating income of 53.21 billion yuan, with R&D investment accounting for 11.03% and the industry average being 9.68%; (the remaining records are arranged in order by year and manufacturer).

[0131] The server inputs the structured query results into the natural language generation module, which then generates a natural language response based on financial knowledge of the consumer electronics industry. The response consists of three parts: numerical result presentation, indicator description, and trend analysis.

[0132] The natural language answer is as follows: "The proportion of R&D investment of the leading new energy vehicle manufacturers (AE) in 2021-2023 is as follows: In 2021: the R&D investment of leading manufacturer A accounted for 10.77% (R&D expenses of 5.23 billion yuan / operating income of 48.56 billion yuan), leading manufacturer B was 9.55% (4.89 billion yuan / 51.23 billion yuan), leading manufacturer C was 11.20% (5.56 billion yuan / 49.65 billion yuan), leading manufacturer D was 8.92% (4.25 billion yuan / 47.64 billion yuan), and leading manufacturer E was 9.83% (4.67 billion yuan / 47.51 billion yuan); the average proportion of R&D investment in the industry was 9.25%. In 2022: the R&D investment of leading manufacturer A increased to 11.03% (5.87 billion yuan / 53.21 billion yuan), and the R&D investment of leading manufacturer C increased to 11.58% (6.23 100 million yuan / 53.8 billion yuan), while the share of leading manufacturer E dropped to 9.45% (4.82 billion yuan / 51.0 billion yuan); the industry average increased to 9.68%. In 2023, leading manufacturer A accounted for 11.35% (6.52 billion yuan / 57.45 billion yuan), and leading manufacturer C accounted for 11.82% (6.85 billion yuan / 57.95 billion yuan), with the industry average being 10.12%. R&D investment percentage = annual R&D expenses / annual operating revenue × 100%, reflecting the intensity of a company's R&D investment. The data covers the period 2021-2023, with leading manufacturers defined as the top five companies in terms of new energy vehicle market share. This shows that the R&D investment percentage of leading manufacturers A and C has increased for three consecutive years, while that of leading manufacturer E has declined slightly. Overall, the percentage is higher than the industry average, indicating that leading companies prioritize R&D more than the industry as a whole. This answer clearly presents the annual R&D investment percentage of each manufacturer, the calculation basis, and industry comparison trends, meeting the user's core needs for indicator analysis.

[0133] In an embodiment of the present invention, after obtaining the query result data and generating a natural language answer, the embodiment of the present invention further provides the following implementation methods.

[0134] If the SQL query statement fails to execute, returns an empty result, contradicts known common sense, or the confidence level of the generated result is insufficient, the reflection mechanism is triggered;

[0135] If it is determined that there is an omission or an incorrect match in the retrieval stage, the retrieval strategy is adjusted or the query conditions are expanded, and the steps of recalling candidate results from the index library based on the query vector and screening the candidate results are re-executed;

[0136] If it is determined that the query parsing is ambiguous or the user intention is misunderstood, the processing result of the query parsing and expansion module is modified and the query vector is regenerated.

[0137] In an embodiment of the present invention, illustratively, after generating a natural language answer, the server starts a result verification process, and performs multi-dimensional verification of the SQL execution status, return data, common sense consistency and confidence through a built-in anomaly detection module. When an anomaly is detected, a reflection mechanism is triggered to locate the root cause of the problem and perform targeted adjustments.

[0138] When the server executed the SQL query for "R&D investment proportion of leading new energy vehicle manufacturers in the past three years", the database returned the error code "ORA-00904: "R&D expenses": invalid identifier", indicating that the field name does not exist. After the anomaly detection module captured the error, it immediately triggered the reflection mechanism. The server first retrieved the SQL generation log and compared it with the database metadata dictionary. It was found that in the refined related information set, the "R&D expenses of leading manufacturer A (quarterly)" indicator in the table "ev_enterprise_finance" was actually named "R&D investment amount", rather than "R&D expenses" marked in the screening stage. This error was caused by the large model's mislabeling of the indicator metadata when screening candidate results (abbreviating "R&D investment amount" to "R&D expenses"), which caused the generated SQL statement to reference a non-existent field.

[0139] The server analyzed the error using an error attribution algorithm: the incorrect field name originated from the refined information set, which was generated by screening candidate results, which in turn were generated by recalling indicators during the search phase. Therefore, the root cause of the problem was identified as an error in extracting indicator metadata during the search phase. The server then adjusted its search strategy and added an indicator metadata verification step to the candidate result screening process. This step involves calling a database metadata interface (such as Oracle's DESCRIBE command) to perform real-time verification of the indicator, table, and field names filtered by the large model to ensure consistency with the actual database structure.

[0140] After the adjustment, the server re-executed the "Recalling Candidate Results Based on the Query Vector" and "Filtering Candidate Results" steps. During the multi-way recall phase, the search logic for the original query vector, derived query vectors, and key indicator enhancement channels remained unchanged. During the filtering phase, when the large model outputs indicators, it additionally called the metadata validation API to verify the fields in the "ev_enterprise_finance" table. This corrected the "R&D Expenses" field to the actual field name, "R&D Investment Amount," and simultaneously updated the indicator metadata label. Finally, the newly refined related information set included the corrected field names, ensuring correct references in subsequently generated SQL statements.

[0141] In another example, the server successfully executed the SQL query and generated a natural language response, which stated, "Leading manufacturer A's R&D investment accounted for 25.3% in 2023." The anomaly detection module compared this response with a built-in database of consumer electronics industry common sense (which indicates that "new energy vehicle manufacturers' R&D investment accounts for an industry average of 8%-15%, with leading manufacturers typically spending no more than 20%)." The response was determined to be inconsistent with common sense, triggering a reflection mechanism.

[0142] The server retrieved query parsing logs and discovered that during the "processing natural language queries to generate query vectors," the semantic expansion module incorrectly associated "R&D investment ratio" with "R&D investment / net profit" (the formula was sourced from a non-financial knowledge base), rather than the correct "R&D investment / operating income" formula. Because net profit is typically much smaller than operating income, the calculated ratio was abnormally high. Therefore, the root cause of the issue was identified as "ambiguous query parsing and misunderstanding of user intent."

[0143] The server initiates the correction process for query parsing and expansion modules: First, the standard definition of "R&D investment ratio" in the domain knowledge graph is updated, and the calculation formula "R&D investment ratio = R&D expenses / operating income × 100%" in the authoritative financial dictionary is bound, and the priority of this association is set higher than that of other domain knowledge bases; second, in the semantic expansion stage, an "indicator formula verification" step is added to check the formula compliance of the expanded indicator elements to ensure consistency with financial field standards.

[0144] After the adjustment, the server reprocessed the original natural language query: During the word segmentation and intent recognition phase, "R&D investment ratio" was still extracted as a key metric. During the semantic expansion phase, based on the updated knowledge graph, "R&D investment ratio" was correctly associated with "R&D expenses / operating revenue × 100%," adding "operating revenue" as a required basic metric. During the vectorization phase, the generated query vector incorporated the correct semantics of the metric calculation formula. After re-running the recall, screening, SQL generation, and execution steps, the 2023 R&D investment ratio for leading manufacturer A was revised to 11.35% (R&D expenses of 6.52 billion yuan / operating revenue of 57.45 billion yuan), consistent with industry consensus, and the natural language answer was updated simultaneously.

[0145] Through the above-mentioned reflection mechanism, the server realizes automatic detection, root cause location and dynamic adjustment of abnormal results, ensuring the accuracy of the entire process from query parsing to result generation, and significantly improving the robustness of complex financial indicator queries.

[0146] In the embodiment of the present invention, the output of the natural language answer and the result according to the description can be implemented through the following examples.

[0147] Desensitizing sensitive information contained in the query result data;

[0148] Output the natural language answer and attach a description of the result basis, which includes the name of the indicator involved, the data year, the SQL query fragment and the statistical caliber description.

[0149] In an embodiment of the present invention, for example, after generating a natural language answer to the question "R&D investment proportion of leading new energy vehicle manufacturers in the past three years", the server initiates a desensitizing process and a basis explanation integration process before outputting the result to ensure that the output content complies with data security specifications and has complete explainability.

[0150] The server calls the built-in sensitive information identification module to systematically scan the query result data and associated metadata. This module is based on the financial industry data desensitization rule library and automatically identifies three types of sensitive information: First, the company's undisclosed detailed data, such as "Leading manufacturer A's R&D expenses in 2023Q1 were 1.23 billion yuan" (quarterly data is internal management and not disclosed to the public). The server summarizes it on an annual basis as "Leading manufacturer A's R&D expenses in 2023 were 6.52 billion yuan", deleting the quarterly details; second, the company's internal identification, such as the "enterprise_id" field in the database table "ev_enterprise_finance" (the value is internal coding such as "EV-INT-001" and "EV-INT-002"). The server replaces it with the public manufacturer's abbreviation "Leading manufacturer A" and "Leading manufacturer B" to ensure that the company's internal identification system is not leaked; third, sensitive table names and field names, such as the original table name "internal_ev_finance_data" (containing the sensitive prefix "internal"), which is adjusted to the standard business table name "ev_enterprise_finance", and the field "R&D investment_internal accounting value" is corrected to the public indicator name "R&D expenses".

[0151] After desensitization, all output data complies with pre-set desensitization rules and industry data disclosure standards, retaining the aggregate dimensions required for analysis while removing detailed information that may involve commercial secrets. For example, the original query result "Top manufacturer C's R&D expenses in Q3 2022: 1.08 billion yuan (including 210 million yuan in special investment for Project XX)" is desensitized to "Top manufacturer C's R&D expenses in 2022: 5.32 billion yuan," removing the quarterly breakdown and project details. Irrelevant sensitive fields such as manufacturer executive compensation and supply chain costs are removed from the result set.

[0152] The server integrates the desensitized natural language answers and explanations of the results into structured output. The natural language answers are presented in the form of "data summary + trend analysis": "The R&D investment proportions of the leading new energy vehicle manufacturers (AE) from 2021 to 2023 are as follows: In 2021, leading manufacturer A accounted for 10.77% (R&D expenses of 5.23 billion yuan / operating income of 48.56 billion yuan), leading manufacturer C accounted for 11.20%, and the industry average was 9.25%; in 2022, the proportion of leading manufacturer A increased to 11.03%, and leading manufacturer C increased to 11.58%, with an industry average of 9.68%; in 2023, leading manufacturer A accounted for 11.35%, and leading manufacturer C accounted for 11.82%, with an industry average of 10.12%. Overall, the R&D investment intensity of leading manufacturers A and C has been higher than the industry average for three consecutive years, and has shown an upward trend year by year."

[0153] Names of indicators involved: Clearly list the core indicator "R&D investment ratio" and the basic indicators "R&D expenses" and "operating income", and mark the indicator type (enterprise-level indicators / industry-level indicators), for example, "enterprise-level indicators: R&D expenses (100 million yuan, annual cumulative value), operating income (100 million yuan, annual report value); industry-level indicators: total industry R&D expenses (100 million yuan), total industry operating income (100 million yuan)".

[0154] Data year: The unified time range is "January 1, 2021 - December 31, 2023", the data granularity is "annual" (because quarterly data has been anonymized), and the data source period is marked as "corporate financial year (calendar year)".

[0155] SQL query snippet: Selects and displays key parts of the query logic, including table join conditions, filter conditions, and core calculation logic. For example, "Key SQL logic: SELECT t1.enterprise_name, t1.year, ROUND((SUM (t1. R&D expenses) / t1. operating income) * 100, 2) AS R&D investment ratio_pct FROM ev_enterprise_finance t1 LEFT JOIN ev_industry_aggregate t2 ON t1.year = t2.year WHERE t1.enterprise_name IN ('Top Manufacturer A', 'Top Manufacturer B', 'Top Manufacturer C', 'Top Manufacturer D', 'Top Manufacturer E') AND t1.year BETWEEN 2021 AND 2023 GROUP BY t1.enterprise_name, t1.year."

[0156] Explanation of statistical scope: Key terms are defined in detail, including that "head manufacturers" refers to "the top five companies in the new energy vehicle market share (based on the 'ranking by annual sales' in the 2023 New Energy Vehicle Industry Report of the China Association of Automobile Manufacturers)", and the "R&D investment share" is calculated as "R&D investment share = annual R&D expenses of the company / annual operating income of the company × 100% (R&D expenses include direct R&D personnel salaries, equipment purchases, testing expenses, etc., and operating income is the operating income of the consolidated financial statements)".

[0157] Finally, the server renders the above content into an HTML format page and displays it to the user through the client interface. The left side of the page is the natural language answer (including data table visualization), and the right side is the explanation of the result basis (details can be expanded / collapsed), ensuring that users can quickly obtain analysis conclusions and trace the data source, calculation logic and statistical standards, meeting the dual requirements of the financial field for the explainability and compliance of query results.

[0158] In order to more clearly describe the solution provided by the embodiment of the present invention, a relatively complete implementation method is provided below.

[0159] The Text2SQL system proposed in this paper adopts a bottom-up architecture, dividing the query process into multiple modules and gradually building the final answer from the bottom up. The following is a detailed description of each module and its data flow, combined with a schematic diagram of the architecture.

[0160] Query Analysis & Expansion

[0161] After the user enters a natural language query, the system first enters the query parsing and expansion module. This module performs semantic analysis and preprocessing on the query, including word segmentation and intent recognition, and extracts key indicator names, filter conditions, general terms and other elements. For the detected indicators or entities, the module uses domain knowledge to perform alias replacement and semantic expansion: for example, "social financing" is expanded to "social financing scale" or the English abbreviation "M2" is identified as "broad money supply M2", etc. There are also summary words contained in the query, such as "various regions in Yunnan" will be broken down into the names of various urban areas under Yunnan Province or "white appliances" will be broken down into "refrigerators, air conditioners, washing machines", etc. The expanded query elements are further converted into vector representations (Embedding) to prepare for subsequent vector retrieval. In the present invention, a pre-trained financial field word vector model and a large language model embedding are used to encode the query and its key fragments into one or more high-dimensional vectors to capture the semantic information of the query intent.

[0162] Example:

[0163] User: "Please analyze the market share of the three major white goods giants in the past three years."

[0164] System processing:

[0165] Concept segmentation → {"white appliances":["refrigerator","washing machine","air conditioner"], "Big Three":["Haier","Midea","Gree"]};

[0166] Problem Analysis → (1) Key Financial Indicator: Market Share

[0167] (2) Calculation formula: Market share = sales or shipments of a company / total sales or shipments of the industry × 100%

[0168] Keyword identification → ['Big Three White Goods', 'Market Share', 'Sales', 'Shipment', 'Industry Total Sales', 'Total Shipment'];

[0169] Vector Generation → Combine "Query Refrigerator Washing Machine Air Conditioner Haier Midea Gree White Goods Three Giants Market Share Market Share Sales Shipment Industry Total Sales Total Shipment" to generate a semantic vector.

[0170] Hybrid Vector Retrieval

[0171] The vectorized query will be retrieved from the massive index library in this module through a multi-channel vector retrieval mechanism. Specifically, the present invention adopts a triple parallel recall strategy to build a composite recall solution:

[0172] Original query recall channel: Use the original query vector to perform a Top-100 similarity search in a vector index (such as Faiss or other vector databases) to retain complete query semantic information and ensure basic recall quality. This is particularly suitable for situations where the query expression is standardized and highly matches the database terminology. (2) Query expansion recall channel: Perform semantic expansion on the original query to generate a derivative query vector. Use the expanded vector to perform a Top-100 similarity search in parallel. Query expansion technology is used to solve the term mismatch problem and enhance semantic recall capabilities. (3) Key indicator enhancement channel: Use the original query to perform a Top-50 accurate recall from a predefined set of important indicators to ensure that core business indicators are recalled first. A special weighting mechanism is used to ensure that key indicators are not overwhelmed by conventional results.

[0173] Enhanced multi-dimensional search: For complex queries, the system supports splitting the query into multiple feature dimensions and generating vectors for each dimension (such as indicator name, general dimension, measurement method, etc.), and obtaining a more accurate candidate set through feature-level vector search.

[0174] Recall Result Fusion: Through parallel retrieval in three channels, the system comprehensively obtains: database fields that directly match the query, semantically relevant pre-computed views, relevant SQL snippets from historical Q&A, and necessary code-value mapping tables. This multi-channel recall mechanism significantly improves recall rate and result coverage compared to a single search mode, providing a more complete candidate set for the subsequent refined ranking module.

[0175] Example:

[0176] User: "Please analyze the market share of the three major white goods giants in the past three years."

[0177] System processing:

[0178] Multi-way vectorized recall → embedding (query) & embedding (query + refrigerator) & embedding (query + fan) & embedding (query + refrigerator) & embedding (query + fan) & embedding (query + Market Share + total shipments + total white appliance sales in the industry + company white appliance sales). etc.

[0179] Large Model Filtering (LLM-based Filtering with Expert Prompt):

[0180] After obtaining the candidate set, not all content is highly relevant to the user's query and may contain some noisy items. To improve the accuracy of subsequent reasoning, the present invention introduces a large language model for filtering and fine-sizing. Specifically, an expert prompt is designed to guide the LLM to select the most relevant elements from the given candidate list. This prompt fully incorporates domain knowledge. For example, the LLM can be prompted with the following: "You are a financial data analysis expert. Please select the indicator name and necessary table name from the candidate list that are most relevant to the user's question." Guided by the prompt, the LLM will score and interpret the relevance of the candidate items based on contextual semantics and financial common sense, eliminate items that clearly do not match, and output a refined set of relevant information. This step is equivalent to using the LLM's semantic understanding capabilities to act as a "filter," narrowing the broad set in the recall phase to a refined set, providing focused, high-quality context for subsequent query generation.

[0181] Expert Prompt

[0182] The embodiment of the present invention designs a system prompt, introduces financial domain knowledge, project context and the rule of "how to filter irrelevant indicators", and guides LLM to make relevance judgments according to user needs.

[0183] A typical prompt might look like this: "You are a financial data analysis expert. Based on the user's query, please select the indicator name and table name that best matches the given candidate indicator list. Ignore irrelevant items and provide reasons for retaining them."

[0184] Through this prompt with domain information and screening criteria, LLM can more accurately evaluate the match between candidate items and user intentions.

[0185] Double scoring for semantics and financial knowledge

[0186] LLM goes beyond superficial keyword matching and incorporates financial knowledge and context. For example, if a user wants "nominal GDP" and the only available options are "GDP year-on-year (%)" and "GDP (current price)," LLM will prefer to retain "GDP at current price" and filter out "year-on-year growth rate." This scoring method, which combines semantic understanding with industry logic, is superior to pure keyword searches.

[0187] Output refined set:

[0188] Guided by prompts, LLM will eliminate obviously inconsistent candidates and provide a minimal and sufficient set (including possible indicators and table information), with brief reasons or ranking results for direct use in subsequent processes.

[0189] Example:

[0190] Candidate indicators (5), numbered starting from 0:

[0191] 0. China: Export value: USD (monthly);

[0192] 1. China: GDP: Quarter-on-quarter: Seasonally Adjusted (QoQ);

[0193] 2. China: GDP: Constant Price: Year-on-year (quarterly);

[0194] 3. China: United States: Export Value (Annual);

[0195] 4. China: United States: Import and Export Value (Monthly);

[0196] User query: "China's GDP share in exports to the United States".

[0197] System processing:

[0198] #0 (China: Export Value: USD (Monthly)) refers to China's exports to the world, not limited to the US. But perhaps users could combine this with another indicator for comparison? It's barely related.

[0199] #1 / #2 are both "China's GDP growth rate or month-on-month growth rate", not the nominal amount of GDP. If users really want to "share", nominal GDP is needed to be accurate. These two indicators can only provide growth rates, which is not enough.

[0200] #3 (China:US:Export Amount (Annual)) is exactly the nominal value of "Export Amount to the United States" and is the best match.

[0201] #4 (China:US:Import and Export Amount (Monthly)) includes the total import and export amount, including exports to the US. However, it is not straightforward to separate "Exports to the US"; it can be retained or deleted with caution.

[0202] Large Model Oracle Reasoning and Query Execution (LLM Oracle Reasoning and Query Execution):

[0203] The filtered key information (including confirmed indicator names, involved tables and fields, and filter conditions) is passed to the large model Oracle module. Here, a large language model is assigned the Oracle's responsibilities, namely, final reasoning and SQL generation and execution. Unlike conventional Text2SQL, the LLM of our invention receives highly relevant and structured information, along with specialized prompts, to guide it through the correct query construction steps. The LLM Oracle module first generates an SQL query based on the input: for example, it constructs a SELECT statement based on the filtered indicators and conditions, joins the corresponding tables, and adds time or other constraints to the WHERE clause. After generating the SQL, the system executes the SQL statement on the actual database to obtain the query result data. The LLM Oracle then combines the result data with professional knowledge to generate a user-friendly natural language answer. If necessary, it also adds SQL snippets or result references as explanations. For example, for queries requiring tabular output, the LLM Oracle can organize the results into a table format. At this stage, the large model acts as the "ultimate solver," leveraging the accurate information prepared in the previous stage to produce valid queries and results. Internal testing has verified that this module, combined with the aforementioned steps, can improve the accuracy of complex financial queries by more than 5%, while controlling the average response time to approximately 23 seconds, significantly improving practicality compared to traditional end-to-end LLM.

[0204] Reflection mechanism (Refinement & Self-correction):

[0205] To further improve the robustness of the system, the present invention designs a reflection mechanism that runs through the entire process. When the results given by LLMOracle are incorrect or lack confidence (for example, SQL execution fails, the returned result is empty, or it contradicts known common sense), the system will trigger the reflection module to start working. The reflection mechanism will automatically analyze the cause of the error and handle it in two situations: (5a) If it is suspected that there are omissions or mismatches in the retrieval stage, the retrieval strategy will be adjusted or the query conditions will be expanded, and vector recall and filtering will be performed again, that is, returning to the candidate retrieval stage of the process; (5b) If it is determined that the query parsing is ambiguous or the user's intention is misunderstood, the results of the query parsing and expansion will be modified, such as adjusting the interpretation of ambiguous words, and generating new vector representations again. After the above self-correction, the system will re-enter the LLM Oracle reasoning stage, generate the corrected SQL and execute it. The reflection mechanism is equivalent to adding a layer of feedback loop to the system, ensuring that even if the initial reasoning is not completely correct, it can approach the correct answer through automatic iteration. This self-correction capability greatly improves the robustness of the system when facing complex or ambiguous problems and reduces the need for manual intervention.

[0206] Example:

[0207] The generated SQL uses certain syntax that Oracle does not support (such as calling an alias in HAVING or misspelling UNION ALL + ORDER BY), resulting in the following error: Oracle Database error code: 933, message: ORA-00933: SQL command not properly ended.

[0208] System processing:

[0209] 1. Cause of the error: (1) In Oracle, you cannot use aliases in SELECT directly during the HAVING or GROUP BY phase, such as "Total electricity consumption (100 million kWh)"; (2) After a UNIONALL operation, if you want to ORDER BY the entire result, you need to put it in the outer SELECT;

[0210] 2. Reflection: (1) Check whether the search misses any alternative indicators. If you suspect that the search indicator itself is incorrect, you can return to the search module and try a new alias or expansion of “total electricity consumption” to see if there are more available ind_der_codes.

[0211] (2) Update the SQL generation logic, modify the parts that do not conform to Oracle specifications, remove incorrect alias references, or make UNIONALL into a subquery and then ORDER BY;

[0212] 3. Retry the execution and run the corrected SQL again. If successful, the answer is complete; if it still fails, continue to reflect.

[0213] The system generated problematic SQL during its initial reasoning; when an error occurred during execution, it automatically reflected on the incompatibility of Oracle syntax and corrected the query. This self-correction capability enables the system to handle complex or ambiguous scenarios and gradually approach the correct answer with minimal human intervention.

[0214] Safe and Interpretable Output:

[0215] When finally generating the answer, the present invention pays special attention to the security and explainability of the output results. Security refers to avoiding the leakage of sensitive information and complying with compliance requirements in the financial field, such as desensitizing query results involving personal data. Explainability is reflected in the fact that the system will provide users with a certain degree of explanation of the basis of the results. For example, when outputting numerical values, the system can indicate which indicators or years these values ​​come from, and provide some SQL query fragments or statistical caliber descriptions. This explanation module can help users understand the source of the results and enhance their trust in the system's answers. In addition, when answering some inference questions, the system will attach a brief description of the analysis process. In short, the output module ensures that the system's answers are intuitive, easy to understand and trustworthy, meeting the audit and traceability requirements of the financial industry. Comply with regulations.

[0216] Through the modular division of labor and collaboration described above, the present invention achieves an efficient closed loop from user questions to SQL and then to answers. The entire bottom-up process begins with retrieval and then inference, with layer-by-layer screening and gradual refinement, fully leveraging the speed and coverage advantages of vector retrieval and the deep reasoning capabilities of large models. Actual tests have shown that in a data environment with millions of indicators, this solution significantly outperforms the traditional top-down architecture, achieving an accuracy improvement of over 5% in complex query scenarios and an average query time of approximately 23 seconds, demonstrating superior performance in terms of speed, accuracy, and scalability.

[0217] In summary, the present invention organically integrates multiple technical elements, and its innovation and key technical points are mainly reflected in the following aspects: breaking through the traditional top-down single-step generation approach by the model, adopting a bottom-up, multi-stage and step-by-step improvement of the Bottom-up query construction process architecture, first retrieving relevant information and then making decisions by model reasoning, reducing the complexity of the model directly processing the entire search space, improving the stability and efficiency of query generation, and constituting a basic framework innovation; proposing a hybrid multi-way vector recall scheme that combines query, multi-dimensional expanded query and core indicator set retrieval, using the complementary advantages of semantic matching and keyword matching, and targeting the diverse professional terms and frequent aliases and abbreviations in the financial field, achieving high recall rate and quasi-recall in massive indicators, ensuring that the system finds relevant data support comprehensively and accurately, which is a key means to improve query accuracy; innovatively combining large-scale language models The role of the system is divided into two stages: filter and oracle solver. Through expert prompts, LLM first performs semantic filtering, and then generates SQL and executes it based on the refined information through deep reasoning. This significantly reduces the probability of large models misusing information, gives full play to the optimal role of LLM in different stages, and improves the overall accuracy of the system. The introduction of an automatic reflection feedback loop enables the system to have the ability to retry and self-improve when errors occur. When the first generated result is not ideal, it automatically adjusts the retrieval or parsing strategy and performs secondary reasoning, improving the robustness of the system, reducing the need for manual intervention and debugging, and ensuring reliability in complex query scenarios. It focuses on the interpretability of query results, and provides the source of the results (such as the indicators and SQL fragments involved) for each answer. At the same time, it complies with the financial data security and compliance requirements to protect sensitive information, ensuring that the system meets industry supervision and audit requirements while achieving intelligence, and providing reliable protection for actual deployment. The above key innovations work together to form the overall technical solution to be protected by this invention, and together realize the efficient automation of complex Text2SQL queries in the financial field, providing a new technical path for the industry.Compared with traditional alternatives, this invention has obvious advantages: the traditional RAG (retrieval enhanced generation) solution generates a single large model end-to-end, allowing the model to generate SQL directly from user questions. However, there are problems such as the model is difficult to grasp the details of millions of indicators, prone to knowledge hallucination, poor real-time performance, huge computational overhead, and high maintenance cost when the database structure changes. This invention avoids the problems of pure LLM by introducing retrieval and multi-stage processing. Relying on generative reasoning without retrieval assistance leads to problems such as insufficient accuracy and easy factual errors; although traditional RAG solutions introduce a retrieval step before LLM generation, they are mostly based on static documents, resulting in untimely updates, and the main reasoning burden is still on LLM. The model needs to understand and integrate a large amount of text descriptions, which is prone to errors. The present invention uses structured filtering and simplification after retrieval to allow LLM to receive highly relevant key information, reduce the difficulty of reasoning, and the retrieval index is built based on the latest data table to ensure timeliness; retrieval or template solutions based on fixed rules are effective in limited fields, but when facing open questions about financial business, the rules have limited coverage, it is difficult to enumerate all questioning methods, and they are difficult to maintain. The present invention has stronger generalization capabilities through the combination of data-driven and model reasoning, and can handle diverse problems without being limited to preset modes, thereby providing a flexible, reliable and efficient financial query solution.

[0218] Please refer to Figure 2 , Figure 2 A retrieval device 110 based on a hybrid vector model includes:

[0219] The acquisition module 1101 is configured to process a natural language query input by a user to generate a query vector; retrieve candidate results from an indicator library based on the query vector; and screen the candidate results to obtain a refined relevant information set.

[0220] The retrieval module 1102 is used to generate and execute SQL query statements based on the refined relevant information set, obtain query result data and generate natural language answers; and output the natural language answers and result basis descriptions.

[0221] It should be noted that the implementation principles of the aforementioned hybrid vector model-based retrieval device 110 can be referenced to the implementation principles of the aforementioned hybrid vector model-based retrieval method, and will not be elaborated upon here. It should be understood that the division of the various modules of the aforementioned device is merely a division of logical functions. In actual implementation, they may be fully or partially integrated into a single physical entity, or physically separated. Furthermore, these modules may be implemented entirely in software invoked by a processing element, or entirely in hardware. Alternatively, some modules may be implemented in software invoked by a processing element, while others may be implemented in hardware. For example, the hybrid vector model-based retrieval device 110 may be a separate processing element, or integrated into a chip of the aforementioned device. Furthermore, it may be stored in the form of program code in the memory of the aforementioned device, invoked by a processing element of the aforementioned device, and execute the functions of the hybrid vector model-based retrieval device 110. The implementation of the other modules is similar. Furthermore, these modules may be fully or partially integrated together, or implemented independently. The processing element described herein may be an integrated circuit with signal processing capabilities. During implementation, the steps of the aforementioned method or the aforementioned modules may be performed by hardware integrated logic circuits in a processor element, or by software instructions.

[0222] For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASICs), one or more digital signal processors (DSPs), or one or more field programmable gate arrays (FPGAs). For another example, when a module is implemented by scheduling program code on a processing element, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).

[0223] The embodiment of the present invention provides a computer device 100, which includes a processor and a non-volatile memory storing computer instructions. When the computer instructions are executed by the processor, the computer device 100 executes the aforementioned retrieval device 110 based on the hybrid vector model. Figure 3 As shown, Figure 3This is a structural block diagram of a computer device 100 provided in an embodiment of the present invention. The computer device 100 includes a hybrid vector model-based retrieval device 110 , a memory 111 , a processor 112 , and a communication unit 113 .

[0224] To achieve data transmission or interaction, the memory 111, processor 112, and communication unit 113 are electrically connected to each other directly or indirectly. For example, these components can be electrically connected to each other through one or more communication buses or signal lines. The hybrid vector model-based retrieval device 110 includes at least one software function module that can be stored in the memory 111 in the form of software or firmware or embedded in the operating system (OS) of the computer device 100. The processor 112 is used to execute the hybrid vector model-based retrieval device 110 stored in the memory 111, such as the software function modules and computer programs included in the hybrid vector model-based retrieval device 110.

[0225] An embodiment of the present invention provides a readable storage medium, which includes a computer program. When the computer program is executed, the computer device where the readable storage medium is located is controlled to execute the aforementioned retrieval device 110 based on the hybrid vector model.

[0226] For illustrative purposes, the foregoing description has been made with reference to specific embodiments. However, the above illustrative discussion is not intended to be exhaustive or to limit the present disclosure to the precise forms disclosed. Numerous modifications and variations are possible in light of the above teachings. These embodiments have been selected and described in order to best illustrate the principles of the present disclosure and its practical application, thereby enabling those skilled in the art to best utilize the present disclosure and to utilize various embodiments with various modifications as appropriate for the specific application contemplated.

Claims

1. A retrieval method based on a hybrid vector model, characterized in that: include: In response to a natural language query input by a user, processing the natural language query to generate a query vector; Recalling candidate results from an indicator library based on the query vector, screening the candidate results, and obtaining a refined relevant information set; Generate and execute SQL query statements based on the refined relevant information set, obtain query result data and generate natural language answers; Outputting the natural language answer and explanation of the result; The processing of the natural language query to generate a query vector includes: Perform word segmentation and intent recognition on the natural language query to extract key indicator names, filtering conditions, and general terms; Performing alias replacement and semantic expansion on the key indicator names and general terms based on financial domain knowledge to obtain expanded query elements; Using a pre-trained financial domain word vector model and a large language model to perform vectorization processing, the expanded query elements are converted into the query vector; Recalling candidate results from the indicator library based on the query vector includes: Using the original query recall channel, perform a top-N similarity search in the vector index using the query vector to obtain a first candidate subset; Performing semantic expansion on the natural language query to generate a derived query vector through a query expansion and recall channel, and performing a top-N similarity search in the vector index using the derived query vector to obtain a second candidate subset; Performing top M precision recalls using the query vector from a predefined set of important indicators through a key indicator enhancement channel to obtain a third candidate subset, wherein M is less than N; For complex queries, the natural language query is split into multiple feature dimensions, feature vectors are generated for each dimension, and vector retrieval is performed to obtain a fourth candidate subset; fusing the first candidate subset, the second candidate subset, the third candidate subset, and the fourth candidate subset to obtain the candidate result; The screening of the candidate results includes: Expert prompts are input into the large language model to guide the large language model to select the indicator names and table names most relevant to the natural language query from the candidate results; the expert prompts include financial domain knowledge, project context and screening rules, and the large language model combines semantic understanding and financial common sense to score the relevance of the candidate results, eliminate irrelevant items, and output the refined relevant information set.

2. The method according to claim 1, characterized in that Generating and executing SQL query statements based on the refined relevant information set, obtaining query result data and generating natural language answers, includes: Based on the indicator names, table names and filtering conditions in the refined relevant information set, combined with financial professional prompt words, the large language model is guided to generate SQL query statements that conform to the database syntax; Executing the SQL query statement on the enterprise database to obtain the query result data; The natural language answer is generated by combining the query result data and financial expertise, and the natural language answer includes the result value and the corresponding indicator description.

3. The method according to claim 1, characterized in that After obtaining the query result data and generating a natural language answer, the method further includes: If the SQL query statement fails to execute, returns an empty result, contradicts known common sense, or the confidence level of the generated result is insufficient, the reflection mechanism is triggered; If it is determined that there is an omission or an incorrect match in the retrieval stage, the retrieval strategy is adjusted or the query conditions are expanded, and the steps of recalling candidate results from the index library based on the query vector and screening the candidate results are re-executed; If it is determined that the query parsing is ambiguous or the user intention is misunderstood, the processing result of the query parsing and expansion module is modified and the query vector is regenerated.

4. The method according to claim 1, wherein The output of the natural language answer and the result basis description includes: Desensitizing sensitive information contained in the query result data; Output the natural language answer and attach a description of the result basis, which includes the name of the indicator involved, the data year, the SQL query fragment and the statistical caliber description.

5. A retrieval device based on a hybrid vector model, characterized in that: include: an acquisition module, configured to process a natural language query input by a user and generate a query vector; Recalling candidate results from an indicator library based on the query vector, screening the candidate results, and obtaining a refined relevant information set; A retrieval module is configured to generate and execute SQL query statements based on the refined relevant information set, obtain query result data, and generate a natural language answer; and output the natural language answer and a description of the result basis; The acquisition module is specifically used to: Performing word segmentation and intent recognition on the natural language query to extract key indicator names, filtering conditions, and general terms; performing alias replacement and semantic expansion on the key indicator names and general terms based on financial domain knowledge to obtain expanded query elements; performing vectorization processing using a pre-trained financial domain word vector model and a large language model to convert the expanded query elements into the query vector; Using the original query recall channel, the query vector is used to perform a top N similarity search in the vector index to obtain a first candidate subset; using the query expansion recall channel, the natural language query is semantically expanded to generate a derived query vector, and the derived query vector is used to perform a top N similarity search in the vector index to obtain a second candidate subset; using the key indicator enhancement channel, the query vector is used to perform a top M precise recall from a predefined set of important indicators to obtain a third candidate subset, where M is less than N. For complex queries, the natural language query is split into multiple feature dimensions, feature vectors are generated for each dimension, and vector retrieval is performed to obtain a fourth candidate subset; fusing the first candidate subset, the second candidate subset, the third candidate subset, and the fourth candidate subset to obtain the candidate result; Inputting expert prompt words into the large language model to guide the large language model to select the indicator name and table name most relevant to the natural language query from the candidate results; The expert prompt words include financial domain knowledge, project context and screening rules. The large language model combines semantic understanding and financial common sense to perform relevance scoring on the candidate results, eliminates irrelevant items, and outputs the refined relevant information set.

6. A computer device, characterized in that: The computer device includes a processor and a non-volatile memory storing computer instructions. When the computer instructions are executed by the processor, the computer device executes the method according to any one of claims 1 to 4.

7. A readable storage medium, characterized in that: The readable storage medium includes a computer program, and when the computer program is executed, the computer device where the readable storage medium is located is controlled to execute the method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Financial index query method and device, computer equipment and medium

    CN119988455A

  • Large model Text-to-SQL conditional clause improvement method and system based on fuzzy recall field value enhancement

    CN120277103A