Instrument construction intelligent recommendation system and method based on LangGraph, LLM and RAG

By using the intelligent recommendation system of LangGraph, LLM, and RAG, the problems of low efficiency and interpretation errors in manual operation during instrument construction have been solved. The system has achieved full-process automation, accurate classification and retrieval, and generated actionable construction recommendation texts, thereby improving construction quality and compliance.

CN121390757APending Publication Date: 2026-01-23HANGZHOU DIANZI UNIV
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511561301.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-29
Publication Date
2026-01-23

AI Technical Summary

Technical Problem

Existing technologies in instrument construction suffer from problems such as low efficiency of manual operation, large interpretation errors, poor knowledge transfer, inability of LLM to achieve process control, insufficient RAG retrieval accuracy, and lack of evaluation system, making it difficult to guarantee construction quality and compliance.

Method used

An intelligent recommendation system based on LangGraph, LLM, and RAG is adopted, including a user interaction module, a LangGraph task control module, a hybrid intelligent classification module, an enhanced RAG module, and an LLM recommendation generation module. Combined with a hierarchical decoupled architecture, multi-level classification strategies, and a comprehensive evaluation system, it achieves full-process automation, accurate classification and retrieval, and generation of actionable construction recommendation texts.

Benefits of technology

It has achieved full automation of instrument construction, reduced the labor intensity of personnel, improved the accuracy of classification and retrieval, and generated text directly guides on-site construction, ensuring the integrity and operability of the text, and supporting the flexible expansion of the system and long-term adaptation to engineering needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121390757A_ABST
    Figure CN121390757A_ABST
Patent Text Reader

Abstract

The invention is suitable for the technical field of industrial automation and artificial intelligence, and provides an instrument construction intelligent recommendation system and method based on LangGraph, LLM and RAG, the system comprises a user interaction module, a LangGraph task control module, a hybrid intelligent classification module, an enhanced RAG module, an LLM recommendation generation module and a comprehensive evaluation system; the method comprises the steps that an instrument list and an instruction uploaded by a user are obtained, a task execution graph is constructed through LangGraph, subtasks are decomposed, after instrument list data are analyzed, a multi-level mixed strategy is adopted to classify instruments, industry standards and historical documents are retrieved through enhanced RAG based on a classification result, and construction recommendation texts are generated in combination with LLM. And finally evaluating and optimizing through a comprehensive evaluation module. According to the method, automation and precision of instrument construction recommendation are realized, the engineering efficiency and compliance are improved, the labor cost is reduced, and the method has a good industrial popularization prospect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of industrial automation and artificial intelligence technology, specifically to an intelligent recommendation system and method for instrument construction based on LangGraph, LLM, and RAG. Background Technology

[0002] In industrial automation engineering, instrument installation is a crucial step in ensuring the stable operation of production systems. Traditional instrument installation relies on manual review of vast amounts of national standards, industry specifications, and design drawings to manually analyze instrument list information and develop construction plans. This process presents several problems: Firstly, manual operation leads to a large amount of repetitive labor, resulting in low efficiency and susceptibility to interpretation errors due to differences in personnel experience, affecting construction quality and compliance. Secondly, industry knowledge transfer depends on word-of-mouth, which is slow for new employees to learn and master the complex instrument classification rules and construction standards, making project progress susceptible to disruptions caused by staff turnover.

[0003] With the development of artificial intelligence technology, Large Language Modeling (LLM) and Retrieval Augmentation (RAG) technologies have shown potential in the field of text understanding and generation. However, existing technologies still have shortcomings when applied to instrument construction recommendations. First, traditional LLM applications are mostly stateless, single-step calls, which cannot achieve process control for complex tasks and are difficult to handle the entire chain of instrument construction tasks from data parsing, classification, retrieval to recommendation generation. Second, the retrieval accuracy of basic RAG technology is insufficient, and general retrieval strategies cannot adapt to the special characteristics of instrumentation-related professional terminology and standard clauses, easily leading to a mismatch between retrieval results and actual construction needs. Third, there is a lack of a professional evaluation system for instrument construction recommendation texts. Existing text evaluation indicators (such as BLEU and ROUGE) only focus on word overlap and cannot measure the on-site operability and engineering compliance of the recommended content, making it difficult to directly apply the generated results to actual projects.

[0004] Therefore, in view of the above situation, there is an urgent need to provide an intelligent recommendation system and method for instrument construction based on LangGraph, LLM and RAG to overcome the shortcomings in current practical applications. Summary of the Invention

[0005] The purpose of this invention is to provide an intelligent recommendation system and method for instrument construction based on LangGraph, LLM, and RAG, effectively solving the problems mentioned in the background art.

[0006] This invention is implemented as follows: an intelligent recommendation system for instrument construction based on LangGraph, LLM, and RAG, including a user interaction module, a LangGraph task control module, a hybrid intelligent classification module, an enhanced RAG module, an LLM recommendation generation module, and a comprehensive evaluation system; The user interaction module is used to receive the Excel format instrument list file and natural language commands uploaded by the user, and at the same time display the instrument classification statistics, construction recommendation text and comprehensive evaluation score to the user; The LangGraph task control module is used to construct a state graph containing 31 functional nodes and 61 edges to realize task planning, dynamic routing, reflective error handling and retries. The task planning generates a structured task list by parsing user instructions through LLM, the dynamic routing selects the execution path according to the task type, and the reflective error handling can identify the error type and location and trigger incremental retries. The hybrid intelligent classification module uses a multi-level classification strategy to classify instrument data. The LLM recommendation generation module is used to call the large language model, integrate the instrument list parsing data and the reference text output by the enhanced RAG module, and generate construction recommendation text containing installation location, installation method, required materials, personnel configuration, quality inspection points and standard clause references according to a predefined structure; The comprehensive evaluation system is used to score the construction recommendation text from three dimensions: content coverage, operability, and quality review.

