Commercial condition insight method and device based on large language model, electronic equipment and medium

Through the business situation insight method based on the large language model, the business situation NL2SQL model was built, which solved the problem of low data query efficiency and accuracy in business opportunity and business situation analysis, and achieved efficient and accurate business situation data query and analysis support.

CN119621761APending Publication Date: 2025-03-14CHINA TELECOM CORP LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411756270.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-02
Publication Date
2025-03-14

AI Technical Summary

Technical Problem

In the analysis of business opportunities and business situation data, the efficiency and accuracy of data query are affected by the scheduling problems caused by the need to understand and task transfer among multiple roles. NL2SQL technology relies on the richness of sentence templates, resulting in high system operation costs and affecting efficiency and accuracy.

Method used

Using a business situation insight method based on a large language model, we obtain preset open source NL2SQL data sets and internal business situation data, build open source fine-tuning samples and business situation fine-tuning samples, fine-tuning the base model, and obtain the business situation NL2SQL model. This model can generate target SQL statements from natural language input, implement database query and integrate presentation.

Benefits of technology

It improves the efficiency and accuracy of business information data query, reduces the scheduling problems caused by inter-role requirements understanding and task transfer, reduces system operation costs, and enhances the support capabilities of business information insight analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119621761A_ABST
    Figure CN119621761A_ABST
Patent Text Reader

Abstract

The invention discloses a business condition insight method and device based on a large language model, electronic equipment and a medium, and the method comprises the steps: obtaining a preset open source NL2SQL data set and internal business condition data, and constructing an open source fine tuning sample and a business condition fine tuning sample according to the open source NL2SQL data set and the internal business condition data; according to the open source fine tuning sample and the business condition fine tuning sample, performing fine tuning on a preset base large model to obtain a business condition NL2SQL large model; obtaining a question input statement, and performing task splitting on the question input statement to obtain a target index and a target dimension; constructing a target prompt statement according to the target index and the target dimension, and inputting the target prompt statement into the business condition NL2SQL large model to obtain a target SQL statement; and querying a database according to the target SQL statement to obtain target data, and performing content integration and rendering display on the target data. The business condition data query efficiency and accuracy are improved, and the method can be widely applied to the technical field of artificial intelligence.
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 technology, and in particular to a business insight method, device, electronic device and medium based on a large language model. Background Art

[0002] In the business opportunity and information data analysis scenario, data is generally stored in a structured manner in the database. When the operation staff has data analysis or query requirements, they need to pass the requirements to professional data analysts, who understand the requirements and database table structure and write SQL / HIVE query statements to obtain data, and then pass the results to the operation staff. The overall process spans multiple roles, and the alignment of requirements between roles and the scheduling problems caused by task transfer seriously affect the efficiency of data analysis, especially seriously hindering the efficiency of heuristic data mining and exploration.

[0003] With the development of AI technology, the field of data intelligence continues to innovate, and a series of technologies and products such as NL2SQL have emerged. The principle of NL2SQL is generally to realize the generation of natural language to SQL through NLP algorithm. This method is heavily dependent on the richness of sentence templates. If the template is not covered, SQL generation cannot be completed, resulting in excessively high system operating costs and affecting the efficiency and accuracy of business data queries.

[0004] Terminology explanation:

[0005] LLM (Large Language Model): refers to a deep learning model trained with a large amount of text data, which can generate natural language text or understand the meaning of language text. Large language models can handle a variety of natural language tasks, such as text classification, question answering, dialogue, etc., and are an important path to artificial intelligence. Summary of the invention

[0006] The purpose of the present invention is to solve one of the technical problems existing in the prior art to at least a certain extent.

[0007] To this end, an object of an embodiment of the present invention is to provide a business insight method based on a large language model, which improves the efficiency and accuracy of business data query.

[0008] Another object of an embodiment of the present invention is to provide a business insight device based on a large language model.

[0009] In order to achieve the above technical objectives, the technical solutions adopted by the embodiments of the present invention include:

[0010] On the one hand, an embodiment of the present invention provides a business insight method based on a large language model, comprising the following steps:

[0011] Obtaining a preset open source NL2SQL data set and internal business data, and constructing an open source fine-tuning sample and a business fine-tuning sample according to the open source NL2SQL data set and the internal business data respectively;

[0012] Fine-tune the preset base big model according to the open source fine-tuning sample and the business situation fine-tuning sample to obtain the business situation NL2SQL big model;

[0013] Obtain a problem input statement, and perform task decomposition on the problem input statement to obtain target indicators and target dimensions;

[0014] Construct a target prompt statement according to the target indicator and the target dimension, and input the target prompt statement into the business information NL2SQL big model to obtain a target SQL statement;

[0015] The database is queried according to the target SQL statement to obtain the target data, and then the target data is integrated and rendered for display.

[0016] Furthermore, in one embodiment of the present invention, the open source fine-tuning sample is constructed by the following steps:

[0017] Determine a first data table description, a first problem description, and a first SQL statement corresponding to the first data sample according to the open source NL2SQL data set;

