Rail transit rule system automatic revision method and system based on knowledge base and LLM
By constructing a knowledge base and using Large Language Model (LLM) to automatically identify and process regulatory document slices, the problems of low revision efficiency and poor accuracy in existing technologies have been solved, enabling efficient and accurate automatic revision of rail transit regulations.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHENGDU YUNDA TECH CO LTD
- Filing Date
- 2026-03-05
- Publication Date
- 2026-05-05
AI Technical Summary
The revision of existing rail transit regulations is inefficient, with manual comparison being time-consuming, prone to omissions and erroneous changes, making it difficult to ensure the consistency and accuracy of revisions. Furthermore, the lack of knowledge association means that the revised content cannot be automatically located to the specific clauses in the original regulations knowledge base.
By constructing a knowledge base of rules and regulations, using Large Language Model (LLM) to identify and process document segments, and combining knowledge base retrieval technology, the system automatically identifies newly added, modified, and deleted content, and introduces an exception retry mechanism and output format verification to generate structured revision results.
It has automated and intelligentized the revision of rules and regulations, significantly reduced labor costs, improved the accuracy and efficiency of revisions, and ensured that the revised content accurately corresponds to the specific clauses of the original document.
Smart Images

Figure CN121766418B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of rail transit regulations revision technology, specifically to an automatic revision method and system for rail transit regulations based on a knowledge base and LLM. Background Technology
[0002] In the rail transit industry, regulations and systems serve as crucial bases for ensuring safe operation and standardizing work processes. They have the following characteristics: large volume and rapid updates, requiring frequent revisions due to technological upgrades, operational strategy adjustments, or changes in higher-level policies; high rigor requirements, as any error or omission in any clause could lead to safety hazards; and difficulty in version tracing, as traditional revision methods rely heavily on manual comparison and modification in editors such as Word, which is not only inefficient but also makes it difficult to record changes in a structured manner, resulting in difficulty in subsequent tracing.
[0003] Existing regulations and rules identification typically uses character-based comparison tools (such as the Diff algorithm) or simple keyword matching. These methods have significant drawbacks in the following aspects:
[0004] 1) The revision process is inefficient, and manual comparison is time-consuming. When the scale of rules and regulations is large, the cost of manual revision increases significantly.
[0005] 2) It is prone to omissions and erroneous modifications, making it difficult to guarantee the consistency and accuracy of revisions;
[0006] 3) Lack of knowledge association: It is impossible to automatically locate the modified content to the specific clause in the existing large regulatory knowledge base;
[0007] 4) Non-automated operation: After identifying the differences, manual deletion, insertion, or replacement operations are still required;
[0008] Therefore, there is an urgent need for a technical solution that can automatically identify the modification points in rules and regulations and complete the revision of rules and regulations, so as to improve the efficiency and reliability of revision. Summary of the Invention
[0009] The purpose of this invention is to overcome the shortcomings of the prior art and provide a method and system for automatic revision of rail transit regulations based on knowledge base and LLM.
[0010] The objective of this invention is achieved through the following technical solution:
[0011] Firstly, this application discloses a method for automatically revising rail transit regulations based on knowledge bases and LLM, including the following steps:
[0012] S1. Construct a rules and regulations knowledge base and record the rules and regulations knowledge base ID; parse the original document into plain text, and then divide the original document into multiple small slices according to clauses, paragraphs or semantic rules; vectorize the small slices, and then store them in the rules and regulations knowledge base, and record the original document ID and the small slice ID.
[0013] S2: Receive the revision object uploaded by the user, obtain the rules and regulations knowledge base ID and the original document ID corresponding to the original document selected by the user; parse the revision object into plain text, slice it according to the preset character length plus symbol rule, and obtain a first array containing multiple candidate paragraphs;
[0014] S3: Iterate through all candidate paragraphs in the first array. During the loop, input all candidate paragraphs in the first array into the first language model. The first language model identifies and extracts the paragraphs that need to be revised, generating the second array. If there is no content that needs to be revised in the candidate paragraphs, output "no modification". Filter out the candidate paragraphs that have no modification during the summary. Aggregate all the second arrays to obtain the set of content to be revised.
[0015] S4: Based on the knowledge base scope locked in step S2, perform vector retrieval on each piece of revision content in the set of content to be revised, and return the K first candidate sets most similar to the revised content; clean the data in all first candidate sets, retain the data consistent with the original document ID candidate content obtained in step S2, and obtain the second candidate set; standardize the data in the second candidate set to the format [paragraph ID]: [content], and obtain the third candidate set; input the third candidate set and the revised content in the set of content to be revised into the second language model, and generate the target revision result based on the preset prompt words; constrain the output format of all target revision results, and then aggregate all constrained target revision results to generate the third array;
[0016] S5: Automatically update and revise all target revision results in the third array based on preset document revision rules, and save them to the database.
[0017] Based on the first aspect, in step S1, if there are images in the original document, the images are stored as web page links.
[0018] Based on the first aspect, step S3 also introduces an abnormal retry mechanism to verify whether the second array returned by the first large language model is valid. If the returned second array is invalid, the large language model is triggered to retry and generate a new second array using the first large language model. The number of retries does not exceed the preset maximum limit.
[0019] Based on the first aspect, the output format of constraining all target revision results in step S4 specifically includes: the output format includes type, text, original document ID and paragraph ID, the type includes addition, modification and deletion, the text includes the original rule content and the modified content; if the type is deletion, the modified content is empty; if the type is addition, the paragraph ID is -1, otherwise it is the original document ID.
[0020] Based on the first aspect, the preset document revision rules mentioned in step S5 specifically include:
[0021] The criteria for determining modification include: the type is modification, the modified content is not equal to the original regulation content, and the original document ID and paragraph ID are correct;
[0022] The criteria for deletion include: the type is deletion, the original rule content is not empty, the modified content is empty, and the original document ID and paragraph ID are correct.
[0023] The newly added judgment rules include: the type is new, the original rule content is empty, the modified content is not empty, the original document ID is correct, and the paragraph ID is equal to -1.
[0024] Based on the first aspect, step S5 also includes a manual calibration and confirmation step, which specifically includes: manually calibrating all target revision results in the updated and revised third array, manually confirming whether revision is required, and if revision is confirmed, replacing the original content with the new content and saving it into the database.
[0025] Secondly, this application discloses an automatic revision system for rail transit regulations based on a knowledge base and LLM, used in the aforementioned automatic revision method for rail transit regulations based on a knowledge base and LLM, comprising:
[0026] The knowledge base construction module is used to complete the parsing, slicing, vectorization processing of the original document and the construction of the rules and regulations knowledge base, and associate the rules and regulations knowledge base ID, the original document ID and the small slice ID;
[0027] The document preprocessing module receives the revision object and the original document selection, performs parsing and slicing of the revision object, and generates the first array.
[0028] The change identification module is used to identify and extract all candidate paragraphs that need to be revised in the first array through the first language model, verify the legality of the results through the abnormal retry mechanism, and aggregate and generate a set of content to be revised.
[0029] The revised decision module is used to obtain a candidate set through vector retrieval, which, after screening and standardization, is input into the second language model to generate a third array according to a specified format.
[0030] The automatic execution module automatically updates and revises the target revision results in the third array according to the preset document revision rules, calibrates the revision results, and finally saves them into the database.
[0031] The beneficial effects of this invention are:
[0032] 1) This application solves the problem that traditional character comparison cannot understand "wording adjustment but semantic change" or "large-scale logical reorganization" by using large model recognition, thereby automating the revision process of rules and regulations and significantly reducing the cost of manual revision.
[0033] 2) This application can automatically identify the addition, modification and deletion of rules and regulations, reduce omissions and misjudgments, and at the same time, based on the retrieval mechanism of knowledge base ID and paragraph ID, it ensures that the revised content can accurately correspond to the specific clauses of the original document, thereby improving the accuracy and consistency of the revision.
[0034] 3) This application introduces an output format verification and retry mechanism, which solves the engineering problem of unstable generative AI output.
[0035] 4) This application requires no manual intervention from identification to final document generation, which greatly improves the efficiency of regulation revision and is particularly suitable for application scenarios in the rail transit field where regulations are large in scale and frequently updated. Attached Figure Description
[0036] Figure 1 This is a flowchart illustrating the automatic revision method for rail transit regulations based on knowledge base and LLM according to an embodiment of the present invention.
[0037] Figure 2 This is a schematic diagram of the automatic revision system for rail transit regulations based on knowledge base and LLM according to an embodiment of the present invention;
[0038] Figure 3 This is a schematic diagram of the automatic identification of modification points and abnormal retry logic in an embodiment of the present invention;
[0039] Figure 4 A logic diagram is generated for the knowledge base retrieval-based revision scheme of this invention. Detailed Implementation
[0040] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0041] This application discloses a method and system for automatically revising rail transit regulations based on a knowledge base and Large Language Model (LLM). By introducing a knowledge base and LLM technology, it accurately identifies semantic changes between old and new documents, automatically identifies newly added, modified, and deleted regulations, retrieves the changed content through knowledge base retrieval technology, compares the revised content with the original content, and automatically generates the revised regulations document content; thus completing the content revision. This achieves automation, intelligence, and structure in the revision process while ensuring high accuracy. A flowchart of the method is shown below. Figure 1 As shown, the specific steps include:
[0042] S1. Structured Construction of the Rules and Regulations Knowledge Base: Construct a rules and regulations knowledge base and record the rules and regulations knowledge base ID; parse the original document (previously published old rules and regulations documents, i.e., documents that need to be revised and adapted) into plain text, and then divide the original document into multiple small slices according to clauses, paragraphs or semantic rules; vectorize the small slices, and then store them in the rules and regulations knowledge base, and record the original document ID and the small slice ID;
[0043] S2: Receive the revised object (newly released modified document) uploaded by the user, obtain the rules and regulations knowledge base ID and original document ID corresponding to the original document selected by the user; parse the revised object into plain text, and slice it according to the preset character length (e.g., 5000 characters) plus symbols (e.g., period and other semantically clear symbols) to obtain the first array (array A) containing multiple candidate paragraphs (strings to be identified).
[0044] S3: Iterate through all candidate paragraphs in the first array. During the loop, input all candidate paragraphs in the first array into the first language model. The first language model identifies and extracts the paragraphs that need to be revised, generating the second array (array B). If there is no content that needs to be revised in the candidate paragraphs, output "no modification". Filter out the candidate paragraphs that need no modification during the summary. Aggregate all the second arrays to obtain the set of content to be revised (array C).
[0045] S4: Based on the knowledge base scope locked in step S2, perform vector retrieval on each piece of revision content in the set of content to be revised, and return the K first candidate sets most similar to the revision content; clean the data in all first candidate sets, retaining the data consistent with the original document ID candidate content obtained in step S2, to obtain the second candidate set. The purpose of cleaning is to ensure the correctness of the revised document, that is, the final revision must be the original document corresponding to the revision object; standardize the data in the second candidate set to the format [paragraph ID]: [content] to obtain the third candidate set; input the third candidate set and the revision content in the set of content to be revised into the second language model, and generate the target revision result based on the preset prompt words; constrain the output format of all target revision results, and then aggregate all constrained target revision results to generate the third array (array D).
[0046] S5: Automatically update and revise all target revision results in the third array based on preset document revision rules, and save them to the database. Generate a logic diagram based on the revision scheme retrieved from the knowledge base, as shown in the figure. Figure 4 As shown.
[0047] For example, in step S1, if there are images in the original document, the images are stored as web page links.
[0048] For example, the schematic diagram of automatic modification point identification and abnormal retry logic is as follows: Figure 3 As shown; Step S3 also introduces an abnormal retry mechanism to check whether the second array returned by the first large language model is valid. If the returned second array is invalid, the large language model is triggered to retry and generate a new second array using the first large language model. The number of retries does not exceed the preset maximum limit (default is 3). The purpose of the preset maximum limit is to prevent infinite loops.
[0049] For example, the output format of constraining all target revision results in step S4 specifically includes: the output format includes type, content, original document ID (document_id) and segment ID (segment_id), the type includes addition, modification and deletion, the content includes original rule content (old_content) and modified content (new_content), where if type is deletion, the modified content (new_content) is empty; if type is addition, the segment ID (segment_id) is -1, otherwise it is the original document ID (document_id).
[0050] For example, the preset prompt in step S4 determines whether it is an addition, modification, or deletion based on the provided revision content and candidate original paragraphs. If it is a modification, please indicate the corresponding original document ID (document_id) and content, and output the modified content; if it is a deletion, the modified content is empty; if it is an addition, the paragraph ID is -1.
[0051] For example, the third array mentioned in step S5 can retrieve the corresponding content from the database using the original document ID (document_id) and paragraph ID. The changes in content before and after revision can be compared using old_content and new_content. The type of revision is determined by type. The preset document revision rules specifically include:
[0052] The rules for determining modification include: the value of type is modified, old_content is not equal to new_content, and document_id and segment_id are correct;
[0053] The deletion criteria include: the value of type is "delete", old_content is not empty, new_content is empty, and document_id and segment_id are correct.
[0054] The new criteria include: the value of type is new, old_content is empty, new_content is not empty, document_id is correct, and segment_id is equal to -1.
[0055] For example, step S5 also includes a manual calibration and confirmation step, which specifically includes: manually calibrating all target revision results in the updated and revised third array, manually confirming whether a revision has been made, and if a revision is confirmed, replacing the original content with the new content and saving it into the database.
[0056] For example, this application discloses an automatic revision system for rail transit regulations based on a knowledge base and LLM, the structural diagram of which is shown below. Figure 2 As shown, the automatic revision method for rail transit regulations based on knowledge base and LLM, as described above, includes:
[0057] The knowledge base construction module is used to complete the parsing, slicing, vectorization processing of the original documents and the construction of the rules and regulations knowledge base, and associate the rules and regulations knowledge base ID, document ID and small slice ID;
[0058] The document preprocessing module receives the revision object and the original document selection, performs parsing and slicing of the revision object, and generates the first array.
[0059] The change identification module is used to identify and extract all candidate paragraphs that need to be revised in the first array through the first language model, verify the legality of the results through the abnormal retry mechanism, and aggregate and generate a set of content to be revised.
[0060] The revised decision module is used to obtain a candidate set through vector retrieval, which, after screening and standardization, is input into the second language model to generate a third array according to a specified format.
[0061] The automatic execution module automatically updates and revises the target revision results in the third array according to the preset document revision rules, calibrates the revision results, and finally saves them into the database.
[0062] For example, taking the revision of the "Rules for Train Operation Organization by EMU Drivers" as an example, the method described in this application specifically includes:
[0063] First, the existing "Rules for Train Operation by EMU Drivers" (Version V1.0) is initialized. The document is read, and the clause "Article 3.2.1 The driver must confirm the signal before the train starts." is identified. After the slice is added to the database, the knowledge base ID, document ID, and slice ID are recorded.
[0064] A user uploaded a new version of the document "Rules for Train Operation by High-Speed Train Drivers (Revised Version).docx", in which the corresponding content has been modified to: "The driver must confirm the status of signals and platform screen doors before the train starts." The document is read and split into parts based on 5000 characters and the special character period ".".
[0065] Each segmented document is input into the large model, and the combined output yields the final array that needs revision ["The driver must confirm the signal and platform screen door status before the train starts."].
[0066] The loop iterates through the array that needs revision. This example has only one modification point, so there's only one loop. Taking "The driver must confirm the signal and platform screen door status before the train starts" as input, it searches the knowledge base, recalling three candidate knowledge points: ["Content corresponding to document X", "Article 3.2.1 The driver must confirm the signal before the train starts.", "Content M corresponding to the EMU driver's operation rules"]. It then filters by document ID to obtain the candidate set ["Article 3.2.1 The driver must confirm the signal before the train starts.", "Content M corresponding to the EMU driver's operation rules"]. Using "The driver must confirm the signal and platform screen door status before the train starts" and the cleaned candidate set, along with the task prompt, as input, it calls the large model, ultimately returning the result requiring revision:
[0067] {"type": "Modified","content": {"old_content": "Article 3.2.1 The driver must confirm the signals before the train starts.","new_content": "Article 3.2.1 The driver must confirm the signals and platform screen door status before the train starts."},"document_id": "Original document ID","segment_id": "Original paragraph ID"}, combined output yields:
[0068] [{"type": "Modified","content": {"old_content": "Article 3.2.1 The driver must confirm the signals before the train starts.","new_content":"Article 3.2.1 The driver must confirm the signals and platform screen door status before the train starts."},"document_id": "Original document ID","segment_id": "Original paragraph ID"}];
[0069] Update the database or update it after manual calibration.
[0070] For example, this embodiment describes in detail how to handle the unstable output of a large model in the automatic identification of modification points in the step, corresponding to Figure 3 The retry loop logic, taking the processing of a 500-page "Emergency Plan Compilation Manual" as an example, first divides the document into multiple slices, and then starts the loop processing.
[0071] When processing the 5th slice, the large model did not return the modification points in array format as required, but instead returned the string "This section is mainly about traffic light maintenance, modification is recommended." The system's built-in data parser attempted to parse the returned result, but an error occurred. The system caught the exception, and the retry counter incremented from 0 to 1.
[0072] Trigger the retry logic, rebuild the prompt words in the large language model, and add the emphasis instruction: "Note: The previous answer was formatted incorrectly. The error message was 'This paragraph is mainly about traffic light maintenance, it is recommended to modify it.' Please be sure to strictly follow the required format for output and do not include any additional explanatory text." Then call the large model to generate again.
[0073] If the second response is successful, the system will merge the verified data into the total change array and continue processing the next segment. If the number of retries reaches the preset threshold (3 times) and still fails, the data will be skipped to avoid program blocking.
[0074] The above description is merely a preferred embodiment of the present invention. It should be understood that the present invention is not limited to the forms disclosed herein and should not be construed as excluding other embodiments. It can be used in various other combinations, modifications, and environments, and can be altered within the scope of the concept described herein through the above teachings or related technologies or knowledge. Modifications and variations made by those skilled in the art that do not depart from the spirit and scope of the present invention should be within the protection scope of the appended claims.
Claims
1. A method for automatically revising rail transit regulations based on knowledge base and LLM, characterized in that, Includes the following steps: S1. Construct a rules and regulations knowledge base and record the rules and regulations knowledge base ID; parse the original document into plain text, and then divide the original document into multiple small slices according to clauses, paragraphs or semantic rules; vectorize the small slices, and then store them in the rules and regulations knowledge base, and record the original document ID and the small slice ID. S2: Receive the revision object uploaded by the user, obtain the rules and regulations knowledge base ID and the original document ID corresponding to the original document selected by the user; parse the revision object into plain text, slice it according to the preset character length plus symbol rule, and obtain a first array containing multiple candidate paragraphs; S3: Loop through all candidate paragraphs in the first array. During the loop, input all candidate paragraphs in the first array into the first language model. The first language model identifies and extracts the paragraphs that need to be revised, and generates the second array. If there is no content that needs to be revised in the candidate paragraphs, then output "No modification". Filter out the candidate paragraphs with no modification during the summary. Aggregate all the second arrays to obtain the set of content to be revised. S4: Based on the knowledge base scope locked in step S2, perform vector retrieval on each revision content in the set of content to be revised, and return the K first candidate sets that are most similar to the revision content; clean the data in all first candidate sets, retain the data that is consistent with the original document ID candidate content obtained in step S2, and obtain the second candidate set; standardize the data in the second candidate set to the format of [paragraph ID]: [content], and obtain the third candidate set; input the third candidate set and the revision content in the set of content to be revised into the second language model, and generate the target revision result based on the preset prompt words; Constrain the output format of all target revision results, and then aggregate all constrained target revision results to generate a third array; S5: Automatically update and revise all target revision results in the third array based on preset document revision rules, and save them to the database.
2. The automatic revision method for rail transit regulations based on knowledge base and LLM as described in claim 1, characterized in that: In step S1, if the original document contains images, the images are stored as webpage links.
3. The automatic revision method for rail transit regulations based on knowledge base and LLM as described in claim 1, characterized in that: Step S3 also introduces an exception retry mechanism to verify whether the second array returned by the first large language model is valid. If the returned second array is invalid, the large language model is triggered to retry and generate a new second array using the first large language model. The number of retries shall not exceed the preset maximum limit.
4. The method for automatic revision of rail transit regulations based on knowledge base and LLM as described in claim 1, characterized in that, The output format for constraining all target revision results in step S4 specifically includes: the output format includes type, text, original document ID, and paragraph ID; the type includes addition, modification, and deletion; the text includes the original rule content and the modified content; if the type is deletion, the modified content is empty; if the type is addition, the paragraph ID is -1, otherwise it is the original document ID.
5. The automatic revision method for rail transit regulations based on knowledge base and LLM as described in claim 4, characterized in that, The preset document revision rules mentioned in step S5 specifically include: The criteria for determining modification include: the type is modification, the modified content is not equal to the original regulation content, and the original document ID and paragraph ID are correct; The criteria for deletion include: the type is deletion, the original rule content is not empty, the modified content is empty, and the original document ID and paragraph ID are correct. The newly added judgment rules include: the type is new, the original rule content is empty, the modified content is not empty, the original document ID is correct, and the paragraph ID is equal to -1.
6. The method for automatic revision of rail transit regulations based on knowledge base and LLM as described in claim 1, characterized in that, Step S5 also includes a manual calibration and confirmation step, which specifically includes: manually calibrating all target revision results in the updated and revised third array, manually confirming whether the revision is valid, and if the revision is confirmed, replacing the original content with the new content and saving it into the database.
7. An automatic revision system for rail transit regulations based on knowledge base and LLM, used in the automatic revision method for rail transit regulations based on knowledge base and LLM as described in any one of claims 1-6, characterized in that, include: The knowledge base construction module is used to complete the parsing, slicing, vectorization processing of the original document and the construction of the rules and regulations knowledge base, and associate the rules and regulations knowledge base ID, the original document ID and the small slice ID; The document preprocessing module receives the revision object and the original document selection, performs parsing and slicing of the revision object, and generates the first array. The change identification module is used to identify and extract all candidate paragraphs that need to be revised in the first array through the first language model, verify the legality of the results through the abnormal retry mechanism, and aggregate and generate a set of content to be revised. The revised decision module is used to obtain a candidate set through vector retrieval, and after screening and standardization, it is input into the second language model to generate a third array according to a specified format. The automatic execution module automatically updates and revises the target revision results in the third array according to the preset document revision rules, calibrates the revision results, and finally saves them into the database.
Citation Information
Patent Citations
Motor vehicle servicing integrated management and control method for power set servicing
CN119579153A
Document revision method, document revision device and storage medium
CN121435933A