[0007] As a further aspect of the present invention: the state diagram of the LangGraph task control module adopts a layered decoupled architecture, with the upper layer responsible for task planning and user interaction, the middle layer responsible for data processing and business logic, and the lower layer responsible for basic services and error recovery. Furthermore, the state graph supports full lifecycle state management of the agent, managing 38 core fields, each with semantic definition, atomic responsibility, and reserved space for expansion.

[0008] As a further aspect of the present invention: the predefined instrument types of the hybrid intelligent classification module include temperature instruments, pressure instruments, flow instruments, level instruments, regulating valves, and control devices; Furthermore, if neither the table-based structured classification nor the LLM intelligent classification can determine the instrument type, it will be marked as "unrecognizable".

[0009] As a further aspect of the present invention: the content coverage dimension of the comprehensive evaluation system adopts a three-layer judgment mechanism, namely L1 direct keyword matching, L2 alias / regular expression matching, and L3 semantic similarity fallback. Furthermore, the content coverage dimensions are weighted differently.

[0010] As a further aspect of the present invention: the enhanced RAG module includes a domain index library construction unit, a query keyword rewriting unit, a preliminary vector matching unit, and a reordering unit; The domain index library construction unit segments and extracts embedded representations from industry standard specification document paragraphs to construct a vector index. The query keyword rewriting unit generates multiple semantic variants based on the task intent parsed by LLM; The preliminary vector matching unit encodes the task content vector and then matches it with the similarity of the standard document vector library.

[0011] As a further aspect of the present invention: after the re-ranking unit initially recalls and coarsely ranks a batch of candidate segments using BM25, it then enters the re-ranking stage and obtains a score S1 through rule matching. Then, it uses a trained dual-tower Sentence-BERT to encode the query and candidate segments into semantic vectors respectively, and calculates the cosine similarity to obtain a fine-grained relevance score S2. S1 and S2 are weighted to obtain the final re-ranking score S. Finally, S is fused with the coarse ranking score after normalization using linear or learning-based methods, and the top-k′ is finally selected as the high-confidence context input to the LLM recommendation generation module.

[0012] As a further aspect of the present invention: in the quality review dimensions of the comprehensive evaluation system, the LLM-as-Judge technology reviews from four aspects: technical accuracy, clarity of expression, completeness, and usability; Self-consistency verification calculates the standard deviation by sampling and scoring multiple times. If the standard deviation is too large, the result is marked as unreliable. Furthermore, the quality review dimensions also integrate expert knowledge in the field of instrument installation.

[0013] This invention also provides an intelligent recommendation method for instrument installation based on LangGraph, LLM, and RAG, using the system described above. The method includes the following steps: S1. Obtain File and User Context: Receive the user-uploaded Excel format instrument list file and natural language commands through the user interaction module, extract the structured field information from the instrument list, and mark abnormal formats and missing items. S2. Constructing Task Planning and Execution Process: Based on user commands and instrument list information, the LangGraph task control module parses intent through LLM to generate a structured task list, constructs a state diagram containing subtask dependencies, and determines whether the task is a statistical data task or a construction recommendation generation task. S3. Extract and parse the input file: Call the data processing module to identify the format and extract fields of the instrument list file, identify the instrument name, specifications, location, model and quantity fields, and convert them into memory objects that can be called by the intelligent agent; S4. Generate instrument classification statistics: The hybrid intelligent classification module uses a multi-level classification strategy to classify the parsed instrument data, and performs statistics according to the dimensions of category, model and purpose, and outputs structured classification information; If step S2 is determined to be a statistical data task, the process ends after outputting the statistical results. If the task is a construction recommendation, proceed to step S5; S5. Based on the statistical results, the enhanced RAG module is used to re-rank and retrieve industry standards and historical documents to obtain recommendation criteria: The enhanced RAG module constructs search suggestions based on the classification information in step S4, calls the domain index library to perform semantic search, and outputs a set of reference text paragraphs after keyword rewriting, preliminary vector matching, rule filtering and re-ranking. S6. LLM generates construction recommendations: The LLM recommendation generation module calls the large language model, integrates the instrument information extracted in step S3 with the reference text output in step S5, and generates construction recommendation text according to a predefined structure. S7. The comprehensive evaluation system conducts a quality assessment of the generated recommended text: The comprehensive evaluation system scores the construction recommended text generated in step S6 from the dimensions of content coverage, operability, and quality review. If the score is greater than or equal to the preset threshold, output the construction recommendation text; If the score is less than the preset threshold, the reflection mechanism of the LangGraph task control module is triggered, and steps S5-S6 are re-executed until the score is greater than or equal to the preset threshold or the retry limit is reached.

[0014] As a further aspect of the present invention: In step S5, the specific process of enhanced RAG retrieval includes: S51: Domain index library construction. Based on the construction manual and industry standard documents, the paragraph is segmented using a segmentation method. The embedding model is used to extract the text embedding representation of each paragraph and store it in the FAISS vector index structure to build the domain index library. S52: Query keyword rewriting, LLM parses the classification information and user instruction intent of step S4, and generates multiple semantic variant query keywords containing elements such as instrument model, purpose and installation location; S53: Preliminary vector matching: Input the query keywords generated in step S52 into the embedded model vector encoding to obtain the query vector; Perform similarity matching in the FAISS vector index to obtain the Top-K preliminary candidate text paragraphs; S54: Re-ranking. After the initial candidate text segments from step S53 are initially recalled and coarsely ranked using BM25, they enter the re-ranking stage. After rule matching and scoring to obtain a score S1, the query and candidate segments are encoded into semantic vectors using a trained dual-tower Sentence-BERT. Cosine similarity is calculated to obtain a fine-grained relevance score S2. S1 and S2 are weighted to obtain the final re-ranking score S. Finally, S is fused with the coarse ranking score after normalization using linear or learning-based methods, and the top-k′ is selected as the reference text segment set. S55: Output reference text. Associate the set of reference text paragraphs obtained in step S54 with the corresponding standard document identifiers and output them to the LLM recommendation generation module.