[0018] Construct a first annotation triple according to the first data table description, the first problem description, and the first SQL statement;

[0019] The first labeled triplet is normalized to obtain the open source fine-tuning sample.

[0020] Furthermore, in one embodiment of the present invention, the business information fine-tuning sample is constructed by the following steps:

[0021] Determine the database table, business information and real business content according to the internal business data;

[0022] Determine slot information according to the database table and the business information, and construct a question template according to the business information;

[0023] Filling the slot information into the problem template to obtain a problem slot template, and filling the real business content into the problem slot template to obtain a second problem description;

[0024] Determine a second data table description according to the database table, and convert the second problem description into an SQL statement according to the second data table description to obtain a second SQL statement;

[0025] A second annotated triple is constructed according to the second data table description, the second problem description, and the second SQL statement, and the second annotated triple is used as the business situation fine-tuning sample.

[0026] Further, in one embodiment of the present invention, the preset base big model is fine-tuned according to the open source fine-tuning sample and the business situation fine-tuning sample to obtain the business situation NL2SQL big model, which specifically includes:

[0027] Fine-tune the base large model in full according to the open source fine-tuning sample to obtain the basic NL2SQL large model;

[0028] The basic NL2SQL large model is fine-tuned for a second time according to the business situation fine-tuning sample to obtain the business situation NL2SQL large model.

[0029] Further, in one embodiment of the present invention, the task decomposition of the problem input statement to obtain target indicators and target dimensions specifically includes:

[0030] Performing lexical analysis and named entity recognition on the question input sentence to obtain a first entity sequence;

[0031] Performing entity extraction on the first entity sequence to obtain time parameters, object parameters, and dimension parameters;

[0032] Constructing an indicator tree according to the time parameter, the object parameter and the dimension parameter;

[0033] Determine the target indicator and candidate dimensions according to the indicator tree, and calculate the JS divergence between each candidate dimension and the target indicator;

[0034] The candidate dimension with the largest JS divergence is selected as the target dimension.

[0035] Further, in an embodiment of the present invention, the constructing the indicator tree according to the time parameter, the object parameter and the dimension parameter specifically includes:

[0036] Performing indicator type identification on the time parameter and the object parameter to obtain multiple indicator types and corresponding indicator contents;

[0037] Relationship identification is performed on multiple indicator contents of the same indicator type to obtain the relationship between the indicators;

[0038] The indicator tree is constructed according to the indicator type, the indicator content, the relationship between the indicators and the dimension parameters.

[0039] Further, in one embodiment of the present invention, constructing a target prompt statement according to the target indicator and the target dimension specifically includes:

[0040] Obtaining a preset prompt template and a data table description of the business information NL2SQL large model;

[0041] The target prompt statement is constructed according to the data table description, the question input statement, the target indicator, the target dimension and the prompt template.

[0042] On the other hand, an embodiment of the present invention provides a business insight device based on a large language model, including:

[0043] A fine-tuning sample construction module is used to obtain a preset open source NL2SQL data set and internal business information data, and to construct an open source fine-tuning sample and a business information fine-tuning sample according to the open source NL2SQL data set and the internal business information data respectively;

[0044] A large model fine-tuning module, used to fine-tune the preset base large model according to the open source fine-tuning sample and the business situation fine-tuning sample to obtain the business situation NL2SQL large model;

[0045] A task decomposition module is used to obtain a problem input statement, and perform task decomposition on the problem input statement to obtain a target indicator and a target dimension;

[0046] An SQL statement output module is used to construct a target prompt statement according to the target indicator and the target dimension, and input the target prompt statement into the business information NL2SQL big model to obtain a target SQL statement;

[0047] The database query module is used to query the database according to the target SQL statement to obtain the target data, and then perform content integration and rendering display on the target data.

[0048] On the other hand, an embodiment of the present invention provides an electronic device, comprising a memory, a processor, a program stored in the memory and executable on the processor, and a data bus for realizing connection and communication between the processor and the memory, wherein the program, when executed by the processor, realizes the business insight method based on the large language model as described above.

[0049] On the other hand, an embodiment of the present invention further provides a storage medium, which is a computer-readable storage medium used for computer-readable storage, and the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the business insight method based on the large language model as described above.

[0050] The advantages and beneficial effects of the present invention will be partly given in the following description, partly become apparent from the following description, or be understood through the practice of the present invention:

[0051] The embodiment of the present invention obtains a preset open source NL2SQL data set and internal business data, constructs an open source fine-tuning sample and a business fine-tuning sample according to the open source NL2SQL data set and the internal business data, respectively, fine-tunes the preset base large model according to the open source fine-tuning sample and the business fine-tuning sample, obtains the business NL2SQL large model, obtains the problem input statement, performs task decomposition on the problem input statement to obtain the target indicator and target dimension, constructs the target prompt statement according to the target indicator and target dimension, and inputs the target prompt statement into the business NL2SQL large model to obtain the target SQL statement, queries the database according to the target SQL statement, obtains the target data, and then integrates the content and renders the target data. The embodiment of the present invention realizes the business information query and number-asking functions with the help of the semantic understanding and dialogue capabilities of the large model, thereby assisting the business information insight analysis and improving the efficiency and accuracy of the business information data query. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] In order to more clearly illustrate the technical solution in the embodiments of the present invention, the following introduction is made to the drawings required for use in the embodiments of the present invention. It should be understood that the drawings introduced below are only for the convenience of clearly describing some embodiments of the technical solution of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0053] Figure 1 A flowchart of a method for business insight based on a large language model provided by an embodiment of the present invention;

