Traffic question and answer method, device and equipment based on large model
By semantically understanding the question text to generate triple information and converting it into structured instructions, the problem of inaccurate SQL statements generated by large models is solved, achieving more accurate question-and-answer results.
Patent Information
- Application Number
- CN202511443851.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-10
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2045-10-10
AI Technical Summary
Existing large models, due to limitations in training data, often produce SQL statements that are irrelevant to the input natural language question text, thus affecting question-answering performance.
The question-answering model performs semantic understanding of the question text, generates triple information, and converts it into structured target instructions. The instruction parsing engine then generates SQL statements for question-answering.
It improves the accuracy of generated SQL statements, enhances the question-and-answer effect, and solves the inaccuracy problem caused by insufficient understanding of the question text in traditional question-and-answer systems.
Smart Images

Figure CN120929575A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a traffic question-answering method, apparatus and equipment based on a large model. Background Technology
[0002] Currently, with the technological upgrades brought about by advanced large-scale models such as ChatGPT and DeepSeek, large-scale model technology has moved from exploring general capabilities to deeply empowering vertical industries, becoming a core engine driving the digital transformation of industries.
[0003] With the development of large-scale models, they have been widely applied in the field of Natural Language to Structured Query Language (NL2SQL). This involves directly inputting natural language statements into a large model, which then converts them into SQL statements. However, due to limitations in the training data for large-scale models, the SQL statements output by the model may be unrelated to the input natural language statements. This can lead to inaccurate responses generated based on the SQL output of the large model, affecting the question-answering results. Summary of the Invention
[0004] This application provides a traffic question-answering method, apparatus, and device based on a large model to improve the accuracy of generated SQL, thereby improving the question-answering effect.
[0005] In a first aspect, embodiments of this application provide a traffic question-answering method based on a large model, the method comprising: The input question text is processed using a question-answering model to generate a target instruction containing triple information of the question text; wherein, the triple information includes intent, entity and corresponding constraints. The instruction parsing engine is invoked to process the target instruction and generate a first SQL statement for querying the intent, entity, and corresponding constraint data. Based on the first SQL statement, query the knowledge base for the first target data corresponding to the intent, entity and corresponding constraints, and generate a response text based on the first target data.
[0006] Secondly, embodiments of this application also provide a traffic question-answering device based on a large model, the device comprising: The processing module is used to process the input question text using a question-answering model to generate a target instruction containing triple information of the question text; wherein, the triple information includes intent, entity and corresponding constraints; and calls the instruction parsing engine to process the target instruction to generate a first SQL statement for querying the data corresponding to the intent, entity and corresponding constraints. The question-and-answer module is used to query the first target data corresponding to the intent, entity and corresponding constraints in the knowledge base according to the first SQL statement, and generate a response text based on the first target data.
[0007] Thirdly, embodiments of this application also provide an electronic device, which includes at least a processor and a memory, wherein the processor is used to execute a computer program stored in the memory to implement the steps of the traffic question-answering method based on a large model described above.
[0008] In this embodiment of the application, the question text is converted into a structured target instruction, which contains complete semantic information of the question text. Then, an SQL statement is generated based on the structured target query instruction, and question and answer are performed based on the SQL statement. This solves the problem in traditional question and answer where the generated SQL statement is irrelevant to the question text due to insufficient understanding of the question text, resulting in inaccurate question and answer and poor effect. Attached Figure Description
[0009] To more clearly illustrate the technical solutions of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0010] Figure 1 A schematic diagram of a traffic question-and-answer process based on a large model is provided for an embodiment of this application; Figure 2 A flowchart illustrating the generation process of semantic parsing tags provided in this application embodiment; Figure 3 This is a schematic diagram of the traffic management business domain indicator system provided in the embodiments of this application; Figure 4 A schematic diagram illustrating the correspondence between intents and API templates provided in the embodiments of this application; Figure 5 A possible question-and-answer flowchart provided for an embodiment of this application; Figure 6 Another possible question-and-answer flowchart provided for an embodiment of this application; Figure 7A schematic diagram of a traffic question-and-answer device based on a large model provided in an embodiment of this application; Figure 8 This is a schematic diagram of an electronic device structure provided in an embodiment of this application. Detailed Implementation
[0011] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0012] Currently, with the technological upgrades brought by advanced large-scale models such as ChatGPT and DeepSeek, large-scale model technology has moved from exploring general capabilities to deeply empowering vertical industries, becoming a core engine driving the digital transformation of industries. Intelligent question answering and intelligent data querying, as typical application scenarios of large-scale models, enable data querying and analysis through natural language interaction, significantly lowering the barrier for business personnel to use data.
[0013] Despite the widespread application of intelligent question answering and intelligent data analysis, existing technological approaches still have significant limitations. On the one hand, the NL2SQL approach suffers from the illusion problem of large models, resulting in low reliability in directly generating dynamic SQL statements. Practice shows that general-purpose models require fine-tuning with massive amounts of domain data to reach basic usability, and the accuracy of complex queries, such as multi-table joins and nested clauses, is less than 55%. On the other hand, while the commonly used alternative NL2DSL can mitigate some of the illusion risk, it is limited by the expressive capabilities of DSLs. For example, traditional DSLs struggle to support unstructured semantics such as spatial relationships (e.g., "near a school") and event descriptions (e.g., "mentioning vehicle fires"), leading to narrow application scenarios and poor scalability. These shortcomings collectively constrain the deep analysis needs for complex semantics in the traffic management vertical domain.
[0014] Based on this, in order to improve the accuracy of generated SQL and thus improve the question-answering effect, this application provides a traffic question-answering method, apparatus and device based on a large model.
[0015] Figure 1 A schematic diagram of a traffic question-answering process based on a large model is provided for embodiments of this application. The process includes: S101: The input question text is processed using a question-answering model to generate a target instruction containing triple information of the question text; wherein, the triple information includes intent, entity and corresponding constraints.
[0016] This application provides a traffic question-answering method based on a large model, which is applied to an electronic device, such as a server, PC, or terminal device.
[0017] In related technologies, natural language question text is directly input into a large model, which then converts it into SQL statements. However, due to limitations in the training data of large models, the SQL statements output by the large model may be irrelevant to the input natural language question text. In other words, the large model cannot accurately understand the semantic information of the natural language question text, resulting in irrelevant SQL statements. Consequently, the responses generated based on the SQL statements output by the large model are inaccurate, affecting the question-answering performance.
[0018] Compared to related technologies, the embodiments of this application design a structured intermediate layer design. First, the question text is semantically understood to obtain the triple information corresponding to the semantic information of the question text. Then, the triple information is converted into a structured target instruction, and a first SQL statement is generated based on the target instruction, thereby generating a response text according to the first SQL statement.
[0019] In this embodiment, the question text is fully semantically understood through a question-answering model to obtain triple information. This triple information is then carried in the structured target instruction generated subsequently. Based on this structured target query instruction, an SQL statement is generated, and question-answering is performed based on the SQL statement. This solves the problem in traditional question-answering where insufficient understanding of the question text leads to irrelevant SQL statements, inaccurate answers, and poor results.
[0020] In one possible implementation, the electronic device can receive question text sent by other devices; the electronic device can also employ a voice receiver to receive voice information input by the user, convert the voice information into text, and identify the converted text as question text; the electronic device can also directly receive question text input by the user through an external device, such as a keyboard; the electronic device can also receive question text input by the user through software such as an APP or a WEB page.
[0021] The question text can be natural language text or text in other formats; there are no restrictions on this.
[0022] In this embodiment of the application, the electronic device is equipped with a trained question-answering model, which is used to transform question text into structured target instructions.
[0023] Specifically, the electronic device inputs the question text into the question-answering model, which performs semantic understanding on the question text to obtain the triple information corresponding to the question text, and then converts the triple information into structured target instructions.
[0024] In one possible implementation, the question-answering model can be a neural network model with learning capabilities, such as CNN, BERT, etc.; the question-answering model can also be a large model, such as a large language model, a multimodal large model, etc.
[0025] In this embodiment of the application, the triple information obtained by the question-answering model through semantic understanding of the question text includes, but is not limited to, intent, entity, and constraint. The entity in the triple information is the entity type corresponding to the entity contained in the question text, such as name, employee ID, etc., and the constraint is the specific entity value contained in the question text, such as a specific name, specific province, etc.
[0026] In this embodiment, the structured target instruction uses a predefined JSON format. This target instruction can be a data query instruction used to retrieve data related to triple information from the knowledge base. This application pre-configures templates corresponding to the structured target instructions. The question-answering model can call these templates and add the triple information to the corresponding positions in the templates to obtain the target instruction.
[0027] S102: Call the instruction parsing engine to process the target instruction and generate a first SQL statement for querying the data corresponding to the intent, entity and corresponding constraints.
[0028] In this embodiment of the application, the electronic device is also pre-configured with an instruction parsing engine. The instruction parsing engine can parse the target instruction, obtain the triple information carried in the target instruction, and generate a first SQL statement based on the triple information to query the data corresponding to the intent, entity and corresponding constraint conditions contained in the triple information.
[0029] In one possible implementation, the instruction parsing engine can determine the business domain corresponding to this question and answer based on the intent carried in the target instruction; then, based on the business domain, determine the database table to be queried; the instruction parsing engine can also determine the SQL statement template corresponding to the intent based on the intent; the instruction parsing engine adds the information of the database table, the entity carried in the target instruction, and the constraints to the SQL template to obtain the first SQL statement.
[0030] For example, in this embodiment of the application, traffic management data is divided into five core business domains: accidents, police reports, vehicles, drivers, and violations, and a corresponding database table is designed for each business domain.
[0031] Specifically, the electronic device is pre-configured with a mapping between intents, business domains, and database tables, and also with a mapping between intents and SQL templates. The instruction parsing engine obtains the triple information carried in the target instruction, and determines the business domain and the database table to be queried corresponding to the intent carried in the triple information based on the pre-configured mapping between intents, business domains, and database tables. The instruction parsing engine then determines the SQL template corresponding to the intent carried in the triple information based on the pre-configured mapping between intents and SQL templates. Finally, the instruction parsing engine adds the entity and constraints carried in the triple information, as well as the saved information of the database table to be queried, to the SQL template to obtain the first SQL statement.
[0032] For example, the instruction parsing engine matches predefined SQL templates based on the intent type. For instance, query instructions correspond to `SELECT [field] FROM [table] WHERE [condition]`, and statistical instructions correspond to `SELECT COUNT(...)`. The command parsing engine combines the database table schema information (such as table structure, field types, primary key / foreign key relationships) to map the triples to the SQL template. For example, the SELECT clause corresponds to the query field in the intent, such as "temperature" mapped to SELECT temperature; the WHERE clause corresponds to the entity and constraint conditions, such as "Beijing" mapped to WHERE location = 'Beijing', and "tomorrow" mapped to WHERE date = '2025-09-23'.
[0033] S103: Based on the first SQL statement, query the first target data corresponding to the intent, entity and corresponding constraints in the knowledge base, and generate a response text based on the first target data.
[0034] In this embodiment of the application, after the electronic device obtains the first SQL statement based on the instruction parsing engine, the electronic device executes the first SQL statement, queries the knowledge base for the first target data corresponding to the intent, entity and corresponding constraints based on the first SQL statement, and generates a response text based on the first target data.
[0035] To improve data querying and question answering, this embodiment of the application preprocesses the data stored in the knowledge base. This preprocessing includes, but is not limited to, at least one of the following: structured definition of business domains, enhancement of hierarchical tagging system, and indicator-based modeling.
[0036] Specifically, the structured definition of business domains includes: constructing database tables based on business domains and storing the relationships between business domains and database tables. Specifically, traffic management data can be divided into five core business domains: accidents, police reports, vehicles, drivers, and violations. A standardized original database table structure is designed for each business domain, establishing field types, constraints, and relationships. Data is then saved to the corresponding database table according to this table structure.
[0037] The storage format of data in technical systems (such as database fields and code values) cannot be directly understood by business personnel, and business analysis needs (such as "running a red light" or "delivery and takeout") often cannot be accurately matched one-to-one with specific fields in the stored business tables. This gap leads to inefficiency in intelligent data querying and analysis, and distorted decision-making. To break down the gap between data and business semantics, this application enhances fragmented data into computable business semantic units through a layered tagging system, addressing the shortcomings of traditional data models in supporting complex semantic understanding.
[0038] Specifically, the enhanced hierarchical tagging system includes: assigning multi-level tags to each data point based on its specific information. These multi-level tags include, but are not limited to, basic tags, derived tags, statistical tags, and semantic parsing tags. The basic tag is a field from the corresponding database table, such as jurisdiction or accident time. The derived tag is the category or scope to which the basic tag belongs, obtained by transforming the basic tag based on rules; for example, if the basic tag is accident time, the derived tag could be a quarterly tag, an annual tag, etc. The statistical tag is generated by referencing other database tables and SQL calculations, carrying information from those tables; for example, if the basic tag is "engineering transport vehicle," the corresponding statistical tag could be "related vehicle information table and accident personnel table," etc. The semantic parsing tag is key textual information extracted from the corresponding text description, such as identifying the "hospital surroundings" tag from a case description.
[0039] Specifically, a four-level enhanced tag system can be constructed, consisting of basic tags (original fields), derived tags (rule mapping), statistical tags (multi-table join calculations), and semantic parsing tags (NLP semantic extraction).
[0040] In one possible implementation, the text description corresponding to the data can be processed using a large model to obtain the semantic description tag corresponding to the data.
[0041] Figure 2 This is a flowchart illustrating the generation process of semantic parsing tags provided in an embodiment of this application. Figure 2As shown, the process includes: obtaining the brief case text of the accident corresponding to the data to be added (i.e., text description), using a large model to extract features from the brief case text of the accident, and then labeling it in real time based on the extracted features to obtain semantic tags (i.e. semantic parsing tags).
[0042] Indicator-based modeling is the process of transforming business objectives into a quantifiable and structured indicator system. First, you can define the dimension columns (defining the analytical perspective, such as the time dimension of a quarter or the spatial dimension of a jurisdiction) and the measure columns (setting quantifiable indicators, such as the number of accidents or vehicle density) of the database tables. Then, define the indicator definitions and establish clear, structured indicator calculation rules for the large model, greatly improving accuracy.
[0043] For example, the scope of indicators includes, but is not limited to, atomic indicators, derived indicators, and composite indicators.
[0044] Among them, atomic indicators are the values corresponding to the basic labels carried in the data, that is, the basic calculation units, such as: number of accidents = COUNT(accident ID); derived indicators are based on the composite operation of atomic indicators, such as: year-on-year accident growth rate = (number of accidents in this period - number of accidents in the previous period) / number of accidents in the previous period); composite indicators are calculated by integrating multiple dimensions, such as: percentage of accidents around hospitals = number of accidents around hospitals / total number of accidents).
[0045] Figure 3 This is a schematic diagram of the traffic management business domain indicator system provided in the embodiments of this application, as shown below. Figure 3 As shown, the "Accidents" field contains 4 major categories of indicators and 53 dimensions. The 4 major categories of indicators are the number of accidents, the number of injuries, the number of deaths, and the property damage. The 53 dimensions include the time of occurrence: today / yesterday / last week, etc. The "Motor Vehicles" field contains 4 major categories of indicators and 30 dimensions. The 4 major categories of indicators are the number of motor vehicles in operation, the number of registered vehicles, the number of deregistered vehicles, and the number of vehicles that have not been scrapped by the due date. The 3 dimensions include the statistical time: year / quarter / last month / week / day, etc. The "Drivers" field contains 3 major categories of indicators and 23 dimensions. The 3 major categories of indicators are the number of drivers in operation, the number of registered drivers, and the number of deregistered drivers. The "Quantity" field includes 23 dimensions, including statistical time periods such as year, quarter, last month, week, and day; the "Operational Status" field contains 7 categories of indicators and 14 dimensions. The 7 categories of indicators are traffic index, average speed, congested mileage, traffic flow, number of vehicles on the road, number of daily active vehicles, and number of vehicles entering and leaving the city. The 14 dimensions include statistical periods such as today, morning rush hour, 9:00 AM, yesterday, and this week; the "Police Incident" field contains 3 categories of indicators and 22 dimensions. The 3 categories of indicators are the number of police incidents, dispatch time, and arrival time. The 22 dimensions include time periods such as year, quarter, last month, week, day, and hour.
[0046] In this embodiment, the electronic device integrates a three-dimensional metadata system of fields, tags, and indicators to construct a wide table of business domains, and adds natural language notes to key elements (such as the calculation logic for the label "engineering transport vehicle": "associate the vehicle_info table and the accident_person table, and filter vehicle_type∈{'concrete truck', 'dump truck'}"), supporting semantic understanding and automated analysis of large models.
[0047] Based on this, in this embodiment of the application, the electronic device can query the first target data corresponding to the intent, entity and corresponding constraints in the knowledge base according to the first SQL statement and the tags and indicators corresponding to each data stored in the knowledge base, and generate a response text based on the first target data.
[0048] Specifically, the electronic device determines the database table to be queried in the knowledge base based on the database table information carried in the first SQL statement, and then determines the first target data corresponding to the entity and its corresponding constraints based on the tag information and indicator information corresponding to each data in the database table to be queried stored in the knowledge base, and generates a response text based on the first target data.
[0049] In this embodiment of the application, the question text is converted into a structured target instruction, which contains complete semantic information of the question text. Then, an SQL statement is generated based on the structured target query instruction, and question and answer are performed based on the SQL statement. This solves the problem in traditional question and answer where the generated SQL statement is irrelevant to the question text due to insufficient understanding of the question text, resulting in inaccurate question and answer and poor effect.
[0050] To improve the accuracy of generated SQL and thus enhance the question-answering effect, based on the above embodiments, in this application embodiment, the question-answering model includes a text encoder and a structure encoder; The step of processing the input question text using a question-answering model to generate a target instruction containing triple information of the target question includes: The text encoder is used to process the question text to obtain the triplet information corresponding to the question text; The structure encoder is used to process the triplet information to obtain the target instruction.
[0051] In this embodiment, the question-answering model includes a text encoder and a structure encoder. The text encoder performs semantic parsing on the question text to obtain the triple information corresponding to the question text; the structure encoder obtains structured target instructions based on the triple information corresponding to the question text.
[0052] Specifically, the electronic device inputs the question text into the question-answering model, where the text encoder processes the question text to obtain the triple information corresponding to the question text; the text encoder then inputs the triple information as input into the structural encoder of the question-answering model, where the structural encoder processes the triple information to obtain the target instruction.
[0053] For example, the triplet information of the question text Q can be represented as: Q=I,E,C; where I represents intent, E represents entity, and C represents constraint.
[0054] In one possible implementation, the intent of the question text is one of a pre-configured set of intents, which includes, but is not limited to, four categories: filtering statistics, trend exploration, computational processing, and horizontal comparison. Among them, filtering statistics includes, but is not limited to, detail query, list filtering, and count statistics; trend exploration includes, but is not limited to, trend analysis, year-on-year calculation, month-on-month calculation, and percentage analysis; computational processing includes, but is not limited to, mean calculation, addition and subtraction calculation, and indicator comparison; and horizontal comparison includes, but is not limited to, sorting statistics, TopN selection, and extreme value analysis.
[0055] The entity in the question text is at least one of a pre-configured set of entities, which can be a field, time range, etc. Specifically, a question text's triplet information contains one or more entities.
[0056] The constraints of the question text are at least one of a pre-configured set of constraints, which can be filtering conditions, sorting rules, etc. Each question text contains one or more constraint rules within its triplet information.
[0057] For example, the triplet information of the problem text Q can be Q=TopN sort, {incident volume, jurisdiction}, {time=2024Q1, N=5}. That is, the intent of the problem text Q is TopN sort, the entities of the problem text Q are accident volume and jurisdiction, and the constraints of the problem text Q are time=2024Q1, N=5.
[0058] In this embodiment, the structural encoder obtains the target instruction based on triplet information.
[0059] The API instruction generation function can be defined as follows:
[0060] in, Let Q be the target instruction corresponding to the question text, I be the intent, E be the entity, and C be the constraint.
[0061] To improve the accuracy of generated SQL and thus enhance question-answering effectiveness, based on the above embodiments, in this embodiment, the step of processing the question text using the text encoder to obtain the triplet information corresponding to the question text includes: The text encoder is used to perform intent recognition on the question text to obtain the intent of the question text; The text encoder is used to perform entity recognition on the question text to obtain the entities contained in the question text; The text encoder is used to identify the constraints in the question text to obtain the constraints contained in the question text. The intent, the entity, and the constraint are determined as the triplet information.
[0062] In this embodiment of the application, the text encoder is used to perform intent recognition, entity recognition and constraint recognition on the question text to obtain the intent of the question text, the entities contained in the question text and the constraints. The text encoder uses the recognized intent, entities and constraints as triple information.
[0063] In one possible implementation, the text encoder can determine the intent corresponding to the question text through semantic classification; the text encoder can determine the entity corresponding to the question text through rule matching or entity detection; the text encoder can determine the constraint corresponding to the question text through rule matching or constraint detection.
[0064] For example, an electronic device is pre-configured with an entity set and a constraint set. The text encoder can determine candidate entities in the entity set contained in the question text based on the entity set, and use the candidate entities as entities contained in the question text; the text encoder can determine candidate constraints in the constraint set contained in the question text based on the constraint set, and use the candidate constraints as constraints contained in the question text.
[0065] In order to improve the accuracy of generated SQL and thus improve the question-answering effect, based on the above embodiments, in this embodiment of the application, the target instruction is an API instruction; The process of using the structure encoder to process the triplet information to obtain the target instruction includes: The structure encoder determines the target API instruction type corresponding to the intent of the question text based on the configured correspondence between intent and API instruction type. The structure encoder obtains the API template corresponding to the configured target API instruction type, and adds the intent of the question text, the entities contained in the question text, and the corresponding entity values to the API template to obtain the API instruction.
[0066] In this embodiment of the application, the target instruction output by the structure encoder can be an API instruction.
[0067] Furthermore, to better reflect each intent, an API template corresponding to each intent is pre-configured. One intent can correspond to one API template, or multiple intents can correspond to one API template.
[0068] In one possible implementation, API commands can be divided into data query / filtering API commands (getDetails), indicator statistics API commands (getIndices), and indicator secondary statistical processing API commands (getIndicesMeasure).
[0069] Figure 4 This is a schematic diagram illustrating the correspondence between intents and API templates provided in the embodiments of this application, as shown below. Figure 4 As shown, the intents are divided into four categories: screening statistics, trend exploration, calculation and processing, and horizontal comparison. Among them, screening statistics include but are not limited to detail query, list filtering, and count statistics; trend exploration includes but is not limited to trend analysis, year-on-year calculation, month-on-month calculation, and percentage analysis; calculation and processing includes but is not limited to mean calculation, addition and subtraction calculation, and indicator comparison; horizontal comparison includes but is not limited to sorting statistics, TopN selection, and extreme value analysis.
[0070] Among them, the intent of the data query / filter API command (getDetails) is detailed query and list filter; the intent of the indicator statistics API command (getIndices) is count statistics, year-on-year calculation, month-on-month calculation, percentage analysis, sort statistics and TopN selection; the intent of the indicator secondary statistical processing API command (getIndicesMeasure) is mean calculation, addition and subtraction calculation, indicator comparison and extreme value analysis.
[0071] For example, the API template format definition for the indicator statistics API command is as follows:
[0072] in, For indicator statistics API commands, For indicator generation functions (such as sum(x) → "measureTypes": ["SUM"]), For conditional compilation functions (e.g., time = 2024Q1 → "time_range": ["2024-01-01", "2024-03-31"]).
[0073] Specifically, the structure encoder determines the index generation function corresponding to the entity based on the entity carried in the triple information; the structure encoder also determines the condition compilation function corresponding to the constraint based on the constraint carried in the triple information.
[0074] For example, if the question text Q is the Top 5 single-vehicle accidents in each jurisdiction in Q1 2024, then the corresponding API instruction A for the question text Q is:
[0075] In this context, endpoint: "getIndices" specifies that the API command type is getIndices; groupFields:["jurisdiction"] defines the data grouping field as "jurisdiction"; metrics: ["number of incidents"] specifies that the metric to be counted is "number of incidents". The query will calculate the number of accidents within each group (grouped by jurisdiction); `startTime: "2024-01-01", endTime: "2024-03-31"` sets the time range for the query, from January 1, 2024 to March 31, 2024, and the query will only return data within this time period; `queryParams: [ field: "Accident Type", mode: 6, value: "Single Vehicle Accident" ]` is used to further filter the data; `field: "Accident Type"` indicates that the field to be filtered is "Accident Type"; `mode: 6` represents the filtering mode; `value: "Single Vehicle Accident"` specifies that the value to be filtered is "Single Vehicle Accident", that is, only data with the accident type "Single Vehicle Accident" will be selected; `orderParams: "Number of Accidents": "desc"` defines the sorting method of the results, which is sorted in descending order (desc) according to the "Number of Accidents" field, that is, the group with the most accidents will be ranked first; `limit: 5` limits the number of results returned to 5, that is, only the first 5 data after filtering and sorting according to the above conditions will be returned.
[0076]
[0077] Table 1
[0078] Table 1 shows the format definition of the getIndices type API instruction provided in the embodiments of this application. The structure encoder can generate the getIndices type API instruction as shown in Table 1 according to the format definition. The getIndices API instruction includes multiple parameters, namely: query token (sysCode), index domain (indexDomain), business domain (geoDim), atomic index field (atomIndexes), start time (startTime), end time (endTime), aggregation dimension (groupFields), having condition (havingQueryParams), sorting field (orderParams), limit on the number of records to be returned (limitNum), whether to need the same period value, year-on-year comparison (samePeriod), whether to need the previous period value month-on-month comparison (lastPeriod), and constraint conditions (query Params) including column name (field), filter specific value (val), and operator (mod).
[0079] Table 1 also stores information on whether each parameter is a required field and the corresponding enumeration value for each parameter. For example, `sysCode` is a required field and can be system identifiers such as `hiface`, `hicon`, and `hitraffic`; `indexDomain` is a required field and can be fields such as `trafficStatus` and `trafficSafe`; `geoDim` is a required field, where the `trafficStatus` index has the following business domains: `crossing`, `section`, `area`, `line`, `city`, and `inout`; the `trafficSafe` index has the following business domains: `veh`, `drv`, `acd`, `violation`, and `pis`; `atomIndexes` is a required field and can be fields such as the number of accidents, property damage, and the number of police incidents; `startTime` is a required field and can be in the format `2024-7-26 14:24:06`; `endTime` is a required field and can be in the format `2024-7-26`. 14:24:06; groupFields is not required and can be an array, etc.; havingQueryParams is required and has the same structure as queryParam; orderParams is not required and can have multiple fields separated by commas. It must be specified whether the order is increasing or decreasing, with increasing as the default. Fields can be sgfssjdesc, xzqh, sgdd desc, etc.; limitNum is not required and defaults to 100,000 records, allowing a maximum query of TOP records. 100000; `samePeriod` is not required and can be any number from 0 to 5, where 0 indicates no return of the same period last year, 1 indicates return of the same period last week, 2 indicates return of the same period last month, 3 indicates return of the same period last quarter, 4 indicates return of the same period last year, 5 indicates return of the same period last day, etc.; `lastPeriod` is not required and can be any number from 0 to 5 or 11, where 0 indicates no return, 1 indicates an interval of an integer number of weeks, 2 indicates an interval of an integer number of months, 3 indicates an interval of an integer number of quarters, 4 indicates an interval of an integer number of months. Year, 5 indicates an interval of integer days, 11 indicates an interval where the end time represents the start time difference, etc.; mode can be SQL operators or semantic operators. SQL operators are any numbers from 0 to 10, where 1 represents greater than, 2 represents greater than or equal to, 3 represents less than, 4 represents less than or equal to, 5 represents not equal to, 6 represents equal to, 7 represents like, 8 represents not like, 9 represents in, multiple values are separated by the English word |, 10 represents not in, multiple values are separated by the English word |. Semantic operators are passed in fixed semantic vocabulary, such as: "located in", "mentioned", "nocturnal".
[0080] In addition, electronic devices can also be configured with format definitions corresponding to other types of API instructions. The structure encoder generates API instructions for each type based on the format definition corresponding to each type of API instruction.
[0081] To improve the accuracy of generated SQL and thus enhance question-answering performance, based on the above embodiments, the training process of the question-answering model in this embodiment includes: Obtain training samples, which include sample question text, corresponding sample triplet information, and sample instructions; The text encoder of the question-answering model to be trained is used to process the sample question text to obtain the predicted triplet information corresponding to the sample question text; The structural encoder of the question-answering model to be trained is used to process the predicted triplet information to obtain the prediction instruction; The text loss value is determined based on the sample triplet information and the predicted triplet information; The structural loss value is determined based on the sample instruction and the prediction instruction; Based on the text loss value and the structural loss value, a total loss value is determined, and the parameters of the question-answering model to be trained are adjusted according to the total loss value.
[0082] In this embodiment of the application, the electronic device can jointly train the text encoder and the structure encoder of the question answering model to achieve end-to-end mapping from semantics to API; and adjust the parameters of the text encoder and the structure encoder by constructing a multi-task loss function.
[0083] For example, the architecture of a question-answering model can be:
[0084] Where Model represents the question-answering model. Indicates a text encoder. This indicates the problem text. Indicates a structure encoder. This refers to the API specification.
[0085] Specifically, the electronic device acquires training samples, which include sample question text, corresponding sample triplet information, and sample instructions. The electronic device processes the sample question text using the text encoder of the question-answering model to be trained, obtaining the predicted triplet information corresponding to the sample question text. The electronic device then processes the predicted triplet information using the structural encoder of the question-answering model to be trained, obtaining the predicted instructions. Based on the sample triplet information and the predicted triplet information, the electronic device determines a text loss value. Based on the sample instructions and the predicted instructions, the electronic device determines a structural loss value. Based on the text loss value and the structural loss value, the electronic device determines a total loss value and adjusts the parameters of the question-answering model to be trained based on the total loss value.
[0086] In one possible implementation, the electronic device can determine the text loss value based on the sample intent carried in the sample triplet information and the probability that the sample question text carried in the predicted triplet information belongs to each intent.
[0087] In another possible implementation, the electronic device can also determine the structural loss value based on whether each field generated by the structural encoder is an illegal field under the current intent.
[0088] For example, the text loss value satisfies the following formula:
[0089] in, Represents the text loss value. One-hot encoded vector representing the sample intent (e.g., "statistical percentage" corresponds to class i). K represents the probability that the text encoder predicts the question text belongs to the i-th intent category, where K is the total number of intent categories.
[0090] For example, the structural loss value satisfies the following formula:
[0091] in, This represents the structural loss value, where F represents the set of all fields generated by the structural encoder model (such as groupFields, metrics, etc.). This represents the set of illegal fields under the current intent, and I() represents the indicator function, which takes 1 for illegal fields and 0 otherwise. This represents the L2 norm penalty for the parameter corresponding to the illegal field.
[0092] For example, the total loss value satisfies the following formula:
[0093] in, This represents the total loss value. Represents the text loss value. Indicates the structural loss value. and Preset weights.
[0094] To improve the accuracy of generated SQL and thus enhance question-answering effectiveness, based on the above embodiments, in this embodiment, before the instruction parsing engine processes the target instruction to generate a first SQL statement for querying data corresponding to the intent, entity, and corresponding constraints, the method further includes: Based on each data tag stored in the knowledge base, determine whether there exists a target data tag that contains the constraints; If the target data tag exists, the subsequent call instruction parsing engine is executed to process the target instruction and generate a first SQL statement for querying the intent, entity, and corresponding constraint data.
[0095] In this embodiment of the application, in order to avoid the situation where no response is possible, the electronic device calls the instruction parsing engine to process the target instruction and generate a first SQL statement for querying the intent, entity and corresponding constraint conditions. The electronic device will determine whether there is a target data tag containing the constraint condition based on each data tag stored in the knowledge base.
[0096] If the electronic device determines that the knowledge base contains the target data tag containing the constraint, and determines that it can directly find the relevant data for replying to the question text in the knowledge base, then the electronic device can execute the subsequent call instruction parsing engine to process the target instruction and generate the first SQL statement for querying the intent, entity and corresponding constraint data.
[0097] In another possible implementation, the electronic device can analyze whether the database table contains the data corresponding to the constraint condition through a semantic model, such as a large language model. If the electronic device determines that the database table contains the data corresponding to the constraint condition based on the semantic model, the electronic device can execute the subsequent call instruction parsing engine to process the target instruction and generate a first SQL statement for querying the intent, entity and corresponding constraint condition data.
[0098] To improve the accuracy of generated SQL and thus enhance question-answering effectiveness, based on the above embodiments, the method in this application embodiment further includes: If the knowledge base does not contain a target data tag that contains the constraints, the instruction parsing engine is invoked to process the target instruction and generate a second SQL statement for querying the data corresponding to the intent and entity. According to the second SQL statement, query the knowledge base for the second target data corresponding to the intent and the entity, and generate a response text based on the second target data.
[0099] If the electronic device determines that the target data label containing the constraints does not exist in the knowledge base, then the electronic device determines that it cannot directly find the relevant data for replying to the question text in the knowledge base.
[0100] The electronic device can call the instruction parsing engine to process the target instruction and generate a second SQL statement for querying the data corresponding to the intent and entity; based on the second SQL statement, it queries the knowledge base for the second target data corresponding to the intent and entity, and generates a response text based on the second target data.
[0101] In another possible implementation, the electronic device can analyze whether the database table contains the data corresponding to the constraint condition through a semantic model, such as a large language model. If the electronic device determines, based on the semantic model, that the database table does not contain the data corresponding to the constraint condition, the electronic device can call the instruction parsing engine to process the target instruction and generate a second SQL statement for querying the data corresponding to the intent and entity.
[0102] To improve the accuracy of generated SQL and thus enhance question-answering performance, based on the above embodiments, in this embodiment, querying the second target data corresponding to the intent and the entity in the knowledge base according to the second SQL statement includes: Based on the second SQL statement, retrieve each candidate data corresponding to the intent and the entity from the knowledge base; Based on a preset similarity algorithm, the similarity between each candidate data and the constraint condition is determined. Candidate data whose similarity exceeds a preset similarity threshold are identified as the second target data.
[0103] In this embodiment of the application, after the electronic device calls the instruction parsing engine to process the target instruction and generate a second SQL statement for querying the data corresponding to the intent and entity, the electronic device responds to the second SQL statement.
[0104] Specifically, the electronic device retrieves each candidate data corresponding to the intent and entity from the knowledge base according to the second SQL statement; determines the similarity between each candidate data and the constraint conditions according to the preset similarity algorithm; and determines the candidate data whose corresponding similarity exceeds the preset similarity threshold as the second target data.
[0105] Traditional SQL parsing engines suffer from a "semantic processing bottleneck," failing to parse complex semantics such as spatial relationships (e.g., "near the school") and event descriptions (e.g., "mention of vehicle fire"). Furthermore, a single execution engine struggles to adapt to multimodal query requirements (structured data + unstructured text).
[0106] Based on this, this application proposes a hybrid engine architecture that achieves semantic collaborative computing through a three-layer fusion design. Specifically, the hybrid engine architecture includes a semantic operator execution model, an SQL calculation module, and a dedicated operator interface module. The SQL calculation module can be the instruction parsing engine described in the above embodiments.
[0107] The semantic operator execution model can call LLM to handle the semantic computation requirements of non-SQL logic in the API. This semantic operator execution module supports five types of complex semantics (spatial relationships, event descriptions, temporal evolution, text features, and domain rules). The SQL computation module is used to perform standard data filtering and aggregation, such as WHERE alarm type = 'traffic accident', GROUPBY month, etc. The dedicated interface operator module is used to encapsulate domain-specific computation logic (such as traffic congestion index and accident hotspot prediction).
[0108] Figure 5 A possible question-and-answer flowchart provided for an embodiment of this application, such as Figure 5 As shown, the structured query API intent of the electronic device yields the following structured API commands: Data model: Police incident; Data metric: Number of police incidents; Statistical period: 2025-05-01 00:00:00 to 2025-06-01 00:00:00; Grouping dimension: Month; Analysis dimensions: Police incident type, filter criteria: equal to, filter value: traffic accident; Intelligence description, filter criteria: include, filter values: vehicle burning | spontaneous combustion; Sort by month, in ascending order; The electronic device inputs the structured API instructions into the hybrid computing engine. Based on the structured API instructions, the hybrid computing engine decomposes and arranges query subtasks, analyzes whether each alarm description text mentions vehicle burning or spontaneous combustion based on the semantic operator execution module, obtains candidate SQL statements based on the SQL calculation module, and finally summarizes and generates the first SQL statement.
[0109] Figure 6 As another possible question-answering flowchart provided in this application embodiment, the electronic device uses the training dataset to fine-tune the SET large model to obtain a general vertical domain large model (question-answering model) for NL2API structured parsing, obtaining the structured API instruction corresponding to the user question "Please analyze the changing trend of the number of traffic accident-related police reports involving vehicle combustion and spontaneous combustion in the last quarter". The API instruction is: Data model: Police incident; Data metric: Number of police incidents; Statistical period: 2025-05-01 00:00:00 to 2025-06-01 00:00:00; Grouping dimension: Month; Analysis dimensions: Police incident type, filter criteria: equal to, filter value: traffic accident; Intelligence description, filter criteria: include, filter values: vehicle burning | spontaneous combustion; Sort by month, in ascending order; The electronic device performs post-processing verification on the API instruction; The verified API instruction is input into the hybrid computing engine, which decomposes and arranges query subtasks based on the structured API instruction, and obtains the first SQL statement based on the semantic operator execution module, the SQL calculation module, and the external computing extension module.
[0110] Based on the above embodiments, this application also provides a traffic question-and-answer device based on a large model. Figure 7 A schematic diagram of a traffic question-answering device based on a large model is provided for embodiments of this application. The device includes: The processing module 701 is used to process the input question text using a question-answering model to generate a target instruction containing triple information of the question text; wherein, the triple information includes intent, entity and corresponding constraints; and to call the instruction parsing engine to process the target instruction to generate a first SQL statement for querying the data corresponding to the intent, entity and corresponding constraints. The question-answering module 702 is used to query the first target data corresponding to the intent, entity and corresponding constraints in the knowledge base according to the first SQL statement, and generate a response text based on the first target data.
[0111] In one possible implementation, the question-answering model includes a text encoder and a structure encoder; The processing module 701 is specifically used to process the problem text using the text encoder to obtain the triplet information corresponding to the problem text; and to process the triplet information using the structure encoder to obtain the target instruction.
[0112] In one possible implementation, the processing module 701 is specifically configured to: use the text encoder to perform intent recognition on the question text to obtain the intent of the question text; use the text encoder to perform entity recognition on the question text to obtain the entities contained in the question text; use the text encoder to perform constraint recognition on the question text to obtain the constraints contained in the question text; and determine the intent, the entities, and the constraints as the triplet information.
[0113] In one possible implementation, the target instruction is an API instruction; The processing module 701 is specifically used to call the structure encoder to determine the target API instruction type corresponding to the intent of the question text according to the configured correspondence between intent and API instruction type; call the structure encoder to obtain the API template corresponding to the configured target API instruction type; and add the intent of the question text, the entities contained in the question text and the corresponding entity values to the API template to obtain the API instruction.
[0114] In one possible implementation, the device further includes: The training module 703 is used to acquire training samples, which include sample question text, corresponding sample triplet information, and sample instructions; process the sample question text using the text encoder of the question-answering model to be trained to obtain the prediction triplet information corresponding to the sample question text; process the prediction triplet information using the structure encoder of the question-answering model to be trained to obtain prediction instructions; determine the text loss value based on the sample triplet information and the prediction triplet information; determine the structure loss value based on the sample instructions and the prediction instructions; determine the total loss value based on the text loss value and the structure loss value; and adjust the parameters of the question-answering model to be trained based on the total loss value.
[0115] In one possible implementation, the processing module 701 is further configured to determine whether there is a target data tag containing the constraint condition based on each data tag stored in the knowledge base; if the target data tag exists, the subsequent call instruction parsing engine is executed to process the target instruction and generate a first SQL statement for querying the intent, entity and corresponding constraint condition data.
[0116] In one possible implementation, the processing module 701 is further configured to, if the knowledge base does not contain a target data tag containing the constraint, call the instruction parsing engine to process the target instruction and generate a second SQL statement for querying the data corresponding to the intent and entity; according to the second SQL statement, query the second target data corresponding to the intent and entity in the knowledge base, and generate a response text based on the second target data.
[0117] In one possible implementation, the processing module 701 is specifically configured to: obtain each candidate data corresponding to the intent and the entity from the knowledge base according to the second SQL statement; determine the similarity between each candidate data and the constraint conditions according to a preset similarity algorithm; and determine the candidate data whose corresponding similarity exceeds a preset similarity threshold as the second target data.
[0118] Based on the above embodiments, this application also provides an electronic device. Figure 8 This application provides a schematic diagram of an electronic device structure, such as... Figure 8 As shown, it includes: processor 801, communication interface 802, memory 803 and communication bus 804, wherein processor 801, communication interface 802 and memory 803 communicate with each other through communication bus 804. The memory 803 stores a computer program. When the program is executed by the processor 801, the processor 801 performs the following steps: The input question text is processed using a question-answering model to generate a target instruction containing triple information of the question text; wherein, the triple information includes intent, entity and corresponding constraints. The instruction parsing engine is invoked to process the target instruction and generate a first SQL statement for querying the intent, entity, and corresponding constraint data. Based on the first SQL statement, query the knowledge base for the first target data corresponding to the intent, entity and corresponding constraints, and generate a response text based on the first target data.
[0119] In one possible implementation, the question-answering model includes a text encoder and a structure encoder; The step of processing the input question text using a question-answering model to generate a target instruction containing triple information of the question text includes: The text encoder is used to process the question text to obtain the triplet information corresponding to the question text; The structure encoder is used to process the triplet information to obtain the target instruction.
[0120] In one possible implementation, processing the question text using the text encoder to obtain the triplet information corresponding to the question text includes: The text encoder is used to perform intent recognition on the question text to obtain the intent of the question text; The text encoder is used to perform entity recognition on the question text to obtain the entities contained in the question text; The text encoder is used to identify the constraints in the question text to obtain the constraints contained in the question text. The intent, the entity, and the constraint are determined as the triplet information.
[0121] In one possible implementation, the target instruction is an API instruction; The process of using the structure encoder to process the triplet information to obtain the target instruction includes: The structure encoder determines the target API instruction type corresponding to the intent of the question text based on the configured correspondence between intent and API instruction type. The structure encoder obtains the API template corresponding to the configured target API instruction type, and adds the intent of the question text, the entities contained in the question text, and the corresponding entity values to the API template to obtain the API instruction.
[0122] In one possible implementation, the training process of the question-answering model includes: Obtain training samples, which include sample question text, corresponding sample triplet information, and sample instructions; The text encoder of the question-answering model to be trained is used to process the sample question text to obtain the predicted triplet information corresponding to the sample question text; The structural encoder of the question-answering model to be trained is used to process the predicted triplet information to obtain the prediction instruction; The text loss value is determined based on the sample triplet information and the predicted triplet information; The structural loss value is determined based on the sample instruction and the prediction instruction; Based on the text loss value and the structural loss value, a total loss value is determined, and the parameters of the question-answering model to be trained are adjusted according to the total loss value.
[0123] In one possible implementation, before the call instruction parsing engine processes the target instruction and generates a first SQL statement for querying data corresponding to the intent, entity, and corresponding constraints, the method further includes: Based on each data tag stored in the knowledge base, determine whether there exists a target data tag that contains the constraints; If the target data tag exists, the subsequent call instruction parsing engine is executed to process the target instruction and generate a first SQL statement for querying the intent, entity, and corresponding constraint data.
[0124] In one possible implementation, the method further includes: If the knowledge base does not contain a target data tag that contains the constraints, the instruction parsing engine is invoked to process the target instruction and generate a second SQL statement for querying the data corresponding to the intent and entity. According to the second SQL statement, query the knowledge base for the second target data corresponding to the intent and the entity, and generate a response text based on the second target data.
[0125] In one possible implementation, querying the knowledge base for the second target data corresponding to the intent and the entity according to the second SQL statement includes: Based on the second SQL statement, retrieve each candidate data corresponding to the intent and the entity from the knowledge base; Based on a preset similarity algorithm, the similarity between each candidate data and the constraint condition is determined. Candidate data whose similarity exceeds a preset similarity threshold are identified as the second target data.
[0126] Since the principle of the above-mentioned electronic device in solving problems is similar to that of the traffic question-answering method based on a large model, the implementation of the above-mentioned electronic device can be found in the embodiments of the method, and the repeated parts will not be described again.
[0127] The communication bus mentioned in the aforementioned electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used in the figure, but this does not indicate that there is only one bus or one type of bus. The communication interface 802 is used for communication between the aforementioned electronic device and other devices. The memory can include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory can also be at least one storage device located remotely from the aforementioned processor.
[0128] The processors mentioned above can be general-purpose processors, including central processing units, network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits, field-programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0129] Based on the above embodiments, this invention also provides a computer-readable storage medium storing a computer program executable by a processor. When the program runs on the processor, it causes the processor to perform the following steps: The input question text is processed using a question-answering model to generate a target instruction containing triple information of the question text; wherein, the triple information includes intent, entity and corresponding constraints. The instruction parsing engine is invoked to process the target instruction and generate a first SQL statement for querying the intent, entity, and corresponding constraint data. Based on the first SQL statement, query the knowledge base for the first target data corresponding to the intent, entity and corresponding constraints, and generate a response text based on the first target data.
[0130] In one possible implementation, the question-answering model includes a text encoder and a structure encoder; The step of processing the input question text using a question-answering model to generate a target instruction containing triple information of the question text includes: The text encoder is used to process the question text to obtain the triplet information corresponding to the question text; The structure encoder is used to process the triplet information to obtain the target instruction.
[0131] In one possible implementation, processing the question text using the text encoder to obtain the triplet information corresponding to the question text includes: The text encoder is used to perform intent recognition on the question text to obtain the intent of the question text; The text encoder is used to perform entity recognition on the question text to obtain the entities contained in the question text; The text encoder is used to identify the constraints in the question text to obtain the constraints contained in the question text. The intent, the entity, and the constraint are determined as the triplet information.
[0132] In one possible implementation, the target instruction is an API instruction; The process of using the structure encoder to process the triplet information to obtain the target instruction includes: The structure encoder determines the target API instruction type corresponding to the intent of the question text based on the configured correspondence between intent and API instruction type. The structure encoder obtains the API template corresponding to the configured target API instruction type, and adds the intent of the question text, the entities contained in the question text, and the corresponding entity values to the API template to obtain the API instruction.
[0133] In one possible implementation, the training process of the question-answering model includes: Obtain training samples, which include sample question text, corresponding sample triplet information, and sample instructions; The text encoder of the question-answering model to be trained is used to process the sample question text to obtain the predicted triplet information corresponding to the sample question text; The structural encoder of the question-answering model to be trained is used to process the predicted triplet information to obtain the prediction instruction; The text loss value is determined based on the sample triplet information and the predicted triplet information; The structural loss value is determined based on the sample instruction and the prediction instruction; Based on the text loss value and the structural loss value, a total loss value is determined, and the parameters of the question-answering model to be trained are adjusted according to the total loss value.
[0134] In one possible implementation, before the call instruction parsing engine processes the target instruction and generates a first SQL statement for querying data corresponding to the intent, entity, and corresponding constraints, the method further includes: Based on each data tag stored in the knowledge base, determine whether there exists a target data tag that contains the constraints; If the target data tag exists, the subsequent call instruction parsing engine is executed to process the target instruction and generate a first SQL statement for querying the intent, entity, and corresponding constraint data.
[0135] In one possible implementation, the method further includes: If the knowledge base does not contain a target data tag that contains the constraints, the instruction parsing engine is invoked to process the target instruction and generate a second SQL statement for querying the data corresponding to the intent and entity. According to the second SQL statement, query the knowledge base for the second target data corresponding to the intent and the entity, and generate a response text based on the second target data.
[0136] In one possible implementation, querying the knowledge base for the second target data corresponding to the intent and the entity according to the second SQL statement includes: Based on the second SQL statement, retrieve each candidate data corresponding to the intent and the entity from the knowledge base; Based on a preset similarity algorithm, the similarity between each candidate data and the constraint condition is determined. Candidate data whose similarity exceeds a preset similarity threshold are identified as the second target data.
[0137] Since the principle of the computer-readable storage medium in solving the problem is similar to that of the traffic question-answering method based on a large model, the implementation of the computer-readable storage medium can be found in the embodiments of the method, and repeated details will not be repeated.
[0138] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0139] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0140] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0141] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0142] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A traffic question-answering method based on a large model, characterized in that, The method includes: The input question text is processed using a question-answering model to generate a target instruction containing triple information of the question text; wherein, the triple information includes intent, entity and corresponding constraints. The instruction parsing engine is invoked to process the target instruction and generate a first SQL statement for querying the intent, entity, and corresponding constraint data. Based on the first SQL statement, query the knowledge base for the first target data corresponding to the intent, entity and corresponding constraints, and generate a response text based on the first target data.
2. The method according to claim 1, characterized in that, The question-answering model includes a text encoder and a structure encoder; The step of processing the input question text using a question-answering model to generate a target instruction containing triple information of the question text includes: The text encoder is used to process the question text to obtain the triplet information corresponding to the question text; The structure encoder is used to process the triplet information to obtain the target instruction.
3. The method according to claim 2, characterized in that, The process of processing the question text using the text encoder to obtain the triplet information corresponding to the question text includes: The text encoder is used to perform intent recognition on the question text to obtain the intent of the question text; The text encoder is used to perform entity recognition on the question text to obtain the entities contained in the question text; The text encoder is used to identify the constraints in the question text to obtain the constraints contained in the question text. The intent, the entity, and the constraint are determined as the triplet information.
4. The method according to claim 2, characterized in that, The target instruction is an API instruction; The process of using the structure encoder to process the triplet information to obtain the target instruction includes: The structure encoder uses the configured correspondence between intent and API instruction type to determine the target API instruction type corresponding to the intent of the question text; The structure encoder is used to obtain the API template corresponding to the configured target API instruction type, and the intent of the question text, the entities contained in the question text, and the constraints contained in the question text are added to the API template to obtain the API instruction.
5. The method according to any one of claims 2-4, characterized in that, The training process of the question-answering model includes: Obtain training samples, which include sample question text, corresponding sample triplet information, and sample instructions; The text encoder of the question-answering model to be trained is used to process the sample question text to obtain the predicted triplet information corresponding to the sample question text; The structural encoder of the question-answering model to be trained is used to process the predicted triplet information to obtain the prediction instruction; The text loss value is determined based on the sample triplet information and the predicted triplet information; The structural loss value is determined based on the sample instruction and the prediction instruction; Based on the text loss value and the structural loss value, a total loss value is determined, and the parameters of the question-answering model to be trained are adjusted according to the total loss value.
6. The method according to claim 1, characterized in that, Before the call instruction parsing engine processes the target instruction and generates a first SQL statement for querying the intent, entity, and corresponding constraints, the method further includes: Based on each data tag stored in the knowledge base, determine whether there exists a target data tag that contains the constraints; If the target data tag exists, the subsequent call instruction parsing engine is executed to process the target instruction and generate a first SQL statement for querying the intent, entity, and corresponding constraint data.
7. The method according to claim 6, characterized in that, The method further includes: If the knowledge base does not contain a target data tag that contains the constraints, the instruction parsing engine is invoked to process the target instruction and generate a second SQL statement for querying the data corresponding to the intent and entity. According to the second SQL statement, query the knowledge base for the second target data corresponding to the intent and the entity, and generate a response text based on the second target data.
8. The method according to claim 7, characterized in that, The step of querying the second target data corresponding to the intent and the entity in the knowledge base according to the second SQL statement includes: Based on the second SQL statement, retrieve each candidate data corresponding to the intent and the entity from the knowledge base; Based on a preset similarity algorithm, the similarity between each candidate data and the constraint condition is determined. Candidate data whose similarity exceeds a preset similarity threshold are identified as the second target data.
9. A traffic question-and-answer device based on a large model, characterized in that, The device includes: The processing module is used to process the input question text using a question-answering model to generate a target instruction containing triple information of the question text; wherein, the triple information includes intent, entity and corresponding constraints; and calls the instruction parsing engine to process the target instruction to generate a first SQL statement for querying the data corresponding to the intent, entity and corresponding constraints. The question-and-answer module is used to query the first target data corresponding to the intent, entity and corresponding constraints in the knowledge base according to the first SQL statement, and generate a response text based on the first target data.
10. An electronic device, characterized in that, The electronic device includes at least a processor and a memory, wherein the processor is configured to execute a computer program stored in the memory to implement the steps of the traffic question-answering method based on a large model as described in any one of claims 1-8.
Citation Information
Patent Citations
Intelligent question answering method, apparatus, computer device and storage medium
CN109522393A
Method for interactively generating data report and computing equipment
CN116756169A
Method and system for converting natural language into SQL (Structured Query Language) statement
CN118916381A
Query generation method in Text2SQL (Structured Query Language) task based on large language model
CN119938698A
Intelligent question answering system and intelligent question answering method based on large model
CN120277091A
Cited By
Intelligent number asking method based on adaptive rule constraint and program product
CN122086959A