Smart city security abnormal event detection method and system

By introducing verifiable feedback reinforcement learning and vision-guided reasoning paradigms into smart city security monitoring systems, the problems of insufficient detection accuracy and interpretability in existing technologies are solved, and high-precision, low-false-alarm-rate abnormal event detection is achieved, adapting to multi-scenario applications.

CN120673348AActive Publication Date: 2025-09-19JIANGXI CLOUD EYE VISION TECH CO LTD

Patent Information

Application Number
CN202511178493.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-22
Publication Date
2025-09-19
Estimated Expiration
2045-08-22

AI Technical Summary

Technical Problem

Existing smart city security monitoring systems lack explicit reasoning, reflective calibration, and automatic evaluation capabilities in complex urban scenarios, resulting in high false alarm and missed alarm rates, and difficulty in achieving a good balance between detection accuracy, explainability, and training costs.

Method used

Adopting a verifiable feedback reinforcement learning mechanism and a visually guided reasoning paradigm, multi-stage training is performed by adding a positioning reasoning paradigm and a multi-dimensional reward function to the initial large model to optimize the detection performance and interpretability of the model. This includes adding prompt templates to the initial large model, designing reward functions, and training through multi-scenario, multi-dimensional reinforcement learning strategies.

Benefits of technology

It significantly reduces the false alarm rate and missed alarm rate, improves detection accuracy and explainability, and is adaptable to a variety of urban security scenarios, including public security, urban management, transportation, municipal administration, emergency response, environmental protection and other fields, with good practicality and promotion value.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120673348A_ABST
    Figure CN120673348A_ABST
Patent Text Reader

Abstract

The invention provides a smart city security abnormal event detection method and system, and the method comprises the steps: obtaining an initial large model, and adding a positioning reasoning normal form in the initial large model, so as to obtain an adjustment large model; designing and adjusting a reward function of the large model; performing first training on the adjustment large model based on a reward function and a first training sample to obtain a first training model; updating the reward function to obtain an updated reward function, and training the first training model for the second time based on a second training sample and the updated reward function to obtain a second training model; and inputting to-be-recognized smart city security anomaly input data into the second training model to output an anomaly recognition result, the method has significant advantages in the aspects of target positioning precision, interpretability and training efficiency, can adapt to various city security scenes, and provides important technical support for smart city construction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of smart city security monitoring, and specifically relates to a smart city security abnormal event detection method and system. Background Art

[0002] Smart city security monitoring systems are a crucial component of modern urban management. Their ability to accurately identify and promptly warn of unusual events is directly related to urban safety. Existing technologies for unusual event detection primarily rely on traditional deep learning methods, which suffer from numerous technical drawbacks in practical applications.

[0003] Conventional object detection methods based on algorithms like YOLO and DETR are limited to closed-category detection and lack generalization capabilities when faced with unknown event types in open scenarios. While open-vocabulary object detection models like OWL-ViT and Grounding-DINO have expanded their capabilities for identifying unknown domains, they remain insufficient for detecting unusual urban public safety events, which require complex semantic understanding and logical reasoning.

[0004] In recent years, large-scale visual language models such as LLaVA and Qwen-VL have improved visual understanding capabilities through collaborative learning of images and text. However, mainstream supervised fine-tuning methods are often limited to memorizing training samples and lack true logical reasoning and generalization capabilities. In complex urban security scenarios, these models often lack effective explanation mechanisms, making it difficult to accurately identify key areas and generate reasonable logical chain outputs, resulting in high false positive and false negative rates.

[0005] Among existing reinforcement learning methods, those based on human feedback rely heavily on manual preference annotation, resulting in high costs and subjectivity. While implicit reinforcement learning based on rule-based rewards can directly output positioning results, it lacks an explainable reasoning chain, making it difficult to meet the transparent decision-making requirements of security scenarios. Furthermore, while methods that rely on external toolchains perform well on certain tasks, they suffer from tool performance dependence, high inference latency, high deployment costs, and cold-start difficulties in actual deployments.

[0006] Therefore, the existing technology lacks a smart city security abnormal event detection method that can combine explicit reasoning, reflective calibration and automatic evaluation capabilities, and it is difficult to achieve a good balance between detection accuracy, explainability and training cost. Summary of the Invention

[0007] In order to solve the above technical problems, the present invention provides a smart city security abnormal event detection method and system for solving the technical problems in the prior art.

[0008] In one aspect, the present invention provides the following technical solution: a method for detecting abnormal security events in a smart city, comprising: Obtaining an initial large model, and adding a positioning reasoning paradigm to the initial large model to obtain an adjusted large model; Designing a reward function for adjusting the large model; Obtaining a first training sample, and performing a first training on the adjusted large model based on the reward function and the first training sample to obtain a first training model; Obtaining a second training sample, updating the reward function to obtain an updated reward function, and training the first training model a second time based on the second training sample and the updated reward function to obtain a second training model; Obtain the smart city security anomaly input data to be identified, and input the smart city security anomaly input data to be identified into the second training model to output an anomaly identification result.