[0015] As a further aspect of the present invention: In step S6, the specific process of generating construction recommendations using LLM includes: S61: Construct a recommended document skeleton. Based on the instrument type and construction scenario, call the predefined recommended document template to determine the document skeleton. S62: Integrate data and evidence, combine the instrument name, model, installation location, medium temperature, and pressure parameters extracted in step S3 with the standard clauses, installation process, and risk warning information in the reference text output in step S5, and construct an LLM input prompt template; S63: Call LLM to generate text, input the prompt template from step S62 into the large language model, set temperature parameters to control the determinism of the generated text, and generate a draft of construction recommendation text that conforms to industry terminology standards; S64: Structured cleaning removes redundant content from the initial draft of the construction recommendation text, adds missing fields, standardizes unit expressions, corrects terminology errors, and forms a standardized construction recommendation text. S65: Output construction recommendations. Associate the standardized construction recommendation text from step S64 with the instrument tag number and statistical classification information, and output it to the comprehensive evaluation system.

[0016] Compared with the prior art, the beneficial effects of the present invention are as follows: Full-process automation: LangGraph automates the entire process from dashboard list parsing, classification, standard retrieval to recommendation generation, replacing traditional manual operations and significantly reducing the workload of personnel.

[0017] Accurate Classification and Retrieval: The multi-level strategy of the hybrid intelligent classification module avoids misclassification, and the multi-rule reordering of the enhanced RAG module improves the accuracy of knowledge acquisition.

[0018] Recommended text is practical: The LLM recommendation generation module combines engineering templates with professional knowledge to generate texts that include specific installation steps, material lists, and standard references, which can directly guide on-site construction; the comprehensive evaluation module ensures the completeness, operability, and professionalism of the texts, reducing rework caused by defects in the solution.

[0019] The system is flexible and scalable: LangGraph's layered and decoupled architecture and full lifecycle state management support module upgrades (such as replacing with a new LLM model) and multi-task expansion (such as adding instrument maintenance recommendation functions); the enhanced RAG domain index library can be easily updated with new industry standards, ensuring that the system adapts to engineering needs in the long term. Attached Figure Description

[0020] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0021] Figure 1 This is a schematic diagram of the system of the present invention.

[0022] Figure 2 This is a schematic diagram of the reflection mechanism in this invention.

[0023] Figure 3 This is a flowchart illustrating the structure of the task planning function in this invention.

[0024] Figure 4 This is a basic working principle diagram of RAG.

[0025] Figure 5 The method flowchart of this invention is shown below. Detailed Implementation

[0026] The technical solution of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. 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.

[0027] The present invention will be further explained below with reference to specific embodiments.

[0028] Please see Figure 1 The instrument construction intelligent recommendation system based on LangGraph, LLM and RAG provided in this embodiment of the invention includes a user interaction module, a LangGraph task control module, a hybrid intelligent classification module, an enhanced RAG module, an LLM recommendation generation module and a comprehensive evaluation system; The user interaction module is used to receive the Excel format instrument list file and natural language commands uploaded by the user, and at the same time display the instrument classification statistics, construction recommendation text and comprehensive evaluation score to the user; The LangGraph task control module is used to construct a state graph containing 31 functional nodes and 61 edges, realizing task planning, dynamic routing, reflective error handling, and retries. Task planning generates a structured task list by parsing user commands through LLM. Dynamic routing selects the execution path according to the task type. Reflective error handling can identify the error type and location and trigger incremental retries. The state graph of the LangGraph task control module adopts a layered and decoupled architecture. The upper layer is responsible for task planning and user interaction, the middle layer is responsible for data processing and business logic, and the lower layer is responsible for basic services and error recovery. Furthermore, the state diagram supports full lifecycle state management of the agent, managing 38 core fields, each with semantic definition, atomic responsibility, and reserved space for expansion; The hybrid intelligent classification module uses a multi-level classification strategy to classify instrument data. Priority 1 is the table-structured classification, which uses regular expressions to identify the separate or merged category titles and number formats in the Excel table and establishes the correspondence between instrument items and categories. Priority 2 is LLM intelligent classification, which receives instrument model and specification information, determines the classification based on predefined instrument types, and only returns the specific type when it is determined, and returns "unrecognizable" when it is uncertain; the predefined instrument types of the hybrid intelligent classification module include temperature instruments, pressure instruments, flow instruments, level instruments, regulating valves and control devices; Furthermore, if neither the table-based structured classification nor the LLM intelligent classification can determine the instrument type, it will be marked as "unrecognizable".

[0029] The enhanced RAG module includes a domain index library construction unit, a query keyword rewriting unit, a preliminary vector matching unit, and a reordering unit; The domain index library construction unit segments and extracts embedded representations from industry standard specification document paragraphs to construct a vector index. The query keyword rewriting unit generates multiple semantic variants based on the task intent parsed by LLM; The preliminary vector matching unit encodes the task content vector and then matches it with the similarity of the standard document vector library.

