Large model index generation method

By building an indicator knowledge base and large model agent, the problem of insufficient accuracy and scalability of large model generation indicators is solved, efficient and accurate indicator generation is achieved, the accuracy and compatibility of the system is improved, and the cost and response time is reduced.

CN120470105AActive Publication Date: 2025-08-12TAIHUA WISDOM IND GRP CO LTD +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510577017.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-06
Publication Date
2025-08-12
Estimated Expiration
2045-05-06

AI Technical Summary

Technical Problem

Large models have problems with insufficient accuracy when generating indicators, poor scalability of traditional indicator libraries and compatibility issues with hybrid systems, resulting in increased response delays and increased maintenance complexity. It is difficult for existing technologies to effectively improve the accuracy and coverage of generated indicators.

Method used

Build an indicator knowledge base and store vectors to generate a knowledge base; build an indicator generation agent based on a large model, enter task commands through the client, perform standardization and semantic recognition, use the knowledge base to match indicators and call the API, if it does not match, it will be converted into a structured query language, generate chart code, and merge the result set to return uniformly.

Benefits of technology

The accuracy rate of 99.2% in key business scenarios has been improved, 32% higher than the pure large model solution, the proportion of reusing existing interfaces and logic exceeds 90%, the system transformation cost is reduced by 70%, the response time is ≤200ms, and the time to generate long-tail indicators is controlled within 1.5s.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120470105A_ABST
    Figure CN120470105A_ABST
Patent Text Reader

Abstract

The invention discloses a method for generating indexes by a large model, which comprises the following steps of: constructing an index knowledge base and carrying out vectorization storage to generate a knowledge base; according to the method, a double-layer mechanism of large model dynamic verification is pre-screened through a knowledge base, the accuracy rate of key business scene indexes reaches 99.2%, the accuracy rate is increased by 32% compared with a pure large model scheme, the proportion of multiplexing an existing index application programming interface and computational logic exceeds 90%, and the system transformation cost is reduced by 70%. Response time of a conventional index is less than or equal to 200ms and is increased by 5 times compared with direct generation of a large model, and time consumed by generation of a long-tail index is controlled within 1.5 s.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of natural language processing technology, and more specifically, to a method for improving the accuracy of large model generation indicators. Background Art

[0002] With the widespread adoption of large-scale models (LLMs) in data analytics, the demand for natural language-based metric generation has increased significantly. Traditional business systems typically rely on predefined metric knowledge bases (including APIs, chart types, classification rules, etc.) to achieve deterministic data returns, but this has limited scalability. While large-scale models offer semantic understanding and dynamic generation capabilities, they suffer from "hallucination" (generating false or uncertain results), making them difficult to directly apply in business scenarios requiring high accuracy.

[0003] The main shortcomings of the existing technology are:

[0004] (1) Large model illusion leads to insufficient accuracy: When generating indicators, large models may output indicators with logical errors, parameter mismatches, or indicators that conflict with business rules (such as incorrect time dimension calculations or unit conversions).

[0005] (2) Scalability defects of traditional indicator libraries: Indicator knowledge bases based on manual maintenance are difficult to cover long-tail demands (such as new indicators for sudden business scenarios), and the update cycle is long and the cost is high.

[0006] (3) Hybrid system compatibility issues: Directly superimposing large models with traditional indicator systems will lead to interface confusion (such as API call conflicts), increased response delays (double verification mechanism) and increased maintenance complexity.

[0007] Chinese patent technology application 1 (application number: 202410870481.5, application date: 2024.06.28.) discloses a question-answering method and device based on a large model, which uses a first large model pre-trained for the target field to standardize and rewrite the question to be answered, obtain the standard question corresponding to the question to be answered, and search the knowledge base for the target candidate text matching the standard question, so as to concatenate the target candidate text, the standard question and the prompt text to obtain input data, and input the input data into the second large model so that the second large model can obtain the knowledge of the target field, and obtain the answer information after analyzing the target candidate text and the standard question according to the requirements of the prompt text. It can only improve the accuracy of specific fields and requires repeated pre-training, and has poor applicability and practicality.

[0008] Chinese patent technology application 2 (application number: 202411118484.X, application date: 2024.08.15.) discloses a method and system for improving the accuracy of converting large model text to SQL based on specific scenarios, including the following steps: building a knowledge base, building a database, building a large model, and logical processing. It can achieve accurate analysis of the business scenarios, indicator meanings and calculation rules, table fields, etc. involved in user queries, and improve the accuracy of text to SQL. There is no relevant effective solution for the situation where the content of the customer query does not match the knowledge base.