[0054] Figure 2 A schematic diagram of an online service part and an offline processing part of a business insight method based on a large language model provided in an embodiment of the present invention;

[0055] Figure 3 A step flow chart of step S101 provided in an embodiment of the present invention;

[0056] Figure 4 Another step flow chart of step S101 provided in an embodiment of the present invention;

[0057] Figure 5 A step flow chart of step S102 provided in an embodiment of the present invention;

[0058] Figure 6 A schematic diagram of querying questions and displaying results based on the business information NL2SQL big model provided by an embodiment of the present invention;

[0059] Figure 7 A step flow chart of step S103 provided in an embodiment of the present invention;

[0060] Figure 8 A step flow chart of step S1033 provided in an embodiment of the present invention;

[0061] Fig. 9 A step flow chart of step S104 provided in an embodiment of the present invention;

[0062] Fig.10 A schematic diagram of the structure of a business insight device based on a large language model provided by an embodiment of the present invention;

[0063] Fig.11 A schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present invention;

[0064] Fig.12 A schematic diagram of the structure of a storage medium provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0065] Embodiments of the present invention are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be understood as limitations on the present application. It should be noted that, although the functional module division is performed in the system schematic diagram and the logical order is shown in the flow chart, in some cases, the steps shown or described may be performed in a different order from the module division in the system schematic diagram or the flow chart. For the step numbers in the following embodiments, they are only set for the convenience of explanation, and the order between the steps is not limited in any way. The execution order of each step in the embodiment can be adaptively adjusted according to the understanding of those skilled in the art.

[0066] In the description of the present invention, the meaning of "a plurality" is two or more. If there is a description of the first or the second, it is only for the purpose of distinguishing the technical features, and it cannot be understood as indicating or implying the relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features. In addition, unless otherwise defined, all technical and scientific terms used in this document have the same meaning as those commonly understood by technicians in the technical field of this application. The terms used in this document are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.

[0067] The business insight method based on the large language model provided in the embodiment of the present application can be applied to the terminal, can also be applied to the server side, and can also be software running in the terminal or the server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a set-top box, etc.; the server side can be configured as an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the business insight method based on the large language model, etc., but is not limited to the above forms.

[0068] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0069] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with the relevant laws, regulations, and standards of the relevant countries and regions. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.

[0070] The present invention aims to provide a business insight method based on a large language model, which is suitable for business insight analysis in multi-table data scenarios. Through an end-to-end solution generated from natural language to SQL, with the help of the semantic understanding and dialogue capabilities of the large model, business information query and number-asking functions are realized, thereby assisting business insight analysis and improving the efficiency and accuracy of business data query.

[0071] like Figure 1 FIG. 1 is a flowchart of a method for business insight based on a large language model provided by an embodiment of the present invention. Figure 1 The embodiment of the present invention provides a business insight method based on a large language model, which specifically includes the following steps:

[0072] S101, obtaining a preset open source NL2SQL data set and internal business data, and constructing an open source fine-tuning sample and a business fine-tuning sample according to the open source NL2SQL data set and the internal business data respectively;

[0073] S102, fine-tuning the preset base large model according to the open source fine-tuning sample and the business situation fine-tuning sample to obtain the business situation NL2SQL large model;

[0074] S103, obtaining a problem input statement, and performing task decomposition on the problem input statement to obtain target indicators and target dimensions;

[0075] S104, construct a target prompt statement according to the target indicator and the target dimension, and input the target prompt statement into the business information NL2SQL big model to obtain a target SQL statement;

[0076] S105. Query the database according to the target SQL statement to obtain target data, and then integrate and render the target data.

[0077] like Figure 2 The figure shows a schematic diagram of the online service part and the offline processing part of the business insight method based on the large language model provided by an embodiment of the present invention. The present invention implements NL2SQL by using the large model technology to achieve the use of natural language to query the database for business information. It is mainly divided into two parts: LLM offline training (offline processing part) and LLM online insight (online service part), wherein:

[0078] LLM offline training: First, select the base large model, use the open source NL2SQL dataset to fine-tune the base large model, and obtain the NL2SQL large model; then construct scenario sample data for the business scenario, combine the business database table schema, and generate business fine-tuning samples; finally, use the sample to perform secondary fine-tuning on the NL2SQL large model to obtain the business NL2SQL large model.

[0079] LLM online insights: By accepting users' natural language questions, they are input into the offline trained business information NL2SQL large model to obtain relevant SQL statements; then the SQL statements are used to query the database to obtain the target data; finally, through content integration, the data is rendered and output on the front-end page.

