An enhanced retrieval generation optimization method based on knowledge graph

By constructing a knowledge graph of multi-level community summaries and using a particle swarm optimization algorithm, the problems of insufficient weight configuration and threshold adaptability in traditional retrieval generation technologies are solved, realizing intelligent optimization of retrieval parameters and improving the accuracy and comprehensiveness of complex queries.

CN121350280BActive Publication Date: 2026-06-19STATE GRID SHANGHAI MUNICIPAL ELECTRIC POWER CO +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
STATE GRID SHANGHAI MUNICIPAL ELECTRIC POWER CO
Filing Date
2025-12-19
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Traditional search enhancement generation techniques suffer from several drawbacks when handling complex queries. These include reliance on human experience for multimodal search mode weight configuration, difficulty in achieving optimal results, lack of adaptive information filtering thresholds leading to noise interference or information loss, and a lack of intelligent differentiated processing mechanisms. Consequently, they cannot effectively address the mixed needs of global summary queries and local fact queries.

Method used

By constructing a knowledge graph containing entities, attributes, and relationships, communities are divided and multi-level community summaries are generated. The particle swarm optimization algorithm is combined to jointly optimize the hybrid weights of multimodal retrieval and the information filtering threshold, intelligently distinguishing between global queries and local queries, and constructing enhanced context in the large language model.

Benefits of technology

It achieves adaptive configuration of retrieval parameters, improves the accuracy, logic, and comprehensiveness of knowledge coverage in complex question answering, solves the semantic fragmentation problem in traditional methods, and enhances the adaptive optimization capability of retrieval generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121350280B_ABST
    Figure CN121350280B_ABST
Patent Text Reader

Abstract

This invention discloses an enhanced retrieval generation optimization method integrating knowledge graphs, belonging to the field of data processing technology. The method includes: constructing a knowledge graph containing entities, attributes, and relationships from a data source; dividing the knowledge graph into communities and generating multi-level community summaries for each community to form a structured summary information database; employing a particle swarm optimization algorithm to jointly optimize the multimodal retrieval hybrid weights and information filtering thresholds to obtain optimized multimodal retrieval hybrid weights and optimized information filtering thresholds, wherein the multimodal retrieval hybrid weights include vector retrieval weights, graph relationship retrieval weights, and keyword retrieval weights; receiving user queries and classifying them into global or local queries based on semantic features; constructing an enhanced context based on the user query classification results; and inputting the enhanced context into a large language model to generate the final answer. This invention achieves adaptive optimization of the retrieval generation process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and more specifically to an enhanced retrieval generation optimization method that integrates knowledge graphs. Background Technology

[0002] With the rapid development of large language model technology, retrieval enhancement generation technology has become a key solution to problems such as lagging model knowledge updates and factual illusions, and has been widely used in the field of data processing. Traditional retrieval enhancement generation technology mostly obtains relevant information by segmenting text data and combining it with multimodal retrieval methods such as vector retrieval and keyword retrieval.

[0003] Traditional augmented retrieval generation methods have the following problems when dealing with complex queries: the weight configuration of different retrieval modes in multimodal retrieval depends on human experience and is difficult to achieve optimal results; the information filtering threshold setting lacks adaptive capability, leading to noise interference or information loss; and when faced with mixed needs of global summary queries and local fact queries, there is a lack of intelligent differentiated processing mechanisms. Summary of the Invention

[0004] This invention provides an enhanced retrieval generation optimization method that integrates knowledge graphs, aiming to solve the technical problem of insufficient adaptive optimization in the retrieval generation process in the prior art.

[0005] In view of the above problems, the present invention provides an enhanced retrieval generation optimization method that integrates knowledge graphs, comprising:

[0006] A knowledge graph containing entities, attributes, and relationships is constructed from the data source. The knowledge graph is then divided into communities, and multi-level community summaries are generated for each community to form a structured summary information database.

[0007] The particle swarm optimization algorithm is used to jointly optimize the multimodal retrieval hybrid weight and the information filtering threshold to obtain optimized multimodal retrieval hybrid weight and optimized information filtering threshold. The multimodal retrieval hybrid weight includes vector retrieval weight, graph relationship retrieval weight and keyword retrieval weight.

[0008] Receive user queries and classify them into global queries or local queries based on their semantic features;

[0009] Build enhanced context based on user query categorization results;

[0010] The enhanced context is input into a large language model to generate the final answer.

[0011] One or more technical solutions provided in this invention have at least the following technical effects or advantages:

[0012] This invention provides an enhanced retrieval generation optimization method that integrates knowledge graphs. By constructing a knowledge graph with multi-level community summaries, the retrieval foundation is upgraded from discrete text blocks to a structured semantic network, effectively solving the semantic fragmentation problem of traditional methods. The particle swarm optimization algorithm is used to jointly optimize multimodal retrieval weights and filtering thresholds, achieving adaptive configuration of retrieval parameters. By intelligently distinguishing between global and local queries and constructing differentiated enhanced contexts, the method ultimately considers both the global relevance and local accuracy of knowledge when generating answers, improving the accuracy, logic, and comprehensiveness of knowledge coverage in complex question-and-answer generation, thus achieving adaptive optimization of retrieval generation. Attached Figure Description

[0013] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0014] Figure 1 A flowchart illustrating an enhanced retrieval generation optimization method integrating knowledge graphs, provided as an embodiment of the present invention;

[0015] Figure 2 This is a flowchart illustrating the particle swarm optimization algorithm in an enhanced retrieval generation optimization method that integrates knowledge graphs, as provided in an embodiment of the present invention. Detailed Implementation

[0016] This invention provides an enhanced retrieval generation optimization method that integrates knowledge graphs, addressing the technical problem of insufficient adaptive optimization in the retrieval generation process in existing technologies.

