Method for constructing Text2MDX framework based on intelligent agent
By constructing an agent chain structure, the problem of missing key computing logic of MDX expressions in multiple rounds of dialogue or long text is solved, automatic maintenance across sentence contexts and fuzzy semantics are realized, the conversion accuracy of natural language to MDX expressions and the adaptability of the system are improved, and it is suitable for data analysis in multiple fields.
Patent Information
- Application Number
- CN202510611572.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-13
- Publication Date
- 2025-08-12
AI Technical Summary
The prior art cannot effectively maintain context logic across sentences when dealing with multiple rounds of dialogue or long text, resulting in the lack of key computational logic for MDX expressions, and it is difficult to deal with natural language texts in different fields and forms, and lack effective fuzzy semantic analysis methods.
Build a Text2MDX framework based on agents, including a chain structure of semantic parsing agents, rule memory agents and MDX synthetic agents. Through text semantic disassembly, custom semantic rule management and MDX expression generation, ensure the orderly collaboration of the agent chain, automatically maintain the context logic across sentences, and handle fuzzy semantics through fuzzy logic inference algorithms.
It significantly improves the accuracy and reliability of natural language to MDX expression conversion, can handle context breaking problems in complex interactive scenarios, adapt to different fields and forms of natural language text, generate accurate MDX expressions, and meet users' diverse data analysis needs.
Smart Images