[0009] Compared with the existing technology, the beneficial effects of the present invention are: in terms of detection accuracy, the present invention uses a verifiable feedback reinforcement learning mechanism and a visually guided reasoning paradigm, so that the system can more accurately identify abnormal events, significantly reduce false alarm rates and missed alarm rates, and improve detection performance in complex urban security scenarios. In terms of explainability, the present invention adopts an explicit reasoning chain generation mechanism, which can provide a complete reasoning process and spatial perception information, so that security personnel can understand the decision-making basis of the system, and improve the credibility and practicality of the system. In terms of generalization ability, the present invention can adapt to a variety of urban security scenarios, including public security, urban management, transportation, municipal administration, emergency response, environmental protection and other fields through multi-scenario and multi-dimensional reinforcement learning strategy optimization, and has good practicality and promotion value.

[0010] Preferably, the step of adding a positioning reasoning paradigm to the initial large model to obtain an adjusted large model includes: Adding a prompt template to the initial large model; Adding the thought tags in the prompt template to the initial large model, guiding the initial large model to perform systematic reasoning on the thought tags and output necessary bounding box information during the answering process; Adding the reflection tag in the prompt template to the initial large model, guiding the initial large model to reflect on whether the output bounding box information in the reflection tag is reasonable and evaluate how the corresponding spatial information supports the understanding and reasoning process; The answer tag in the prompt template is added to the initial large model, and the initial large model is guided to comprehensively think and reflect on the content in the answer tag and output a final answer to obtain an adjusted large model.

[0011] Preferably, in the step of designing the reward function for adjusting the large model, the reward function for:

[0012] ; ; ; Where, Representing a given problem The output of the following model and the real answer The reward function between Represent the first to fifth weight coefficients respectively, Reward for content quality, is the semantic matching reward, Reward for format compliance and structural integrity, To focus on regional rewards, For repeated punishment rewards, is the total number of samples in the current training batch, A content quality scorer based on a large model for comparing reference values ​​and predicted values. It is a semantic similarity evaluation function implemented based on the NLTK library. 、 Respectively The predicted output after the input passes through the large model and the corresponding reference answer, is the bounding box judgment value, is the answer quantity judgment value, is the additional reward weight.

[0013] Preferably, the step of performing a first training on the adjusted large model based on the reward function and the first training sample to obtain a first training model includes: For each input question in the first training sample , from the old strategy The response set is obtained by sampling , calculate the reward function value corresponding to each response in the response set through the reward function to obtain the reward set ; Calculate for each response in the response set Relative advantage of the group : ; ; Where, are the standard deviation and mean, For the The reward function value corresponding to the response, is the number of responses; Through the strategic network And the model parameters are adjusted by the objective function Update, where the objective function is: ; Where, is the mathematical expectation, is the sampling ratio, 、 、 Respectively represent the current policy network, old policy, and reference policy under given input Output is generated when The probability of is the sampling distribution on the input task space, is the clipping function, is the smoothing coefficient under the clipping function, is the KL regularization term weight, is the KL divergence, is the objective function value; The adjusted large model is trained for the first time using the objective function value and the maximized reward function until convergence to obtain a first training model.

[0014] Preferably, the step of updating the reward function to obtain an updated reward function, and training the first training model for a second time based on the second training sample and the updated reward function to obtain a second training model includes: In the reward function Add reinforcement learning rewards to get the updated reward function : ; Where, is the proportion of correct matches in the prediction box, is the proportion of successful matches in the standard truth frame; The first training model is trained for the second time using the same method as the first training and maximizing the updated reward function until convergence to obtain a second training model.

[0015] In a second aspect, the present invention provides the following technical solution: a smart city security abnormal event detection system, the system comprising: a prompting module, configured to obtain an initial large model and add a positioning reasoning paradigm to the initial large model to obtain an adjusted large model; A design module, configured to design a reward function for adjusting the large model; A first training module, configured to obtain a first training sample, and perform a first training on the adjusted large model based on the reward function and the first training sample to obtain a first training model; a second training module, configured to obtain a second training sample, update the reward function to obtain an updated reward function, and perform a second training on the first training model based on the second training sample and the updated reward function to obtain a second training model; The output module is used to obtain the smart city security anomaly input data to be identified, input the smart city security anomaly input data to be identified into the second training model, and output the anomaly identification result.

[0016] Preferably, the first training module includes: The collection submodule is used to answer each input question in the first training sample. , from the old strategy The response set is obtained by sampling , calculate the reward function value corresponding to each response in the response set through the reward function to obtain the reward set ; Advantage submodule, used to calculate each response in the response set Relative advantage of the group : ; ; Where, are the standard deviation and mean, For the The reward function value corresponding to the response, is the number of responses; Function submodule for passing policy network And the model parameters are adjusted by the objective function Update, where the objective function is: ; Where, is the mathematical expectation, is the sampling ratio, 、 、 Respectively represent the current policy network, old policy, and reference policy under given input Output is generated when The probability of is the sampling distribution on the input task space, is the clipping function, is the smoothing coefficient under the clipping function, is the KL regularization term weight, is the KL divergence, is the objective function value; The first training submodule is used to perform a first training on the adjusted large model by using the objective function value and the maximized reward function until convergence, so as to obtain a first training model.