[0030] After the re-ranking unit initially recalls and coarsely ranks a batch of candidate segments (such as the top-50 segments) using BM25, it then enters the re-ranking stage. After obtaining a score S1 through rule matching, it uses a trained dual-tower Sentence-BERT to encode the query and candidate segments into semantic vectors respectively, and calculates the cosine similarity to obtain a fine-grained relevance score S2. S1 and S2 are weighted to obtain the final re-ranking score S. Finally, S is fused with the normalized linear or learned score, and the smaller top-k′ (such as 5–20) is selected as the high-confidence context input to the LLM recommendation generation module. Among them, the standard adaptation rule prioritizes the retention of text segments that are consistent with the design task specification number; the scenario matching rule combines the pipeline medium type and the measurement point environment to exclude inapplicable solutions; the time validity rule prioritizes the retention of recommended cases from the past three years; the duplication elimination and content merging rule eliminates semantically duplicated text segments; and the structural integrity scoring rule scores based on four elements: material recommendation, installation method, risk warning, and standard source.

[0031] The LLM recommendation generation module is used to call the large language model, integrate the instrument list parsing data and the reference text output by the enhanced RAG module, and generate construction recommendation text containing installation location, installation method, required materials, personnel configuration, quality inspection points and standard clause references according to a predefined structure; The comprehensive evaluation system is used to score the construction recommendation text from three dimensions: content coverage, operability, and quality review. The operability dimension is evaluated from five aspects, including operation steps and tool requirements. The quality review dimension adopts LLM-as-Judge technology and performs self-consistency verification. The content coverage dimension of the comprehensive evaluation system adopts a three-layer judgment mechanism, which is L1 direct keyword matching, L2 alias / regular expression matching, and L3 semantic similarity fallback. Furthermore, the content coverage dimension adopts differentiated weights: core keywords × 5 points, optional keywords × 2 points, semantic hit is calculated with a weight of 50%, and the scoring formula is 100 - number of missing words × 10 points; In the operability dimension of the comprehensive evaluation system, the level of detail of the operation steps accounts for 25 points, the clarity of tool requirements accounts for 20 points, the time estimation accounts for 15 points, the staffing accounts for 20 points, and the quality checkpoints account for 20 points. Furthermore, the operability dimension also includes tool-step correspondence checks, on-site operability assessments, and safety element checks; Among them, the LLM-as-Judge technology in the quality review dimension is evaluated from four aspects: technical accuracy, clarity of expression, completeness, and usability, with 25 points for each aspect; Self-consistency verification calculates the standard deviation by sampling and scoring multiple times. If the standard deviation is too large, the result is marked as unreliable. Furthermore, the quality review dimensions also integrate expert knowledge in the field of instrument installation.

[0032] In this embodiment, the system has the following advantages: This system implements a complex state graph with 31 functional nodes and 61 edges, and realizes intelligent business processes through conditional routing. The entire intelligent agent architecture includes core modules such as task planning nodes, data processing links, RAG retrieval and recommendation generation, and reflective error handling and retries. Each node has a clear division of responsibilities, and information flow is realized through state transmission.

[0033] The system adopts a layered and decoupled architecture: the upper layer is responsible for task planning and user interaction, the middle layer is responsible for data processing and business logic, and the lower layer is responsible for basic services and error recovery. This design ensures the system's high cohesion and low coupling characteristics.

[0034] This invention also constructs the LangGraph framework used by the Agent, which can easily build a visual agent graph, that is, a logical graph including the agent's nodes and edges, such as... Figure 1 As shown, the intelligent agent possesses the following characteristics: It supports task planning and decision-making through large language models (LLM), guiding the agent to determine the execution path according to user instructions; A multi-path task scheduling mechanism is introduced to dynamically select the process based on the task type (such as whether file upload is required); It includes access control and feedback loop mechanisms, such as embedding sensitive operation authorization and result confirmation modules in the standard verification process; It supports user feedback and correction of the content generated by the intelligent agent, forming an iterative structure of "task planning - execution - feedback - replanning"; The structure incorporates LangGraph's state management mechanism, enabling each node's behavior to have context memory and exception handling capabilities.

[0035] Compared to traditional linear processes or stateless Prompt invocation methods, the agents built on LangGraph in this system offer greater interpretability and stability in task flow, state control, and response generation, making them adaptable to complex engineering application scenarios. The innovation lies in: Intelligent agent state diagram structured control: This invention enables modular decomposition of tasks, status management, and process visualization.

[0036] Each node has clear semantics and contextual memory capabilities, avoiding the "stateless" and "single-step call" problems in traditional LLM applications.

[0037] Supports task planning and dynamic routing: The system has LLM task planning capabilities, which can identify task intent based on user natural language requests and automatically construct a task list.

[0038] A conditional routing mechanism is introduced to enable adaptive selection of task execution paths (such as whether to upload files, whether the classification was successful, etc.), thereby enhancing the system's responsiveness.

[0039] Reflection and error retry mechanism: If an intelligent agent encounters an error during task execution, it will not terminate or simply report an error, but will instead enter a "reflection-judgment-retry" process.

[0040] It enables precise location of error types and locations, allows for incremental retries of failed nodes, and improves system robustness and fault tolerance.

[0041] The reflection module can review the initial output based on professional rules and guide LLM revisions, making the generated results more reliable.

[0042] The reflection mechanism enables the agent to reflect on its actions. When encountering an error, the LLM first considers the situation and then decides whether to skip, retry, or over. The system identifies the error type and the node where it occurred through an error recovery gateway, supporting precise retries to specific nodes. Retry strategies include various scenarios such as file extraction retries, data parsing retries, instrument classification retries, standard matching retries, and recommendation generation retries.

[0043] Technical features: Intelligent error identification: Automatically identifies error type and severity; Precise node location: Accurately pinpoint the specific node where the error occurred; Incremental retry strategy: Only re-execute failed nodes, retaining completed work; Retry count control: Prevent unlimited retries by setting a reasonable retry limit; Figure 2 This paper presents a simplified control flow diagram after introducing a reflection mechanism into the intelligent agent system. User requests are first processed by the initial response module (Responde), which generates an initial response and tool invocation suggestions. Subsequently, the reflection module (Revisor) analyzes and modifies the response, proposes improvements, and regenerates a better response. This process forms a self-optimizing closed loop of "generation-evaluation-correction," which helps improve the response quality and stability of the intelligent agent in complex tasks. The final improved result can trigger tool execution again or be directly returned to the user, thereby achieving high-quality task completion.