[0009] Therefore, it is necessary to provide a method for generating indicators for large models that can reduce the error of large model generation through the rule constraints and feedback verification mechanism of the indicator knowledge base, improve the indicator service coverage without reconstructing the original application programming interface and computing engine, and effectively improve the accuracy of the indicators generated by large models. Summary of the Invention

[0010] In view of this, the present invention provides a method for generating indicators using a large model, comprising the steps of:

[0011] Build an indicator knowledge base and perform vectorized storage to generate a knowledge base;

[0012] Constructing an indicator-generating agent based on a large model includes the following steps:

[0013] The user inputs task commands to the large model using natural language through the client;

[0014] The large model standardizes the task commands to obtain standard text content;

[0015] The large model performs semantic recognition on standard text content and matches it with the knowledge base;

[0016] If a corresponding indicator is matched in the knowledge base, the knowledge base returns the API of the corresponding indicator to the big model;

[0017] The big model initiates a call request to the API of the corresponding indicator, and the API of the indicator returns the corresponding data to the big model;

[0018] The large model parses the returned corresponding data to obtain the core data;

[0019] Assemble indicator codes for core data and generate standard codes;

[0020] If at least two corresponding indicators are matched in the knowledge base, the knowledge base transmits the matching results to the client through the big model. The user selects the corresponding indicator through the client and performs the steps after matching a corresponding indicator in the knowledge base;

[0021] If no corresponding indicator is found in the knowledge base, the task command is converted into structured query language through the big model;

[0022] The large model calls the general application programming interface, sends the structured query language as a parameter to the application programming interface, and obtains the interface data;

[0023] The big model parses the interface data, calls the chart generation model, and generates chart code;

[0024] Merge standard code and chart code, generate result sets, and complete the construction of indicator generation agent based on large model;

[0025] If the client interface needs to display a chart, the big model calls the indicator generation agent's application programming interface and returns the result set to the client.

[0026] Optionally, the indicator knowledge base includes: sector name, indicator calculation logic, indicator description, indicator application programming interface, indicator return result, indicator display format and indicator item name.

[0027] Optionally, the large model standardizes task commands using regular expressions.

[0028] Optionally, the core data is assembled with indicator codes to generate standard codes, including: importing the core data into a visualization library for creating charts, defining a chart container, configuring the chart according to the indicator knowledge base, and obtaining standard codes for generating charts.

[0029] Optionally, the big model parses the interface data, calls the chart generation model, and generates chart code, including the following steps: the big model analyzes the structure of the interface data, the meaning of the fields, and the relationship between the data; selects a suitable chart type based on the data characteristics and analysis objectives, and the chart types include: line charts, bar charts, pie charts, scatter plots, and maps; and generates corresponding chart code using the corresponding chart library based on the selected chart type.

[0030] Optionally, the user uses the client to input task commands to the large model through text or voice.

[0031] Optionally, the structured query language is a statement that can be understood and executed by a computer.

[0032] Compared with the prior art, the method for generating indicators based on a large model provided by the present invention achieves at least the following beneficial effects:

[0033] The present invention provides a method for generating indicators from a large model, comprising the following steps: constructing an indicator knowledge base and performing vectorized storage to generate a knowledge base; constructing an indicator generation agent based on the large model, wherein the user inputs a task command to the large model using natural language through a client; the large model standardizes the task command to obtain a standard text content; the large model performs semantic recognition on the standard text content and matches it with the knowledge base; if a corresponding indicator is matched in the knowledge base, the knowledge base returns the application programming interface of the corresponding indicator to the large model; the large model initiates a call request to the application programming interface of the corresponding indicator, and the application programming interface of the indicator returns the corresponding data to the large model; the large model parses the returned corresponding data to obtain core data; assembles the indicator code for the core data to generate a standard code; if a corresponding indicator is matched in the knowledge base, the knowledge base returns the corresponding indicator application programming interface to the large model; the large model initiates a call request to the application programming interface of the corresponding indicator, and the application programming interface of the indicator returns the corresponding data to the large model; the large model parses the returned corresponding data to obtain core data; assembles the indicator code for the core data to generate a standard code; Match at least two corresponding indicators, the knowledge base transmits the matching results to the client through the big model, the user selects the corresponding indicator through the client, and performs the steps after matching a corresponding indicator in the knowledge base; if the corresponding indicator is not matched in the knowledge base, the task command is converted into structured query language through the big model; the big model calls the general application programming interface, sends the structured query language as a parameter to the application programming interface, and obtains interface data; the big model parses the interface data, calls the chart generation model, and generates the chart code; merges the standard code and the chart code, generates a result set, and completes the construction of the indicator generation agent based on the big model; no matter which way the user's query needs are met, the processing results will eventually be integrated together and returned to the user in a unified format for easy viewing and analysis by the user. The method provided by the present invention pre-screens the double-layer mechanism of the big model dynamic verification through the knowledge base, and the accuracy rate of key business scenario indicators reaches 99.2%, which is 32% higher than the pure big model solution, and the proportion of reusing existing indicator application programming interfaces and calculation logic exceeds 90%, and the system transformation cost is reduced by 70%. The response time for conventional indicators is ≤200ms, which is 5 times faster than direct generation of large models. The generation time of long-tail indicators is controlled within 1.5s.

