Humanized law enforcement verbal skill generation method based on knowledge graph retrieval enhancement

By building a knowledge graph and large language model optimization in the field of law enforcement, the problem of lack of personalization and precision of law enforcement speech is solved, and more professional and appropriate generation of law enforcement speeches is achieved, and the efficiency and quality of law enforcement are improved.

CN119597876APending Publication Date: 2025-03-11北京争上游科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411623249.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-14
Publication Date
2025-03-11

AI Technical Summary

Technical Problem

In the field of law enforcement, it is difficult for the existing technology to provide personalized and precise law enforcement speech, which makes it difficult for law enforcement personnel to communicate effectively when dealing with illegal acts, which may cause public misunderstandings and conflicts.

Method used

Using a method based on knowledge graph retrieval, we build a knowledge graph in the field of law enforcement, use key information to search, generate initial humanized law enforcement speech, and optimize through large language models to ultimately generate professional and appropriate law enforcement speech.

Benefits of technology

It improves the professionalism and normativeness of law enforcement speech, enhances the communication effect between law enforcement personnel and the public, reduces the occurrence of law enforcement errors and improper behaviors, and improves the efficiency and quality of law enforcement.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119597876A_ABST
    Figure CN119597876A_ABST
Patent Text Reader

Abstract

The invention discloses a humanized law enforcement verbal skill generation method based on knowledge graph retrieval enhancement, and belongs to the technical field of natural language processing, and the method comprises the following steps: S1, obtaining and preprocessing related text data in the field of law enforcement; s2, constructing a law enforcement field knowledge graph by using the preprocessed related text data; s3, performing retrieval in the law enforcement field knowledge graph by using key information to obtain most relevant knowledge; wherein the key information comprises keywords or key phrases extracted from a user query intention; s4, filling the key information and the most relevant knowledge into a corresponding law enforcement verbal skill template to obtain an initial humanized law enforcement verbal skill; and S5, inputting the initial humanized law enforcement verbal skill into a large language model, and optimizing the initial humanized law enforcement verbal skill by utilizing a cue word project to obtain a final humanized law enforcement verbal skill. According to the invention, accurate and humanized law enforcement verbal skills can be obtained, so that the law enforcement efficiency and the law enforcement quality of law enforcement officers are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of natural language processing technology, and more specifically to a method for generating humanized law enforcement speech based on knowledge graph retrieval enhancement. Background Art

[0002] With the rapid development of artificial intelligence technology and the explosive growth of law enforcement information, people's demand for personalized and precise law enforcement language is increasing.

[0003] The field of law enforcement involves a large amount of information such as laws, regulations, cases, and law enforcement procedures. As an effective knowledge management tool, knowledge graphs can store and manage this information. Through the retrieval of knowledge graphs, law enforcement officers can quickly obtain relevant laws, regulations, cases, law enforcement procedures, and other knowledge, helping them to better understand laws, regulations, and law enforcement procedures, reduce the occurrence of law enforcement errors and improper behavior, and thus improve the efficiency and quality of law enforcement services;

[0004] In addition, in many areas, there are often not many law enforcement officers who can enforce the law in a professional and humane manner, which leads to unprofessional and inhumane law enforcement language used by law enforcement officers in many remote areas. In this case, the public is often prone to misunderstand the behavior of law enforcement officers, which can easily lead to further conflicts.

[0005] Therefore, how to provide a method for generating humanized law enforcement scripts based on knowledge graph retrieval enhancement is an urgent problem that technicians in this field need to solve. Summary of the invention

[0006] In view of this, the purpose of the present invention is to provide a method for generating humanized law enforcement speech based on knowledge graph retrieval enhancement.

[0007] In order to achieve the above object, the present invention adopts the following technical solution:

[0008] A method for generating humanized law enforcement speech based on knowledge graph retrieval enhancement, characterized by comprising the following steps:

[0009] S1: Obtain relevant text data in the field of law enforcement and perform preprocessing;

[0010] S2: Use the pre-processed relevant text data to build a knowledge graph in the field of law enforcement;

[0011] S3: Using key information to search in the law enforcement field knowledge graph to obtain the most relevant knowledge; wherein the key information includes keywords or key phrases extracted from the user's query intent;

[0012] S4: Filling the key information and the most relevant knowledge into the corresponding law enforcement speech template to obtain initial humanized law enforcement speech;