[0044] LLM Task Planning (Plan): Integrates LLM for intelligent task planning, enhancing user experience. The system parses user input through natural language processing, extracts file paths and analyzes intent, and creates a structured task plan. The LLM task planner can understand complex user needs and automatically decompose them into a sequence of executable subtasks.

[0045] Core competencies: Intent recognition: accurately understanding the user's analytical needs and goals; Parameter extraction: Automatically extracts key parameters such as file path and analysis type; Task orchestration: Arrange the execution order of tasks reasonably according to dependencies; Parameter passing: Ensures the correctness of data flow between tasks; Figure 3 This paper demonstrates the structural flow of task planning functionality within an intelligent agent system. After a user issues a request, the built-in planning module (Planner) parses the intent and generates a task list based on a Large Language Model (LLM). Each task represents an independently executable step, which is sequentially scheduled and executed by a single agent. During execution, the agent can invoke multiple external tools (Tool1, Tool2, etc.) to complete subtasks, forming an internal "execution-feedback-correction" loop as needed. After all subtasks are completed, the final result is aggregated and returned to the user. This structure enables the agent to autonomously decompose complex problems, execute steps sequentially, and complete complex engineering tasks through multi-tool collaboration, demonstrating good versatility and scalability.

[0046] Enhanced RAG search system: Basic RAG retrieval and generation: RAG is a "retrieval + generation" paradigm: first, relevant information is retrieved from an external knowledge base, and then a large language model (LLM) generates a response based on the retrieval results.

[0047] It uses "external facts" to fill the knowledge gaps in pure LLM and reduce the risk of illusion.

[0048] Typical process: ① User question → Text vectorization → Retrieve Top-K documents from the index; ② Combine the retrieved document fragments with the user's question to form a Prompt; ③ The LLM reads the Prompt and generates a response under the "Search Evidence" constraint; ④ (Optional) Return the answer along with the document source for easy tracing.

[0049] Basic advantages and limitations: Advantages: It does not rely on the model's internal knowledge when responding to "latest, specialized, or long-tail" questions; the knowledge base can be updated at any time.

[0050] Limitations: Insufficient recall: When the search hit rate is insufficient, LLMs will still have illusions even without evidence; Top-K coarse ranking: Simple similarity often ranks segments that "seem related but are actually unrelated" at the top; Lack of domain adaptation: General word segmentation and general embedding models are not good at recognizing professional terms; Unaligned evaluation: The retrieval-generation process lacks automatic measurement of whether it is "faithful"; Figure 4This is the basic working principle of RAG. The workflow of the RAG (Retrieval-Augmented Generation) system is mainly divided into three stages: Step 1: Build a vector index library; The system first inputs the original document (such as specification clauses, technical specifications, etc.) into the embedding model to generate semantic vectors.

[0051] These vectors are then stored in the vector index structure built by FAISS, forming a knowledge base (VectorStore) for efficient retrieval later.

[0052] Step 2: Query and Retrieval (QueryEncoding & DocumentRetrieval); When a user submits a query, the system converts it into a vector representation using the same embedding model.

[0053] Use FAISSindexSearch for efficient similarity matching to find the top k document paragraphs that are closest to the query.

[0054] This stage can be further refined as follows: 2a: Generate query vector; 2b: Find the nearest neighbor document in the vector index; 2c: Extract document content to form candidate contexts.

[0055] Step 3: Integrate with LLM to generate answers; The user's original question and the retrieved context paragraphs are combined, and additional prompts are added before being fed into a large language model (LLM, such as GPT-4) for knowledge-based generation, and the results are output.

[0056] Intelligent RAG retrieval algorithm: The enhanced RAG search engine is the core component of the system, employing a multi-layered architecture to achieve accurate standard clause retrieval. The system includes core modules such as a basic search engine, a glossary of instruments, and a semantic enhancer, utilizing various technical means to improve search performance.

[0057] Technical features: Multi-query Enhanced Retrieval: The system implements an advanced multi-query enhanced retrieval mechanism. First, the original query is expanded based on the instrument vocabulary to generate multiple related queries. Then, each enhanced query is retrieved, and the results are merged according to query weight. Finally, a comprehensive re-ranking algorithm optimizes the final result.

[0058] Reranking Algorithm: Reranking refers to the process of recalculating and rearranging candidate results using a more complex algorithm after the initial retrieval. Compared to the ordinary RAG technique, its process inserts the steps of obtaining the candidate set and re-scoring and sorting before returning the top k options. The system adopts a five-factor comprehensive scoring reranking strategy: Base score: the product of the original vector similarity and the query weight; Instrument type matching bonus: Additional points are awarded based on the relevance of the instrument type; Keyword overlap bonus: Calculates the degree of overlap between the query keywords and the document content; Content quality scoring: Quality is assessed based on document structure and technical terminology density; Irrelevant content penalty: Penalize content that is not relevant to the query; Semantic caching optimization: Document vector caching mechanism, saving an average of 80% GPU latency; Compared to the traditional "Top-K similarity" coarse ranking strategy, it effectively improves accuracy and domain adaptability (+25%).