[0080] like Figure 3 FIG. 1 is a flowchart of step S101 provided in an embodiment of the present invention, referring to FIG. Figure 4 As an optional implementation, the open source fine-tuning sample is constructed by the following steps:

[0081] S1011. Determine a first data table description, a first problem description, and a first SQL statement corresponding to a first data sample according to the open source NL2SQL data set;

[0082] S1012, constructing a first annotation triple according to the first data table description, the first problem description, and the first SQL statement;

[0083] S1013: Normalize the first labeled triplet to obtain an open source fine-tuning sample.

[0084] Specifically, open source NL2SQL datasets are collected, including CSpider, BIRD, and DuSQL, all of which are manually annotated NL2SQL datasets for open source scenarios; the sample annotation format of the above datasets is unified, and the annotation triple format is defined as follows: (schema, question, SQL), where schema is the description of the data table, question is the question, and SQL is the SQL statement corresponding to the question; the annotation triples are normalized, that is, the translation operation is performed; the English dataset is converted into Chinese form through Baidu translation and manual verification, and the open source fine-tuning samples can be obtained.

[0085] like Figure 4 FIG. 1 is another step flow chart of step S101 provided in an embodiment of the present invention, referring to FIG. Figure 4 As an optional implementation, the business information fine-tuning sample is constructed by the following steps:

[0086] S1014. Determine the database table, business information and real business content based on the internal business data;

[0087] S1015. Determine slot information according to the database table and the business information, and construct a question template according to the business information;

[0088] S1016. Fill the slot information into the problem template to obtain the problem slot template, and fill the real business content into the problem slot template to obtain a second problem description;

[0089] S1017, determining a second data table description according to the database table, and converting the second problem description into an SQL statement according to the second data table description to obtain a second SQL statement;

[0090] S1018. Construct a second annotated triple according to the second data table description, the second problem description, and the second SQL statement, and use the second annotated triple as a sample for fine-tuning the business situation.

[0091] Specifically, the process of generating samples for tables and data in business scenarios is as follows:

[0092] 1) Slot information S i Definition, slot information is customized based on database table and business information;

[0093] 2) Question Template Q i Definition: Question templates can be used to construct a variety of questions in combination with business;

[0094] 3) The slot information S i Fill in the question template Q i To form a problem slot template (Q i |S i );

[0095] 4) Add the real business content to the problem slot template (Q i |S i ) to fill in to construct the instantiation problem;

[0096] 5) Manually convert the SQL statements of the instantiated problems by referring to the table schema;

[0097] 6) Summarize the above content into triples (schema, question, SQL) to obtain the business information fine-tuning sample.

[0098] The following is an example of constructing a business insight triplet.

[0099] Get the sales database table sales_table, and create the table statement as follows:

[0100]

[0101]

[0102] Slot Information i , which are id (primary key), org (organization name), sales_amount (sales amount) and month (month);

[0103] Question TemplateQ i , an example is as follows:

[0104] “What is the {metric} situation at {dim_org} at {Time}?”

[0105] Time is the time slot, dim_org is the organization name slot, and metric is the indicator slot. Each slot has several candidates based on business information. These candidate information comes from specific records in the database table.

[0106] Sampling from slot candidates, such as Time = "March 2024", dim_org = "Beijing Branch", metric = "sales", and then using this information to fill in the question template, we get an instantiated question: "What is the sales of the Beijing branch in March 2024?"

[0107] Manually translate the instantiated problem into SQL statements based on the structure of sales_table, as follows:

[0108] “SELECT sales_amount FROM sales_table WHERE org = "Beijing Branch" and month = 202403”

[0109] A triple data sample is constructed:

[0110]

[0111] like Figure 5 FIG. 1 is a flow chart of step S102 provided in an embodiment of the present invention, referring to FIG. Figure 5 As an optional implementation, the preset base model is fine-tuned according to the open source fine-tuning sample and the business fine-tuning sample to obtain the business NL2SQL model, which specifically includes:

[0112] S1021. Fine-tune the base large model in full according to the open source fine-tuning samples to obtain the basic NL2SQL large model;

[0113] S1022. Perform secondary fine-tuning on the basic NL2SQL large model according to the business situation fine-tuning sample to obtain the business situation NL2SQL large model.

[0114] Specifically, the base big model is selected by comprehensively considering the big model's own capabilities and community activity. The base big model is fully fine-tuned according to the open source fine-tuning samples to obtain the basic NL2SQL big model. The basic NL2SQL big model is fine-tuned again according to the business fine-tuning samples to obtain the business NL2SQL big model. The details are as follows:

[0115] 1) LLM fine-tuning based on the open source NL2SQL dataset: The principle of the NL2SQL model is to train a large model so that the model satisfies the aforementioned triple constraints, that is, SQL = model (schema, question). The training method is similar to the traditional machine learning method, and the parameters in the model are updated by gradient descent, so that the model becomes the maximum likelihood estimate of all the aforementioned triple constraints; the full-scale fine-tuning algorithm is used to train and fine-tune the base large model. After the model converges, the basic NL2SQL large model is obtained; at this time, the large model has the ability to convert general natural language to SQL language, and can be used as a new base LLM for data intelligent query applications θ , where θ is the trained parameter;