Figure CN120470106A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular to a method for constructing an agent-based Text2MDX framework. Background Art
[0002] In today's digital age, data volumes are exploding. Enterprises and research institutions are accumulating vast amounts of multidimensional data. Multidimensional data analysis is crucial for mining data value and supporting decision-making. MDX, as a powerful multidimensional data analysis language, can accurately extract valuable information from complex data models. Existing technologies have certain flaws. First, when processing multi-round conversations or long texts, existing technologies cannot effectively maintain cross-sentence contextual logic (for example, a user first defines "sales = revenue - cost" and then directly asks "sales in East China"). As a result, the generated MDX lacks key calculation logic. Second, existing technologies have difficulty processing natural language texts in different fields and forms, and lack effective parsing methods for fuzzy semantics. To this end, we propose a method for building an agent-based Text2MDX framework. Summary of the Invention
[0003] The purpose of the present invention is to provide a method for constructing an agent-based Text2MDX framework.
[0004] To achieve the above objectives, the present invention provides the following technical solution: a method for constructing an agent-based Text2MDX framework, the method comprising the following specific steps: Step 1: Build an agent architecture, establishing a chain structure consisting of a semantic parsing agent, a rule memory agent, and an MDX synthesis agent. The semantic parsing agent is responsible for the initial processing of the input natural language text, the rule memory agent is used to store and manage custom semantic rules, and the MDX synthesis agent is responsible for generating the final MDX expression. The format and process of data exchange between agents are clarified to ensure that information can flow in an orderly manner in the agent chain. Step 2: Initial text semantic decomposition. The semantic parsing agent receives the input text and uses the text semantic decomposition algorithm to decompose the text into basic semantic segments. The text semantic decomposition algorithm is as follows:
[0005] Obtained through text semantic decomposition algorithm The basic semantic fragments are used to prepare for subsequent semantic analysis, and then the basic semantic fragments are tagged with parts of speech and their grammatical structures are sorted out to explore potential custom semantic rules; Step 3: Extraction and storage of custom semantic rules. When the semantic parsing agent identifies a custom semantic rule in the basic semantic fragment, it transfers it to the rule memory agent. The rule memory agent uses a storage strategy to store the rule in a dedicated cache area. The specific formula of the storage strategy is as follows:
[0006] in, Indicates custom semantic rules, Represents the key identifier of the rule, using the new hash function Determine the storage location and calculate the function based on the custom priority To optimize storage and ensure that commonly used rules can be quickly accessed, the priority calculation function Frequency of use of comprehensive rules , most recent usage time (calculated within 7 days from the current time) and the importance of the rule to the business , the specific calculation formula is as follows:
[0007] in, The weight coefficient is adjusted according to the business scenario, and ; Step 4: Processing new query text. When a new query text is received, the semantic parsing agent performs semantic decomposition and grammatical analysis again. At the same time, the rule memory agent uses a dedicated retrieval algorithm to search for relevant custom semantic rules in the cache area based on the key information in the query text. The specific retrieval algorithm is as follows:
[0008] in, Represents the new query text, It is to query key information, locate the storage area where relevant rules exist through the new hash function, and search in the customized search range Search matching rules within the scope of the search The determination takes into account the semantic similarity between the query text and the rules in the cache , rule priority And the cache space usage , the specific calculation formula is as follows:
[0009] in, Represents a function that dynamically adjusts the search range based on the above factors; Step 5: Generate MDX expressions. The MDX synthesis agent combines the semantic information of the new query text with the custom semantic rules obtained from the rule memory agent and generates a complete and accurate MDX expression according to a specific MDX construction algorithm. The construction algorithm is:
[0010] in, Represents the semantic information of the query text, Represents custom semantic rules through custom semantic mapping functions Associate queries with rules and build functions using syntax Convert it into an expression that conforms to the MDX syntax specification. Represents a custom fusion operation to ensure that the generated expression can accurately reflect user needs and semantic mapping function Based on the semantic vector space model, the query text semantic vector is calculated Rule semantic vector Cosine similarity , and combined with the semantic association strength coefficient Make adjustments, namely:
[0011] Syntax building functions Based on the MDX syntax rule library, combined with the query intent and the operators and data dimension information in the rules, a syntax tree is recursively generated and converted into an MDX expression string.
[0012] As a further solution of the present invention: in the step 2, the text semantic decomposition algorithm Indicates input text, input text First, the sentences are divided into two categories based on punctuation marks (period, question mark and exclamation mark) as sentence boundary markers and a pre-built conjunction vocabulary containing common coordinating conjunctions ("and", "and" and "or") and subordinate conjunctions ("if", "because" and "when") Main text blocks , each main text block It is further divided into vocabulary clustering algorithms based on word form, part of speech, and word meaning clustering and part of speech association algorithms based on dependency syntax analysis. Small text blocks is based on The vocabulary richness (the ratio of the number of words to the length of the text) and the word frequency distribution (the statistical distribution of the number of times different words appear) are dynamically generated for the main disassembly function The parameter set, It is a function for sub-decomposition generated based on the grammatical dependency analysis results of the StanfordCoreNLP toolkit and the semantic role labeling results optimized based on the PropBank semantic role labeling system. The parameter set, Divide small text blocks into semantic segments from different dimensions, and obtain more accurate semantic segments through intersection operations. It is a weight adjustment parameter that comprehensively considers the topic coherence of the entire input text (the text topic consistency score calculated based on the LDA topic model) and the relevance of domain knowledge (the matching degree with the pre-built domain knowledge base). It is used to perform weighted processing on the division results of each subdivided text block according to the weight.
[0013] As a further solution of the present invention: In the step 3, the rule cache area of the rule memory agent adopts a hierarchical storage structure, which is divided into a high-speed cache area and a low-speed storage area. The custom semantic rules that have been used at least once every two days in the past week and whose scores are in the top 30% of all rule scores after calculation by the priority calculation function are stored in the high-speed cache area to speed up the retrieval speed. Other rules are stored in the low-speed storage area. The rule migration strategy between the high-speed cache area and the low-speed storage area is determined by the migration function. This function determines whether to migrate the rule between the high-speed cache area and the low-speed storage area based on the cache status information of the ratio of the used space in the cache area to the total space and the rate of change of the access frequency of the rule during the statistical period. The calculation formula for the rate of change of the access frequency of the rule during the statistical period is: Indicates the access frequency of the rule in the current statistical period. Indicates the access frequency of the rule in the previous statistical period.
[0014] As a further solution of the present invention: in step 5, after generating an MDX expression, the MDX synthesis agent uses a verification algorithm to perform syntax verification and semantic verification on the expression. The syntax verification algorithm builds a custom syntax rule tree and matches the generated expression with the rule tree for verification. The semantic verification compares the data dictionary in the multidimensional data model with the semantic elements in the expression to ensure that the expression can correctly query the target data. The syntax verification algorithm formula is as follows:
[0015] The semantic verification algorithm formula is as follows:
[0016] in, Represents the generated MDX expression, Represents a grammar rule tree, Represents the data dictionary. During the semantic verification process, a fuzzy matching algorithm is used to match the semantic elements in the expression with the data dictionary. in, Represents an expression semantic element, Represents an element in the data dictionary, Indicates matching tolerance to handle possible differences in semantic expressions. The fuzzy matching algorithm calculates the character edit distance between semantic elements and data dictionary elements and adjusts the matching results in combination with the semantic relevance weight.
[0017] As a further solution of the present invention, when the semantic parsing agent recognizes fuzzy semantics in the input text, it uses an algorithm based on fuzzy logic reasoning to clarify the semantics. The fuzzy logic reasoning algorithm constructs a fuzzy membership function to perform quantitative analysis on the fuzzy semantics and determine the most likely accurate semantics. The fuzzy membership function is as follows:
[0018] in, is a fuzzy semantic element, is a set of customized fuzzy membership parameters. The membership of fuzzy semantics in different accurate semantic sets is calculated through this function, so as to determine the accurate semantics that meets the user's intention. The fuzzy membership parameters Adjust according to the field to which the text belongs and the user's historical query habits.
[0019] As a further solution of the present invention: in step 1, various parameters in the text semantic decomposition algorithm adopted by the semantic parsing agent are , each time the text is processed, it will be dynamically adjusted according to the real-time characteristics of the text through the parameter update function, the parameter update function is as follows:
[0020] in, It is based on data on vocabulary changes and grammatical structure evolution Updated custom functions are used to improve the accuracy of decomposing different types of texts. Vocabulary change data is obtained by comparing the vocabulary set differences between the current text and historical texts, and grammatical structure evolution data is obtained by analyzing the syntactic structure change trends of continuous texts.
[0021] As a further solution of the present invention, after the MDX synthesis agent generates an MDX expression, it optimizes the expression according to the performance optimization index of the multidimensional data model. During the optimization process, based on the association relationship between different data sets in the data model and the index settings, the query order and connection method in the expression are adjusted using the following formula to improve query efficiency:
[0022] Among them, E represents the generated MDX expression, Represents the set of all query sequences, Represents the data set in the query order The query cost itself, which is based on the size of the data set , Index Selectivity And the complexity of the filter conditions It is calculated by the formula, which is as follows:
[0023] Representing a data set The connection cost between them is used to find the query sequence that minimizes the total cost, optimize the MDX expression, and improve query performance.
[0024] By adopting the above technical solution, compared with the prior art, the beneficial effects of the present invention are: 1. The present invention constructs a chain structure consisting of a semantic parsing agent, a rule memory agent, and an MDX synthesis agent. In multi-round conversations or long text processing, the semantic parsing agent can accurately disassemble the text and extract potential custom semantic rules, such as "sales = income - cost". The rule memory agent dynamically caches these rules. When subsequent related queries appear, such as "sales in East China", the previously stored rules can be quickly retrieved. The MDX synthesis agent then combines the semantic information of the new query text with the cached rules to generate an MDX expression containing complete calculation logic. Throughout the process, the agent chain collaborates in an orderly manner and automatically maintains the context logic across sentences, avoiding the situation where the MDX expression lacks key calculation logic. This significantly improves the accuracy and reliability of the conversion from natural language to MDX expression, provides users with more accurate data analysis support, and solves the problem of context disconnection in complex interactive scenarios. 2. The present invention enhances the adaptability of the system in complex scenarios by setting up a complete processing flow, including text semantic decomposition, management of custom semantic rules, new query text processing and MDX expression generation and verification. When faced with natural language texts in different fields and forms, the semantic parsing agent uses a specific algorithm to decompose the text into basic semantic fragments, laying the foundation for subsequent processing. The rule memory agent efficiently stores and retrieves custom semantic rules to adapt to changing business needs. After generating the MDX expression, the syntax and semantic verification mechanism ensures the correctness of the expression. Even if the text has ambiguous semantics, it can be semantically clarified through fuzzy logic reasoning algorithms. This enables the system to process various complex texts, accurately generate MDX expressions, and meet users' diverse data analysis needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 Schematic diagram of the method steps in an embodiment of the present invention. DETAILED DESCRIPTION
[0026] The specific embodiments of the present invention will be further described below in conjunction with the accompanying drawings. It should be noted that the description of these embodiments is used to help understand the present invention, but does not constitute a limitation of the present invention.
[0027] In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0028] Please see the attached Figure 1 The present invention provides a method for constructing an agent-based Text2MDX framework, the method comprising the following specific steps: Step 1: Build an agent architecture, establishing a chain structure consisting of a semantic parsing agent, a rule memory agent, and an MDX synthesis agent. The semantic parsing agent is responsible for the initial processing of the input natural language text, the rule memory agent is used to store and manage custom semantic rules, and the MDX synthesis agent is responsible for generating the final MDX expression. The format and process of data exchange between agents are clarified to ensure that information can flow in an orderly manner in the agent chain. Step 2: Initial text semantic decomposition. The semantic parsing agent receives the input text and uses the text semantic decomposition algorithm to decompose the text into basic semantic segments. The text semantic decomposition algorithm is as follows:
[0029] D basic semantic segments are obtained through the text semantic decomposition algorithm to prepare for subsequent semantic analysis. The basic semantic segments are then tagged with parts of speech and their grammatical structures are sorted out to explore potential custom semantic rules. Step 3: Extraction and storage of custom semantic rules. When the semantic parsing agent identifies a custom semantic rule in the basic semantic fragment, it transfers it to the rule memory agent. The rule memory agent uses a storage strategy to store the rule in a dedicated cache area. The specific formula of the storage strategy is as follows:
[0030] in, Indicates custom semantic rules, Represents the key identifier of the rule, using the new hash function Determine the storage location and calculate the function based on the custom priority To optimize storage and ensure that commonly used rules can be quickly accessed, the priority calculation function Frequency of use of comprehensive rules , most recent usage time (calculated within 7 days from the current time) and the importance of the rule to the business The specific calculation formula is as follows: in, The weight coefficient is adjusted according to the business scenario, and Step 4: Processing new query text. When a new query text is received, the semantic parsing agent performs semantic decomposition and grammatical analysis again. At the same time, the rule memory agent uses a dedicated retrieval algorithm to search for relevant custom semantic rules in the cache area based on the key information in the query text. The specific retrieval algorithm is as follows:
[0031] in, Represents the new query text, It is to query key information, locate the storage area where relevant rules exist through the new hash function, and search in the customized search range Search matching rules within the search scope The determination takes into account the semantic similarity between the query text and the rules in the cache , rule priority And the cache space usage , the specific calculation formula is as follows:
[0032] in, Represents a function that dynamically adjusts the search range based on the above factors; Step 5: Generate MDX expressions. The MDX synthesis agent combines the semantic information of the new query text with the custom semantic rules obtained from the rule memory agent and generates a complete and accurate MDX expression according to a specific MDX construction algorithm. The construction algorithm is:
[0033] in, The query text semantic information is shown. Represents custom semantic rules through custom semantic mapping functions Associate queries with rules and build functions using syntax Convert it into an expression that conforms to the MDX syntax specification. Represents a custom fusion operation to ensure that the generated expression can accurately reflect user needs and semantic mapping function Based on the semantic vector space model, the query text semantic vector is calculated and rule semantic vector Cosine similarity of , and combined with the semantic association strength coefficient Make adjustments, namely:
[0034] Syntax building functions Based on the MDX syntax rule library, combined with the query intent and the operators and data dimension information in the rules, a syntax tree is recursively generated and converted into an MDX expression string.
[0035] In one embodiment of the present invention: In step 2, T in the text semantic decomposition algorithm represents the input text, and the input text T is first divided into: Main text blocks , each main text block It is further divided into vocabulary clustering algorithms based on word form, part of speech, and word meaning clustering and part of speech association algorithms based on dependency syntax analysis. Small text blocks is based on The vocabulary richness (the ratio of the number of words to the length of the text) and the word frequency distribution (the statistical distribution of the number of times different words appear) are dynamically generated for the main disassembly function parameter sets, is based on The toolkit's grammatical dependency analysis results and the semantic role annotation results optimized based on the PropBank semantic role annotation system are used to generate the sub-decomposition function The parameter set, Divide small text blocks into semantic segments from different dimensions, and obtain more accurate semantic segments through intersection operations. It is a weight adjustment parameter that comprehensively considers the topic coherence of the entire input text (the text topic consistency score calculated based on the LDA topic model) and the relevance of domain knowledge (the matching degree with the pre-built domain knowledge base). It is used to perform weighted processing on the division results of each subdivided text block according to the weight.
[0036] In one embodiment of the present invention: In step 3, the rule cache area of the rule memory agent adopts a hierarchical storage structure, which is divided into a high-speed cache area and a low-speed storage area. Custom semantic rules that have been used at least once every two days in the past week and whose scores are in the top 30% of all rule scores after calculation by the priority calculation function are stored in the high-speed cache area to speed up the retrieval speed. Other rules are stored in the low-speed storage area. The rule migration strategy between the high-speed cache area and the low-speed storage area is determined by the migration function. This function determines whether to migrate the rule between the high-speed cache area and the low-speed storage area based on the cache status information of the ratio of the used space in the cache area to the total space and the rate of change of the access frequency of the rule during the statistical period. The calculation formula for the rate of change of the access frequency of the rule during the statistical period is: , Indicates the access frequency of the rule in the current statistical period. Indicates the access frequency of the rule in the previous statistical period.
[0037] In one embodiment of the present invention, in step 5, after generating an MDX expression, the MDX synthesis agent uses a verification algorithm to perform syntax verification and semantic verification on the expression. The syntax verification algorithm builds a custom syntax rule tree and matches the generated expression with the rule tree for verification. The semantic verification compares the data dictionary in the multidimensional data model with the semantic elements in the expression to ensure that the expression can correctly query the target data. The syntax verification algorithm formula is as follows:
[0038] The semantic verification algorithm formula is as follows:
[0039] Among them, M represents the generated MDX expression, Represents a grammar rule tree, Represents the data dictionary. During the semantic verification process, a fuzzy matching algorithm is used to match the semantic elements in the expression with the data dictionary. , where e represents the expression semantic element, Represents an element in the data dictionary, Indicates matching tolerance to handle possible differences in semantic expressions. The fuzzy matching algorithm calculates the character edit distance between semantic elements and data dictionary elements and adjusts the matching results in combination with the semantic relevance weight.
[0040] In one embodiment of the present invention, when the semantic parsing agent recognizes fuzzy semantics in the input text, it uses an algorithm based on fuzzy logic reasoning to clarify the semantics. The fuzzy logic reasoning algorithm constructs a fuzzy membership function to quantitatively analyze the fuzzy semantics and determine the most likely accurate semantics. The fuzzy membership function is as follows:
[0041] in, is a fuzzy semantic element, is a set of customized fuzzy membership parameters. The membership of fuzzy semantics in different accurate semantic sets is calculated through this function, so as to determine the accurate semantics that meets the user's intention. The fuzzy membership parameters Adjust according to the field to which the text belongs and the user's historical query habits.
[0042] In one embodiment of the present invention: In step 1, various parameters in the text semantic decomposition algorithm used by the semantic parsing agent are , each time the text is processed, it will be dynamically adjusted according to the real-time characteristics of the text through the parameter update function, the parameter update function is as follows: in, It is based on data on vocabulary changes and grammatical structure evolution Updated custom functions are used to improve the accuracy of decomposing different types of texts. Vocabulary change data is obtained by comparing the vocabulary set differences between the current text and historical texts, and grammatical structure evolution data is obtained by analyzing the syntactic structure change trends of continuous texts.
[0043] In one embodiment of the present invention, after the MDX synthesis agent generates an MDX expression, it optimizes the expression according to the performance optimization index of the multidimensional data model. During the optimization process, the query order and connection method in the expression are adjusted according to the association relationship between different data sets in the data model and the index settings to improve query efficiency through the following formula:
[0044] Among them, E represents the generated MDX expression, Shows all query sequence sets, Represents the data set in the query order The query cost itself, which is based on the size of the data set , Index Selectivity And the complexity of the filter conditions It is calculated by the formula, which is as follows:
[0045] Represents a data set and The connection cost between them is used to find the query sequence that minimizes the total cost, optimize the MDX expression, and improve query performance.
[0046] Example 1, please refer to the attached Figure 1 In an e-commerce data analysis scenario, users want to analyze sales in different regions within a specific time period; 1. Input text: "What were the sales in Beijing and Shanghai in the past three months?" 2. Building the agent architecture: The semantic parsing agent, rule memory agent, and MDX synthesis agent have been built, and data exchange between agents is carried out using JSON format and HTTP protocol. 3. Initial text semantic decomposition: (1) The semantic parsing agent receives the input text and divides it into a main text block based on punctuation marks and connective word lexicon. Then, it further subdivides it into multiple small text blocks based on vocabulary clustering and part-of-speech association algorithms. (2) Calculate the vocabulary richness, word frequency distribution and other parameters to generate , generated by the StanfordCoreNLP toolkit and optimized semantic role annotation system , calculate the text topic consistency score based on the LDA topic model, and determine the weight adjustment parameter based on the matching degree of the domain knowledge base After being processed by the text semantic decomposition algorithm, the basic semantic fragments were obtained, and part-of-speech tagging and grammatical structure sorting were performed. No custom semantic rules were found; (3) After being processed by the text semantic decomposition algorithm, basic semantic fragments were obtained, and part-of-speech tagging and grammatical structure sorting were performed. No custom semantic rules were found; 4. Extraction and storage of custom semantic rules: Since no custom semantic rules are identified, this step does not take any action. 5. Processing of new query text: The semantic parsing agent further deconstructs the query text and performs grammatical analysis, determining that the key information is "past three months", "Beijing", "Shanghai", and "sales volume". The rule memory agent searches for relevant rules in the cache area using a retrieval algorithm based on key information, but no matching rules are found; 6. Generation of MDX expressions: (1) The MDX synthesis agent combines the query text semantic information and generates an MDX expression based on the MDX syntax rule library and the default data dimension information in the absence of custom semantic rules. Assuming that the data model contains dimensions such as "time", "region", and "sales", the generated MDX expression is: SELECT [Measures].[Sales]ONCOLUMNS {[Region].[Beijing],[Region].[Shanghai]}ONROWS FROM [Sales Data Cube] WHERE ([time].[last three months]) (2) After the expression is generated, syntax verification and semantic verification are performed. Syntax verification matches the expression by building a syntax rule tree, and semantic verification compares the data dictionary with the semantic elements in the expression to ensure that the expression can correctly query the target data. (3) Based on the performance optimization indicators of the multidimensional data model, assuming that the "region" dimension in the data model has an index and the query filter conditions of the "time" dimension can use the index to quickly locate data, the expression is optimized by adjusting the query order and connection method.
[0047] Example 2, please refer to the attached Figure 1 ,In the financial investment analysis scenario, the user first defines a calculation rule and then performs ,related queries; 1. Enter text and rule definition: The user enters "Define net profit = total revenue - total cost"; 2. Determine the weight coefficient for priority calculation In this financial investment analysis scenario, we need to calculate the priority function Determine the weight coefficient ,The determination of these weight coefficients requires comprehensive consideration of the ,characteristics and requirements of the business scenario; Use frequency weights :In financial analysis, multiple queries and analyses are often performed based on some key financial indicator rules. For example, when performing quarterly financial report analysis, project investment return rate evaluation, and other operations, core financial indicator calculation rules such as "net profit" are frequently used. Therefore, the frequency of use has a great impact on the priority of the rules. We will Set to 0.4; Recent use time weight :In the financial field, market conditions and business needs change rapidly. Recently used rules are likely to be used again in the short term because analysts may conduct continuous research and evaluation around the same topic or project. Therefore, the time of recent use is also an important factor. We will Set to 0.3; Business importance weight "Net profit" is one of the most critical indicators in financial investment analysis. It directly reflects the profitability of an enterprise or project and is of vital importance to investment decisions, risk assessment and other business operations. Therefore, the importance of the business has a greater impact on the priority of the rules. We will Set to 0.3; and satisfy .
[0048] 3. Calculate the frequency of rule priority :Since this is a newly defined rule and has not been used yet, the frequency of use is Last used time :The rule has just been defined, and the current time is 0 days. However, in order to avoid the situation where the denominator is 0, we can express it as a very small positive number, assuming it is 0.001 days. Then ; Business importance "Net profit" is extremely important in financial investment analysis, and we set its business importance to 0.8; Substituting the above parameters into the priority calculation function yields:
[0049] The semantic parsing agent recognizes the custom semantic rule and transmits it to the rule memory agent. The rule memory agent adopts a storage strategy and uses the new hash function to determine the storage location. Based on the calculated priority of 300.24, the rule is stored in the cache area. Since this rule has a high priority, it is stored in the high-speed cache area for subsequent fast access. 4. Subsequent query text "What was the net profit of each investment project in the most recent quarter?" 5. Build the intelligent agent architecture and ensure the normal operation of each intelligent agent; 6. Initial text semantic analysis (1) For the input text “What is the net profit of each investment project in the most recent quarter?”, the semantic parsing agent first divides it into small text blocks. , can be divided into small text blocks such as "the most recent quarter", "various investment projects", "net profit", "how much"; (2) Taking the small text block “various investment projects” as an example to calculate the vocabulary richness, the length of this text block is 5 (containing 5 characters), and the number of different words in it is 2 (“various”, “investment projects”), so the vocabulary richness is 2 ÷ 5 = 0.4; (3) When calculating the word frequency distribution, from 100 historical similar texts, "investment project" appears 10 times, and "each" appears 5 times. Then the word frequency of "investment project" is 10÷100=0.1, and the word frequency of "each" is 5÷100=0.05. These lexical richness and word frequency distribution data are input into a specific parameter generation model (a regression model based on machine learning, whose training data contains a large number of lexical features of similar text blocks and corresponding Value), get the parameter set for the main disassembly function PrimarySegment For the small text block "various investment projects", after model calculation, we can get (The values here are just examples and are actually calculated by the model based on the data). These values will affect The function divides the text block into semantic segments.
[0050] 2. Generate Parameter Set: Using the Stanford Core NLP toolkit, we performed a grammatical dependency analysis on the sentence "What was the net profit of each investment project in the most recent quarter?" and found that "net profit" is the core object of the sentence, and "investment projects" is a modifier of "net profit." A specific dependency relationship exists between them. The semantic role labeling results optimized based on the PropBank semantic role labeling system show that "net profit" assumes the semantic role of "queried object" and "investment projects" assumes the role of "limited scope"; These grammatical dependencies and semantic role labeling results are encoded and input into another The model (neural network model, obtained by training a large amount of labeled text data) is calculated. For the small text block "various investment projects", the generated =[0.15,0.25,0.35,0.25] (again, these are example values). These parameters are used by the SecondarySegment function to segment small text blocks into semantic segments, supplementing and refining semantic analysis from another dimension. 3. Determine the weight adjustment parameter γ: Calculate the text topic consistency score based on the LDA topic model. Suppose that in the topic model of the financial investment analysis field, the consistency score of the input text with the topic of "investment project return analysis" is 0.8 (the value range is 0-1, and the higher the score, the stronger the relevance to the topic); Calculate the matching degree with the pre-built domain knowledge base. The financial domain knowledge base contains various financial terms, investment concepts, and related relationships. Using the text matching algorithm, calculate the matching degree between the input text and the relevant content in the knowledge base, assuming the matching degree is 0.75; Set a comprehensive calculation function (weighted average function), set =0.6×0.8+0.4×0.75=0.78 (the weights 0.6 and 0.4 here are set based on business experience and can be adjusted according to actual conditions), Used for ContextWeight Function, which performs weighted processing on the division results of each subdivided text block to comprehensively consider the topic coherence and domain knowledge relevance of the entire input text.
[0051] 7. Extraction and storage of custom semantic rules: No new rules are extracted. The rule memory agent retrieves the previously stored "net profit = total revenue - total cost" rule from the cache; 8. Processing of new query text: (1) The semantic parsing agent determines that the key query information is "the most recent quarter", "various investment projects", and "net profit"; (2) The rule memory agent retrieves key information and finds matching rules. It determines the search scope based on the semantic similarity between the query text and the rules, the rule priority, and the cache space occupancy.
[0052] 9. Generation of MDX expressions: The MDX synthesis agent combines the query text semantic information with the obtained custom semantic rules to generate an MDX expression. Assuming that the data model includes dimensions such as "time", "investment project", "total income", and "total cost", the generated expression is: WITH MEMBER[Measures].[Net Profit] AS([Measures].[Total Revenue] - [Measures].[Total Cost]) SELECT [Measures].[Net Profit]ONCOLUMNS, [Investment Projects].[All Investment Projects]ONROWS FROM [Investment Data Cube] WHERE ([time].[most recent quarter]) (1) Perform syntax and semantic verification. During semantic verification, a fuzzy matching algorithm is used to match the semantic element of "net profit" with the relevant elements in the data dictionary to handle possible differences in semantic expressions; (2) Optimize the expression based on the relationship between tables in the data model and the index settings. For example, if the index of the "investment project" dimension helps to quickly locate data, adjust the query order to use this index to improve query efficiency.
[0053] According to the contents of the above embodiments, it can be concluded that by constructing an intelligent agent chain structure and combining processes such as text semantic decomposition, rule management, query processing and expression generation and verification, the problem of converting natural language to MDX expressions in complex interactive scenarios is effectively solved. In multi-round conversations or long text processing, each intelligent agent works together to accurately extract and apply custom semantic rules, avoid the lack of key calculation logic of MDX expressions, and significantly improve the accuracy and reliability of the conversion. At the same time, the system has strong adaptability and can handle texts in different fields and forms. Even if there is ambiguous semantics, it can be accurately parsed. The invention has obvious technical advantages and has broad application prospects in the field of data analysis. It can provide efficient and accurate data analysis support for users in various industries.
[0054] Although the present invention is disclosed above with reference to preferred embodiments, this is not intended to limit the present invention. Any person skilled in the art may make possible changes and modifications without departing from the spirit and scope of the present invention. Therefore, any modifications, equivalent variations, and modifications made to the above embodiments in accordance with the technical essence of the present invention without departing from the content of the technical solution of the present invention shall fall within the scope of protection defined by the claims of the present invention.
Claims
1. A method for constructing an agent-based Text2MDX framework, characterized in that: The method comprises the following specific steps: Step 1: Build an agent architecture, establishing a chain structure consisting of a semantic parsing agent, a rule memory agent, and an MDX synthesis agent. The semantic parsing agent is responsible for the initial processing of the input natural language text, the rule memory agent is used to store and manage custom semantic rules, and the MDX synthesis agent is responsible for generating the final MDX expression. The format and process of data exchange between agents are clarified to ensure that information can flow in an orderly manner in the agent chain. Step 2: Initial text semantic decomposition. The semantic parsing agent receives the input text and uses the text semantic decomposition algorithm to decompose the text into basic semantic segments. The text semantic decomposition algorithm is as follows: ; D basic semantic segments are obtained through the text semantic decomposition algorithm to prepare for subsequent semantic analysis. The basic semantic segments are then tagged with parts of speech and their grammatical structures are sorted out to explore potential custom semantic rules. Step 3: Extraction and storage of custom semantic rules. When the semantic parsing agent recognizes a custom semantic rule in the basic semantic fragment, it transfers it to the rule memory agent. The rule memory agent uses a storage strategy to store the rule in a dedicated cache area. The specific formula of the storage strategy is as follows: Among them, R represents a custom semantic rule, Represents the key identifier of the rule, using the new hash function Determine the storage location and calculate the function based on the custom priority To optimize storage and ensure that commonly used rules can be quickly accessed, the priority calculation function Frequency of use of comprehensive rules , most recent usage time (calculated within 7 days from the current time) and the importance of the rule to the business , the specific calculation formula is as follows: in, The weight coefficient is adjusted according to the business scenario, and ; Step 4: Processing new query text. When a new query text is received, the semantic parsing agent performs semantic decomposition and grammatical analysis again. At the same time, the rule memory agent uses a dedicated retrieval algorithm to search for relevant custom semantic rules in the cache area based on the key information in the query text. The specific retrieval algorithm is as follows: ; in, Represents the new query text, It is to query key information, locate the storage area where relevant rules exist through the new hash function, and search in the customized search range Search matching rules within the search scope The determination takes into account the semantic similarity between the query text and the rules in the cache , rule priority And the cache space usage , the specific calculation formula is as follows: ; in, Represents a function that dynamically adjusts the search range based on the above factors; Step 5: Generate MDX expressions. The MDX synthesis agent combines the semantic information of the new query text with the custom semantic rules obtained from the rule memory agent and generates a complete and accurate MDX expression according to a specific MDX construction algorithm. The construction algorithm is: ; in, Represents the semantic information of the query text, Represents custom semantic rules through custom semantic mapping functions Associate queries with rules and build functions using syntax Convert it into an expression that conforms to the MDX syntax specification. " indicates a customized fusion operation to ensure that the generated expression can accurately reflect user needs and the semantic mapping function Based on the semantic vector space model, the query text semantic vector is calculated and rule semantic vector Cosine similarity of , and combined with the semantic association strength coefficient Make adjustments, namely: ; Syntax building functions Based on the MDX syntax rule library, combined with the query intent and the operators and data dimension information in the rules, a syntax tree is recursively generated and converted into an MDX expression string.
2. The method for constructing an agent-based Text2MDX framework according to claim 1, characterized in that: In the step 2, the text semantic decomposition algorithm Indicates input text, input text First, based on punctuation marks (period, question mark and exclamation mark) as sentence boundary markers, and a pre-built conjunction vocabulary containing common coordinating conjunctions ("and", "and", and "or") and subordinate conjunctions ("if", "because" and "when"), it is divided into Main text blocks , each main text block It is further divided into vocabulary clustering algorithms based on word form, part of speech, and word meaning clustering and part of speech association algorithms based on dependency syntax analysis. Small text blocks , is based on The vocabulary richness (the ratio of the number of words to the length of the text) and the word frequency distribution (the statistical distribution of the number of times different words appear) are dynamically generated for the main disassembly function The parameter set, It is a function for sub-decomposition generated based on the grammatical dependency analysis results of the StanfordCoreNLP toolkit and the semantic role labeling results optimized based on the PropBank semantic role labeling system. The parameter set, and Divide small text blocks into semantic segments from different dimensions, and obtain more accurate semantic segments through intersection operations. It is a weight adjustment parameter that comprehensively considers the topic coherence of the entire input text (the text topic consistency score calculated based on the LDA topic model) and the relevance of domain knowledge (the matching degree with the pre-built domain knowledge base). It is used to perform weighted processing on the division results of each subdivided text block according to the weight.
3. The method for constructing an agent-based Text2MDX framework according to claim 1, characterized in that: In the step 3, the rule cache area of the rule memory agent adopts a hierarchical storage structure, which is divided into a high-speed cache area and a low-speed storage area. Custom semantic rules that have been used at least once every two days in the past week and whose scores are in the top 30% of all rule scores after calculation by the priority calculation function are stored in the high-speed cache area to speed up the retrieval speed. Other rules are stored in the low-speed storage area. The rule migration strategy between the high-speed cache area and the low-speed storage area is determined by the migration function. This function determines whether to migrate the rule between the high-speed cache area and the low-speed storage area based on the cache status information of the ratio of the used space in the cache area to the total space and the rate of change of the access frequency of the rule during the statistical period. The calculation formula for the rate of change of the access frequency of the rule during the statistical period is: , Indicates the access frequency of the rule in the current statistical period. Indicates the access frequency of the rule in the previous statistical period.
4. The method for constructing an agent-based Text2MDX framework according to claim 1, characterized in that: In step 5, after generating an MDX expression, the MDX synthesis agent uses a verification algorithm to perform syntax verification and semantic verification on the expression. The syntax verification algorithm builds a custom syntax rule tree and matches the generated expression with the rule tree for verification. The semantic verification compares the data dictionary in the multidimensional data model with the semantic elements in the expression to ensure that the expression can correctly query the target data. The syntax verification algorithm formula is as follows: ; The semantic verification algorithm formula is as follows: ; in, Represents the generated MDX expression, Represents a grammar rule tree, Represents the data dictionary. During the semantic verification process, a fuzzy matching algorithm is used to match the semantic elements in the expression with the data dictionary. ,in, Represents an expression semantic element, Represents an element in the data dictionary, Indicates matching tolerance to handle possible differences in semantic expressions. The fuzzy matching algorithm calculates the character edit distance between semantic elements and data dictionary elements and adjusts the matching results in combination with the semantic relevance weight.
5. The method for constructing an agent-based Text2MDX framework according to claim 1, characterized in that: When the semantic parsing agent identifies fuzzy semantics in the input text, it uses an algorithm based on fuzzy logic reasoning to clarify the semantics. The fuzzy logic reasoning algorithm constructs a fuzzy membership function to quantitatively analyze the fuzzy semantics and determine the most likely accurate semantics. The fuzzy membership function is as follows: ; in, is a fuzzy semantic element, is a set of customized fuzzy membership parameters. The membership of fuzzy semantics in different accurate semantic sets is calculated through this function, so as to determine the accurate semantics that meets the user's intention. The fuzzy membership parameters Adjust according to the field to which the text belongs and the user's historical query habits.
6. The method for constructing an agent-based Text2MDX framework according to claim 1, characterized in that: In step 1, various parameters in the text semantic decomposition algorithm used by the semantic parsing agent , each time the text is processed, it will be dynamically adjusted according to the real-time characteristics of the text through the parameter update function, the parameter update function is as follows: ; in, It is based on data on vocabulary changes and grammatical structure evolution Updated custom functions are used to improve the accuracy of decomposing different types of texts. Vocabulary change data is obtained by comparing the vocabulary set differences between the current text and historical texts, and grammatical structure evolution data is obtained by analyzing the syntactic structure change trends of continuous texts.
7. The method for constructing an agent-based Text2MDX framework according to claim 1, characterized in that: After the MDX synthesis agent generates an MDX expression, it optimizes the expression according to the performance optimization index of the multidimensional data model. During the optimization process, the query order and connection method in the expression are adjusted according to the association relationship between different data sets in the data model and the index settings through the following formula to improve query efficiency: ; in, Represents the generated MDX expression, Represents the set of all query sequences, Represents the data set in the query order The query cost itself, which is based on the size of the data set , Index Selectivity And the complexity of the filter conditions It is calculated by the formula, which is as follows: ; Representing a data set The connection cost between them is used to find the query sequence that minimizes the total cost, optimize the MDX expression, and improve query performance.
Citation Information
Cited By
Method for generating SQL (structured query language) from natural language based on bidirectional mapping and semantic analysis
CN120910087A
Intelligent semantic analysis method and system based on MDX framework
CN121935268A