[0017] Preferably, the second training module includes: The update submodule is used to update the reward function Add reinforcement learning rewards to get the updated reward function : ; Where, is the proportion of correct matches in the prediction box, is the proportion of successful matches in the standard truth frame; The second training submodule is used to train the first training model for the second time by adopting the same method as the first training and maximizing the updated reward function until convergence, so as to obtain a second training model.

[0018] In a third aspect, the present invention provides the following technical solution: a computer comprising 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 detecting abnormal security events in a smart city as described above is implemented.

[0019] In a fourth aspect, the present invention provides the following technical solution: a storage medium storing a computer program, which, when executed by a processor, implements the above-mentioned smart city security abnormal event detection method. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0021] Figure 1 This is a flow chart of the method for detecting abnormal security events in a smart city provided in the first embodiment of the present invention; Figure 2 This is a structural block diagram of the smart city security abnormal event detection system provided in Example 2 of the present invention; Figure 3 A schematic diagram of the hardware structure of a computer provided in another embodiment of the present invention.

[0022] The embodiments of the present invention will be further described below with reference to the accompanying drawings. DETAILED DESCRIPTION

[0023] The following describes embodiments of the present invention in detail, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the embodiments of the present invention, and should not be construed as limiting the present invention.

[0024] Example 1 In the first embodiment of the present invention, Figure 1 As shown, a method for detecting abnormal security events in a smart city includes: S1. Obtain an initial large model, and add a positioning reasoning paradigm to the initial large model to obtain an adjusted large model; The initial large model here is the Qwen2.5-VL-Instruct-3B model, and its positioning reasoning paradigm differs from traditional plain text models and reasoning models based on implicit Chain of Thought (CoT). The core innovation of this paradigm lies in explicitly requiring the model to generate reasoning processes during the training phase, and explicitly embedding spatial perception information into it, guiding the model to reflect on and calibrate its own reasoning behavior.

[0025] Wherein, the step S1 includes: S11, adding a prompt template to the initial large model; S12, adding the thought tags in the prompt template to the initial large model, guiding the initial large model to perform systematic reasoning on the thought tags and output necessary bounding box information during the answering process; Specifically, for a given question, guided by the prompt template, we first conduct systematic reasoning in the thinking label, and output the necessary bounding box information in the format of (x1, y1, x2, y2) in the process of answering according to actual needs.

[0026] S13, adding the reflection tag in the prompt template to the initial large model, guiding the initial large model to reflect on whether the output bounding box information in the reflection tag is reasonable and evaluate how the corresponding spatial information supports the understanding and reasoning process; Specifically, in the reflection tab, reflect on whether the visual areas extracted by the model are reasonable and evaluate how this spatial information supports the understanding and reasoning process.

[0027] S14, adding the answer tag in the prompt template to the initial large model, guiding the initial large model to comprehensively think and reflect on the content in the answer tag and output a final answer, so as to obtain an adjusted large model; Specifically, the above content is integrated into the answer model to give a clear and complete final answer; It should be noted that the given questions here are specifically questions that are input to the model. The structured output format of "think-reflect-answer" ensures the transparency and explainability of the reasoning process. In addition, to prevent the model from being tampered with by rewards, no overly strict constraints such as content format or positioning box accuracy are imposed. Instead, the model is encouraged to freely explore in a broader word space, thereby independently searching for the most reasonable and effective reasoning path in the current environment. The prompt template design includes clear task instructions, output format requirements, and reasoning guidance information. Through a specific label structure, the model is guided to generate a reasoning chain that meets the expectations. The model needs to clearly mark the spatial area of ​​interest during the reasoning process and reflect on and verify the reasoning results.

[0028] S2. Designing a reward function for adjusting the large model; Specifically, the reward model in this application is a multi-dimensional and multi-level reward system to ensure that the model achieves balanced optimization between accuracy, readability and positioning quality.

[0029] Among them, the reward function for:

[0030] ; ; ; Where, Representing a given problem The output of the following model and the real answer The reward function between Represent the first to fifth weight coefficients respectively, Reward for content quality, is the semantic matching reward, Reward for format compliance and structural integrity, To focus on regional rewards, For repeated punishment rewards, is the total number of samples in the current training batch, A content quality scorer based on a large model for comparing reference values ​​and predicted values. It is a semantic similarity evaluation function implemented based on the NLTK library. 、 Respectively The predicted output after the input passes through the large model and the corresponding reference answer, is the bounding box judgment value, is the answer quantity judgment value, is the additional reward weight; It should be noted that for content quality rewards, trajectory sampling in the evaluation environment is implemented through the LLM-as-a-judge mechanism. This mechanism provides reward signals for accuracy and depth for model-generated results, effectively avoiding the problem of incorrectly eliminating correct content samples due to superficial flaws such as formatting specifications, thereby increasing reward sparsity. The detailed prompt for content quality rewards is shown in the following example: You are a professional evaluation expert, responsible for evaluating the quality of the model's answers based on the reference answers. You need to score the model's answers based on accuracy, completeness, relevance, and consistency with the standard answers, with a score range of -1 to 1. 1 indicates high consistency with the reference answer, 0 indicates that the answer is mostly correct but incomplete, and -1 indicates that the answer is incorrect or of poor quality. After reviewing the following content, please output your evaluation results in JSON format: {"score": <score>}. Question: {q}, Answer: {s}, Reference Answer: {a}.