[0116] 2) Fine-tuning of LLM based on the business data set of business scenarios: Since the number of samples in this scenario is limited, generally between dozens and hundreds, fine-tuning is adopted on the basic NL2SQL large model; a prompt-type large language model is constructed based on the input-output examples. The optimization goal of this model is:

[0117]

[0118] Among them, q i is a specific single data sample (schema, question), M is a data sample set, k is the number of data sample sets, σ(q i ,M) represents a representation space used to match sample data q i Related information, S i Possible SQL corresponding to sample data;

[0119] An example of an input-output construction prompt large language model is as follows:

[0120]

[0121]

[0122] The minimized empirical loss for fine-tuning the above model objective is defined as follows:

[0123]

[0124] Among them, L is the loss function that measures the difference between generated SQL and target SQL

[0125] When the minimized experience loss no longer decreases or tends to be stable, the business situation NL2SQL large model is finally obtained.

[0126] like Figure 6The following is a schematic diagram of querying questions and displaying results based on the business information NL2SQL big model provided by an embodiment of the present invention. Figure 6 The question query process of the embodiment of the present invention is further illustrated with reference to the accompanying drawings.

[0127] like Figure 7 FIG. 1 is a flow chart of step S103 provided in an embodiment of the present invention, referring to FIG. Figure 7 As an optional implementation, the problem input statement is further decomposed into tasks to obtain target indicators and target dimensions, which specifically include:

[0128] S1031, performing lexical analysis and named entity recognition on the question input sentence to obtain a first entity sequence;

[0129] S1032, extracting entities from the first entity sequence to obtain time parameters, object parameters, and dimension parameters;

[0130] S1033, constructing an indicator tree according to time parameters, object parameters, and dimension parameters;

[0131] S1034. Determine the target indicator and candidate dimensions according to the indicator tree, and calculate the JS divergence between each candidate dimension and the target indicator;

[0132] S1035. Select the candidate dimension with the largest JS divergence as the target dimension.

[0133] like Figure 8 FIG. 1 is a flow chart of step S1033 provided in an embodiment of the present invention, referring to FIG. Figure 8 As an optional implementation, an indicator tree is constructed according to the time parameter, the object parameter and the dimension parameter, which specifically includes:

[0134] S10331. Identify the indicator type of the time parameter and the object parameter to obtain multiple indicator types and corresponding indicator contents;

[0135] S10332, identifying the relationship between multiple indicator contents of the same indicator type to obtain the relationship between the indicators;

[0136] S10333. Construct an indicator tree based on indicator type, indicator content, relationship between indicators and dimension parameters.

[0137] Specifically, the number-checking task is broken down by lexical analysis, building an indicator tree, and extracting dimensions, as follows:

[0138] 1) Perform lexical analysis and named entity recognition on user question input;

[0139] 2) The longest common subsequence LCS technique is used to recall the content of the output of step S3-1. For the extracted content S1[i] and the content to be recalled S2[j], if S1[i] and S2[j] are the same, the common subsequence is S1[i]; if S1[i] and S2[j] are different, the common subsequence is the common subsequence of S1[0] to S1[i-1] and S2[0] to S2[j], or the longer subsequence of the common subsequence of S1[0] to S1[i] and S2[0] to S2[j-1]. The recursive formula is as follows:

[0140]

[0141] 3) Combine time, index, grouping, sorting, and filtering to output the corresponding available parameters:

[0142] a. Time parameters are extracted as follows:

[0143] First, output the recall sequence S of length n seq ={s1,s2,L,s n}, use the time format to perform time-first extraction:

[0144] T is = {P(s i )|P(s i )∈C promopt ,i∈[1,n]}

[0145] Where P(g) is the time information template conversion function, which converts irregular time input into the standard time output required for data table query, C promopt To preset the completion time template, check the accuracy and compliance of the function conversion time.

[0146] Secondly, the relationship is confirmed based on the number of extraction times. The specific confirmation process is as follows:

[0147] For security reasons, the database restricts the modification and deletion of SQL in the business opportunity model. Therefore, the time relationship under the query operation is divided into three categories: no relationship query, comparison relationship, and parallel relationship.

[0148] If T is = 1, no need to consider the time relationship, directly enter the conversion time into the database for corresponding information query, at this time the time parameter constitutes the query (T is ).

[0149] If T is >1. The time relationship is determined as follows:

[0150] (1) The logical relationship words and sentences provided in the above steps are vectorized using a vector coding model, and word meaning matching is performed in a preset comparison word meaning vector library and parallel relationship. The matching calculation is as follows:

[0151]

[0152] Where d is the vector dimension after word encoding, j represents the defined relationship category, which is 2 in the embodiment of the present invention, n represents the total number of semantic vectors of the jth relationship, and v w,k Represents the kth vector value in the input vector, v i,k,j Represents the kth vector value of the jth relationship category at the ith semantic vector.