[0013] S5: Input the initial humanized law enforcement speech into the large language model, and optimize the initial humanized law enforcement speech using prompt word engineering to obtain the final humanized law enforcement speech.

[0014] Preferably, the preprocessing in S1 includes data cleaning; the data cleaning includes removing text data with incorrect format, and removing redundant spaces and punctuation marks.

[0015] Preferably, S2 specifically includes:

[0016] S21: Define rules and templates for entity recognition and relationship extraction;

[0017] S22: manually annotating entities and relationships in a first data set using the rules and templates; wherein the first data set is part of the text data in the preprocessed related text data;

[0018] S23: training the automation model using the annotated first data set to obtain a trained automation model;

[0019] S24: inputting the second data set into the trained automated model to identify entities and relationships in each text data in the second data set; wherein the union of the second data set and the first data set constitutes the preprocessed related text data;

[0020] S25: Use the entities and relationships marked by S22 and the entities and relationships identified by S24 to construct the law enforcement field knowledge graph.

[0021] Preferably, S2 further comprises:

[0022] S26: Store the law enforcement field knowledge graph in the graph database Neo4j.

[0023] Preferably, the automated model is a NER model or an ER model.

[0024] Preferably, S3 specifically includes:

[0025] S31: Obtaining user query intention;

[0026] S32: parsing the user's query intention to obtain the key information;

[0027] S33: using the key information to retrieve relevant knowledge in the law enforcement field knowledge graph;

[0028] S34: Sort and filter the relevant knowledge retrieved in S33 to obtain the most relevant knowledge.

[0029] Preferably, the law enforcement speech templates include traffic law enforcement speech templates, public security law enforcement speech templates, economic crime law enforcement speech templates, environmental protection law enforcement speech templates and food and drug law enforcement speech templates.

[0030] Preferably, the traffic law enforcement speech template is a template designed for traffic violations, including violation confirmation, legal basis, punishment description, humanized suggestions and subsequent procedures;

[0031] The public security law enforcement speech template is designed for public security violations, including legal consequences, social harm and corresponding legal remedies;

[0032] The economic crime law enforcement script template is designed for economic crime behavior, including legal basis, evidence collection, amount involved and the penalties faced;

[0033] The environmental law enforcement speech template is designed for environmental law violations, including the importance of environmental protection, corresponding rectification measures and punishment basis;

[0034] The food and drug law enforcement script template is designed for food and drug violations, including food safety and consumer rights protection, corresponding reporting channels and punishment measures.

[0035] Preferably, the prompt word project includes role definition; the content of the role definition includes: you are an experienced law enforcement officer, please use a professional tone and consider the expression method to generate an appropriate and decent answer in combination with the input material.

[0036] An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method for generating humanized law enforcement speech based on knowledge graph retrieval enhancement is implemented.

[0037] It can be seen from the above technical solutions that, compared with the prior art, the present invention discloses a method for generating humanized law enforcement speech based on knowledge graph retrieval enhancement, which can achieve the following beneficial technical effects:

[0038] 1. The present invention constructs a knowledge graph through a semi-automatic construction method, integrates knowledge such as laws and regulations, cases, and law enforcement procedures related to the law enforcement field, overcomes the problem of data sparsity in traditional methods, and provides a more comprehensive and accurate knowledge basis for speech generation. Compared with completely manual construction, the semi-automatic construction method can significantly improve the efficiency and quality of knowledge graph construction, thereby helping law enforcement personnel to have a deeper understanding of the case and generate more targeted and persuasive law enforcement speech.

[0039] 2. The present invention designs personalized law enforcement speech templates according to different law enforcement scenarios and legal types to ensure the professionalism and standardization of law enforcement speech, and can change the tone of different scenario templates according to different scenarios to inform the law enforcement personnel of the severity of the illegal crimes.

[0040] 3. The present invention incorporates humanized suggestions into the speech template to reflect the warmth of law enforcement, help offenders understand their mistakes, and guide them to correct them.

[0041] 4. The present invention utilizes a generative large language model in the legal vertical field to optimize the generated law enforcement speech, making it more professional, appropriate, and in line with the language habits of law enforcement personnel.