[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.

[0018] It should be noted that the terms "comprising" and "having" are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or server that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or modules that are not explicitly listed or that are inherent to these processes, methods, products, or devices.

[0019] Examples, such as Figure 1As shown, this invention provides an enhanced retrieval generation optimization method that integrates knowledge graphs, the method comprising:

[0020] S100: Construct a knowledge graph containing entities, attributes, and relationships from the data source, divide the knowledge graph into communities, and generate multi-level community summaries for each community to form a structured summary information database.

[0021] In this embodiment of the invention, a knowledge graph containing entities, attributes, and relationships is constructed from a data source. This knowledge graph is then divided into communities, and multi-level community summaries are generated for each community, forming a structured summary information database. Traditional retrieval enhancement generation methods typically directly segment and vectorize the original document, resulting in knowledge being fragmented into isolated text fragments and disrupting its inherent semantic connections. When processing complex queries involving multi-step reasoning or requiring a global context, semantic fragmentation leads to incomplete and illogical retrieved contextual information, ultimately degrading the quality of answers generated by large language models. This step aims to construct a structured knowledge graph and intelligently cluster it into communities, organizing originally discrete knowledge points into an organic, hierarchical semantic network, laying the foundation for subsequent accurate retrieval and deep reasoning.

[0022] Step S100 in the method provided in this embodiment of the invention includes:

[0023] Extract entities, attributes, and relationships from both structured and unstructured data sources;

[0024] Instantiate entities as nodes, instantiate attributes as node attributes, and instantiate relationships as edges;

[0025] Based on the co-occurrence frequency of relations in the data source, relation weights are assigned to relation edges to form a knowledge graph containing nodes, node attributes, edges, and relation weights.

[0026] A graph neural network algorithm is used to learn node embedding representations for the knowledge graph;

[0027] Based on node embedding vectors, a hierarchical clustering algorithm is used to perform multi-granularity community partitioning of the knowledge graph.

[0028] A hierarchical summary, including leaf-level community summaries and parent-level community summaries, is generated for each community using a large language model;

[0029] The generated hierarchical community summaries are organized and stored according to the community hierarchy to form a structured summary information database.

[0030] First, entities, attributes, and relationships are extracted from both structured and unstructured data sources. Structured data sources refer to data sources with fixed formats and fields, such as plant variety databases and Excel maintenance parameter tables. Unstructured data sources refer to text data without fixed formats, such as gardening forum posts and maintenance experience sharing documents. Entities are objectively existing concrete things or abstract concepts, such as pothos, indirect light environment, and yellowing leaves. Attributes are the characteristics of entities, such as the watering frequency of pothos. Relationships are the associations between entities, such as pothos being suitable for indirect light environment. For structured data sources, field mapping and rule matching are used for extraction. The correspondence between entities, attributes, relationships, and data source fields is predefined, and information is obtained through database queries and table parsing tools. For unstructured data sources, pre-trained models and domain dictionaries are used for extraction. Named entity recognition is based on the BERT model, and relationships between entities are extracted based on the PCNN model combined with an indoor plant maintenance domain dictionary.

[0031] For example, in the field of plant care, the unstructured data source is a gardening forum post, from which the entities of diffused light environment, general fertilizer, and leaf yellowing are extracted; the structured data source is a plant variety database, from which the entity "pothos" and its attribute "watering frequency once a week" are extracted; at the same time, the relationships are extracted: pothos is suitable for diffused light environment, pothos needs to be fertilized with general fertilizer, and overwatering will cause leaf yellowing.

[0032] Secondly, entities are instantiated as nodes, attributes as node attributes, and relationships as edges. Instantiation transforms abstract entities, attributes, and relationships into concrete elements that can be stored in the knowledge graph. Nodes are the basic units representing entities in a knowledge graph. Node attributes are the entity feature information attached to nodes. Edges are elements that connect two nodes and represent the relationships between entities. Graph databases such as Neo4j are selected as the storage medium, and unified data mapping rules are established. Each entity corresponds to a unique node, and the node ID is named in the format of entity type + sequence number; entity attributes are associated with the corresponding node in the form of key-value pairs; each relationship corresponds to an edge connecting two nodes, and the edge type is named after the relationship.

[0033] For example, the entity "Pothos" is instantiated as a node with the ID "Plant 001", and the attribute "Watering frequency once a week" is bound to this node; the entity "Indirect Light Environment" is instantiated as a node with the ID "Environment 001", the entity "General Fertilizer" is instantiated as a node with the ID "Fertilizer 001", and the entity "Leaf Yellowing" is instantiated as a node with the ID "Disease 001"; the relationship "Pothos Suitable Indirect Light Environment" is instantiated as an edge connecting Plant 001 and Environment 001, and the edge type is defined as "Suitable"; the relationship "Pothos Requires General Fertilizer" is instantiated as an edge connecting Plant 001 and Fertilizer 001, and the edge type is defined as "Requires"; the relationship "Overwatering Causes Leaf Yellowing" is instantiated as an edge connecting Overwatering (node ​​ID: Maintenance Behavior 001) and Disease 001, and the edge type is defined as "Causes".

[0034] Next, relationship weights are assigned to relationship edges based on the co-occurrence frequency of relationships in the data source, forming a knowledge graph containing nodes, node attributes, edges, and relationship weights. Co-occurrence frequency refers to the number of times two entities appear simultaneously in the entire data source through a specific relationship. Relationship weight is a numerical value that quantifies the closeness of the relationship between entities, ranging from 0 to 1; a higher weight indicates a greater importance of the connection between entities through that relationship. First, the co-occurrence frequency of each relationship in the entire data source is counted; then, normalization is used to convert the co-occurrence frequency into a weight value in the 0-1 range, calculated by dividing the co-occurrence frequency of that relationship by the maximum co-occurrence frequency of all relationships; finally, the calculated weight values ​​are associated with the corresponding relationship edges, updating the knowledge graph structure in the graph database.

[0035] For example, statistical analysis of the entire data source for indoor plant care reveals that the relationship "Pothos - Suitable - Indirect Light Environment" appears 92 times, "Pothos - Requires Application - General Fertilizer" appears 68 times, and "Overwatering - Causes - Leaf Yellowing" appears 115 times. 115 times is the maximum number of occurrences across all relationships. Calculating the weights of each relationship, the weight for "Pothos - Suitable - Indirect Light Environment" is 92 / 115 = 0.8, the weight for "Pothos - Requires Application - General Fertilizer" is 68 / 115 ≈ 0.59, and the weight for "Overwatering - Causes - Leaf Yellowing" is 115 / 115 = 1.0. These weights are then bound to their corresponding edges to form a complete knowledge graph.

[0036] Subsequently, a graph neural network (GNN) algorithm is employed to learn node embedding representations for the knowledge graph. GNNs are deep learning algorithms specifically designed for processing graph-structured data, effectively capturing neighbor information and structural features of the graph. Node embedding representations transform nodes in the knowledge graph into low-dimensional, dense numerical vectors, where the cosine similarity reflects the semantic or structural association between nodes. A graph convolutional network (GAT) based on an attention mechanism is chosen as the node embedding model. Initial node features from the knowledge graph are input, such as the encoded values ​​of node attributes and edge weights. A multi-head attention layer calculates the attention weights of each node to its neighboring nodes, strengthening the influence of important associations by combining edge weights. The features of neighboring nodes are weighted and aggregated to update the feature representation of the current node. After 3-5 layers of network iteration, low-dimensional embedding vectors for each node are output; in this example, 128-dimensional vectors are used.

[0037] For example, a weighted knowledge graph is input into the GAT model. The initial features of the node "Pothos" (plant 001) are a combination of attributes such as watering frequency encoding. The model combines the features of its neighboring nodes, "Diffuse Light Environment" (edge ​​weight 0.8) and "General Fertilizer" (edge ​​weight 0.59), and outputs a 128-dimensional embedding vector after attention aggregation calculation. The vector content is 0.15, 0.28, ..., 0.31. The cosine similarity between the vectors of "Pothos" and "Diffuse Light Environment" is 0.88, indicating a close relationship between the two. The cosine similarity between the vectors of "Pothos" and "Succulent-Specific Fertilizer" is 0.35, indicating a weaker relationship between the two.

[0038] Furthermore, based on node embedding vectors, a hierarchical clustering algorithm is used to partition the knowledge graph into multi-granularity communities. Hierarchical clustering is an unsupervised learning algorithm that forms a tree-like clustering structure by repeatedly merging or splitting clusters with high similarity. Multi-granularity communities refer to node clusters at different levels, from fine-grained to coarse-grained. Fine-grained (leaf-level) communities focus on specific sub-topics, while coarse-grained (parent-level) communities cover a wider range of topics. A bottom-up hierarchical clustering algorithm, AGNES, is used. First, each node is considered an initial cluster; the cosine similarity between the center vectors of any two clusters and the average of the embedding vectors of all nodes within those clusters is calculated; the two clusters with the highest similarity are merged to form a new cluster; this calculation and merging process is repeated until all clusters are merged into a single overall cluster; different levels of the clustering tree are extracted according to business requirements. In this example, three levels are set: leaf level, parent-child level, and parent level, resulting in multi-granularity communities.

[0039] For example, after clustering based on node embedding vectors, a three-level community is formed. The leaf-level community includes cluster 1 (Pothos), indirect light environment, general fertilizer, yellowing leaves, overwatering; cluster 2 (Spider Plant), semi-shade environment, organic fertilizer, dry leaf tips, underwatering; and cluster 3 (Succulent), direct light, granular fertilizer, root rot, waterlogging. The parent-child level community is the vine plant care community, which is formed by merging cluster 1 and cluster 2, and the succulent plant care community is cluster 3. The parent-general level community is the overall indoor plant care community, which is formed by merging the vine plant care community and the succulent plant care community.

[0040] Building upon this foundation, a hierarchical summary, including leaf-level and parent-level community summaries, is generated for each community using a Large Language Model (LLM). The LLM is a generative artificial intelligence model trained on a large-scale corpus, possessing powerful semantic understanding and text generation capabilities. The hierarchical summary is an adaptive summary generated for communities of different granularities; leaf-level summaries focus on presenting detailed information, while parent-level summaries focus on providing an overall overview. The LLM is chosen as the generative model, employing a community content aggregation + Prompt-guided approach to generate summaries. For each community, the original data source fragments containing node attributes, edge relationships, and related information are aggregated. For leaf-level communities, the Prompt is designed as follows: "Based on the following entities, relationships, and case information in the field of indoor plant care, please generate a detailed technical summary, including entities, key relationships, and typical application scenarios, and attach the aggregated content." For parent-level communities, the Prompt is designed as follows: "Based on the summaries of the following sub-communities, please generate a general summary, clarifying the topic scope of the parent community and the relational logic of each sub-community, and attach the sub-community summaries." After generating the summaries, the accuracy of technical terminology is manually verified.

[0041] For example, the leaf-level cluster 1 abstract focuses on indoor care knowledge for pothos, with entities including pothos, indirect light environment, general-purpose fertilizer, leaf yellowing, and overwatering. The attribute of pothos is watering frequency once a week; the key relationships are that pothos is suitable for indirect light environment (weight 0.8), requires general-purpose fertilizer (weight 0.59), and overwatering will cause leaf yellowing (weight 1.0). A typical application scenario is that when beginners care for pothos, following the weekly watering frequency, placing it in an indirect light environment, and applying general-purpose fertilizer can prevent leaf yellowing; parent-child level vine plant care The community summary covers the care of two common indoor climbing plants, pothos and spider plants. Its two sub-communities focus on the suitable growing environments, fertilizer selection, and common disease causes for pothos and spider plants, respectively. Both plants thrive in partial shade or diffused light, requiring targeted control of watering frequency. The parent-level indoor plant care community summary covers indoor care knowledge for climbing plants and succulents, including the growing environment of plant varieties, fertilizer suitability, watering requirements, and common disease prevention, providing comprehensive knowledge support from basic care to problem-solving for caregivers with different needs.

[0042] Finally, the generated hierarchical community summaries are organized and stored according to the community hierarchy, forming a structured summary information repository. The structured summary information repository is a database that stores summaries according to a preset hierarchical structure, supporting hierarchical retrieval and relational queries, enabling a top-down information retrieval approach. A hybrid storage architecture of relational database + file system is adopted. A community hierarchy table is created in MySQL to store metadata such as community ID, parent community ID, community name, and summary type; the generated summary text is named in the format of community ID_summary type and stored in a distributed file system, with the file storage path recorded in the MySQL table; an indexing mechanism is established to support retrieval by keywords such as community name, entity, and maintenance issue, enabling hierarchical navigation.

[0043] For example, the key records in the MySQL community hierarchy table are: Community ID1, Name: Indoor Plant Care General Community, Parent ID0, Type: General Parent, File path: / summary / 1_total.txt; Community ID2, Name: Climbing Plant Care Community, Parent ID1, Type: Child Parent, File path: / summary / 2_sub.txt; Community ID3, Name: Cluster 1, Parent ID2, Type: Leaf Level, File path: / summary / 3_leaf.txt. When searching for yellowing leaves of pothos, the system first matches the leaf level cluster 1, returns its detailed summary, and provides hierarchical navigation options to jump to the Climbing Plant Care Community and then to the Indoor Plant Care General Community.

[0044] In this embodiment of the invention, the degree of knowledge structuring is improved by constructing knowledge graphs, dividing communities, and generating hierarchical summaries, making implicit connections explicit, accurately matching multi-granularity information needs, effectively improving retrieval efficiency, enhancing knowledge reusability and ease of updating, and facilitating the efficient flow and continuous improvement of the knowledge system.

[0045] S200: The particle swarm optimization algorithm is used to jointly optimize the multimodal retrieval hybrid weight and the information filtering threshold to obtain the optimized multimodal retrieval hybrid weight and the optimized information filtering threshold. The multimodal retrieval hybrid weight includes vector retrieval weight, graph relationship retrieval weight and keyword retrieval weight.

[0046] In this embodiment of the invention, a particle swarm optimization algorithm is used to jointly optimize the multimodal retrieval hybrid weights and information filtering thresholds, obtaining optimized multimodal retrieval hybrid weights and optimized information filtering thresholds. The multimodal retrieval hybrid weights include vector retrieval weights, graph relation retrieval weights, and keyword retrieval weights. In multimodal retrieval, the mixing ratio of vector retrieval weights, graph relation retrieval weights, and keyword retrieval weights, as well as the setting of information filtering thresholds, have long relied on manual adjustment based on experience. This not only makes it difficult to accurately adapt to the hierarchical knowledge characteristics of structured summary information databases, but also easily leads to weight imbalances, preventing certain retrieval methods from leveraging their advantages and thus affecting the comprehensiveness of retrieval results. Simultaneously, unreasonable information filtering thresholds can result in redundant and complex retrieval results or missing key knowledge, ultimately triggering a chain reaction of problems such as mismatch between retrieval quality and user needs, inconsistent quality of retrieval summary generation, and low efficiency of the retrieval process. Therefore, it is necessary to use a particle swarm optimization algorithm to jointly optimize the multimodal retrieval hybrid weights and information filtering thresholds, obtaining the optimal parameter combination suitable for the scenario through the algorithm's intelligent search capabilities.

[0047] like Figure 2 As shown, step S200 in the method provided in this embodiment of the invention includes:

[0048] Based on the structured summary information database, a verification query set containing global query samples and local query samples is constructed;

[0049] Define the particle search space, where the position vector of each particle contains two components: a multimodal retrieval hybrid weight and an information filtering threshold.

[0050] Construct a fitness function, wherein the fitness function includes a retrieval quality assessment component, a generation quality assessment component, and an efficiency assessment component;

[0051] Based on the verification query set, the optimal particle position that maximizes the fitness function is searched in the particle search space using the particle swarm optimization algorithm.

[0052] The multimodal retrieval hybrid weight component in the optimal particle position is used as the optimized multimodal retrieval hybrid weight, and the information filtering threshold component is used as the optimized information filtering threshold.

[0053] First, based on the structured summary information database, a validation query set is constructed, comprising global query samples and local query samples. Global query samples refer to query content covering the overall scope of the domain, focusing on macro-level themes. Local query samples refer to query content targeting specific sub-problems within the domain, focusing on micro-level details. The validation query set is a standardized query set used for algorithm optimization verification, providing an evaluation basis for subsequent optimization. The hierarchical themes of the structured summary information database are analyzed, and query content covering different levels is selected based on common user search needs. Global query samples are selected around the themes of the parent and child parent-child communities, while local query samples focus on specific problems in the leaf-level communities. After integration and removal of duplicate and invalid queries, a standardized validation query set is formed.

[0054] For example, global query samples are selected from the structured summary information database for indoor plant care, including indoor plant care methods, key points for vine care, and disease prevention for succulents; local query samples are selected, including suitable growing environment for pothos, solutions for yellowing leaves of pothos, and watering frequency control for spider plants, and integrated to form a unique validation query set.

[0055] Secondly, the particle search space is determined, where each particle's position vector contains two components: a multimodal retrieval hybrid weight and an information filtering threshold. In particle swarm optimization, particles represent potential solutions to the optimization problem, and the particle search space is the set of all possible positions of the particles, i.e., the range of potential solutions. The position vector is a numerical vector describing the particle's position in the search space, with each component corresponding to a parameter to be optimized. The multimodal retrieval hybrid weight includes vector retrieval weight, graph relation retrieval weight, and keyword retrieval weight, all summed to 1. The value range of each parameter to be optimized is set based on the business requirements of the retrieval process. In the multimodal retrieval hybrid weight, the values ​​of vector retrieval weight, graph relation retrieval weight, and keyword retrieval weight are all between 0 and 1, and their sum is 1. The information filtering threshold, based on the relevance criteria of the summary information, is set to a value range of 0 to 1, used to filter content in the search results that meets the relevance standard. The particle search space is defined based on the parameter range, and the format of each particle's position vector is [vector retrieval weight, graph relation retrieval weight, keyword retrieval weight, information filtering threshold].

[0056] For example, in the particle search space, the vector retrieval weight, graph relationship retrieval weight, and keyword retrieval weight are all set to a value between 0 and 1, and their sum is 1. The information filtering threshold is set to a value between 0 and 1. The initial position vector of a particle is [0.5, 0.3, 0.2, 0.6], where the first three components are multimodal retrieval mixed weights, and the last component is the information filtering threshold.

[0057] Subsequently, a fitness function is constructed, wherein the fitness function includes a retrieval quality assessment component, a generation quality assessment component, and an efficiency assessment component.

[0058] The construction of the fitness function includes:

[0059] The search is performed based on the multimodal search hybrid weights at the current particle position to obtain the search result community set;

[0060] Calculate the similarity between the search result community set and the standard community set to obtain the community coverage score;

[0061] The relationship recall score is obtained by calculating the matching ratio between the relationship paths contained in the community set of search results and the standard relationship path set.

[0062] The community coverage score and the relationship recall score are weighted and fused to obtain the retrieval quality assessment component;

[0063] Based on the information filtering threshold at the current particle position, intermediate answers generated by the large language model are filtered to obtain the final answer;

[0064] Analyze the hierarchical distribution of the community summary cited in the final answer and calculate the coverage depth score;

[0065] The overlap ratio between entities used in the final answer and entities in the enhanced context is statistically analyzed, and the context utilization score is calculated.

[0066] The coverage depth score and context utilization score are weighted and fused to obtain the generation quality assessment component;

[0067] Measure the response time from receiving a query to generating an answer, and calculate a response efficiency score based on the preset optimal response time;

[0068] The number of tokens in the constructed enhanced context is counted, and a context efficiency score is calculated based on the preset optimal number of tokens;

[0069] The response efficiency score and the context efficiency score are weighted and fused to obtain the efficiency evaluation component;

[0070] The retrieval quality assessment component, generation quality assessment component, and efficiency assessment component are weighted and summed according to preset weights to obtain the fitness function.

[0071] First, a search is performed based on the multimodal retrieval hybrid weights at the current particle position to obtain the search result community set. The current particle position refers to the instantaneous position of the particle in the search space during the iteration process, corresponding to a set of multimodal retrieval hybrid weights to be evaluated. The search result community set is the set of communities matched in the structured summary information database after the search based on this weight combination. The first three components of the current particle position vector are extracted as multimodal retrieval hybrid weights and configured into the multimodal retrieval system. Using samples from the validation query set as search input, the system performs searches according to the weight ratios of vector search, graph relationship search, and keyword search, aggregating all communities with matching degrees to form the search result community set. For example, if the multimodal retrieval hybrid weights at the current particle position are [0.5, 0.3, 0.2], and a search is performed using the validation query sample "solution for yellowing leaves of pothos", the system integrates the three types of search results according to the weight ratios, matching the leaf-level cluster 1 community, forming the search result community set {cluster 1}.

[0072] Secondly, the similarity between the search result community set and the standard community set is calculated to obtain the community coverage score. The standard community set is a pre-labeled community set containing all relevant knowledge for the query sample, serving as a benchmark for search quality. The community coverage score is an indicator that quantifies the degree to which the search result community set covers the standard community set; a higher score indicates more comprehensive coverage. The Jaccard similarity algorithm is used to calculate the similarity between the two, with the formula: Community Coverage Score = (Intersection size of the search result community set and the standard community set) / (Union size of the two sets). The similarity result is the community coverage score, ranging from 0 to 1. For example, if the standard community set for the query sample "solutions for yellowing leaves of pothos" is {cluster 1}, and the search result community set is also {cluster 1}, with both the intersection and union sizes being 1, the calculated community coverage score is 1.0.

[0073] Next, the matching ratio of the relational paths contained in the community set of search results with the standard relational path set is calculated to obtain the relational recall score. A relational path refers to the link between entities in a knowledge graph, such as "pothos-suitable-astigmatic light environment". The standard relational path set is a set of core relational paths that must be included in the query sample. The relational recall score is an indicator that quantifies the recall degree of the core relational paths in the search results. The relational paths of all entities in the community set of search results are extracted and compared with the standard relational path set. The number of successfully matched relational paths is counted. The relational recall score = number of successfully matched paths / total number of paths in the standard relational path set, with a value range of 0-1. For example, the standard relational path set for the query sample "Pothos leaf yellowing solution" is {Pothos-prone to-leaf yellowing, leaf yellowing-repair solution-battery replacement}. The community set of search results matches the above two relational paths, with a total of 2 paths, resulting in a relational recall score of 1.0.

[0074] Then, the community coverage score and the relationship recall score are weighted and fused to obtain the retrieval quality assessment component. Weighted fusion refers to assigning weights to two different indicators and then summing them to comprehensively reflect the overall performance; the weights are set according to the importance of the indicators. Considering the retrieval needs for indoor plant care, a fusion weight is set for the community coverage score and the relationship recall score, with the sum of their weights being 1. The retrieval quality assessment component = community coverage score × weight 1 + relationship recall score × weight 2. For example, if the weight of the community coverage score is set to 0.5 and the weight of the relationship recall score is 0.5, and the community coverage score is known to be 1.0 and the relationship recall score to be 1.0, the weighted fusion retrieval quality assessment component = 1.0 × 0.5 + 1.0 × 0.5 = 1.0.

[0075] Furthermore, based on the information filtering threshold at the current particle position, intermediate answers generated by the large language model are filtered to obtain the final answer. Intermediate answers refer to the search answers generated directly by the large language model without filtering, and may contain low-relevance content. The information filtering threshold is the critical value for filtering answers; content with relevance below this value is discarded. Answer relevance scoring rules are set. After the large language model generates intermediate answers, the system automatically scores each piece of content, retaining content with scores no lower than the information filtering threshold at the current particle position, and integrating them to form the final answer. For example, if the information filtering threshold for the current particle is 0.7, and the intermediate answers generated by the large language model contain 3 pieces of content with relevance scores of 0.8, 0.6, and 0.9 respectively, after filtering, content with scores of 0.8 and 0.9 is retained and integrated into the final answer.

[0076] Subsequently, the hierarchical distribution of the community summaries cited in the final answer was analyzed, and the coverage depth score was calculated. The hierarchical distribution of community summaries refers to the different levels of the knowledge graph, such as leaf level, parent-child level, and parent level, cited by the final answer. The coverage depth score is an indicator that quantifies the completeness of the answer's coverage of knowledge at each level. The number of levels to which the summaries cited in the final answer belong is counted, and the coverage depth score is calculated based on preset level weights. If the answer covers all key levels, the score approaches 1; the fewer the covered levels, the lower the score. For example, the key levels for the query sample "solution for yellowing leaves of pothos" are leaf level and parent-child level. The final answer cited summaries from both Cluster 1 (leaf level) and the "vine plant care community" (parent-child level), covering all key levels, and the calculated coverage depth score is 1.0.

[0077] Furthermore, the overlap ratio between entities used in the final answer and entities in the enhanced context is statistically analyzed, and a context utilization score is calculated. Enhanced context refers to a set of knowledge containing entities constructed to assist in answer generation. The context utilization score is an indicator that quantifies the degree to which the final answer reuses entities from the enhanced context. The entity sets in the final answer and the enhanced context are extracted, and the overlap ratio is calculated. The context utilization score = number of overlapping entities / total number of entities in the enhanced context, with a value ranging from 0 to 1. For example, if the entity set in the enhanced context is {Pothos, diffused light environment, general-purpose fertilizer, leaf yellowing}, and the entity set in the final answer is {Pothos, leaf yellowing, general-purpose fertilizer}, the number of overlapping entities is 3, and the total number of entities in the enhanced context is 4, resulting in a context utilization score of 0.75.

[0078] Secondly, the coverage depth score and context utilization score are weighted and fused to obtain the generated quality assessment component. The generated quality assessment component is an indicator that comprehensively reflects the hierarchical completeness and context reuse degree of the final answer, demonstrating the logic and relevance of the answer. A fusion weight is set for the coverage depth score and the context utilization score, with the sum of their weights being 1. The generated quality assessment component = coverage depth score × weight 1 + context utilization score × weight 2. For example, setting the weight of the coverage depth score to 0.6 and the weight of the context utilization score to 0.4, given a coverage depth score of 1.0 and a context utilization score of 0.75, the weighted fused generated quality assessment component = 1.0 × 0.6 + 0.75 × 0.4 = 0.9.

[0079] Next, the response time from receiving the query to generating the answer is measured, and a response efficiency score is calculated based on the preset optimal response time. Response time refers to the total time the retrieval system takes from receiving a user query to outputting the final answer. The preset optimal response time is an ideal time standard set based on business requirements. The response efficiency score is an indicator that quantifies the retrieval response speed. Actual response time is recorded using a timing tool. If the actual time is less than or equal to the preset optimal response time, the response efficiency score is 1.0; if the actual time is greater than the preset optimal response time, the score is calculated proportionally, with a lower score for longer actual times, ranging from 0 to 1. For example, if the preset optimal response time is 1 second, and the actual response time for a query about a solution for yellowing leaves on a pothos plant is 0.8 seconds, which is less than the optimal time, the calculated response efficiency score is 1.0.

[0080] Then, the number of tokens in the constructed enhanced context is counted, and a context efficiency score is calculated based on the preset optimal number of tokens. The number of tokens refers to the number of basic semantic units obtained after segmenting the enhanced context text. The preset optimal number of tokens is the ideal number of tokens that balances context completeness and processing efficiency. The context efficiency score is an indicator that quantifies the conciseness and processing efficiency of the enhanced context. The actual number of tokens in the enhanced context is counted using natural language processing tools. If the actual number is within the preset optimal number range, the context efficiency score is 1.0; if it exceeds the range, points are deducted proportionally, with a value ranging from 0 to 1. For example, if the preset optimal number range is 50-80, and the actual number of tokens in the enhanced context for querying "solution for yellowing leaves of pothos" is 65, which is within the range, the calculated context efficiency score is 1.0.

[0081] Next, the response efficiency score and the context efficiency score are weighted and fused to obtain an efficiency evaluation component. The efficiency evaluation component is an indicator that comprehensively reflects the retrieval response speed and context processing efficiency. A fusion weight is set for the response efficiency score and the context efficiency score, and the weighted sum is used to obtain the efficiency evaluation component. For example, if the weight of both the response efficiency score and the context efficiency score is set to 0.5, the fused efficiency evaluation component = 1.0 × 0.5 + 1.0 × 0.5 = 1.0.

[0082] Finally, the retrieval quality evaluation component, generation quality evaluation component, and efficiency evaluation component are weighted and summed according to preset weights to obtain the fitness function. The fitness function is the final evaluation function integrating the three dimensions of retrieval quality, generation quality, and efficiency, and its value determines the quality of the particle's position. Preset weights are set for the retrieval quality, generation quality, and efficiency evaluation components, with the sum of their weights being 1. The fitness function value is obtained after weighted summation. For example, if the weight of the retrieval quality evaluation component is set to 0.4, the weight of the generation quality evaluation component to 0.3, and the weight of the efficiency evaluation component to 0.3, the final fitness function value = 1.0 × 0.4 + 0.9 × 0.3 + 1.0 × 0.3 = 0.97.

[0083] Based on this, and using the verification query set, the optimal particle position that maximizes the fitness function is searched in the particle search space using the particle swarm optimization algorithm.

[0084] Specifically, based on the verification query set, the optimal particle position in the particle search space that maximizes the fitness function is searched using a particle swarm optimization algorithm, including:

[0085] The fitness function value of each particle is calculated based on the verification query set;

[0086] Based on the particle's historical best position and the group's global best position, combined with inertia weights and learning factors, the particle's velocity vector and position vector are updated.

[0087] When the fitness function value no longer improves after a preset number of iterations, a random perturbation is applied to the particle position based on the community structure of the knowledge graph.

[0088] The magnitude of the inertia weight is dynamically adjusted based on the changing trend of the fitness function value during the iteration process.

[0089] Through multiple iterative searches, the optimal particle position that maximizes the fitness function is determined.

[0090] First, the fitness function value of each particle is calculated based on the verification query set. The particle fitness function value is a quantitative score obtained by evaluating the parameter combination corresponding to each particle through the fitness function constructed in the above steps, and it is the basis for judging the quality of the particles. All particles in the particle swarm are traversed, and the position vector of each particle is extracted one by one. Using all samples in the verification query set as input, the complete process of constructing the fitness function is executed sequentially, calculating the fitness function value corresponding to each particle, and storing it in the particle's attribute information. For example, with a particle swarm size of 50, each particle is traversed, and verification query samples such as "solutions for yellowing leaves of pothos" and "indoor plant care methods" are used as input. The fitness function value of particle A is calculated to be 0.97, and the fitness function value of particle B is 0.85. The score calculation for all particles is completed sequentially.

[0091] Secondly, based on the particle's historical best position and the swarm's global best position, combined with inertia weights and learning factors, the particle's velocity and position vectors are updated. The particle's historical best position is the position with the highest fitness function value in each iteration. The swarm's global best position is the position with the highest fitness function value for all particles in each iteration. Inertia weights are used to balance the particle's global exploration ability and local exploitation ability. The learning factor is used to adjust the degree to which the particle learns from its own historical best and the swarm's global best. Initial values ​​for inertia weights and learning factors are set. The learning factor includes a self-learning factor and a swarm learning factor, using the standard velocity and position update formulas of the particle swarm optimization algorithm. The velocity vector update formula is: New velocity = Inertia weight × Old velocity + Self-learning factor × Random number × (Historical best position - Current position) + Swarm learning factor × Random number × (Global best position - Current position); the position vector update formula is: New position = Current position + New velocity, while ensuring that the updated position vector satisfies the parameter value constraints: the total weight is 1, and the threshold is in the range of 0-1.

[0092] For example, the initial value of the inertia weight is set to 0.6, the self-learning factor and the group learning factor are both 1.5, and the random number range is 0-1. The current position of particle A is [0.4, 0.3, 0.3, 0.6], the historical best position is [0.45, 0.3, 0.25, 0.65], and the group's global best position is [0.5, 0.3, 0.2, 0.7]. After calculating the new velocity according to the formula, the updated position is [0.46, 0.3, 0.24, 0.66], and the sum of the first three components is 1, which meets the parameter constraints.

[0093] Furthermore, when the fitness function value stops improving after a preset number of iterations, a random perturbation is applied to the particle position based on the community structure of the knowledge graph. The preset number of iterations is an iteration threshold set according to business requirements, used to determine if the algorithm is trapped in a local optimum. The random perturbation applies a small, random change to the particle's current position to help it escape local optima. The community structure of the knowledge graph refers to the multi-granularity communities divided in sub-step 5; the perturbation range is determined by the community association strength. A continuous iteration threshold is set, and the global optimal fitness function value of the group is monitored in real time. When the number of consecutive iterations reaches the threshold and the score does not improve, a small perturbation is applied to the weight component in the particle position vector based on the tightness of community associations in the knowledge graph. The perturbation amplitude is controlled between 0.01 and 0.05, while ensuring that the position after perturbation still satisfies the parameter constraints. For example, if the continuous iteration threshold is set to 10 times, and the global optimal fitness score of the group remains at 0.97 without improvement after 20-30 iterations, the perturbation mechanism is triggered. Apply a perturbation to the current position of particle A [0.46, 0.3, 0.24, 0.66], adjust the vector retrieval weight to 0.48 and the keyword retrieval weight to 0.22, and the perturbation position is [0.48, 0.3, 0.22, 0.66], which still satisfies the constraint that the total weight sum is 1.

[0094] Then, the inertia weight is dynamically adjusted based on the trend of the fitness function value during the iteration process. The trend of the fitness function value refers to the rise and fall of the global optimal fitness score of the population in adjacent iterations, used to determine the search state of the particles. Dynamically adjusting the inertia weight balances the exploration and development capabilities of particles in different search stages by changing the weight value. A range of inertia weight values ​​is set. If the fitness function value increases significantly, it indicates that the particle is in the global exploration stage, and the inertia weight is appropriately increased to strengthen exploration; if the fitness function value increases slightly or tends to stabilize, it indicates that the particle is in the local development stage, and the inertia weight is appropriately decreased for precise search; if the fitness function value decreases, the inertia weight is slightly increased to help the particle adjust its search direction. For example, if the inertia weight range is set to 0.4-0.9, and the fitness score increases significantly from 0.8 to 0.97 in the early stages of iteration, the inertia weight is adjusted from 0.6 to 0.8; if the fitness score only increases slightly from 0.97 to 0.98 in the later stages of iteration, the inertia weight is adjusted from 0.8 to 0.4 to focus on precise local search.

[0095] Next, through multiple iterative searches, the optimal particle position that maximizes the fitness function is determined. Multiple iterative searches refer to executing the complete particle update process according to a preset total number of iterations, ensuring the particle swarm fully traverses the search space and avoids missing optimal solutions. The above steps are repeated until the preset total number of iterations is reached. After iteration, all historical optimal positions and the swarm's global optimal positions are traversed, and the position vector with the largest fitness function value is selected as the final optimal particle position. For example, if the preset total number of iterations is 100, after all iterations, the swarm's global optimal position is [0.5, 0.3, 0.2, 0.7], with a corresponding fitness function value of 0.99, which is the maximum value among all particle positions; this position is the optimal particle position.

[0096] Finally, the multimodal retrieval hybrid weight component in the optimal particle position is used as the optimized multimodal retrieval hybrid weight, and the information filtering threshold component is used as the optimized information filtering threshold. The optimized multimodal retrieval hybrid weight is the weight ratio of vector retrieval, graph relationship retrieval, and keyword retrieval adapted to the current retrieval scenario after algorithm optimization. The optimized information filtering threshold is a threshold standard that can accurately filter high-quality retrieval results after algorithm optimization. The components in the optimal particle position vector are extracted, and the first three components correspond to vector retrieval weight, graph relationship retrieval weight, and keyword retrieval weight in sequence, and are integrated into the optimized multimodal retrieval hybrid weight; the last component is directly used as the optimized information filtering threshold. Both are stored and applied to the subsequent multimodal retrieval process.

[0097] For example, the optimal particle position vector is [0.5, 0.3, 0.2, 0.7]. The first three components are extracted as the weights for optimizing the multimodal retrieval mixture, namely, vector retrieval weight 0.5, graph relationship retrieval weight 0.3, and keyword retrieval weight 0.2. The last component is extracted as the information filtering threshold 0.7, which is used for parameter configuration of multimodal retrieval for indoor plant care.

[0098] In this embodiment of the invention, the particle swarm optimization algorithm is used to jointly optimize the hybrid weights and information filtering thresholds for multimodal retrieval, realizing a shift in parameter configuration from reliance on manual experience to intelligent algorithm adaptation. The optimized hybrid weights allow vector retrieval, graph relation retrieval, and keyword retrieval to fully leverage their respective advantages and create a synergistic effect, effectively improving the accuracy and knowledge coverage of retrieval results. The optimized information filtering thresholds can accurately filter out highly relevant content, effectively eliminating redundant information and avoiding the omission of key knowledge. Simultaneously, the optimal parameter combination adapted to the scenario not only ensures the fluency and logical coherence of the generated retrieval result summaries but also improves the response speed of the retrieval process, reduces unnecessary computational consumption, and provides stable and reliable parameter support for subsequent efficient and accurate multimodal retrieval based on a structured summary information database.

[0099] S300: Receives user queries and classifies them into global queries or local queries based on their semantic features.

[0100] In this embodiment of the invention, user queries are received and classified into global queries or local queries based on their semantic features. User queries may exhibit differences in semantic needs, ranging from macro-level topic exploration to micro-level detail queries. Directly executing a retrieval without accurate classification can easily lead to mismatches between search results and user needs. Using only global queries may return too much fragmented information, while using local queries may miss crucial details. Therefore, it is necessary to extract multi-dimensional semantic features of the queries and combine them with a pre-trained classification model to achieve automated and accurate classification, providing preliminary support for subsequent retrieval processes adapted to communities of different granularities.

[0101] Step S300 in the method provided in this embodiment of the invention includes:

[0102] The total number of words in the user query is counted, and the total number of words is normalized to obtain the query length feature;

[0103] Identify the number of named entities appearing in the user query, calculate the ratio of the number of named entities to the total number of words, and obtain the entity density feature;

[0104] Identify the number of interrogative words appearing in the user query, calculate the ratio of the number of interrogative words to the total number of words, and obtain the intent clarity feature;

[0105] The query length feature, entity density feature, and intent explicitness feature are combined to form a semantic feature vector of the user query;

[0106] The semantic feature vector is input into a pre-trained classification model, which outputs the classification result of a global query or a local query. The classification model is built based on a neural network model.

[0107] First, the total number of words in the user query is counted, and then normalized to obtain the query length feature. The total number of words refers to the total number of words obtained after word segmentation of the user query text. Normalization is a standardization operation that maps the total number of words to the 0-1 range, eliminating numerical differences between queries of different lengths. The query length feature is a feature value that quantifies the length of the user query text, used to help determine the scope of the query. Natural language processing tools are used to segment the user query, and after removing stop words, the total number of remaining words is counted. A reasonable range for the total number of query words is set, and a normalization formula is constructed based on the maximum and minimum values ​​to convert the actual total number of words into a query length feature value between 0 and 1. The longer the query, the closer the feature value is to 1, and vice versa. For example, a reasonable range for the total number of words in an indoor plant care query is set to 2-10. After word segmentation and removal of stop words, the query "How to deal with yellowing leaves of pothos" yields: pothos, leaves, yellowing, how, how, how, 5 words in total. After normalization, the query length feature value is 0.5. After word segmentation, the query "Indoor plant care" yields: indoor, plant, care, 3 words in total. After normalization, the query length feature value is 0.2.

[0108] Secondly, the number of named entities appearing in the user query is identified, and the ratio of the number of named entities to the total number of words is calculated to obtain the entity density feature. Named entities refer to proper nouns representing specific things in the user query, such as plant varieties, disease names, and care products in the context of indoor plant care. The entity density feature is an indicator that quantifies the density of specific entities in the query; a higher ratio indicates a clearer focus on the specific object of the query. Based on a dictionary for indoor plant care, the BERT named entity recognition model is used to extract named entities from the segmented user query and count their number. The number of named entities is divided by the total number of words in the query to obtain the entity density feature, with a value range of 0-1. For example, in the user query "What to do about yellowing leaves of pothos", the identified named entities are "pothos" and "yellowing leaves", a total of 2, with a total of 5 words, resulting in an entity density feature of 2 / 5 = 0.4; in the user query "Indoor plant care", the identified named entity is "indoor plant", a total of 1, with a total of 3 words, resulting in an entity density feature of 1 / 3 ≈ 0.33.

[0109] Furthermore, the number of interrogative words appearing in user queries is identified, and the ratio of the number of interrogative words to the total number of words is calculated to obtain the intent clarity feature. Interrogative words refer to words in user queries used to express a questioning tone and clarify the direction of the need, such as "how to do," "how," "what," "how long," etc. The intent clarity feature is an indicator that quantifies the clarity of user query needs; a higher ratio indicates that the information the user wants to obtain is more specific. A dictionary of interrogative words for the target scenario is constructed, including words such as "how to do," "how," "suitable," "how much," "what," etc.; the user queries after word segmentation are traversed, and the number of matched interrogative words is counted; the number of interrogative words is divided by the total number of words to obtain the intent clarity feature, with a value range of 0-1. For example, in the user query "What to do about yellowing leaves on a pothos plant," the matched interrogative word is "how to do," with a total of 5 words, so the calculated intent clarity feature = 1 / 5 = 0.2; in the user query "How to control the watering frequency of a spider plant," the matched interrogative word is "how," with a total of 6 words, so the calculated intent clarity feature = 1 / 6 ≈ 0.17.

[0110] Furthermore, the query length feature, entity density feature, and intent clarity feature are combined to form a semantic feature vector for the user query. The semantic feature vector is a numerical vector that integrates multi-dimensional query features, aggregating scattered feature indicators into a unified vector form, facilitating feature learning and processing by the classification model. The query length feature, entity density feature, and intent clarity feature are arranged in a fixed order to construct a three-dimensional semantic feature vector, with the vector format being [query length feature, entity density feature, intent clarity feature]. For example, the query length feature for the user query "What to do about yellowing leaves on pothos" is 0.5, the entity density feature is 0.4, and the intent clarity feature is 0.2, combined to form the semantic feature vector [0.5, 0.4, 0.2]; the query length feature for the user query "Indoor plant care" is 0.2, the entity density feature is 0.33, and the intent clarity feature is 0, combined to form the semantic feature vector [0.2, 0.33, 0].

[0111] Finally, the semantic feature vector is input into a pre-trained classification model, which outputs the classification results of the global or local queries. The classification model is built upon a neural network model. The pre-trained classification model refers to a model trained in advance using a large number of query samples from the field of indoor plant care, possessing mature classification capabilities. The neural network model is a deep learning model built based on neurons; here, a lightweight network structure suitable for feature classification is adopted. Global queries focus on macro-level topics, while local queries focus on specific sub-problems. A convolutional neural network (CNN) is used to construct the classification model. The model's input layer receives a three-dimensional semantic feature vector, extracts feature association information through convolutional layers, maps it to the classification space through fully connected layers, and the output layer uses a softmax function to output the classification probabilities of the global or local queries. The classification model is pre-trained using labeled indoor plant care query samples. When the semantic feature vector is input, the category with the higher probability value is output as the final classification result.

[0112] For example, when the semantic feature vector [0.5, 0.4, 0.2] of a user query "What to do about yellowing leaves of pothos" is input into a pre-trained classification model, the model outputs a probability of 0.85 for local query and 0.15 for global query, and the final classification result is local query; when the semantic feature vector [0.2, 0.33, 0] of a user query "Indoor plant care" is input into the model, the model outputs a probability of 0.92 for global query and 0.08 for local query, and the final classification result is global query.

[0113] In this embodiment of the invention, by extracting three-dimensional semantic features of query length, entity density, and intent explicitness, and combining them with a pre-trained neural network classification model, accurate classification of user queries is achieved, effectively distinguishing the semantic differences between global and local queries. The classification results can accurately adapt to the multi-granularity community structure of the structured summary information database, providing a precise basis for matching parent-level community summaries for global queries and leaf-level community summaries for local queries, avoiding misaligned retrieval directions. Simultaneously, automated classification replaces traditional manual rule-based classification, effectively improving the efficiency and adaptability of query classification, reducing the waste of retrieval resources caused by classification errors, and laying the foundation for subsequent efficient and accurate multimodal retrieval.

[0114] S400: Build an enhanced context based on the user's query category results.

[0115] In this embodiment of the invention, an enhanced context is constructed based on the user query classification results. The enhanced context is the knowledge foundation supporting the generation of accurate answers by a large language model. However, user queries exhibit differences between global macro-level exploration and local detailed queries. If a uniform approach is used to construct the context, the global query context will lack a framework, and the local query context will lack specificity. Furthermore, unoptimized retrieval weights and filtering strategies can result in the context containing redundant information or missing key content, affecting the quality of subsequent answer generation. Therefore, it is necessary to combine the user query classification results with the optimized multimodal retrieval hybrid weights and optimized information filtering thresholds obtained in S200 to customize the enhanced context for both global and local queries, ensuring the accuracy, completeness, and adaptability of the context.

[0116] Step S400 in the method provided in this embodiment of the invention includes:

[0117] For global queries, relevant community summaries are retrieved from the structured summary information database based on the optimized multimodal retrieval hybrid weights, and intermediate answers generated by the large language model are filtered using optimized information filtering thresholds to construct enhanced context.

[0118] For local queries, based on the optimized multimodal retrieval hybrid weight, vector similarity is calculated between the user query and entities and relationships in the knowledge graph, and relevant information is retrieved to construct an enhanced context.

[0119] First, for global queries, relevant community summaries are retrieved from the structured summary information database based on the optimized multimodal retrieval hybrid weights, and intermediate answers generated by the large language model are filtered using optimized information filtering thresholds to construct enhanced context.

[0120] Specifically, for global queries, relevant community summaries are retrieved from the structured summary information database based on the optimized multimodal retrieval hybrid weights, and intermediate answers generated by the large language model are filtered using optimized information filtering thresholds to construct enhanced context, including:

[0121] Based on the optimized multimodal retrieval hybrid weight, multiple community summaries related to the global query semantics are retrieved from the structured summary information database;

[0122] Each relevant community summary is processed in parallel, and an intermediate answer is generated based on the community summary content and global query using a large language model.

[0123] The generated intermediate answers are scored and filtered using the optimized information filtering threshold, and intermediate answers with scores lower than the optimized information filtering threshold are filtered out.

[0124] The selected intermediate answers are sorted in descending order of score from highest to lowest.

[0125] The intermediate answers are added to the context window in descending order until a preset number of tokens is reached, thus forming an enhanced context.

[0126] First, based on the optimized multimodal retrieval hybrid weights, multiple community summaries semantically related to the global query are retrieved from the structured summary information database. The optimized multimodal retrieval hybrid weights are the weight ratios of vector retrieval, graph relationship retrieval, and keyword retrieval obtained in step S200 to suit the scenario. Community summaries are hierarchical summaries of communities at different granularities generated in step S100, covering topical knowledge. The optimized multimodal retrieval hybrid weights are configured into the retrieval system. Using the global query as input, relevant community summaries are retrieved across levels in the structured summary information database, covering the parent-child level, the core leaf level, and other communities, ensuring the comprehensiveness of the retrieval results, and aggregating them to form a set of relevant community summaries. For example, if the optimized multimodal retrieval hybrid weights are [0.5, 0.3, 0.2], and the global query is "indoor plant care methods," the retrieval will match summaries from the overall indoor plant care community (parent-child level), the vine plant care community (parent-child level), and the succulent plant care community (parent-child level), forming a set of relevant community summaries.

[0127] Secondly, each relevant community summary is processed in parallel, and an intermediate answer is generated based on the community summary content and the global query using a large language model. Parallel processing refers to performing generation tasks on multiple community summaries simultaneously to improve processing efficiency. The intermediate answer is a targeted preliminary answer generated by the large language model based on the main content of the community summary and the query requirements, without filtering. A multi-threaded parallel mechanism is adopted, allocating an independent processing thread to each relevant community summary; the community summary content and the global query are used as input, and an intermediate answer is generated by a pre-trained large language model. The answer must be relevant to the community topic and respond to the query requirements. For example, the community summaries on vine care and succulent care are processed in parallel. After inputting into the large language model, the following intermediate answers are generated: Intermediate answer 1: "Vine care requires suitable indirect light or semi-shade environment, control the watering frequency and apply organic fertilizer to prevent diseases such as leaf tip drying"; Intermediate answer 2: "Succulents are suitable for direct light, require the use of granular fertilizer, and avoid waterlogging to prevent root rot"; Intermediate answer 3: "Indoor plants need regular pruning."

[0128] Subsequently, the generated intermediate answers are scored and filtered using the optimized information filtering threshold, discarding those with scores lower than the threshold. The optimized information filtering threshold is a critical value obtained in S200 for filtering highly relevant content. The score is a quantitative value given by the system based on indicators such as semantic relevance and knowledge completeness between the answer and the query. Intermediate answer scoring rules are set, scoring from two dimensions: semantic matching degree and knowledge coverage, with the total score mapped to the 0-1 range. The score of each intermediate answer is compared with the optimized information filtering threshold, retaining intermediate answers with scores not lower than the threshold and discarding low-relevance content. For example, if the optimized information filtering threshold is 0.7, intermediate answer 1 scores 0.85, intermediate answer 2 scores 0.82, and intermediate answer 3, "Indoor plants need regular pruning," scores 0.65, which is lower than the threshold and is filtered out, retaining intermediate answers 1 and 2.

[0129] Furthermore, the selected intermediate answers are sorted in descending order of their scores. This descending order of scores prioritizes high-quality content for contextualization, ensuring core knowledge is prioritized. The scores of the selected intermediate answers are extracted and sorted using a bubble sort algorithm, with the highest-scoring answer at the top, followed by the others in descending order, forming an ordered list of intermediate answers. For example, if intermediate answer 1 has a score of 0.85 and intermediate answer 2 has a score of 0.82, the descending sorted list would be: [Intermediate answer 1 (0.85), Intermediate answer 2 (0.82)].

[0130] Finally, intermediate answers are added to the context window in descending order until a preset number of tokens is reached, forming the enhanced context. The context window is a capacity threshold used to limit the length of the enhanced context. The preset number of tokens is an upper limit on the number of semantic units set to balance answer quality and model processing efficiency. The enhanced context is a structured set of knowledge formed by integrating the sorted intermediate answers. An empty context window is initialized, and intermediate answers are added to the window in order of sorting, with the number of tokens counted in real time. When the number of tokens exceeds the preset value after adding an answer, adding more tokens stops, and the content in the window at this point constitutes the enhanced context. For example, the preset token count is 120. The intermediate answer 1 has 55 tokens, which does not exceed the threshold after being added. If intermediate answer 2 (48 tokens) is added, the total token count will be 103, which also does not exceed the threshold. If no further answers meet the conditions, the final enhanced context will be the combined content of intermediate answer 1 and intermediate answer 2, such as: Climbing plants need to be adapted to diffused light or semi-shade environment, control the watering frequency and apply organic fertilizer to prevent diseases such as leaf tip drying; Succulents are suitable for direct sunlight, need to use granular fertilizer, and avoid waterlogging to prevent root rot.

[0131] Secondly, for local queries, based on the optimized multimodal retrieval hybrid weight, vector similarity is calculated between the user query and entities and relationships in the knowledge graph, and relevant information is retrieved to construct an enhanced context.

[0132] For local queries, based on the optimized multimodal retrieval hybrid weights, vector similarity is calculated between the user query and entities and relationships in the knowledge graph, and relevant information is retrieved to construct an enhanced context, including:

[0133] Based on the vector retrieval weight in the optimized multimodal retrieval hybrid weight, the cosine similarity between the user query vector and the entity vector and relation vector in the knowledge graph is calculated, and the mean is calculated to obtain the vector similarity score.

[0134] Based on the graph relation retrieval weight in the optimized multimodal retrieval hybrid weight, multi-hop relation paths related to the user query semantics are retrieved in the knowledge graph, and the graph relation path relevance is calculated;

[0135] Based on the keyword retrieval weight in the optimized multimodal retrieval hybrid weight, the keyword overlap between the user query and the text content in the knowledge graph is calculated to obtain the keyword matching degree;

[0136] Based on the weight allocation ratio in the optimized multimodal retrieval hybrid weight, the vector similarity score, graph relationship path relevance, and keyword matching degree are weighted and summed to obtain the comprehensive retrieval score;

[0137] Based on the comprehensive search score, the optimal search result is selected, and the corresponding node attributes, relationship description text and related text fragments are extracted from the knowledge graph and combined to form an enhanced context.

[0138] First, based on the vector retrieval weight in the optimized multimodal retrieval hybrid weight, the cosine similarity between the user query vector and the entity vectors and relation vectors in the knowledge graph is calculated, and the mean is calculated to obtain the vector similarity score. The vector retrieval weight is the proportion allocated to vector retrieval in the optimized multimodal retrieval hybrid weight. The user query vector is a low-dimensional dense vector transformed from the user query using a word vector model. Cosine similarity is an indicator that measures the consistency of the direction between two vectors, ranging from 0 to 1; the larger the value, the stronger the association. The local query is transformed into a query vector using a pre-trained word vector model; all entity vectors and relation vectors in the knowledge graph are extracted, and the cosine similarity between the query vector and these vectors is calculated one by one; the mean of all similarities is taken as the vector similarity score. For example, the local query is "What to do about yellowing leaves on a pothos plant," which, after being transformed into a query vector, has cosine similarities of 0.92, 0.88, and 0.85 with the entity vectors "pothos," "yellowing leaves," and the relation vector "cause," respectively, with a mean of 0.88, i.e., a vector similarity score of 0.88.

[0139] Secondly, based on the graph relation retrieval weight in the optimized multimodal retrieval hybrid weight, multi-hop relation paths related to the user query semantics are retrieved in the knowledge graph, and the graph relation path relevance is calculated.

[0140] Specifically, based on the graph relation retrieval weight in the optimized multimodal retrieval hybrid weight, multi-hop relation paths semantically related to the user query are retrieved in the knowledge graph, and the graph relation path relevance is calculated, including:

[0141] Identify all entities in the user query, count the frequency of each entity, and calculate the centrality index of each entity based on the topological structure of the knowledge graph.

[0142] Based on the weighted sum of the frequency score and centrality index, the entity with the highest score is selected as the principal entity.

[0143] The maximum number of hops for path exploration is determined based on the graph relationship retrieval weight in the optimized multimodal retrieval hybrid weight;

[0144] Starting with the main entity, multi-hop relationship paths are explored in the knowledge graph, all reachable relationship paths are recorded, and a candidate path set is formed.

[0145] Based on the optimized information filtering threshold, the relational paths in the candidate path set are filtered to obtain the filtered path set;

[0146] Based on the relation weights and path lengths in the knowledge graph, calculate the path confidence of each relation path in the filtered path set;

[0147] The semantic relevance is obtained by calculating the degree of matching between the relation sequence of each relation path in the set of filtered paths and the semantic feature vector of the user query.

[0148] Based on the graph relationship retrieval weight in the optimized multimodal retrieval hybrid weight, the path confidence and semantic relevance are weighted and fused to obtain the graph relationship path relevance score.

[0149] First, all entities in the user query are identified, their frequency of occurrence is counted, and the centrality index of each entity is calculated based on the topological structure of the knowledge graph. Entity frequency is the number of times an entity appears in the user query. The topological structure of the knowledge graph refers to the way nodes and edges are connected in the knowledge graph. The centrality index measures the importance of an entity in the knowledge graph; here, it is the number of edges associated with the entity. The BERT named entity recognition model is used to extract all entities in the user query, and the frequency of occurrence of each entity is counted. Based on the adjacency matrix of the knowledge graph, the number of nodes directly connected to each entity is calculated as the centrality index. For example, in the local query "What to do about yellowing leaves of pothos", the entities "pothos" and "yellowing leaves" are identified, both with a frequency of 1. There are 3 edges associated with "pothos" in the knowledge graph: suitable for diffused light environment, requires application of general-purpose fertilizer, and easily causes yellowing leaves, with a centrality of 3. There are 2 edges associated with "yellowing leaves": caused by overwatering and the solution is to adjust the watering frequency, with a centrality of 2.

[0150] Secondly, based on the weighted sum of the frequency of occurrence score and the centrality index, the entity with the highest score is selected as the principal entity. The frequency of occurrence score is the normalized value of the entity's occurrence frequency. The weighted sum is the comprehensive score calculated after assigning weights to the two indices. The principal entity is the core entity in the user query and the entity with the strongest influence in the knowledge graph, serving as the starting point for path exploration. The entity frequency of occurrence and the centrality index are normalized to the 0-1 range, with a weight of 0.4 for the frequency of occurrence score and 0.6 for the centrality index. The comprehensive score of each entity is calculated, and the entity with the highest comprehensive score is selected as the principal entity. For example, the frequency score of the pothos is 1.0, the maximum degree centrality of the entity in the knowledge graph is 5, the centrality index score is 3 / 5=0.6, and the overall score is 1.0×0.4+0.6×0.6=0.76; the frequency score of yellowing leaves is 1.0, the centrality index score is 2 / 5=0.4, and the overall score is 1.0×0.4+0.4×0.6=0.64; 0.76>0.64, so the pothos is selected as the main entity.

[0151] Next, the maximum number of hops for path exploration is determined based on the graph relationship retrieval weights in the optimized multimodal retrieval hybrid weights. The maximum number of hops is the upper limit of the number of relationship connections allowed during path exploration. More hops result in more comprehensive relationship path coverage, but also higher computational complexity. A hop number mapping rule is set: the graph relationship retrieval weights are positively correlated with the maximum number of hops. A weight of 0-0.2 corresponds to 1 hop, 0.2-0.4 corresponds to 2 hops, and 0.4-1.0 corresponds to 3 hops. The maximum number of hops is determined based on the optimized graph relationship retrieval weights. For example, if the graph relationship retrieval weight in the optimized multimodal retrieval hybrid weights is 0.3, falling within the 0.2-0.4 range, the maximum number of hops for path exploration is determined to be 2 hops.

[0152] Subsequently, starting from the main entity, multi-hop relationship paths are explored in the knowledge graph, recording all reachable relationship paths to form a candidate path set. Path exploration starts from the main entity and traverses all connected entities and relationships in the knowledge graph according to the maximum number of hops. The candidate path set is a set containing all relationship paths that meet the hop count requirement, without filtering. A depth-first search algorithm is used, starting from the main entity, to traverse 1-hop and 2-hop relationship paths in the knowledge graph sequentially, recording the starting point, intermediate entities, ending point, and relationship type of each path; after removing duplicate paths, a candidate path set is formed. For example, starting with pothos, with a maximum hop count of 2, the following candidate path sets are obtained: Path 1 (Pothos - prone to - leaf yellowing), Path 2 (Pothos - suitable - diffused light environment), Path 3 (Pothos - prone to - leaf yellowing - solution - adjust watering frequency).

[0153] Then, based on the optimized information filtering threshold, the relational paths in the candidate path set are filtered to obtain a filtered path set. The filtered path set is the set of relational paths that are semantically compatible with the user query after removing low-relevance paths. A semantic relevance score is calculated for each candidate path and the user query, based on the degree of matching between the relationships in the path and the query. The score is compared with the optimized information filtering threshold, and paths with scores not lower than the threshold are retained to form the filtered path set. For example, if the optimized information filtering threshold is 0.7, path 1 has a score of 0.85, path 2 has a score of 0.6, and path 3 has a score of 0.9, path 2 is removed, and the filtered path set is {path 1, path 3}.

[0154] Furthermore, based on the relation weights and path lengths in the knowledge graph, the path confidence score for each relation path in the filtered path set is calculated. Path confidence score is an indicator that quantifies the reliability of a relation path; the higher the relation weight and the shorter the path, the higher the confidence score. Path confidence score = sum of all relation weights in the path / path length, where path length refers to the number of relations in the path. The path confidence score ranges from 0 to 1. For example, path 1 has a relation weight of 0.82 and a path length of 1, so its path confidence score is 0.82 / 1 = 0.82; path 3 has a relation weight sum of 0.82 + 0.9 = 1.72 and a path length of 2, so its path confidence score is 1.72 / 2 = 0.86.

[0155] Based on this, the semantic relevance is obtained by calculating the matching degree between the relation sequence of each relation path in the filtered path set and the semantic feature vector of the user query. A relation sequence is a sequence of all relations in the relation path arranged in order. Semantic relevance is an indicator that measures the semantic fit between the relation sequence and the user query. The relation sequence of each path is transformed into a low-dimensional vector, and a cosine similarity is calculated between it and the semantic feature vector of the user query. This similarity is the semantic relevance, with a value ranging from 0 to 1. For example, the semantic feature vector of the user query "What to do about yellowing leaves on pothos" is [0.5, 0.4, 0.2]. The cosine similarity between the relation sequence vector of path 1 and the query vector is 0.88, and the semantic relevance is 0.88; the cosine similarity between the relation sequence vector of path 3 and the query vector is 0.92, and the semantic relevance is 0.92.

[0156] Finally, based on the graph relationship retrieval weight in the optimized multimodal retrieval hybrid weighting, the path confidence and semantic relevance are weighted and fused to obtain the graph relationship path relevance score. The graph relationship path relevance score is a comprehensive indicator integrating path confidence and semantic relevance, used to measure the overall suitability of relationship paths. A path confidence weight of 0.4 and a semantic relevance weight of 0.6 are set, and their weighted sum is used to obtain the relevance score for each path. If the selected path set contains multiple paths, the highest score is taken as the final graph relationship path relevance score. For example, the relevance score for path 1 = 0.82 × 0.4 + 0.88 × 0.6 = 0.856; the relevance score for path 3 = 0.86 × 0.4 + 0.92 × 0.6 = 0.896; the final graph relationship path relevance score is 0.896.

[0157] Furthermore, based on the keyword retrieval weight in the optimized multimodal retrieval hybrid weighting, the keyword overlap between the user query and the text content in the knowledge graph is calculated to obtain the keyword matching degree. The keyword retrieval weight is the proportion allocated to keyword retrieval in the optimized multimodal retrieval hybrid weighting. The keyword overlap is the proportion of keywords in the query and keywords in the knowledge graph text content that overlap. Keywords from the local query are extracted to construct a keyword set; a keyword set from the text content in the knowledge graph is extracted; the ratio of the intersection of the two sets to the number of query keywords is calculated as the keyword matching degree. For example, if the keyword set of the local query is {Pothos, yellowing leaves, solutions}, and the keyword set of the related text in the knowledge graph is {Pothos, yellowing leaves, watering frequency, solutions}, the intersection is 3, the number of query keywords is 3, and the keyword matching degree is 1.0.

[0158] Furthermore, based on the weight allocation ratio in the optimized multimodal retrieval hybrid weight, the vector similarity score, graph relationship path relevance, and keyword matching degree are weighted and summed to obtain the comprehensive retrieval score. The comprehensive retrieval score is a quantitative score that integrates the three dimensions of retrieval indicators, used to measure the overall suitability of the retrieval results; a higher score indicates a better result. The vector retrieval weight, graph relationship retrieval weight, and keyword retrieval weight in the optimized multimodal retrieval hybrid weight are extracted, multiplied by their corresponding scores using these three as coefficients, and then summed to obtain the comprehensive retrieval score. For example, if the optimized multimodal retrieval hybrid weight is [0.5, 0.3, 0.2], the vector similarity score is 0.88, the graph relationship path relevance is 0.896, and the keyword matching degree is 1.0, the comprehensive retrieval score = 0.88 × 0.5 + 0.896 × 0.3 + 1.0 × 0.2 ≈ 0.91.

[0159] Finally, based on the comprehensive search score, the optimal search result is selected. Corresponding node attributes, relationship description text, and related text fragments are extracted from the knowledge graph and combined to form an enhanced context. The optimal search result is the set of search content with the highest comprehensive search score, containing the entities, relationships, and text information most relevant to the query. Node attributes are the characteristic information of entities, such as the watering frequency of pothos. The comprehensive search scores of all search results are compared, and the highest score is selected as the optimal search result. The entity node attributes, relationship link description text, and associated community summary fragments corresponding to this result are extracted from the knowledge graph and integrated in the order of attribute-relationship-text fragment to form an enhanced context. For example, the optimal search result corresponds to a comprehensive search score of 0.91. The node attribute "Pothos: watering frequency once a week," the relationship description text "Pothos is prone to leaf yellowing; the solution to leaf yellowing is to adjust the watering frequency," and the related text fragment "Pothos is suitable for indirect light environments; applying general-purpose fertilizers can reduce disease occurrence" are extracted and combined to form an enhanced context.

[0160] In this embodiment of the invention, to address the differentiated needs of global and local queries, an enhanced context is custom-constructed by combining optimized multimodal retrieval hybrid weights and information filtering thresholds. Global queries ensure the context's framework and comprehensiveness through multi-community summary integration and filtering ranking; local queries accurately extract core attributes and relationship information from the knowledge graph through multi-dimensional retrieval index weighted calculations, ensuring the context's relevance and detailed completeness. The constructed enhanced context effectively eliminates redundant information and supplements core knowledge, adapting to the processing needs of large language models and providing solid support for generating logically coherent and accurate answers. It also avoids the blind construction of context, improving the overall collaborative efficiency of the retrieval and generation process.

[0161] S500: Input the enhanced context into the large language model to generate the final answer.

[0162] In this embodiment of the invention, the enhanced context is input into a large language model to generate the final answer. By inputting the enhanced context into the large language model, and leveraging the semantic understanding and text generation capabilities of the large language model, structured knowledge is transformed into a final natural language answer that meets the requirements and conforms to professional standards.

[0163] First, the enhanced context obtained from S400 is preprocessed to remove redundant statements, adjust the content order, and front-load core knowledge into plain text format. Then, the parameters of the large language model are configured, setting a temperature coefficient of 0.3-0.5, a suitable maximum generation length, and a Top-P value of 0.8 to ensure accurate and logically coherent answers. Next, a Prompt is constructed, specifying that the instruction model generates professional and easy-to-understand answers based on the enhanced context for user queries. The Prompt and the preprocessed enhanced context are integrated into complete input content. Finally, the input content is fed into the pre-trained large language model, which parses the instructions, extracts core knowledge, and directly outputs the final answer. For example, after preprocessing the enhanced context for the local query "What to do about yellowing leaves on pothos," the input model generates the answer "Yellowing leaves on pothos can be solved by adjusting the watering frequency. The normal watering frequency is once a week. Placing it in a diffused light environment and applying a general-purpose fertilizer can reduce the occurrence of diseases." For the global query "Indoor plant care methods," differentiated care answers are generated for vines and succulents.

[0164] In this embodiment of the invention, through a streamlined enhanced context processing and large language model input process, the generated final answer accurately matches the user's global or local query needs, combining domain expertise with natural fluency, effectively avoiding problems such as model-fabricated information and knowledge bias. The answer is easy to understand and adaptable to users with different knowledge levels, achieving both efficient conversion of structured knowledge into practical natural language and improving the user query experience.

[0165] Through the specific implementation methods described above, the embodiments of the present invention achieve the following technical effects:

[0166] This invention provides an enhanced retrieval generation optimization method that integrates knowledge graphs. It addresses the problem of knowledge fragmentation by constructing a multi-granularity community-structured summary information database, avoids the limitations of manual parameters by optimizing multimodal retrieval weights and filtering thresholds, clarifies the retrieval direction through precise classification of global and local queries, and provides accurate knowledge support through customized construction of enhanced context, ultimately generating professional and fluent final answers. The entire process achieves a closed loop from knowledge structure integration, intelligent parameter optimization, accurate query matching to efficient answer generation, effectively improving knowledge retrieval efficiency and accuracy, avoiding bias in model-generated content, balancing answer professionalism and readability, and realizing adaptive optimization of the retrieval generation process, effectively enhancing the user query experience.

[0167] It should be noted that the order of the above embodiments of the present invention is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, the above description focuses on specific embodiments of this specification. Additionally, the processes depicted in the accompanying drawings do not necessarily require a specific or sequential order to achieve the desired results. In some embodiments, multitasking and parallel processing are possible or may be advantageous.

[0168] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

[0169] This specification and accompanying drawings are merely illustrative examples of the invention and are intended to cover any and all modifications, variations, combinations, or equivalents within the scope of the invention. Clearly, those skilled in the art can make various alterations and modifications to the invention without departing from its scope. Therefore, if such modifications and modifications fall within the scope of the invention and its equivalents, the invention is intended to include these modifications and modifications.

Claims

1. An enhanced retrieval generation optimization method integrating knowledge graphs, characterized in that, include: A knowledge graph containing entities, attributes, and relationships is constructed from the data source. The knowledge graph is then divided into communities, and multi-level community summaries are generated for each community to form a structured summary information database. The particle swarm optimization algorithm is used to jointly optimize the multimodal retrieval hybrid weight and the information filtering threshold to obtain optimized multimodal retrieval hybrid weight and optimized information filtering threshold. The multimodal retrieval hybrid weight includes vector retrieval weight, graph relationship retrieval weight and keyword retrieval weight. Receive user queries and classify them into global queries or local queries based on their semantic features; Build enhanced context based on user query categorization results; The enhanced context is input into the large language model to generate the final answer; This includes receiving user queries and classifying them into global or local queries based on their semantic features, including: The total number of words in the user query is counted, and the total number of words is normalized to obtain the query length feature; Identify the number of named entities appearing in the user query, calculate the ratio of the number of named entities to the total number of words, and obtain the entity density feature; Identify the number of interrogative words appearing in the user query, calculate the ratio of the number of interrogative words to the total number of words, and obtain the intent clarity feature; The query length feature, entity density feature, and intent explicitness feature are combined to form a semantic feature vector of the user query; The semantic feature vector is input into a pre-trained classification model, which outputs the classification result of a global query or a local query. The classification model is built based on a neural network model. This includes constructing enhanced context based on user query classification results, including: For global queries, relevant community summaries are retrieved from the structured summary information database based on the optimized multimodal retrieval hybrid weights, and intermediate answers generated by the large language model are filtered using optimized information filtering thresholds to construct enhanced context. For local queries, based on the optimized multimodal retrieval hybrid weight, vector similarity is calculated between the user query and entities and relationships in the knowledge graph, and relevant information is retrieved to construct an enhanced context; For local queries, based on the optimized multimodal retrieval hybrid weights, vector similarity is calculated between the user query and entities and relationships in the knowledge graph, and relevant information is retrieved to construct an enhanced context, including: Based on the vector retrieval weight in the optimized multimodal retrieval hybrid weight, the cosine similarity between the user query vector and the entity vector and relation vector in the knowledge graph is calculated, and the mean is calculated to obtain the vector similarity score. Based on the graph relation retrieval weight in the optimized multimodal retrieval hybrid weight, multi-hop relation paths related to the user query semantics are retrieved in the knowledge graph, and the graph relation path relevance is calculated; Based on the keyword retrieval weight in the optimized multimodal retrieval hybrid weight, the keyword overlap between the user query and the text content in the knowledge graph is calculated to obtain the keyword matching degree; Based on the weight allocation ratio in the optimized multimodal retrieval hybrid weight, the vector similarity score, graph relationship path relevance, and keyword matching degree are weighted and summed to obtain the comprehensive retrieval score; Based on the comprehensive search score, the optimal search result is selected, and the corresponding node attributes, relationship description text and related text fragments are extracted from the knowledge graph and combined to form an enhanced context.

2. The enhanced retrieval generation optimization method based on knowledge graph fusion according to claim 1, characterized in that, A knowledge graph containing entities, attributes, and relationships is constructed from the data source. This knowledge graph is then divided into communities, and multi-level community summaries are generated for each community, forming a structured summary information database, including: Extract entities, attributes, and relationships from both structured and unstructured data sources; Instantiate entities as nodes, instantiate attributes as node attributes, and instantiate relationships as edges; Based on the co-occurrence frequency of relations in the data source, relation weights are assigned to relation edges to form a knowledge graph containing nodes, node attributes, edges, and relation weights. A graph neural network algorithm is used to learn node embedding representations for the knowledge graph; Based on node embedding vectors, a hierarchical clustering algorithm is used to perform multi-granularity community partitioning of the knowledge graph. A hierarchical summary, including leaf-level community summaries and parent-level community summaries, is generated for each community using a large language model; The generated hierarchical community summaries are organized and stored according to the community hierarchy to form a structured summary information database.

3. The enhanced retrieval generation optimization method based on knowledge graph fusion according to claim 1, characterized in that, The particle swarm optimization algorithm is used to jointly optimize the multimodal retrieval hybrid weights and the information filtering threshold, resulting in optimized multimodal retrieval hybrid weights and optimized information filtering thresholds, including: Based on the structured summary information database, a verification query set containing global query samples and local query samples is constructed; Define the particle search space, where the position vector of each particle contains two components: a multimodal retrieval hybrid weight and an information filtering threshold. Construct a fitness function, wherein the fitness function includes a retrieval quality assessment component, a generation quality assessment component, and an efficiency assessment component; Based on the verification query set, the optimal particle position that maximizes the fitness function is searched in the particle search space using the particle swarm optimization algorithm. The multimodal retrieval hybrid weight component in the optimal particle position is used as the optimized multimodal retrieval hybrid weight, and the information filtering threshold component is used as the optimized information filtering threshold.

4. The enhanced retrieval generation optimization method based on knowledge graph fusion according to claim 3, characterized in that, Constructing the fitness function includes: The search is performed based on the multimodal search hybrid weights at the current particle position to obtain the search result community set; Calculate the similarity between the search result community set and the standard community set to obtain the community coverage score; The relationship recall score is obtained by calculating the matching ratio between the relationship paths contained in the community set of search results and the standard relationship path set. The community coverage score and the relationship recall score are weighted and fused to obtain the retrieval quality assessment component; Based on the information filtering threshold at the current particle position, intermediate answers generated by the large language model are filtered to obtain the final answer; Analyze the hierarchical distribution of the community summary cited in the final answer and calculate the coverage depth score; The overlap ratio between entities used in the final answer and entities in the enhanced context is statistically analyzed, and the context utilization score is calculated. The coverage depth score and context utilization score are weighted and fused to obtain the generation quality assessment component; Measure the response time from receiving a query to generating an answer, and calculate a response efficiency score based on the preset optimal response time; The number of tokens in the constructed enhanced context is counted, and a context efficiency score is calculated based on the preset optimal number of tokens; The response efficiency score and the context efficiency score are weighted and fused to obtain the efficiency evaluation component; The retrieval quality assessment component, generation quality assessment component, and efficiency assessment component are weighted and summed according to preset weights to obtain the fitness function.

5. The enhanced retrieval generation optimization method based on knowledge graph fusion according to claim 3, characterized in that, Based on the verification query set, the optimal particle position that maximizes the fitness function is searched in the particle search space using a particle swarm optimization algorithm, including: The fitness function value of each particle is calculated based on the verification query set; Based on the particle's historical best position and the group's global best position, combined with inertia weights and learning factors, the particle's velocity vector and position vector are updated. When the fitness function value no longer improves after a preset number of iterations, a random perturbation is applied to the particle position based on the community structure of the knowledge graph. The magnitude of the inertia weight is dynamically adjusted based on the changing trend of the fitness function value during the iteration process. Through multiple iterative searches, the optimal particle position that maximizes the fitness function is determined.

6. The enhanced retrieval generation optimization method based on knowledge graph fusion according to claim 1, characterized in that, For global queries, relevant community summaries are retrieved from the structured summary information database based on the optimized multimodal retrieval hybrid weights, and intermediate answers generated by the large language model are filtered using optimized information filtering thresholds to construct enhanced context, including: Based on the optimized multimodal retrieval hybrid weight, multiple community summaries related to the global query semantics are retrieved from the structured summary information database; Each relevant community summary is processed in parallel, and an intermediate answer is generated based on the community summary content and global query using a large language model. The generated intermediate answers are scored and filtered using the optimized information filtering threshold, and intermediate answers with scores lower than the optimized information filtering threshold are filtered out. The selected intermediate answers are sorted in descending order of score from highest to lowest. The intermediate answers are added to the context window in descending order until a preset number of tokens is reached, thus forming an enhanced context.

7. The enhanced retrieval generation optimization method based on knowledge graph fusion according to claim 1, characterized in that, Based on the graph relation retrieval weights in the optimized multimodal retrieval hybrid weights, multi-hop relation paths semantically related to the user query are retrieved in the knowledge graph, and the graph relation path relevance is calculated, including: Identify all entities in the user query, count the frequency of each entity, and calculate the centrality index of each entity based on the topological structure of the knowledge graph. Based on the weighted sum of the frequency score and centrality index, the entity with the highest score is selected as the principal entity. The maximum number of hops for path exploration is determined based on the graph relationship retrieval weight in the optimized multimodal retrieval hybrid weight; Starting with the main entity, multi-hop relationship paths are explored in the knowledge graph, all reachable relationship paths are recorded, and a candidate path set is formed. Based on the optimized information filtering threshold, the relational paths in the candidate path set are filtered to obtain the filtered path set; Based on the relation weights and path lengths in the knowledge graph, calculate the path confidence of each relation path in the filtered path set; The semantic relevance is obtained by calculating the degree of matching between the relation sequence of each relation path in the set of filtered paths and the semantic feature vector of the user query. Based on the graph relationship retrieval weight in the optimized multimodal retrieval hybrid weight, the path confidence and semantic relevance are weighted and fused to obtain the graph relationship path relevance score.

Citation Information

Patent Citations

  • Information processing method

    CN120316073A

  • Intelligent positioning and early warning control method and system for ground wire in electric power operation

    CN120952554A