Report generation method and device, equipment, medium and program product
By parsing the report description text using a large model and optimizing the query statement using a preset domain terminology dictionary and prompt words, the accuracy and efficiency issues in generating reports from large models are solved, achieving efficient and accurate data extraction and report generation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-17
- Publication Date
- 2026-03-27
AI Technical Summary
Large models, due to limited background knowledge, result in low accuracy of query statements and low data extraction efficiency when generating reports, failing to meet the personalized needs of different users.
The report description text is analyzed by a large model, and evaluation suggestions are generated by using a preset domain terminology dictionary and prompt words. The query statement is optimized to improve accuracy, and the target query statement is generated by combining the user's input optimization instructions to perform data query and report generation.
It improves the accuracy of report generation and the efficiency of data extraction, ensuring that the large model understands user needs and generates high-quality reports that meet user intent.
Smart Images

Figure CN121743348A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence, and more specifically to a report generation method, apparatus, device, medium, and program product. Background Technology
[0002] With the development of artificial intelligence technology and the increase in the amount of report data, using large models for data analysis and report generation has become the main way for users to improve the efficiency of report production.
[0003] By understanding users' natural language descriptions through large models, report formats that meet user needs can be automatically generated. However, different users have different report generation requirements. Since the capabilities of large models are limited by the support of background knowledge, the accuracy of the query statements transformed by large models needs to be improved, which affects the quality and efficiency of data extraction. Summary of the Invention
[0004] In view of the above problems, this application provides a method, apparatus, device, medium and program product for improving the accuracy of report generation.
[0005] According to a first aspect of this application, a report generation method is provided, the method comprising: responding to user input of report description text, parsing the report description text using a large model to obtain target report elements; using the large model to convert a received query session into candidate query statements, and guiding the large model to generate evaluation suggestions based on the candidate query statements based on preset first prompt words, the first prompt words including reasoning steps for guiding the large model to evaluate the candidate query statements, and the evaluation suggestions for prompting the user to input second prompt words for optimizing the candidate query statements; guiding the large model to optimize the candidate query statements based on multiple received second prompt words to obtain a target query statement; and querying a preset report database using the target query statement to obtain target data and populating it into the report structure indicated by the target report elements to obtain a target report.
[0006] According to an embodiment of this application, the process of parsing report description text using a large model to obtain target report elements includes: performing word segmentation on the report description text based on a report element benchmark indicated by a preset domain terminology dictionary to obtain structured text; and guiding the large model to process the structured text based on a preset third prompt word to obtain target report elements. The third prompt word is used to indicate the element extraction step and the element verification step of the structured text.
[0007] According to an embodiment of this application, the preset third prompt word includes multiple first sub-prompt words and multiple second sub-prompt words. Based on the preset third prompt word, the large model is guided to process structured text to obtain target report elements, including: based on multiple first sub-prompt words, the large model is guided to process structured text according to pre-stored association rules and element extraction steps to obtain multiple candidate report elements, where association rules characterize the association relationships between report elements; based on multiple second sub-prompt words, the large model is guided to process multiple candidate report elements according to element verification steps, and if the verification passes, the target report element is obtained.
[0008] According to embodiments of this application, converting a received query session into candidate query statements using a large model includes: performing named entity recognition on the preprocessed query session to form an information list, the information list including multiple information categories, each of which has a matching intent type, and the multiple information categories indicating the user's query intent; processing the preprocessed query session through a trained intent recognition model to obtain intent types, converting the information categories in the information list that match the intent types into intent elements, the intent elements indicating the user's query scope; retrieving query statement templates based on intent types from a preset query statement template library to obtain query statement templates, mapping intent elements to query statement templates to obtain candidate query statements.
[0009] According to an embodiment of this application, the process of guiding a large model to generate evaluation suggestions based on candidate query statements, based on a preset first prompt word, includes: performing grammatical verification and keyword extraction on the candidate query statements to obtain a query structure summary, wherein the query structure summary represents the grammatical structure of the candidate query statements; and guiding the large model to call preset evaluation rules and process the candidate query statements and query structure summaries according to the reasoning steps, based on the preset first prompt word, to obtain evaluation suggestions, wherein the evaluation rules indicate the evaluation dimensions and evaluation criteria of the candidate query statements.
[0010] According to embodiments of this application, guiding a large model to optimize candidate query statements based on received second prompt words to obtain a target query statement includes: extracting keywords from the second prompt words to obtain at least one of optimization objectives, constraints, and auxiliary requirements, wherein the optimization objective indicates the optimization direction of the candidate query statement, the constraints indicate the optimization limitations of the candidate query statement, and the auxiliary requirements indicate the user's optimization preferences; guiding the large model to perform anomaly detection on the candidate query statement based on the diagnostic dimension of the optimization objective matching to obtain the position to be optimized; and guiding the large model to optimize the candidate query statement under the constraints and / or auxiliary requirements based on the position to be optimized to obtain the target query statement.
[0011] According to embodiments of this application, the evaluation recommendations include at least one of index optimization, query simplification, execution plan optimization, syntax optimization, and semantic optimization.
[0012] A second aspect of this application provides a report generation apparatus, comprising: a parsing module, configured to parse the report description text using a large model in response to user input of report description text to obtain target report elements; a conversion module, configured to convert a received query session into candidate query statements using the large model, and guide the large model to generate evaluation suggestions based on the candidate query statements based on preset first prompt words, the first prompt words including reasoning steps for guiding the large model to evaluate the candidate query statements, the evaluation suggestions for prompting the user to input second prompt words for optimizing the candidate query statements; an optimization module, configured to guide the large model to optimize the candidate query statements based on multiple received second prompt words to obtain a target query statement; and a generation module, configured to query a preset report database using the target query statement to obtain target data and populate it into the report structure indicated by the target report elements to obtain a target report.
[0013] A third aspect of this application provides an electronic device comprising: one or more processors; and a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the method described above.
[0014] A fourth aspect of this application also provides a computer-readable storage medium having a computer program or instructions stored thereon, which, when executed by a processor, implement the steps of the above-described method.
[0015] The fifth aspect of this application also provides a computer program product, including a computer program or instructions that, when executed by a processor, implement the steps of the above-described method.
[0016] According to the report generation method, apparatus, device, medium, and program products provided in this application, a large model is used to convert the received query session into candidate query statements, and the candidate query statements are evaluated to generate evaluation suggestions for prompting the user to input optimization instructions. The candidate query statements are then optimized in combination with the second prompt word input by the user so that the large model can fully understand the user's needs, ensure the functional accuracy of the target query statement, and then use the target query statement to perform data query and report generation, thereby improving data extraction efficiency and report generation quality. Attached Figure Description
[0017] The above-mentioned contents, other objects, features and advantages of this application will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:
[0018] Figure 1 The illustrations depict application scenarios of report generation methods, apparatus, devices, media, and program products according to embodiments of this application.
[0019] Figure 2A flowchart illustrating a report generation method according to an embodiment of this application is shown schematically;
[0020] Figure 3 A flowchart illustrating the parsing of report description text according to an embodiment of this application is shown schematically;
[0021] Figure 4 A flowchart illustrating the evaluation recommendations according to embodiments of this application is shown schematically;
[0022] Figure 5 This schematically illustrates a structural block diagram of a report generation apparatus according to an embodiment of this application; and
[0023] Figure 6 A block diagram schematically illustrates an electronic device suitable for implementing a report generation method according to an embodiment of this application. Detailed Implementation
[0024] The embodiments of this application will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of this application. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of this application for ease of explanation. However, it will be apparent that one or more embodiments may be implemented without these specific details. Furthermore, descriptions of well-known structures and technologies are omitted in the following description to avoid unnecessarily obscuring the concepts of this application.
[0025] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of this application. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0026] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.
[0027] When using expressions such as "at least one of A, B and C", they should generally be interpreted in accordance with the meaning that is commonly understood by those skilled in the art (e.g., "a system having at least one of A, B and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B and C, etc.).
[0028] In the technical solution of this application, the user information (including but not limited to user personal information, user image information, user device information, such as location information) and data (including but not limited to data used for analysis, stored data, and displayed data) involved are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of related data all comply with relevant laws, regulations, and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entry points for users to choose to authorize or refuse.
[0029] In scenarios involving automated decision-making using personal information, the methods, devices, and systems provided in this application all offer users corresponding entry points for choosing to agree to or reject the automated decision-making results. If the user chooses to reject, the process proceeds to the expert decision-making stage. Here, "automated decision-making" refers to the activity of automatically analyzing and evaluating an individual's behavioral habits, interests, or economic, health, and credit status through computer programs, and then making a decision. Here, "expert decision-making" refers to the activity of making decisions by personnel who specialize in a particular field, possess specialized experience, knowledge, and skills, and have reached a certain level of professional expertise.
[0030] The embodiments of this application provide a report generation method, which uses a large model to parse the report description text, clarifies the report type required by the user, and uses the large model to obtain the target query statement for querying the user's required data based on the query session, ensuring the efficiency of report generation and data extraction; at the same time, in the process of generating the target query statement, the candidate query statements obtained from the initial transformation are evaluated and optimized in combination with the user's requirements to ensure the functional accuracy of the target query statement.
[0031] Figure 1 The diagram illustrates an application scenario of the report generation method according to an embodiment of this application.
[0032] like Figure 1 As shown, application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 serves as a medium for providing a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0033] Users can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 via the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).
[0034] The first terminal device 101, the second terminal device 102, and the third terminal device 103 can be various electronic devices with displays and support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0035] Server 105 can be a server that provides various services, such as a backend management server that supports websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103 (this is just an example). The backend management server can analyze and process data such as received user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal devices.
[0036] It should be noted that the report generation method provided in this application embodiment can generally be executed by server 105. Correspondingly, the report generation device provided in this application embodiment can generally be located in server 105. The report generation method provided in this application embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105. Correspondingly, the report generation device provided in this application embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105.
[0037] It should be understood that Figure 1 The number of terminal devices, network 104, and server 105 shown is merely illustrative. Any number of terminal devices, network 104, and server 105 can be used depending on implementation needs.
[0038] The following will be based on Figure 1 The described scene, through Figures 2-4 The report generation method according to the embodiments of this application will be described in detail.
[0039] Figure 2 A flowchart illustrating a report generation method according to an embodiment of this application is shown schematically. Figure 3A flowchart illustrating the parsing of report description text 301 according to an embodiment of this application is shown. Figure 4 A flowchart illustrating the evaluation recommendation 403 according to an embodiment of this application is shown.
[0040] Combination Figures 2-4 The report generation method in this embodiment includes operations S210 to S240.
[0041] In operation S210, in response to the user input of report description text 301, the large model 303 is used to parse the report description text 301 to obtain the target report element 304.
[0042] According to an embodiment of this application, the report description text 301 is used to indicate the user's report generation requirements, such as generating a quarterly bar chart displaying sales and profits, or generating a pie chart displaying the revenue share of each product; the target report element 304 is used to indicate the key elements of the target report, which may include report type, data indicators, grouping method, statistical period, etc. For example, the report type may be a bar chart, the data indicators may be sales and profits, the grouping method may be a region, and the statistical period may be a quarter.
[0043] The large model 303 refers to a general-purpose artificial intelligence model trained on massive amounts of data and a large number of parameters using deep learning technology. In the process of using the large model 303 to parse the report description text 301 to obtain the target report elements 304, the natural language processing technology of the large language model can be used to deeply understand the user's intent and implied meanings, such as the time range and report type indicated by the "quarterly bar chart," thereby obtaining the user's report generation requirements. Among these, natural language understanding technology enables the model not only to recognize keywords and phrases but also to track the user's intent and dialogue state in multi-turn conversations, thus providing a more comprehensive interpretation of the user's needs.
[0044] In operation S220, the large model 303 converts the received query session into candidate query statements 401, and based on the preset first prompt words, guides the large model 303 to generate evaluation suggestions 403 based on the candidate query statements 401.
[0045] According to an embodiment of this application, the query session can be a data query statement input by the user into the large model 303 through multiple rounds of question and answer, which can reflect the user's data query needs, such as querying the sales of a certain quarter; the first prompt word includes a reasoning step for guiding the large model 303 to evaluate the candidate query statement 401, and the evaluation suggestion 403 is used to prompt the user to input a second prompt word for optimizing the candidate query statement 401.
[0046] Furthermore, the large model 303 is used to perform deep understanding and knowledge reasoning on the query session, identify the query intent in the query session, and use the query intent to retrieve candidate query statements 401 from the preset query statement template library; the large model 303 processes the candidate query statements 401 according to the reasoning steps of evaluating the candidate query statements 401, and generates evaluation suggestions 403.
[0047] For example, the query intent may include the query object, operation target, filtering conditions, etc. The reasoning steps for evaluating the candidate query statement 401 may include evaluating the candidate query statement 401 according to the evaluation rules. The evaluation rules may include grammatical rationality verification and structural analysis according to the query statement grammar standards. The evaluation suggestions 403 may include index optimization, query statement simplification, etc.
[0048] In operation S230, the large model 303 optimizes the candidate query statement 401 based on the received multiple second prompt words to obtain the target query statement.
[0049] According to an embodiment of this application, multiple second prompt words include optimization reasoning steps for candidate query statements 401. Based on multiple second prompt words, the large model 303 is guided to process candidate query statements 401 according to the optimization reasoning steps to obtain the target query statement.
[0050] For example, multiple second suggestion words may include: optimizing the readability of candidate query statement 401, disabling new indexes, and adapting it to database version 8.0.
[0051] In operation S240, the target query statement is used to query the preset report database, obtain the target data, and populate it into the report structure indicated by the target report element 304 to obtain the target report.
[0052] According to an embodiment of this application, the report database may include all data that can be used for data analysis as the data source for report generation; the target report element 304 also includes the report structure, that is, the report layout under the current report type, data indicators, and grouping method.
[0053] For example, the target data is obtained by querying the preset report database using the target query statement and filling it into the fill position of the corresponding data indicator to obtain the target report.
[0054] Through the above operations S210 to S240, the large model 303 parses the report description text 301 to obtain the target report elements 304 that reflect the report requirements, thereby improving the efficiency of report generation. The large model 303 converts the received query session into candidate query statements 401 and evaluates the candidate query statements 401 to generate evaluation suggestions 403 for prompting the user to input optimization instructions. The candidate query statements 401 are optimized in combination with the second prompt word input by the user so that the large model 303 can fully understand the user's needs and ensure the functional accuracy of the target query statement. The target query statement is then used to perform data query and report generation, thereby improving the efficiency of data extraction and the quality of report generation.
[0055] Considering the varying report generation needs of different users, and to address the domain adaptation rigidity issue caused by the limitations of the large model 303 due to its own knowledge base reserves, this study aims to improve the reasoning ability of the large model 303 and enhance the reliability of extracting target report elements 304. Figure 3 The parsing process of the report description text 301 shown introduces a preset domain terminology dictionary and third-party prompts into the reasoning process of the large model 303. In some embodiments, operation S210 specifically includes:
[0056] First, based on the report element benchmark indicated by the preset domain terminology dictionary, the report description text 301 is segmented to obtain structured text 302.
[0057] According to embodiments of this application, a preset domain terminology dictionary is used to indicate the benchmark of report elements. It may include multiple report terms, each of which has matching attribute tags. The attribute tags include standard element name, a set of synonyms, corresponding report type (such as profit statement, cash flow statement, custom report), data type (such as numeric, date, text), unit type (such as percentage, yuan, ten thousand yuan), and terminology category (such as basic terminology, compound terminology, custom terminology). Basic terms include "assets," "liabilities," and "revenue," compound terms include "consolidated balance sheet," and custom terms are enterprise-specific elements. The structured text 302 supports structured formats, such as JSON, XML, and other structured formats.
[0058] Furthermore, preprocess the report description text 301. Traverse the preprocessed report description text 301 based on a preset domain term dictionary. First, retrieve the report terms in the domain term dictionary whose length is greater than the preset threshold. If a match is successful, mark the corresponding text in the preprocessed report description text 301 as a standard term and lock it. For the text fragments that do not match the aforementioned report terms, sequentially match them with the remaining terms in the preset domain term dictionary. Mark the successfully matched ones as standard terms, and for those that are not successfully matched, perform word segmentation using a word segmentation tool and mark them as non-standard terms, thereby avoiding splitting long terms in the text into short terms during the word segmentation process. Then, output the word-segmented text based on the structured fields.
[0059] Exemplarily, the preprocessing can be redundant information cleaning, key information pre-marking, sentence splitting, and paragraph splitting. For example, remove punctuation marks, modal particles (such as "呢", "啦") and meaningless filler words (such as "大概", "左右") in the text, identify the numerical values (including integers, decimals, percentages), dates / cycles (such as "2024 annual", "third quarter", "last year"), and units (such as "ten thousand yuan", "percentage point", "%") in the text, and mark them as "numerical value", "cycle", and "unit" tags respectively. Split the report description text 301 into independent semantic units according to semantic pauses (periods, semicolons, commas), and each unit serves as a word segmentation processing unit for traversal. The word segmentation tool can be the bidirectional maximum matching algorithm. The structured fields can include: standard element name, original synonymous expression, numerical value, unit, statistical cycle, report type, data type, source text fragment, and associated validity.
[0060] In an embodiment of the present application, a preset domain term dictionary is used to provide a word segmentation benchmark to solve the problem that general word segmentation tools lack the ability to adapt to terms in the financial report field, resulting in incorrect splitting of professional report terms. For example, "asset-liability ratio" is split into "asset / liability ratio", and structured data associated with core attributes is output, which is convenient for further improving the processing efficiency of the large model 303.
[0061] Then, based on a preset third prompt word, guide the large model 303 to process the structured text 302 to obtain the target report element 304.
[0062] According to an embodiment of the present application, the third prompt word is used to indicate the element extraction step and the element verification step of the structured text 302. The element extraction step is used to guide the large model 303 to extract the report elements in the structured text 302, and the element verification step is used to verify the logic of the report elements.
[0063] For example, based on a preset third prompt word, the large model 303 is guided to process the structured text 302 according to the element extraction step and the element verification step to obtain the target report element 304; the element extraction step and the element verification step correspond to the reasoning steps executed sequentially by the large model 303.
[0064] In the embodiments of this application, after extracting report elements, the inference of the large model 303 is used to verify the elements, which can effectively identify the extraction errors of the large model 303 and improve the reliability of report element extraction.
[0065] In some embodiments, the preset third prompt word includes multiple first sub-prompt words and multiple second sub-prompt words. Based on the preset third prompt word, guiding the large model 303 to process the structured text 302 to obtain the target report element 304 includes: based on multiple first sub-prompt words, guiding the large model 303 to process the structured text 302 according to the element extraction steps based on pre-stored association rules to obtain multiple candidate report elements; based on multiple second sub-prompt words, guiding the large model 303 to process the multiple candidate report elements according to the element verification steps; and obtaining the target report element 304 if the verification passes.
[0066] According to the embodiments of this application, the sub-prompt word (first sub-prompt word or second sub-prompt word) is the smallest guiding unit with a clear division of labor, which is split according to the reasoning steps in the preset third prompt word. Each sub-prompt word corresponds to a specific reasoning step and is used to guide the large model 303 to complete a single sub-task, such as report element extraction, candidate report element verification, target report element 304 output, etc. The sub-prompt word can be preset.
[0067] In the embodiments of this application, the element extraction step and the element verification step are divided into ordered sub-tasks by multiple first sub-prompt words and multiple second sub-prompt words, so that the large model 303 can analyze the report description text 301 and candidate report elements step by step, thereby improving the logic of reasoning.
[0068] According to the embodiments of this application, association rules characterize the relationship between report elements. There are multiple association rules, for example, the data indicator "revenue" is associated with the statistical period "annual", and the data indicator "conversion rate" is associated with the grouping method "time" / "channel".
[0069] For example, multiple first sub-prompt words may include: extracting report type, data indicator and grouping method from structured text 302; determining whether the corresponding fields of report type, data indicator and grouping method are empty; if any corresponding field of report type, data indicator and grouping method is empty, calling the association rule corresponding to the non-empty field; inferring the content of the empty field based on the association rule and structured text 302; and filling the empty field with the inferred content.
[0070] For example, multiple second sub-prompts may include: performing compatibility checks on multiple candidate report elements; if the compatibility check passes, performing industry statistical standard checks on multiple candidate report elements; if the industry statistical standard check passes, outputting the target report element 304 in a structured format; compatibility checks may include a report type of "line chart" and a grouping method that is associated with time grouping; industry standard checks may include a report type of "pie chart" and checking whether the data indicator has "percentage / composition" and whether the data indicator is "deposit interest rate"; checking whether the grouping method is a conventional dimension in the financial field ("region" and "customer type" are compliant, "product category" is not compliant); the structured format may be JSON format, tables, etc.
[0071] In the embodiments of this application, the accuracy of completion is improved by combining the relationships between report elements and the empty fields in the reasoning and completion extraction process of the large model 303; the extracted candidate report elements are verified in accordance with industry standards to ensure the reliability of the output of the target report element 304.
[0072] In some embodiments, converting a received query session into candidate query statements 401 using the large model 303 includes:
[0073] First, named entity recognition is performed on the preprocessed query sessions to form an information list.
[0074] According to embodiments of this application, a query session can provide a multi-turn question-and-answer session for a user to input large model 303 in order to query data. The information list includes multiple information categories, each of which has a matching intent type, and the multiple information categories indicate the user's query intent.
[0075] For example, preprocessing the query session can be done by: removing redundant information such as interjections, polite expressions, and emoticons from the query session, and unifying colloquial expressions (such as "total amount") and synonyms (such as "order") into standard business terms through a business thesaurus.
[0076] For example, the preprocessed query session is processed by a trained Named Entity Recognition (NER) model to obtain multiple information categories and form an information list. At the same time, the information categories are marked at the corresponding positions in the preprocessed query session. The multiple information categories may include time categories, status categories, query object categories, aggregation method categories, etc. Each of the multiple information categories has a corresponding original text, such as "October 2025" → time category, "paid" → status category, "order" → query object category, which reflects the relevant elements for query statement generation and provides basic data for query statement generation.
[0077] Then, the preprocessed query session is processed by the trained intent recognition model to obtain the intent type, and the information categories in the information list that match the intent type are converted into intent elements.
[0078] According to embodiments of this application, the intent element indicates the scope of the user's query.
[0079] For example, the trained intent recognition model can be a text classification model, such as a text convolutional neural network, support vector machine, long short-term memory network, etc. The intent types include data aggregation query intent, data detail query intent, data addition intent, data modification intent, etc. Based on the intent type, the information list is searched to obtain the corresponding information category. The information category and the corresponding text are converted into intent elements. For example, if the intent type is data detail query intent, the information list is searched to obtain the required information categories such as query object class, time class, aggregation method class, etc., which are then converted into table name elements, field elements, filter condition elements, and aggregation method elements. That is, data detail query intent → table name elements, field elements, filter condition elements, aggregation method elements. The query object class "xx order details" table name element "xx order details table", field elements "name: xx", "quantity: xx", etc., the time class "2025-10" → filter condition element "time: 2025-10", and the aggregation method class "sum" → aggregation method element "SUM".
[0080] Then, based on the intent type, a query statement template is retrieved from the preset query statement template library to obtain the query statement template. The intent elements are then mapped to the query statement template to obtain candidate query statement 401.
[0081] According to an embodiment of this application, the query statement template library includes multiple query statement templates, each of which has a matching intent type. For example, the data aggregation query intent corresponds to the aggregation query template. The intent elements are replaced one by one according to the template placeholders. For example, {aggregate function} → SUM(order_amount).
[0082] In the embodiments of this application, by identifying information categories, the query sessions are categorized and organized according to the query statement generation requirements to form an information list. During the intent recognition process, by using the labeling of information categories, the core elements required for the generation of query statements are informed in advance, reducing interference from irrelevant information and improving the accuracy and efficiency of intent recognition.
[0083] Here, the terms "candidate query statement 401" and "query statement" refer to the standard language used for querying the database.
[0084] In some embodiments, based on a preset first prompt word, guiding the large model 303 to generate evaluation suggestions 403 based on candidate query statements 401 includes:
[0085] First, perform syntax validation and keyword extraction on candidate query statement 401 to obtain query structure summary 402.
[0086] According to an embodiment of this application, the query structure summary 402 characterizes the syntactic structure of the candidate query statement 401.
[0087] For example, performing syntax validation on candidate query statements 401 can exclude obviously invalid query statements, such as missing keywords, incorrect field names, or mismatched parentheses; extracting keywords from the remaining candidate query statements 401 can extract the core elements from the remaining candidate query statements 401 to form a query structure summary 402. The query structure summary 402 can include table names / field names, join methods (JOIN type), filtering conditions (WHERE / HAVING), aggregation logic (GROUPBY), execution order, etc., which can reflect the syntactic structure of candidate query statements 401.
[0088] Then, based on the preset first prompt word, the large model 303 is guided to call the preset evaluation rules, process the candidate query statement 401 and query structure summary 402 according to the reasoning steps, and obtain the evaluation suggestion 403.
[0089] According to an embodiment of this application, the evaluation rules indicate the evaluation dimensions and evaluation criteria of the candidate query statement 401. The evaluation dimensions may include syntax, performance, structure, etc., and the evaluation criteria may include query statement syntax criteria, index evaluation rules, query evaluation rules, etc.
[0090] Furthermore, evaluation recommendation 403 includes at least one of the following: index optimization, query simplification, execution plan optimization, syntax optimization, and semantic optimization.
[0091] Based on this, the large model 303 can provide users with comprehensive query optimization suggestions.
[0092] For example, the preset first prompt may include: according to the query syntax standard, checking whether the candidate query statement 401 fully conforms to the query syntax standard, analyzing whether the WHERE / JOIN field has an index, and if there is no index, determining whether to recommend creating an index based on the field query frequency and data volume (e.g., recommending to create a B+ tree index for high-frequency query fields), identifying redundant subqueries, duplicate conditions, invalid DISTINCT, etc., and suggesting replacement with more concise syntax (e.g., changing the subquery to JOIN, merging filter conditions).
[0093] In the embodiments of this application, the large model 303 is used to process the candidate query statement 401 and the query structure summary 402, so that the large model 303 can accurately identify the core elements in the query statement, evaluate the query statement from multiple different dimensions, comprehensively discover problems in the query statement, and reduce the probability of errors when using the query statement.
[0094] In some embodiments, guiding the large model 303 to optimize the candidate query statement 401 based on the received second prompt word to obtain the target query statement includes: extracting keywords from the second prompt word to obtain at least one of the optimization target, constraints, and auxiliary requirements; guiding the large model 303 to perform anomaly detection on the candidate query statement 401 based on the diagnostic dimension of the optimization target matching to obtain the position to be optimized; and guiding the large model 303 to optimize the candidate query statement 401 under the constraints and / or auxiliary requirements based on the position to be optimized to obtain the target query statement.
[0095] According to an embodiment of this application, the optimization objective indicates the optimization direction of the candidate query statement 401, the constraint condition indicates the optimization restrictions of the candidate query statement 401, and the auxiliary requirements indicate the user's optimization preferences.
[0096] For example, firstly, the optimization objectives, constraints, and auxiliary requirements in the second prompt words are extracted using natural language processing entity recognition technology and transformed into structured data. Optimization objectives can be readability-related (e.g., grammar simplification, comment retention) or resource-related (e.g., reducing disk usage). Constraints can be prohibiting the addition of new indexes / table structures or prohibiting subqueries. Auxiliary requirements can be retaining comments or splitting complex queries. Then, the large model 303 is guided to perform anomaly detection on the candidate query statement 401 based on the diagnostic dimensions of the optimization objective matching to obtain the position to be optimized. The diagnostic dimensions of the optimization objective matching can include the diagnostic dimensions of readability matching, such as subquery nesting level, grammatical redundancy, and alias standardization. Then, under the constraints, the large model 303 calls the optimization strategies in the optimization strategy library to process the candidate query statement 401 to obtain the target query statement. For example, if the position to be optimized is an index, the anomaly is index failure, and the constraint is prohibiting the addition of new indexes, the optimization strategy is syntax transformation. Finally, the optimized candidate query statement 401 is subjected to syntax verification, and the candidate query statement 401 that passes the syntax verification is used as the target query statement.
[0097] In the embodiments of this application, the second prompt word is decomposed, and anomaly detection is performed with the optimization target as the direction. The candidate query statement 401 is diagnosed in a targeted manner to improve the diagnostic efficiency. The candidate query statement 401 is optimized under the constraints to ensure that the optimization operation of the large model 303 is closely integrated with the user's needs.
[0098] Based on the above report generation method, this application also provides a report generation apparatus. The following will combine... Figure 5 The device is described in detail.
[0099] Figure 5 A schematic block diagram of a report generation apparatus according to an embodiment of this application is shown.
[0100] like Figure 5 As shown, the report generation device 500 of this embodiment includes a parsing module 510, a conversion module 520, an optimization module 530, and a generation module 540.
[0101] The parsing module 510 is used to respond to the user input of report description text 301, and uses the large model 303 to parse the report description text 301 to obtain the target report element 304. In one embodiment, the parsing module 510 can be used to perform the operation S210 described above, which will not be repeated here.
[0102] The conversion module 520 is used to convert the received query session into candidate query statements 401 using the large model 303. Based on a preset first prompt word, it guides the large model 303 to generate evaluation suggestions 403 based on the candidate query statements 401. The first prompt word includes reasoning steps to guide the large model 303 to evaluate the candidate query statements 401. The evaluation suggestions 403 are used to prompt the user to input a second prompt word to optimize the candidate query statements 401. In one embodiment, the conversion module 520 can be used to perform the operation S220 described above, which will not be repeated here.
[0103] The optimization module 530 is used to guide the large model 303 to optimize the candidate query statement 401 based on the received multiple second prompt words, so as to obtain the target query statement. In one embodiment, the optimization module 530 can be used to perform the operation S230 described above, which will not be repeated here.
[0104] The generation module 540 is used to query a preset report database using a target query statement, obtain target data, and populate it into the report structure indicated by the target report element 304 to obtain the target report. In one embodiment, the optimization module 530 can be used to perform the operation S240 described above, which will not be repeated here.
[0105] According to an embodiment of this application, the parsing module 510 includes a word segmentation submodule and a processing submodule. The word segmentation submodule performs word segmentation on the report description text 301 based on the report element benchmark indicated by a preset domain terminology dictionary to obtain structured text 302. The processing submodule is used to guide the large model 303 to process the structured text 302 based on a preset third prompt word to obtain the target report element 304. The third prompt word is used to indicate the element extraction step and the element verification step of the structured text 302.
[0106] According to an embodiment of this application, the processing submodule includes an element extraction unit and an element verification unit. The element extraction unit is used to guide the large model 303 to process the structured text 302 according to the element extraction steps based on multiple first sub-prompt words and pre-stored association rules to obtain multiple candidate report elements. The association rules represent the association relationship between the report elements. The element verification unit is used to guide the large model 303 to process the multiple candidate report elements according to the element verification steps based on multiple second sub-prompt words. If the verification is successful, the target report element 304 is obtained.
[0107] According to an embodiment of this application, the conversion module 520 includes an identification submodule, a conversion submodule, and a retrieval submodule. The identification submodule is used to perform named entity recognition on the preprocessed query session to form an information list. The information list includes multiple information categories, each of which has a matching intent type. The multiple information categories indicate the user's query intent. The conversion submodule is used to process the preprocessed query session through a trained intent recognition model to obtain the intent type. It converts the information categories in the information list that match the intent type into intent elements. The intent elements indicate the user's query scope. The retrieval submodule is used to retrieve from a preset query statement template library based on the intent type to obtain a query statement template. It maps the intent elements to the query statement template to obtain candidate query statements 401.
[0108] According to an embodiment of this application, the conversion module 520 further includes an extraction submodule and a generation submodule. The extraction submodule is used to perform grammar verification and keyword extraction on the candidate query statement 401 to obtain a query structure summary 402, which represents the grammatical structure of the candidate query statement 401. The generation submodule is used to guide the large model 303 to call preset evaluation rules and process the candidate query statement 401 and the query structure summary 402 according to the reasoning steps based on preset first prompt words to obtain evaluation suggestions 403. The evaluation rules indicate the evaluation dimensions and evaluation criteria of the candidate query statement 401.
[0109] According to an embodiment of this application, the optimization module 530 includes a keyword extraction submodule, a detection submodule, and an optimization submodule. The keyword extraction submodule is used to extract keywords from the second prompt word to obtain at least one of the optimization target, constraints, and auxiliary requirements. The optimization target indicates the optimization direction of the candidate query statement 401, the constraints indicate the optimization limitations of the candidate query statement 401, and the auxiliary requirements indicate the user's optimization preferences. The detection submodule is used to guide the large model 303 to perform anomaly detection on the candidate query statement 401 based on the diagnostic dimension of matching the optimization target to obtain the position to be optimized. The optimization submodule is used to guide the large model 303 to optimize the candidate query statement 401 under the constraints and / or auxiliary requirements based on the position to be optimized to obtain the target query statement.
[0110] According to embodiments of this application, any plurality of modules among the parsing module 510, conversion module 520, optimization module 530, and generation module 540 can be merged into one module, or any one of these modules can be split into multiple modules. Alternatively, at least part of the functionality of one or more of these modules can be combined with at least part of the functionality of other modules and implemented in one module. According to embodiments of this application, at least one of the parsing module 510, conversion module 520, optimization module 530, and generation module 540 can be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or implemented in hardware or firmware by any other reasonable means of integrating or packaging circuitry, or implemented in software, hardware, or firmware, or in any appropriate combination of any of these three implementation methods. Alternatively, at least one of the parsing module 510, conversion module 520, optimization module 530, and generation module 540 can be at least partially implemented as a computer program module, which can perform corresponding functions when the computer program module is run.
[0111] Figure 6 A block diagram schematically illustrates an electronic device suitable for implementing a report generation method according to an embodiment of this application.
[0112] like Figure 6 As shown, an electronic device 600 according to an embodiment of this application includes a processor 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage portion 608 into a random access memory (RAM) 603. The processor 601 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 601 may also include onboard memory for caching purposes. The processor 601 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of this application.
[0113] RAM 603 stores various programs and data required for the operation of electronic device 600. Processor 601, ROM 602, and RAM 603 are interconnected via bus 604. Processor 601 executes various operations of the method flow according to embodiments of this application by executing programs in ROM 602 and / or RAM 603. It should be noted that the programs may also be stored in one or more memories other than ROM 602 and RAM 603. Processor 601 may also execute various operations of the method flow according to embodiments of this application by executing programs stored in said one or more memories.
[0114] According to embodiments of this application, the electronic device 600 may further include an input / output (I / O) interface 605, which is also connected to a bus 604. The electronic device 600 may also include one or more of the following components connected to the input / output (I / O) interface 605: an input section 606 including a keyboard, mouse, etc.; an output section 607 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the input / output (I / O) interface 605 as needed. A removable medium 611, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 610 as needed so that computer programs read from it can be installed into the storage section 608 as needed.
[0115] This application also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs, which, when executed, implement the method according to the embodiments of this application.
[0116] According to embodiments of this application, the computer-readable storage medium can be a non-volatile computer-readable storage medium, such as including but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of this application, the computer-readable storage medium may include ROM 602 and / or RAM 603 and / or one or more memories other than ROM 602 and RAM 603 described above.
[0117] Embodiments of this application also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code is used to enable the computer system to implement the report generation method provided in the embodiments of this application.
[0118] When the computer program is executed by the processor 601, it performs the functions defined in the system / apparatus of this application embodiment. According to the embodiments of this application, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0119] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and downloaded and installed via the communication section 609, and / or installed from the removable medium 611. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.
[0120] In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 609, and / or installed from the removable medium 611. When the computer program is executed by the processor 601, it performs the functions defined in the system of this application embodiment. According to the embodiments of this application, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0121] According to embodiments of this application, program code for executing the computer programs provided in the embodiments of this application can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, Python, "C", or similar programming languages. The program code can be executed entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0122] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0123] Those skilled in the art will understand that the features described in the various embodiments of this application can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in this application. In particular, the features described in the various embodiments of this application can be combined and / or combined in various ways without departing from the spirit and teachings of this application. All such combinations and / or combinations fall within the scope of this application.
Claims
1. A report generation method, characterized in that, The method includes: In response to user input of report description text, the large model is used to parse the report description text to obtain the target report elements; The large model converts the received query session into candidate query statements. Based on a preset first prompt word, the large model is guided to generate evaluation suggestions based on the candidate query statements. The first prompt word includes reasoning steps to guide the large model to evaluate the candidate query statements. The evaluation suggestions are used to prompt the user to input a second prompt word to optimize the candidate query statements. Based on the received multiple second prompt words, the large model is guided to optimize the candidate query statement to obtain the target query statement; The target data is obtained by querying the preset report database using the target query statement and then filling it into the report structure indicated by the target report element to obtain the target report.
2. The method according to claim 1, characterized in that, The process of parsing the report description text using a large model to obtain the target report elements includes: Based on the report element benchmark indicated by the preset domain terminology dictionary, the report description text is segmented to obtain structured text; Based on a preset third prompt word, the large model is guided to process the structured text to obtain target report elements. The third prompt word is used to indicate the element extraction step and the element verification step of the structured text.
3. The method according to claim 2, characterized in that, The preset third prompt word includes multiple first sub-prompt words and multiple second sub-prompt words. Based on the preset third prompt word, the large model is guided to process the structured text to obtain the target report elements, including: Based on the multiple first sub-prompt words, the large model is guided to process the structured text according to the element extraction steps based on the pre-stored association rules, and obtain multiple candidate report elements. The association rules represent the relationship between the report elements. Based on the multiple second sub-prompt words, the large model is guided to process the multiple candidate report elements according to the element verification steps, and the target report element is obtained when the verification is passed.
4. The method according to claim 1, characterized in that, The process of converting the received query session into candidate query statements using the large model includes: Named entity recognition is performed on the preprocessed query session to form an information list. The information list includes multiple information categories, each of which has a matching intent type. The multiple information categories indicate the user's query intent. The preprocessed query session is processed by a trained intent recognition model to obtain intent types. Information categories in the information list that match the intent types are converted into intent elements, which indicate the scope of the user's query. Based on the intent type, a query statement template is retrieved from a preset query statement template library to obtain a query statement template. The intent element is then mapped to the query statement template to obtain a candidate query statement.
5. The method according to claim 1, characterized in that, The step of guiding the large model to generate evaluation suggestions based on the candidate query statement based on the preset first prompt word includes: The candidate query statements are subjected to syntax validation and keyword extraction to obtain a query structure summary, which represents the syntactic structure of the candidate query statements; Based on the preset first prompt word, the large model is guided to call the preset evaluation rules, process the candidate query statement and the query structure summary according to the reasoning steps, and obtain evaluation suggestions. The evaluation rules indicate the evaluation dimensions and evaluation criteria of the candidate query statement.
6. The method according to claim 1, characterized in that, The process of guiding the large model to optimize the candidate query statement based on the received second prompt word to obtain the target query statement includes: Keyword extraction is performed on the second prompt word to obtain at least one of the following: optimization objective, constraint condition, and auxiliary requirement. The optimization objective indicates the optimization direction of the candidate query statement, the constraint condition indicates the optimization limitation of the candidate query statement, and the auxiliary requirement indicates the user's optimization preference. Based on the diagnostic dimensions of the optimization target matching, the large model is guided to perform anomaly detection on the candidate query statements to obtain the position to be optimized; Based on the position to be optimized, the large model is guided to optimize the candidate query statement under the constraints and / or auxiliary requirements to obtain the target query statement.
7. The method according to any one of claims 1 to 6, characterized in that, The evaluation recommendations include at least one of the following: index optimization, query simplification, execution plan optimization, syntax optimization, and semantic optimization.
8. A report generation device, characterized in that, The device includes: The parsing module is used to respond to the user's input of report description text, and use the large model to parse the report description text to obtain the target report elements; The conversion module is used to convert the received query session into candidate query statements using the large model, and guide the large model to generate evaluation suggestions based on the candidate query statements based on a preset first prompt word. The first prompt word includes a reasoning step for guiding the large model to evaluate the candidate query statements. The evaluation suggestions are used to prompt the user to input a second prompt word for optimizing the candidate query statements. An optimization module is used to guide the large model to optimize the candidate query statement based on multiple received second prompt words, thereby obtaining the target query statement; and The generation module is used to query a preset report database using the target query statement, obtain target data, and populate it into the report structure indicated by the target report element to obtain the target report.
9. An electronic device, comprising: One or more processors; Memory, used to store one or more computer programs. The characteristic feature is that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program or instructions stored thereon, characterized in that, When the computer program or instructions are executed by a processor, they implement the steps of the method according to any one of claims 1 to 7.
11. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instructions are executed by a processor, they implement the steps of the method according to any one of claims 1 to 7.