[0042] 5. The present invention automatically generates law enforcement scripts based on knowledge graphs and artificial intelligence technology, saving the time and energy of law enforcement personnel and improving the efficiency and quality of law enforcement. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0044] Figure 1 A flowchart of a method for generating humanized law enforcement speech based on knowledge graph retrieval enhancement provided in an embodiment of the present invention;

[0045] Figure 2 A schematic diagram of an electronic device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0046] 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.

[0047] like Figure 1 As shown, the embodiment of the present invention discloses a method for generating humanized law enforcement speech based on knowledge graph retrieval enhancement, which is characterized by comprising the following steps:

[0048] S1: Obtain relevant text data in the field of law enforcement and perform preprocessing;

[0049] In one embodiment, the preprocessing in S1 includes data cleaning; the data cleaning includes removing text data with incorrect formats, and removing redundant spaces and punctuation marks.

[0050] S2: Use the pre-processed relevant text data to build a knowledge graph in the field of law enforcement;

[0051] In one embodiment, S2 specifically includes:

[0052] S21: Define rules and templates for entity recognition and relationship extraction;

[0053] Specifically: Based on the characteristics and needs of the law enforcement field, define the rules and templates for entity recognition and relationship extraction; in this embodiment, the entity can represent a specific illegal act, and the relationship can represent the violated legal clause;

[0054] For example, you can define entity types (such as "running a red light", "drunk driving", etc.) and relationship types (such as "violating legal provisions", etc.) related to traffic violations.

[0055] S22: manually annotating entities and relationships in a first data set using the rules and templates; wherein the first data set is part of the text data in the preprocessed related text data;

[0056] S23: training the automation model using the annotated first data set to obtain a trained automation model;

[0057] In one embodiment, the automated model is a NER model or an ER model.

[0058] S24: inputting the second data set into the trained automated model to identify entities and relationships in each text data in the second data set; wherein the union of the second data set and the first data set constitutes the preprocessed related text data;

[0059] S25: construct the law enforcement domain knowledge graph using the entities and relationships annotated in S22 and the entities and relationships identified in S24;

[0060] S26: Store the law enforcement field knowledge graph in the graph database Neo4j.

[0061] S3: using key information to search in the law enforcement field knowledge graph to obtain the most relevant knowledge; wherein the key information includes keywords or key phrases extracted from the user's query intent; in one embodiment, S3 specifically includes:

[0062] S31: Obtaining user query intention;

[0063] S32: parsing the user's query intention to obtain the key information;

[0064] It is understandable that the present invention provides a query interface for users to input query intentions. After receiving the user's query intentions, the user's query intentions are parsed to extract key information.

[0065] Extracting key information specifically includes lexical analysis, entity recognition, named entity recognition and information extraction:

[0066] 1) Lexical analysis: Decompose the user query intent text into words or phrases and mark their parts of speech to provide the basic structure for subsequent entity recognition, named entity recognition and information extraction.

[0067] 2) Entity recognition: Identify various entities in the text after lexical analysis, including named entities and other types of entities, so as to locate key information.

[0068] 3) Named Entity Recognition: specifically identifies named entities (such as names of people, places, dates, etc.) in text after lexical analysis to ensure that proper nouns in key information are accurately extracted.

[0069] 4) Information extraction: Further extract structured information, such as relationships, attributes, etc., from the identified entities to achieve in-depth mining and organization of key information.

[0070] S33: using the key information to retrieve relevant knowledge in the law enforcement field knowledge graph;

[0071] S34: Sort and filter the relevant knowledge retrieved in S33 to obtain the most relevant knowledge.

[0072] Specifically: Based on the extracted key information, use the graph database query language (such as cypher) to retrieve relevant laws and regulations, cases, law enforcement procedures and other knowledge in the law enforcement field knowledge graph. Sort and filter the relevant knowledge retrieved in the law enforcement field knowledge graph to obtain the most relevant knowledge.

[0073] S4: Filling the key information and the most relevant knowledge into the corresponding law enforcement speech template to obtain initial humanized law enforcement speech;

[0074] In a certain embodiment, the present invention constructs different law enforcement speech templates based on different law enforcement scenarios and legal types, and each law enforcement speech template includes a data query request and law enforcement speech template generation.

[0075] Specifically: The present invention divides law enforcement scenarios into the following categories according to the relevant text data of the law enforcement field obtained in S1, and constructs corresponding templates respectively:

