Bill information query method and device, storage medium and electronic equipment
By converting natural language text into SQL query statements and performing queries in non-tax data wide tables, the difficulty and efficiency of query operations in the non-tax invoice management mode is solved, and more flexible and efficient bill information query is achieved.
Patent Information
- Application Number
- CN202411844487.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-13
- Publication Date
- 2025-03-25
AI Technical Summary
In the non-tax invoice management model, users need to perform precise matching query operations in a complex database architecture based on preset query conditions, resulting in increased operational difficulty and poor flexibility and efficiency.
By receiving the natural language text of the bill information entered by the user, the conversion interface of the text conversion model service is called to convert the natural language text into SQL query statements, and the query is executed in the non-tax data wide table to obtain the query results corresponding to the SQL query statement.
It reduces the difficulty of users' operation, improves the flexibility and query efficiency of query operations, and automatically obtains the target query results corresponding to the ticket information query problem.
Smart Images

Figure CN119690994A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a bill information query method and device, storage medium and electronic device thereof. Background Art
[0002] In the context of digital transformation driving economic and social development, and with the in-depth implementation of the national data industry high-quality development strategy and artificial intelligence capability enhancement plan, fiscal and medical non-tax electronic invoices, as key vouchers in the non-tax revenue management system, their data accuracy, processing efficiency, in-depth analysis and effective use of data information have become core elements for improving management efficiency and scientific decision-making.
[0003] In the non-tax invoice management model of related technologies, when performing data retrieval and analysis tasks, users are often required to perform precise matching query operations in a complex database architecture based on preset query conditions. This process increases the difficulty of operation for users who do not have knowledge of database structure and the ability to write query statements, resulting in poor flexibility and efficiency of query operations. Summary of the invention
[0004] In view of this, an embodiment of the present application provides a bill information query method and its device, storage medium and electronic device to solve or alleviate the problems of poor flexibility and query efficiency of query operations in related technologies.
[0005] According to the first aspect of an embodiment of the present application, a bill information query method is provided, the method comprising: receiving a natural language text of a bill information query question entered by a user; calling a conversion interface of a text conversion model service to convert the natural language text into an SQL query statement; generating a non-tax data wide table including associated bill element fields and bill item fields, and executing a query in the non-tax data wide table to obtain a query result corresponding to the SQL query statement, wherein the non-tax data wide table is stored in a local query database; summarizing the query results to obtain a target query result corresponding to the bill information query question.
[0006] In some embodiments of the present application, a conversion interface of a text conversion model service is called to convert natural language text into an SQL query statement, including: creating a prompt template consisting of at least one prompt element; inputting a training data set and a prompt template into a pre-trained conversion model, and fine-tuning the pre-trained model; building a text conversion model service locally based on the trained pre-trained conversion model, and configuring the conversion interface through a model management tool installed in an offline environment; and calling the conversion interface to convert natural language text into an SQL query statement.
[0007] In some embodiments of the present application, a prompt template consisting of at least one prompt element is created, including: creating a preset prompt template through a prompt project, and adding an instruction element, a data structure element, a reference sample element, a constraint element, a domain knowledge element and a user question element as at least one prompt element in the preset prompt template; adding the address information of the non-tax data wide table and the query database to the data structure element to obtain the prompt template.
[0008] In some embodiments of the present application, before receiving the natural language text of the ticket information query question entered by the user, the ticket information query method also includes: encapsulating the natural language text of the user's question into a query text in a preset data exchange format through a management terminal; sending the query text to a text conversion model service deployed on the management server through a query interface and a data transmission protocol, so as to convert the natural language text into an SQL query statement through the text conversion model service.
[0009] In some embodiments of the present application, after aggregating the query results to obtain the target query results corresponding to the ticket information query question, the ticket information query method also includes: aggregating the query data in the target query results into text form or chart form, and encapsulating them into target query results in a preset data exchange format; through the query interface and data transmission protocol, sending the target query results in the preset data exchange format to the terminal interface for display.
[0010] In some embodiments of the present application, a non-tax data wide table including associated bill element fields and bill item fields is generated, including: determining the bill element fields and bill item fields in the data wide table to be created; selecting corresponding data types and data lengths for the bill element fields and bill item fields; creating a data wide table in a query database, and defining the bill element fields and bill item fields in the data wide table; collecting basic bill information, bill transaction information and medical item information, and writing the basic bill information and bill transaction information into the bill element fields, and writing the medical item information into the bill item fields, to obtain the non-tax data wide table.
[0011] In some embodiments of the present application, a query is performed in a non-tax data wide table to obtain a query result corresponding to the SQL query statement, including: receiving an SQL query statement and establishing a communication connection with a query database; searching the non-tax data wide table in the query database, and querying the query result corresponding to the SQL query statement in the bill element field and the bill item field of the non-tax data wide table, wherein the query result includes at least one of the bill basic information, bill transaction information and medical item information.
[0012] According to the second aspect of an embodiment of the present application, a bill information query device is provided, which includes: a receiving module for receiving a natural language text of a bill information query question entered by a user; a conversion module for calling a conversion interface of a text conversion model service to convert the natural language text into an SQL query statement; an execution module for generating a non-tax data wide table including associated bill element fields and bill item fields, and executing a query in the non-tax data wide table to obtain a query result corresponding to the SQL query statement, wherein the non-tax data wide table is stored in a local query database; and a summary module for summarizing the query results to obtain a query result corresponding to the bill information query question.
[0013] According to the third aspect of the embodiments of the present application, there is provided an electronic device comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform operations corresponding to the ticket information query method of any of the above embodiments.
[0014] According to a fourth aspect of the embodiments of the present application, a computer storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, a ticket information query method as described in any of the above embodiments is implemented.
[0015] According to the bill information query method and its device, storage medium and electronic device provided in the embodiments of the present application, after converting the natural language text into an SQL query statement by calling the conversion interface of the text conversion model service, a differential selection is performed in the created non-tax data wide table to obtain the query result corresponding to the SQL query statement, and the query results are summarized to automatically obtain the target query result corresponding to the bill information query question, thereby reducing the user's operation difficulty and improving the flexibility and efficiency of the query operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0017] Figure 1 A flowchart of a method for querying bill information according to an embodiment of the present application is shown in FIG.
[0018] Figure 2 A statement conversion diagram of a bill information query method according to the present application;
[0019] Figure 3A schematic diagram of the application architecture of a bill information query method according to the present application;
[0020] Figure 4 A schematic diagram of the structure of a bill information query device according to an embodiment of the present application;
[0021] Figure 5 It is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0022] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the embodiments of the present application should fall within the scope of protection of the embodiments of the present application.
[0023] The specific implementation of the embodiments of the present application is further explained below in combination with the embodiments of the present application and the accompanying drawings.
[0024] Understandably, in the invoice management platform of medical institutions, the issuance data of electronic invoices has grown rapidly, and the annual invoice volume often reaches more than 10 million. However, traditional manual analysis and query tools are inefficient, and the mining and utilization of data information value is not sufficient, objective and scientific. With the rapid development of AI technology, the way of directly obtaining information by inputting natural language questions and answers has become an important means to improve the efficiency of information acquisition, gain insight into the logic behind the invoice business, and assist the development of data value in the medical field.
[0025] The rapid development of Large Language Models (LLMs) has brought significant progress to the task of converting natural language (NL) to structured query language (SQL), greatly reducing the threshold for accessing relational databases. With its powerful semantic understanding ability, LLMs can more accurately grasp the content that users want to query, thereby achieving efficient conversion from natural language to SQL query statements. The application of technologies such as BIRD algorithm (Batch-update Incremental Rare category Detection, an incremental rare category detection algorithm for big data analysis and anomaly detection) has also further improved the accuracy and efficiency of natural language to structured query statements NL2SQL.
[0026] For business personnel who are not familiar with SQL language, it is particularly convenient to use large language models (LLMs) for NL2SQL conversion. They do not need to learn complex database query languages and syntax, and can obtain the required data by simply expressing their needs in natural language. This lowers the technical threshold for data query and analysis, and allows business personnel to directly obtain the required information without relying on technical background, allowing more people to participate in data analysis and decision-making, thereby maximizing the value of invoice data.
[0027] For example, a user can enter natural language questions such as "Query the number of invoice amounts greater than 10,000 last month?" or "Show all invoice details that include Elocon Ointment?" The system passes these questions to the management server, which calls the conversion model service (such as NL2SQL_Moder_Server) to parse the natural language input by the user, identify the intent and keywords, and automatically generate the corresponding SQL query statement based on the specific database model. After executing the SQL query statement, the query result is returned to the management terminal for display.
[0028] Figure 1 The figure is a flow chart of a method for querying bill information according to an embodiment of the present application.
[0029] like Figure 1 As shown, the bill information query method includes:
[0030] S11: Receive the natural language text of the bill information query question entered by the user.
[0031] Specifically, the present application designs a bill management software system to execute the bill information query method. The bill management software system includes a management terminal and a management server. The management terminal provides a design question and answer interface. The design question and answer interface includes an input box for users to ask questions, an area for displaying answers, and possible buttons or other interactive elements. Users can enter bill information query questions on the interface, and the management server is used to receive the natural language text of the bill information query question submitted by the management terminal and convert it into an SQL query statement.
[0032] The management terminal can be an application installed on the management device, which relies on the resources (such as hardware resources and software resources) provided by the management device to perform the above corresponding steps and operations. The management terminal is developed using the Vue.js (progressive JavaScript framework for building user interfaces) framework, which is mainly used to build user interfaces and single-page applications, and is simple, easy to use and efficient.
[0033] In the Vue.js framework, the MVVM (Model-View-ViewModel) pattern is the key architectural pattern of the Vue.js framework, which is used to build the user interface. Among them, View is the user interface layer in the MVVM architecture, responsible for displaying the data model and providing an interface for user interaction. In Vue.js, View is usually defined by HTML templates, which can contain data binding and instructions to display dynamic content and handle user interaction. CSS and Templates are used to define component structure and style, which can help to clearly separate HTML structure and style, making the code easier to manage and maintain.
[0034] ViewModel is the core of the MVVM architecture. It serves as a bridge between the model and the view and is responsible for coordinating the interaction between data and the view. Javascript is used to write the main code of Vue.js, enabling Vue.js to run in any environment that supports JavaScript. Runtime provides the core functions of the Vue instance, such as instance creation, data binding, event handling, etc. The Compiler is responsible for converting the template string of the template or component into a JavaScript rendering function.
[0035] In Vue.js, ViewModel is usually performed by the Vue instance itself, which contains the data model, view template and component logic. ViewModel is responsible for implementing two-way binding of data and ensuring data synchronization between the view and view model. When the data of the model changes, ViewModel will notify the view to update. Similarly, when the user modifies the data through the View, ViewModel will also update the model.
[0036] In Vue.js, Model represents the data and business logic layer of the application. It is responsible for storing and processing data, as well as interacting with backend services. Model is the single source of application state, provides CRUD (create, read, update, delete) operations for data, and is also responsible for processing business logic such as data validation, calculation, and conversion.
[0037] In some embodiments, before receiving the natural language text of the ticket information query question entered by the user, the method also includes: encapsulating the natural language text of the user's question into a query text in a preset data exchange format through the management terminal; sending the query text to the text conversion model service deployed on the management server through the query interface and data transmission protocol, so as to convert the natural language text into an SQL query statement through the text conversion model service.
[0038] The preset data exchange format refers to the JSON (JavaScript Object Notation, a lightweight data exchange format) format, which is easy for humans to read and write, and is also easy for machines to parse and generate. The text conversion model service is deployed on the management server and is a service that can convert natural language text into SQL query statements.
[0039] The management terminal interacts with the management service server through the Fetch API (Web Application Programming Interface, network application program interface) for initiating network requests in the JavaScript environment, and encapsulates the natural language text into query text data in JSON format. Then, the query text data is sent to the text conversion model service (i.e., NL2SQL conversion model service) deployed on the management server through the data transmission protocol HTTP (Hypertext Transfer Protocol) and the query interface Fetch API, so that the text conversion model service converts the natural language text into SQL query statements.
[0040] S12: Call the conversion interface of the text conversion model service to convert the natural language text into an SQL query statement.
[0041] In some embodiments, calling a conversion interface of a text conversion model service to convert natural language text into an SQL query statement includes: creating a prompt template consisting of at least one prompt element; inputting a training data set and a prompt template into a pre-trained conversion model, and fine-tuning the pre-trained model; building a text conversion model service locally based on the trained pre-trained conversion model, and configuring a conversion interface through a model management tool installed in an offline environment; calling the conversion interface to convert natural language text into an SQL query statement.
[0042] Specifically, a prompt template is a structured input framework used in natural language processing tasks, which aims to guide the model to understand and respond to specific input information. In the application of large language models (LLMs), prompt templates play a vital role, especially in complex tasks such as natural language to SQL (NL2SQL). When training a pre-trained conversion model, the prompt template is usually used as part of the input and input into the model together with the actual user question, so that the pre-trained conversion model will understand and process the input according to the instructions and structural information in the prompt template, and generate output that meets the requirements.
[0043] In some embodiments, a prompt template consisting of at least one prompt element is created, including: creating a preset prompt template through a prompt project, and adding an instruction element, a data structure element, a reference sample element, a constraint element, a domain knowledge element and a user question element as at least one prompt element in the preset prompt template; adding the address information of the non-tax data wide table and the query database to the data structure element to obtain the prompt template.
[0044] The prompt template should contain the following six elements: instructions, data structure (TableSchema), reference examples (Sample), other prompt constraints (Constraint), domain knowledge (Knowledge) and user questions (Question). These elements together provide a comprehensive context for the model to guide the model to generate correct SQL queries.
[0045] The instruction element is the core part of the prompt template, which tells the pre-trained conversion model what task to perform. In the NL2SQL task, the instruction may include "Convert the following natural language query into a SQL query";
[0046] The data structure element provides information about the database and data tables, such as table column names, data types, and possible constraints. This information is crucial for the model to generate correct SQL queries.
[0047] The reference sample element provides the model with sample input and output, helping the pre-trained conversion model understand the expected output format and style. In the NL2SQL task, the reference sample may include a natural language query and its corresponding SQL query;
[0048] Constraint elements are used to limit the output of the pre-trained conversion model to ensure that it meets specific requirements. In the NL2SQL task, constraints may include grammatical rules of SQL queries, matching requirements of data types, etc.
[0049] Domain knowledge elements can help the pre-trained conversion model better understand the input information. In the NL2SQL task, domain knowledge may include business logic and data relationships related to the database table.
[0050] The user question element is the actual input that the pre-trained transformation model needs to understand and respond to. In the NL2SQL task, the user question is a natural language query that the model needs to convert into an equivalent SQL query.
[0051] That is to say, after adding instruction elements, data structure elements, reference sample elements, constraint elements, domain knowledge elements and user question elements to the preset prompt template, the address information of the non-tax data wide table and the query database is added to the data structure elements, and the prompt template can be obtained, thereby providing better guidance for the pre-trained conversion model and improving the accuracy of the NL2SQL task.
[0052] In addition, trainable continuous prompt word embeddings (ContinuousPrompt Embeddings) can be used in the prompt elements of the prompt template, so that the pre-trained conversion model can learn and optimize the word embeddings in the prompt template during the training process, and design a comprehensive dynamic system prompt for querying the wide table of medical non-tax invoice data, so that the pre-trained conversion model can better adapt to the specific field task of non-tax invoice information query, learn the specific semantics and query patterns in the field of medical non-tax invoices, thereby improving the accuracy and flexibility of the text conversion model service built by the pre-trained conversion model on the NL2SQL task.
[0053] Furthermore, the pre-trained conversion model refers to a large language model LLMs (Large Language Models), which is a natural language processing model based on deep learning that can understand and generate natural language text. The emergence ability of LLMs can help the model better understand the semantics of natural language questions, identify key information, entities and relations in bill information query questions, and then generate the correct SQL structure based on this information. They learn the grammar, semantics and various language features of the language by training on large-scale text data, so that they can perform a variety of language tasks such as text generation, translation, summarization, question and answer, etc. For example, in the NL2SQL (natural language to SQL) task, LLMs can deeply understand the intent of natural language queries and accurately convert them into SQL query statements for execution on relational databases.
[0054] The training datasets include but are not limited to the WikiSQL training set and the BIRD training set. WikiSQL is a large, public NL2SQL dataset. The datasets in WikiSQL are built based on tables in Wikipedia, and each table corresponds to a set of questions and SQL queries. These questions are written based on the content of the table, and each question has a unique SQL query as the answer. The model management tool refers to Ollama (an open source large language model management tool and service), which can simplify the process of running large language models locally. Through Ollama configuration, run pre-trained conversion models, modify the network, write code to expand the Python API interface, and add a conversion interface for natural language conversion SQL.
[0055] That is to say, the pre-trained conversion model is trained through the open source data set WikiSQL or BIRD and the prompt template, and the pre-trained conversion model is fine-tuned. Then, based on the trained pre-trained conversion model, a text conversion model service is built locally at low cost to ensure the correct operation and efficient performance of each system, and the conversion interface is called through the text conversion model service to efficiently convert natural language text into SQL query statements.
[0056] S13: Generate a non-tax data wide table including associated bill element fields and bill item fields, and execute a query in the non-tax data wide table to obtain a query result corresponding to the SQL query statement, wherein the non-tax data wide table is stored in a local query database.
[0057] In some embodiments, a non-tax data wide table including associated bill element fields and bill item fields is generated, including: determining the bill element fields and bill item fields in the data wide table to be created; selecting corresponding data types and data lengths for the bill element fields and bill item fields; creating a data wide table in a query database, and defining the bill element fields and bill item fields in the data wide table; collecting basic bill information, bill transaction information, and medical item information, and writing the basic bill information and bill transaction information into the bill element fields, and writing the medical item information into the bill item fields, to obtain a non-tax data wide table.
[0058] Specifically, when constructing a wide table of non-tax data (Invoice_Wide_Table), first, it is necessary to clarify the wide structure, that is, which fields are included. These fields include but are not limited to: bill code, bill number, check code, total amount, invoice date, invoice unit information, payee information (name, age, address, ID number), payment method, medical category, medical insurance information, project information (name, quantity, amount), fee details project information, etc. These data are characterized by accurate data and complete structure. After the invoice is completed, these information data are regularly collected into an invoice wide table (Invoice_Wide_Table).
[0059] Next, select the corresponding data type and data length for the bill element field and bill item field. For example, the bill code and bill number may be string types, the total amount may be a floating point or fixed point type, the invoice date may be a date type, etc.
[0060] Then, create a data wide table in the query database, define the bill element field and bill item field in the data wide table, and finally set a scheduled task or trigger in the bill management software system to automatically collect the basic bill information, bill transaction information and medical project information after the bill is issued, and insert it into Invoice_Wide_Table. Among them, the basic bill information includes but is not limited to the bill code, bill number, and check code; the bill transaction information includes but is not limited to the total amount, invoice date, invoice unit information, payee information (name, age, address and ID number, etc.), payment method and medical insurance information, etc.; medical project information includes but is not limited to medical categories, project information (name, quantity, amount) and fee details, etc. In this way, through the collection and organization of non-tax invoice data sets, it is ensured that the data in the process of building the text conversion model service is diverse and comprehensive, so that the NL2SQL service has high accuracy and performance.
[0061] In addition, before inserting data such as basic bill information, bill transaction information, and medical project information into the non-tax data wide table, necessary data verification and cleaning can be performed to ensure the accuracy and completeness of the data. For example, check whether the field is empty, whether the data format is correct, whether there are duplicate records, etc. And regularly maintain the non-tax data wide table, such as index reconstruction and partition management, to improve query performance.
[0062] In some embodiments, a query is performed in a non-tax data wide table to obtain a query result corresponding to the SQL query statement, including: receiving an SQL query statement and establishing a communication connection with a query database; searching the non-tax data wide table in the query database, and querying the query result corresponding to the SQL query statement in the bill element field and the bill item field of the non-tax data wide table, wherein the query result includes at least one of the bill basic information, bill transaction information, and medical item information.
[0063] That is to say, after the text conversion model service converts the natural language text into an SQL query statement, it will return the SQL query statement to the management terminal, so that the bill management software installed on the management terminal will establish a communication connection with the query database, so that the query database can query the query results corresponding to the SQL query statement in the bill element field and bill item field of the non-tax data wide table.
[0064] S14: Summarize the query results to obtain the target query result corresponding to the bill information query question.
[0065] For example, Figure 2 The figure is a statement conversion diagram of a bill information query method according to the present application.
[0066] like Figure 2As shown, when a user submits the natural language text of the bill information query question "Query the number of invoice amounts greater than 10,000 last month?" in the design question and answer interface of the management terminal, first, the design question and answer interface interacts with the management service server through the Fetch API and encapsulates the natural language text into query text data in JSON format.
[0067] Then, the query text data is sent to the text conversion model service (i.e., NL2SQL conversion model service) deployed on the management server through the data transmission protocol HTTP protocol and the query interface Fetch API, so as to call the conversion interface of the text conversion model service to perform SQL conversion and obtain the SQL query statement, i.e., "sequence-to-sql generation".
[0068] Finally, the text conversion model service returns the SQL query statement to the management terminal so that the management terminal can execute the query in the query database DB where the non-tax data wide table is located, obtain the query result answer corresponding to the SQL query statement, and summarize the query results to obtain the target query result corresponding to the bill information query question.
[0069] Furthermore, in some embodiments, after aggregating the query results to obtain the target query results corresponding to the bill information query question, the method also includes: aggregating the query data in the target query results into text form or chart form, and encapsulating them into target query results in a preset data exchange format; through the query interface and data transmission protocol, sending the target query results in the preset data exchange format to the terminal interface for display.
[0070] That is to say, after summarizing the query results and obtaining the target query results in text or chart form, the target query results can be encapsulated as target query results in JSON format, and sent to the terminal interface (i.e., the design question and answer interface of the management terminal) through the data transmission protocol HTTP protocol and the query interface Fetch API for display, thereby realizing real-time display of question submission and answers.
[0071] Through the bill information query method of the present application, after converting the natural language text into an SQL query statement by calling the conversion interface of the text conversion model service, a differential selection is performed in the created non-tax data wide table to obtain the query result corresponding to the SQL query statement, and the query results are summarized to automatically obtain the target query result corresponding to the bill information query question, thereby reducing the user's operation difficulty and improving the flexibility and efficiency of the query operation.
[0072] For example, Figure 3 FIG. 1 is a schematic diagram of an application architecture of a bill information query method according to the present application. Figure 3 As shown, first, the user enters a bill information query question in the design question-and-answer interface of the bill management software, such as "Query the number of invoices with an amount greater than 10,000 last month?" The management terminal where the bill management software is located encapsulates the natural language text of the bill information query question into a query text in a preset data exchange format, and sends the query text to the NL2SQL conversion model service deployed on the management server through the query interface and data transmission protocol. The pre-trained conversion model LLMs is deployed on the NL2SQL conversion model service;
[0073] Then, after receiving the query text, the NL2SQL conversion model service will use natural language processing (NLP) technology to parse the user's input intentions and keywords, and understand the data type, conditions, range, etc. that the user wants to query. After parsing the query text, the NL2SQL conversion model service will automatically generate the corresponding SQL query statement based on the predefined database schema (i.e., the structure of the table in the database, field type, and other information). Specifically, after parsing, determine the database table involved in the query (for example, if the query is about invoices, then you may need to query the "invoice" table), determine the fields involved in the query (for example, if the query mentions "invoice amount", then you may need to query the "amount" field in the "invoice" table), and ensure that the data type in the query matches the data type of the database field (for example, if the query mentions the amount, then you may need to ensure that the database field is a numeric type). After completing the parsing of the natural language text and the mapping of the database schema, the conversion interface can be called to convert the natural language text into an SQL query statement and return it to the bill management software. The SQL query statement can accurately reflect the user's query needs;
[0074] Finally, the bill management software establishes a communication connection with the query database DB. The query database will retrieve, filter and sort data according to the SQL query statement to query the query results corresponding to the SQL query statement in the bill element field and bill item field of the non-tax data wide table, and return the query results to the bill management software. The bill management software will then summarize the query results to obtain the target query results corresponding to the bill information query questions, and display these query results to users so that users can intuitively see the data they want.
[0075] In summary, compared to the traditional manual query of bill information or query methods that rely on database tools, the natural language processing (NLP) technology of this application can quickly parse the query statements entered by users in natural language, obtain the converted SQL query statements, and achieve accurate matching and retrieval in the huge non-tax data wide table, greatly shortening the query cycle, allowing users to quickly obtain the required invoice information. In addition, through the local deployment of the NL2SQL (natural language to structured query language) conversion model service, compared to cloud deployment or calling external service interfaces, this application can better control and protect its own sensitive data, effectively reduce the risk of data leakage, and improve the reliability and credibility of the system. At the same time, local deployment also has a high degree of customization capabilities, controllable costs, stable performance, and is convenient for subsequent updates and maintenance.
[0076] It should be noted that with the continuous increase of bill data and changes in user needs, this application can continue to improve the text conversion model service and non-tax data wide table, add new functions and features, and improve the accuracy and practicality of bill information query.
[0077] The ticket information query method of the present application can be executed by any appropriate electronic device with data processing capabilities, including but not limited to: servers, mobile terminals (such as mobile phones, PADs, etc.) and PCs, etc.
[0078] In addition, the technical solutions of the above-mentioned embodiments of the present application can be combined with each other and are not limited here.
[0079] Figure 4 The present invention is a structural block diagram of a bill information query device according to an embodiment of the present application.
[0080] like Figure 4 As shown, the bill information query device 400 can execute Figure 1 The bill information query method, the bill information query device 400 includes: a receiving module 401, used to receive the natural language text of the bill information query question entered by the user; a conversion module 402, used to call the conversion interface of the text conversion model service to convert the natural language text into an SQL query statement; an execution module 403, used to generate a non-tax data wide table including associated bill element fields and bill item fields, and execute a query in the non-tax data wide table to obtain a query result corresponding to the SQL query statement, wherein the non-tax data wide table is stored in a local query database; a summary module 404, used to summarize the query results to obtain a query result corresponding to the bill information query question.
[0081] In some embodiments of the present application, the conversion module 402 is specifically used to: create a prompt template consisting of at least one prompt element; input the training data set and the prompt template into the pre-trained conversion model, and fine-tune the pre-trained model; build a text conversion model service locally based on the trained pre-trained conversion model, and configure the conversion interface through the model management tool installed in the offline environment; call the conversion interface to convert natural language text into SQL query statements.
[0082] In some embodiments of the present application, a creation module (not shown in the figure) is used to: create a preset prompt template through a prompt project, and add instruction elements, data structure elements, reference sample elements, constraint elements, domain knowledge elements and user question elements as at least one prompt element in the preset prompt template; add the address information of the non-tax data wide table and the query database to the data structure element to obtain the prompt template.
[0083] In some embodiments of the present application, an encapsulation module (not shown in the figure) is used to: encapsulate the natural language text of a user's question into a query text in a preset data exchange format through a management terminal; send the query text to a text conversion model service deployed on a management server through a query interface and a data transmission protocol, so as to convert the natural language text into an SQL query statement through the text conversion model service.
[0084] In some embodiments of the present application, the summary module 404 is also used to: summarize the query data in the target query results into text form or chart form, and encapsulate them into target query results in a preset data exchange format; send the target query results in a preset data exchange format to the terminal interface for display through the query interface and data transmission protocol.
[0085] In some embodiments of the present application, the execution module 403 is specifically used to: determine the bill element field and the bill item field in the data wide table to be created; select corresponding data types and data lengths for the bill element field and the bill item field; create a data wide table in the query database, and define the bill element field and the bill item field in the data wide table; collect basic bill information, bill transaction information and medical item information, and write the basic bill information and the bill transaction information into the bill element field, and write the medical item information into the bill item field to obtain a non-tax data wide table.
[0086] In some embodiments of the present application, the execution module 403 is specifically used to: receive an SQL query statement and establish a communication connection with a query database; search the non-tax data wide table in the query database, and query the query results corresponding to the SQL query statement in the bill element field and the bill item field of the non-tax data wide table, wherein the query results include at least one of the bill basic information, bill transaction information and medical item information.
[0087] According to the bill information query device of the embodiment of the present application, after converting the natural language text into an SQL query statement by calling the conversion interface of the text conversion model service, a differential selection is performed in the created non-tax data wide table to obtain the query result corresponding to the SQL query statement, and the query results are summarized to automatically obtain the target query result corresponding to the bill information query question, thereby reducing the user's operation difficulty and improving the flexibility and efficiency of the query operation.
[0088] The bill information query device 400 of this embodiment is used to implement the corresponding bill information query method in the aforementioned multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be described in detail here. In addition, the functional implementation of each module in the bill information query device 400 of this embodiment can refer to the description of the corresponding part in the aforementioned method embodiments, which will not be described in detail here.
[0089] Figure 5 This is a structural block diagram of an electronic device according to an embodiment of the present application. The specific embodiment of the present application does not limit the specific implementation of the electronic device.
[0090] like Figure 5 As shown, the electronic device 500 may include: a processor 501, a memory 502, a communication interface 503 and a communication bus 504. The processor 501, the memory 502 and the communication interface 503 communicate with each other through the communication bus 504; the memory 502 is used to store at least one executable instruction, and the executable instruction enables the processor 501 to perform the operation corresponding to the ticket information query method of any of the above embodiments.
[0091] The processor 501 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application. The one or more processors included in the smart device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0092] The memory 502 is used to store programs, and may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0093] According to the electronic device of the embodiment of the present application, after converting the natural language text into an SQL query statement by calling the conversion interface of the text conversion model service, a differential selection is performed in the created non-tax data wide table to obtain the query result corresponding to the SQL query statement, and the query results are summarized to automatically obtain the target query result corresponding to the bill information query question, thereby reducing the user's operation difficulty and improving the flexibility and efficiency of the query operation.
[0094] The embodiment of the present application also provides a computer storage medium on which a computer program is stored. When the program is executed by a processor, the ticket information query method of any of the above embodiments is implemented.
[0095] According to the computer storage medium of the embodiment of the present application, after converting the natural language text into an SQL query statement by calling the conversion interface of the text conversion model service, a differential selection is performed in the created non-tax data wide table to obtain the query result corresponding to the SQL query statement, and the query result is summarized to automatically obtain the target query result corresponding to the bill information query question, thereby reducing the user's operation difficulty and improving the flexibility and efficiency of the query operation.
[0096] It should be pointed out that, according to the needs of implementation, the various components / steps described in the embodiments of the present application can be split into more components / steps, or two or more components / steps or partial operations of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of the present application.
[0097] The above-mentioned method according to the embodiment of the present application can be implemented in hardware, firmware, or implemented as software or computer code that can be stored in a recording medium (such as a CD ROM, RAM, floppy disk, hard disk or magneto-optical disk), or implemented as computer code originally stored in a remote recording medium or a non-temporary machine-readable medium downloaded through a network and to be stored in a local recording medium, so that the method described herein can be stored in such software processing on a recording medium using a general-purpose computer, a dedicated processor or programmable or dedicated hardware (such as an ASIC or FPGA). It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component (e.g., RAM, ROM, flash memory, etc.) that can store or receive software or computer code, and when the software or computer code is accessed and executed by a computer, a processor or hardware, the ticket information query method described herein is implemented. In addition, when a general-purpose computer accesses the code for implementing the ticket information query method shown herein, the execution of the code converts the general-purpose computer into a dedicated computer for executing the ticket information query method shown herein.
[0098] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present application.
[0099] The above implementation methods are only used to illustrate the embodiments of the present application, and are not intended to limit the embodiments of the present application. Ordinary technicians in the relevant technical field can make various changes and modifications without departing from the spirit and scope of the embodiments of the present application. Therefore, all equivalent technical solutions also belong to the scope of the embodiments of the present application, and the scope of patent protection of the embodiments of the present application should be defined by the claims. The systems, devices or modules described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions.
Claims
1. A bill information query method, characterized in that: The method comprises: Receive natural language text of bill information query questions entered by users; Calling a conversion interface of a text conversion model service to convert the natural language text into an SQL query statement; generating a non-tax data wide table including associated bill element fields and bill item fields, and executing a query in the non-tax data wide table to obtain a query result corresponding to the SQL query statement, wherein the non-tax data wide table is stored in a local query database; The query results are aggregated to obtain the target query result corresponding to the bill information query question.
2. The bill information query method according to claim 1, characterized in that: Calling the conversion interface of the text conversion model service to convert the natural language text into an SQL query statement includes: Creating a prompt template consisting of at least one prompt element; Inputting the training data set and the prompt template into a pre-trained conversion model, and fine-tuning the pre-trained model; Building the text conversion model service locally based on the trained pre-trained conversion model, and configuring the conversion interface through a model management tool installed in an offline environment; The conversion interface is called to convert the natural language text into an SQL query statement.
3. The bill information query method according to claim 2, characterized in that: Create a prompt template consisting of at least one prompt element, including: Creating a preset prompt template through a prompt project, and adding an instruction element, a data structure element, a reference example element, a constraint element, a domain knowledge element, and a user question element to the preset prompt template as the at least one prompt element; The non-tax data wide table and the address information of the query database are added to the data structure element to obtain the prompt template.
4. The bill information query method according to claim 1, characterized in that: Before receiving the natural language text of the bill information query question entered by the user, the method further includes: [HZTC-HXRJGS241011][HS2411400CCN] Encapsulating the natural language text of the user's question into a query text in a preset data exchange format through the management terminal; The query text is sent to the text conversion model service deployed on the management server through the query interface and the data transmission protocol, so that the natural language text is converted into an SQL query statement through the text conversion model service.
5. The bill information query method according to claim 4, characterized in that: After aggregating the query results to obtain a target query result corresponding to the bill information query question, the method further includes: Summarizing the query data in the target query result into a text form or a chart form, and encapsulating it into the target query result in the preset data exchange format; The target query result in the preset data exchange format is sent to the terminal interface for display through the query interface and the data transmission protocol.
6. The bill information query method according to claim 1, characterized in that: Generates a wide table of non-tax data that includes associated bill element fields and bill item fields, including: Determine the bill element fields and bill item fields in the data wide table to be created; Select corresponding data types and data lengths for the bill element field and the bill item field; Creating a data wide table in the query database, and defining the bill element field and the bill item field in the data wide table; Collect basic bill information, bill transaction information and medical item information, write the basic bill information and bill transaction information into the bill element field, and write the medical item information into the bill item field to obtain the non-tax data wide table.
7. The bill information query method according to claim 6, characterized in that: Execute a query in the non-tax data wide table to obtain query results corresponding to the SQL query statement, including: Receive the SQL query statement and establish a communication connection with the query database; The non-tax data wide table is searched in the query database, and the query result corresponding to the SQL query statement is searched in the bill element field and the bill item field of the non-tax data wide table, wherein the query result includes at least one item of the bill basic information, bill transaction information and medical item information.
8. A bill information query device, characterized in that: include: A receiving module, configured to receive a natural language text of a bill information query question entered by a user; A conversion module, configured to call a conversion interface of a text conversion model service to convert the natural language text into an SQL query statement; an execution module, configured to generate a non-tax data wide table including associated bill element fields and bill item fields, and execute a query in the non-tax data wide table to obtain a query result corresponding to the SQL query statement, wherein the non-tax data wide table is stored in a local query database; The summarizing module is used to summarize the query results to obtain the query results corresponding to the bill information query question.
9. An electronic device comprising: A processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute an operation corresponding to the bill information query method according to any one of claims 1 to 7.
10. A computer storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the bill information query method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Invoice processing method and device, computer equipment and storage medium
CN120910137A