[0059] Please see Figure 5 This invention also provides an intelligent recommendation method for instrument construction based on LangGraph, LLM, and RAG, using the system described above. The method includes the following steps: S1. Obtain File and User Context: Receive the user-uploaded Excel format instrument list file and natural language commands through the user interaction module, extract the structured field information from the instrument list, mark abnormal formats and missing items, and ensure the accuracy of data transmission to subsequent modules. S2. Constructing Task Planning and Execution Process: The LangGraph task control module, based on user commands and dashboard information, uses LLM to parse intent, decomposes user requests into executable subtasks, and represents the dependencies between tasks using a directed graph structure, clearly defining the execution order and branch decisions. The agent can plan two types of tasks: statistical data collection and generating construction recommendations; S3. Extract and parse the input file: Call the data processing module to identify the format and extract fields of the instrument list file, identify the instrument name, specifications, location, model and quantity fields, convert them into memory objects that can be called by the intelligent agent, and mark missing items or abnormal fields. S4. Generate instrument classification statistics: The hybrid intelligent classification module uses a multi-level classification strategy to classify the parsed instrument data, and performs statistics according to the dimensions of category, model and use, outputting structured classification information for subsequent recommendation logic condition judgment; If step S2 is determined to be a statistical data task, the process ends after outputting the statistical results. If the task is a construction recommendation, proceed to step S5; S5. Based on the statistical results, the enhanced RAG module is used to re-rank and retrieve industry standards and historical documents to obtain recommendation criteria: The enhanced RAG module constructs search suggestions based on the classification information in step S4, calls the domain index library to perform semantic search, and outputs a set of reference text paragraphs after keyword rewriting, preliminary vector matching, rule filtering and re-ranking. S6. LLM generates construction recommendations: The LLM recommendation generation module calls the large language model, integrates the instrument information extracted in step S3 with the reference text output in step S5, and generates construction recommendation text according to a predefined structure. The recommendation text includes structured content such as recommended materials, installation process, standard clause references, and precautions, which meets industry format requirements and has direct usability. S7. The comprehensive evaluation system assesses the quality of the generated recommended text: Independent of the generation process, it uses a self-developed comprehensive scoring system to evaluate the readability, accuracy, and compliance of the recommended text. The evaluation system includes three main categories of indicators: content coverage, operability, and standard compliance. Scores in each dimension are used to select high-quality text or suggest further optimization. If the score is greater than or equal to the preset threshold, output the construction recommendation text; If the score is less than the preset threshold, the reflection mechanism of the LangGraph task control module is triggered, and steps S5-S6 are re-executed until the score is greater than or equal to the preset threshold or the retry limit is reached.

[0060] In step S5, the specific process of enhanced RAG retrieval includes: S51: Domain index library construction. Based on the construction manual and industry standard documents, the paragraph is segmented using a segmentation method. The embedding model is used to extract the text embedding representation of each paragraph and store it in the FAISS vector index structure to build a domain index library to support efficient semantic retrieval. S52: Query keyword rewriting. The LLM parses the classification information and user instruction intent of step S4 to generate multiple semantic variant query keywords containing elements such as instrument model, purpose, and installation location. The recall capability is improved by keyword expansion, and the standard clause content is adapted to different expression forms. S53: Preliminary vector matching: Input the query keywords generated in step S52 into the embedded model vector encoding to obtain the query vector; Perform similarity matching in the FAISS vector index to obtain the Top-K preliminary candidate text paragraphs; S54: Re-ranking. After the initial candidate text segments from step S53 are initially recalled and coarsely ranked using BM25, they enter the re-ranking stage. After rule matching and scoring to obtain a score S1, the query and candidate segments are encoded into semantic vectors using a trained dual-tower Sentence-BERT. Cosine similarity is calculated to obtain a fine-grained relevance score S2. S1 and S2 are weighted to obtain the final re-ranking score S. Finally, S is fused with the coarse ranking score after normalization using linear or learning-based methods, and the top-k′ is selected as the reference text segment set. Alternatively, step S54 may include: Construct search suggestions and perform semantic encoding: Based on the statistical results of instrument categories, construct search suggestions containing elements such as model, purpose, installation location, and system to which they belong, and feed them into the encoding model for semantic vectorization processing to serve as search keyword suggestion word vectors.

[0061] Access the embedded document knowledge base of the enhanced RAG module: this knowledge base includes industry standards, historical recommended texts, and high-quality sample explanations. Vector similarity calculations are used to select document fragments most similar to the query suggestions as the candidate content set.

[0062] Extract key attributes from candidate segments: Extract structural information related to construction elements from the matched candidate segments, such as recommended material types, process procedures, and relevant specification clause numbers, to provide semantic features for subsequent judgment and ranking.

[0063] Rule-based filtering and re-ranking: Perform multi-dimensional rule-based filtering and re-ranking on the above candidate content, including but not limited to the following strategies: (1) Standard adaptation rules: Prioritize retaining text segments that are highly consistent with the specification numbers (such as GB / T, DL / T, etc.) involved in the current design task, and remove content that conflicts with the target scenario or is invalid; (2) Scenario matching rules: Combine the "pipeline medium type" and "measuring point environment" information in the context, and recommend different materials and installation methods to exclude inapplicable solutions; (3) Time validity rule: Prioritize retaining practical application cases within the last three years in the historical recommendation records, and reduce the weight of earlier texts; (4) Repetition elimination and content merging: Semantic repetition and similar wording of texts are eliminated, and only typical representatives are retained; (5) Structural integrity scoring: The text is scored and ranked according to whether it has four elements: material recommendation, installation method, risk warning and standard source.

[0064] The final output is a set of reordered text segments, which serves as the input prompt for the recommendation text generation module.

[0065] S55: Output reference text. Associate the set of reference text paragraphs obtained in step S54 with the corresponding standard document identifiers and output them to the LLM recommendation generation module.