[0076] Traffic law enforcement: Design special templates for traffic violations, such as running red lights, drunk driving, speeding, etc., covering violation confirmation, legal basis, punishment instructions, humanized suggestions and follow-up procedures.

[0077] Public security law enforcement: Design special templates for public security violations, such as theft, fighting, and provoking disturbances, emphasizing the legal consequences and social harm, and providing corresponding legal remedies.

[0078] Economic Crime Enforcement: Design a special template for economic crimes, focus on legal basis and evidence collection, and clearly state the amount involved and the possible penalties.

[0079] Environmental law enforcement: Design special templates for environmental violations, such as pollution emissions and damage to the ecological environment, emphasize the importance of environmental protection, and provide corresponding rectification measures and punishment basis.

[0080] Food and drug law enforcement: Design special templates for food and drug violations, focus on food safety and consumer rights protection, and provide corresponding reporting channels and punishment measures.

[0081] In this embodiment, the specific contents of the violation confirmation, legal basis, punishment description, humanized suggestions and subsequent processes in the traffic law enforcement speech template are as follows:

[0082] Confirmation of Violation: According to our records, you violated Article [Article No.] of the Traffic Safety Law at [time] and [location], and the specific behavior is [description of violation].

[0083] Legal basis: According to the Traffic Safety Law, your behavior constitutes [illegal nature].

[0084] Penalty description: According to the law, such violations are usually subject to [penalty type], including [specific penalty content].

[0085] Humanized suggestion: We understand that this may be an oversight or misunderstanding, but please understand the importance of obeying traffic laws. For the safety of you and others, please [improvement suggestion].

[0086] Subsequent process: If you have any objection to this enforcement, you have the right to raise an objection within [objection submission time limit] and can appeal through [objection submission channel].

[0087] In this embodiment, the most relevant knowledge retrieved (such as "running a red light", "a fine of 200 yuan and 6 points") and the extracted key information (such as "May 20, 2024", "Chenghua Avenue") are filled into the corresponding law enforcement speech template, and the completed law enforcement speech (i.e., the initial humanized law enforcement speech) is output.

[0088] S5: Input the initial humanized law enforcement speech into the large language model, and optimize the initial humanized law enforcement speech using prompt word engineering to obtain the final humanized law enforcement speech.

[0089] In one embodiment, the large language model is a generative large language model for the legal vertical field.

[0090] In one embodiment, the prompt word project includes role definition; the content of the role definition includes: You are an experienced law enforcement officer, please use a professional tone and consider the expression method to combine the above materials to generate an appropriate and decent answer.

[0091] Taking traffic law enforcement speech as an example, the final humanized law enforcement speech is:

[0092] Dear Mr. / Ms. Driver:

[0093] According to our records, you violated Article 47 of the Road Traffic Safety Law at the intersection of Guangming Street and Xinhua Road on November 8, 2023, by running a red light. I must point out that this behavior not only violates the law, but also increases the risk of road safety.

[0094] As a law enforcement officer, I have the responsibility to explain to you that according to the Road Traffic Safety Law, your behavior constitutes a violation of traffic light regulations. According to the law, such violations are usually subject to fines and deductions, including a fine of 200 yuan and 6 points on your driver's license.

[0095] I understand that in our busy daily lives, there may be times when we are in a hurry to get to where we are, but please recognize the importance of obeying traffic rules. For the safety of you and others, I strongly recommend that you strictly obey traffic lights and avoid running red lights in the future.

[0096] If you have any objection to this enforcement, you have the right to raise an objection within 15 working days. You can appeal through the designated channels on the official website of the Municipal Public Security Bureau Traffic Management Bureau, and we will carefully review your appeal.

[0097] Finally, I thank you for your cooperation and hope that you can learn a lesson from this experience, strictly abide by traffic regulations in the future, and work with us to maintain traffic order and the civilized image of the city.

[0098] I wish you safe driving and all the best in your future travels.

[0099] Sincerely, [name of law enforcement officer] [name of law enforcement unit].

[0100] The embodiment of the present invention also discloses a physical structure diagram of an electronic device, such as Figure 2As shown, the electronic device may include: a processor 201, a communication interface 202, a memory 203 and a communication bus 204, wherein the processor 201, the communication interface 202 and the memory 203 communicate with each other through the communication bus 204. The processor 201 may call the logic instructions in the memory 203 to execute the above-mentioned humanized law enforcement speech generation method based on knowledge graph retrieval enhancement.