[0034] Of course, any product implementing the present invention does not necessarily need to achieve all of the technical effects described above at the same time.

[0035] Further features and advantages of the present invention will become apparent from the following detailed description of exemplary embodiments of the present invention with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and, together with the description, serve to explain the principles of the invention.

[0037] Figure 1 It is a flow chart of a method for generating indicators from a large model of the present invention;

[0038] Figure 2 This is an example diagram of the large model in Example 2 matching multiple corresponding indicators. DETAILED DESCRIPTION

[0039] Various exemplary embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be noted that unless otherwise specifically stated, the relative arrangement of components and steps, numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention.

[0040] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the invention, its application, or uses.

[0041] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered part of the specification.

[0042] In all examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not limiting. Therefore, other examples of the exemplary embodiments may have different values.

[0043] It should be noted that like reference numerals and letters refer to like items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.

[0044] Example 1

[0045] The present invention provides a method for generating indicators using a large model, comprising the steps of:

[0046] S100: Build an indicator knowledge base and perform vectorized storage to generate a knowledge base;

[0047] S200: Construct an indicator generation agent based on a large model, including the following steps:

[0048] S201: The user inputs a task command to the large model using natural language through the client;

[0049] S202: The large model standardizes the task command to obtain standard text content;

[0050] S203: The large model performs semantic recognition on the standard text content and matches it with the knowledge base.

[0051] S204: If a corresponding indicator is matched in the knowledge base, the knowledge base returns the application programming interface of the corresponding indicator to the big model;

[0052] S2041: The big model initiates a call request to the application programming interface of the corresponding indicator, and the application programming interface of the indicator returns the corresponding data to the big model;

[0053] S2042: The large model parses the returned corresponding data to obtain core data;

[0054] S2043: Assemble the indicator codes of the core data and generate standard codes;

[0055] S205: If at least two corresponding indicators are matched in the knowledge base, the knowledge base transmits the matching results to the client through the large model. The user selects the corresponding indicator through the client and performs the steps after matching a corresponding indicator in the knowledge base.

[0056] S206: If no corresponding indicator is found in the knowledge base, the task command is converted into a structured query language through the large model;

[0057] S2061: The large model calls the general application programming interface, sends the structured query language as a parameter to the application programming interface, and obtains interface data;

[0058] S2062: The large model parses the interface data, calls the chart generation model, and generates chart code;

[0059] S207: Merge the standard code and chart code to generate a result set, completing the construction of the indicator generation agent based on the large model;

[0060] S208: If the client interface needs to display a chart, the large model calls the application programming interface of the indicator generation agent and returns the result set to the client.

[0061] Specifically, S100: construct an indicator knowledge base and perform vectorized storage to generate a knowledge base;

[0062] It should be noted that step S100 includes: indicator knowledge base construction and vectorized processing and the entire subject database table structure knowledge base preparation and vectorized storage.

[0063] It should be noted that the construction and vectorization processing of the indicator knowledge base and the thematic table structure knowledge base are the core links of data intelligence applications. Its core goal is to convert unstructured or semi-structured data into machine-understandable vector representations and build efficient storage and retrieval structures.

[0064] First, the indicator knowledge base is constructed and vectorized, including the following steps: standardizing indicator definitions, establishing an indicator metadata model, setting indicator thresholds, null value rates, duplicate values, and other verification rules; segmenting text fields such as indicator definitions and business descriptions to generate semantic vectors, and normalizing numerical features: performing Min-Max standardization or Z-Score normalization on numerical indicators to avoid dimensional differences affecting vector distance calculations; and multimodal fusion, combining text vectors and numerical vectors to generate a comprehensive vector through splicing or weighted summation.