[0031] In addition, in order to avoid occasional errors, this application introduces a retry mechanism to ensure the stability and reliability of the evaluation results.

[0032] As for the semantic matching reward, it is used to measure the consistency and fit between the answer generated by the model and the reference answer at the semantic level. This reward item is designed to capture situations that may be literally different but semantically equivalent or similar, thereby supplementing the traditional surface-based matching method.

[0033] As for the format specification and structural integrity rewards, they are used to test whether the model output follows the preset structured template, especially whether the model correctly generates paired and reasonably nested format tags (such as <think> ...< / think> 、 <reflect> ...< / reflect> 、 <answer> ...< / answer> ), which uses a simple and efficient regular matching rule-driven verification mechanism to check whether necessary tags exist, whether the order is correct, and whether the nesting is standardized, thereby ensuring the structural integrity and format of the generated content. This mechanism helps to improve the clarity and parsability of answers and reduce downstream processing obstacles caused by format errors.

[0034] As for the focus area reward, in order to further improve the perception and reasoning ability of the model in visual tasks, especially in tasks involving object positioning, area counting, etc., accurately identify and utilize the key area information in the image, a focus area reward module is introduced to judge whether the model actively pays attention to the target area in the visual input during the response generation process, and give reward signals accordingly to promote the spatial alignment and causal reasoning ability of the model generation process. Specifically, this module detects whether the model explicitly uses <think>stage, and whether the content of this stage contains a legal target box expression format, so as to identify whether the model has autonomous attention and reasoning behavior based on the region. If legal target region information is detected, a basic reward is given; in addition, for some special tasks such as counting tasks, if the model <think>If the number of areas mentioned in the thinking stage is consistent with the count value in the standard answer, an additional reward will be given to enhance the model's target detection ability and counting consistency. The bounding box judgment value specifically indicates whether the model contains valid bounding box information in the thinking stage. The answer quantity judgment value specifically indicates whether the number of areas mentioned by the model is consistent with the true answer in the counting task. The additional reward weight is only for special tasks. This reward mechanism encourages the model to explicitly call image area knowledge during the generation process, especially to perform sub-tasks such as target detection and region positioning in the thinking stage. It not only helps to improve the accuracy and reliability of the model in complex visual tasks (such as object counting and target screening), but also enhances the interpretability of the model and the explicitness of the reasoning path, providing basic support for subsequent high-level multimodal intelligent tasks.

[0035] To improve the diversity and naturalness of the language generation model's output and prevent repetitive fragments or patterned output during responses, a repetitive reward mechanism was introduced. This mechanism detects repetitiveness in the model's generated text and provides negative incentives for samples with redundant structures, thereby guiding the model to express more fluent, concise, and informative semantics. This reward mechanism utilizes a dual-granularity design: First, a fixed-window sliding N-gram check is performed on the generated text at the word level to calculate the repetition ratio between consecutive fragments. Second, an equivalent repetition check is performed at the token ID level (i.e., the encoding level generated by the model) to identify potential redundancies in the model's generated patterns. The repetition rates at both granularities are normalized and their scores are combined to calculate the final repetition penalty score. When the model output is short or does not meet the detection requirements, a default neutral reward is assigned to maintain robustness. The final reward is scaled within a set range and incorporated as a negative factor in the overall reward function to effectively curb looping outputs during generation and improve output quality. This mechanism is particularly suitable for tasks such as open-ended question answering and description generation. It helps the model avoid templated answers and enhance the language diversity and readability of the answer content.

[0036] S3. Obtain a first training sample, and perform a first training on the adjusted large model based on the reward function and the first training sample to obtain a first training model; Specifically, for the first training sample and the second training sample in this application, its data engineering adopts a comprehensive and sophisticated strategy to ensure the quality and diversity of the training data. The data sources cover three levels: online data accumulated in business scenarios, high-quality datasets publicly available in academia such as VSR and GQA, and high-resolution images crawled from websites such as Pixabay. All collected data undergo a rigorous automated cleaning process to filter out images with low resolution, blur, improper exposure, damage, or homogeneous content. By designing a unified metadata format template, the template contains key attributes such as task type, application scenario, and difficulty. The task type is subdivided into dimensions such as spatial understanding, quantity recognition, event judgment, and behavior detection to support differentiated reward optimization strategies. The application scenarios cover real-world scenarios such as public security, urban management, transportation, municipal administration, emergency response, environmental protection, education, community, and industry, enhancing the practicality of the model. The difficulty level divides samples into two levels: simple and difficult based on standards such as semantic complexity and counting scale, and is used for subsequent multi-stage training strategies. The first training sample is a simple sample and the second training sample is a difficult sample.

