A vehicle knowledge question and answer method based on a GraphRAG method and a computer device
Patent Information
- Application Number
- CN202511056838.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-30
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2045-07-30
AI Technical Summary
在车辆知识领域,功能模块间存在复杂的层次关系和交互关系,单纯依靠向量相似度难以捕捉这些结构化特征,导致检索效率低下,回答质量不佳
[0013]本发明实施例的基于GraphRAG方法的车辆知识问答方法具有以下技术效果:基于图结构检索增强生成(GraphRAG)的车辆知识问答系统及方法,应用莱顿(Leiden)社区检测算法进行知识组织,并通过多层次社区摘要和双路径知识融合机制,实现高效精准的知识检索与问答生成,为用户提供更加准确、全面且结构合理的车辆领域知识回答。
Smart Images

Figure CN120973882B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent generation technology for vehicle knowledge question answering, specifically to a vehicle knowledge question answering method and computer device based on the GraphRAG method. Background Technology
[0002] With the rapid development of intelligent connected vehicles, modern vehicles are equipped with increasingly complex functions and systems, leading to difficulties for users in understanding and operating them. Traditional vehicle user manuals are cumbersome and inconvenient to search; existing in-vehicle voice assistants, based on simple pattern matching or shallow semantic analysis, struggle to accurately understand complex user questions, especially multi-level queries related to vehicle functions. Retrieval Enhancement Generation (RAG) technology has made significant progress in the field of knowledge question answering, but existing RAG systems mostly employ vector retrieval methods, lacking a deep understanding of the inherent structure of knowledge. In the vehicle knowledge domain, complex hierarchical and interactive relationships exist between functional modules, and relying solely on vector similarity is insufficient to capture these structured features, resulting in low retrieval efficiency and poor answer quality. Existing question answering systems struggle to handle complex queries across functional modules and cannot organically connect related knowledge points, leading to fragmented and incomplete answers. Faced with massive amounts of vehicle knowledge documents, traditional vector retrieval methods struggle to quickly locate knowledge of appropriate granularity based on the abstract level of the query, resulting in low retrieval efficiency. Summary of the Invention
[0003] To address at least one of the aforementioned technical problems, embodiments of the present invention provide a vehicle knowledge question answering method based on the GraphRAG method, comprising: acquiring vehicle knowledge documents; constructing a document tree structure based on the title hierarchy of the vehicle knowledge documents; assigning text identifiers and adding metadata information to each text unit in the document tree structure; storing the text units in JSON format; converting the stored text units into text unit vectors using a vector embedding model; establishing a text vector index based on the type of the text units; converting the query text into a query vector using the same vector embedding model as the text units; calculating the similarity score between the query vector and the text unit vector; and determining the traditional RAG path text units based on the similarity score. Entity and relation types are defined and edge weights are assigned. A large language model is used to identify entities and entity relations in text units based on entity and relation types to generate a vehicle knowledge graph. The Leiden community detection algorithm is used to divide the vehicle knowledge graph into multi-level communities, generating hierarchical communities. Structured community summaries are generated based on each level of community, and the community summaries are converted into vector representations and a community summary vector index is established. The large language model is used to determine the query granularity level based on the query text, and the community summaries are retrieved and sorted according to the query granularity level to determine the GraphRAG path community summary. The community summaries of the GraphRAG path are fused with traditional RAG path text units to construct a complete context for the large language model to generate answers.
[0004] Preferably, the step of determining traditional RAG path text units based on similarity scores further includes: selecting a set of a predetermined number of text units at the front end of the relevance sequence as initial screening text units based on vector similarity scores; reordering the initial screening text units according to their metadata information; performing fine sorting using a cross-encoder model based on the semantic matching degree between the query intent and the text content of the initial screening text units; and selecting a predetermined number of text units at the front end of the sequence as traditional RAG path text units based on the fine sorting of the initial screening text units.
[0005] Preferably, the step of using a large language model to identify entities and entity relationships in text units based on entity type and relation type to generate a vehicle knowledge graph further includes: providing structured text of entity types to the large language model, where entity types include functions, components, control elements, operations, states, parameters, warnings, and faults; based on entity prompt information, using the structured text of entity types from the vehicle's text units using the large language model to identify entities and generate an entity list, where the entity list includes standardized entity descriptions and entity identifiers, and entity prompt information includes entity identification prompts, output prompts, and grouping prompts; providing relation types and edge weights to the large language model, where relation types include functional relations, component relations, function-component relations, operation relations, function-operation relations, and state-transition relations; and based on relation prompt information, using the large language model to extract entity relations from the entity list and text units, and recording the textual evidence and confidence of entity relations to generate a vehicle knowledge graph, where relation prompt information includes relation identification prompts, relation type prompts, relation textual evidence prompts, and relation strength prompts.
[0006] Preferably, the step of using the Leiden community detection algorithm to perform multi-level community division of the vehicle knowledge graph and generate hierarchical communities further includes: setting multi-level community resolution parameters, where the multi-level community resolution includes coarse-grained, medium-grained, and fine-grained levels; using the Leiden community detection algorithm to perform the hierarchical detection process recursively, performing community detection for each level using the corresponding resolution parameters, recording the current level community structure, and continuing to divide communities that reach a preset community size threshold into sub-communities to generate hierarchical vehicle knowledge communities.
[0007] Preferably, the step of generating structured community summaries based on each level of community further includes: based on the leaf-level community summary hints, using a large language model to sort the entities of each level of community according to the node centrality index and entity relationship weight, generating leaf-level community summaries, the leaf-level community summary hints include summary length hints and summary terminology hints; based on the high-level summary hints, merging leaf-level community summaries for each level of community respectively, when the total length is less than or equal to a preset marking range, directly merging the leaf-level community summaries to generate a high-level community summary, when the total length is greater than the preset marking range, sorting the sub-communities according to the number of nodes and node connection density, and generating a high-level community summary based on the sorted sub-communities.
[0008] Preferably, the steps of converting community summaries into vector representations and establishing a community summary vector index further include: using a text vector embedding model to generate semantic vector representations based on community summaries at all levels, while recording their hierarchical information and community IDs; constructing a multi-level hierarchical index structure, and using the HNSW algorithm for each level of the index structure and configuring community parameters.
[0009] Preferably, the step of using a large language model to determine the query granularity level based on the query text further includes: setting the query granularity level, which includes coarse-grained, medium-grained, and fine-grained granularity; and using the large language model to directly determine the query type and query granularity level based on the query prompt information through deep semantic understanding capabilities, with the query prompt information including level definition and granularity level examples.
[0010] Preferably, the steps of retrieving and sorting community summaries according to the query granularity level to determine the GraphRAG path community summaries include: retrieving community summaries of the corresponding level from the multi-level community structure according to the query granularity level; converting the query text into a vector representation, calculating the similarity between the vector representation of the query text and the community summary vector, performing initial screening based on the vector similarity, rearranging the community summaries according to the initial screening results in combination with edge weight information, performing semantic matching precision to fine-rank the rearranged community summaries based on semantic matching precision, and determining the GraphRAG path community summaries based on the semantic matching precision ranking.
[0011] Preferably, the step of fusing the community summary of the GraphRAG path with the text unit of the traditional RAG path to construct a complete context for the large language model to generate answers further includes: obtaining the text unit of the traditional RAG path and the community summary of the GraphRAG path; determining the priority of the text unit of the traditional RAG path and the community summary of the GraphRAG path according to the query granularity level; supplementing related knowledge points according to the connection relationship of related communities in the community summary of the GraphRAG path; and, based on the answer prompt information, structuring and marking the fused context, and generating answers using the large language model. The answer prompt information includes granularity level prompts, priority prompts, completion prompts, answer clue prompts, and important information prompts.
[0012] On the other hand, a computer device is provided, including a memory and a processor, the memory including computer program instructions, which are executed by the processor at runtime as described above for a vehicle knowledge question-answering method based on the GraphRAG method.
[0013] The vehicle knowledge question answering method based on the GraphRAG method in this invention has the following technical effects: The vehicle knowledge question answering system and method based on graph structure retrieval enhancement generation (GraphRAG) applies the Leiden community detection algorithm for knowledge organization, and achieves efficient and accurate knowledge retrieval and question answer generation through multi-level community summarization and dual-path knowledge fusion mechanism, providing users with more accurate, comprehensive and structurally reasonable vehicle domain knowledge answers.
[0014] Significantly improved retrieval accuracy and knowledge completeness: Traditional RAG systems rely solely on vector similarity for retrieval, often resulting in fragmented knowledge and a lack of relevance; the dual-path fusion architecture of this invention combines the detailed precision of traditional RAG with the structured perspective of GraphRAG, thereby improving retrieval accuracy while ensuring that the answer contains a complete and interconnected knowledge system.
[0015] Complex multi-level query processing capability: Existing in-vehicle question answering systems have difficulty handling complex queries across functional modules; this invention provides comprehensive and well-structured answers through community detection and multi-level summarization.
[0016] Deep utilization of inherent knowledge associations: Common knowledge systems cannot fully utilize the structural characteristics of vehicle knowledge; this invention effectively captures and utilizes the hierarchical and interactive relationships between functions through edge weight design and multi-level community detection, making the answers more consistent with the actual working logic of the vehicle system.
[0017] The burden of understanding for users is significantly reduced: Compared with traditional vehicle user manuals and existing question-and-answer systems, the answers provided by this invention not only include specific operational details, but also provide contextual background and system-level perspectives on related functions, enabling users to understand vehicle functions more comprehensively, reducing the learning curve and improving user experience. Attached Figure Description
[0018] To better understand the above and other objects, features, advantages, and functions of the present invention, reference can be made to the embodiments shown in the accompanying drawings. The same reference numerals in the drawings refer to the same parts. Those skilled in the art should understand that the drawings are intended to schematically illustrate preferred embodiments of the invention and do not limit the scope of the invention in any way; the parts in the drawings are not drawn to scale.
[0019] Figure 1 A flowchart illustrating a vehicle knowledge question-answering method based on the GraphRAG method according to an embodiment of the present invention is shown. Detailed Implementation
[0020] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0021] The term "comprising" and its variations as used herein signify open inclusion, i.e., "including but not limited to". Unless otherwise stated, the term "or" means "and / or". The term "based on" means "at least partially based on". The terms "one example embodiment" and "one embodiment" mean "at least one example embodiment". The term "another embodiment" means "at least one additional embodiment". The terms "first", "second", etc., may refer to different or the same objects. Other explicit and implicit definitions may also be included below.
[0022] To at least partially address one or more of the aforementioned problems and other potential issues, embodiments of this disclosure propose a vehicle knowledge question-answering method based on the GraphRAG method, comprising: step S1, obtaining a vehicle knowledge document, constructing a document tree structure based on the title hierarchy of the vehicle knowledge document, assigning text identifiers and adding metadata information to each text unit of the document tree structure, and storing the text units in JSON format. Specifically, this includes:
[0023] Step S11 involves acquiring various vehicle knowledge documents, including user manuals, function manuals, maintenance manuals, troubleshooting guides, vehicle system operation guides, and vehicle specification parameter tables. These documents (such as PDF and HTML) are then converted into plain text format while retaining necessary structural information, such as table content and chapter structure.
[0024] Step S12: Perform hierarchical segmentation based on the original document structure. Identify chapter titles and subheadings, and construct a document tree structure. Segment the document based on its original structure, identify chapter titles and subheadings, and construct a document tree structure according to the title hierarchy, using each smallest level chapter as the initial segmentation unit. Then, further segment the initial units according to semantic integrity and length constraints to ensure that each text unit is semantically self-contained and of appropriate length.
[0025] Step S13: Assign a unique identifier to each text unit, including document source identifier, chapter hierarchy path, sequence number, and content type tag. The unique identifier is, for example: VEH-UM-2023-S3.4.2-F-001, where the corresponding relationships are as follows: `VEH-UM-2023`: 2023 edition of the vehicle owner's manual; `S3.4.2`: Chapter 3, Section 4, Subsection 2; `F`: Functional description type; `001`: The first text unit in this section.
[0026] Step S14, simultaneously add metadata information, including: title information, parent chapter, related chapter references, content type (function description, operation guide, warning prompts, etc.), applicable vehicle models and versions, creation and update timestamps.
[0027] Step S15: Finally, the processed text units are stored in structured JSON format, preserving their hierarchical structure and metadata information to provide basic data for subsequent processing. An example is shown below:
[0028]
[0029] Step S21: The stored text units are converted into text unit vectors using a vector embedding model, and a text vector index is established according to the type of the text units.
[0030] Specifically, this step converts text units into vector representations and establishes an index. First, text vectorization is performed: a suitable text vector embedding model for the vehicle domain is selected, and vector embedding is generated for each text unit, preserving the mapping relationship between the unique identifier of the text unit and the vector, while retaining its original structural information and metadata. For long text units, a sliding window segmentation embedding method is used followed by merging to ensure the integrity of the semantic representation.
[0031] Secondly, use an efficient vector index structure (such as HNSW or IVF-PQ) to build the vector index, which supports fast nearest neighbor search. For example, when building a vector index using HNSW, the specific parameter settings are: -HNSW: set M=16 (maximum number of connections per node), efConstruction=200 (search depth during construction), ef=50 (search depth during query).
[0032] Next, specialized indexes are created: specialized indexes are built for different types of text content (operation guides, troubleshooting, parameter specifications, etc.) to improve retrieval accuracy and efficiency. Each specialized index uses the same basic model but applies different similarity calculation weights; for example, the operation guide index gives higher weight to words related to operation steps.
[0033] Step S22: Use the same vector embedding model as the text unit to convert the query text into a query vector, calculate the similarity score between the query vector and the text unit vector, and determine the traditional RAG path text unit based on the similarity score.
[0034] Specifically, the query text is encoded into semantic vectors using the same vector embedding model as the text units to achieve query vectorization, ensuring that the query vector and document vector reside in the same vector space. Cosine similarity and other measurement methods are used to calculate the similarity score between the query vector and the text unit vector. The steps for determining traditional RAG path text units based on similarity scores also include: a multi-step ranking strategy selecting a predetermined number of text units at the beginning of the relevance sequence as initial screening text units based on vector similarity scores; re-ranking based on the metadata information of the initial screening text units; fine-ranking using a cross-encoder model based on the semantic matching degree between the query intent and the text content of the initial screening text units; and selecting a predetermined number of text units at the beginning of the sequence as traditional RAG path text units based on the fine-ranking of the initial screening text units.
[0035] For example, the initial screening step is based on vector similarity calculations to initially select the top 50 most relevant text units as the initial screening text units. Then, the text units are re-ranked based on their metadata information (such as document type, chapter position, timestamp, etc.); finally, a semantic re-ranking strategy is applied to perform fine-grained ranking based on the semantic matching degree between query intent and text content. Semantic re-ranking uses a cross-encoder model to perform fine-grained ranking based on the semantic matching degree between query intent and text content, generating the final top 10 text unit set as the traditional RAG path text units.
[0036] Step S31: Define entity types and relation types, assign edge weights, and use a large language model to identify entities and entity relations of text units based on entity types and relation types to generate a vehicle knowledge graph.
[0037] Specifically, this step begins by designing the vehicle knowledge ontology, defining core entity types and relation types. For example, the defined entity types are as follows:
[0038]
[0039] Simultaneously, weights are assigned to edges of different relation types. For example, the functional hierarchy relation `has_subfunction` has a weight of 0.9, and the spatial location relation `located_at` has a weight of 0.5. These weights reflect the importance of edges in community formation. The defined relation types and corresponding edge weights are as follows:
[0040]
[0041] Then, based on a large language model, vehicle-related entities are extracted from text units. Using prompt templates specifically designed for the vehicle domain, the model is guided to identify different types of entities, and entity deduplication and merging are performed. Next, relationships between entities are extracted, and specialized prompt templates are designed to guide the model to identify implicit relationships in the text. The identified relationships are converted into triples of (head entity, relationship type, tail entity), ultimately constructing a complete vehicle knowledge graph.
[0042] In some embodiments, the step of using a large language model to identify entities and entity relationships of text units based on entity type and relationship type to generate a vehicle knowledge graph further includes: step S311, providing structured text of entity types to the large language model, where entity types include functions, components, control elements, operations, states, parameters, warnings, and faults.
[0043] Specifically, the institutionalization of entity types includes each entity type and its corresponding definition.
[0044] Step S312: Based on entity prompt information, the entity is identified from the text units of the vehicle using the structured text of the large language model according to the entity type, and an entity list is generated. The entity list includes standardized entity descriptions and entity identifiers. The entity prompt information includes entity recognition prompts, output prompts, and grouping prompts.
[0045] Specifically, the structured text containing the text units and entity types to be identified is input into the large language model through a preset prompt template. Entity prompts are then set to instruct the large language model to output the identified entities. The entity recognition prompt is "Please carefully analyze the text and identify all entities that match the above types," the output prompt is "Provide a brief description and unique identifier for each entity," and the grouping prompt is "Output results grouped by entity type." The entity extraction prompt template is as follows:
[0046] #Vehicle Knowledge Entity Extraction Task
[0047] ##Ontology Definition
[0048] The following are the entity type definitions in the vehicle knowledge domain:
[0049] - Function: The various functions provided by the vehicle, such as adaptive cruise control, automatic parking, etc.
[0050] - Component: The physical parts of a vehicle, such as the engine, transmission, sensors, etc.
[0051] - Control elements: User-operable control elements, such as buttons, switches, touchscreens, etc.
[0052] - Operation: The actions performed by the user, such as starting the engine or adjusting the seat.
[0053] - State: The state of a vehicle or system, such as startup state, fault state, etc.
[0054] - Parameters: Configurable parameters, such as cruise speed, air conditioning temperature, etc.
[0055] -Warning: Safety warnings and precautions
[0056] - Fault: Possible faults and their symptoms
[0057] ## Enter text
[0058] {Text Unit Content}
[0059] ## Extraction Requirements
[0060] 1. Please carefully analyze the text and identify all entities that match the above types.
[0061] 2. Provide a brief description and a unique identifier for each entity.
[0062] 3. Output results grouped by entity type.
[0063] The entity recognition results in JSON format output by the large language model are as follows:
[0064]
[0065] Step S313: Provide relation types and edge weights to the large language model. Relation types include functional relations, component relations, function-component relations, operation relations, function-operation relations, and state-transition relations.
[0066] Specifically, the prompt template of the large language model provides each relation type and its corresponding edge weight in a preset text structure.
[0067]
[0068] Step S314: Based on the relationship hint information, a large language model is used to extract entity relationships based on the entity list and text units, and the text evidence and confidence of the entity relationships are recorded to generate a vehicle knowledge graph. The relationship hint information includes relationship identification hints, relationship type hints, relationship text evidence hints, and relationship strength hints.
[0069] Specifically, the relationship hints are the extraction requirements set in the relationship extraction template. These include relationship identification hints such as "Extract the relationships between entities based on the provided text and identified entities," relationship type hints such as "Each relationship must use a predefined relationship type," relationship text evidence hints such as "Provide the location of text evidence for each relationship," and relationship strength hints such as "Extract only relationships explicitly stated or strongly implied in the text." The relationship identification results in JSON format output by the large language model are as follows:
[0070]
[0071] A two-stage extraction strategy based on a large language model is adopted, guided by a complete vehicle knowledge ontology, to achieve high-quality entity and relation extraction. First, in the entity extraction stage, a structured ontology defining entities is provided to the large language model, guiding the model to accurately identify various entities from vehicle text and generate standardized descriptions and unique identifiers for each entity. Then, in the relation extraction stage, based on a predefined relation ontology (and its weight settings), the identified entity list and the original text are input into the model to extract the structured relationships between entities, while simultaneously recording the textual evidence and confidence level of the relationships.
[0072] Step S32 involves using the Leiden community detection algorithm to perform multi-level community segmentation on the vehicle knowledge graph, generating hierarchical communities. Specifically, this includes: Step S321, setting multi-level community resolution parameters, where the multi-level community resolution includes coarse-grained, medium-grained, and fine-grained levels.
[0073] Multi-layered community detection is based on the Leiden algorithm, and the granularity of the community is controlled by adjusting the resolution parameters. The resolution parameter design and hierarchical division include: coarse-grained level (γ=0.5): division at the level of major vehicle systems (powertrain system, safety system, etc.); medium-grained level (γ=1.0): division at the level of subsystems (engine control system, air conditioning control system, etc.); fine-grained level (γ=2.0): division at the level of specific functional modules (adaptive cruise control, lane keeping assist, etc.).
[0074] Step S322: The Leiden community detection algorithm is used to perform a hierarchical detection process recursively. For each level, community detection is performed using the corresponding resolution parameters. The current level's community structure is recorded, and communities that reach a preset community size threshold are further divided into sub-communities to generate a hierarchical community for vehicle knowledge. The hierarchical detection algorithm process includes:
[0075]
[0076] This step applies the Leiden community detection algorithm to perform multi-level community partitioning of the vehicle knowledge graph. Multiple resolution parameters are set to generate community partitions of different granularities: coarse-grained level (resolution = 0.5) corresponds to the main system level of the vehicle; medium-grained level (resolution = 1.0) corresponds to the subsystem level; and fine-grained level (resolution = 2.0) corresponds to the specific functional module level. The hierarchical detection process is executed recursively, performing community detection at each level using the corresponding resolution parameters, recording the current level's community structure, and further partitioning communities that reach a certain size into sub-communities. During algorithm execution, the community structure is continuously optimized to ensure cohesion and modularity while maintaining connectivity within each community, ultimately forming a hierarchical vehicle knowledge community structure.
[0077] Step S33: Generate structured community summaries based on each level of community.
[0078] Specifically, step S331 involves generating leaf-level community summaries based on leaf-level community summary hints. The summaries are generated using a large language model, ranking entities within each hierarchical community according to their node centrality and entity relationship weights. The leaf-level community summary hints include summary length and vocabulary suggestions. An example of a large language model hint template for generating leaf-level community summaries is provided below.
[0079] ### Community Core Nodes (Sorted by Centrality):
[0080] 1. Adaptive Cruise Control (ACC): An advanced driver assistance system that automatically adjusts the vehicle speed to maintain a safe distance from the vehicle in front.
[0081] 2. Millimeter-wave radar sensor: Located in the center of the front bumper, used to detect the distance and relative speed of vehicles ahead.
[0082] 3. ACC control module: Electronic control unit that processes radar signals and controls the throttle and braking system.
[0083] 4. Safety distance setting: Allows the driver to select the time interval (1.0-2.5 seconds) to maintain distance from the vehicle in front.
[0084] 5. Cruise speed setting: Allows the driver to set the desired cruise speed (30-180km / h).
[0085] 6. Braking system interface: The connection interface between the ACC system and the vehicle's braking system.
[0086] 7. Instrument panel display: The interface on the instrument panel displays the ACC status, set speed, and distance.
[0087] 8. Steering wheel control buttons: Located on the right side of the steering wheel, these are buttons used to operate the ACC system.
[0088] 9. Follow-the-car mode: The ACC system follows the vehicle in front.
[0089] 10. Constant speed mode: The ACC system maintains the set speed when there is no vehicle in front.
[0090] 11. System limitations: Operating limitations of the ACC system, such as severe weather, sharp turns, etc.
[0091] 12. Driver Takeover Prompt: A warning to the driver to take over when the system is unable to handle the current situation.
[0092] ###Key Community Relationships (Sorted by Weight):
[0093] 1. [Adaptive cruise control] implemented by [millimeter-wave radar sensor] (weight: 0.8)
[0094] 2. [Adaptive Cruise Control] implemented by [ACC Control Module] (Weight: 0.8)
[0095] 3. [Adaptive Cruise Control] controls [Brake System Interface] (Weight: 0.6)
[0096] 4. [Adaptive Cruise Control] activated_by [Steering Wheel Control Buttons] (Weight: 0.7)
[0097] 5. [ACC Control Module] controls [Brake System Interface] (Weight: 0.6)
[0098] 6. [Safety Distance Settings] configured_by [Steering Wheel Control Buttons] (Weight: 0.6)
[0099] 7. [Cruise Speed Setting] configured_by [Steering Wheel Control Buttons] (Weight: 0.6)
[0100] 8. [Adaptive Cruise Control] transitions_to [Follow Mode] (Weight: 0.7)
[0101] 9. [Adaptive Cruise Control] transitions_to [Cruise Mode] (Weight: 0.7)
[0102] 10. [System Restriction] triggered_by [Driver Takeover Prompt] (Weight: 0.6)
[0103] Generate a community summary based on the provided community information. The summary should be clear, concise, and no longer than 500 words. Use technically accurate language that is understandable to the average driver.
[0104] Hierarchical community summary generation uses a large language model to generate structured summaries of communities at different granularities, achieving efficient knowledge organization and retrieval. Community summaries are systematically generated according to different levels, with each level's summaries having unique characteristics and being interconnected, forming a complete knowledge representation system.
[0105] Leaf-level community summary generation extracts and organizes key information from the smallest community unit of the knowledge graph using a structured approach. The leaf-level community summary prompts include, for example, a summary length prompt such as "The summary text should be clear and concise, with a total length controlled within 500 words," a summary language prompt such as "Use technically accurate but understandable language for ordinary drivers," and a summary generation prompt such as "Generate a community summary based on the provided community information."
[0106] First, entities within the community are prioritized based on their importance, primarily according to the node centrality metric. This prioritization ensures that the most influential and connected entities are included in the summary first. For example, in the adaptive cruise control community, core functional nodes (such as the ACC system itself) are prioritized over implementation components like sensors and control modules. Second, the system sorts relationships within the community in descending order of weight, prioritizing high-weight relationships. These relationships reflect important connections between entities; for instance, implementation relationships (implemented_by, weight 0.8) are prioritized over configuration relationships (configured_by, weight 0.6). This prioritization ensures that the summary captures the most critical interactions and dependencies between entities. Finally, the system sequentially populates the prioritized elements into a pre-defined community summary template until a predetermined tagging limit is reached (usually controlled within 500 characters).
[0107] This structured summary generation method ensures that leaf-level community summaries can efficiently capture and convey core knowledge within the community, providing a high-quality knowledge foundation for upper-level community summaries and final user question-and-answer sessions. In this way, the system can maximize the retention and delivery of key information within a limited tagging space, while maintaining the structure and comprehensibility of the information.
[0108] Step S332: Based on the high-level summary hint information, merge the leaf-level community summaries for each hierarchical community. When the total length is less than or equal to the preset mark range, directly merge the leaf-level community summaries to generate the high-level community summary. When the total length is greater than the preset mark range, sort the sub-communities according to the number of nodes and node connection density, and generate the high-level community summary based on the sub-community sorting. Hint template:
[0109] You are a vehicle knowledge expert system, responsible for integrating and synthesizing information. Please generate a high-level community summary based on the following sub-community summary information.
[0110] ### Subcommunity Summary Collection:
[0111] ##{Subcommunity 1 Summary}
[0112] ##{Subcommunity 2 Summary}
[0113] ##{Subcommunity 3 Summary} ...
[0115] ##Task Description
[0116] You need to generate a high-level community summary that summarizes the core content of the entire community while retaining the most important details.
[0117] The high-level community summary generation process employs two strategies to handle sub-community information integration. First, all sub-community summaries are directly merged. If their total length is within the tagging limit, these summaries are merged to generate a complete high-level overview. If the merged content exceeds the tagging limit, the system assesses and ranks the importance of each sub-community based on metrics such as sub-community size (number of nodes) and internal connection density. In the final output, the system prioritizes retaining the complete summary content of highly important sub-communities, while for less important sub-communities, only their core topic tags are retained, ensuring that the high-level summary maintains information richness without exceeding the length limit.
[0118] Step S34: Convert the community summary into a vector representation and establish a community summary vector index.
[0119] This step converts community summaries at all levels into vector representations and builds an index. First, a suitable text vector embedding model for the vehicle domain is selected to generate semantic vector representations for community summaries at all levels, while recording their hierarchical information and community IDs. Then, an efficient vector index structure is used to build a multi-level vector index, supporting fast nearest neighbor search. A hierarchical index structure is established to meet different granularity query needs: coarse-grained indexes correspond to system-level community summaries, medium-grained indexes correspond to subsystem-level community summaries, and fine-grained indexes correspond to functional module-level community summaries. Specifically, the steps of converting community summaries into vector representations and building a community summary vector index also include: step S341, using a text vector embedding model to generate semantic vector representations based on community summaries at all levels, while recording their hierarchical information and community IDs.
[0120] To address the specific characteristics of the vehicle domain, a vector embedding model is chosen to convert community summary text into a semantic representation in a high-dimensional vector space, ensuring that the vectors fully capture the semantic features of vehicle terminology and functional descriptions. Simultaneously, metadata is appended to each community summary vector, including a unique community identifier, a community hierarchy marker (hierarchical values corresponding to 0.5 / 1.0 / 2.0), the number of nodes contained, community topic tags, and a parent-child community relationship mapping.
[0121] Step S342: Construct a multi-level hierarchical index structure, and apply the HNSW algorithm to each level of the index structure and configure community parameters.
[0122] Specifically, in terms of index construction, a three-level hierarchical index structure is constructed: a system-level index (L1), a subsystem-level index (L2), and a functional module-level index (L3). Each level of the index is managed as an independent vector space. To improve retrieval performance, the HNSW (Hierarchical Navigable Small World Graph) algorithm is applied to each level of the index, and community parameters are configured for each level to adapt to different sizes of community sets. These community parameters include the number of connections (M value) and the efConstruction value. For example, the L1 index uses a smaller M value and a larger efConstruction value to optimize global navigation; the L2 and L3 indexes gradually increase the M value and decrease the efConstruction value to balance search accuracy and computational efficiency. The efConstruction value determines the size of the dynamic candidate list when adding new nodes. A higher efConstruction value indicates a more thorough connection establishment process, but it is slower. This parameter helps balance connection density, affecting search efficiency and accuracy.
[0123] A specialized quantification strategy is implemented to address the characteristics of vehicle knowledge, assigning weights to different dimensions to highlight dimensions representing safety features and core functions, thereby improving the retrieval accuracy of related queries. The index structure supports incremental updates, enabling efficient updates to the vector representations and index positions of affected communities when the knowledge graph and community structure change, maintaining the system's knowledge timeliness.
[0124] Step S35: Use a large language model to determine the query granularity level based on the query text.
[0125] Specifically, the steps of using a large language model to determine the query granularity level based on the query text also include: setting the query granularity level, which includes coarse-grained, medium-grained, and fine-grained; and using the large language model to directly determine the query type and granularity level based on the query prompt information through deep semantic understanding capabilities, with the query prompt information including level definitions and granularity level examples.
[0126] This step leverages a large language model to analyze the complexity and abstraction level of the user's query, determining the most suitable community level to answer it. A sample prompt is provided below:
[0127] As a vehicle technology query and analysis system, you need to determine the complexity level of the following query questions in order to provide answers with appropriate granularity.
[0128] Hierarchical definition:
[0129] 1. Coarse-grained: Conceptual, system-level questions, such as "What are the main systems in a car?"
[0130] 2. Medium-grained: Subsystem functional issues, such as "How does the ABS system work?"
[0131] 3. Fine-grained: Component-level, parameter-level, and technical details, such as "normal range of oxygen sensor voltage".
[0132] Example judgment:
[0133] -"What types of automotive safety systems are there?" → Coarse-grained (conceptual classification question)
[0134] -"What are the components of an engine cooling system?" → Medium-grained (specific system composition question)
[0135] -"What is the maximum bearing temperature of the turbocharger?" → Fine-grained (specific component parameter issue)
[0136] - "How to read fault codes using an OBD system?" → Medium-granularity (operational procedure issue)
[0137] -"What are the injection angle and number of nozzles for the fuel injector?" → Fine-grained (component specification issue)
[0138] Query question: "{{User query}}"
[0139] Please determine the hierarchy of this query and briefly explain your reasoning. Answer format:
[0140] Level: [Coarse-grained / Medium-grained / Fine-grained]
[0141] Step S36: Retrieve and sort the retrieved community summaries according to the query granularity level to determine the GraphRAG path community summaries.
[0142] Specifically, the steps for retrieving and sorting community summaries based on query granularity to determine GraphRAG path community summaries include: retrieving community summaries of the corresponding level from a multi-level community structure based on query granularity; converting the query text into a vector representation, calculating the similarity between the vector representation of the query text and the community summary vector, performing initial screening based on vector similarity, rearranging the community summaries based on edge weight information according to the initial screening results, performing semantic matching precision ranking on the rearranged community summaries, and determining the GraphRAG path community summaries based on the semantic matching precision ranking.
[0143] Hierarchical community summary retrieval and similarity calculation intelligently retrieves and ranks relevant community summaries based on the granularity of user queries. First, summaries of the corresponding level are selected from a multi-level community structure according to the query granularity: coarse-grained query retrieval system-level summaries (resolution 0.5), medium-grained query retrieval subsystem-level summaries (resolution 1.0), and fine-grained query retrieval functional module-level summaries (resolution 2.0). Simultaneously, neighboring and cross-community queries are considered to ensure comprehensive knowledge coverage. The retrieval process employs a three-step ranking strategy: initial screening based on vector similarity, re-ranking based on edge weight information, and final fine-ranking using semantic matching. This method not only adaptively selects the knowledge granularity according to the level of question abstraction but also provides complete and coherent information by considering the structured relationships between knowledge points. Ultimately, the set of community summaries with the highest similarity is selected as the knowledge foundation for the GraphRAG path, providing structured knowledge support for subsequent answer generation.
[0144] Step S4: The community summary of the GraphRAG path is fused with the text units of the traditional RAG path to construct a complete context for the large language model to generate answers.
[0145] Specifically, this step intelligently fuses community summary information from GraphRAG paths with text units from traditional RAG path retrieval to construct a complete context for the large language model to generate answers. In some embodiments, the prompt template is as follows:
[0146] System: You are a professional vehicle knowledge assistant, and you need to answer user questions based on the information provided below. Please ensure your answers are accurate, comprehensive, and logically structured.
[0147] User query: {user_query}
[0148] Query granularity level: {query_granularity_level}
[0149] #Possible values: coarse-grained (system-level concept), medium-grained (subsystem function), fine-grained (specific parameter or operation)
[0150] ## Community Knowledge Summary (GraphRAG Path)
[0151] {community_summaries}
[0152] #Includes hierarchical summaries of relevant communities, providing structured knowledge and a global perspective.
[0153] ## Detailed Text Knowledge (Traditional RAG Path)
[0154] {text_units}
[0155] #Contains the most relevant original text units, providing detailed specific knowledge.
[0156] ##Knowledge-related information
[0157] {knowledge_connections}
[0158] #Includes connections between related communities and supplements relevant knowledge points.
[0159] Answer requirements:
[0160] 1. Adjust the abstraction level of the answer based on the granularity of the query.
[0161] 2. For coarse-grained queries, prioritize using community summaries to provide a system-level overview.
[0162] 3. For fine-grained queries, prioritize using detailed text knowledge to provide specific information.
[0163] 4. Ensure your answer contains a complete and interconnected knowledge system.
[0164] 5. Provide context and system-level perspective for the functionality when necessary.
[0165] 6. Use a clear structure to organize your answers and highlight important information.
[0166] Based on the information above, please generate an accurate, comprehensive, and well-structured answer:
[0167] As shown in the example, the steps to fuse the community summary of the GraphRAG path with the text unit of the traditional RAG path to construct a complete context for the large language model to generate answers also include: obtaining the text unit of the traditional RAG path and the community summary of the GraphRAG path; determining the priority of the text unit of the traditional RAG path and the community summary of the GraphRAG path according to the query granularity level; supplementing related knowledge points according to the connection relationship of related communities in the community summary of the GraphRAG path; and, based on the answer prompt information, structuring and marking the fused context, and generating answers using the large language model. The answer prompt information includes granularity level prompts, priority prompts, completion prompts, answer clue prompts, and important information prompts.
[0168] As shown in the example, the answer prompts include: granularity level prompt "Adjust the level of abstraction of the answer according to the granularity of the query", priority prompt "For coarse-grained queries, prioritize the use of community summaries to provide a system-level overview; for fine-grained queries, prioritize the use of detailed text knowledge to provide specific information", completion prompt "Ensure that the answer contains a complete and interconnected knowledge system", answer clue prompt "Provide the context and system-level perspective of the function when necessary", and important information prompt "Organize the answer with a clear structure and highlight important information".
[0169] This step extracts the most relevant text units from the traditional RAG path, providing detailed raw knowledge. Simultaneously, it introduces the most similar community summaries from the GraphRAG path, offering structured knowledge background and a global perspective. The system employs an adaptive fusion strategy: for queries requiring a global perspective, the weight of community summaries in the context is increased; for queries requiring specific details, the weight of text units in the context is increased. Furthermore, the system supplements related knowledge points based on the connections between communities, ensuring the completeness of the answer. Finally, the fused context is structured and labeled, highlighting important information to guide the large language model in generating accurate, comprehensive, and logically structured answers that meet the user's knowledge needs.
[0170] On the other hand, a computer device is provided, including a memory and a processor, the memory including computer program instructions, which are executed by the processor at runtime as described above for a vehicle knowledge question-answering method based on the GraphRAG method.
[0171] Specifically, the computer device can be an electronic computer, and the computer program instructions in the memory include multiple functional modules. Each module includes multiple units, and each module and unit independently or jointly completes the vehicle knowledge question answering method based on the GraphRAG method as described above.
[0172] For example, multiple functional modules include a structured text module, a traditional RAG module, a GraphRAG module, and a fusion module.
[0173] The structured text module is used to obtain vehicle knowledge documents. It constructs a document tree structure based on the title hierarchy of the vehicle knowledge documents, assigns text identifiers and adds metadata information to each text unit in the document tree structure, and stores the text units in JSON format.
[0174] The traditional RAG module uses a vector embedding model to convert stored text units into text unit vectors and builds a text vector index based on the type of text unit. The same vector embedding model as the text unit is used to convert query text into query vectors, calculate the similarity score between the query vector and the text unit vector, and determine the traditional RAG path text unit based on the similarity score.
[0175] The GraphRAG and fusion modules define entity and relation types and assign edge weights. A large language model is used to identify entities and entity relations in text units based on entity and relation types to generate a vehicle knowledge graph. The Leiden community detection algorithm is used to perform multi-level community partitioning of the vehicle knowledge graph, generating hierarchical communities. Structured community summaries are generated based on each level of community, and the community summaries are converted into vector representations and a community summary vector index is established. The large language model determines the query granularity level based on the query text, and the community summaries are retrieved and sorted according to the query granularity level to determine the GraphRAG path community summary.
[0176] The fusion module is used to merge the community summary of the GraphRAG path with the text units of the traditional RAG path to build a complete context for the large language model to generate answers.
[0177] The various embodiments of this disclosure have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or technical improvements to the embodiments in the market, or to enable others skilled in the art to understand this document.
Claims
1. A vehicle knowledge question answering method based on the GraphRAG method, characterized in that, include: The system retrieves vehicle knowledge documents, constructs a document tree structure based on the title hierarchy of the vehicle knowledge documents, assigns text identifiers and adds metadata information to each text unit in the document tree structure, and stores the text units in JSON format. The stored text units are converted into text unit vectors using a vector embedding model, and a text vector index is built according to the type of the text unit. The query text is transformed into a query vector using the same vector embedding model as the text unit. The similarity score between the query vector and the text unit vector is calculated, and the traditional RAG path text unit is determined based on the similarity score. Define entity types and relation types, assign edge weights, and use a large language model to identify entities and entity relations in text units to generate a vehicle knowledge graph. This includes: providing structured text of entity types to the large language model, including functions, components, control elements, operations, states, parameters, warnings, and faults; based on entity prompts, using the large language model to identify entities from vehicle text units according to the structured text of entity types and generating an entity list, including standardized entity descriptions and entity identifiers, and entity prompts including entity recognition prompts, output prompts, and grouping prompts; providing relation types and edge weights to the large language model, including functional relations, component relations, function-component relations, operation relations, function-operation relations, and state-transition relations; and based on relation prompts, using the large language model to extract entity relations from the entity list and text units, and recording textual evidence and confidence levels of entity relations to generate a vehicle knowledge graph, with relation prompts including relation recognition prompts, relation type prompts, relation textual evidence prompts, and relation strength prompts. The Leiden community detection algorithm is used to divide the vehicle knowledge graph into multi-level communities, generate hierarchical communities, generate structured community summaries based on each level of community, convert the community summaries into vector representations, and establish a community summary vector index. A large language model is used to determine the query granularity level based on the query text, and the retrieval community summaries are sorted and retrieved according to the query granularity level to determine the GraphRAG path community summaries; This method integrates community summaries of GraphRAG paths with text units of traditional RAG paths to construct a complete context for a large language model to generate answers. This process includes: obtaining text units of traditional RAG paths and community summaries of GraphRAG paths; determining the priority of traditional RAG path text units and community summaries of GraphRAG paths based on query granularity; supplementing related knowledge points based on the connections between relevant communities in the GraphRAG path community summaries; and, based on answer prompts, structuring and labeling the integrated context, and generating answers using a large language model. Answer prompts include granularity level prompts, priority prompts, completion prompts, answer clue prompts, and important information prompts.
2. The vehicle knowledge question answering method based on the GraphRAG method according to claim 1, characterized in that, The steps for determining traditional RAG path text units based on similarity scores also include: Based on vector similarity scores, a set of a predetermined number of text units at the front end of the relevant sequence is selected as the initial screened text units. Reorder the texts based on the metadata information of the initially screened text units; A cross-encoder model is used to perform fine sorting based on the semantic matching degree of the query intent and the text content of the initially screened text units; Based on the fine sorting of the initial screened text units, a preset number of text units at the beginning of the sequence are selected as traditional RAG path text units.
3. The vehicle knowledge question answering method based on the GraphRAG method according to claim 2, characterized in that, The Leiden community detection algorithm is used to divide the vehicle knowledge graph into multi-level communities. The steps for generating hierarchical communities also include: Set multi-level community resolution parameters, which include coarse-grained, medium-grained, and fine-grained levels; The Leiden community detection algorithm is used to perform a hierarchical detection process recursively. For each level, community detection is performed using the corresponding resolution parameters. The current level community structure is recorded, and communities that reach the preset community size threshold are further divided into sub-communities to generate vehicle knowledge hierarchical communities.
4. The vehicle knowledge question answering method based on the GraphRAG method according to claim 3, characterized in that, The steps for generating structured community summaries based on each level of community also include: Based on the leaf-level community summary prompts, a large language model is used to sort the entities of each level of community according to the node centrality index and the entity relationship weight, and to generate leaf-level community summaries. The leaf-level community summary prompts include summary length prompts and summary term prompts. Based on the high-level summary prompts, leaf-level community summaries are merged for each level of community. When the total length is less than or equal to the preset mark range, the leaf-level community summaries are directly merged to generate the high-level community summary. When the total length is greater than the preset mark range, the sub-communities are sorted according to the number of nodes and node connection density, and the high-level community summary is generated according to the sorted sub-communities.
5. The vehicle knowledge question answering method based on the GraphRAG method according to claim 4, characterized in that, The steps of converting community summaries into vector representations and building a community summary vector index also include: A text vector embedding model is used to generate semantic vector representations based on community summaries at all levels, while recording their hierarchical information and community IDs; Construct a multi-level hierarchical index structure, and use the HNSW algorithm for each level of the index structure and configure community parameters.
6. The vehicle knowledge question answering method based on the GraphRAG method according to claim 4, characterized in that, The steps of using a large language model to determine the query granularity level based on the query text also include: Set the query granularity level, which includes coarse-grained, medium-grained, and fine-grained. Based on the query hints, a large language model is used to directly determine the query type and query granularity level by leveraging deep semantic understanding capabilities. The query hints include the level definition and granularity level examples.
7. The vehicle knowledge question answering method based on the GraphRAG method according to claim 4, characterized in that, The steps for retrieving and sorting community summaries based on query granularity to determine GraphRAG path community summaries include: Retrieve community summaries of the corresponding level from a multi-level community structure based on the query granularity level; The query text is converted into a vector representation. The similarity between the vector representation of the query text and the community summary vector is calculated. The vector similarity is used for initial screening. Based on the initial screening results, the community summaries are rearranged in combination with edge weight information. The semantic matching accuracy is used to perform semantic matching degree fine ranking on the rearranged community summaries. The GraphRAG path community summaries are determined based on the semantic matching degree fine ranking.
8. A computer device, characterized in that, It includes a memory and a processor, the memory including computer program instructions, which are executed by the processor at runtime as described in any of claims 1-7, representing a vehicle knowledge question-answering method based on the GraphRAG method.
Citation Information
Patent Citations
Construction method of RAG system based on Graph
CN118503407A
Intelligent construction and retrieval method for medical knowledge graph based on GraphRAG and LLM
CN119719383A