Public safety emergency prediction method and system
Through deep learning neural networks that extract event theme encodings on multiple social platform clients and utilize spatiotemporal attention mechanisms, the problem of inaccurate event theme extraction in the existing technology is solved, and the accuracy of public safety emergencies is improved. and privacy.
Patent Information
- Application Number
- CN202410965025.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2024-12-20
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the prediction of public safety emergencies, the existing technology failed to effectively consider the semantic information of the document in the dataset, resulting in inaccurate extraction of event subject words. Especially when facing lengthy event sequences, they will encounter dimension-related challenges, which affects the accuracy of prediction. sex.
Multiple clients are deployed on social platforms, event topic encoding is extracted through preset encoding modules, and deep learning neural networks that integrate spatiotemporal attention weighting mechanisms are used to continuously process event topics and calculate other clients' target client. Influence and scientific influence context, mapped to the same semantic space to obtain the prediction results of the event-themed sequence for the next moment.
It improves the accuracy of extracting topic terms for public safety emergencies and the credibility of predicted results, while improving data privacy and security through federated learning, reducing data transmission needs.
Smart Images

Figure CN119167890A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of event prediction, and in particular to a method and system for predicting public safety emergencies. Background Art
[0002] In the data age, the massive amount of information collected on social media platforms has a profound impact on people's lives and the decision-making of decision-making departments. Public safety emergencies in the mobile Internet environment have become an important research topic for public regulatory agencies and academia. Effective acquisition and prediction of public safety emergency topics can objectively and accurately grasp the development direction of public safety emergencies, enable decision-making departments to more accurately grasp the development trend of events, and are of great significance to the relevant management departments in carrying out emergency management, control and decision-making. However, most of the relevant information on the topic of public safety emergencies appears in the form of unstructured natural language texts. How to obtain rich event situation information from these massive texts has become the key to predicting the development trend of public safety emergencies and solving general event prediction problems. When discussing public safety emergencies in the mobile Internet environment, we also need to pay attention to the problem of data non-sharing between social media platforms and how to properly handle data privacy. Although various media social platforms play an important role in information dissemination, each platform operates independently and data exchange is limited, which hinders a comprehensive understanding of public safety events and affects the effectiveness of decision-making.
[0003] In the existing technology, predicting the future trend of public safety emergencies is a time series prediction problem. At present, deep learning architectures such as differential integrated moving average autoregressive model, recurrent neural network, long short-term memory network, gated recurrent unit, convolutional neural network, graph neural network and Transformer have been widely used in various event prediction tasks. However, existing research mainly relies on time series data and graphic data of event development, which requires accurate and efficient preprocessing to represent events as such data. Since the semantic information of the documents in the dataset is not considered, the correct event subject words cannot be extracted; on the other hand, some methods represent event information by using the unique hot vector encoding of words in the text, supplemented by additional numerical data, but these methods will encounter challenges related to dimension when facing lengthy event sequences. Therefore, how to accurately extract the theme of public safety emergencies and accurately predict future developments is a problem that needs to be solved urgently. Summary of the invention
[0004] In view of this, the embodiments of the present invention provide a method and system for predicting public safety emergencies to eliminate or improve one or more defects in the prior art and solve the problem of low accuracy in predicting public safety emergencies in the prior art.
[0005] One aspect of the present invention provides a method for predicting public safety emergencies, the method being used to be executed on multiple clients, each of which is deployed on multiple social platforms, each of which collects and processes text information on a corresponding social platform to obtain text sequence data, the method comprising the following steps:
[0006] The text sequence data of the target client is extracted into corresponding event theme codes through a preset coding module, the event theme codes are summarized and arranged to obtain the event theme sequence of the target client, and the event theme sequence of the target client and the theme embedding matrix of the target client are calculated according to a set method to obtain the event theme of the target client;
[0007] Obtain a pre-trained deep learning neural network, wherein the deep learning neural network integrates a spatiotemporal attention weighting mechanism; based on the deep learning neural network, continuously process the event topics of each client at each moment to output the hidden state of the client at each moment;
[0008] Mapping the event topic of the target client at the current moment and the hidden states of other clients at the previous moment to the same semantic space through linear transformation, and calculating the influence of other clients on the target client at the current moment by setting rules;
[0009] Setting the influence matrix and influence degree parameter vector of the target client affected by the other clients, and calculating the scientific influence context of the other clients on the target client at the current moment in combination with the influence matrix and the influence degree parameter vector according to the influence of the other clients on the target client at the current moment;
[0010] The scientific impact context of the other clients on the target client is mapped to the same semantic space as the hidden state at the current moment, and the event topic sequence prediction result at the next moment is obtained after fusion.
[0011] In some embodiments, the method further comprises:
[0012] The text sequence data of other clients are extracted to obtain corresponding event theme codes through a preset coding module, the event theme codes are summarized and arranged to obtain event theme sequences of other clients, and the event theme sequences of other clients are combined with theme embedding matrices of other clients according to a set method to obtain event themes of other clients.
[0013] In some embodiments, the training process of the deep learning neural network includes:
[0014] Each client obtains a local training sample set respectively, wherein the local training sample set includes local text sequence data generated by the social platform under various public safety emergency scenarios; samples in the local training sample set of each client are associated according to public safety emergencies, and the type of public safety emergency at each moment is added as a label; in each training batch, each client uses the local text sequence data at the same moment for joint training;
[0015] Each client extracts local event theme codes from the local text sequence data through a preset coding module, summarizes and arranges the local event theme codes to obtain a local event theme sequence of each client, and calculates the local event theme sequence and the theme embedding matrix according to a set method to obtain a local event theme of each client;
[0016] Each client deploys an initial client local model respectively, and the initial client local model integrates the spatiotemporal attention weighting mechanism, continuously processes the local event topics at each moment, and outputs the hidden state of the client at each moment; wherein the parameters of the initial client local model of each client are issued by the server;
[0017] Each client maps the local event topic at the current moment and the hidden states of other clients at the previous moment to the same semantic space through linear transformation, and calculates the influence of other clients on the current client at the current moment by setting rules;
[0018] Each client sets the influence matrix and influence degree parameter vector of the current client affected by other clients, and calculates the scientific influence context of other clients on the current client at the current moment in combination with the influence matrix and the influence degree parameter vector according to the influence of other clients on the current client at the current moment;
[0019] Each client maps the scientific impact context of other clients on the current client to the same semantic space as the hidden state at the current moment, and obtains the event topic sequence prediction result at the next moment after fusion;
[0020] Each client compares the event topic sequence prediction result at the next moment with the label, and constructs a loss function to update the parameters of the initial client local model of the current client, and uploads the updated parameters to the server for fusion and then sends them down again to obtain the updated deep learning neural network.
[0021] In some embodiments, the loss function is constructed based on the matrix norm of the covariance matrix between features and the classification loss, and the classification loss is obtained by multiplying the cross entropy loss of the public safety emergency type label and prediction result of each client with the sample weight.
[0022] In some embodiments, the preset encoding module includes a word embedding layer, a one-dimensional convolution layer, and a multi-head attention layer, and extracting the corresponding event theme code from the text sequence data of the target client through the preset encoding module includes:
[0023] Converting the word units of the text sequence data into a set number of word embedding vectors through a word embedding operation and adding position codes to the word embedding vectors;
[0024] Inputting the matrix obtained by permuting the word embedding vector as an input matrix into a one-dimensional convolution layer, and converting the word embedding vector into a compact vector after performing multiple convolution operations on the input matrix using multiple convolution kernels;
[0025] The compact vector is converted into event coding through a multi-head attention layer, and information extraction and fusion are performed on different compact vectors with relevant information to obtain event topic coding.
[0026] In some embodiments, a pre-trained deep learning neural network is obtained, and the deep learning neural network integrates a spatiotemporal attention weighting mechanism; based on the deep learning neural network, the event topics of each client at each time are continuously processed to output the hidden state of the client at each time, and the expression is:
[0027]
[0028]
[0029] in, represents the hidden state of the target client i at time t without the spatial attention weighting mechanism, represents the hidden state of the target client i at time t after the spatial attention weighting mechanism, represents the scaling factor, represents the event topic of target client i at time t, represents the hidden state of target client i at time t-1, W qi represents the query vector hyperparameter set by the spatiotemporal attention weighting mechanism, W ki represents the key vector hyperparameter set by the spatiotemporal attention weighting mechanism, W vi A vector of values representing the hyperparameters set by the spatiotemporal attention weighting mechanism.
[0030] In some embodiments, the event topic of the target client at the current moment and the hidden state of other clients at the previous moment are mapped to the same semantic space through linear transformation, and the expression is:
[0031]
[0032] The influence of other clients on the target client at the current moment is obtained by setting rules and calculation, and the expression is:
[0033]
[0034] in, represents the hidden state of client j at the previous time t-1, represents the hidden state of client k at the previous time t-1, W i represents the setting parameters of client i, W j represents the setting parameters of client j, W k represents the setting parameters of client k, represents the influence of client j on target client i at the current time t, Represents the influence of client k on target client i at the current time t.
[0035] In some embodiments, the influence matrix and influence degree parameter vector of the target client affected by the other clients are set, and according to the influence of the other clients on the target client at the current moment, the scientific influence context of the other clients on the target client at the current moment is calculated by combining the influence matrix and the influence degree parameter vector, and the expression is:
[0036]
[0037] The scientific impact context of the other clients on the target client is mapped to the same semantic space as the hidden state at the current moment, and the expression is:
[0038]
[0039] Among them, G is represents the influence matrix of other clients s on the target client i, G∈R n×n , when i≠s,G is =1, when i=s,G is =0,λ is represents the influence vector of other clients s on target client i, W influ Indicates the setting parameters of the scientific influence of target client i.
[0040] On the other hand, the present invention also provides a public safety emergency prediction system, the system includes a plurality of clients, and the clients execute the above-mentioned public safety emergency prediction method.
[0041] On the other hand, the present invention also provides a computer-readable storage medium having a computer program stored thereon, characterized in that when the program is executed by a processor, the steps of the above-mentioned public safety emergency prediction method are implemented.
[0042] The beneficial effects of the present invention are at least:
[0043] The present invention discloses a method and system for predicting public safety emergencies. The method is used to be executed on multiple clients. A trained client local model is deployed on each client. The text sequence data of the target client is extracted through a word embedding layer, a one-dimensional convolution layer and a multi-head attention layer to obtain a corresponding event theme code. The text sequence data and the word vector are combined to make the extraction of the subject words of the public safety emergencies more reasonable and reliable. The event theme codes are summarized and arranged to obtain the event theme sequence of the target client, and the event theme of the corresponding client is obtained by calculation with the theme embedding matrix. The event theme of each client at each moment is processed based on a deep learning neural network that integrates a spatiotemporal attention weighting mechanism, and the hidden state of the client at each moment is output to improve the accuracy of the extraction of the subject words of the public safety emergencies. The influence and scientific influence context of the other clients on the target client at the current moment are calculated and the scientific influence context is mapped to the same semantic space as the hidden state at the current moment and fused to obtain the event theme sequence prediction result at the next moment, thereby improving the accuracy of the extraction of the subject words of the public safety emergencies and obtaining more accurate and reliable prediction results.
[0044] Furthermore, the present invention adopts a federated learning approach when training the client local model, and the clients collaborate to jointly train the client local model, learn the future development of emergencies from other clients, improve data privacy and security, reduce data transmission requirements, and improve the accuracy of prediction results.
[0045] Additional advantages, purposes, and features of the present invention will be described in part in the following description, and will become apparent to those skilled in the art after studying the following, or may be learned from the practice of the present invention. The purposes and other advantages of the present invention may be achieved and obtained by the structures specifically indicated in the specification and the accompanying drawings.
[0046] Those skilled in the art will appreciate that the objectives and advantages that can be achieved with the present invention are not limited to the above specific description, and the above and other objectives that can be achieved by the present invention will be more clearly understood from the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of the present application, and do not constitute a limitation of the present invention. In the drawings:
[0048] Figure 1 The present invention is a flowchart of a method for predicting public safety emergencies according to an embodiment of the present invention.
[0049] Figure 2 It is a structural schematic diagram of a method for predicting public safety emergencies according to another embodiment of the present invention. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments and the accompanying drawings. Here, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0051] It should also be noted that, in order to avoid obscuring the present invention due to unnecessary details, only structures and / or processing steps closely related to the solutions according to the present invention are shown in the accompanying drawings, while other details that are not closely related to the present invention are omitted.
[0052] It should be emphasized that the term “include / comprises” when used herein refers to the presence of features, elements, steps or components, but does not exclude the presence or addition of one or more other features, elements, steps or components.
[0053] It should also be noted that, unless otherwise specified, the term “connection” herein may refer not only to a direct connection but also to an indirect connection involving an intermediate.
[0054] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. In the accompanying drawings, the same reference numerals represent the same or similar components, or the same or similar steps.
[0055] In the prior art, deep learning architectures such as long short-term memory networks, gated recurrent units, convolutional neural networks, graph neural networks and Transformers have been widely used in various event prediction tasks. However, the prediction of public safety emergencies mainly relies on time series data and graphic data of event development, and accurate and efficient preprocessing is required to represent events as such data. Since the semantic information of the documents in the data set is not considered, the correct event keywords cannot be extracted; some methods represent event information by using the unique hot vector encoding of words in the text, supplemented by additional numerical data, but these methods will encounter challenges related to dimension when facing lengthy event sequences; the present invention proposes a method and system for predicting public safety emergencies, which is used to be executed on multiple clients deployed on multiple social platforms, and each client collects and processes text information in the corresponding social platform to obtain text sequence data , each client deploys a trained client local model, extracts the corresponding event topic encoding from the text sequence data of the target client through a preset encoding module, summarizes and arranges the event topic sequence of the target client, and obtains the corresponding event topic according to the calculation with the topic embedding matrix; the deep learning neural network based on the fusion of spatiotemporal attention weighting mechanism continuously processes the event topic of each client at each moment to output the hidden state of the client at each moment; the event topic of the target client at the current moment and the hidden state of other clients at the previous moment are mapped to the same semantic space through linear transformation, the influence of the other clients on the target client at the current moment is calculated, and the scientific influence context is calculated by combining the set influence matrix and influence degree parameter vector; the scientific influence context is mapped to the same semantic space as the hidden state at the current moment and fused to obtain the event topic sequence prediction result at the next moment.
[0056] Figure 1 The flowchart of the public safety emergency prediction method according to an embodiment of the present invention is shown in FIG. Specifically, the present application provides a public safety emergency prediction method, which is used to be executed on multiple clients, each of which is deployed on multiple social platforms, and each client collects and processes text information in the corresponding social platform to obtain text sequence data. The method includes the following steps S101 to S105:
[0057] Step S101: extract the corresponding event theme codes from the text sequence data of the target client through a preset encoding module, summarize and arrange the event theme codes to obtain the event theme sequence of the target client, and calculate the event theme sequence of the target client and the theme embedding matrix of the target client according to a set method to obtain the event theme of the target client.
[0058] Step S102: Obtain a pre-trained deep learning neural network, which integrates a spatiotemporal attention weighting mechanism; based on the deep learning neural network, continuously process the event topics of each client at each moment to output the hidden state of the client at each moment.
[0059] Step S103: Map the event topic of the target client at the current moment and the hidden states of other clients at the previous moment to the same semantic space through linear transformation, and calculate the influence of other clients on the target client at the current moment by setting rules.
[0060] Step S104: Set the influence matrix and influence degree parameter vector of the target client affected by other clients, and calculate the scientific influence context of other clients on the target client at the current moment based on the influence of other clients on the target client at the current moment, combined with the influence matrix and influence degree parameter vector.
[0061] Step S105: Map the scientific impact context of other clients on the target client to the same semantic space as the hidden state at the current moment, and fuse them to obtain the event topic sequence prediction result at the next moment.
[0062] In step S101, the text sequence data includes information of various social platforms. The client collects and processes the information of the social platforms. The processed text sequence data can be stored locally on the client and used as a local data set. In some embodiments, the preset encoding module includes a word embedding layer, a one-dimensional convolution layer, and a multi-head attention layer. The text sequence data of the target client is extracted through the preset encoding module to obtain the corresponding event theme code, including steps S1011 to S1013:
[0063] Step S1011: Convert the word units of the text sequence data into a set number of word embedding vectors through a word embedding operation and add position codes to the word embedding vectors.
[0064] Step S1012: The matrix obtained by permutation of the word embedding vector is input into the one-dimensional convolution layer as the input matrix, and the word embedding vector is converted into a compact vector after multiple convolution operations are performed on the input matrix using multiple convolution kernels.
[0065] Step S1013: The compact vector is converted into an event code through a multi-head attention layer, and different compact vectors with relevant information are extracted and fused to obtain the event topic code.
[0066] Specifically, the word embedding layer in the large language model is a language model with large-scale parameters and capabilities. The large language model is based on deep learning and trained with a large amount of text data. The word embedding layer of the large language model maps each token (word) to an initial word embedding vector and automatically adds a corresponding position encoding vector to each word embedding vector. The embedding layer converts the word sequence into a set number of word embedding vectors, and the vector dimension is the embedding size * the number of words. Multiple convolution operations are performed on the input matrix composed of the word embedding vectors through multiple convolution kernels of the one-dimensional convolution layer to convert the word embedding vector into a compact vector, and the vector dimension of the compact vector is the embedding size * 1; the obtained multiple compact vectors are converted into event codes through a multi-headed attention layer, and the relevant information in different compact vectors is selectively fused; further, different convolution kernels are used to generate feature maps on the data matrix to obtain different features of the input matrix. The multi-headed attention layer can obtain the dependency between different parts and produce a more compact and rich representation.
[0067] In step S102, the deep learning neural network model includes an integrated moving average autoregressive model (ARIMA), a recurrent neural network (RNN), a long short-term memory network (LSTM), a gated recurrent unit (GRU), a convolutional neural network (CNN), a graph neural network (GNN) and a Transformer, which can all be used for event prediction tasks. The deep learning neural network of the present application adopts a long short-term memory network, which has a better modeling ability and can handle long-term dependencies. The spatiotemporal attention weighting mechanism is an attention mechanism used in a deep learning model. The spatial attention weighting mechanism is used to calculate the attention weight to distinguish the importance of different event topics in an event. Each ten-gram event topic has a corresponding weight, thereby obtaining the hidden state corresponding to the event topic at each moment. The spatial attention weighting mechanism further considers the relationship between time and space. In some embodiments, a pre-trained deep learning neural network is obtained, and the deep learning neural network integrates the spatiotemporal attention weighting mechanism; based on the deep learning neural network, the event topic of each client at each moment is continuously processed to output the hidden state of the client at each moment, and the expression is:
[0068]
[0069] in, represents the hidden state of the target client i at time t without the spatial attention weighting mechanism, represents the hidden state of the target client i at time t after the spatial attention weighting mechanism, represents the scaling factor, represents the event topic of target client i at time t, represents the hidden state of target client i at time t-1, Wqi represents the query vector hyperparameter set by the spatiotemporal attention weighting mechanism, W ki represents the key vector hyperparameter set by the spatiotemporal attention weighting mechanism, W vi A vector of values representing the hyperparameters set by the spatiotemporal attention weighting mechanism.
[0070] Furthermore, the output hidden state is the hidden state after spatial attention weighting. During the operation, the event theme of the current moment and the hidden state of the previous moment without the spatial attention weighting mechanism are input to output the hidden state of the current stage without the spatial attention weighting mechanism, and the hidden state after the spatial attention weighting mechanism is output. According to the time theme of the input moment, the hidden state corresponding to the input moment can be obtained to obtain the hidden state of the client at each moment; The dimensions represent the different characteristic attributes of the event theme, and the event theme will be affected by multiple elements.
[0071] In step S103, when obtaining the hidden state of other clients, it is necessary to obtain the event topics of other clients, which is consistent with the event topic acquisition process of the target client. In some embodiments, the public safety emergency prediction method further includes:
[0072] The text sequence data of other clients are extracted to obtain the corresponding event theme codes through a preset coding module, the event theme codes are summarized and arranged to obtain the event theme sequences of other clients, and the event theme sequences of other clients are combined with the theme embedding matrices of other clients according to the set method to obtain the event themes of other clients.
[0073] Furthermore, in some embodiments, the event topic of the target client at the current moment and the hidden state of other clients at the previous moment are mapped to the same semantic space through linear transformation, and the expression is:
[0074]
[0075] By setting rules to calculate the influence of other clients on the target client at the current moment, the expression is:
[0076]
[0077] in, represents the hidden state of client j at the previous time t-1, represents the hidden state of client k at the previous time t-1, W i represents the setting parameters of client i, W j represents the setting parameters of client j, W k represents the setting parameters of client k, represents the influence of client j on target client i at the current time t, Represents the influence of client k on target client i at the current time t.
[0078] In step S104 and step S105, after calculating the influence of other clients on the target client at the current moment, an influence matrix G is set is Indicates that the target client i is affected by all other clients s, G∈R n ×n , set an influence parameter vector to represent the influence degree of target client i on all other clients s, λ is ∈R n In some embodiments, the influence matrix and influence degree parameter vector of the target client are set, and the scientific influence context of other clients on the target client at the current moment is calculated by combining the influence matrix and the influence degree parameter vector according to the influence of other clients on the target client at the current moment, and the expression is:
[0079]
[0080] Furthermore, since the hidden state and the scientific impact context do not belong to the same semantic space, it is necessary to map the scientific impact context of other clients on the target client to the same semantic space as the hidden state at the current moment, and ensure that the mapped scientific impact context is aligned with the hidden state before fusion. The expression is:
[0081]
[0082] Among them, G is represents the influence matrix of other clients s on target client i, G is ∈R n×n , when i≠s,G is =1, when i=s,G is =0,λ is represents the influence vector of other clients s on target client i, W influ Indicates the setting parameters of the scientific influence of target client i.
[0083] In some embodiments, the training process of the deep learning neural network includes steps S201 to S207:
[0084] Step S201: Each client obtains a local training sample set respectively, and the local training sample set contains local text sequence data generated by the social platform under various public safety emergency scenarios; the samples in the local training sample set of each client are associated according to the public safety emergency, and the type of public safety emergency at each moment is added as a label; in each training batch, each client uses the local text sequence data at the same moment for joint training.
[0085] Step S202: Each client extracts local event topic codes from local text sequence data through a preset coding module, summarizes and arranges the local event topic codes to obtain a local event topic sequence of each client, and calculates the local event topic sequence and the topic embedding matrix according to a set method to obtain a local event topic of each client.
[0086] Step S203: Each client deploys an initial client local model respectively. The initial client local model integrates the spatiotemporal attention weighting mechanism, continuously processes the local event topics at each moment, and outputs the hidden state of the client at each moment; wherein the parameters of the initial client local model of each client are issued by the server.
[0087] Step S204: Each client maps the local event topic at the current moment and the hidden states of other clients at the previous moment to the same semantic space through linear transformation, and obtains the influence of other clients on the current client at the current moment by setting rules for calculation.
[0088] Step S205: Each client sets the influence matrix and influence degree parameter vector of the current client influenced by other clients, and calculates the scientific influence context of other clients on the current client at the current moment based on the influence of other clients on the current client at the current moment, combining the influence matrix and influence degree parameter vector.
[0089] Step S206: Each client maps the scientific impact context of other clients on the current client to the same semantic space as the hidden state at the current moment, and obtains the event topic sequence prediction result at the next moment after fusion.
[0090] Step S207: Each client compares the event topic sequence prediction result at the next moment with the label, and constructs a loss function to update the parameters of the initial client local model of the current client, and uploads the updated parameters to the server for fusion and then sends them down again to obtain an updated deep learning neural network.
[0091] Specifically, the client local model and the service point perform federated learning, and each client deploys an initial client local model. After training, the client local model is obtained. The initial parameters of the initial client local model are sent by the server, including initial feature extraction parameters, initial classifier parameters, and initial strategy parameters. The initial parameters are returned to the server after training the initial client local model. The server performs weighted summation of the parameters of each client according to the proportion of the client's data volume to the total data volume, obtains the aggregated parameters, and sends them to the initial client local model for the next round of parameter updates. After each parameter update, the initial client local model needs to send the parameters back to the server to obtain the aggregated parameters, which are then sent by the server.
[0092] Furthermore, the type of public safety emergency at each moment is compared with the prediction result. In some embodiments, the loss function is constructed based on the matrix norm of the covariance matrix between features and the classification loss. The classification loss is obtained by multiplying the cross entropy loss of the public safety emergency type label and the prediction result of each client by the sample weight; the client local model is obtained after multiple parameter updates through the constructed loss function; specifically, in federated learning, converting the original data into feature vectors through a feature extractor and using the feature vectors to calculate the loss function can better protect data privacy and improve security. The matrix norm of the covariance matrix is used to measure the difference between feature vectors and to optimize the feature extractor, helping the model to better extract features and improve performance in tasks. The policy gradient-based reinforcement learning sample weighting strategy decorrelates the features, improves the stability and generalization ability of the model, and makes the features more independent and representative.
[0093] On the other hand, the present invention also provides a public safety emergency prediction system, which includes multiple clients, and the clients execute the above-mentioned public safety emergency prediction method.
[0094] On the other hand, the present invention also provides a computer-readable storage medium having a computer program stored thereon, characterized in that when the program is executed by a processor, the steps of the above-mentioned public safety emergency prediction method are implemented.
[0095] The present invention is described below in conjunction with a specific embodiment:
[0096] Figure 2 This is a structural diagram of a method for predicting public safety emergencies according to another embodiment of the present invention, wherein the structure includes event topic extraction and embedding based on a large language model, and an influence modeling unit based on spatiotemporal attention to calculate the influence and scientific influence context of the other clients on the target client at the current moment and map them to the same semantic space to obtain the event topic sequence prediction result at the next moment after fusion.
[0097] 1. Event topic extraction and embedding process based on large language model.
[0098] First, the token sequence is converted into multiple word embedding vectors through the word embedding layer of the pre-trained large language model. The vector dimension is embedding size * number of words. The specific method is to map each word to an initial word embedding vector through the embedding layer of the large language model. In order to enable the model to capture the position information of the token in the sequence, the corresponding position encoding vector is automatically added to each word embedding vector. The second step is to convert the word embedding vector into a compact vector through a one-dimensional convolution layer. The vector dimension is embedding size * 1. The specific operation is to use convolution kernels of different sizes to perform multiple convolution operations on the input matrix. Finally, the obtained multiple compact vectors are converted into event codes through a multi-head attention layer, and the relevant information in different compact vectors is selectively fused.
[0099] 2. Event influence modeling unit based on spatiotemporal attention.
[0100] Although the future development of events on the client undergoing federated learning is largely related to the historical event data of the client, it will inevitably be affected by the historical event data of other clients. The event influence modeling unit based on spatiotemporal attention learns the event distribution of other clients. Given the event topic sequence of federated client i, in is the event topic sequence of the i-th federated client at time t; the topic embedding matrix Φ is used to convert Converted into a dense low-dimensional vector, the event topic of client i at time t The expression is:
[0101]
[0102] Embed with event theme As input, iteratively update the hidden state The hidden state captures the event topic of client i at time t, and the hidden state expression is:
[0103]
[0104] Among them, LSTM (Long Short-Term Memory Network) has more powerful modeling capabilities than simple RNN (Recurrent Neural Network) and can better handle long-term dependencies. Each dimension represents a different characteristic attribute of the event theme, and the event theme is affected by many factors such as theme frequency and popularity.
[0105] The spatiotemporal attention mechanism is used to calculate the attention weight of the event to distinguish the importance of different topics in the event. The key to this method is to integrate the spatiotemporal attention mechanism into federated learning and traditional LSTM-based topic sequence modeling to distinguish the importance of different topics in the event. Since any topic at any time has its corresponding weight, the hidden state of client i after spatiotemporal attention weighting is expressed as Similarly, the event topics of client j and client k at time t-1 can be expressed as and The calculation is as follows:
[0106]
[0107] Among them, W qi , W ki and W vi Represents the multi-head hyperparameters set by the spatiotemporal attention weighting mechanism.
[0108] Since different federated clients have different research topics, their semantic spaces are not comparable. When calculating the impact of events between federated clients, they need to be mapped to comparable semantic spaces and then calculate the impact context to ensure the optimal event impact context. Therefore, we model the event impact context based on semantic space consistency. First, we transform the event impact context into and Projecting into a shared semantic space yields and The expression of the transformation process is:
[0109]
[0110]
[0111] Among them, W i , W j and W k is a parameter. Then, the influence of client j and client k on client i at time t is and The calculation is as follows:
[0112]
[0113] Where ⊙ represents the element-by-element product operation. The influence between clients is encapsulated in the matrix G, assuming that the evolution of the event topic within client i is affected by all clients. The matrix G∈R n×n ; For each row i of G, it indicates that client i is affected by all related clients. Therefore, if i≠j, then G ij =1; otherwise, Gij = 0. At the same time, an influencing parameter vector λ is inferred ij ∈R n , represents the degree to which client i is influenced by client j. The scientific impact context of the event topic of client i is influ i The calculation is as follows:
[0114]
[0115] However, and influenza i does not belong to a consistent semantic space. Therefore, influ i Map to Make sure it is After alignment, fusion is performed.
[0116]
[0117] Among them, W influ Indicates the setting parameters of the scientific influence of target client i.
[0118] 3. The client local model and the server federated training process.
[0119] Federated learning is mainly divided into two processes: client-side local model training and server-side aggregation. Table 1 is the federated training algorithm table of the client-side local model and the server.
[0120] During the server aggregation process, the parameters sent back by the client are received, weighted according to the amount of client data, and then aggregated, and the aggregated model parameters are sent back to the client. In the first iteration, the parameters of feature extraction, classifier, and strategy are initialized to obtain f 0 ,c 0 and Policy 0 , and sent to each federated client. After training, each client returns the trained parameters to the server. The server weights the parameters returned by each client according to the proportion of the client's data volume to the total data volume, and sums them up as the initial parameters for the new round of iteration.
[0121] During the client training process, the client receives the aggregation parameters sent by the server to initialize the client local model. After each training round, the initial client local model parameters are sent back to the server. During client training, a batch of data is obtained from the local data set Di of client i, and image features are extracted through the feature extractor. The Frobenius norm (matrix norm) of the covariance matrix between features is used as the loss. The policy gradient-based reinforcement learning sample weighting strategy is trained to decorrelate the features. The sample weight is obtained through the sample weighting strategy, and the cross entropy between the predicted structure obtained by the classifier and the actual result is calculated. The sum is multiplied by the sample weight as the classification loss, and the updated feature extraction, classifier and strategy parameters are sent back to the server.
[0122] Table 1 Client local model and server federated training algorithm
[0123]
[0124] In summary, the present invention provides a public safety emergency prediction method and system, the method is used to be executed on multiple clients deployed on multiple social platforms, each client collects and processes text information in the corresponding social platform to obtain text sequence data, each client deploys a trained client local model, extracts the corresponding event theme code from the text sequence data of the target client through a preset encoding module, summarizes and arranges the event theme sequence, and calculates the event theme of the target client according to a set method with the theme embedding matrix of the target client; the event theme of each client at each moment is continuously processed based on a deep learning neural network with a fusion spatiotemporal attention weighting mechanism to output the hidden state of the client at each moment; the event theme of the target client at the current moment and the hidden state of other clients at the previous moment are mapped to the same semantic space through linear transformation, the influence of other clients on the target client at the current moment is calculated by setting rules, and the scientific influence context of other clients on the target client at the current moment is calculated in combination with the set influence matrix and influence degree parameter vector; the scientific influence context is mapped to the same semantic space as the hidden state at the current moment and fused to obtain the event theme sequence prediction result at the next moment.
[0125] Furthermore, the present invention adopts a federated learning approach when training the client local model, and the clients collaborate to jointly train the client local model. Each time the initial client local model undergoes a parameter update, the parameters need to be sent back to the server to obtain aggregated parameters, which are then issued by the server to obtain an updated client local model.
[0126] An embodiment of the present invention further provides a computer device, which may include a processor and a memory, wherein the processor and the memory may be connected via a bus or in other ways.
[0127] The processor may be a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above chips.
[0128] The memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer executable programs and modules, such as the program instructions / modules corresponding to the key shielding method of the vehicle-mounted display device in the embodiment of the present invention. The processor executes various functional applications and data processing of the processor by running the non-transitory software programs, instructions and modules stored in the memory.
[0129] The memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created by the processor, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0130] The one or more modules are stored in the memory, and when executed by the processor, the method described in this embodiment is performed.
[0131] The embodiment of the present invention also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the aforementioned edge computing server deployment method are implemented. The computer-readable storage medium can be a tangible storage medium, such as a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a floppy disk, a hard disk, a removable storage disk, a CD-ROM, or any other form of storage medium known in the technical field.
[0132] It should be understood by those skilled in the art that the exemplary components, systems and methods described in conjunction with the embodiments disclosed herein can be implemented in hardware, software or a combination of the two. Whether it is performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present invention are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link via a data signal carried in a carrier.
[0133] It should be clear that the present invention is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present invention.
[0134] In the present invention, features described and / or illustrated for one embodiment may be used in the same or similar manner in one or more other embodiments, and / or combined with features of other embodiments or replace features of other embodiments.
[0135] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for predicting public safety emergencies, characterized in that: The method is used to be executed on multiple clients, each of which is deployed in multiple social platforms. Each client collects and processes text information in the corresponding social platform to obtain text sequence data. The method includes the following steps: The text sequence data of the target client is extracted into corresponding event theme codes through a preset coding module, the event theme codes are summarized and arranged to obtain the event theme sequence of the target client, and the event theme sequence of the target client and the theme embedding matrix of the target client are calculated according to a set method to obtain the event theme of the target client; Obtain a pre-trained deep learning neural network, wherein the deep learning neural network integrates a spatiotemporal attention weighting mechanism; based on the deep learning neural network, continuously process the event topics of each client at each moment to output the hidden state of the client at each moment; Mapping the event topic of the target client at the current moment and the hidden states of other clients at the previous moment to the same semantic space through linear transformation, and calculating the influence of other clients on the target client at the current moment by setting rules; Setting the influence matrix and influence degree parameter vector of the target client affected by the other clients, and calculating the scientific influence context of the other clients on the target client at the current moment in combination with the influence matrix and the influence degree parameter vector according to the influence of the other clients on the target client at the current moment; The scientific impact context of the other clients on the target client is mapped to the same semantic space as the hidden state at the current moment, and the event topic sequence prediction result at the next moment is obtained after fusion.
2. The public safety emergency prediction method according to claim 1, characterized in that: The method further comprises: The text sequence data of other clients are extracted to obtain corresponding event theme codes through a preset coding module, the event theme codes are summarized and arranged to obtain event theme sequences of other clients, and the event theme sequences of other clients are combined with theme embedding matrices of other clients according to a set method to obtain event themes of other clients.
3. The public safety emergency prediction method according to claim 1, characterized in that: The training process of the deep learning neural network includes: Each client obtains a local training sample set respectively, wherein the local training sample set includes local text sequence data generated by the social platform under various public safety emergency scenarios; samples in the local training sample set of each client are associated according to public safety emergencies, and the type of public safety emergency at each moment is added as a label; in each training batch, each client uses the local text sequence data at the same moment for joint training; Each client extracts local event theme codes from the local text sequence data through a preset coding module, summarizes and arranges the local event theme codes to obtain a local event theme sequence of each client, and calculates the local event theme sequence and the theme embedding matrix according to a set method to obtain a local event theme of each client; Each client deploys an initial client local model respectively, and the initial client local model integrates the spatiotemporal attention weighting mechanism, continuously processes the local event topics at each moment, and outputs the hidden state of the client at each moment; wherein the parameters of the initial client local model of each client are issued by the server; Each client maps the local event topic at the current moment and the hidden states of other clients at the previous moment to the same semantic space through linear transformation, and calculates the influence of other clients on the current client at the current moment by setting rules; Each client sets the influence matrix and influence degree parameter vector of the current client affected by other clients, and calculates the scientific influence context of other clients on the current client at the current moment in combination with the influence matrix and the influence degree parameter vector according to the influence of other clients on the current client at the current moment; Each client maps the scientific impact context of other clients on the current client to the same semantic space as the hidden state at the current moment, and obtains the event topic sequence prediction result at the next moment after fusion; Each client compares the event topic sequence prediction result at the next moment with the label, and constructs a loss function to update the parameters of the initial client local model of the current client, and uploads the updated parameters to the server for fusion and then sends them down again to obtain the updated deep learning neural network.
4. The method for predicting public safety emergencies according to claim 3, characterized in that: The loss function is constructed based on the matrix norm of the covariance matrix between features and the classification loss, and the classification loss is obtained by multiplying the cross entropy loss of the public safety emergency type label and the prediction result of each client with the sample weight and summing them.
5. The method for predicting public safety emergencies according to claim 1, characterized in that: The preset coding module includes a word embedding layer, a one-dimensional convolution layer and a multi-head attention layer. The text sequence data of the target client is extracted through the preset coding module to obtain the corresponding event theme code, including: Converting the word units of the text sequence data into a set number of word embedding vectors through a word embedding operation and adding position codes to the word embedding vectors; Inputting the matrix obtained by permuting the word embedding vector as an input matrix into a one-dimensional convolution layer, and converting the word embedding vector into a compact vector after performing multiple convolution operations on the input matrix using multiple convolution kernels; The compact vector is converted into event coding through a multi-head attention layer, and information extraction and fusion are performed on different compact vectors with relevant information to obtain event topic coding.
6. The method for predicting public safety emergencies according to claim 1, characterized in that: Obtain a pre-trained deep learning neural network, which integrates a spatiotemporal attention weighting mechanism; based on the deep learning neural network, continuously process the event topics of each client at each moment to output the hidden state of the client at each moment, expressed as: in, represents the hidden state of the target client i at time t without the spatial attention weighting mechanism, represents the hidden state of the target client i at time t after the spatial attention weighting mechanism, represents the scaling factor, represents the event topic of target client i at time t, represents the hidden state of target client i at time t-1, W qi represents the query vector hyperparameter set by the spatiotemporal attention weighting mechanism, W ki represents the key vector hyperparameter set by the spatiotemporal attention weighting mechanism, W vi A vector of values representing the hyperparameters set by the spatiotemporal attention weighting mechanism.
7. The method for predicting public safety emergencies according to claim 1, characterized in that: The event topic of the target client at the current moment and the hidden state of other clients at the previous moment are mapped to the same semantic space through linear transformation, and the expression is: The influence of other clients on the target client at the current moment is obtained by setting rules and calculation, and the expression is: in, represents the hidden state of client j at the previous time t-1, represents the hidden state of client k at the previous time t-1, W i represents the setting parameters of client i, W j represents the setting parameters of client j, W k represents the setting parameters of client k, represents the influence of client j on target client i at the current time t, Represents the influence of client k on target client i at the current time t.
8. The method for predicting public safety emergencies according to claim 1, characterized in that:The influence matrix and influence degree parameter vector of the target client affected by the other clients are set, and according to the influence of the other clients on the target client at the current moment, the scientific influence context of the other clients on the target client at the current moment is calculated by combining the influence matrix and the influence degree parameter vector, and the expression is: The scientific impact context of the other clients on the target client is mapped to the same semantic space as the hidden state at the current moment, and the expression is: Among them, G is represents the influence matrix of other clients s on the target client i, G∈R n×n , when i≠s,G is =1, when i=s,G is =0,λ is represents the influence vector of other clients s on target client i, W influ Indicates the setting parameters of the scientific influence of target client i.
9. A public safety emergency prediction system, characterized in that: The system includes a plurality of clients, and the clients execute the public safety emergency prediction method as described in claims 1 to 8.
10. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instructions are executed by a processor, the steps of the method as claimed in any one of claims 1 to 9 are implemented.
Citation Information
Patent Citations
Personalized public safety emergency detection model training method, detection method and device
CN116541779A