[0037] At the same time, for the first and second training processes, a two-stage training strategy is adopted. The first training only uses simple samples for training. Based on the aforementioned reward design, the model quickly masters the basic reasoning structure and content generation requirements. This stage focuses on cultivating the model's basic reasoning ability and format specification awareness, laying the foundation for subsequent complex task training. In this process, based on Qwen2.5-VL-Instruct-3B, the Group Relative Policy Optimization (GRPO) algorithm is combined for reinforcement learning optimization. The process includes policy network initialization, experience sampling, reward calculation, policy update, and convergence judgment. GRPO implements a comparative unsupervised advantage design. While retaining the core clipping mechanism of PPO (Proximal Policy Optimization), it cancels the value The network is no longer dependent on the training set, and the average reward of a group of samples generated by the same problem is used as the benchmark, which significantly reduces the consumption of training resources and has the characteristics of strong stability and comparative optimization. The second training is carried out using difficult samples. In order to quantify the performance of the model on the clustered targets, the present invention introduces an additional reward evaluation system based on positioning accuracy, namely reinforcement learning reward. For the output results of the model on the set of predicted bounding boxes and the set of standard true bounding boxes, a strict matching criterion is established: a valid matching pair is considered to be formed only when the intersection of the predicted box and the true value box reaches a specified threshold. This strict standard is intended to guide the model to gradually learn to accurately locate the key areas during the training process to support subsequent high-quality reasoning and answer generation.

[0038] Wherein, the step S3 includes: S31: For each input question in the first training sample , from the old strategy The response set is obtained by sampling , calculate the reward function value corresponding to each response in the response set through the reward function to obtain the reward set .

[0039] S32. Calculate each response in the response set. Relative advantage of the group : ; ; Where, are the standard deviation and mean, For the The reward function value corresponding to the response, is the number of responses.

[0040] S33, through the policy network And the model parameters are adjusted by the objective function Update, where the objective function is: ; Where, is the mathematical expectation, is the sampling ratio, 、 、 Respectively represent the current policy network, old policy, and reference policy under given input Output is generated when The probability of is the sampling distribution on the input task space, is the clipping function, is the smoothing coefficient under the clipping function, is the KL regularization term weight, is the KL divergence, is the objective function value; Specifically, the old policy here refers to the behavioral policy used for sampling. The purpose of the smoothing coefficient is to add restrictions to prevent the distribution from drastically deviating from the old policy and improve training robustness. The KL regularization term weight is to maintain the distribution consistency between the sampling policy and the reference policy. The KL divergence is to prevent the new policy from deviating too far from the original model and guide learning to stably align the target distribution. As for the reference policy, it comes from the original model and remains unchanged during training, which is used to guide the stability of the policy distribution.

[0041] S34, performing a first training on the adjusted large model using the objective function value and the maximized reward function until convergence, to obtain a first training model; Specifically, during the actual training process, by maximizing the function value of the expected reward function, the training process will continuously drive the model to improve its visual positioning ability and ensure that the model continues to focus on the most relevant information areas during the inference chain generation process.

[0042] S4. Obtain a second training sample, update the reward function to obtain an updated reward function, and train the first training model for a second time based on the second training sample and the updated reward function to obtain a second training model; Wherein, the step S4 includes: S41, in the reward function Add reinforcement learning rewards to get the updated reward function : ; Where, is the proportion of correct matches in the prediction box, is the proportion of successful matches in the standard truth frame; Specifically, by introducing reinforcement learning rewards, this reward signal can maintain the model's positioning accuracy while taking into account the comprehensiveness of target detection, thereby providing a stable and meaningful feedback mechanism for the policy optimization process.

[0043] S42, training the first training model for a second time using the same method as the first training and maximizing the updated reward function until convergence to obtain a second training model; At the same time, the method used in the second training is the same as that in the first training, except that a new reward signal is introduced during the second training process. It is worth noting that the matching threshold will gradually increase as the training process progresses, thereby realizing a coarse-to-fine strategy learning path, that is, in the early stage, large deviations are tolerated to ensure training stability, and in the later stage, the standards are gradually tightened to promote the model to learn to locate boundaries more finely.

[0044] S5. Obtaining input data of the smart city security anomaly to be identified, and inputting the input data of the smart city security anomaly to be identified into the second training model to output an anomaly identification result; Specifically, the second training model of this application is deployed at the front-end node of the smart city security system. It is responsible for quickly identifying and reasoning about abnormal events in images in actual application scenarios. It directly calls the visual language model that has completed the above-mentioned implementation steps and has a visual positioning and reasoning thinking chain output. By focusing on the input image and outputting a structured result containing "reasoning process + spatial positioning + self-reflection", it provides highly explainable intelligent support for security decision-making. The model follows the "thinking-reflection-answer" reasoning chain generation paradigm. After receiving the image input, the model first extracts potential abnormal areas in the image through the visual perception component and clearly indicates their spatial coordinates in the output. For example, the following is the output of the model when processing an image of a traffic accident scene: Thought Process: The coordinates for the signs of a traffic accident are approximately (486, 334, 606, 373). The broken pieces of the car are visible on the road, indicating a possible accident. Reflection Verification: The broken pieces of the car on the road suggest that there has been a traffic accident. The signs of the accident are clearly visible. Final answer: Yes, there are signs of a traffic accident in this picture. As can be seen from the above examples, the model not only provides clear spatial positioning information (such as the coordinates of the accident signs in the image), but also uses natural language to describe its reasoning basis (for example, "broken car wreckage"). During the reflection phase, semantic cross-validation is performed to enhance the robustness and credibility of the judgment results. The final conclusion is presented in a concise and clear sentence, suitable for direct display in the front-end system or as an alarm basis for reporting to the back-end platform.

