Large Model Prompt Design Method for Constructing a Social Governance Knowledge Graph Based on Chain of Thought
Through CoT chain thinking decomposition tasks and combining the context understanding ability of the big model, prompt templates are dynamically generated, which solves the problems of low efficiency, insufficient flexibility and model illusion in the traditional knowledge graph construction method, and realizes efficient and accurate knowledge graph construction of social governance data.
Patent Information
- Application Number
- CN202510398928.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-01
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2045-04-01
AI Technical Summary
Traditional knowledge graph construction methods are inefficient, flexible and adaptable, rely on field experts' experience, and information extraction based on pre-trained language models is prone to produce hallucinatory output, making it difficult to adapt to the complex needs of large-scale multi-source heterogeneous social governance data.
CoT chain thinking decomposition tasks are adopted, combined with the context understanding ability of the big model, and dynamically generate high-precision prompt templates. Through data preprocessing, expected output design, prompt template generation and optimization feedback mechanisms, entities, relationships and attributes in social governance data are automatically extracted to build a high-quality knowledge graph.
Significantly reduce the cost of manual intervention, improve the flexibility of templates and scene adaptability, alleviate the problem of model hallucinations, and ensure the efficient construction and accuracy of knowledge graphs.
Smart Images

Figure CN119918677B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of artificial intelligence, and specifically relates to a large model prompt design method based on CoT chain of thought, which is used to automatically construct knowledge graph five-tuple knowledge including entity categories from social governance data. Background Art
[0002] With the rapid development of artificial intelligence technology, knowledge graphs, as important tools for structured knowledge representation, play a key role in fields such as social governance, policy analysis, and decision-making support. Traditional knowledge graph construction methods usually rely on manual annotation and rule design. Especially in the triple extraction stage, experts need to pre-define entity types, relationship patterns, and templates to guide the training and reasoning of information extraction models. For example, in political and legal data, manually designed templates may include fixed fields such as case names, participants, time, and legal provisions. However, this method has the following significant defects:
[0003] (1) Low efficiency:
[0004] Manually designing templates requires a large amount of time and professional resources. Especially when facing large-scale, multi-source heterogeneous social governance data, it is difficult to quickly adapt to different scenarios and task requirements. For example, the entities and relationships of marriage and family disputes and labor disputes are significantly different, and templates need to be designed separately, resulting in a long development cycle and high costs.
[0005] (2) Lack of flexibility and adaptability:
[0006] Static templates are difficult to cover complex semantic relationships and dynamic changes in the data. For example, emerging dispute types or implicit information in unstructured text may exceed the scope of the preset templates, resulting in missing or incorrect information extraction.
[0007] (3) Strong dependence on domain knowledge:
[0008] Traditional methods highly rely on the experience of domain experts. In cross-domain or sub-scenarios (such as neighborhood disputes in grass-roots social governance), the generalization ability of templates is limited, and it is difficult to achieve large-scale application.
[0009] (4) Model hallucination problem:
[0010] Although information extraction methods based on pre-trained language models can partially alleviate manual intervention, they are prone to generating "hallucination" outputs unrelated to the original text when lacking high-quality template guidance, affecting the accuracy of triples.
[0011] In recent years, researchers have tried to optimize the knowledge graph construction process through automated template generation technology. For example, using rule engines or machine learning models to dynamically generate templates, but these methods still have problems such as unstable quality of generated templates and weak context adaptation capabilities. In addition, existing technologies pay less attention to how to guide large models to accurately understand complex requirements through task decomposition and chain-of-thought (CoT), resulting in insufficient guidance and controllability of templates.
[0012] In response to the above problems, the present invention proposes a large model prompt design method based on CoT chain thinking. By decomposing complex tasks into logically coherent sub-steps and combining the contextual understanding ability of the large model, high-precision prompt templates are dynamically generated to achieve the automatic extraction and structuring of entities, relationships and attributes in social governance data. Compared with traditional methods, the present invention significantly reduces the cost of manual intervention, improves the flexibility and scenario adaptability of the template, and effectively alleviates the model illusion problem, providing an innovative solution for the efficient construction of knowledge graphs. Summary of the invention
[0013] In order to improve the accuracy and efficiency of extracting information from social governance data through the automatic generation and optimization of big model prompt templates, the present invention proposes a big model prompt design method based on the construction of social governance knowledge graph based on CoT chain thinking, including the following steps:
[0014] (1) Step 1: Data preprocessing
[0015] First, collect a large amount of text data and metadata (such as source, release time, classification label, etc.) from the government public information center or other social governance-related platforms. Data cleaning, denoising, formatting and structuring are the key to this step. Data cleaning includes removing invalid and redundant data, correcting errors and repeated information in the text. Formatting ensures that all data conforms to unified standards and encoding methods, providing high-quality, standardized data sets for subsequent large model input.
[0016] (2) Step 2: Design of expected output
[0017] In this step, the output format is designed to meet the different requirements of the data layer, event layer, and logic layer. The structure of the model output is determined by defining the "five-tuple" (entity-entity category-relationship-entity-entity category) format. This step includes clarifying the task requirements for the construction of the data layer, event layer, and logic layer, defining the entity categories and relationship types required for each layer, and designing corresponding output templates for each layer.
[0018] (3) Step 3: Prompt template generation
[0019] Using the CoT chain of thought, first, the knowledge graph construction task is segmented, and then the first part of the prompt template is designed: "Task description - entities to be extracted - relationships to be extracted - designed expected output template"; secondly, in order to further enable the large model to understand the task, through a restrictive text, the large model is prompted to process more accurately; finally, the high-quality example output helps the large model understand the reasoning process from text to five-tuples and reduces the risk of the model generating "hallucinated" output. The prompt template consists of the above three parts, and the specific details are dynamically adjusted according to the requirements of each hierarchical task, guiding the large model on how to accurately extract key information.
[0020] (4) Step Four: Knowledge Graph Construction
[0021] According to the generated prompt template, the large model automatically extracts key information from the social governance text and generates structured five-tuples in this step. These five-tuples consist of entities, relationships, and category information of the entities, meeting the knowledge graph standards. By automatically filling in this information, it is ensured that useful structured data is extracted from the text data, further constructing a complete social governance knowledge graph.
[0022] (5) Step Five: Optimization and Feedback
[0023] After generating the five-tuples, it enters the result optimization and feedback stage. According to the evaluation results, the prompt template is adjusted to further optimize the generated output of the model. Through continuous feedback, the prompt template is optimized and adjusted, enabling the large model to better adapt to the subsequent social governance data analysis requirements and continuously improving the quality and accuracy of the triple construction.
[0024] Compared with the prior art, the beneficial effects of the present invention are: by introducing the CoT chain of thought, the present invention can help the large model better understand and extract key information, effectively alleviating the hallucination problem and the limitations of domain knowledge; a variety of five-tuple output templates are designed according to different social governance scenarios to ensure that the generated triples can meet various application requirements; through the continuous result evaluation and feedback mechanism, the prompt template and the processing ability of the large model are continuously optimized to ensure that the model output always maintains high accuracy and quality. Description of the Drawings
[0025] Figure 1 It is the flowchart of the method of the present invention. Detailed Embodiments
[0026] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts belong to the scope of protection of the present invention.
[0027] As Figure 1 shown, the large model prompt design method for constructing a social governance knowledge graph based on CoT chain of thought proposed by the present invention can efficiently and intelligently extract key information from text data in the field of social governance and construct a more complete knowledge graph through the implementation of the following steps. This implementation method includes multiple steps such as data preprocessing, expected output design, prompt template generation, knowledge graph construction, and optimization and feedback. Each step can be adjusted and optimized according to task requirements. The following is the implementation method for each step.
[0028] (1) Step 1: Data preprocessing,
[0029] This step includes three main parts: data cleaning, formatting, and structuring:
[0030] a. Data cleaning:
[0031] Collect data from government public information platforms or other databases related to social governance. First, perform preliminary cleaning on this data to remove invalid, redundant, or incomplete records. For incorrect data, use rule-based algorithms or manual annotation for correction. All duplicate information is eliminated, and spelling mistakes and grammar problems in the text are ensured to be repaired.
[0032] b. Data formatting:
[0033] Ensure that the formats of all data fields are unified, such as dates, times, locations, person names, etc. The data fields are standardized before being input into the model to ensure that all text content, metadata, etc. meet the preset format requirements and provide consistent and standardized data input for the model.
[0034] c. Data structuring:
[0035] By extracting key information in the text, convert the data into a structured format, such as mapping information such as participants, time, and location in a case into structured data. Mark or eliminate invalid or incomplete records to ensure that the final dataset can meet the input requirements of the subsequent model.
[0036] (2) Step 2: Expected output design,
[0037] This step designs the expected output format to meet the needs of different application scenarios. The implementation method is as follows:
[0038] a. Entity and relationship definition:
[0039] First, define the key information entities in the social governance scenario and the relationships between them. For the construction of the data layer, entities include people, time, place, case type, etc. Each entity also needs to be clearly labeled with its category, and the relationship is the connection between these entities. For example, "Wang A"-"Father"-"Li B". For the construction of the event layer, entities refer to specific events in the text data, and relationships are the relationships between events, such as: cause-effect relationships, sequential relationships, etc. For the construction of the matter layer, entities are events abstracted from specific events identified in the text, and relationships are the relationships between abstracted small events, such as: explanation relationships, cause-effect relationships, etc.
[0040] b. Output quintuple format design:
[0041] According to the task requirements, multiple output templates are designed. For example, for marriage and family dispute cases, a five-tuple template of event data can be designed: "(Wang A, person, marriage relationship, Li B, person)". For the mediation process of the case, a five-tuple of mediation results can be designed: "(case, mediation result, Li B pays 1,000 yuan in alimony per month, mediation result)"; for the five-tuple at the event level, the output format is designed as (Wang A and Li B divorce, event, causal relationship, Li B pays 1,000 yuan in alimony per month, event); for the five-tuple at the principle level, the output format is designed as (divorce, event, causal relationship, lawsuit, event).
[0042] c. Output template:
[0043] At this stage, the system applies the output templates to different social governance scenarios to ensure that the generated quintuples meet expectations. For each application scenario, a specific set of templates can be designed to ensure that different types of case data can be covered.
[0044] (3) Step 3: Prompt template generation
[0045] This step is the core step of the whole method. CoT chain thinking is used to design and generate effective prompt templates. The implementation method is as follows:
[0046] a. Task decomposition: clarify task requirements and reasoning steps
[0047] The first step of CoT chain thinking is task decomposition, which helps the large model to reason step by step by splitting a complex task into multiple small subtasks, ensuring that each link can be processed with high quality.
[0048] First, clarify what tasks the model needs to complete. For example, when constructing a knowledge graph of the data layer for marriage and family dispute cases in social governance, the task requirement is: "Please generate a five-tuple (Entity 1, Entity 1 type, Relationship, Entity 2, Entity 2 type) that includes the event title, event category, occurrence time, source method, applicant, respondent, case description, mediation process, and mediation result with entity type annotations according to the specific content." Clarifying the task requirements helps provide guidance for subsequent steps and enables the model to understand the goal.
[0049] In CoT chain of thought, step-by-step reasoning is an important process. The completion of each subtask is the basis for the successful execution of subsequent tasks. For example, in the task of constructing the marriage and family dispute data layer, the first step is to identify the person entities in the text, such as "Wang Moumou" and "Li Moujia"; the second step is to identify the relationships between these people, such as "marriage relationship"; the third step is to transform the identified entities and relationships into structured data. Through these small steps, the model can clearly understand the requirements of each link and avoid confusion.
[0050] b. Reasoning path: How to get from text to five-tuple
[0051] When guiding the model to gradually complete tasks through the reasoning path, the large model needs to extract key information from the text through self-reasoning and transform it into elements of a structured knowledge graph.
[0052] The first step of the reasoning path is to identify entities from the text. For example, in a marriage and family dispute case, the model needs to identify the main people involved from the case description, such as "Wang Moumou" and "Li Moujia", and these two entities need to be marked as the "person" category.
[0053] The next reasoning step is to identify the relationships between entities. In the marriage and family dispute task, the model needs to identify the relationship between "Wang Moumou" and "Li Moujia" from the text and identify this relationship as a "marriage relationship". This step requires the model to be able to understand the semantics of keywords such as "married" or "husband and wife" and judge the relationship between the two from the context.
[0054] Finally, the result of the reasoning needs to be transformed into structured information, usually presented in the form of a five-tuple. For example, the relationship "marriage relationship" between the entities "Wang Moumou" and "Li Moujia" identified from the text can be transformed into a five-tuple: "(Wang Moumou, person, marriage relationship, Li Moujia, person)". This structured information facilitates subsequent data processing, storage, and analysis.
[0055] c. Demonstrative output: Ensure correct reasoning
[0056] To ensure that the large model works along the correct reasoning path, we design high-quality example outputs. The example outputs help guide the model to understand the transformation process from task requirements to quintuples, thereby reducing the risk of the model generating "hallucinatory" outputs when performing tasks.
[0057] The examples are designed based on real scenarios of task requirements, and they demonstrate the reasoning process from text to structured output. For example, in the task of marriage and family dispute cases, an example could be: Given the case description: "Wang Moujia and Li Moujia have been married for ten years and now have a dispute over property issues and the upbringing of Li Mouyi." The output quintuple is: "(Wang Moujia, person, marriage partner, Li Moujia, person)", or "(Wang Moujia, person, mother, Li Mouyi, person)". These examples help the large model understand how to extract and correctly organize information according to different input texts.
[0058] High-quality examples can effectively reduce the information generated by the large model that is irrelevant to the actual task. Especially when dealing with tasks in the complex field of social governance, the model may generate irrelevant outputs due to the lack of clear guidance. By providing specific examples, the model can more clearly understand the goals of the task and avoid generating "hallucinatory" outputs, that is, those results that are irrelevant to the actual task.
[0059] d. Feedback adjustment: Dynamically optimize task prompts
[0060] The last step of CoT chain of thought is feedback adjustment, which is a process of improving the model's reasoning ability by continuously optimizing the prompt template and task decomposition. At this stage, the system will fine-tune the prompt template according to the output effect of the model so that the model can better adapt to new task requirements and data scenarios.
[0061] (4) Step Four: Knowledge graph construction
[0062] a. Quintuple extraction:
[0063] Based on the generated prompt template, the system automatically extracts key information from social governance text data and maps it into a quintuple structure. Each quintuple contains entities, entity categories, relationships, and related attributes, meeting the construction requirements of the knowledge graph.
[0064] b. Structured generation:
[0065] Each quintuple represents the specific information extracted from the text, and the model will automatically fill in the relevant entity and relationship content to generate structured triples or quintuples.
[0066] c. Associated information identification:
[0067] During the construction of the five-tuples, the model will identify and analyze the relationships between entities, such as temporal relationships, person relationships, geographical location relationships, etc., to ensure that the extracted information can construct a complete knowledge graph.
[0068] (5) Step Five: Optimization and Feedback
[0069] According to the evaluation results, adjust and optimize the output format of the five-tuples and the generated prompt templates. Through manual intervention and automatic optimization mechanisms, ensure that the generated five-tuples can meet the final requirements and expectations. By continuous evaluation and feedback, optimize the prompt templates and improve the performance of the model. This continuous optimization process can ensure that the generated knowledge graph is always in the best state and meets the needs of social governance data analysis and decision support.
[0070] For those skilled in the art, it is obvious that the present invention is not limited to the details of the above exemplary embodiments, and without departing from the spirit or basic characteristics of the present invention, the present invention can be implemented in other specific forms. Therefore, in any aspect, the embodiments should be regarded as exemplary and non-restrictive. The scope of the present invention is defined by the appended claims rather than the above description. Therefore, all changes falling within the meaning and scope of the equivalent elements of the claims are intended to be included in the present invention. Any reference signs in the claims should not be regarded as limiting the claimed claims.
[0071] In addition, it should be understood that although this specification is described according to embodiments, not every embodiment only contains an independent technical solution. This narrative way of the specification is only for clarity. Those skilled in the art should regard the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.
Claims
1. A large model prompt design method for constructing a social governance knowledge graph based on CoT chain of thought, characterized in that, The steps include: Data preprocessing: Obtain social governance data and perform data cleaning, formatting and structuring to remove invalid, redundant and erroneous data; Expected output design: Design the output format for social governance application scenarios, define the entity categories that need to be extracted for the data layer, event layer, and reasoning layer, and define the relationships between entities; Prompt template generation: Apply CoT chain thinking to divide the prompt design task into four steps: Task decomposition: decompose the task into entity recognition, relationship recognition, entity category labeling and format assembly steps, and generate different task descriptions according to the different expected outputs of the design; Reasoning path: complete the task step by step; Example output: provide high-quality example output to help the model make correct inferences and alleviate the "hallucination" problem; Feedback adjustment: adjust the prompt content according to the output of small sample data; Knowledge graph construction: Based on the prompt template, extract key information and generate quintuples, including entity, relationship and entity category information, to construct structured quintuples that meet the knowledge graph standards; Optimization and feedback: The feedback mechanism is used to refine and optimize the results. First, the generated knowledge graph is evaluated; then, the prompt template is adjusted based on the feedback information to ensure that the next step of reasoning can better adapt to the task requirements.
2. The large model prompt design method for constructing a social governance knowledge graph based on CoT chain of thought according to claim 1, wherein The data preprocessing utilizes a deep learning model to perform semantic analysis of text content.
3. The large model prompt design method for constructing a social governance knowledge graph based on CoT chain of thought according to claim 1, characterized in that, The knowledge graph construction intelligently fills in relevant entities and relationships through a large model, and finally generates quintuple data.
4. The large model prompt design method for constructing a social governance knowledge graph based on CoT chain of thought according to claim 1, characterized in that, The optimization and feedback optimizes the expected output and prompt design according to actual application feedback to ensure that the generated prompt template can adapt to the task requirements.
Citation Information
Patent Citations
Social governance knowledge graph triple construction-oriented large model prompt template generation method
CN119323263A
Knowledge graph construction system and method based on cue words
CN119443253A