[0101] In addition, the logic instructions in the above-mentioned memory 203 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in the embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0102] On the other hand, an embodiment of the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the above-mentioned method for generating humanized law enforcement speech based on knowledge graph retrieval enhancement.

[0103] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0104] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for generating humanized law enforcement speech based on knowledge graph retrieval enhancement, characterized in that: The following steps are involved: S1: Obtain relevant text data in the field of law enforcement and perform preprocessing; S2: Use the pre-processed relevant text data to build a knowledge graph in the field of law enforcement; S3: Using key information to search in the law enforcement field knowledge graph to obtain the most relevant knowledge; wherein the key information includes keywords or key phrases extracted from the user's query intent; S4: Filling the key information and the most relevant knowledge into the corresponding law enforcement speech template to obtain initial humanized law enforcement speech; S5: Input the initial humanized law enforcement speech into the large language model, and optimize the initial humanized law enforcement speech using prompt word engineering to obtain the final humanized law enforcement speech.

2. According to claim 1, a method for generating humanized law enforcement speech based on knowledge graph retrieval enhancement is characterized in that: The preprocessing in S1 includes data cleaning; the data cleaning includes removing text data with incorrect formats, and removing redundant spaces and punctuation marks.

3. According to claim 1, a method for generating humanized law enforcement speech based on knowledge graph retrieval enhancement is characterized in that: S2 specifically includes: S21: Define rules and templates for entity recognition and relationship extraction; S22: manually annotating entities and relationships in a first data set using the rules and templates; wherein the first data set is part of the text data in the preprocessed related text data; S23: training the automation model using the annotated first data set to obtain a trained automation model; S24: inputting the second data set into the trained automated model to identify entities and relationships in each text data in the second data set; wherein the union of the second data set and the first data set constitutes the preprocessed related text data; S25: Use the entities and relationships marked by S22 and the entities and relationships identified by S24 to construct the law enforcement field knowledge graph.

4. According to claim 3, a method for generating humanized law enforcement speech based on knowledge graph retrieval enhancement is characterized in that: S2 further comprises: S26: Store the law enforcement field knowledge graph in the graph database Neo4j.

5. According to claim 3, a method for generating humanized law enforcement speech based on knowledge graph retrieval enhancement is characterized in that: The automated model is a NER model or an ER model.

6. According to claim 1, a method for generating humanized law enforcement speech based on knowledge graph retrieval enhancement is characterized in that: S3 specifically includes: S31: Obtaining user query intention; S32: parsing the user's query intention to obtain the key information; S33: using the key information to retrieve relevant knowledge in the law enforcement field knowledge graph; S34: Sort and filter the relevant knowledge retrieved in S33 to obtain the most relevant knowledge.

7. According to claim 1, a method for generating humanized law enforcement speech based on knowledge graph retrieval enhancement is characterized in that: Law enforcement script templates include traffic law enforcement script template, public security law enforcement script template, economic crime law enforcement script template, environmental protection law enforcement script template and food and drug law enforcement script template.

8. According to claim 7, a method for generating humanized law enforcement speech based on knowledge graph retrieval enhancement is characterized in that: The traffic law enforcement script template is designed for traffic violations, including violation confirmation, legal basis, penalty description, humanized suggestions and follow-up procedures; The public security law enforcement speech template is designed for public security violations, including legal consequences, social harm and corresponding legal remedies; The economic crime law enforcement script template is designed for economic crime behavior, including legal basis, evidence collection, amount involved and the penalties faced; The environmental law enforcement speech template is designed for environmental law violations, including the importance of environmental protection, corresponding rectification measures and punishment basis; The food and drug law enforcement script template is designed for food and drug violations, including food safety and consumer rights protection, corresponding reporting channels and punishment measures.

9. According to claim 1, a method for generating humanized law enforcement speech based on knowledge graph retrieval enhancement is characterized in that: The prompt word project includes role definition; The role definition includes: You are an experienced law enforcement officer. Please use a professional tone and consider the expression to generate appropriate and decent responses in combination with the input materials.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, it implements the method for generating humanized law enforcement speech based on knowledge graph retrieval enhancement as described in any one of claims 1 to 9.