[0153] (2) According to the result of step (1), the corresponding time relationship is determined, and the time parameters are constructed according to the order of time appearance. The construction example is l(sort(T is )), l is the relation result, sort q (T is ) indicates the result of sorting the translated time sequence according to the time when the output problem occurred.

[0154] b. Object parameters are extracted as follows:

[0155] Different from time information extraction, since the large model can only be queried and cannot be modified, the query objects are all parallel relationships, and the object parameters are constructed directly based on the parallel relationship. The specific construction formula is:

[0156] T obj = parallel (sort q ({s i |F(s i )∈O promopt ,i∈[1,n]}))

[0157] Where, T obj In order to extract the object parameters after the processing, F(g) is a semantic conversion function, which performs semantic conversion on the recalled information in the previous step and matches it in the preset target matching library O promopt Perform validity matching.

[0158] c. Dimension parameters are extracted as follows:

[0159] Predefined business analysis dimension vector C including {cost, expenditure, income, gross profit, net profit, month-on-month, year-on-year} mon ; Based on word frequency and regularization methods, retain the business opportunity description text in the recalled information in the previous steps.

[0160] 4) Construct the corresponding indicator tree for the parameters output in step 3):

[0161] a. Index tree = (time, object, dimension), where time includes no-relationship query, comparative relationship, and parallel relationship, objects only have parallel relationships, and predefined dimensions include cost, expenditure, income, gross profit, net profit, month-on-month, and year-on-year;

[0162] b. Identify the parameters and indicator types;

[0163] c. Identify the relationship between indicators within the same set of parameters;

[0164] d. Select the analysis indicator index based on the contribution calculation and improve the indicator tree construction.

[0165] 5) Dimension extraction is performed on the parameters output above. In order to find which dimensions have a higher contribution to the extracted indicators, it is necessary to calculate the JS divergence between the indicator and each dimension, and then select the dimension with a larger contribution as the main factor of the indicator mutation. The specific extraction results are as follows:

[0166] Take the preset business information vector to be detected, the business description text and the indicators obtained in the previous steps as input to perform JS divergence calculation, and select the dimension with the maximum contribution calculation as the rough analysis dimension;

[0167] Based on the rough analysis dimensions obtained, drill down on the existing data table to further refine the dimensions and obtain the final indicator dimension.

[0168] An example of indicator tree construction is as follows:

[0169] 1) Receive user input "What is the reason for the sudden drop in funding costs of Beijing Branch and Shanghai Branch in 2023 compared to 2022?"

[0170] 2) The output related entities are as follows: In 2023, Beijing Branch, Shanghai Branch, the cost of funds, compared with 2022, dropped sharply, the reasons; the identified available parameters are as follows: In 2023, Beijing Branch, Shanghai Branch, the cost of funds, compared with 2022, dropped sharply;

[0171] 3) The extracted dimensions include: capital cost;

[0172] 4) Identify indicator types including: time (2023, 2022), object (Beijing Branch, Shanghai Branch);

[0173] 5) The constructed indicator tree is as follows:

[0174] Indicator tree = (time, object, dimension)

[0175] Time (Comparison: 2023, 2022)

[0176] Target (tied: Beijing Branch, Shanghai Branch)

[0177] Dimension (available dimensions: capital cost)

[0178] like Fig. 9 FIG. 1 is a flowchart of step S104 provided in an embodiment of the present invention, referring to FIG. Fig. 9 As an optional implementation, a target prompt statement is constructed according to the target indicator and the target dimension, which specifically includes:

[0179] S1041, obtaining a preset prompt template and a data table description of the business information NL2SQL large model;

[0180] S1042. Construct a target prompt statement according to the data table description, the question input statement, the target indicator, the target dimension, and the prompt template.

[0181] Specifically, call the business information NL2SQL big model to obtain the results and perform front-end rendering: combine the indicators, dimensions and table schema output in the previous steps, build a prompt, and call the business information NL2SQL big model.

[0182] The construction prompt is as follows:

[0183] {

[0184] You are a data analyst and SQL expert. Please write the most efficient SQL according to the user's question.

[0185] The table information is as follows: CREATE TABLE sales_table(

[0186] id INT AUTO_INCREMENT PRIMARY KEY,

[0187] org VARCHAR(255)NOT NULL,

[0188] sales_amount DECIMAL(10,2)NOT NULL,

[0189] month DATE NOT NULL );

[0191] User question: What is the reason for the sharp drop in funding costs of Beijing Branch and Shanghai Branch in 2023 compared with 2022? Related indicators: Time (2023, 2022)-month, Object (Beijing Branch, Shanghai Branch)-org

[0192] Relevant dimensions: Capital cost-sales_amount

[0193] }

[0194] According to the big model, the target SQL statement is returned to query the database to obtain the target data, and then the target data is integrated and rendered for display.

[0195] The above is a description of the method steps of the embodiment of the present invention. It can be appreciated that the embodiment of the present invention uses the semantic understanding and dialogue capabilities of the big model to achieve the business information query and number query functions, thereby assisting business information insight analysis and improving the efficiency and accuracy of business information data query.