[0066] In step S6, the specific process of generating construction recommendations using LLM includes: S61: Construct a recommended document skeleton. Based on the instrument type and construction scenario, call the predefined recommended document template to determine the document skeleton, including sections such as "Recommended Materials", "Installation Methods", "Precautions", and "Referenced Standards". S62: Integrate data and evidence, combine the instrument name, model, installation location, medium temperature, and pressure parameters extracted in step S3 with the standard clauses, installation process, and risk warning information in the reference text output in step S5, and construct an LLM input prompt template; S63: Call LLM to generate text, input the prompt template from step S62 into the large language model, set temperature parameters to control the determinism of the generated text, and generate a draft of construction recommendation text that conforms to industry terminology standards; S64: Structured cleaning removes redundant content from the initial draft of the construction recommendation text, adds missing fields, standardizes unit expressions, corrects terminology errors, and forms a standardized construction recommendation text. S65: Output construction recommendations. Associate the standardized construction recommendation text from step S64 with the instrument tag number and statistical classification information, and output it to the comprehensive evaluation system.

[0067] In this embodiment, the method aims to build an intelligent agent system for industrial automation scenarios, which can automatically parse and classify instrument information from the instrument list of the construction drawings of the design institute, and generate construction and installation recommendation text that meets the engineering requirements in combination with national standards and industry specifications.

[0068] This intelligent agent relies on LangGraph to control task flow, and combines large language models (LLM, such as GPT-4o) and enhanced RAG retrieval technology to achieve an intelligent task closed loop of "understanding-planning-execution-evaluation-optimization".

[0069] The core tasks of this intelligent agent include: Users can upload construction drawings and instrument lists in Excel format, and then analyze and plan tasks using natural language commands.

[0070] The system automatically identifies the instrument model, parameters, and type in the table, employing a hybrid classification mechanism that combines structured parsing, LLM classification, and rule-based fallback.

[0071] A knowledge base for instrument construction is established based on national standards and specifications (such as GB50093-2013), and high-precision retrieval is achieved using enhanced RAG technology.

[0072] LLM is used to generate recommended text for instrument installation with search support. The text includes the instrument installation method, required materials, personnel configuration, and key points for quality inspection.

[0073] A reflection mechanism and error retry strategy are introduced to support automatic text correction and task modification.

[0074] Establish a comprehensive evaluation system to score and provide feedback on the generated text from three aspects: content completeness, operability, and professional quality, so as to continuously optimize the output results.

[0075] Features of this system: LangGraph constructs multi-node state graphs with clear task paths, integrates reflection and planning functions, and supports dynamic workflows and anomaly recovery.

[0076] An innovative, comprehensive three-tier evaluation system ensures that the output text is both engineering-applicable and compliant with regulations.

[0077] The reordered enhanced RAG search effectively improves search accuracy and generated quality.

[0078] It supports efficient caching, GPU acceleration, and Docker deployment, and has practical implementation capabilities.

[0079] Intelligent agent full lifecycle state management: The system manages 38 core fields, covering all intermediate states of the task from input to output; each field has semantic definition, atomic responsibility and reserved space for expansion, which is conducive to future module upgrades and multi-task expansion.

[0080] Traditional instrument installation projects require manual review of design specifications, leading to repetitive work and insufficient knowledge transfer. This intelligent agent addresses these issues, serving as a smart assistant for instrument installation projects that integrates AI task planning, document retrieval, and natural language generation. It possesses significant practical engineering value and promising prospects for industry adoption.

[0081] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. An intelligent instrument construction recommendation system based on LangGraph, LLM and RAG, characterized in that, The user interaction module, the LangGraph task control module, the hybrid intelligent classification module, the enhanced RAG module, the LLM recommendation generation module, and the comprehensive evaluation system are included. The user interaction module is used for receiving an Excel format instrument list file and a natural language instruction uploaded by a user, and simultaneously displaying an instrument classification statistical result, a construction recommendation text, and a comprehensive evaluation score to the user. The LangGraph task control module is used for constructing a state diagram including 31 functional nodes and 61 edges, implementing task planning, dynamic routing, error reflection processing, and retrying, wherein the task planning generates a structured task list by analyzing a user instruction through an LLM, the dynamic routing selects an execution path according to a task type, and the error reflection processing can identify an error type and a position and trigger an incremental retry. The hybrid intelligent classification module adopts a multi-level classification strategy to classify instrument data. The LLM recommendation generation module is used for calling a large language model, fusing instrument list analysis data and a reference text output by the enhanced RAG module, and generating a construction recommendation text including an installation position, an installation method, required materials, personnel configuration, quality check points, and standard article references according to a predefined structure. The comprehensive evaluation system is used for scoring a construction recommendation text from three dimensions of content coverage, operability, and quality review.

2. The system of claim 1, wherein, The state diagram of the LangGraph task control module adopts a hierarchical decoupling architecture, the upper layer is responsible for task planning and user interaction, the middle layer is responsible for data processing and business logic, and the bottom layer is responsible for basic services and error recovery. The state diagram supports intelligent agent full life cycle state management, manages 38 core fields, and each field has semantic definition, atomic responsibility, and extension reservation space.

3. The system of claim 1, wherein, The predefined instrument types of the hybrid intelligent classification module include temperature instruments, pressure instruments, flow instruments, liquid level instruments, regulating valves, and control devices. When the table structured classification and the LLM intelligent classification cannot determine the instrument type, it is marked as "unidentified".

4. The system of claim 1, wherein, The content coverage dimension of the comprehensive evaluation system adopts a three-layer judgment mechanism, the three-layer judgment mechanism is L1 keyword direct matching, L2 alias / regular matching, and L3 semantic similarity bottom-up. The content coverage dimension adopts a differentiated weight.