[0045] The method for detecting abnormal events in smart city security provided in Example 1 of the present invention has the advantages of more accurate detection accuracy, significantly reducing false alarm and missed alarm rates, and improving detection performance in complex urban security scenarios through a verifiable feedback reinforcement learning mechanism and a visually guided reasoning paradigm. In terms of explainability, the present invention adopts an explicit reasoning chain generation mechanism, which can provide a complete reasoning process and spatial perception information, enabling security personnel to understand the decision-making basis of the system, thereby improving the credibility and practicality of the system. In terms of generalization ability, the present invention can adapt to a variety of urban security scenarios, including public security, urban management, transportation, municipal administration, emergency response, environmental protection and other fields, through multi-scenario and multi-dimensional reinforcement learning strategy optimization, and has good practicality and promotion value.

[0046] Example 2 like Figure 2 As shown, in a second embodiment of the present invention, a smart city security abnormal event detection system is provided, the system comprising: Prompt module 1, used to obtain an initial large model, and add a positioning reasoning paradigm to the initial large model to obtain an adjusted large model; Design module 2, used to design the reward function of the adjustment model; A first training module 3 is configured to obtain a first training sample, and perform a first training on the adjusted large model based on the reward function and the first training sample to obtain a first training model; A second training module 4 is configured to obtain a second training sample, update the reward function to obtain an updated reward function, and perform a second training on the first training model based on the second training sample and the updated reward function to obtain a second training model; The output module 5 is used to obtain the input data of the smart city security anomaly to be identified, input the input data of the smart city security anomaly to be identified into the second training model, and output the anomaly identification result.

[0047] Wherein, the prompt module 1 includes: A prompt submodule, used for adding a prompt template to the initial large model; A thinking submodule, configured to add the thinking tags in the prompt template to the initial large model, guide the initial large model to perform systematic reasoning on the thinking tags and output necessary bounding box information during the answering process; a reflection submodule, configured to add the reflection tag in the prompt template to the initial large model, guiding the initial large model to reflect on whether the output bounding box information in the reflection tag is reasonable and to evaluate how the corresponding spatial information supports the understanding and reasoning process; The answer submodule is used to add the answer tag in the prompt template to the initial large model, guide the initial large model to comprehensively think and reflect on the content in the answer tag and output the final answer to obtain the adjusted large model.

[0048] The first training module 3 includes: The collection submodule is used to answer each input question in the first training sample. , from the old strategy The response set is obtained by sampling , calculate the reward function value corresponding to each response in the response set through the reward function to obtain the reward set ; Advantage submodule, used to calculate each response in the response set Relative advantage of the group : ; ; Where, are the standard deviation and mean, For the The reward function value corresponding to the response, is the number of responses; Function submodule for passing policy network And the model parameters are adjusted by the objective function Update, where the objective function is: ; Where, is the mathematical expectation, is the sampling ratio, 、 、 Respectively represent the current policy network, old policy, and reference policy under given input Output is generated when The probability of is the sampling distribution on the input task space, is the clipping function, is the smoothing coefficient under the clipping function, is the KL regularization term weight, is the KL divergence, is the objective function value; The first training submodule is used to perform a first training on the adjusted large model by using the objective function value and the maximized reward function until convergence, so as to obtain a first training model.

[0049] The second training module 4 includes: The update submodule is used to update the reward function Add reinforcement learning rewards to get the updated reward function : ; Where, is the proportion of correct matches in the prediction box, is the proportion of successful matches in the standard truth frame; The second training submodule is used to train the first training model for the second time by adopting the same method as the first training and maximizing the updated reward function until convergence, so as to obtain a second training model.

[0050] In other embodiments of the present invention, the embodiments of the present invention provide the following technical solutions: a computer comprising a memory 102, a processor 101, and a computer program stored on the memory 102 and executable on the processor 101; the processor 101 implements the above-described method for detecting abnormal security events in a smart city when executing the computer program.

[0051] Specifically, the processor 101 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured as one or more integrated circuits for implementing the embodiments of the present invention.

[0052] Memory 102 may include a large-capacity memory for data or instructions. By way of example, and not limitation, memory 102 may include a hard disk drive (HDD), a floppy disk drive, a solid-state drive (SSD), flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 102 may include removable or non-removable (or fixed) media. Where appropriate, memory 102 may be internal or external to the data processing device. In certain embodiments, memory 102 is non-volatile memory. In certain embodiments, memory 102 includes read-only memory (ROM) and random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically alterable ROM (EAROM) or a flash memory (FLASH), or a combination of two or more of these. Under appropriate circumstances, the RAM can be a static random access memory (SRAM) or a dynamic random access memory (DRAM), where the DRAM can be a fast page mode dynamic random access memory (FPMDRAM), an extended data output dynamic random access memory (EDODRAM), a synchronous dynamic random access memory (SDRAM), etc.