[0196] like Fig.10 FIG. 1 is a schematic diagram of a business insight device based on a large language model provided by an embodiment of the present invention, referring to FIG. Fig.10 The embodiment of the present invention provides a business insight device based on a large language model, including:

[0197] A fine-tuning sample construction module is used to obtain a preset open source NL2SQL data set and internal business data, and to construct an open source fine-tuning sample and a business fine-tuning sample according to the open source NL2SQL data set and the internal business data;

[0198] The large model fine-tuning module is used to fine-tune the preset base large model according to the open source fine-tuning samples and the business fine-tuning samples to obtain the business NL2SQL large model;

[0199] The task decomposition module is used to obtain the problem input statement, decompose the problem input statement into tasks to obtain the target indicators and target dimensions;

[0200] The SQL statement output module is used to construct a target prompt statement according to the target indicator and target dimension, and input the target prompt statement into the business information NL2SQL large model to obtain the target SQL statement;

[0201] The database query module is used to query the database according to the target SQL statement, obtain the target data, and then integrate and render the target data.

[0202] The contents of the above method embodiments are all applicable to the present device embodiments. The functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0203] The embodiment of the present invention further provides an electronic device, the electronic device comprising: a memory, a processor, a program stored in the memory and executable on the processor, and a data bus for realizing connection and communication between the processor and the memory, wherein when the program is executed by the processor, the above-mentioned business insight method based on a large language model is realized. The electronic device may be any intelligent terminal including a tablet computer, a vehicle-mounted computer, etc.

[0204] like Fig.11 FIG. 1 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention, referring to FIG. Fig.11 , an embodiment of the present invention provides an electronic device, including:

[0205] The processor 1101 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present invention;

[0206] The memory 1102 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1102 can store an operating system and other application programs. When the technical solution provided in the embodiments of this specification is implemented by software or firmware, the relevant program code is stored in the memory 1102, and the processor 1101 calls and executes the business insight method based on a large language model in the embodiment of the present invention;

[0207] Input / output interface 1103, used to implement information input and output;

[0208] The communication interface 1104 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WIFI, Bluetooth, etc.);

[0209] A bus 1105 that transmits information between various components of the device (e.g., the processor 1101, the memory 1102, the input / output interface 1103, and the communication interface 1104);

[0210] The processor 1101 , the memory 1102 , the input / output interface 1103 and the communication interface 1104 are connected to each other in communication within the device via the bus 1105 .

[0211] like Fig.12 FIG. 1 is a schematic diagram of a storage medium according to an embodiment of the present invention. Fig.12 The embodiment of the present invention further provides a storage medium, which is a computer-readable storage medium used for computer-readable storage. The storage medium stores one or more programs 1201, and the one or more programs 1201 can be executed by one or more processors to implement the above-mentioned business insight method based on a large language model.

[0212] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0213] The embodiment of the present invention also discloses a computer program product or a computer program, wherein the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device can read the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes Figure 1 The method shown.

[0214] In some selectable embodiments, the function / operation mentioned in the block diagram may not occur in the order mentioned in the operation diagram. For example, depending on the function / operation involved, the two boxes shown in succession can actually be executed substantially simultaneously or the above-mentioned boxes can sometimes be executed in reverse order. In addition, the embodiment presented and described in the flow chart of the present invention is provided by way of example, for the purpose of providing a more comprehensive understanding of technology. The disclosed method is not limited to the operation and logic flow presented herein. Selectable embodiments are expected, wherein the order of various operations is changed and the sub-operation of a part for which is described as a larger operation is performed independently.

[0215] In addition, although the present invention is described in the context of functional modules, it should be understood that, unless otherwise specified to the contrary, one or more of the above-mentioned functions and / or features can be integrated into a single physical device and / or software module, or one or more functions and / or features can be implemented in a separate physical device or software module. It is also understood that a detailed discussion of the actual implementation of each module is unnecessary for understanding the present invention. More specifically, in view of the properties, functions and internal relationships of the various functional modules in the device disclosed herein, the actual implementation of the module will be understood within the conventional skills of the engineer. Therefore, those skilled in the art can implement the present invention set forth in the claims without excessive experimentation using ordinary techniques. It is also understood that the specific concepts disclosed are merely illustrative and are not intended to limit the scope of the present invention, which is determined by the full scope of the appended claims and their equivalents.

[0216] If the above functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the above methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0217] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.

[0218] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the above-mentioned program is printed, since the above-mentioned program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or processing in other suitable ways as necessary, and then stored in a computer memory.

[0219] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0220] In the above description of this specification, the description with reference to the terms "one embodiment / example", "another embodiment / example" or "certain embodiments / examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0221] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.

[0222] The above is a specific description of the preferred implementation of the present invention, but the present invention is not limited to the above embodiments. Those skilled in the art may make various equivalent modifications or substitutions without violating the spirit of the present invention. These equivalent modifications or substitutions are all included in the scope defined by the claims of this application.

Claims

