A government affair work order structured extraction method, device and equipment
By using dynamic knowledge graph-guided few-sample retrieval and adaptive prompting construction, the problem of dynamic adaptation to varying request types and responsibility boundaries in the structured extraction of government work orders is solved. This achieves high accuracy and low cost in the structured extraction of work orders, supporting the intelligentization of government public services.
Patent Information
- Application Number
- CN202610865151.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-16
- Publication Date
- 2026-08-25
- Estimated Expiration
- 2046-06-16
AI Technical Summary
Existing technologies cannot adapt to the diverse types of requests in the structured extraction of government work orders, have poor dynamic adaptability to the boundaries of responsibilities, and the example library cannot evolve on its own, resulting in low extraction accuracy and high costs.
By constructing a dynamic knowledge graph-guided few-sample retrieval and adaptive prompting, a dual-path retrieval system using graph relation matching and vector semantic similarity is adopted. This system combines a large model to generate structured output and updates the knowledge graph through confidence evaluation and conflict detection mechanisms, thereby achieving self-optimization.
It significantly improves the accuracy and generalization of structured work order extraction, reduces the maintenance cost of the example library, and achieves efficient and reliable intelligent analysis of government work orders.
Smart Images

Figure CN122412499B_ABST
Abstract
Description
Technical Field
[0001] This invention discloses a method, apparatus, and equipment for extracting structured government work orders, which relates to the fields of natural language processing and intelligent government public services. Background Technology
[0002] Public service requests, such as those submitted through citizen hotlines, mailboxes, and online platforms, are crucial data sources for understanding public demands and optimizing public services. Automatically extracting key structured information from large amounts of unstructured request texts is a core step in improving the efficiency of request assignment and processing. However, existing methods still face limitations in this task. For example, some methods rely on manual input or traditional rules combined with machine learning models. These methods depend on staff reading and manually filling in structured fields, or using regular expressions, keyword matching, and traditional classification models for automated extraction. To overcome these problems, a second type of method attempts to introduce a Large Language Model (LLM) and employ zero-shot or fixed-few-shot hints for structured extraction. However, the following inherent defects still exist: (1) Fixed examples cannot adapt to different types of demands; (2) Differences in the boundaries of regional and departmental responsibilities cannot be dynamically injected; (3) Lack of perception of example quality and dynamic update mechanism; (4) Limited prompt window length and cost issues: If we try to cover more types by increasing the number of examples, it will quickly fill the context window of the large model, and at the same time significantly increase inference latency and API call cost. Summary of the Invention
[0003] This invention addresses the problems of existing technologies by providing a method, apparatus, and equipment for structured extraction of government work orders. Through dynamic knowledge graph-guided small-sample retrieval and adaptive prompting construction, it solves the problems of fixed examples failing to cover diverse request types and poor dynamic adaptability of responsibility boundaries. This significantly improves the accuracy and generalization of structured work order extraction, especially for low-frequency request categories, providing efficient and reliable technical support for intelligent analysis of government hotlines.
[0004] The specific solution proposed in this invention is as follows: This invention provides a method for extracting structured government work orders, comprising: Step 1: Construct a knowledge graph and vectorized index for government public services: Construct a knowledge graph that includes nodes for categories of public services, functional departments, rules for responsibility boundaries, and typical work order examples, and generate a semantic vector for each example node to establish a vector index; Step 2: Entity recognition of input work orders and dual-path few-shot retrieval: Entity recognition and category mapping are performed on the input work order text. Graph relation matching and vector semantic similarity are used for dual-path retrieval to dynamically recall the Top-K typical work order examples most relevant to the current work order and their corresponding structured extraction results, forming a few-shot example set. Step 3: Construct adaptive few-sample prompts and perform structured extraction for the large model: Dynamically concatenate the retrieved K typical work order examples into the context window of the large model according to the dialogue format, construct adaptive prompts containing system roles, example demonstrations and the current work order, drive the large model to generate structured output that conforms to the predefined JSONSchema, and complete the field extraction for judging the complainant, the complained object and the scope of government responsibilities. Step 4: Update the knowledge graph: Based on the output of the large model and human feedback, through confidence evaluation and conflict detection mechanisms, the structured extraction results with evaluation quality higher than the threshold are added to the knowledge graph as new examples, and the vector index and graph relationship are updated; Step 5: Continuously optimize retrieval quality: Utilize joint training to optimize the retrieval and extraction process, and dynamically adjust the number of typical work order examples as needed for continuous optimization of retrieval quality.
[0005] Furthermore, step 1 of the aforementioned method for extracting structured government work orders specifically includes: Step 101: Define Knowledge Graph Nodes and Relationships: Define nodes for categories of public welfare matters, functional departments, responsibility boundary rules, and typical work order examples; establish the attribution, processing, applicability, and similarity relationships between nodes. Step 102: Generate semantic vector indexes for knowledge graph nodes: For each typical work order example node, use a pre-trained sentence encoder to map the original text of the typical work order example into a semantic vector, and construct a vector index based on a hierarchical navigable small-world graph (HNSW) for the semantic vectors of all typical work order example nodes, which is used to calculate the cosine similarity of the query vector. Step 103: Perform graph relationship storage: Store the graph structure of the knowledge graph as an adjacency list, which is used to retrieve a set of typical work order example nodes associated with a certain category of livelihood matters or functional department nodes through graph queries.
[0006] Furthermore, step 2 of the aforementioned method for extracting structured government work orders specifically includes: Step 201: Entity Recognition and Category Mapping of Input Work Orders: For the input work order text, a lightweight Named Entity Recognition (NER) model is used to extract keywords related to public welfare matters, department names, and geographical entities. Fuzzy matching is then performed with public welfare matter category nodes and functional department nodes in the knowledge graph to obtain initial category labels and department labels. Step 202: Perform dual-path retrieval and recall: including graph relation retrieval and vector semantic retrieval. Graph relation retrieval obtains a set of associated typical work order example nodes in the knowledge graph based on the initial category and department labels. Vector semantic retrieval maps the input work order text into query vectors using the same sentence encoder, and retrieves the most similar typical work order example nodes from the vector index. After deduplicating the candidate sets from both paths, the results are ranked based on graph matching indicators, semantic similarity, and node graph centrality, and the Top-K examples are selected. Step 203: Perform deduplication and filtering of typical work order examples: Perform text-level deduplication on the retrieved typical work order examples and filter out typical work order examples that clearly conflict with the topic of the current work order.
[0007] Furthermore, step 3 of the aforementioned method for extracting structured government work orders specifically includes: Step 301: Construct an adaptive few-shot suggestion template: Define a suggestion template containing three parts: system role definition, dynamic few-shot demonstration, and the current work order request. The system role definition is fixed content. The dynamic few-shot demonstration concatenates each typical work order example retrieved in the following format: the original work order text and structured JSON. The entire suggestion context is dynamically generated based on the search results. Step 302: Perform large model structure extraction: Call the large model interface, set temperature parameters to ensure output stability, and obtain the model output text; then perform robust JSON parsing, attempting direct parsing, removing Markdown code block markers, and parsing after truncating from the first left curly brace to the last right curly brace. If all attempts fail, record the parsing failure flag. Step 303: Output Schema Forced Validation and Completion: Align the parsed JSON with the predefined target schema, fill missing fields with null values or default values, attempt automatic type conversion for fields with mismatched types, and finally output a standardized structured result.
[0008] Furthermore, step 4 of the aforementioned method for extracting structured government work orders specifically includes: Step 401: Calculate the confidence score of the model output: For the structured output of a large model, consider factors such as field fill rate, consistency between the output and the responsibility rules in the knowledge graph, and the stability of the output after multiple samplings. Step 402: Conflict Detection and Manual Feedback: If the confidence level is lower than the set threshold, or if the output result has a hard conflict with the responsibility boundary rules in the knowledge graph, the work order and model output are pushed to the manual review queue; the correct structured result after manual review is used as authentication data. Step 403: Create a knowledge graph update strategy: Add output results with confidence scores higher than the threshold or authentication results after manual review to the knowledge graph as new typical work order example nodes, and perform the following updates: create new typical work order example nodes and store the original text, structured results, timestamps, and sources; calculate semantic vectors and insert vector indexes; establish associations with existing public service category nodes and functional department nodes; add similarity relationships to typical work order examples with similarity scores exceeding the threshold; periodically perform example deduplication and aging elimination, eliminating examples with low contribution or that have expired.
[0009] Furthermore, step 5 of the aforementioned method for extracting structured government work orders specifically includes: Step 501: Perform end-to-end retrieval-extraction joint framework optimization: Treat the sentence encoder, entity recognition model, and large model as a framework that can be optimized as a whole, and perform joint training using reinforcement learning or approximate gradient propagation to maximize the accuracy of the final structured extraction and optimize the retrieval ranking loss. Step 502: Adaptive Dynamic Adjustment of K Value: Based on the quality of the current work order's retrieval results, the number K of typical work order examples used is dynamically adjusted through a lightweight controller network to achieve a balance between accuracy and computational overhead. Step 503: Embedding multi-granularity responsibility boundary rules: Encode the responsibility boundary rule nodes in the knowledge graph into vectors, recall relevant rule texts during the retrieval phase, and concatenate the rule texts as additional constraints into the prompt template to guide the large model to follow explicit rules when judging the scope of responsibility.
[0010] This invention also provides a structured extraction device for government work orders, including a knowledge graph construction module, a dual-path retrieval module, a structured extraction module, an update module, and an optimization module. The knowledge graph construction module builds a knowledge graph and vectorized index for government public services: it constructs a knowledge graph containing nodes for categories of livelihood matters, functional department nodes, responsibility boundary rule nodes, and typical work order example nodes, and generates semantic vectors for each example node and establishes a vector index; The dual-path retrieval module performs entity recognition on the input work order and performs dual-path few-sample retrieval: it performs entity recognition and category mapping on the input work order text, and uses graph relation matching and vector semantic similarity dual-path retrieval to dynamically recall the Top-K typical work order examples most relevant to the current work order and their corresponding structured extraction results to form a few-sample example set. The structured extraction module constructs adaptive few-sample prompts for structured extraction of the large model: it dynamically concatenates the retrieved K typical work order examples into the context window of the large model according to the dialogue format, constructs adaptive prompts containing system roles, example demonstrations and the current work order, drives the large model to generate structured output that conforms to the predefined JSONSchema, and completes the field extraction for judging the complainant, the complained object and the scope of government responsibilities. The update module updates the knowledge graph: Based on the output of the large model and human feedback, through confidence assessment and conflict detection mechanisms, structured extraction results with evaluation quality exceeding the threshold are added to the knowledge graph as new examples, and the vector indices and graph relationships are updated. The optimization module continuously improves retrieval quality: it utilizes joint training to optimize the retrieval and extraction process and dynamically adjusts the number of typical work order examples as needed for continuous optimization of retrieval quality.
[0011] The present invention also provides a government work order structure extraction device, comprising: at least one memory and at least one processor; The at least one memory is used to store a machine-readable program; The at least one processor is used to call the machine-readable program to execute the government work order structure extraction method.
[0012] The advantages of the method of the present invention are: This invention creatively introduces structured knowledge graphs and the idea of enhanced generation of few-shot retrieval (RAG) into the structured extraction task of government work orders by constructing a complete technical chain of "knowledge graph construction - dual-path dynamic retrieval - adaptive prompt construction - closed-loop continuous evolution". It effectively solves the problems of insufficient coverage of diverse request types, inability to dynamically adapt to the boundaries of regional and departmental responsibilities, and inability of the example library to self-evolve by the traditional fixed few-shot method, and achieves a unity of high accuracy, strong generalization and low cost maintenance.
[0013] By introducing a dual-path retrieval mechanism combining "graph relationship matching + vector semantic similarity," the explicit structural relationships in the knowledge graph and the implicit semantic similarity of the text can be utilized simultaneously. This ensures that the retrieved examples match both in category and semantically, significantly improving the relevance of the examples to the current work order. Experiments show that the dual-path retrieval improves example matching accuracy by more than 20% compared to the single-path approach.
[0014] By designing a closed-loop update strategy based on confidence assessment and conflict detection, the method can automatically filter high-quality model outputs and feed them back to the knowledge graph. A redundancy management mechanism keeps the example library concise and efficient. This allows the example library to continuously optimize itself as business volume grows, and new types of requests can be quickly covered with minimal manual annotation, significantly reducing knowledge base maintenance costs.
[0015] By dynamically adjusting the K-value and embedding multi-granularity responsibility rules, the method achieves an intelligent balance between inference efficiency and accuracy, and enhances the business compliance of responsibility scope judgment. Attached Figure Description
[0016] Figure 1 This is a schematic diagram of the method flow of the present invention. Detailed Implementation
[0017] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, so that those skilled in the art can better understand and implement the present invention. However, the embodiments described are not intended to limit the present invention.
[0018] Example 1: This invention provides a method for extracting structured government work orders, the specific process of which may include: Step 1: Construct a knowledge graph and vectorized index for government public services: Construct a knowledge graph that includes nodes for categories of public services, functional departments, rules for responsibility boundaries, and typical work order examples, and generate a semantic vector for each example node to establish a vector index.
[0019] Specifically, this may include: Step 101: Knowledge Graph Node and Relationship Definition: Define the set of node types ={C,D,R,E} represents the categories of public service matters, functional departments, responsibility boundary rules, and typical work order examples, respectively. The categories of public service matters may include environmental sanitation, traffic order, and fee collection nodes; the functional departments nodes may include urban management departments, education management departments, and street management departments; the responsibility boundary rules nodes include rules such as "sewage within the community that is not part of the municipal pipe network is not under the responsibility of urban management"; and the typical work order example nodes establish the following relationships: belong_to, handles, apply_to, and similar_to. Define a set of relation types ={belongs_to,handles,applies_to,similar_to}; Each example node e∈E is associated with its original text. and the corresponding standard JSON structured output ; Step 102: Semantic Vector Generation and Indexing: For each typical work order example node e, a pre-trained sentence encoder is used. Its original text Mapping to semantic vectors ,Right now For the semantic vectors of all typical work order example nodes, an efficient nearest neighbor retrieval vector index structure is constructed based on the HNSW index, enabling rapid calculation of similarity given a query vector q. , express The L2 norm of the query vector The "model length", express The L2 norm, i.e., semantic vector The "model length", Step 103: Graph Relationship Storage: Store the graph structure of the knowledge graph as an adjacency list, which is used to quickly retrieve the set of example nodes associated with a certain category of livelihood matters or functional department nodes through graph queries.
[0020] Step 2: Entity recognition of input work orders and dual-path few-shot retrieval: Entity recognition and category mapping are performed on the input work order text. Graph relation matching and vector semantic similarity are used for dual-path retrieval to dynamically recall the Top-K typical work order examples most relevant to the current work order and their corresponding structured extraction results, forming a few-shot example set.
[0021] Specifically, this may include: Step 201: Entity recognition and category mapping of input work orders: For the input work order text x, the lightweight named entity recognition model BERT-BiLSTM-CRF is used to extract keywords related to public welfare matters, department names, and geographical entities to obtain the entity set. The extracted entities are then fuzzily matched with category nodes C and department nodes D in the knowledge graph to obtain initial category labels. and departmental labels ; Step 202: Dual-path retrieval and recall: Graph Relationship Retrieval: Based on Initial Category Labels and departmental labels Perform a graph query within the knowledge graph to retrieve related data. A collection of typical work order example nodes connected by the `belongs_to` relationship. and with A collection of typical work order example nodes connected by the handles relationship. take the union ; Vector semantic retrieval: Transform the input work order text x into the same sentence encoder. Mapped to query vector Searching for related data in the vector index The highest cosine similarity A collection of typical work order example nodes is obtained. ; Dual-path fusion and sorting: merging search results from two paths For each candidate example e∈E, calculate the composite score: , In the formula, For indicator functions, , , For adjustable fusion weights, node_centrality(e) represents the graph centrality of the example node in the knowledge graph, i.e., the PageRank value, used to improve the recall priority of high-frequency effective examples; the Top-K examples are selected in descending order of score, and K is dynamically adjusted according to the complexity of the input work order, with a value of [value missing]. , where entropy(x) is the semantic entropy estimate of the work order text, and α is a linear scaling factor that controls the magnitude of the influence of semantic entropy on the number of examples K.
[0022] Step 203: Example Deduplication and Filtering: The retrieved typical work order examples are deduplicated at the text level using Jaccard similarity with a threshold of 0.85, and typical work order examples that clearly conflict with the topic of the current work order are filtered out.
[0023] Step 3: Construct adaptive few-sample prompts and perform structured extraction for the large model: Dynamically concatenate the retrieved K typical work order examples into the context window of the large model according to the dialogue format, construct adaptive prompts that include system roles, example demonstrations and the current work order, drive the large model to generate structured output that conforms to the predefined JSONSchema, and complete the field extraction for judging the complainant, the complained party and the scope of government responsibilities.
[0024] Specifically, it can include: Step 301: Construction of Adaptive Few-Sample Cue Template: Define the cue template It consists of three parts: System role definition: Fixed content: "You are a government service request work order analysis expert, and you must strictly judge according to your responsibilities and output valid JSON." Dynamic few-sample demonstration: For each typical work order example retrieved (i=1..K), construct message pairs: , , And assemble them in sequence; Current work order request: End-user message "Please refer to the above example and output the structured result in JSON format for the following work order. Do not output any other content:" +x; The entire context of the prompt is denoted as ; Step 302: Large Model Structure Extraction: Call the large model interface, set the temperature parameter T to 0.1, and the maximum number of output tokens. The value is 1024, resulting in the model's output text. Then robust JSON parsing is performed: , In the formula, the JSONExtract function attempts in sequence: direct parsing, removing Markdown code block markers, and parsing after extracting from the first { to the last}. If all of these fail, it returns an empty dictionary and records the parsing failure flag. Step 303: Output Schema Forced Validation and Completion: The parsed... Align with predefined target schemas, fill missing fields with null or default values, and attempt automatic type conversion for fields with mismatched types; finally, output the standardized structured result. .
[0025] Step 4: Update the knowledge graph: Based on the output of the large model and human feedback, through confidence evaluation and conflict detection mechanisms, the structured extraction results with evaluation quality higher than the threshold are added to the knowledge graph as new examples, and the vector index and graph relationship are updated.
[0026] Specifically, it can include: Step 401: Confidence assessment of model output: For structured results of large model output Calculate its confidence score Considering the following factors: Field fill rate: ; Consistency of responsibility scope: If the output contains the "responsibility scope judgment" field, it is compared with the default responsibility scope of the corresponding livelihood matter category node in the knowledge graph to obtain rule_score∈[0,1]; Output stability: Sample the same work order multiple times, such as 3 times, at a temperature of 0.1, and calculate the average field-level Jaccard similarity (stability) between the output results. The formula for calculating the total confidence level is: , In the formula, , , For the weighting coefficients, satisfying + + =1; Step 402: Conflict Detection and Manual Feedback Trigger: If If the output is 0.6, or if there is a hard conflict between the output and the responsibility rules in the knowledge graph (e.g., it is judged to be "within the scope of responsibility" but the corresponding item is clearly in the exclusion list), then the work order and model output are pushed to the manual review queue; the correct structured result after manual review is recorded as . ; Step 403: Knowledge Graph Update Strategy: For knowledge graphs with confidence scores higher than a threshold For example, the output of 0.9 Or after manual review This will be used as a new typical work order example node. Add to the knowledge graph and perform the following updates: Adding a node: Create a new typical work order example node to store the original text x and the structured result. or Timestamp and source; Vector index update: calculation semantic vectors Insert it into the vector index; Graph relationship update: Establish "belongs_to" or "handles" relationships between entities extracted from x and existing public service category nodes and department nodes; if a new typical work order example is highly similar to an existing example (e.g., cosine similarity > 0.95), add a "similar_to" relationship to form an example cluster; Redundancy management: Regularly perform instance deduplication and aging-out, and for instances exceeding the maximum retention limit... Examples are sorted according to "time decay factor" and "contribution," and the example with the lowest score is eliminated. The score calculation formula is as follows: , In the formula, `hit_count(e)` represents the time interval since the last retrieval, `hit_count(e)` represents the number of times the example has been retrieved, and `avg_conf(e)` represents the average confidence score of the model output after the example has been used. This is a hyperparameter.
[0027] Step 5: Continuously optimize retrieval quality: Utilize joint training to optimize the retrieval and extraction process, and dynamically adjust the number of typical work order examples as needed for continuous optimization of retrieval quality.
[0028] Specifically, it may include: Step 501: End-to-end retrieval-extraction joint optimization framework: incorporating sentence encoders The entity recognition model and the larger model are treated as a differentiable whole, and joint optimization is performed using reinforcement learning or approximate gradient propagation. The goal is to maximize the accuracy of the final structured extraction, and the loss function is designed as follows: , In the formula, the structured output is flattened into a sequence prediction task. For cross-entropy loss, It is a correctly structured output that has been manually annotated or verified by business processes, i.e., the accurate JSON representation of fields such as the complainant, the respondent, and the scope of responsibilities under ideal conditions. It is to adjust the search ranking loss Total loss The balancing hyperparameters for the proportion of contributions in the middle. To retrieve ranking losses such as PairwiseHingeLoss, ensure that relevant examples are ranked higher than irrelevant examples: , In the formula, This is a typical work order example node related to the current input work order x. These are typical work order example nodes that are unrelated or have low relevance to the current input work order x. This is a set of typical work order examples, representing both relevant and irrelevant traffic, where m is the interval hyperparameter. It is the relevance score between the example node and the input work order x; Step 502: Dynamic K-value adaptive adjustment: The number of samples K used is dynamically adjusted based on the quality of the current work order's retrieval results, through a lightweight controller network. Input work order features and retrieval similarity distribution, output optimal K value: , In the formula, This is a small multilayer perceptron trained using the policy gradient method. The reward function is a trade-off between the accuracy improvement and computational cost of the model output after using K examples. These are the batch of candidate examples most relevant to the current input work order x; Step 503: Multi-granularity responsibility rule embedding: The responsibility boundary rule nodes R in the knowledge graph are also encoded as vectors, and relevant rule texts are recalled simultaneously during the retrieval phase. These rules are then concatenated as additional constraints into the system prompts to guide the large model to follow explicit rules when determining the scope of responsibility. The rule matching score is calculated as follows: , In the formula, This represents the semantic vector of a responsibility boundary rule node *r* in the knowledge graph, i.e., the vector representation of the rule node; and selects the one with the highest score. Add a prompt to the rule. The prompt format is: "Note: According to the 'xxx regulations', [rule content]".
[0029] Simulation experiments show that, in a scenario covering over 100 categories of public service requests and processing tens of thousands of work orders daily, the method of this invention, compared to a fixed few-shot large model baseline, improves the F1 score for the requester field by over 9%, the accuracy of responsibility scope determination by over 13%, and the F1 score for extracting low-frequency request categories by over 20%, while keeping the increase in inference latency within 30%. This provides crucial technical support for building a large-scale, implementable, and continuously evolving intelligent government public service system.
[0030] Example 2: When the method of the present invention is applied to a citizen service hotline, the process can be referred to as follows: Step 1: Construction and Vectorized Indexing of the Government Public Service Knowledge Graph: A knowledge graph was constructed based on historical work order data from a city's citizen service hotline. The specific steps are as follows: S101. Knowledge Graph Node and Relationship Definitions: 2 million labeled work orders from the past 12 months were collected. From these, 86 categories of public service items were extracted (e.g., "Environmental Sanitation - Garbage Collection," "Traffic Order - Parking," "Education Fees - Kindergarten," "Property Management - Elevator Malfunction," etc.), 47 functional department nodes (e.g., "Urban Management Bureau," "District Education Bureau," "Street Office," etc.), and 312 responsibility boundary rule nodes (derived from the "List of Responsibilities of Functional Departments" and local implementation rules, e.g., "Sewage Pipeline Repair within the Community Red Line - Belongs to the Property Service Company or the Local Street Office, Not the Responsibility of the Municipal Water Resources Bureau"). Each work order was manually reviewed to form a typical work order example node. Initially, 20,000 examples were selected, covering all categories and with complete fields. Each example node stores the original work order text. and the corresponding standard JSON structured output This includes a "Petitioner" object, a "Respondent" object, and a "Scope of Responsibility Judgment" field containing the scope of acceptance, confidence level, and judgment basis. Relationships are established between nodes: Category nodes are connected to their parent category via `belongs_to`; Example nodes are connected to their finest-grained public service category via `belongs_to`; Example nodes are connected to the relevant functional departments via `handles`; Rule nodes are connected to categories or departments via `applies_to`; If the text cosine similarity between examples is >0.85, a `similar_to` relationship is added.
[0031] Step 102: Semantic Vector Generation and Indexing: Using a pre-trained paraphrase-multilingual-MiniLM-L12-v2 sentence encoder. The work order text for each example node Encoded as a 768-dimensional semantic vector A vector index based on a hierarchical navigable small-world graph (HNSW) was constructed using the FAISS library. The index parameters were set to: M=32 connections per node and ef_construction=200, supporting cosine similarity retrieval. This index can hold millions of vectors, with a single query latency of less than 10ms.
[0032] Step 103: Graph Relationship Storage: The knowledge graph structure is stored using the graph database Neo4j, including node attributes such as type, text, JSON, creation time, and edge relationships. It supports the Cypher query language for quickly retrieving example nodes: for example, given the category label "garbage collection", all relevant examples can be retrieved via MATCH(e:Example)-[:belongs_to]->(c:Category{name:'garbage collection'})RETURNe.
[0033] Step 2: Entity recognition and dual-path few-sample retrieval of input work orders: Receive a real-time input work order text x = "I am a resident of XX community. There is a pile of garbage at the entrance of the community that has not been cleaned for a week, which is affecting my life. Which department is responsible for this? Can it be handled as soon as possible? My phone number is 138****1234." Perform the following operations: Step 201: Entity Recognition and Category Mapping of Input Work Orders: Using a lightweight BERT-BiLSTM-CRF named entity recognition model, the following keywords were extracted: "garbage cleaning" and "garbage dump". The department name did not appear directly (identified as "None"), and the geographical entity "XX Community". Based on edit distance and a thesaurus, the extracted keywords were fuzzily matched with the category nodes in the knowledge graph to obtain the initial category label "environmental sanitation - garbage collection" and the department label, which is currently empty.
[0034] Step 202: Dual-path retrieval and recall: Graph Relationship Retrieval: Execute a Cypher query based on the category label "Environmental Sanitation - Garbage Collection" to retrieve the set of example nodes connected to this category via the `belongs_to` relationship. A total of 124 examples were obtained. Because the department label was empty, It is empty, therefore .
[0035] Vector semantic retrieval: Transforming the work order text x through the same sentence encoder Mapped to a 768-dimensional query vector Search for the vector index with the highest cosine similarity. =50 example nodes, resulting in .
[0036] Dual-path fusion and sorting: merging results from two paths There are a total of 158 candidate examples. Set the fusion weights. =0.3, =0.5, =0.2, where the node graph centrality (e) is pre-calculated and stored using the PageRank algorithm. A composite score is calculated for each candidate example: , Sort by score in descending order and take the first K=3 examples. The three examples retrieved in this example are: Example 1: Similarity 0.94, score 0.89, content is a typical work order for "garbage piling up in the community and no one cleaning it"; Example 2: Similarity 0.88, score 0.82, content is "odor from garbage transfer station in urban village"; Example 3: Similarity 0.85, score 0.79, content is "garbage bins overflowing on the road".
[0037] Step 203: Example deduplication and filtering: Calculate the Jaccard similarity between each pair of the three examples based on the bag of words after word segmentation. All are less than 0.7, indicating no duplication; and all are consistent with the current work order topic, so all are retained.
[0038] Step 3: Adaptive few-shot cue construction and structured extraction for large models: Step 301: Adaptive Few-Sample Hint Template Construction: Dynamically construct the hint context based on the 3 retrieved examples. System Role: You are a petition analysis expert, and you must strictly judge according to the scope of government responsibilities, outputting valid JSON. No explanatory text is allowed.
[0039] Example 1: User: Garbage has been piling up at the entrance of our community for a week and the stench is disturbing the residents. Who is responsible for this? Assistant: {"Complainant":{"Name":"Anonymous","Phone":null,"Address":"A Certain Residential Community"},"Respondent":[{"Name":"Local Subdistrict Office or Sanitation Department","Type":"Government Department"}],"Judgment of Scope of Responsibilities":{"Scope of Acceptance":"Within the scope of business","Confidence Level":"High","Basis for Judgment":"Household waste collection and transportation falls under the responsibilities of public services and should be transferred to the local sanitation department or subdistrict office for handling"}} Example 2: User: The noise and odor from the nighttime operation of the garbage transfer station in the urban village are alarming. Please provide a solution.
[0040] Assistant: {"Complainant":{"Name":"Anonymous","Phone":null,"Address":"A certain urban village"},"Respondent":[{"Name":"District Urban Management Bureau","Type":"Government Department"}],"Scope of Responsibilities Judgment":{"Scope of Acceptance":"Within the scope of business","Confidence Level":"Medium","Judgment Basis":"Management of garbage transfer stations falls under the responsibilities of the urban management department; noise and odor disturbances fall within the scope of business"}} Example 3: User: The trash cans on the roadside are overflowing and no one is cleaning them, which affects the appearance of the city.
[0041] Assistant: {"Complainant":{"Name":"Anonymous","Phone":null,"Address":"A Certain Road Section"},"Respondent":[{"Name":"District Sanitation Office","Type":"Public Institution"}],"Judgment of Scope of Responsibilities":{"Scope of Acceptance":"Within the scope of business","Confidence Level":"High","Judgment Basis":"Road sanitation and cleaning fall under the responsibilities of government public services"}} Current task: User: Please refer to the example above and output a structured JSON format result for the following work order. Do not output any other content. Work order text: I am a resident of XX community. There is a pile of garbage at the entrance of the community that has not been cleaned for a week, seriously affecting my life. Which department is responsible for this? Can it be handled as soon as possible? My phone number is 138****1234.
[0042] Step 302: Large Model Structure Extraction: Call GPT-4o, temperature=0.1, max_tokens=800, to obtain the model output text. Then, robust JSON parsing was performed: First, json.loads was tried directly, and it was found that the output contained prefixes and suffixes. So, regular expressions were used to extract the content from the first { to the last}, which was successfully parsed into a dictionary.
[0043] Step 303: Output Schema Forced Validation and Completion: Following the predefined JSON Schema, the "Applicant" field is mapped to the "Petitioner," and default values are provided for verification. In the model output, the "Petitioner" field contains an address, and the phone number is correctly extracted; the "Respondent" field is output as [{"Name":"Local Street Office or Sanitation Department","Type":"Government Department"}]; the "Scope of Responsibility Judgment" field is output as {"Scope of Acceptance":"Within the scope of business","Confidence Level":"High","Judgment Basis":"Household waste collection belongs to the responsibilities of government public services"}. Missing fields, such as "Name" for "Petitioner," are filled with an empty string, and "Gender," etc., are filled with null. Final standardized output. as follows: { "Petitioner":{"Name":"","Gender":null,"Date of Birth":null,"ID Number":null,"Address":"XX Community","Phone Number":"138****1234","Workplace":null}, "Respondent":[{"Name / Title":"Local Subdistrict Office or Sanitation Department","Type":"Government Department","Address":null}], "Scope of Responsibilities Assessment":{"Scope of Acceptance":"Within the scope of business","Confidence Level":"High","Basis for Assessment":"Household waste collection and transportation falls under the responsibilities of government public services"} }, Step 4: Closed-loop update of the knowledge graph and self-evolution of retrieval quality: Step 401: Confidence assessment of model output: Calculation Confidence level: Field fill ratio: The schema has a total of 15 fields, 9 of which are non-empty, so field_ratio = 9 / 15 = 0.6; Consistency of responsibility scope: Output the judgment "within the business scope", which is consistent with the default responsibility scope of the "Environmental Sanitation - Garbage Collection" category in the knowledge graph, rule_score=1.0; Output stability: The large model was called 3 times for the same work order, with a temperature of 0.1. The average Jaccard similarity of the three outputs in key fields such as the complainant's phone number, the complained party, and the scope of acceptance was calculated, and the stability was 0.95.
[0044] Set weights , , Therefore, conf = 0.2 × 0.6 + 0.5 × 1.0 + 0.3 × 0.95 = 0.12 + 0.5 + 0.285 = 0.905, which is higher than the high threshold. .
[0045] Step 402: Conflict detection and manual feedback trigger: Since conf=0.905>0.9 and there is no hard conflict, manual review is not triggered, and the automatic update process is directly initiated.
[0046] Step 403: Knowledge Graph Update Strategy: Adding a node: Creating a new example node Store the original text x and standardize the output. The timestamp and source fields are "model self-generated".
[0047] Vector index update: calculation Insert the FAISS index.
[0048] Graph relationship update: Establish the located_in relationship between the entity "XX Community" extracted from x and the existing "XX Street" node; establish the belongs_to relationship by extracting the category label "Environmental Sanitation - Garbage Collection" from the output; if the vector cosine similarity with the existing example "Example 1" is 0.93 > 0.90, then add a similar_to edge pointing to Example 1.
[0049] Redundancy management: Regularly perform deduplication and aging-out processes. The current sample library contains 20,315 entries, which is already exceeded. =20000, calculate the retention score for each example: , In the formula, Δt is the number of days since the last retrieval, hit_count is the number of times the model has been retrieved in the last 30 days, and avg_conf is the average confidence score of the model output when used. The 315 examples with the lowest scores are eliminated, and their corresponding graph relations and vectors are also deleted.
[0050] Step 5: Model Training and Deployment Phase, End-to-End Optimization and Adaptive Strategies: Includes optimization strategies for the offline training phase to continuously improve system performance. Step 501: End-to-end retrieval-extraction joint optimization framework: In monthly regular model fine-tuning, the sentence encoder... The entity recognition model and the large model are jointly optimized using reinforcement learning algorithms such as REINFORCE. The reward function is defined as the field-level accuracy of the final structured extraction. Simultaneously, the retrieval ranking loss (Pairwise Hinge Loss) is optimized with an interval m=0.1. After 10 epochs of training, the overall F1 score of the end-to-end model on the validation set improved from 0.82 to 0.86.
[0051] Step 502: Dynamic K-value Adaptive Adjustment: Train a small MLP controller Ψ, taking the first 8 principal components of the query vector and the skewness and kurtosis of the retrieval similarity distribution as input, and outputting discrete actions K∈{1,2,3,4,5}. Policy gradient training is used, with the reward being... After training, the controller tends to choose K=1 or 2 for work orders with simple and clear categories, and K=4 or 5 for fuzzy or sparse categories. The average K value drops from a fixed 3 to 2.4, while the overall F1 remains stable.
[0052] Step 503: Multi-granularity responsibility rule embedding: During the retrieval phase, responsibility rules related to the current work order category are simultaneously recalled. Two rules are obtained through rule vector retrieval: "Environmental sanitation in the community's public areas falls under the responsibility of the street office" and "Household waste collection should be responded to within 24 hours." These two rules are formatted as "Note: According to the 'XX City Environmental Sanitation Management Regulations,' [rule content]" and appended to the end of the system prompt. In the subsequent output of the large model, the judgment criteria field explicitly references the rule content, improving the rule compliance rate.
[0053] Example 3: The present invention also provides a government work order structure extraction device, including a knowledge graph construction module, a dual-path retrieval module, a structure extraction module, an update module, and an optimization module. The knowledge graph construction module builds a knowledge graph and vectorized index for government public services: it constructs a knowledge graph containing nodes for categories of livelihood matters, functional department nodes, responsibility boundary rule nodes, and typical work order example nodes, and generates semantic vectors for each example node and establishes a vector index; The dual-path retrieval module performs entity recognition on the input work order and performs dual-path few-sample retrieval: it performs entity recognition and category mapping on the input work order text, and uses graph relation matching and vector semantic similarity dual-path retrieval to dynamically recall the Top-K typical work order examples most relevant to the current work order and their corresponding structured extraction results to form a few-sample example set. The structured extraction module constructs adaptive few-sample prompts for structured extraction of the large model: it dynamically concatenates the retrieved K typical work order examples into the context window of the large model according to the dialogue format, constructs adaptive prompts containing system roles, example demonstrations and the current work order, drives the large model to generate structured output that conforms to the predefined JSONSchema, and completes the field extraction for judging the complainant, the complained object and the scope of government responsibilities. The update module updates the knowledge graph: Based on the output of the large model and human feedback, through confidence assessment and conflict detection mechanisms, structured extraction results with evaluation quality exceeding the threshold are added to the knowledge graph as new examples, and the vector indices and graph relationships are updated. The optimization module continuously improves retrieval quality: it utilizes joint training to optimize the retrieval and extraction process and dynamically adjusts the number of typical work order examples as needed for continuous optimization of retrieval quality.
[0054] The information interaction and execution of readable programs between the modules in the above-mentioned device are based on the same concept as the method embodiments of the present invention, and the specific details can be found in the descriptions in the method embodiments of the present invention, and will not be repeated here.
[0055] Similarly, the advantages of the device of the present invention are: By constructing a complete technical chain of "knowledge graph construction - dual-path dynamic retrieval - adaptive prompt construction - closed-loop continuous evolution", the structured knowledge graph and the idea of enhanced generation of few-shot retrieval (RAG) are creatively introduced into the structured extraction task of government work orders. This effectively solves the problems of insufficient coverage of diverse request types, inability to dynamically adapt to the boundaries of regional and departmental responsibilities, and inability of the example library to self-evolve by the traditional fixed few-shot method, and achieves a unity of high accuracy, strong generalization and low cost maintenance.
[0056] By introducing a dual-path retrieval mechanism combining "graph relationship matching + vector semantic similarity," the explicit structural relationships in the knowledge graph and the implicit semantic similarity of the text can be utilized simultaneously. This ensures that the retrieved examples match both in category and semantically, significantly improving the relevance of the examples to the current work order. Experiments show that the dual-path retrieval improves example matching accuracy by more than 20% compared to the single-path approach.
[0057] By designing a closed-loop update strategy based on confidence assessment and conflict detection, the method can automatically filter high-quality model outputs and feed them back to the knowledge graph. A redundancy management mechanism keeps the example library concise and efficient. This allows the example library to continuously optimize itself as business volume grows, and new types of requests can be quickly covered with minimal manual annotation, significantly reducing knowledge base maintenance costs.
[0058] By dynamically adjusting the K-value and embedding multi-granularity responsibility rules, the method achieves an intelligent balance between inference efficiency and accuracy, and enhances the business compliance of responsibility scope judgment.
[0059] It should be noted that not all steps and modules in the above processes and device structures are mandatory; some steps or modules may be omitted as needed. The execution order of the steps is not fixed and can be adjusted as required. The device structures described in the above embodiments can be physical or logical structures. That is, some modules may be implemented by the same physical entity, or some modules may be implemented by multiple physical entities, or they may be jointly implemented by certain components in multiple independent devices.
[0060] Example 4: The present invention also provides a government work order structure extraction device, comprising: at least one memory and at least one processor; The at least one memory is used to store a machine-readable program; The at least one processor is used to call the machine-readable program to execute the government work order structure extraction method.
[0061] The processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), off-the-shelf programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor can be a microprocessor or any conventional processor.
[0062] Memory is used to store computer programs and / or modules. The processor implements various functions of the electronic device by running or executing the computer programs and / or modules stored in the memory, and by accessing data stored in the memory. Memory can mainly include a program storage area and a data storage area. The program storage area can store the operating system, at least one application program required for a function, etc.; the data storage area can store data created based on the use of the terminal, etc. In addition, memory can also include high-speed random access memory, and can also include non-volatile memory, such as hard disks, RAM, plug-in hard disks, smart memory cards (SMC), secure digital cards (SD cards), flash memory cards, at least one disk storage device, flash memory devices, or other volatile solid-state storage devices.
[0063] The processes by which the processor in the aforementioned device performs information interaction and executes readable programs are based on the same concept as those in the embodiments of the present invention, and the specific details can be found in the descriptions in the embodiments of the present invention, and will not be repeated here.
[0064] Similarly, the advantages of the device of the present invention are: By constructing a complete technical chain of "knowledge graph construction - dual-path dynamic retrieval - adaptive prompt construction - closed-loop continuous evolution", the structured knowledge graph and the idea of enhanced generation of few-shot retrieval (RAG) are creatively introduced into the structured extraction task of government work orders. This effectively solves the problems of insufficient coverage of diverse request types, inability to dynamically adapt to the boundaries of regional and departmental responsibilities, and inability of the example library to self-evolve by the traditional fixed few-shot method, and achieves a unity of high accuracy, strong generalization and low cost maintenance.
[0065] By introducing a dual-path retrieval mechanism combining "graph relationship matching + vector semantic similarity," the explicit structural relationships in the knowledge graph and the implicit semantic similarity of the text can be utilized simultaneously. This ensures that the retrieved examples match both in category and semantically, significantly improving the relevance of the examples to the current work order. Experiments show that the dual-path retrieval improves example matching accuracy by more than 20% compared to the single-path approach.
[0066] By designing a closed-loop update strategy based on confidence assessment and conflict detection, the method can automatically filter high-quality model outputs and feed them back to the knowledge graph. A redundancy management mechanism keeps the example library concise and efficient. This allows the example library to continuously optimize itself as business volume grows, and new types of requests can be quickly covered with minimal manual annotation, significantly reducing knowledge base maintenance costs.
[0067] By dynamically adjusting the K-value and embedding multi-granularity responsibility rules, the method achieves an intelligent balance between inference efficiency and accuracy, and enhances the business compliance of responsibility scope judgment.
[0068] The above-described embodiments are merely preferred embodiments provided to fully illustrate the present invention, and the scope of protection of the present invention is not limited thereto. Equivalent substitutions or modifications made by those skilled in the art based on the present invention are all within the scope of protection of the present invention. The scope of protection of the present invention is defined by the claims.
Claims
1. A method for extracting structured government work orders, characterized by: include: Step 1: Construct a knowledge graph and vectorized index for government public services: Construct a knowledge graph that includes nodes for categories of public services, functional departments, responsibility boundary rules, and typical work order example nodes, and generate a semantic vector for each example node to establish a vector index; Step 2: Entity recognition of input work orders and dual-path few-shot retrieval: Entity recognition and category mapping are performed on the input work order text. Graph relation matching and vector semantic similarity are used for dual-path retrieval to dynamically recall the Top-K typical work order examples most relevant to the current work order and their corresponding structured extraction results, forming a few-shot example set. Specifically, it includes: Step 201: Entity Recognition and Category Mapping of Input Work Orders: For the input work order text, a lightweight Named Entity Recognition (NER) model is used to extract keywords related to public welfare matters, department names, and geographical entities. Fuzzy matching is then performed with public welfare matter category nodes and functional department nodes in the knowledge graph to obtain initial category labels and department labels. Step 202: Perform dual-path retrieval and recall: including graph relation retrieval and vector semantic retrieval. Graph relation retrieval obtains a set of associated typical work order example nodes in the knowledge graph based on the initial category and department labels. Vector semantic retrieval maps the input work order text into query vectors using the same sentence encoder, and retrieves the most similar typical work order example nodes from the vector index. After deduplicating the candidate sets from both paths, the results are ranked based on graph matching indicators, semantic similarity, and node graph centrality, and the Top-K examples are selected. Step 203: Perform deduplication and filtering of typical work order examples: Perform text-level deduplication on the retrieved typical work order examples and filter out typical work order examples that clearly conflict with the topic of the current work order. Step 3: Construct adaptive few-sample prompts and perform structured extraction for the large model: Dynamically concatenate the retrieved K typical work order examples into the context window of the large model according to the dialogue format, construct adaptive prompts containing system roles, example demonstrations and the current work order, drive the large model to generate structured output that conforms to the predefined JSONSchema, and complete the field extraction for judging the complainant, the complained object and the scope of government responsibilities. Specifically, it includes: Step 301: Construct an adaptive few-shot suggestion template: Define a suggestion template containing three parts: system role definition, dynamic few-shot demonstration, and the current work order request. The system role definition is fixed content. The dynamic few-shot demonstration concatenates each typical work order example retrieved in the following format: the original work order text and structured JSON. The entire suggestion context is dynamically generated based on the search results. Step 302: Perform large model structure extraction: Call the large model interface, set temperature parameters to ensure output stability, and obtain the model output text; then perform robust JSON parsing, attempting direct parsing, removing Markdown code block markers, and parsing after truncating from the first left curly brace to the last right curly brace. If all attempts fail, record the parsing failure flag. Step 303: Output Schema Forced Validation and Completion: Align the parsed JSON with the predefined target Schema, fill missing fields with null values or default values, attempt automatic type conversion for fields with mismatched types, and finally output a standardized structured result; Step 4: Update the knowledge graph: Based on the output of the large model and human feedback, through confidence assessment and conflict detection mechanisms, structured extraction results with evaluation quality higher than the threshold are added to the knowledge graph as new examples, and the vector indices and graph relationships are updated. Step 5: Continuously optimize retrieval quality: Utilize joint training to optimize the retrieval and extraction process, and dynamically adjust the number of typical work order examples as needed for continuous optimization of retrieval quality.
2. The method for extracting structured government work orders according to claim 1, characterized in that step 1 specifically includes: Step 101: Define Knowledge Graph Nodes and Relationships: Define nodes for categories of public welfare matters, functional departments, responsibility boundary rules, and typical work order examples; establish the attribution, processing, applicability, and similarity relationships between nodes. Step 102: Generate semantic vector indexes for knowledge graph nodes: For each typical work order example node, use a pre-trained sentence encoder to map the original text of the typical work order example into a semantic vector, and construct a vector index based on a hierarchical navigable small-world graph (HNSW) for the semantic vectors of all typical work order example nodes, which is used to calculate the cosine similarity of the query vector. Step 103: Perform graph relationship storage: Store the graph structure of the knowledge graph as an adjacency list, which is used to retrieve a set of typical work order example nodes associated with a certain category of livelihood matters or functional department nodes through graph queries.
3. The method for extracting structured government work orders according to claim 1, characterized in that: Step 4 specifically includes: Step 401: Calculate the confidence score of the model output: For the structured output of a large model, consider factors such as field fill rate, consistency between the output and the responsibility rules in the knowledge graph, and the stability of the output after multiple samplings. Step 402: Conflict Detection and Manual Feedback: If the confidence level is lower than the set threshold, or if the output result has a hard conflict with the responsibility boundary rules in the knowledge graph, the work order and model output are pushed to the manual review queue; the correct structured result after manual review is used as authentication data. Step 403: Create a knowledge graph update strategy: Add output results with confidence scores higher than the threshold or authentication results after manual review to the knowledge graph as new typical work order example nodes, and perform the following updates: create new typical work order example nodes and store the original text, structured results, timestamps, and sources; calculate semantic vectors and insert vector indexes; establish associations with existing public service category nodes and functional department nodes; add similarity relationships to typical work order examples with similarity scores exceeding the threshold; periodically perform example deduplication and aging elimination, eliminating examples with low contribution or that have expired.
4. The method for extracting structured government work orders according to claim 1, characterized in that: Step 5 specifically includes: Step 501: Perform end-to-end retrieval-extraction joint framework optimization: Treat the sentence encoder, entity recognition model, and large model as a framework that can be optimized as a whole, and perform joint training using reinforcement learning or approximate gradient propagation to maximize the accuracy of the final structured extraction and optimize the retrieval ranking loss. Step 502: Adaptive Dynamic Adjustment of K Value: Based on the quality of the current work order's retrieval results, the number K of typical work order examples used is dynamically adjusted through a lightweight controller network to achieve a balance between accuracy and computational overhead. Step 503: Embedding multi-granularity responsibility boundary rules: Encode the responsibility boundary rule nodes in the knowledge graph into vectors, recall relevant rule texts during the retrieval phase, and concatenate the rule texts as additional constraints into the prompt template to guide the large model to follow explicit rules when judging the scope of responsibility.
5. A structured extraction device for government work orders, characterized in that: It includes a knowledge graph construction module, a dual-path retrieval module, a structured extraction module, an update module, and an optimization module. The knowledge graph construction module builds a knowledge graph and vectorized index for government public services: it constructs a knowledge graph containing nodes for categories of livelihood matters, functional department nodes, responsibility boundary rule nodes, and typical work order example nodes, and generates semantic vectors for each example node and establishes a vector index; The dual-path retrieval module performs entity recognition on the input work order and conducts dual-path few-shot retrieval: it performs entity recognition and category mapping on the input work order text, and uses graph relation matching and vector semantic similarity dual-path retrieval to dynamically recall the Top-K most relevant typical work order examples and their corresponding structured extraction results, forming a few-shot example set; the specific execution of the dual-path retrieval module includes: Step 201: Entity Recognition and Category Mapping of Input Work Orders: For the input work order text, a lightweight Named Entity Recognition (NER) model is used to extract keywords related to public welfare matters, department names, and geographical entities. Fuzzy matching is then performed with public welfare matter category nodes and functional department nodes in the knowledge graph to obtain initial category labels and department labels. Step 202: Perform dual-path retrieval and recall: including graph relation retrieval and vector semantic retrieval. Graph relation retrieval obtains a set of associated typical work order example nodes in the knowledge graph based on the initial category and department labels. Vector semantic retrieval maps the input work order text into query vectors using the same sentence encoder, and retrieves the most similar typical work order example nodes from the vector index. After deduplicating the candidate sets from both paths, the results are ranked based on graph matching indicators, semantic similarity, and node graph centrality, and the Top-K examples are selected. Step 203: Perform deduplication and filtering of typical work order examples: Perform text-level deduplication on the retrieved typical work order examples and filter out typical work order examples that clearly conflict with the topic of the current work order. The structured extraction module constructs adaptive few-sample prompts for structured extraction of the large model: it dynamically concatenates the retrieved K typical work order examples into the context window of the large model according to the dialogue format, constructs adaptive prompts containing system roles, example demonstrations, and the current work order, drives the large model to generate structured output conforming to a predefined JSON Schema, and completes the extraction of fields for judging the complainant, the complained party, and the scope of government responsibilities; the specific execution of the structured extraction module includes: Step 301: Construct an adaptive few-shot suggestion template: Define a suggestion template containing three parts: system role definition, dynamic few-shot demonstration, and the current work order request. The system role definition is fixed content. The dynamic few-shot demonstration concatenates each typical work order example retrieved in the following format: the original work order text and structured JSON. The entire suggestion context is dynamically generated based on the search results. Step 302: Perform large model structure extraction: Call the large model interface, set temperature parameters to ensure output stability, and obtain the model output text; then perform robust JSON parsing, attempting direct parsing, removing Markdown code block markers, and parsing after truncating from the first left curly brace to the last right curly brace. If all attempts fail, record the parsing failure flag. Step 303: Output Schema Forced Validation and Completion: Align the parsed JSON with the predefined target Schema, fill missing fields with null values or default values, attempt automatic type conversion for fields with mismatched types, and finally output a standardized structured result; The update module updates the knowledge graph: Based on the output of the large model and human feedback, through confidence assessment and conflict detection mechanisms, structured extraction results with evaluation quality exceeding the threshold are added to the knowledge graph as new examples, and the vector indices and graph relationships are updated. The optimization module continuously improves retrieval quality: it utilizes joint training to optimize the retrieval and extraction process and dynamically adjusts the number of typical work order examples as needed for continuous optimization of retrieval quality.
6. A structured extraction device for government work orders, characterized in that: include: At least one memory and at least one processor; The at least one memory is used to store a machine-readable program; The at least one processor is configured to invoke the machine-readable program to execute the government work order structure extraction method according to any one of claims 1-4.
Citation Information
Patent Citations
Intelligent appeal question and answer large model construction method and device and medium
CN118708693A
Government affair file information extraction and question and answer method and device and medium
CN120687574A