[0053] The memory 102 may be used to store or cache various data files that need to be processed and / or used for communication, as well as possible computer program instructions executed by the processor 101 .

[0054] The processor 101 implements the above-mentioned smart city security abnormal event detection method by reading and executing computer program instructions stored in the memory 102.

[0055] In some embodiments, the computer may further include a communication interface 103 and a bus 100. Figure 3 As shown, the processor 101 , the memory 102 , and the communication interface 103 are connected via a bus 100 and communicate with each other.

[0056] The communication interface 103 is used to implement communication between the various modules, devices, units, and / or equipment in the embodiments of the present invention. The communication interface 103 can also implement data communication with other components such as external devices, image / data acquisition equipment, databases, external storage, and image / data processing workstations.

[0057] Bus 100 includes hardware, software, or both, and couples components of a computer device to each other. Bus 100 includes, but is not limited to, at least one of the following: a data bus, an address bus, a control bus, an expansion bus, and a local bus. By way of example and not limitation, bus 100 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses, or a combination of two or more of these. Bus 100 may include one or more buses, where appropriate. Although embodiments of the present invention describe and illustrate a particular bus, the present invention contemplates any suitable bus or interconnect.

[0058] The computer can execute the smart city security abnormal event detection method of the present invention based on the acquired smart city security abnormal event detection system, thereby realizing smart city security abnormal event detection.

[0059] In some further embodiments of the present invention, in combination with the above-mentioned smart city security abnormal event detection method, the embodiments of the present invention provide the following technical solutions: a storage medium having a computer program stored thereon, and the computer program implements the above-mentioned smart city security abnormal event detection method when executed by a processor.

[0060] Those skilled in the art will appreciate that the logic and / or steps represented in the flowcharts or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing the logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (e.g., a computer-based system, a system including a processor, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For purposes of this specification, "computer-readable medium" refers to any device that can contain, store, communicate, propagate, or transport a program for use by, or in conjunction with, an instruction execution system, apparatus, or device.

[0061] More specific examples (a non-exhaustive list) of computer-readable media include the following: an electrical connection with one or more wires (electronic devices), a portable computer disk cartridge (magnetic devices), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disc read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering, or processing in another suitable manner as necessary, and then stored in a computer memory.

[0062] It should be understood that various components of the present invention may be implemented using hardware, software, firmware, or a combination thereof. In the aforementioned embodiments, multiple steps or methods may be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented using hardware, as in another embodiment, any one or a combination of the following technologies known in the art may be used: a discrete logic circuit having logic gate circuits for implementing logic functions on data signals, an application-specific integrated circuit having suitable combinational logic gate circuits, a programmable gate array (PGA), a field-programmable gate array (FPGA), etc.

[0063] The technical features of the above-mentioned embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above-mentioned embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0064] The above-described embodiments merely represent several implementations of the present invention, and while their descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the patent. It should be noted that a person of ordinary skill in the art would be able to make numerous variations and improvements without departing from the spirit of the present invention, and these variations and improvements fall within the scope of protection of the present invention. Therefore, the scope of protection of the patent for this invention shall be determined by the appended claims.< / think> < / think> < / score>

Claims

1. A method for detecting abnormal security events in smart cities, characterized in that: include: Obtaining an initial large model, and adding a positioning reasoning paradigm to the initial large model to obtain an adjusted large model; Designing a reward function for adjusting the large model; Obtaining a first training sample, and performing a first training on the adjusted large model based on the reward function and the first training sample to obtain a first training model; Obtaining a second training sample, updating the reward function to obtain an updated reward function, and training the first training model a second time based on the second training sample and the updated reward function to obtain a second training model; Obtain the smart city security anomaly input data to be identified, and input the smart city security anomaly input data to be identified into the second training model to output an anomaly identification result.

2. The method for detecting abnormal security events in smart cities according to claim 1, characterized in that: The step of adding a positioning reasoning paradigm to the initial large model to obtain an adjusted large model includes: Adding a prompt template to the initial large model; Adding the thought tags in the prompt template to the initial large model, guiding the initial large model to perform systematic reasoning on the thought tags and output necessary bounding box information during the answering process; Adding the reflection tag in the prompt template to the initial large model, guiding the initial large model to reflect on whether the output bounding box information in the reflection tag is reasonable and evaluate how the corresponding spatial information supports the understanding and reasoning process; The answer tag in the prompt template is added to the initial large model, and the initial large model is guided to comprehensively think and reflect on the content in the answer tag and output a final answer to obtain an adjusted large model.