1. A business insight method based on a large language model, characterized in that: The following steps are involved: Obtaining a preset open source NL2SQL data set and internal business data, and constructing an open source fine-tuning sample and a business fine-tuning sample according to the open source NL2SQL data set and the internal business data respectively; Fine-tune the preset base big model according to the open source fine-tuning sample and the business situation fine-tuning sample to obtain the business situation NL2SQL big model; Obtain a problem input statement, and perform task decomposition on the problem input statement to obtain target indicators and target dimensions; Construct a target prompt statement according to the target indicator and the target dimension, and input the target prompt statement into the business information NL2SQL big model to obtain a target SQL statement; The database is queried according to the target SQL statement to obtain the target data, and then the target data is integrated and rendered for display.

2. The business insight method based on a large language model according to claim 1, characterized in that: The open source fine-tuning sample is constructed by the following steps: Determine a first data table description, a first problem description, and a first SQL statement corresponding to the first data sample according to the open source NL2SQL data set; Construct a first annotation triple according to the first data table description, the first problem description, and the first SQL statement; The first labeled triplet is normalized to obtain the open source fine-tuning sample.

3. The business insight method based on a large language model according to claim 1, characterized in that: The business information fine-tuning sample is constructed by the following steps: Determine the database table, business information and real business content according to the internal business data; Determine slot information according to the database table and the business information, and construct a question template according to the business information; Filling the slot information into the problem template to obtain a problem slot template, and filling the real business content into the problem slot template to obtain a second problem description; Determine a second data table description according to the database table, and convert the second problem description into an SQL statement according to the second data table description to obtain a second SQL statement; A second annotated triple is constructed according to the second data table description, the second problem description, and the second SQL statement, and the second annotated triple is used as the business situation fine-tuning sample.

4. The business insight method based on a large language model according to claim 1, characterized in that: The method of fine-tuning the preset base model according to the open source fine-tuning sample and the business fine-tuning sample to obtain the business NL2SQL model specifically includes: Fine-tune the base large model in full according to the open source fine-tuning sample to obtain the basic NL2SQL large model; The basic NL2SQL large model is fine-tuned for a second time according to the business situation fine-tuning sample to obtain the business situation NL2SQL large model.

5. The business insight method based on a large language model according to claim 1, characterized in that: The task decomposition of the problem input statement to obtain target indicators and target dimensions specifically includes: Performing lexical analysis and named entity recognition on the question input sentence to obtain a first entity sequence; Performing entity extraction on the first entity sequence to obtain time parameters, object parameters, and dimension parameters; Constructing an indicator tree according to the time parameter, the object parameter and the dimension parameter; Determine the target indicator and candidate dimensions according to the indicator tree, and calculate the JS divergence between each candidate dimension and the target indicator; The candidate dimension with the largest JS divergence is selected as the target dimension.

6. The business insight method based on a large language model according to claim 5, characterized in that: The constructing of the indicator tree according to the time parameter, the object parameter and the dimension parameter specifically includes: Performing indicator type identification on the time parameter and the object parameter to obtain multiple indicator types and corresponding indicator contents; Relationship identification is performed on multiple indicator contents of the same indicator type to obtain the relationship between the indicators; The indicator tree is constructed according to the indicator type, the indicator content, the relationship between the indicators and the dimension parameters.

7. A business insight method based on a large language model according to any one of claims 1 to 6, characterized in that: The step of constructing a target prompt statement according to the target indicator and the target dimension specifically includes: Obtaining a preset prompt template and a data table description of the business information NL2SQL large model; The target prompt statement is constructed according to the data table description, the question input statement, the target indicator, the target dimension and the prompt template.

8. A business insight device based on a large language model, characterized in that: include: A fine-tuning sample construction module is used to obtain a preset open source NL2SQL data set and internal business information data, and to construct an open source fine-tuning sample and a business information fine-tuning sample according to the open source NL2SQL data set and the internal business information data respectively; A large model fine-tuning module, used to fine-tune the preset base large model according to the open source fine-tuning sample and the business situation fine-tuning sample to obtain the business situation NL2SQL large model; A task decomposition module is used to obtain a problem input statement, and perform task decomposition on the problem input statement to obtain a target indicator and a target dimension; An SQL statement output module is used to construct a target prompt statement according to the target indicator and the target dimension, and input the target prompt statement into the business information NL2SQL big model to obtain a target SQL statement; The database query module is used to query the database according to the target SQL statement to obtain the target data, and then perform content integration and rendering display on the target data.

9. An electronic device, characterized in that: The electronic device includes a memory, a processor, a program stored in the memory and executable on the processor, and a data bus for realizing connection and communication between the processor and the memory. When the program is executed by the processor, the steps of the business insight method based on a large language model as described in any one of claims 1 to 7 are realized.

10. A storage medium, the storage medium being a computer-readable storage medium, used for computer-readable storage, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the business insight method based on a large language model as described in any one of claims 1 to 7.

Citation Information

Cited By

  • Data analysis index management method and device, electronic equipment and readable storage medium

    CN121412262A