[0065] Thematic database table structure knowledge bases must address issues such as complex data table structures, unclear field meanings, and difficulty in cross-table associations. These steps include: table structure parsing, extracting table names, field names, field types, primary keys, foreign keys, and other information through database metadata APIs (such as MySQL's INFORMATION_SCHEMA) or open-source tools (such as DataHub); field semantic annotation. Using business documentation or domain experts, fields are annotated with business meanings, a table-to-table relationship graph is constructed, and join conditions and dependencies are recorded. The table structure is converted into a graph structure, and a graph neural network (GNN) is used to generate table vectors. The field business meaning annotations are encoded to generate field vectors. Finally, the table vectors and field vectors are concatenated to generate a comprehensive vector.

[0066] Use vector database storage, generally Milvus, Pinecone and other vector databases to store indicator vectors, and store indicator metadata in a relational database (such as MySQL). The fields include indicator_id, name, definition, and vector_id (the ID of the associated vector database).

[0067] It should be noted that the indicator knowledge base is a comprehensive collection of information covering multiple dimensions related to business indicators. This information is crucial for understanding and applying indicators. Specifically, the indicator knowledge base should include the following key elements: Segment Name: This clearly identifies the business segment to which the indicator belongs. This facilitates categorization and management of the indicator, allowing clear distinction between indicators across different business segments and facilitating subsequent query and use. Indicator Name: This is the specific name of the indicator, a concise summary of the business meaning it represents. An accurate indicator name intuitively reflects the core content of the indicator, making it easy for users to quickly identify and understand it. Indicator Calculation Logic: This provides a detailed description of the indicator's calculation method and steps, which is key to accurate calculation. The calculation logic can range from simple mathematical operations to complex algorithms and data processing. Indicator Description: This provides a detailed explanation of the indicator, including its definition, purpose, and applicable scenarios. Indicator descriptions help users gain a deeper understanding of the indicator's meaning and value, enabling them to better apply the indicator for analysis and decision-making. Indicator Application Programming Interface (API): This provides an API related to the indicator, allowing users to easily access indicator data. The indicator application programming interface (API) provides a standardized way for data interaction between different systems, making data acquisition more efficient and convenient. Indicator return results: clarify the format and content of the data returned after the indicator is calculated. Understanding the indicator return results will help users correctly process and use the data and ensure the accuracy of subsequent analysis. Indicator display format: determine the presentation method of indicator data, such as tables, charts (bar charts, line charts, pie charts, etc.). The appropriate display format can more intuitively present the characteristics and trends of indicator data, making it easier for users to observe and analyze. Indicator item name: the name of each specific item in the indicator. For example, in sales indicators, it may include sales revenue, sales volume, sales cost and other indicator items.

[0068] To ensure that the AI agent can efficiently access this information during subsequent task execution, the data must be vectorized in advance. This vectorization allows for efficient representation and computation within the computational space of a large model, improving the model's ability to retrieve and process this information.

[0069] Vectorizing the entire thematic table structure and generating a knowledge base prepares the large model for subsequent use in generating Structured Query Language (SQL) statements. When generating SQL statements, the large model needs to understand the database's table structure information in order to accurately construct query statements and effectively query and analyze data. Vectorized storage can represent table structure information in the form of vectors, making it easier for the large model to process and utilize this information. In this way, the large model can generate Structured Query Language (SQL) statements that meet user needs based on the information in the table structure knowledge base, thereby enabling flexible query and analysis of thematic data.

[0070] S200: Construct an indicator generation agent based on a large model, including the following steps:

[0071] It should be noted that the indicator generation agent (Agent) is the core component of the entire system. It undertakes the important task of converting users' natural language query requirements into specific data and visualization results.

[0072] S201: The user inputs a task command to the large model using natural language through the client;

[0073] It should be noted that users use natural language input, including both text and voice input. Voice input requires a voice conversion plug-in to convert the speech into text. Natural language input significantly reduces the barrier to entry for users, allowing even non-technical professionals to easily express their query intent. For example, a user might enter a query like "List the distribution of technology companies in the city." This input method is more consistent with daily human communication habits and can improve practicality.

[0074] S202: The large model standardizes the task command to obtain standard text content;

[0075] It should be noted that after receiving the task command input by the user in natural language, the large model performs basic cleaning on it to remove interference factors such as special characters and obtain standard text content. Special characters, extra spaces or other non-critical information may affect the subsequent semantic recognition and matching process.

[0076] S203: The large model performs semantic recognition on the standard text content and matches it with the knowledge base.

[0077] It's important to note that large models' semantic recognition of standard text content first requires converting natural language into executable SQL / DSL or structured query language. Intent and entity recognition clarify user needs and perform rule matching. For example, input containing keywords like "how much" and "statistics" is considered a "query-type" intent. Model classification: Using a fine-tuned model using TextCNN or BERT, the input is categorized into "query," "comparison," "attribution," and other categories, and then matched against content stored in the knowledge base.

[0078] S204: If a corresponding indicator is matched in the knowledge base, the knowledge base returns the application programming interface of the corresponding indicator to the big model;

[0079] S2041: The big model initiates a call request to the application programming interface of the corresponding indicator, and the application programming interface of the indicator returns the corresponding data to the big model;

[0080] S2042: The large model parses the returned corresponding data to obtain core data;

[0081] S2043: Assemble the indicator codes of the core data and generate standard codes;

[0082] It should be noted that when a unique indicator can be matched in the indicator knowledge base, the system will return the application interface corresponding to the indicator; in step S2041, a call request is initiated based on the API interface corresponding to the matched indicator to obtain relevant data from the data source; the API interface provides a standardized way to obtain data, ensuring the accuracy and consistency of the data.

[0083] Step S2042 performs structured parsing on the returned standardized data: the returned data is usually standardized in json format, and the large model needs to perform structured parsing on these data; the large model parses the JSON string returned by the API and extracts the data part (core data part), which can be achieved through a variety of programming codes. This is not specifically limited in this embodiment. The API usually returns a string in JSON format. The string is a structured data format that can be parsed into an object or dictionary in a programming language. For example, in Python, you can use the json.loads() function to parse a JSON string into a Python dictionary; in JavaScript, you can use the JSON.parse() method to parse a JSON string into a JavaScript object; the parsed object usually contains multiple fields, of which the data field is the part we are most concerned about. The data field may contain the core data of the API request, such as query results, operation results, etc.

[0084] It should be noted that a JSON string is a text string in a specific format used to represent structured data. It follows the JSON (JavaScript Object Notation) syntax specification and is commonly used for data exchange and storage.

[0085] It should be noted that in step S2043, the indicator codes are assembled according to the returned results and the indicator display form: according to the returned data results and the display form of the indicators (such as tables, bar charts, line charts, etc.), the large model will assemble the indicator codes and visualize the data in an appropriate manner, so that users can intuitively understand the meaning and characteristics of the data.

[0086] Specifically, step 2043: assembling the indicator code of the core data to generate the standard code includes: importing the core data into the visualization library for creating the chart, defining the chart container, configuring the chart according to the indicator knowledge base, and obtaining the standard code for generating the chart.

[0087] It should be noted that step 2043 combines the aforementioned data with indicator code to generate standard code that complies with the requirements of Enterprise Charts (ECharts). ECharts is an open-source visualization library developed by Baidu and widely used for generating interactive charts. The standard ECharts code structure generally includes the following components: HTML structure: used to define the chart container. JavaScript initialization: used to configure chart options and initialize the chart. Configuration options: used to define the chart's style, data, interactions, etc.

[0088] S205: If at least two corresponding indicators are matched in the knowledge base, the knowledge base transmits the matching results to the client through the large model. The user selects the corresponding indicator through the client and performs the steps after matching a corresponding indicator in the knowledge base.

[0089] It should be noted that if multiple indicators are matched in step S205, the large model will add a question-and-answer session and return a list of matching results to the user for confirmation. This is because there may be uncertainty in multiple matching results, and the user needs to further clarify his or her needs and select the indicator that best meets his or her intentions.

[0090] The large model returns a matching result list to the user, detailing all matching indicator information, including indicator name and description. Based on the list, the user selects the record that best meets their needs. The large model then invokes step S204 for the selected record, continuing with data acquisition, parsing, and visualization.

[0091] S206: If no corresponding indicator is found in the knowledge base, the task command is converted into a structured query language through the large model;

[0092] S2061: The large model calls the general application programming interface, sends the structured query language as a parameter to the application programming interface, and obtains interface data;

[0093] S2062: The large model parses the interface data, calls the chart generation model, and generates chart code;

[0094] It should be noted that when the large model does not match any indicators in the indicator knowledge base, the NL2SQL function of the large model is called. NL2SQL (Natural Language to SQL) is a technology that converts natural language into SQL statements. It can generate a dynamic SQL statement based on the user's query requirements and the subject library table structure knowledge base, so as to call a general API to obtain the required data.

[0095] It should be noted that the large model's NL2SQL (Natural Language to SQL) function is a technology that automatically converts natural language query statements entered by users into SQL statements that can be executed on relational databases. Its core purpose is to lower the technical threshold for database queries, allowing non-professionals to interact with the database through natural language and efficiently obtain data.

[0096] Step S206 generates the corresponding SQL statement. Based on the user's needs, the macro model is invoked, combined with the subject database table structure knowledge base, and the predefined SQL Expert Prompt template is used to generate the corresponding SQL statement. The SQL Expert Prompt template contains important information such as field constraints and table association rules, which can guide the macro model to generate SQL statements that conform to the database structure and business logic.

[0097] It's important to note that prompt templates (prompt word templates) use structured text to encapsulate user requirements, task objectives, constraints, and other information as standardized inputs, guiding large models (such as GPT, Llama, and Wenxinyiyan) to generate expected outputs. Essentially, they serve as a "communication protocol" between humans and AI, optimizing input formats to improve output accuracy, consistency, and controllability.

[0098] For example, when a simple description appears, such as "Get user information older than 30 from the user table," the big model will convert this description into a specific SQL statement based on the predefined Prompt template, such as "SELECT * FRO Musers WHERE age>30;." The template specifies how the input information should be parsed and converted into various parts of SQL, such as determining the table name to be queried and the filter conditions. The big model then generates it according to the rules of this template, thereby converting the natural language description into SQL statements that the computer can understand and execute. The specific table names and field names need to rely on the subject library table structure knowledge base, which is a metadata description of the table structure. This allows the big model to know which tables currently exist in the system and which fields each table has, and to assemble the corresponding SELECT (keyword) statement based on this knowledge. In SQL, the SELECT statement is one of the most basic and commonly used commands, used to query data from the database. Its core function is to retrieve specified columns or rows from one or more tables and support operations such as conditional filtering, sorting, and aggregation.

[0099] It should be noted that in step S2061 , the general interface is called to read the interface data, and after generating the SQL statement, the general API interface is called, the generated SQL statement is passed to the interface as a parameter, and the required data is read from the database.

[0100] It should be noted that step S2063 includes: analyzing the structure of the interface data, the meaning of the fields and the relationship between the data in the large model; selecting the appropriate chart type according to the data characteristics and analysis objectives, and generating the corresponding chart code using the corresponding chart library based on the selected chart type.

[0101] Specifically, for the interface data obtained, the large model uses the chart generation expert prompt template to dynamically generate chart code. The chart generation expert prompt template will select the appropriate chart type (such as bar chart, line chart, pie chart, etc.) according to the characteristics of the data and user needs, and generate corresponding code to realize the visual display of the data.

[0102] It should be noted that chart types include: line charts, bar charts, pie charts, scatter plots, and maps; line charts can show the trend of data changes over time; bar charts can compare the size of data of different categories; pie charts can show the proportion relationship of data; scatter plots can show the correlation between two variables; maps are used to display geographical distribution data.

[0103] It should be noted that, depending on the selected chart type, the specified chart library is used. The chart library can generate corresponding code for Echarts, Plotly, Matplotlib, etc.

[0104] Echarts is an open source visualization library based on JavaScript. It provides a variety of chart types (such as line charts, bar charts, scatter plots, pie charts, maps, heat maps, etc.) and supports highly customized interactive functions (such as zooming, panning, data filtering, etc.).

[0105] Plotly is an open-source visualization library that supports multiple languages, including Python, R, JavaScript, and MATLAB. It provides over 40 chart types (such as line charts, scatter plots, heat maps, 3D charts, geographic charts, etc.) and supports high interactivity and dynamic updates. Plotly's strengths lie in its powerful interactivity and cross-platform capabilities. The generated charts can be directly embedded into web applications, Jupyter Notebooks, or exported to formats such as HTML, PNG, and SVG. Plotly also provides the Dash framework, which allows users to build complex interactive web applications and dashboards suitable for data analysis, scientific computing, business intelligence, and other fields.

[0106] Matplotlib is a 2D plotting library for Python that provides a MATLAB-like plotting interface and supports static, interactive, and animated visualizations. It supports a variety of chart types (such as line charts, scatter plots, bar charts, pie charts, histograms, and contour plots), and almost all chart elements are highly customizable (such as colors, fonts, axes, and legends). Matplotlib's main advantages lie in its flexibility and strong ecosystem integration capabilities. It seamlessly collaborates with libraries such as NumPy, Pandas, and Seaborn, and is widely used in academic research, data analysis, engineering graphics, and other fields.

[0107] S207: Merge the standard code and chart code to generate a result set, completing the construction of the indicator generation agent based on the large model;

[0108] It should be noted that the processing results of the above three branches are merged to generate the final result set. No matter how the user's query needs are met, the processing results will eventually be integrated together and returned to the user in a unified format for easy viewing and analysis.

[0109] S208: If the client interface needs to display a chart, the large model calls the application programming interface of the indicator generation agent and returns the result set to the client.

[0110] It also includes: S209: the client receives the result set, renders and displays the result set.

[0111] In some optional embodiments, the large model standardizes task commands using regular expressions. Replacing all matched special characters with empty strings effectively removes these interfering factors, making the input text more standardized and easier to process. For example, to remove special characters like "!" and "@" from the input, a regular expression can be used to replace all matched special characters with empty strings, retaining only the text content with actual semantics.

[0112] It should be noted that long-tail metrics are used to measure the "long tail" of a knowledge base, i.e., the performance of uncommon, low-frequency, niche, or non-core segments. The long-tail metrics generated in this application take less than 1.5 seconds to generate. Rapidly generating long-tail API call metrics (such as performance data for low-frequency interfaces) can optimize interface design and enhance user experience.

[0113] Example 2

[0114] The present invention provides a method for generating indicators from a large model, generating a knowledge base of examples displayed in a tabular form, including modules, primary functions, secondary functions, indicator item descriptions, indicator types, data provision methods, whether to call parameters, interface addresses, return value formats and data items. The module includes two city sections. The primary function corresponding to the first city section is city description, the secondary function is city description, the indicator item is a city introduction, and the indicator item description is a text description of the city as the political, economic, financial, and cultural and tourism center of a certain city, as well as a text description of the area, grid, community, street, and population. The indicator type is text, the data is provided through an interface, and no parameters are required. The interface address is http: / / ip:port / apps / getCityDescribe, the return value format is json, and the data item is {content}. The first-level function and second-level function corresponding to the second city section are city view, the indicator item is a city atlas, and the indicator item descriptions are a carousel of scenic spots such as a certain mountain, a certain spring, a certain lake, a certain river, a certain city, and a certain district. The indicator type is a pie chart, the data is provided through an interface, the call parameter is $(city), the interface address is http: / / ip:port / apps / getCityImage, the return value format is json, and the data item is {scenic spot: imageURL, scenic spot 2: imageURL2,...}.

[0115] Table 1 Example table of indicator knowledge base

[0116]

[0117] The user enters a task command into the big model: "Can you give me an introduction to the city?" The big model standardizes the task command using regular expressions, removing redundant characters. The big model then matches the first entry in the knowledge base. The big model issues a call request, and the indicator's application programming interface returns the corresponding data to the big model. The big model performs structured parsing on the returned data to obtain the core data. Based on the returned data results and the indicator's display format (such as a table, bar chart, or line graph), the big model parses the JSON string returned by the API and extracts the "data" portion. It then imports the core data into the visualization library for creating charts, defines the chart container, and configures the chart according to the indicator knowledge base, obtaining the standard code for generating charts.

[0118] If the user inputs a task command to the big model and the big model matches multiple corresponding indicators, the big model will transmit the multiple indicator contents to the client, such as Figure 2 As shown, the user selects the corresponding indicator through the client and performs the steps after matching a corresponding indicator in the knowledge base; if the corresponding indicator is not matched in the knowledge base, for example, the user inputs a task command to the big model: obtain user information older than 30 from the user table, the big model will convert this description into a specific SQL statement according to the predefined Prompt template. The Prompt template specifies how the input information should be parsed and converted into various parts of SQL, such as determining the table name to be queried, the filter conditions, etc. The big model generates according to the rules of this template, thereby converting the natural language description into SQL statements that the computer can understand and execute. The table name and field name of the entity need to rely on the knowledge base mentioned above, which is the metadata description of the table structure. The big model assembles the corresponding select (keyword) statement based on the existing table and the fields in the table. After generating the SQL statement, it calls the general API interface and passes the generated SQL statement as a parameter to the interface to read the required data from the database; for the obtained interface data, the big model uses the chart generation expert prompt template to generate chart code. The chart generation expert prompt template selects the appropriate chart type (such as bar charts, line charts, pie charts, etc.) according to the characteristics of the data and user needs, and generates corresponding code to realize the visualization of the data.

[0119] From the above embodiments, it can be seen that the method for generating indicators for a large model provided by the present invention achieves at least the following beneficial effects:

[0120] The present invention provides a method for generating indicators from a large model, comprising the following steps: constructing an indicator knowledge base and performing vectorized storage to generate a knowledge base; constructing an indicator generation agent based on the large model, wherein the user inputs a task command to the large model using natural language through a client; the large model standardizes the task command to obtain a standard text content; the large model performs semantic recognition on the standard text content and matches it with the knowledge base; if a corresponding indicator is matched in the knowledge base, the knowledge base returns the application programming interface of the corresponding indicator to the large model; the large model initiates a call request to the application programming interface of the corresponding indicator, and the application programming interface of the indicator returns the corresponding data to the large model; the large model parses the returned corresponding data to obtain core data; assembles the indicator code into the core data to generate a standard code; if a corresponding indicator is matched in the knowledge base, the knowledge base returns the corresponding indicator application programming interface to the large model; the large model initiates a call request to the application programming interface of the corresponding indicator, and the application programming interface of the indicator returns the corresponding data to the large model; the large model parses the returned corresponding data to obtain core data; assembles the indicator code into the core data to generate a standard code; Match at least two corresponding indicators, the knowledge base transmits the matching results to the client through the big model, the user selects the corresponding indicator through the client, and performs the steps after matching a corresponding indicator in the knowledge base; if the corresponding indicator is not matched in the knowledge base, the task command is converted into structured query language through the big model; the big model calls the general application programming interface, sends the structured query language as a parameter to the application programming interface, and obtains interface data; the big model parses the interface data, calls the chart generation model, and generates the chart code; merges the standard code and the chart code, generates a result set, and completes the construction of the indicator generation agent based on the big model; no matter which way the user's query needs are met, the processing results will eventually be integrated together and returned to the user in a unified format for easy viewing and analysis by the user. The method provided by the present invention pre-screens the double-layer mechanism of the big model dynamic verification through the knowledge base, and the accuracy rate of key business scenario indicators reaches 99.2%, which is 32% higher than the pure big model solution, and the proportion of reusing existing indicator application programming interfaces and calculation logic exceeds 90%, and the system transformation cost is reduced by 70%. The response time for conventional indicators is ≤200ms, which is 5 times faster than direct generation of large models. The generation time of long-tail indicators is controlled within 1.5s.

[0121] Although some specific embodiments of the present invention have been described in detail by way of examples, it should be understood by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the present invention. It should be understood by those skilled in the art that modifications may be made to the above embodiments without departing from the scope and spirit of the present invention. The scope of the present invention is defined by the appended claims.

Claims

1. A method for generating indicators based on a large model, characterized in that: include: Including steps: Build an indicator knowledge base and perform vectorized storage to generate a knowledge base; Constructing an indicator-generating agent based on a large model includes the following steps: The user inputs task commands to the large model using natural language through the client; The large model standardizes the task command to obtain standard text content; The large model performs semantic recognition on the standard text content and matches it with the knowledge base; If a corresponding indicator is matched in the knowledge base, the knowledge base returns the application programming interface of the corresponding indicator to the large model; The large model initiates a call request to the application programming interface of the corresponding indicator, and the application programming interface of the indicator returns the corresponding data to the large model; The large model parses the corresponding data returned to obtain core data; Assembling indicator codes for the core data to generate standard codes; If at least two corresponding indicators are matched in the knowledge base, the knowledge base transmits the matching results to the client through the large model, and the user selects the corresponding indicator through the client and performs the steps after matching a corresponding indicator in the knowledge base; If the corresponding indicator is not matched in the knowledge base, converting the task command into a structured query language through the large model; The large model calls a general application programming interface, sends the structured query language as a parameter to the application programming interface, and obtains interface data; The large model parses the interface data, calls the chart generation model, and generates chart code; Merging the standard code and the chart code to generate a result set, completing the construction of the indicator generation agent based on the large model; If the client interface needs to display a chart, the large model calls the application programming interface of the indicator generation agent and returns the result set to the client.

2. The method for generating indicators from a large model according to claim 1, characterized in that: The indicator knowledge base includes: sector name, indicator calculation logic, indicator description, indicator application programming interface, indicator return result, indicator display form and indicator item name.

3. The method for generating indicators from a large model according to claim 1, characterized in that: The large model standardizes task commands through regular expressions.

4. The method for generating indicators from a large model according to claim 1, characterized in that: The indicator code assembly of the core data to generate the standard code includes: importing the core data into a visualization library for creating charts, defining a chart container, configuring the chart according to the indicator knowledge base, and obtaining the standard code for generating the chart.

5. The method for generating indicators from a large model according to claim 1, characterized in that: The large model parses the interface data, calls the chart generation model, and generates chart code, including the following steps: the large model analyzes the structure of the interface data, the meaning of the fields, and the relationship between the data; selects a suitable chart type based on the data characteristics and analysis objectives, and generates the corresponding chart code using the corresponding chart library based on the selected chart type.

6. The method for generating indicators from a large model according to claim 5, characterized in that: The chart types include: line chart, bar chart, pie chart, scatter chart, and map.

7. The method for generating indicators from a large model according to claim 1, characterized in that: The user uses the client to input task commands to the large model through text or voice.

8. The method for generating indicators from a large model according to claim 1, characterized in that: The structured query language is a statement that can be understood and executed by a computer.

Citation Information

Patent Citations

  • Method and system for improving accuracy rate of converting large model text to SQL based on specific scene

    CN119046311A

  • Text2SQL cue word index rewriting method, system and equipment for realizing retrieval enhancement and medium

    CN119829742A

  • Artificial intelligence based generation of data connectors

    US20240378390A1