3. The method for detecting abnormal security events in smart cities according to claim 1, characterized in that: In the step of designing the reward function for adjusting the large model, the reward function for: ; ; ; Where, Representing a given problem The output of the following model and the real answer The reward function between Represent the first to fifth weight coefficients respectively, Reward for content quality, is the semantic matching reward, Reward for format compliance and structural integrity, To focus on regional rewards, For repeated punishment rewards, is the total number of samples in the current training batch, A content quality scorer based on a large model for comparing reference values ​​and predicted values. It is a semantic similarity evaluation function implemented based on the NLTK library. 、 Respectively The predicted output after the input passes through the large model and the corresponding reference answer, is the bounding box judgment value, is the answer quantity judgment value, is the additional reward weight.

4. The method for detecting abnormal security events in smart cities according to claim 1, wherein: The step of performing a first training on the adjusted large model based on the reward function and the first training sample to obtain a first training model includes: For each input question in the first training sample , from the old strategy The response set is obtained by sampling , calculate the reward function value corresponding to each response in the response set through the reward function to obtain the reward set ; Calculate for each response in the response set Relative advantage of the group : ; ; Where, are the standard deviation and mean, For the The reward function value corresponding to the response, is the number of responses; Through the strategic network And the model parameters are adjusted by the objective function Update, where the objective function is: ; Where, is the mathematical expectation, is the sampling ratio, 、 、 Respectively represent the current policy network, old policy, and reference policy under given input Output is generated when The probability of is the sampling distribution on the input task space, is the clipping function, is the smoothing coefficient under the clipping function, is the KL regularization term weight, is the KL divergence, is the objective function value; The adjusted large model is trained for the first time using the objective function value and the maximized reward function until convergence to obtain a first training model.

5. The method for detecting abnormal security events in smart cities according to claim 1, wherein: The step of updating the reward function to obtain an updated reward function, and training the first training model for a second time based on the second training sample and the updated reward function to obtain a second training model includes: In the reward function Add reinforcement learning rewards to get the updated reward function : ; Where, is the proportion of correct matches in the prediction box, is the proportion of successful matches in the standard truth frame; The first training model is trained for the second time using the same method as the first training and maximizing the updated reward function until convergence to obtain a second training model.

6. A smart city security abnormal event detection system, characterized in that: The system comprises: a prompting module, configured to obtain an initial large model and add a positioning reasoning paradigm to the initial large model to obtain an adjusted large model; A design module, configured to design a reward function for adjusting the large model; A first training module, configured to obtain a first training sample, and perform a first training on the adjusted large model based on the reward function and the first training sample to obtain a first training model; a second training module, configured to obtain a second training sample, update the reward function to obtain an updated reward function, and perform a second training on the first training model based on the second training sample and the updated reward function to obtain a second training model; The output module is used to obtain the smart city security anomaly input data to be identified, input the smart city security anomaly input data to be identified into the second training model, and output the anomaly identification result.

7. The smart city security abnormal event detection system according to claim 6, characterized in that: The first training module includes: The collection submodule is used to answer each input question in the first training sample. , from the old strategy The response set is obtained by sampling , calculate the reward function value corresponding to each response in the response set through the reward function to obtain the reward set ; Advantage submodule, used to calculate each response in the response set Relative advantage of the group : ; ; Where, are the standard deviation and mean, For the The reward function value corresponding to the response, is the number of responses; Function submodule for passing policy network And the model parameters are adjusted by the objective function Update, where the objective function is: ; Where, is the mathematical expectation, is the sampling ratio, 、 、 Respectively represent the current policy network, old policy, and reference policy under given input Output is generated when The probability of is the sampling distribution on the input task space, is the clipping function, is the smoothing coefficient under the clipping function, is the KL regularization term weight, is the KL divergence, is the objective function value; The first training submodule is used to perform a first training on the adjusted large model by using the objective function value and the maximized reward function until convergence, so as to obtain a first training model.

8. The smart city security abnormal event detection system according to claim 6, characterized in that: The second training module includes: The update submodule is used to update the reward function Add reinforcement learning rewards to get the updated reward function : ; Where, is the proportion of correct matches in the prediction box, is the proportion of successful matches in the standard truth frame; The second training submodule is used to train the first training model for the second time by adopting the same method as the first training and maximizing the updated reward function until convergence, so as to obtain a second training model.

9. A computer 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, the method for detecting abnormal security events in a smart city as described in any one of claims 1 to 5 is implemented.

10. A storage medium, characterized in that: The storage medium stores a computer program, which, when executed by a processor, implements the smart city security abnormal event detection method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Power transmission channel construction machinery identification method based on incremental learning algorithm

    CN117809239A

  • Power distribution network overhead line radar external damage prevention device based on AI and vehicle intelligent identification

    CN118262286A

  • Model training method and device, electronic equipment and storage medium

    CN120409744A

  • Knowledge distillation method and electronic device

    WO2025086778A1

Cited By

  • Industrial image anomaly detection and segmentation method based on reinforcement learning and cross-modal alignment

    CN120912993A

  • Construction method of reward model and construction method of reasoning model

    CN121052328A

  • Threat object detection method based on reinforcement learning

    CN121415369A

  • Display method, electronic device, readable storage medium and program product

    CN121833099A

  • Weld joint intelligent defect detection model training method, detection method and electronic equipment

    CN122199516A