Method and system for generating community policing risk compensation measures based on graph search enhancement generation
By constructing a knowledge graph and vector database in the field of community security risks, and using a large language model for semantic segmentation and entity relation extraction, the problem of large models lacking specific domain knowledge is solved, enabling efficient and accurate generation of risk compensation measures and improving the interpretability of the generated results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CITIC GUOAN INFORMATION TECH
- Filing Date
- 2025-12-15
- Publication Date
- 2026-05-29
AI Technical Summary
Existing technologies often lack domain-specific knowledge in large models, resulting in poor effectiveness of generated community security risk compensation measures. Furthermore, fixed-length segmentation leads to semantic loss and noise, affecting the accuracy and reliability of the generated results.
This paper adopts a graph retrieval-based enhanced generation method, which constructs a knowledge graph and vector database in the field of community security risk through semantically aware adaptive text segmentation and predefined entity relationships. It then uses a large language model for query parsing and knowledge retrieval to generate reasonable and effective compensation measures.
It improves the accuracy and interpretability of risk compensation measures, ensures the semantic integrity of the text, and enables more efficient and accurate generation of risk compensation measures.
Smart Images

Figure CN122115175A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of security risk technology, and in particular to a method and system for generating community security risk compensation measures based on graph retrieval enhancement. Background Technology
[0002] Assessing and managing security risks in urban communities is a crucial aspect of public safety operations. Typically, risk assessments are used to evaluate security conditions, and based on the assessment results and operational experience, appropriate risk compensation measures are proposed manually. However, with the development of artificial intelligence, large-scale models are increasingly being used to generate risk compensation measures. While using large models to generate security risk compensation measures offers advantages such as high efficiency and fast response times, general-purpose large models lack domain-specific knowledge, resulting in less effective risk compensation measures. Summary of the Invention
[0003] The purpose of this application is to provide a method and system for generating community security risk compensation measures based on graph retrieval enhancement, so as to solve or alleviate the problems existing in the prior art.
[0004] To achieve the above objectives, this application provides the following technical solution: This application provides a method for generating community security risk compensation measures based on graph retrieval enhancement, comprising: performing text segmentation and vectorization on the acquired domain knowledge data of the security risk domain, generating knowledge slices and their corresponding knowledge vectors of the security risk domain and storing them in a vector database; constructing a domain knowledge graph of the community security risk domain, and storing the index relationship between the domain knowledge graph and the knowledge vectors in the vector database to construct a domain knowledge base of the security risk domain; parsing user risk queries through a large language model, retrieving risk elements related to user risk queries in the domain knowledge graph, and retrieving knowledge slices corresponding to risk elements in the domain knowledge base according to the index relationship to generate security risk compensation measures corresponding to user risk queries.
[0005] Preferably, the acquired domain knowledge data in the security risk domain is cleaned, deduplicated, and transformed into structured text data in a predefined format to obtain a domain dataset in the security risk domain; the structured text data is traversed by a pre-trained language model, and knowledge text segmentation is performed on the structured text data according to the text semantics; the segmented slices are vectorized using an embedding model to generate knowledge slices in the security risk domain and stored in a vector database.
[0006] Preferably, a domain knowledge graph for the security risk domain is constructed by performing named entity recognition and relation extraction on the domain knowledge data in the domain dataset through a pre-trained language model.
[0007] Preferably, a pre-trained language model is used to perform preliminary named entity recognition and relation extraction on a portion of the domain knowledge data in the domain dataset, automatically summarizing the potential entity and relation types in the security risk domain, and forming a draft of entity and relation types in the security risk domain; By merging semantic duplicates, revising relationship definitions, supplementing key attributes, and removing noise from the draft entities and relationships, predefined entity types and predefined entity relationships in the security risk domain are established. Using predefined entity types and predefined entity relationships as standards, named entity recognition and relation extraction are performed through a pre-trained language model to generate triple data in the security risk domain, and a domain knowledge graph in the security risk domain is constructed using a graph database.
[0008] Preferably, based on the mapping relationship between the domain knowledge graph and the knowledge slices in the vector database, an index relationship is established between the graph database and the vector database and stored in the vector database.
[0009] Preferably, the user risk query is parsed using a large language model, and based on the parsing results, risk elements related to the user risk query are retrieved from the domain knowledge graph. Based on the risk control relationships between entities within the domain knowledge graph, retrieve the risk measures corresponding to the risk elements related to the user's risk query; Based on the index relationship, knowledge slices of risk elements are retrieved from the vector database, and corresponding security risk compensation measures are generated by combining the retrieved knowledge slices with user risk queries through a large language model.
[0010] This embodiment also provides a community security risk compensation measure generation system based on graph retrieval enhancement, which processes user risk queries using any of the above-described community security risk compensation measure generation methods based on graph retrieval enhancement. The system includes: The vectorization unit is configured to perform text segmentation and vectorization on the acquired domain knowledge data of the security risk domain, generate knowledge slices of the security risk domain and their corresponding knowledge vectors, and store them in the vector database. The knowledge base unit is configured to construct a domain knowledge graph for the community security risk domain and store the index relationship between the domain knowledge graph and knowledge vectors in a vector database to construct a domain knowledge base for the security risk domain. The query compensation unit is configured to parse user risk queries using a large language model, retrieve risk elements related to the user risk query in the domain knowledge graph, and retrieve knowledge slices corresponding to the risk elements in the domain knowledge base according to the index relationship, so as to generate security risk compensation measures corresponding to the user risk query.
[0011] Beneficial effects: The community security risk compensation measure generation method and system based on graph retrieval enhancement provided in this application embodiment performs text segmentation and vectorization on the acquired domain knowledge data of the security risk domain to generate knowledge slices and their corresponding knowledge vectors for the security risk domain, and stores them in a vector database. Simultaneously, a domain knowledge graph of the community security risk domain is constructed, and the index relationship between the domain knowledge graph and the knowledge vectors is stored in the vector database to build a domain knowledge base for the security risk domain. Furthermore, a large language model is used to parse user risk queries, retrieve risk elements related to the user risk query from the domain knowledge graph, and retrieve the corresponding knowledge slices of the risk elements from the domain knowledge base according to the index relationship to generate security risk compensation measures corresponding to the user risk query.
[0012] Therefore, on the one hand, based on knowledge in the field of community security, a large-scale model based on semantic segmentation is used to segment the domain knowledge text according to the natural language meaning of the knowledge text, effectively ensuring that the semantics of the text remain intact during the segmentation process, avoiding the semantic loss problem caused by fixed-length segmentation in existing technologies; on the other hand, a knowledge graph in the field of community security risks is constructed, and an index relationship is established between the domain knowledge graph and knowledge vectors, providing a more comprehensive and accurate knowledge foundation for generating risk compensation measures in the field of community security risks.
[0013] On the other hand, after the segmented slices are vectorized, the knowledge text slices and their corresponding knowledge vectors are stored together in a vector database. An index relationship is established between the knowledge graph and knowledge vectors in the community security risk domain, and this relationship is stored in the vector database, realizing the mapping between the knowledge graph and the knowledge blocks in the vector database. In the enhanced retrieval generation process, when a user queries a professional question in the community security domain, the user's query field is segmented and quantized using a large language model. Based on the user's query intent, the index relationship between knowledge vectors and the knowledge graph is used to retrieve knowledge vectors with high similarity to the user's query field (i.e., risk elements). Then, corresponding security risk compensation measures are generated through the corresponding knowledge slices, effectively improving the efficiency and accuracy of user query retrieval, and making the generated risk compensation measures more reasonable, effective, and interpretable. Attached Figure Description
[0014] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. Wherein: Figure 1 This is a flowchart illustrating a method for generating community security risk compensation measures based on graph retrieval enhancement, according to some embodiments of this application. Figure 2 This is a logical schematic diagram of a community security risk compensation measure generation method based on graph retrieval enhancement provided according to some embodiments of this application; Figure 3 This is a schematic diagram illustrating the principle of a community security risk compensation measures generation system based on graph retrieval enhancement, according to some embodiments of this application. Figure 4 This is a schematic diagram of the structure of a community security risk compensation measure generation system based on graph retrieval enhancement provided according to some embodiments of this application. Detailed Implementation
[0015] The present application will now be described in detail with reference to the accompanying drawings and embodiments. Various examples are provided by way of explanation and not by way of limitation. In fact, those skilled in the art will understand that modifications and variations can be made to the present application without departing from the scope or spirit of the present application. For example, a feature shown or described as part of one embodiment may be used in another embodiment to produce yet another embodiment. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention should fall within the scope of protection of the embodiments of the present invention.
[0016] Currently, the method for generating security risk compensation measures using large models involves directly inputting the risk factors from risk assessments into the large model. The model then generates the compensation measures based on pre-trained parameters. While this method is efficient and fast, the lack of domain-specific knowledge in the large model results in poor effectiveness of the generated compensation measures. To address this, a retrieval-enhanced generation method has been developed to improve the large model's ability to retrieve knowledge in specific domains and generate accurate answers.
[0017] The retrieval-enhanced generation method segments domain-specific knowledge text, then vectorizes the resulting slices (blocks), and finally stores the knowledge text slices (blocks) and their corresponding vectors in a vector database. When a user inquires about a domain-specific question, the large model first segments and quantizes the query field, then retrieves vectors with high similarity to the query field slice (block) vectors from the vector database. Finally, based on the mapping relationship between vectors and knowledge text slices (blocks) in the database, the large model retrieves the most relevant knowledge text slice (block) to the user's inquiry and uses it to generate the answer.
[0018] However, existing retrieval-enhanced generation methods employ fixed-length segmentation, treating knowledge text as an undifferentiated sequence of characters and dividing it equally based solely on a preset number of tokens (e.g., 256 tokens, 512 tokens), ignoring the inherent semantic units and logical structure of natural language. This mechanical and formalized text processing paradigm creates fragments within complete sentences, paragraphs, and even keywords, causing the generated text slices to lose their original context and semantics. The direct consequence is that the vector database stores not complete knowledge concepts, but rather a large number of semantically incomplete text slices. When performing similarity searches, the system can only recall these partial fragments, failing to accurately reconstruct the original meaning of the knowledge, thus introducing significant noise and uncertainty into subsequent answer generation, severely impacting the accuracy and reliability of the generated results.
[0019] Knowledge of public security risks is inherently highly complex and interconnected: a single risk source (such as short-term rental accommodation) may be associated with multiple incidents (such as disputes over "encroachment"), while the same type of incident may originate from different combinations of risk sources. Consequently, the formulation of compensation measures often requires comprehensive analysis of multiple factors for precise tracing and reasoning. Fixed-length segmentation fails to maintain the complete logical chain between "risk source-incident-measure," instead fragmenting and dispersing it across different pieces. This prevents the system from understanding the complex network of relationships between entities and from supporting in-depth causal analysis and measure reasoning. Therefore, the core flaw of existing retrieval-enhanced generation methods—the mechanical and formalistic text processing paradigm—is further amplified in the field of community public security risks, making it difficult for existing technologies to meet complex application needs and fundamentally solve the problems of complex risk assessment and compensation measure generation in community security.
[0020] Based on this, this embodiment proposes a method for generating community security risk compensation measures based on graph retrieval enhancement. It employs an adaptive text segmentation method based on deep learning semantic perception, segmenting the text according to its natural language meaning to ensure semantic integrity during segmentation and avoid semantic loss issues caused by fixed-length segmentation in existing technologies. Furthermore, for knowledge in the community security risk domain, a set of entity and relation types is predefined, and the BERT model is used for named entity recognition and relation extraction to generate triplet data, constructing a human-machine collaborative, bidirectional optimized knowledge graph. This enables the large model to identify and extract key information within the domain, including entities such as risk sources, cases (incidents), personnel, locations, control measures, policies and regulations, and equipment, as well as their relationships, thereby providing a more comprehensive and accurate knowledge base for generating risk compensation measures.
[0021] like Figure 1 , Figure 2As shown in this embodiment, the method for generating community security risk compensation measures based on graph retrieval enhancement includes: Step S101: Perform text segmentation and vectorization on the acquired domain knowledge data of the security risk domain to generate knowledge slices of the security risk domain and their corresponding knowledge vectors, and store them in the vector database.
[0022] In this embodiment, basic community information (such as community population structure data and building volume data) and community security information (such as community cases, security incidents, management data of specific personnel in the community, and community public safety affairs prevention and control measures) are collected as community security domain knowledge data. After data cleaning and deduplication, the acquired security risk domain knowledge data is transformed into structured text data in a predefined format (such as PDF format) to construct a security risk domain dataset.
[0023] Meanwhile, 20% of the data in the neighborhood dataset was selected for annotation as the training dataset, and the remaining 80% of the data in the domain dataset was used as the validation dataset. The pre-trained language model based on the Transformer architecture was trained and validated, and the parameters of the pre-trained language model were adjusted so that it could understand the semantics of text in the community security risk domain.
[0024] Then, the pre-trained language model is used to traverse the structured text data, and knowledge text segmentation is performed on the structured text data according to the semantics of the text. In a specific example, a segmentation based on sliding window and similarity calculation is adopted, that is, the semantic similarity between adjacent text blocks is calculated through a sliding window, and segmentation is performed when the similarity is lower than a preset threshold.
[0025] Among them, structured text data is defined. , For structured text data The number of sentences in A positive integer; defines structured text data. continuous A text block is composed of sentences. , For structured text data The Middle One sentence. For structured text data The Middle One sentence. All are positive integers.
[0026] Next, the structured text data Each text block is input into a pre-trained language model to obtain a semantic representation corresponding to each text block. For example, text blocks... Inputting into a pre-trained language model yields text blocks. Corresponding semantic representation Then, the cosine similarity between adjacent text blocks is calculated, specifically according to the formula: Calculate adjacent text blocks With text blocks Cosine similarity between .
[0027] Adjacent text blocks With text blocks Cosine similarity between With preset threshold Compare, if text blocks With text blocks Cosine similarity between Less than the preset threshold Then the text block is considered With text blocks If a semantic shift occurs between two text blocks, then... With text blocks Semantic segmentation is performed between them, that is, in structured text data. Sentences With sentences The data is segmented into segments, and the resulting slices are vectorized using an embedding model to generate knowledge slices in the security risk domain, which are then stored in a vector database.
[0028] Step S102: Construct a domain knowledge graph for the community security risk domain, and store the index relationship between the domain knowledge graph and knowledge vectors in a vector database to construct a domain knowledge base for the security risk domain.
[0029] In this embodiment, considering the characteristics of "multiple causes and effects, complex intertwining" between community security risk sources and compensation measures, an iterative optimization closed loop of "preliminary machine induction - expert calibration - large-scale machine expansion" is designed. The pre-trained language model with adjusted model parameters is used to perform named entity recognition and relation extraction on the domain knowledge data in the domain dataset, and a domain knowledge graph of the community security risk domain is constructed.
[0030] Specifically, firstly, a pre-trained language model is used to perform preliminary named entity recognition and relation extraction on a portion of the domain knowledge data in the domain dataset. Leveraging the discovery capabilities of the pre-trained language model, potential entity and relation types within the security risk domain are automatically summarized, forming a preliminary draft of entity and relation types for the security risk domain. Then, expert knowledge is used to manually judge, optimize, and refine the preliminary entity and relation type draft, including merging semantic duplicates, revising relation definitions, supplementing key attributes, and removing noise. This establishes a set of accurate, standardized, and predefined entity types and predefined entity relationships that meet the actual requirements of the community security risk domain. The obtained predefined entity types are shown in Table 1. Table 1 is as follows: Table 1 Predefined entity types and their key attributes The obtained predefined entity relations are shown in Table 2, as follows: Table 2 Predefined Entity Relationships Finally, based on the predefined entity types and predefined entity relationships required by the actual needs of the community security risk domain, named entity recognition and relation extraction are performed through a pre-trained language model to generate triplet data for the community security risk domain, and a domain knowledge graph for the community security risk domain is constructed using a graph database.
[0031] The entity nodes and relationships (edges) in the domain knowledge graph are extracted from domain knowledge data using a pre-trained language model according to predefined entity types and predefined entity relationships. The knowledge slices and their corresponding knowledge vectors in the vector database are obtained by semantically segmenting and quantizing the domain knowledge data using a pre-trained language model. Therefore, in this embodiment, after constructing the domain knowledge graph and vector database for the community security risk domain, the mapping relationship between the domain knowledge graph and the vector database is obtained based on the correspondence between nodes (entity nodes and their relationships) and knowledge slices in the domain knowledge graph. An index relationship is then established between the graph database and the vector database and stored in the vector database, resulting in a complete domain knowledge base for the community security risk domain.
[0032] Step S103: Parse the user risk query using a large language model, retrieve risk elements related to the user risk query in the domain knowledge graph, and retrieve the knowledge slices corresponding to the risk elements in the domain knowledge base according to the index relationship, so as to generate security risk compensation measures corresponding to the user risk query.
[0033] When a user performs a risk query, the query fields are parsed using a large language model to determine the user's intent and the corresponding response measures for the risk event being queried. Specifically, based on the parsing results from the large language model, risk elements related to the user's query (identical or similar risk elements, such as similar risk sources or incidents) are retrieved from the domain knowledge graph. Then, based on the risk control relationships (mitigation or constraint relationships) between entities in the domain knowledge graph, corresponding risk measures (control measures, policies, regulations, etc.) are retrieved. Among these, risk measures that effectively address risk factors are defined as risk control relationships (mitigation or constraint relationships) between risk factors and risk compensation measures or policies.
[0034] If no similar risk elements are found in the domain knowledge graph, similar risk elements and corresponding control measures can be retrieved based on similarity relationships. Next, knowledge slices corresponding to the risk elements related to the user's query are retrieved from the vector database based on the index relationships. Then, a large language model is used to combine these knowledge slices with the user's risk query to generate reasonable, effective, and interpretable community security risk compensation measures.
[0035] Therefore, by constructing a knowledge base in the field of community security risks, an index relationship is established between the graph database and the vector database, realizing the mapping between knowledge graph data and knowledge blocks in the vector database. During the enhanced retrieval process, based on the user's risk query intent, the knowledge graph can quickly and accurately retrieve risk sources, cases (incidents), and related control measures, policies, and regulations of the same type or similar to the user's risk query. Combined with contextual fragments from the vector database, this provides more comprehensive and accurate knowledge support for generating risk compensation measures, effectively improving retrieval efficiency and accuracy. Simultaneously, it makes the generated risk compensation measures more reasonable, effective, and more interpretable.
[0036] In this embodiment, by employing semantic segmentation, predefined entities and relationships, and the construction of knowledge graphs and domain knowledge bases, the shortcomings of existing technologies in text segmentation and key information identification are overcome. This significantly improves the accuracy and completeness of generating community security risk compensation measures, providing more scientific and effective technical support for community security governance. On one hand, based on knowledge in the community security domain, a large-scale model-based semantic segmentation method is used to segment domain knowledge text according to the natural language meaning of the knowledge text. This effectively ensures that the semantics of the text remain intact during the segmentation process, avoiding the semantic loss problem caused by fixed-length segmentation in existing technologies. Simultaneously, a knowledge graph for the community security risk domain is constructed, establishing an index relationship between the domain knowledge graph and knowledge vectors, providing a more comprehensive and accurate knowledge foundation for generating risk compensation measures in the community security risk domain.
[0037] On the other hand, after the segmented slices are vectorized, the knowledge text slices and their corresponding knowledge vectors are stored together in a vector database. An index relationship is established between the knowledge graph and knowledge vectors in the community security risk domain, and this relationship is stored in the vector database, realizing the mapping between the knowledge graph and the knowledge blocks in the vector database. In the enhanced retrieval generation process, when a user queries a professional question in the community security domain, the user's query field is segmented and quantized using a large language model. Based on the user's query intent, the index relationship between knowledge vectors and the knowledge graph is used to retrieve knowledge vectors with high similarity to the user's query field (i.e., risk elements). Then, corresponding security risk compensation measures are generated through the corresponding knowledge slices, effectively improving the efficiency and accuracy of user query retrieval, and making the generated risk compensation measures more reasonable, effective, and interpretable.
[0038] This embodiment also provides a community security risk compensation measure generation system based on graph retrieval enhancement, such as... Figure 3 , Figure 4 As shown, the system includes: Vectorization unit 401 is configured to perform text segmentation and vectorization on the acquired domain knowledge data of the security risk domain, generate knowledge slices of the security risk domain and their corresponding knowledge vectors, and store them in the vector database. Knowledge base unit 402 is configured to construct a domain knowledge graph for the community security risk domain and store the index relationship between the domain knowledge graph and knowledge vectors in a vector database to construct a domain knowledge base for the security risk domain. The query compensation unit 403 is configured to parse the user risk query through a large language model, retrieve risk elements related to the user risk query in the domain knowledge graph, and retrieve the knowledge slices corresponding to the risk elements in the domain knowledge base according to the index relationship, so as to generate security risk compensation measures corresponding to the user risk query.
[0039] The community security risk compensation measures generation system based on graph retrieval enhancement provided in this embodiment can realize the steps and processes of the community security risk compensation measures generation method based on graph retrieval enhancement in any of the above embodiments, and achieve the same technical effect, which will not be described in detail here.
[0040] In the description of this invention, it should be understood that the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0041] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for generating community security risk compensation measures based on graph retrieval enhancement, characterized in that, include: The acquired domain knowledge data in the security risk domain is segmented and vectorized to generate knowledge slices and their corresponding knowledge vectors in the security risk domain and stored in the vector database. Construct a domain knowledge graph for the community security risk domain, and store the index relationship between the domain knowledge graph and knowledge vectors in a vector database to build a domain knowledge base for the security risk domain; The system analyzes user risk queries using a large language model, retrieves risk elements related to the user risk query from the domain knowledge graph, and retrieves knowledge slices corresponding to the risk elements from the domain knowledge base based on index relationships, in order to generate security risk compensation measures corresponding to the user risk query.
2. The method according to claim 1, characterized in that, The acquired domain knowledge data in the security risk domain is cleaned, deduplicated, and transformed into structured text data in a predefined format to obtain the domain dataset for the security risk domain. By traversing structured text data through a pre-trained language model, knowledge text segmentation is performed on the structured text data according to the text semantics, and the segmented slices are vectorized using an embedding model to generate knowledge slices in the security risk domain and store them in a vector database.
3. The method according to claim 1, characterized in that, By using a pre-trained language model to perform named entity recognition and relation extraction on domain knowledge data in the domain dataset, a domain knowledge graph for the security risk domain is constructed.
4. The method according to claim 3, characterized in that, By using a pre-trained language model, preliminary named entity recognition and relation extraction are performed on some domain knowledge data in the domain dataset. The potential entity and relation types in the security risk domain are automatically summarized, and a draft of entity and relation types in the security risk domain is formed. By merging semantic duplicates, revising relationship definitions, supplementing key attributes, and removing noise from the draft entities and relationships, predefined entity types and predefined entity relationships in the security risk domain are established. Using predefined entity types and predefined entity relationships as standards, named entity recognition and relation extraction are performed through a pre-trained language model to generate triple data in the security risk domain, and a domain knowledge graph in the security risk domain is constructed using a graph database.
5. The method according to claim 1, characterized in that, Based on the mapping relationship between the domain knowledge graph and the knowledge slices in the vector database, an index relationship is established between the graph database and the vector database and stored in the vector database.
6. The method according to claim 1, characterized in that, The user risk query is parsed using a large language model, and based on the parsing results, risk elements related to the user risk query are retrieved from the domain knowledge graph. Based on the risk control relationships between entities within the domain knowledge graph, retrieve the risk measures corresponding to the risk elements related to the user's risk query; Based on the index relationship, knowledge slices of risk elements are retrieved from the vector database, and corresponding security risk compensation measures are generated by combining the retrieved knowledge slices with user risk queries through a large language model.
7. A community security risk compensation measure generation system based on graph retrieval enhancement, characterized in that, The system employs the community security risk compensation measure generation method based on graph retrieval enhancement as described in any one of claims 1-6 to process user risk queries. The system comprises: The vectorization unit is configured to perform text segmentation and vectorization on the acquired domain knowledge data of the security risk domain, generate knowledge slices of the security risk domain and their corresponding knowledge vectors, and store them in the vector database. The knowledge base unit is configured to construct a domain knowledge graph for the community security risk domain and store the index relationship between the domain knowledge graph and knowledge vectors in a vector database to construct a domain knowledge base for the security risk domain. The query compensation unit is configured to parse user risk queries using a large language model, retrieve risk elements related to the user risk query in the domain knowledge graph, and retrieve knowledge slices corresponding to the risk elements in the domain knowledge base according to the index relationship, so as to generate security risk compensation measures corresponding to the user risk query.