5. The system of claim 1, wherein, The enhanced RAG module includes a domain index library construction unit, a query keyword rewriting unit, a preliminary vector matching unit, and a reordering unit. The domain index library construction unit divides and extracts embedded representations of paragraphs of industry standard specification documents to construct a vector index. The query keyword rewriting unit generates a plurality of semantic variants according to a task intention analyzed by the LLM. The preliminary vector matching unit matches the similarity of the vector coding of the task content and the vector library of the standard document after coding.

6. The system of claim 5, wherein, After the re-ranking unit initially recalls and coarsely ranks a batch of candidate segments using BM25, it then enters the re-ranking stage. After obtaining a score S1 through rule matching, it uses a trained dual-tower Sentence-BERT to encode the query and candidate segments into semantic vectors respectively, and calculates the cosine similarity to obtain a fine-grained relevance score S2. S1 and S2 are weighted to obtain the final re-ranking score S. Finally, S is fused with the normalized linear or learning-based score, and the top-k′ is selected as the high-confidence context input to the LLM recommendation generation module.

7. The system of claim 1, wherein, In the quality review dimensions of the comprehensive evaluation system, the LLM-as-Judge technology reviews the system from four aspects: technical accuracy, clarity of expression, completeness, and usability. Self-consistency verification calculates the standard deviation by sampling and scoring multiple times. If the standard deviation is too large, the result is marked as unreliable. Furthermore, the quality review dimensions also integrate expert knowledge in the field of instrument installation.

8. The intelligent instrument construction recommendation method based on LangGraph, LLM and RAG, using the system according to any one of claims 1-7, characterized in that, The method includes the following steps: S1. Obtain File and User Context: Receive the user-uploaded Excel format instrument list file and natural language commands through the user interaction module, extract the structured field information from the instrument list, and mark abnormal formats and missing items. S2. Constructing Task Planning and Execution Process: Based on user commands and instrument list information, the LangGraph task control module parses intent through LLM to generate a structured task list, constructs a state diagram containing subtask dependencies, and determines whether the task is a statistical data task or a construction recommendation generation task. S3. Extract and parse the input file: Call the data processing module to identify the format and extract fields of the instrument list file, identify the instrument name, specifications, location, model and quantity fields, and convert them into memory objects that can be called by the intelligent agent; S4. Generate instrument classification statistics: The hybrid intelligent classification module uses a multi-level classification strategy to classify the parsed instrument data, and performs statistics according to the dimensions of category, model and purpose, and outputs structured classification information; If step S2 is determined to be a statistical data task, the process ends after outputting the statistical results. If the task is a construction recommendation, proceed to step S5; S5. Based on the statistical results, the enhanced RAG module is used to re-rank and retrieve industry standards and historical documents to obtain recommendation criteria: The enhanced RAG module constructs search suggestions based on the classification information in step S4, calls the domain index library to perform semantic search, and outputs a set of reference text paragraphs after keyword rewriting, preliminary vector matching, rule filtering and re-ranking. S6. LLM generates construction recommendations: The LLM recommendation generation module calls the large language model, integrates the instrument information extracted in step S3 with the reference text output in step S5, and generates construction recommendation text according to a predefined structure. S7. The comprehensive evaluation system conducts a quality assessment of the generated recommended text: The comprehensive evaluation system scores the construction recommended text generated in step S6 from the dimensions of content coverage, operability, and quality review. If the score is greater than or equal to the preset threshold, output the construction recommendation text; If the score < preset threshold, trigger the reflection mechanism of LangGraph task control module, re-execute steps S5-S6 until the score ≥ preset threshold or reach the upper limit of retries.

9. The method of claim 8, wherein, In step S5, the specific process of enhanced RAG retrieval includes: S51: Domain index library construction, according to the construction manual and industry standard documents, use segmented method for paragraph segmentation, use embedded model to extract each text embedding representation, store in FAISS vector index structure, and construct domain index library; S52: Query keyword rewriting, LLM analyzes the classification information and user instruction intent of step S4, generates multiple semantic variant query keywords containing instrument model, purpose, and installation location elements; S53: Preliminary vector matching, input the query keywords generated in step S52 into the embedded model vector coding to obtain the query vector; Perform similarity matching in the FAISS vector index to obtain Top-K preliminary candidate text paragraphs; S54: Reordering, after BM25 first recall and coarse ranking of the preliminary candidate text paragraphs in step S53, then enter the reordering link, and after scoring by rule matching, encode the query and candidate segments into semantic vectors by the trained double-tower Sentence-BERT, calculate the cosine similarity to obtain the fine-grained relevance score S2; S1 and S2 are weighted to obtain the final reordering score S; finally, the normalized linear or learning fusion of S and the coarse ranking score is performed to finally select top-k' as the reference text paragraph set; S55: Output reference text, associate the reference text paragraph set obtained in step S54 with the corresponding standard document identifier, and output to the LLM recommendation generation module.

10. The method of claim 8, wherein, In step S6, the specific process of LLM generating construction recommendation includes: S61: Constructing a recommendation document skeleton, according to the instrument type and construction scene, calling the predefined recommendation document template to determine the document skeleton; S62: Fusion data and basis, fuse the instrument name, model, installation location, medium temperature, and pressure parameters extracted in step S3 with the standard clauses, installation process, and risk prompt information in the reference text output in step S5 to construct an LLM input prompt template; S63: Call LLM to generate text, input the prompt template of step S62 into the large language model, set the temperature parameter to control the certainty of generated text, and generate the initial draft of construction recommendation text conforming to industry terminology specifications; S64: Structured cleaning, remove redundant content, supplement missing fields, unify unit expression method, correct terminology errors, and form standardized construction recommendation text; S65: Output construction recommendation, associate the standardized construction recommendation text of step S64 with the instrument position number and statistical classification information, and output to the comprehensive evaluation system.

Citation Information

Cited By

  • Intelligent camping place recommendation system and method

    CN121636828A