Large model prompt template generation method for social governance knowledge graph triple construction
Through the knowledge graph triple-structure construction method for social governance, and the large-model prompt template generation technology is used to solve the problem of data preprocessing time and insufficient ability to extract entity relationships, efficient and accurate knowledge graph construction is achieved, and complex social governance data analysis and decision-making support are supported.
Patent Information
- Application Number
- CN202411879184.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2044-12-19
AI Technical Summary
In the construction of knowledge graphs in the field of social governance, the existing technology faces the problems of data preprocessing time, inconsistent data quality, and insufficient ability to accurately extract entities and relationships from text.
A large-model prompt template generation method is adopted for social governance knowledge graph triplets, including data preprocessing optimization, data desensitization, design of expected output templates, prompt template generation, knowledge graph triplet construction, quality evaluation and feedback optimization mechanism. Through these steps, intelligent prompt templates are generated to guide the large language model to accurately extract key information in the text.
It significantly improves the efficiency and accuracy of social governance tasks, especially in the customization of tasks and scenario adaptability, and can efficiently build high-quality knowledge graph triplets to support complex social governance data analysis and decision-making support.
Smart Images

Figure CN119323263B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence, and specifically to a method for generating a large model prompt template for constructing a social governance knowledge graph triple. Background Art
[0002] With the rapid development of social informatization, a large amount of complex data has accumulated in the field of social governance. These data include traditional structured information and unstructured or semi-structured data, such as social media posts and news reports. However, these data are often scattered across various platforms, forming "data islands" that are difficult to fully integrate and utilize. This phenomenon has hindered the improvement of social governance efficiency and has also prevented the effective mining of data value.
[0003] In this context, knowledge graph, as an efficient form of data organization and representation, can effectively solve the above problems by defining entities and the relationships between them. It not only helps to achieve cross-domain and cross-system data fusion, but also provides semantic understanding and support, enabling machines to better parse the complex meanings in human language, thereby providing strong support for social governance application scenarios such as decision support, intelligent retrieval, and precise services. However, the knowledge graph construction technology currently used still faces challenges: existing data preprocessing methods take a long time on large-scale text data and are susceptible to inconsistent data quality; at the same time, the ability to accurately extract entities and relationships from text still needs to be improved, especially in the field of social governance where there is strong ambiguity and complex context.
[0004] The development of large language models (LLMs) provides a possible solution to these problems. Through prompt engineering technology, LLMs can use massive knowledge at the implicit level of the model to complete complex tasks. However, the quality of the prompt template directly affects the performance of the model. The current process of constructing knowledge graphs using large model methods mostly relies on manually designed prompts, which not only consumes a lot of manpower, but also is difficult to adapt to different task scenarios. It also lacks dynamic optimization capabilities and targeted optimization strategies, resulting in insufficient model performance in complex scenarios. Summary of the invention
[0005] The purpose of the present invention is to provide a large model prompt template generation method for constructing triples of social governance knowledge graphs to solve the problems raised in the above background technology.
[0006] To achieve the above object, the present invention provides the following technical solutions:
[0007] The method for generating a large model prompt template for building a social governance knowledge graph triplet includes the following steps:
[0008] Step S1, data preprocessing optimization: Clean, denoise, format and structure the social governance text data to ensure data quality and consistency. Use natural language processing technology to remove invalid, redundant and erroneous data and standardize them.
[0009] Step S2, data desensitization: Desensitize sensitive information in the data and use encryption or anonymization technology to ensure privacy protection.
[0010] Step S3, design expected output template: This step aims to construct the knowledge graph triple format output by the large model, define a series of expected output templates for the model, and guide the model to identify and extract key entities in the text and the relationship between entities when processing data.
[0011] Step S4, prompt template generation: Based on the previous step, the expected output is input to the large model, and the prompt template corresponding to the specific task required by the large model itself is automatically generated based on the large language model to guide the model to accurately extract information. The generated prompt template is intelligently adjusted according to the task requirements and input text to adapt to different scenarios. At the same time, the generated prompt template is further optimized according to the task requirements to improve the accuracy and efficiency of the model task execution.
[0012] Step S5, knowledge graph triple construction: Based on the prompt template, extract entity, relationship and attribute information from the social governance text, and construct triples that meet the knowledge graph standards.
[0013] Step S6, triplet quality assessment: perform quality assessment on the generated triplet by calculating relevant indicators.
[0014] Step S7, feedback optimization mechanism: adjust the expected output of the prompt according to the evaluation result to adjust the output prompt template, so as to improve the task execution effect.
[0015] In step S1, data preprocessing is achieved through an automated method, and a deep learning model is used to perform semantic analysis of the text content to ensure the consistency and accuracy of the data.
[0016] The data desensitization in step S2 uses hash encryption technology or universal identifiers to replace sensitive data to ensure that personal privacy information is not leaked.
[0017] In step S3, the expected output is artificial and constructed according to the specific task scenario, and is provided to the large model as the next step for generating the output of the prompt.
[0018] In step S4, the prompt template generation not only considers the task requirements, but also performs adaptive adjustments based on the context to ensure the efficiency and accuracy of the template in different scenarios.
[0019] In step S5, triples are constructed by efficient relationship extraction and attribute extraction methods to ensure that the generated triples conform to the standard format and have high quality.
[0020] In step S6, select F 1 The value is used as an evaluation indicator to measure the quality of triple construction. F 1 The value is the accuracy P and recall R The harmonic mean of , which comprehensively measures the overall performance of the model, is calculated as: ; Accuracy P Measures the proportion of triples correctly identified by the model, calculated as , recall rate R Measures the proportion of all true triples that the model recognizes , G p Represents the total number of triple sets output by the model, G t represents the total number of triple sets annotated by humans, Represents the size of the intersection of the model prediction and the true annotation triples; calculated based on F 1 If the value is between 0 and 1 and close to 1, it means that the triplet output by the model has good quality. Otherwise, it means that the prompt template output by the large model needs further adjustment.
[0021] In step S7, the evaluation results are used to identify deficiencies in the prompt template, optimize the expected output format, and adjust the model. Through a continuous feedback loop, the quality of triple generation is continuously improved, and ultimately, output that meets the needs is provided for social governance and decision-making.
[0022] Compared with the prior art, the present invention has the following beneficial effects:
[0023] Intelligent prompt template generation: This invention automatically generates the prompt templates required by the big model itself through the big model, and dynamically adjusts the template content based on the input text and task requirements. This process is different from the traditional manual design template, which significantly improves the efficiency and accuracy of social governance tasks, especially in terms of task customization and scenario adaptability.
[0024] Task adaptability and customization: The prompt template of the present invention can automatically generate and optimize templates according to different social governance tasks, such as marriage disputes, community management, etc., to ensure the applicability and efficiency of the template in various scenarios. This innovation makes the present invention superior in processing complex and changeable social governance data.
[0025] Efficient data processing and triplet construction: Under the guidance of the generated prompt template, the present invention can accurately and efficiently extract key information from social governance texts, significantly improve the accuracy of triplet construction, and provide a reliable foundation for subsequent data analysis and decision support through standardized triplet output.
[0026] Scalability and versatility: The technical solution of the present invention supports cross-regional and cross-departmental governance needs, can process large-scale data sets, adapt to different types of social governance scenarios, and has strong scalability and versatility. This technology is not only applicable to the current social governance field, but can also be extended to data processing and knowledge extraction tasks in other fields. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 The figure is a flow chart of the method of the present invention. DETAILED DESCRIPTION
[0028] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0029] like Figure 1 As shown, a large model prompt template generation method for social governance knowledge graph triple construction of the present invention includes:
[0030] Step 1: Preprocess and optimize the input data.
[0031] The data is cleaned and formatted in depth. Data cleaning includes removing invalid and incomplete records, correcting errors, and eliminating duplicate information to ensure data quality. Formatting ensures that all data meets the format requirements of the input model, including unified data structure, standard encoding methods, etc.
[0032] For example, using deep learning models such as RoBERTa and T5 for text denoising and content classification can help filter out invalid or irrelevant records. Through the automated analysis of these models, data can be efficiently cleaned, formatted, and converted into a standardized structure that meets input requirements, laying the foundation for subsequent model input and high-quality output.
[0033] Step 2: Data desensitization. Text data involving sensitive information such as personal identity and contact information is anonymized through encrypted hash algorithms or universal identifiers. This not only effectively prevents privacy leaks, but also ensures that the data processing process complies with relevant privacy protection laws and regulations.
[0034] For images and other unstructured data, corresponding privacy protection technologies are also used for desensitization.
[0035] Step 3: Design the expected output template. The goal of this step is to carefully construct the specific format of the knowledge graph output by the large model based on the "entity-relationship-entity" triple structure. This means that a series of expected output templates need to be defined for the model. These templates will guide the model on how to identify and extract key entities in the text when processing data, and how these entities are related to each other.
[0036] Specifically, the output template is in the form of ,in and Represent entities in the text, At the same time, in order to ensure that the triple information generated by the model not only meets the predetermined structural requirements but also meets the data analysis needs in different scenarios, it is necessary to design a suitable output template set for each type of application scenario. , each template Specific mapping rules between entities and relations are defined. These templates not only guide the model on how to accurately extract key information from the text, but also enable flexible adjustments to entities and relations according to actual needs.
[0037] In addition, according to the specific task scenario, relevant information can be appropriately added as a supplement to the output template to allow the large model to better understand the task content. In this way, it can be ensured that the triple information output by the model not only meets the predetermined structural requirements, but also meets the data analysis needs in different scenarios, thereby greatly improving the data availability and analysis efficiency.
[0038] A reasonable knowledge graph triple structure can meet different types of data analysis needs, as well as structural and information-rich requirements.
[0039] For example, when analyzing event information in social governance, the output template can be defined as "event-relationship-participant", such as ("XXX car accident", "perpetrator", "Zhang"). Through this template, the event can be accurately associated with the relevant participants; another template can be defined as "event-occurrence time-specific time", such as ("XXX car accident", "occurrence time", "December 1, 2024"), to reveal the time information of the event. In addition, for problem analysis tasks, a template of "problem-suggested solution-handling method" can be designed, such as ("community noise problem", "suggested solution", "install sound insulation wall"), which is used to structure the representation of problems and their corresponding solutions.
[0040] In the field of policy management, the template can be further defined as "policy name-scope of application-region", such as ("garbage classification policy", "scope of application", "Beijing"), to describe the relationship between the policy and its coverage area. By constructing a triple template that conforms to entity-relationship-entity, it is possible to provide a clear output target for the large model, ensuring that the key information extracted from complex texts not only meets the structural requirements of the knowledge graph, but also enables the output data to better serve social governance, policy analysis, decision support and other application scenarios, thereby improving the utilization value and actual application effect of the data.
[0041] The expected output triplet template obtained here is combined with the actual task scenario information as the final expected output of this type of task and input into the large model.
[0042] Step 4: Prompt template generation. The expected output designed in the previous step is input to the big model, and the prompt template corresponding to the specific task required by the big model itself is generated based on the big language model to guide the model to accurately extract information. In the stage of generating high-quality prompt templates, based on the powerful generation ability of the big model, the expected triple structure set in the previous step is used as the target, and it is automatically adapted and formed according to the context information of the input text to intelligently generate prompt templates.
[0043] The main function of these prompt templates is to guide the large model to extract key information in a targeted and accurate manner when processing downstream text data, such as the specific details of the event, the people involved, the specific date and location of the event, etc. In this way, the efficiency and accuracy of the large model in downstream information extraction tasks can be significantly improved. This automatically generated prompt template enables the model to focus more on task-related information, thereby improving the relevance and accuracy of the knowledge graph triple output, providing a solid foundation for in-depth mining and analysis of social governance data.
[0044] Step 5: Knowledge graph triple construction. Based on the prompt template obtained in the previous step, extract entity, relationship and attribute information from the social governance text and construct triples that meet the knowledge graph standards.
[0045] In this stage, all kinds of social governance data collected in real time are input into the optimized model, and the most appropriate prompt template is intelligently selected according to the specific content of the data. These prompt templates are automatically generated in the previous steps and provide guidance for the big model to extract key information. The big model will automatically fill in the relevant entity and relationship content based on these prompt templates, and finally generate structured knowledge graph triples. These triples contain key entities extracted from the original data, the relationship between entities, and related attribute information.
[0046] Step 6: Triplet quality evaluation: Compare the triplet output by the model with the manually annotated triplet and calculate the evaluation index.
[0047] The generated triples are analyzed in depth to assess their accuracy and usefulness. This step is crucial as it helps identify possible deficiencies in the model’s information extraction process and how the triplet output performs in real-world applications.
[0048] choose F 1 The value is used as an evaluation metric to measure the quality of triplet construction. F 1 The value is the accuracy P and recall R The harmonic mean of , which comprehensively measures the overall performance of the model, is calculated as: . Accuracy P Measures the proportion of triples correctly identified by the model, calculated as , recall rate R Measures the proportion of all true triples that the model recognizes In the above formula, G p Represents the total number of triple sets output by the model, G t represents the total number of triple sets annotated by humans, Represents the size of the triple intersection between the model prediction and the true annotation.
[0049] According to the calculation F 1 If the value is between 0 and 1 and close to 1, it means that the triplet output by the model is of good quality. Otherwise, it means that the prompt template output by the large model needs further adjustment.
[0050] Step 7: Feedback optimization mechanism. Adjust the prompt template and model parameters according to the evaluation results, and adjust the prompt template output by the large model by optimizing the expected output initially input to the large model, so as to improve the task execution effect.
[0051] Based on these analysis results and actual application feedback, the expected output format is further optimized, and these optimization measures are then used to adjust the large model so that it can generate more accurate and applicable prompt templates. Through this continuous feedback and optimization cycle, the quality of triple generation is ultimately guaranteed to be improved, so that the large model can generate output results that are more in line with the needs of social governance data analysis and decision support.
[0052] In the feedback optimization stage, if the large model is deployed locally, a new high-quality prompt dataset can be generated based on the triple quality evaluation results, with the triple accuracy, recall rate and F1 The value is the core indicator, and inefficient or erroneous prompt templates are reconstructed. The reconstructed prompt dataset further optimizes the parameters of the large model through fine-tuning, so that it can continuously improve its task adaptability and knowledge extraction capabilities, thereby ensuring the model's efficient support for complex social governance scenarios and significantly improving the accuracy and reliability of knowledge graph construction.
[0053] It will be apparent to those skilled in the art that the invention is not limited to the details of the exemplary embodiments described above and that the invention can be implemented in other specific forms without departing from the spirit or essential features of the invention. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description, and it is intended that all variations falling within the meaning and scope of the equivalent elements of the claims be included in the invention. Any reference numeral in a claim should not be considered as limiting the claim to which it relates.
[0054] In addition, it should be understood that although the present specification is described according to implementation modes, not every implementation mode contains only one independent technical solution. This description of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment may also be appropriately combined to form other implementation modes that can be understood by those skilled in the art.
Claims
1. A large model prompt template generation method for the construction of social governance knowledge graph triples, characterized in that: The steps include: Step S1, data preprocessing: clean, denoise, format and structure the social governance text data, remove invalid, redundant and erroneous data and standardize them; Step S2, data desensitization: desensitize sensitive information in the data; Step S3: Design the expected output template: The output template is in the form of ,in and Represent entities in the text, Represents the relationship between them; Design a suitable output template set for each application scenario , each template Defines specific mapping rules between entities and relationships; Step S4, prompt template generation: the expected output is input to the big model, and the prompt template corresponding to the specific task required by the big model itself is automatically generated based on the big language model, the model is guided to accurately extract information, and the generated prompt template is intelligently adjusted according to the task requirements and the input text; in the stage of generating high-quality prompt templates, the triple of the expected output template in step S3 is taken as the target, and it is automatically adapted and formed according to the context information of the input text to intelligently generate the prompt template; Step S5, knowledge graph triple construction: based on the prompt template, extract entity, relationship and attribute information from the social governance text, and construct triples that meet the knowledge graph standards; Step S6, triplet quality assessment: compare the triplet output by the model with the triplet of the expected output template and calculate the assessment index; Step S7, feedback optimization mechanism: adjusting the expected output of the prompt according to the evaluation result to adjust the output prompt template; In step S6, select F 1 The value is used as an evaluation indicator to measure the quality of triple construction. F 1 The value is the accuracy P and recall R The harmonic mean of , which comprehensively measures the overall performance of the model, is calculated as: ; Accuracy P Measures the proportion of triples correctly identified by the model, calculated as , recall rate R Measures the proportion of all true triples that the model recognizes , G p Represents the total number of triple sets output by the model, G t represents the total number of triple sets annotated by humans, Represents the size of the intersection of the model prediction and the true annotation triples; calculated based on F 1 If the value is between 0 and 1 and close to 1, it means that the triplet output by the model has good quality. Otherwise, it means that the prompt template output by the large model needs further adjustment.
2. According to claim 1, the large model prompt template generation method for social governance knowledge graph triple construction is characterized in that: In the data preprocessing in step S1, a deep learning model is used to perform semantic analysis of the text content.
3. According to claim 2, the method for generating a large model prompt template for constructing a social governance knowledge graph triple is characterized in that: The data desensitization in step S2 uses hash encryption technology or universal identifiers to replace sensitive data.
Citation Information
Patent Citations
Method for carrying out data enhancement by utilizing large model and cooperative training
CN117407532A
Methods and systems for ontology construction with ai-mediated crowdsourcing and concept mining for high-level activity understanding
US20240112044A1