A multimodal model optimization retrieval training method and storage medium
By extending the DBSCAN algorithm and LOF algorithm, combining spatio-temporal distance measurement and contribution measurement, the training set of the multi-modal model is optimized, which solves the problems of repeated training and low data position adjustment efficiency in multi-modal model training, and improves the robustness of the model. Stickiness and generalization ability.
Patent Information
- Application Number
- CN202410055834.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-15
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2044-01-15
AI Technical Summary
Existing multi-modal models face the problems of repeated training and low efficiency of data position adjustment when performing training. Especially in large-scale data set environments, it is difficult to effectively retrieve samples useful to the model.
By extending the DBSCAN algorithm, combining spatiotemporal distance measurement and multi-metric DBSCAN, sample selection and position adjustment are optimized, the LOF algorithm is used to measure the amount of information, and the training set is optimized based on the distance contribution measurement function.
It achieves faster sample selection and position adjustment in multi-modal model training, improves the robustness and generalization ability of the model, reduces training complexity, and enhances the ability to identify anomalies and boundaries.
Smart Images

Figure CN118094216B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of multimodal recognition, and in particular to a multimodal model optimization retrieval training method and a storage medium. Background Art
[0002] A multimodal model is an AI architecture model that can simultaneously process and integrate multiple (at least two) sensory data, such as text, images, audio, or electronically processed signals. Common forms include, but are not limited to, the CLIP model, ViLBERT model, LXMERT model, VL-BERT model, and UNITER model.
[0003] This type of model can break through the barriers between the physical world and the digital world, directly generate operations with the most basic ability to perceive the world, and achieve the most natural interaction with the physical world. With the continuous advancement of computer technology and the expansion of application scenarios, the demand for multimodal models is also increasing. At the same time, with the continuous development of artificial intelligence, more and more multimodal models of different types are being applied to fields such as human-computer interaction.
[0004] For example, the emotion multimodal models used in virtual reality (VR) and augmented reality (AR) applications (such as the AO-BERT model, a multimodal model based on the Transformer encoder structure and multimodal mask language) can create a more realistic and immersive user experience based on the feedback of user emotional information. By capturing the user's emotional response in real time, the model system can dynamically adjust the virtual environment or augmented reality elements to better adapt to the user's emotional state and needs. Similarly, this type of emotion multimodal model can also be applied to vehicle navigation, smart medical care, big data, smart home and other fields.
[0005] Existing multimodal models have achieved certain results, but when executing multimodal and large-scale data training sets, the sample selection (retrieval) methods of traditional multimodal models often face some problems:
[0006] (1) In traditional multimodal model training, there is a lot of repeated training of similar data, which often makes it difficult to effectively retrieve samples that are more useful to the model;
[0007] (2) Traditional active learning sample selection methods often face problems of inefficient data scanning and data position adjustment;
[0008] That is, the technical problem to be solved is: when faced with a large-scale data training set, how to formulate a multimodal model to optimize the retrieval training method and solve the position adjustment problem and repeated training problem.
[0009] To this end, the present invention proposes a multimodal model optimization retrieval training method and a storage medium. Summary of the invention
[0010] In view of this, the embodiment of the present invention hopes to provide a multimodal model optimization retrieval training method and storage medium; the technical solution of the present invention is implemented as follows:
[0011] First, a multimodal model optimization retrieval training method:
[0012] 1. Overview:
[0013] The present invention aims to formulate a multimodal model optimization retrieval training method to solve the position adjustment problem and repeated training problem. Based on the traditional DBSCAN algorithm (Density-Based Spatial Clustering of Applications with Noise), the present invention further expands and modifies the characteristics of the multimodal model, so that it can further adapt to the spatiotemporal characteristics of the multimodal model training set while taking advantage of the advantages of the DBSCAN algorithm. During the process, the amount of information in the training set and its contribution are measured, and samples with low value and easy to repeat training are filtered out, so that the multimodal model can finally perform intelligent retrieval and optimization training on the training set, that is, compared with the original training set information, sample selection and position adjustment operations can be performed faster.
[0014] (II) Clarify the expected technical effects:
[0015] First, for a given training multimodal dataset D:
[0016]
[0017] Among them, (x i ,y i ) is the i-th input sample x and its corresponding label y, and N is the maximum value of i.
[0018] Sample x i is audio data, text data or video data; that is, the training set includes N samples x = x1, x2, ..., x N , where any sample x i Represents a training data (data point). For the multimodal dataset D, the following solution is introduced to solve the target problem:
[0019] 2.1 Position adjustment problem:
[0020] For a given sample selection method M(D), where M(·) is an adjustment function used to select samples and adjust data positions; the goal of this item is to minimize the time complexity of sample selection and minimize data position adjustment; the optimization objective is defined as minimizing complexity (Min):
[0021] MinTime(M(D));
[0022] Where Time(M(D)) represents the time complexity of the sample selection method M(D); therefore, this item requires the definition of an efficient sample selection strategy to reduce the time complexity and maintain the accuracy of sample selection.
[0023] 2.2 Repeated training problem:
[0024] Introduce an information measurement function I(x i ) to measure the sample x i The amount of information, and the contribution measurement function C(x i ) to measure the sample x i Contribution to the model; the optimization goal is defined as maximizing the amount of information (priority) and contribution (MAX):
[0025]
[0026] Therefore, it is necessary to formulate an I(x i ) and C(x i )A required and accurate sample measurement strategy.
[0027] (III) Technical solution:
[0028] 3.1 Step S1, sample selection strategy:
[0029] This technical solution selects the DBSCAN algorithm as the sample selection strategy. The traditional DBSCAN algorithm defines a cluster as the largest set of density-connected points. It can divide areas with sufficiently high density into clusters and can find clusters of arbitrary shapes in noisy spatial databases.
[0030] However, based on the content of 2.1 above, since the traditional DBSCAN algorithm does not directly consider the characteristics of the time domain and the spatial domain, it needs to be modified or extended to better adapt to data (samples) with time domain and spatial domain characteristics.
[0031] 3.1.1 Step S100, define the spatiotemporal neighborhood:
[0032] For spatiotemporal data, such as continuous video frames or audio signals, this temporal continuity can be exploited to reduce the number of samples that need to be processed.
[0033] Define a spatiotemporal neighborhood (including spatial neighborhood and temporal neighborhood), that is, a spatiotemporal distance metric; this neighborhood considers both spatial proximity and temporal proximity, representing the sample x i The temporal and spatial characteristics of . It is a weighted sum of spatial distance and temporal distance. This spatiotemporal distance metric is used to determine the ε-neighborhood of each sample (data point).
[0034] 2.1.1.1 Step S1000, combining the spatial distance and the temporal distance:
[0035] For any two data points P and Q, their coordinates in space are (x P ,y P , z P ) and (x Q ,y Q , z Q );
[0036] In three-dimensional space, a video frame can be two-dimensional (x, y), and its coordinates in time are t P and t Q . Define the space-time distance metric D ST (P, Q) is as follows:
[0037]
[0038] Among them, D S (P, Q) 2 is the spatial distance between points P and Q, which can be calculated using the Euclidean distance:
[0039]
[0040] For a two-dimensional space (such as a video frame), it simplifies to:
[0041]
[0042] Among them, D T (P, Q) is the temporal distance between points P and Q, formulated using the time difference:
[0043] D T (P, Q) = |t Q -t P |;
[0044] Among them, α is a weight factor used to balance the importance of spatial distance and temporal distance. If temporal continuity is very important, α can be set relatively large; if spatial proximity is more important, α can be set relatively small.
[0045] 2.1.1.1 Step S1001, capturing and determining the neighborhood range:
[0046] Once the space-time distance metric D is defined ST (P, Q), we can use this metric to determine for each sample x i ε-neighborhood of (data point). For a given data point P and distance threshold ε, point Q belongs to the ε-neighborhood of P if and only if (iff):
[0047] D ST (P,Q)<ε;
[0048] The spatiotemporal neighborhood defined in this way can simultaneously consider the proximity of data points in space and time, thereby more accurately capturing the characteristics of spatiotemporal data.
[0049] Among them, the ε-neighborhood is the core concept in the DBSCAN algorithm, which defines a hypersphere range with a radius of ε centered on a given sample. If a sample point is within the ε-neighborhood of another sample point, then the two sample points are considered to be "density-reachable" to each other (that is, the "density-reachable" concept of the DBSCAN algorithm). Through "density reachability", the DBSCAN algorithm can identify areas with sufficient density and divide them into different clusters.
[0050] The neighborhood range of each sample is determined using the defined spatiotemporal neighborhood. This allows only samples that are close to the current sample in time and space to be considered, rather than the entire dataset. For each sample, the sample with the highest density or the sample closest to other samples is selected as a representative. This reduces the number of samples that need to be processed, thereby reducing the time complexity of sample selection.
[0051] 3.1.2 Step S101, execute the multi-metric DBSCAN algorithm:
[0052] This proposal extends the DBSCAN algorithm to support multiple distance metrics, so it is called the multi-metric DBSCAN algorithm. For each sample (data point), its spatial neighborhood and temporal neighborhood need to be considered at the same time, and the point must meet the density requirements under both metrics to be considered as a core point. Therefore, additional parameters are needed to balance the importance of spatial and temporal metrics, and corresponding algorithms are needed to handle the combination of multiple metrics.
[0053] 3.1.2.1 Step S1010, combining distance functions:
[0054] This function combines the spatial distance and temporal distance of spatial neighbors and temporal neighbors respectively, and uses weights to adjust their influence. S (P,Q) and the temporal distance metric D T(P,Q), we can define the combined distance metric D C (P,Q) is as follows:
[0055]
[0056] Among them, w s and w T are the weights of spatial distance and temporal distance, and their sum is 1; D S (P,Q) is a spatial distance metric, representing the spatial distance; D T (P,Q) is a temporal distance metric representing the temporal distance.
[0057] 3.1.2.2 Step S1011, cluster analysis:
[0058] Get the combined distance metric D C (P, Q), the multi-metric DBSCAN algorithm is used to cluster the data set and generate several clusters. By considering both spatial and temporal metrics, a more compact and meaningful clustering result can be obtained. After clustering, the center point or representative sample of each cluster can be selected as training data. This can further reduce the number of samples required for training and maintain the diversity of samples. It specifically includes steps S10110 to S10113.
[0059] Step S10110, clustering: First, use the multi-metric DBSCAN algorithm to cluster the data set. In this process, the algorithm will be based on the combined distance metric D C (P,Q) to determine which samples x i Belong to the same cluster. The multi-metric DBSCAN algorithm considers both spatial distance and temporal distance at the same time, and requires that points meet density requirements under both metrics to be considered core points; the specific steps to determine whether the "density requirements" are met include:
[0060] P1. Choose two distance metrics D S and D T , representing the spatial distance and the temporal distance, and the two corresponding neighborhood radii ε S and ε T , and the minimum number of points MinPts.
[0061] P2. For any two points P and Q in the data set, calculate their combined distance D C (P,Q).
[0062] P3. Determine the neighborhood: For each point P in the data set, find all the points in its neighborhood.
[0063] P4. Mark core points: If the neighborhood of point P contains at least MinPts points, mark P as a core point.
[0064] P5. Expand the cluster: Start from any unvisited core point and create a new cluster. Then, recursively find all points in the neighborhood of the core point and add them to the same cluster. If the point in the neighborhood is also a core point, continue to recursively expand the cluster.
[0065] P6. Repeat P5: until all core points have been visited and their clusters are completely determined.
[0066] P7. Processing noise points: Mark points that do not belong to any cluster as noise points.
[0067] Step S10111, determine the center point: For each formed cluster, the center point CK can be selected as a representative sample. The average value of all points in the cluster is calculated to obtain the center point CK, which can be selected as a weighted average in the spatial and temporal dimensions:
[0068]
[0069] Among them, C k represents the kth cluster (set of points), |C k | is cluster C k number of points in, x i is the point in the cluster. If the data points have dimensions in both space and time, the average is calculated separately for each dimension.
[0070] Step S10112 (optional step), select representative samples: In addition to the center point, other methods can be selected to determine representative samples, such as selecting the point closest to the center point, or selecting the most representative point according to the density evaluation standard.
[0071] Step S10113 (if the above step S10112 is not performed, this step is regarded as S10112), optimizing the training set: once the representative samples of each cluster are determined, these samples can be used to form a reduced training set. Suppose the original training set is:
[0072] X={x1,x2,...,x N};
[0073] Where N is the total number of samples x (data points). After multi-metric DBSCAN clustering, K clusters can be obtained, denoted as:
[0074] C={C1,C2,...,C K};
[0075] For each cluster C i, select a representative sample r; then, optimize the training set X reduced It can be composed of or include these representative samples:
[0076] X reduced ={r1,r2,...,r K};
[0077] Here, we optimize the training set X reduced It contains representative samples of each cluster, so its size is K, which is much smaller than the size N of the original dataset.
[0078] The method of selecting representative samples can select the center point of the cluster as the representative sample. If the center point is defined as the mean of all points in the cluster (weighted average in space and time dimensions), then for the kth cluster C k The center point r k The difference can be calculated as:
[0079]
[0080] Among them, |C k | represents cluster C k The number of points in .
[0081] Clustering can reduce a large number of data points to representative samples of each cluster, thus significantly reducing the size of the training set. That is, the representative samples of each cluster are combined to form a reduced training set. The size of this training set is usually much smaller than the size of the original data set because it only contains representative samples of each cluster, not all data points.
[0082] Once the optimized training set X is obtained reduced , it can be used for subsequent machine learning model training to improve computational efficiency and possibly maintain a certain sample diversity.
[0083] 3.1.3 Step S102, hierarchical clustering:
[0084] Independently sample x i Cluster the spatial and temporal dimensions of the data, and for all samples x i The ε-neighborhood of is judged and whether it is a core point; recursion is performed on all core points. Specifically, it includes three sub-steps S1020 to S1022.
[0085] 3.1.3.1 Step S1020, spatiotemporal clustering:
[0086] First, use the DBSCAN algorithm to cluster the spatial coordinates and time coordinates of the data points respectively:
[0087] 1) Spatial clustering: For spatial clustering, the DBSCAN algorithm will determine clusters based on the spatial distance between data points. Read the optimized training set X reduced For each sample x in i The spatial vector represents the coordinates of the data point in space. The steps include:
[0088] S10200 and DBSCAN algorithms require two parameters: neighborhood radius ε S And the minimum number of points MinPts:
[0089] For each sample x i ∈X reduced , find all points in its ε-neighborhood, that is, satisfy the spatial distance All data points x j .
[0090] S10201. If a sample x i The ε-neighborhood of i (i.e. data points) are marked as core points.
[0091] S10202. Starting from any core point, recursively find all points that are reachable by its density to form a cluster.
[0092] S10203. Repeat S10202 until all core points have been visited and their clusters have been completely determined.
[0093] Among them, the spatial distance metric D S (x i ,x j ) can be calculated using the Euclidean distance formula:
[0094]
[0095] Among them, s id and jd The data points x are i and x j The coordinate in the dth spatial dimension, where D is the total number of spatial dimensions.
[0096] 2) Temporal clustering: For temporal clustering, the DBSCAN algorithm determines clusters based on the temporal distance between data points. Similarly, given the optimized training set X reduced , but at this time we should pay attention to the time attribute of each sample. The temporal distance metric is a time difference metric.
[0097] The steps of DBSCAN algorithm in temporal clustering are similar to those in spatial clustering, but the distance metric and parameters used are different. Specifically:
[0098] S10204. For each sample x i ∈X reduced , find all points in its ε-neighborhood, that is, satisfy the time distance All data points x j .
[0099] S10205. If a sample x i The ε-neighborhood of i (i.e. data points) are marked as core points.
[0100] S10206. Starting from any core point, recursively find all points that are reachable by its density to form a cluster.
[0101] S10207. Repeat S10206 until all core points have been visited and their clusters have been completely determined.
[0102] Among them, the time distance metric D T (x i ,x j ) can be calculated based on the specific time representation. If time is a one-dimensional numerical representation (such as a timestamp), the time distance can be the absolute value difference between two time points:
[0103] D T (x i ,x j )=|t i -t j |;
[0104] Among them, t i and t j The data points x are i and x j The time attribute.
[0105] 3.1.3.2 Step S1021, merging strategy:
[0106] Define a merging strategy to merge these independent clustering results (clusters) into a coarse spatiotemporal clustering hierarchy. This strategy considers the similarity or consistency between spatial clustering and temporal clustering. Among them, the following two schemes are given:
[0107] 1) Based on the number of shared data points: For each spatial cluster C S And each time cluster C T , calculate the number of data points shared between them |C S ∩C T |; If the number of shared data points exceeds the threshold T1, the two clusters are merged into a coarse-grained spatiotemporal cluster.
[0108] 2) Based on the distance between cluster centers:
[0109] For each spatial cluster C S And each time cluster C T , calculate the distance D(c S ,c T ); if this distance is less than the threshold T2, the two clusters are merged into a coarse-grained spatiotemporal cluster. The center point can be the mean or other statistics of all data points in the cluster.
[0110] 3.1.3.3 Step S1022, constructing a fine spatiotemporal clustering hierarchy:
[0111] P1. Intra-cluster fine-grained clustering: In each coarse-grained cluster, the multi-metric DBSCAN algorithm is applied again to perform fine-grained clustering. This step can be repeated multiple times (i.e., continuously returning to step S1021, a maximum number of cycles needs to be set) to gradually refine the cluster structure.
[0112] P2. Obtain a refined spatiotemporal clustering hierarchy: Through a merging strategy (such as based on the number of shared data points or the distance between cluster centers), the clustering results at different levels are merged again to obtain a refined spatiotemporal clustering hierarchy. This structure can be represented as a dendrogram for easy visualization and understanding.
[0113] 3.1.4 Step S103, feature engineering:
[0114] Calculate for each sample x i The statistics (including mean, variance and covariance) of the data point and its neighboring points in time and space are obtained, and these statistics are used as new features to construct a (new) feature set. That is, an extended feature set is obtained. Specifically, it includes three sub-steps from S1030 to S1032.
[0115] 3.1.4.1 Step S1030, define neighboring points:
[0116] For each data point x i ∈X reduced First, we need to define the set of its neighboring points. The set of neighboring points is represented by N(x i ), which contains all the data points x i Data points that are close enough in space and time.
[0117] 3.1.4.2 Step S1031, calculate statistics:
[0118] For each original (sample point) data point x i and its neighboring point set N(xi ), calculate the following statistics:
[0119] 1) Spatial mean μ S (x i ): Calculates the mean vector of neighboring points in the spatial dimension.
[0120]
[0121] where s j is the data point x j The spatial coordinate vector of |N(x i )| is the size of the set of neighboring points.
[0122] 2) Time mean μ T (x i ): Calculates the mean of neighboring points in the time dimension.
[0123]
[0124] where t j is the data point x j The time coordinate of .
[0125] 3) Spatial variance A measure of how dispersed neighboring points are in space.
[0126]
[0127] where ||s j -μ S (x i )|| represents the set N(x i ) is the Euclidean norm of the vector.
[0128] 4) Time variance A measure of how dispersed neighboring points are in time.
[0129]
[0130] 5) Covariance Cov(x) i ) (Optional): If there is a correlation between the spatial and temporal dimensions, their covariance can be computed.
[0131]
[0132] Here, s′ j and t′ j are the values of the space and time coordinates after centralization (i.e., subtracting their respective means), μ′ S (x i ) and μ′ T (x i) are the spatial and temporal means after centralization, which are actually both 0.
[0133] 3.1.4.3 Step S1032, construct a new feature set:
[0134] The statistics (mean, variance, covariance) calculated above are used as new features, together with the features of the original data points to form an extended feature set. This new feature set will be used as the input of the DBSCAN algorithm.
[0135] The original (sample point) data point x i Eigenvectorization of :
[0136] F(x i )=[f1(x i ),f2(x i ),...,f n (x i )];
[0137] Where n is the number of original features. Based on the above statistics (spatial mean, temporal mean, spatial variance, temporal variance and possible covariance).
[0138] f1(x i ),f2(x i ),...,f n (x i ) is the characteristic function, which transforms the data point x i Mapped to different dimensions in the feature space.
[0139] Now add these statistics to the end of the original eigenvector to form an expanded eigenvector F extended (x i ):
[0140]
[0141] If the scales of the original features and statistics are very different (for example, some features have values between 0 and 1, while others have values between 1000 and 10000), it is beneficial to perform feature scaling (such as standardization or normalization) before combining them. This helps ensure that all features have similar influence in the clustering algorithm.
[0142] Finally, we will get an expanded feature set, where each sample (data point) x i Each of them is represented by an extended eigenvector F extended (x i ). This extended feature set can be directly used as the input of the DBSCAN algorithm for further optimization, or directly used for training multimodal models.
[0143] The benefit of this is that feature engineering techniques are used to extract the temporal and spatial characteristics of the data and encode them into new features. These features can capture important information about the data in the temporal and spatial domains while reducing the dimensionality of the data. The so-called "extended feature set" can be regarded as a "reduced dimensionality dataset" that can perform sample selection and position adjustment operations more quickly (because the number of features that need to be processed is reduced).
[0144] 3.2 Step S2, information measurement strategy:
[0145] In this step, the LOF algorithm (Local Outlier Factor, LOF) is selected as the information measurement function I(x i ) to measure the sample x i The maximum amount of information is achieved by calculating the local outlier factor of the sample. The core idea of the LOF algorithm is that the density of the outlier point (or abnormal point) should be smaller than the density of other points in its neighborhood. Therefore, the algorithm determines whether the point is an abnormal point by comparing the density of each point with its neighborhood points.
[0146] 3.2.1 Step S200, define neighborhood:
[0147] For a given sample x i and a radius ε (which can be regarded as a threshold in this step), sample x i The ε-neighborhood N ε (x i ) is defined as all i The set of sample points whose distance is less than or equal to ε.
[0148] The reason why this solution does not use the "k-distance neighborhood" of the traditional LOF algorithm but the "ε-neighborhood" is to establish a complementary relationship with the DBSCAN algorithm mentioned above. Because the ε-neighborhood given by the DBSCAN algorithm provides an additional parameter (i.e., radius ε), the algorithm can more flexibly adapt to data sets of different densities. By adjusting the size of ε, the range of the neighborhood can be controlled, thereby capturing local anomalies of different scales.
[0149] At the same time, in some cases, the density of the data set may change, and using a fixed k-distance neighborhood may not adapt well to such changes. The ε-neighborhood allows the algorithm to use neighborhoods of different sizes in areas of different densities, thereby better capturing local abnormal patterns.
[0150] 3.2.2 Step S201, calculate the local reachability density:
[0151] For the sample x i and any point o in its ε-neighborhood, the reachable distance reachDist(o,x i ) is defined as the distance from point o to x i The maximum value between the distance and ε, that is:
[0152] reachDist(o,x i )=max(|ox i |,ε);
[0153] Sample x i The local reachability density lrd ε (x i ) is defined as x i All points in the ε-neighborhood of x i The reciprocal of the sum of the reciprocals of the reachable distances, that is:
[0154]
[0155] If N ε (x i ) is empty, it needs to be lrd ε (x i ) defines an infinity to handle this situation.
[0156] 3.2.3 Step S202, calculate the local outlier factor:
[0157] Sample x i The local outlier factor LOF ε (x i ) is calculated by comparing the local reachability density of the points in its ε-neighborhood with the sample x i It is calculated by the local reachable density.
[0158] Specifically, it is the sample x i The average local reachability density lrd of all points in the ε-neighborhood ε (o) with sample x i The local reachability density lrd ε (x i ), that is:
[0159]
[0160] Among them, |N ε (x i )| represents x i The number of points in the ε-neighborhood of .
[0161] 3.2.3 Step S203, interpreting the LOF score as an information measure:
[0162] LOF score greater than 1 indicates that sample x i is sparser than its neighbors in the ε-neighborhood and may be an outlier; close to 1 means that the sample x i has a similar density to its neighbors in the ε-neighborhood; if it is less than 1, it means that the sample x i is denser than its neighbors in the ε-neighborhood. Consider the LOF score as a sample x i A high LOF score means that the sample x i It is abnormal relative to its neighbors in the ε-neighborhood, so it carries more information. In this case, maximizing the amount of information is equivalent to finding the sample with the highest LOF score; therefore, we can use this as a basis and distribute the samples to form the reduced training set.
[0163] 3.3 Step S3, contribution measurement strategy:
[0164] This scheme selects the contribution measurement strategy as distance-based weighting as the contribution measurement function C(x i ); that is, the contribution of a sample point to the model is inversely proportional to its distance from the model center. In other words, sample points closer to the model center contribute more to the model, while sample points farther away contribute less.
[0165] 3.3.1 Step S300, determine the model center or reference point:
[0166] The traditional distance-based weighting method is to determine a model center or reference point, but for this scheme, each sample x i The ε-neighborhood center of is the reference point itself. Therefore, there is no need to calculate an additional model center or reference point. This reduces the computational difficulty and also establishes a connection with the DBSCAN algorithm mentioned above.
[0167] 3.3.2 Step S301, calculate distance:
[0168] For each sample x i , calculate its distance to all other samples, that is, which points fall on x i For any two sample points x i and o, if the distance between them |x i -o|≤ε, then it is called "o falls on x i "within the ε-neighborhood of .
[0169] 3.3.3 Step S302, calculate contribution:
[0170] Define a contribution function based on the number of sample points in the ε-neighborhood and calculate all samples x i There are two options:
[0171] 1) Solution 1: For each sample x i , its contribution function C(x i The output of )(is proportional to the number of sample points in its ε-neighborhood:
[0172] C(x i )=|N ε (x i )|;
[0173] Among them, N ε (x i ) represents the sample x i is the set of sample points in the ε-neighborhood of , and |·| represents the number of elements in the set.
[0174] 2) Scheme 2: Different from Scheme 1, this scheme hopes that the contribution is related to the inverse of the distance, so we can further consider the distance-weighted variant:
[0175]
[0176] Here δ is a small positive number (e.g. 0.001) to avoid division by zero.
[0177] 3.3.4 Step S303, standardization (optional):
[0178] If you want to standardize the contribution so that the sum of the contributions of all sample points is 1, then:
[0179]
[0180] Where X represents the set of all sample points. C′(x i ) is the standardized contribution function.
[0181] 3.3.5 Step S304, application:
[0182] Based on the calculated contribution or the standardized contribution, we can determine which samples x i The most important or priority for the model. During model training, sample x can be given a i Different weights are assigned to optimize the learning bias that affects the model. For example, in classifier training, higher misclassification costs can be assigned to sample points with higher contributions to form a reduced training set.
[0183] 3.4 Step S4, constructing the optimized training set:
[0184] After the above S1 to S3 are executed, a training set with reduced samples will be formed; the multimodal model is trained by using the training set.
[0185] In a second aspect, a storage medium is provided: the storage medium stores program instructions for executing the multimodal model optimization retrieval training method as described above.
[0186] Compared with the prior art, the present invention has the following beneficial effects:
[0187] 1. Extended DBSCAN algorithm as a sample selection strategy: In multimodal model optimization retrieval, the present invention uses an extended form of the DBSCAN algorithm to help select representative sample points, which are usually located in the core area of the data distribution and can better reflect the overall structure of the data. By eliminating noise points and boundary points, the interference in the model training process can be reduced, and the robustness and generalization ability of the model can be improved. At the same time, the extended DBSCAN algorithm not only enhances the traditional clustering effect, but also can more accurately process dynamic data, identify anomalies and boundaries, and perform time series analysis and event detection. These characteristics make the extended DBSCAN algorithm have broad application prospects in a variety of complex data processing and analysis tasks.
[0188] 2. Clustering of time and space characteristics: Although the traditional DBSCAN algorithm can find clusters of any shape in spatial data, the extended DBSCAN algorithm proposed in the present invention can more accurately identify dense areas and noise points in space by further considering the spatial characteristics, thereby obtaining more accurate clustering results. By analyzing the spatial characteristics, the extended DBSCAN algorithm can more clearly define the boundaries of clusters, which helps to understand the spatial distribution of data more accurately. At the same time, in time-varying data sets, the distribution and characteristics of data may change over time. The extended DBSCAN algorithm can recognize and adapt to such changes, thereby more accurately capturing the dynamic characteristics of the data. For time series data, the extended DBSCAN algorithm can help identify repetitive patterns, abnormal events, or periodic behaviors in time series. And in applications such as monitoring or sensor networks, being able to identify specific events in the time domain (such as sudden activities, changes in periodic behavior) is crucial for timely response and decision-making. The extended DBSCAN algorithm can detect these events more effectively by identifying time domain characteristics.
[0189] 3. LOF algorithm as an information measurement strategy: This invention evaluates the amount of information or abnormality carried by each sample point. By giving higher attention to sample points with larger information (i.e., higher LOF scores), the importance of these points to the model can be emphasized during the training process, thereby improving the model's ability to identify abnormal or rare situations.
[0190] 4. Distance-based weighting as a contribution measurement function and as a contribution measurement strategy: In multimodal model optimization retrieval, the present invention uses distance-based weighting as a contribution measurement function to quantify the contribution of each sample point to the model. By assigning higher weights to sample points with closer distances and higher similarity, the learning of these points can be strengthened during the model training process, thereby improving the model's retrieval performance for similar instances. BRIEF DESCRIPTION OF THE DRAWINGS
[0191] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0192] Figure 1 It is a schematic diagram of the method flow of steps S1 to S4 of the present invention;
[0193] Figure 2 is a schematic diagram of the method flow of step S1 of the present invention;
[0194] Figure 3 It is a schematic diagram of the method flow of step S2 and step S3 of the present invention;
[0195] Figure 4 FIG. 4 is a schematic diagram of the method flow of step S5 of the present invention. DETAILED DESCRIPTION
[0196] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below;
[0197] It should be noted that in this specification, the terms "point", "sample", "sample point" and "data point" are all represented by x or x. i Specifically, x is a general term that represents any universal symbol of a “point”, “sample”, “sample point” or “data point”; and x iIt refers to any "point", "sample", "sample point" or "data point". Although the terms "point", "sample", "sample point" and "data point" are used interchangeably in the textual descriptions of different steps due to structural limitations, these terms all refer to the same thing in the context of this specification and there is no substantial difference.
[0198] It should be particularly clarified that in this specification, although the terms "training set", "data set" and "time-varying data set" are used interchangeably in different forms of terms in the textual description of different steps due to structural limitations, these terms all refer to the same thing in the context of this specification and there is no substantial difference.
[0199] Example 1: Please refer to Figure 1 , for the optimization problem of multimodal model training set, this embodiment aims to reduce the time complexity, maintain the accuracy of sample selection, and intelligently measure each sample x i The contribution and information content of the training set are used to determine whether to include it in the training set, thereby avoiding unnecessary repeated execution. To achieve this goal, this embodiment sequentially performs the following steps S1 to S3.
[0200] In this embodiment, regarding step S1, sample selection strategy: this step adopts the DBSCAN algorithm as the sample selection strategy, but considering the deficiencies of the traditional DBSCAN algorithm in time domain and spatial domain characteristics, it needs to be expanded to adapt to data with these characteristics. Step S1 includes three sub-steps, S100 to S103.
[0201] In this embodiment, regarding step S100, defining the spatiotemporal neighborhood: When processing a multimodal model involving spatiotemporal data, defining the spatiotemporal neighborhood is a key step in optimizing retrieval training. This embodiment introduces the concept of spatiotemporal distance measurement by combining spatial distance and temporal distance, and determines the ε-neighborhood of each sample based on this. Step S100 specifically includes two sub-steps S1000 to S1001.
[0202] Specifically, regarding step S1000, the spatial distance and the temporal distance are combined:
[0203] In this sub-step, a spatiotemporal distance metric D is defined ST (P, Q), which also takes into account the spatial distance D S (P, Q) and time distance D T (P, Q). Specifically, for any two data points P and Q, their coordinates in space are (x P ,y P , z P ) and (x Q ,y Q , z Q), whose time coordinates are t P and t Q . Space-time distance metric D ST (P, Q) is:
[0204]
[0205] Among them, D S (P, Q) 2 is the spatial distance between points P and Q, which can be calculated using the Euclidean distance; for points in three-dimensional space:
[0206]
[0207] For a two-dimensional space (such as a video frame), it simplifies to:
[0208]
[0209] Among them, D T (P, Q) is the temporal distance between points P and Q, formulated using the time difference:
[0210] D T (P, Q) = |t Q -t P |;
[0211] Among them, the α weight factor is used to balance the importance of spatial distance and temporal distance. If the user actually believes that temporal continuity is greater than spatial proximity in the trend requirements of model training, α can be set to 0.6-1; otherwise, it can be set to 0.1-0.4. If it is believed that balancing spatial distance and temporal distance requires balancing, a value of 0.5 can be used.
[0212] Specifically, regarding step S1001, capturing and determining the neighborhood range: After defining the spatiotemporal distance metric, this substep will use the metric to determine the ε-neighborhood of each sample. The ε-neighborhood refers to the set of all sample points whose spatiotemporal distance to a given sample is less than or equal to a given threshold ε. By setting an appropriate threshold ε, the size of the neighborhood can be controlled, thereby balancing the complexity of the calculation and the accuracy of the sample selection.
[0213] That is, it can be understood that once the space-time distance metric D is defined ST (P,Q), we can use this metric to determine for each sample x i ε-neighborhood of (data point). For a given data point P and distance threshold ε, point Q belongs to the ε-neighborhood of P if and only if D ST(P,Q)<ε, if this condition is met, then point Q is said to belong to the ε-neighborhood of point P. In this way, sample points that are close to the current sample in space and time can be captured instead of considering the entire data set. The spatiotemporal neighborhood defined in this way can consider the proximity of data points in space and time at the same time, thereby more accurately capturing the characteristics of spatiotemporal data.
[0214] It can be understood that after determining the ε-neighborhood of each sample, a representative sample in each neighborhood can be further selected.
[0215] Exemplarily, the sample with the highest density or the sample closest to other samples is selected as a representative; this can reduce the number of samples that need to be processed, thereby reducing the time complexity of sample selection.
[0216] In summary, by executing steps S1000 and S1001, the spatiotemporal neighborhood can be effectively defined, and the ε-neighborhood of each sample can be determined based on the spatiotemporal distance metric. This will provide an important basis for sample selection and position adjustment in subsequent steps, thereby improving the efficiency and accuracy of the multimodal model optimization retrieval training method.
[0217] It should be pointed out that the ε-neighborhood is defined by the distance threshold ε. Specifically, for a given data point P, its ε-neighborhood contains all other data points whose spatiotemporal distance to point P is less than or equal to ε. In other words, if the spatiotemporal distance DST(P,Q) between a data point Q and point P is less than or equal to ε, then point Q is considered to be part of the ε-neighborhood of point P. Therefore, the distance threshold ε actually controls the size of the ε-neighborhood. A larger ε value results in a larger neighborhood range, thereby containing more data points; while a smaller ε value results in a smaller neighborhood range, containing fewer data points. By adjusting the value of ε, the size of the neighborhood and the accuracy of sample selection can be balanced to adapt to different application scenarios and data characteristics. After determining the ε-neighborhood, this neighborhood information can be further used for subsequent steps such as sample selection, clustering, and information measurement to achieve optimized retrieval training of multimodal models.
[0218] Furthermore, the execution program (MATLAB) for incorporating the threshold ε and the ε-neighborhood into S1000 to S1001 is as follows:
[0219]
[0220]
[0221] The principle of the above program is that data is an N*D matrix, where N is the data point x i, D is the number of dimensions (including the time dimension). epsilon is the threshold of the ε-neighborhood. alpha is the weight factor of the time dimension. Use the pdist2 function to calculate the spatial distance between all point pairs and obtain an N*N spatial distance matrix. Calculate the time distance between all point pairs and also obtain an N*N time distance matrix. Combine spatial distance and time distance; then for each point in the data set, find all points whose time-space distance is less than or equal to epsilon. Store the indices of these points in the corresponding elements of the cell array neighbors. Finally, it is necessary to exclude itself, that is, exclude the point itself from the ε-neighborhood of each point, because a point is usually not considered to be its own neighbor. This function finally returns a cell array neighbors, in which each element is an array containing the indices of all points in the ε-neighborhood of the corresponding point. These indexes can be used for further data processing, such as clustering later.
[0222] In this embodiment, regarding step S101, a multi-metric DBSCAN algorithm is executed: in the processing of multimodal data, the traditional DBSCAN algorithm often only supports a single distance measurement method, which is inadequate when processing data that contains both spatial and temporal dimensions. In order to solve this problem, this embodiment proposes an extended DBSCAN algorithm, namely a multi-metric DBSCAN algorithm, which can simultaneously consider the spatial neighborhood and temporal neighborhood of data points, and only considers data points as core points when density requirements are met under both metrics. Step S101 specifically includes sub-steps S1010 to S1011.
[0223] Specifically, regarding step S1010, combined distance function: When processing multimodal data, considering the importance of the two dimensions of space and time, we introduce a combined distance function. This function combines spatial distance and temporal distance and uses weights to adjust their influence. Specifically, given two data points P and Q, their combined distance metric D C (P,Q) is defined as follows:
[0224]
[0225] Among them, D S (P,Q) represents the spatial distance between points P and Q, D T (P,Q) represents the time distance between them. s and w T are the weights of spatial distance and temporal distance, respectively, and their sum is 1. These weights reflect the importance of spatial and temporal metrics in the combined distance. s and weight w T For details on the assignment scheme, please refer to the technical solution provided in Example 2.
[0226] Specifically, regarding step S1011, cluster analysis: obtain the combined distance metric D C (P, Q), through cluster analysis, the data set can be divided into several compact and meaningful clusters, and representative samples are selected from them to construct an optimized training set. It specifically includes steps S10110 to S10113:
[0227] In step S10110, clustering: first, use the multi-metric DBSCAN algorithm to cluster the data set. In this process, the algorithm will be based on the combined distance metric D C (P,Q) to determine which samples belong to the same cluster. Multi-metric DBSCAN considers both spatial distance and temporal distance, and requires that points meet density requirements under both metrics to be considered core points; its specific steps include:
[0228] P1. Choose two distance metrics D S and D T , namely the spatial distance metric (such as Euclidean distance) and the temporal distance metric (such as time difference), and the two corresponding neighborhood radii ε S and ε T , and the minimum number of points MinPts.
[0229] P2. For any two points P and Q in the data set, calculate their combined distance D C (P,Q).
[0230] P3. Determine the neighborhood: For each point P in the data set, find all the points in its neighborhood.
[0231] P4. Mark core points: If the neighborhood of point P contains at least MinPts points, mark P as a core point.
[0232] P5. Expand the cluster: Start from any unvisited core point and create a new cluster. Then, recursively find all points in the neighborhood of the core point and add them to the same cluster. If the point in the neighborhood is also a core point, continue to recursively expand the cluster.
[0233] P6. Repeat P5: until all core points have been visited and their clusters are completely determined.
[0234] P7. Processing noise points: Mark points that do not belong to any cluster as noise points.
[0235] Among them, the assignment of the minimum number of points MinPts can be achieved by drawing a K-distance graph, that is, for each data point, calculate its distance to the kth nearest neighbor and draw these distances into a graph. By observing this graph, you can find several suitable k values (that is, "MinPts-1" in the traditional sense), and through several rounds of trial and error, until the distance change becomes smaller before applying a certain k value, and the distance change becomes larger after applying the k value; find the k value that reflects this phenomenon the most, and use this k value as the minimum number of points MinPts; this method can help identify density changes in data and set the value of MinPts accordingly.
[0236] Among them, regarding step S10111, determine the center point: for each formed cluster, the center point CK can be selected as a representative sample. The average value of all points in the cluster is calculated to obtain the center point CK, which can be selected as a weighted average in the spatial and temporal dimensions:
[0237]
[0238] Among them, C k represents the kth cluster (set of points), |C k | is cluster C k number of points in, x i is the point in the cluster. If the data points have dimensions in both space and time.
[0239] It will be appreciated that this average calculation takes into account each of the spatial and temporal dimensions.
[0240] Among them, regarding step S10112 (optional step), select representative samples: in addition to the center point, other methods can also be selected to determine the representative samples.
[0241] Preferably, in step S10112, the point closest to the center point is selected as a representative sample. This solution includes any of the following beneficial effects:
[0242] 1) Reduce computational complexity: Calculating the center point may require considering the average value (weighted average) of all points in the cluster, which requires calculation and averaging of multiple dimensions. Selecting the point closest to the center point as a representative sample only requires calculating the distance from the point to the center point and selecting the point closest to the center point, thereby simplifying the calculation process;
[0243] 2) Improve sample representativeness: Sometimes there may be some points in a cluster that are far from the center point but still important. However, selecting the point closest to the center point as a representative sample can ensure that the selected sample is at least close to the center point in position, thus better representing the central trend of the cluster to a certain extent;
[0244] 3) Reduce the impact of noise: There may be some noise points or outliers in the data set, which may interfere with the calculation of the center point. Selecting the point closest to the center point as a representative sample helps reduce the impact of these noise points, because noise points are usually not the points closest to the center point.
[0245] In step S10113 (if step S10112 is not performed, this step is regarded as S10112), the training set is optimized: once the representative samples of each cluster are determined, these samples can be used to form a reduced training set. Suppose the original training set is:
[0246] X={x1,x2,...,x N};
[0247] Where N is the sample x i The total number of (data points). After multi-metric DBSCAN clustering, K clusters can be obtained, denoted as:
[0248] C={C1,C2,...,C K};
[0249] For each cluster C i , select a representative sample r; then, optimize the training set X reduced It can be composed of or include these representative samples:
[0250] X reduced ={r1,r2,...,r K};
[0251] Here, we optimize the training set X reduced It contains representative samples of each cluster, so its size is K, which is much smaller than the size of the original data set N. There are many ways to select representative samples.
[0252] Preferably, the center point of the cluster is selected as the representative sample. The calculation formula of the center point has been given in S10111. If the center point is defined as the mean of all points in the cluster (weighted average in space and time dimensions), then for the kth cluster C k , whose center point r k It can be calculated as:
[0253]
[0254] Among them, |C k | represents cluster C k The number of points in .
[0255] It is understandable that clustering can reduce a large number of data points to representative samples of each cluster, thereby significantly reducing the size of the training set. That is, the representative samples of each cluster are combined to form a reduced training set. The size of this training set is usually much smaller than the size of the original data set because it only contains representative samples of each cluster, not all data points.
[0256] Specifically, the MATLAB execution program of step S1011 is:
[0257] % Initialize an empty representative sample set
[0258] representativeSamples = [];
[0259] % For each cluster
[0260] for k=1:size(centers,1)
[0261] % Find the indices of all data points belonging to the current cluster
[0262] clusterIndices=find(labels==k);
[0263] % If the cluster has no data points, skip it
[0264] ifisempty(clusterIndices)
[0265] continue;
[0266] end
[0267] % Extract all data points belonging to the current cluster
[0268] clusterData=data(clusterIndices,:);
[0269] % Calculate the distance from each point to the cluster center
[0270] distances = pdist2(clusterData, centers(k,:)); % Use the pdist2 function to calculate the point-to-point distance
[0271] % Find the index of the point with the smallest distance
[0272] [~,minIndex]=min(distances);
[0273] % Add this point to the representative sample set
[0274] representativeSample=clusterData(minIndex,:);
[0275] representativeSamples=[representativeSamples;
[0276] representativeSample];
[0277] end
[0278] It should be noted that the above program relies on MATLAB's pdist2 function to calculate the distance between points. Therefore, the Statistics and Machine Learning Toolbox tool must be installed.
[0279] It is understandable that once the optimized training set X is obtained reduced , it can be used for subsequent machine learning model training to improve computational efficiency and possibly maintain a certain sample diversity. reduced It has representative samples measured in the time domain and space domain, which can represent the important features or cluster centers in the original data set. As mentioned earlier, selecting the point closest to the center point is a strategy to determine the representative sample. In addition, in the concept of the traditional DBSCAN algorithm, the core point is a key concept in the DBSCAN algorithm, which refers to the point that contains enough neighbors in the neighborhood. Training set X reduced Only core points are included, as they are sufficient to define the structure of the clusters. And thus the areas of higher density in the constructed dataset usually correspond to the cluster centers. By identifying these density peaks and including them in the training set X reduced In this case, clustering can be performed more effectively.
[0280] It should be further pointed out that the training set X reduced The main reasons for the optimization effect of DBSCAN algorithm retrieval and training are as follows:
[0281] 1) Reduce the amount of calculation: Use training set X reduced Replacing the original data set can significantly reduce the number of points that the DBSCAN algorithm needs to process, thereby reducing computational complexity and memory requirements;
[0282] 2) Reduce noise interference: Select representative samples by minimizing the filtering strategy, and train the set X reduced The influence of noise points can be reduced, making it easier for the algorithm to identify the real clustering structure;
[0283] 3) Improve clustering quality: If the training set X reducedThe samples in the dataset can well represent the distribution of the original data, so running DBSCAN on these samples may produce higher quality clustering results.
[0284] 4) Accelerated convergence: Due to the training set X reduced The number of samples in the training set is small, and the DBSCAN algorithm converges to a stable clustering state faster.
[0285] In this embodiment, regarding step S102, hierarchical clustering: hierarchical clustering is a key step in the optimization retrieval training of the multimodal model. It further refines the organizational structure of the data by performing independent clustering operations on the spatial dimension and time dimension of the data, thereby improving the retrieval efficiency. This step will independently cluster the sample x i Cluster the spatial and temporal dimensions of the data, and for all samples x i The ε-neighborhood of is judged and whether it is a core point; recursion is performed on all core points. Specifically, it includes three sub-steps S1020 to S1022.
[0286] Specifically, regarding step S1020, spatiotemporal clustering: spatiotemporal clustering plays a key role in multimodal model optimization retrieval training. This step uses the DBSCAN algorithm to cluster the spatial coordinates and time coordinates of data points respectively, further improving the organizational structure and retrieval efficiency of the data. The specific implementation of spatiotemporal clustering will be described in detail below:
[0287] (1) Spatial clustering: For spatial clustering, the DBSCAN algorithm determines clusters based on the spatial distance between data points. Read the optimized training set X reduced For each sample x in i The spatial vector represents the coordinates of the data point in space. The steps include:
[0288] S10200 and DBSCAN algorithms require two parameters: neighborhood radius ε S And the minimum number of points MinPts:
[0289] For each sample x i ∈X reduced , find all points in its ε-neighborhood, that is, satisfy the spatial distance All data points x j .
[0290] S10201. If a sample x i If the ε-neighborhood of contains at least MinPts points, the point is marked as a core point.
[0291] S10202. Starting from any core point, recursively find all points that are reachable by its density to form a cluster.
[0292] S10203. Repeat S10202 until all core points have been visited and their clusters have been completely determined.
[0293] Among them, the spatial distance metric D S (x i ,x j ) can be calculated using the Euclidean distance formula:
[0294]
[0295] Among them, s id and jd The data points x are i and x j The coordinate in the dth spatial dimension, where D is the total number of spatial dimensions.
[0296] (2) Temporal clustering: For temporal clustering, the DBSCAN algorithm determines clusters based on the temporal distance between data points. Similarly, given the optimized training set X reduced , but at this time we should pay attention to the time attribute of each sample. The temporal distance metric is a time difference metric.
[0297] The steps of DBSCAN algorithm in temporal clustering are similar to those in spatial clustering, but the distance metric and parameters used are different. Specifically:
[0298] S10204. For each sample x i ∈X reduced , find all points in its ε-neighborhood, that is, satisfy the time distance All data points x j .
[0299] S10205. If a sample x i If the ε-neighborhood of contains at least MinPts points, the point is marked as a core point.
[0300] S10206. Starting from any core point, recursively find all points that are reachable by its density to form a cluster.
[0301] S10207. Repeat S10206 until all core points have been visited and their clusters have been completely determined.
[0302] Preferably, the temporal distance metric D T (x i ,x j ) can be calculated based on the specific time representation. If time is a one-dimensional numerical representation (such as a timestamp), the time distance can be the absolute value difference between two time points:
[0303] D T (x i ,x j )=|t i -t j |;
[0304] Among them, t i and t j are respectively the time attributes of data points x i and x j .
[0305] Specifically, regarding steps S10202 and S10206, the two steps are substantially the same in logic:
[0306] P1. Definition of core point: If a point has at least MinPts points (including itself) in its ε-neighborhood, then this point is defined as a core point.
[0307] P2. Density reachability: If there exists a sequence of points p1, p2,..., pn, where p1 is a core point, and for any i (1 ≤ i < n), pi+1 is in the ε-neighborhood of pi, then pn is said to be density reachable from p1. This means that another point can be "reached" through a series of adjacent core points.
[0308] P3. Formation of clusters: Starting from any core point, find all the points that are density reachable from this point and form them into a cluster. This usually involves recursively finding and adding new density reachable points until no new points can be added to the cluster.
[0309] The above P1 to P3 can be implemented through the following Python pseudocode:
[0310]
[0311]
[0312] In the above pseudocode, the expandCluster function is the one that actually executes the logic of "recursively finding all density reachable points starting from a core point". It starts from a given core point, expands the current cluster by finding the points in the ε-neighborhood of this point and recursively performing the same operation on these points. If the points in the neighborhood are also core points and there are new density reachable points, these points will also be added to the cluster. It should be noted that the clusters in the DBSCAN algorithm are defined based on density connectivity, that is, any two points within a cluster must be density connected. This means that even if two points are in each other's ε-neighborhood, but if there are not enough points between them to form a density-connected path, they will not be assigned to the same cluster.
[0313] Specifically, regarding step S1021, the merging strategy is: merging these independent clustering results (clusters) into a coarse spatiotemporal clustering hierarchy. This strategy considers the similarity or consistency between spatial clustering and temporal clustering. Among them, the following two schemes are given:
[0314] 1) Based on the number of shared data points: For each spatial cluster C S And each time cluster C T , calculate the number of data points shared between them |C S ∩C T |; If the number of shared data points exceeds the threshold T1, the two clusters are merged into a coarse-grained spatiotemporal cluster. The steps of this scheme are:
[0315] P1. Calculate the number of shared data points: For each spatial cluster C S And each time cluster C T , calculate the number of data points shared between them, that is, the set C S and C T The intersection size of |C S ∩C T |.
[0316] P2. Set sharing threshold: Define a threshold T1, which represents the minimum number of data points that two clusters need to share in order to be considered related. If a pair of spatial clusters C S and time cluster C T If the number of shared data points between them exceeds the threshold T1, the two clusters are merged into a coarse-grained spatiotemporal cluster.
[0317] It is understandable that the value of the threshold T1 is limited by computing resources; it is necessary for technical personnel in this field to exercise subjective initiative and formulate it according to the actual environment.
[0318] This scheme emphasizes the co-occurrence of data points in spatial and temporal dimensions, and is suitable for clustering events or entities that are closely related in space and time, such as the coordination of a video and audio according to the rhythm of the picture (frame point position);
[0319] 2) Based on the distance between cluster centers: For each spatial cluster C S And each time cluster C T , calculate the distance D(c S ,c T ); if this distance is less than the threshold T2, the two clusters are merged into a coarse-grained spatiotemporal cluster. The center point can be the mean or other statistics of all data points in the cluster.
[0320] Unlike the previous solution, this solution focuses on the overall distribution of clusters rather than just shared data points. If the center points of two clusters are close enough, then the two clusters may belong to the same spatiotemporal context. The specific implementation is as follows:
[0321] P1. Calculate cluster center: For each spatial cluster C S and time cluster C T , calculate its center point. The center point can be the mean, median or other statistics of all data points in the cluster, depending on the specific distribution of the data and clustering requirements.
[0322] P2. Calculate the distance between clusters: Use a distance metric (such as the Euclidean distance provided above) to calculate the distance D (c S ,c T ).
[0323] P3. Set distance threshold: Define a threshold T2, which represents the maximum distance that needs to be met between two cluster centers in order to be considered related.
[0324] P4, merging clusters: If a pair of spatial clusters C S and time cluster C T If the center point distance between them is less than the threshold T2, the two clusters are merged into a coarse-grained spatiotemporal cluster.
[0325] This scheme emphasizes the overall similarity and proximity of clusters and is suitable for clustering events or entities with similar distribution characteristics in spatial and temporal dimensions.
[0326] It is understandable that, similarly, the value of the threshold T2 is limited by computing resources; it is necessary for those skilled in the art to exercise their subjective initiative to formulate it according to the actual environment.
[0327] It should be noted that the threshold T1 and the threshold T2 may also be assigned values according to the solution provided in the third embodiment.
[0328] Specifically, regarding step S1022, constructing a fine spatiotemporal clustering hierarchy:
[0329] P1. Fine-grained clustering within a cluster: Within each coarse-grained cluster, the multi-metric DBSCAN algorithm is applied again for fine-grained clustering. This step can be repeated multiple times to gradually refine the structure of the cluster. Specifically, after each fine-grained clustering, the resulting finer clusters can be used as new inputs and the multi-metric DBSCAN algorithm is applied again for clustering. This process can be repeated multiple times, but in order to avoid over-refinement and waste of computing resources, a maximum number of loops needs to be set. This maximum number of loops can be determined based on the specific application scenario, computing resources, or data set characteristics.
[0330] P2. Obtain a refined spatiotemporal clustering hierarchy: After completing the fine-grained clustering within the cluster, multiple levels of clustering results are obtained. In order to integrate these results into a refined spatiotemporal clustering hierarchy, it is necessary to use a merging strategy again. The merging strategy here can be the same or similar to the strategy used in step S1021, such as merging based on the number of shared data points or the distance between cluster centers. The merging strategy can be used to gradually merge clustering results at different levels into a tree-like clustering hierarchy. This structure can be represented as a dendrogram, in which each node represents a cluster, and the level of the node represents the degree of refinement of the cluster. The visual representation of the dendrogram can help us better understand and interpret the results of the clustering.
[0331] Exemplarily, the generation program (MATLAB) of the above tree diagram is:
[0332] %Generate data
[0333] rng(1); %For repeatability
[0334] data = rand(10,3); % 10 samples, 3 features per sample
[0335] % Perform hierarchical clustering
[0336] Z = linkage(data,'ward'); % Use Ward's method for hierarchical clustering
[0337] % Generate a dendrogram
[0338] figure;
[0339] dendrogram(Z);
[0340] % Customize the display of the tree diagram
[0341] set(gca,'YTickLabel',{}); %Remove the Y-axis label
[0342] title('Dendrogram ofHierarchical Clustering');
[0343] xlabel('Data Points');
[0344] ylabel('Distance');
[0345] %Save the dendrogram as an image file
[0346] saveas(gcf,'dendrogram.png');
[0347] In the above program, the linkage function performs hierarchical clustering and returns a linkage matrix Z, which describes the clusters merged during the clustering process and the distances between them. The dendrogram function uses this linkage matrix to generate a dendrogram.
[0348] In this embodiment, regarding step S103, feature engineering: calculate each sample x i The statistics (including mean, variance and covariance) of the data point and its neighboring points in time and space are obtained, and these statistics are used as new features to construct a (new) feature set. That is, an extended feature set is obtained. Specifically, it includes three sub-steps from S1030 to S1032.
[0349] Specifically, regarding step S1030, define the neighboring points:
[0350] For each data point x i ∈X reduced First, we need to define the set of its neighboring points. The set of neighboring points is represented by N(x i ), which contains all the data points x i Data points that are close enough in space and time. The definition of neighboring points is based on the proximity of data points in space and time. This step is the basis for the subsequent calculation of statistics, because the statistics are calculated based on the relationship between each data point and its neighboring points.
[0351] Specifically, regarding step S1031, calculating statistics: once the neighboring points are defined, a series of statistics can be calculated to describe the relationship between the data point and its neighboring points. These statistics include spatial mean, temporal mean, spatial variance, temporal variance, and optional covariance:
[0352] 1) Spatial mean μ S (x i ): Calculate the mean vector of neighboring points in the spatial dimension:
[0353]
[0354] where s j is the data point x j The spatial coordinate vector of |N(x i )| is the size of the set of neighboring points.
[0355] 2) Time mean μ T (x i ): Calculate the mean of neighboring points in the time dimension:
[0356]
[0357] where t j is the data point x j The time coordinate of .
[0358] 3) Spatial variance A measure of the degree of dispersion of neighboring points in space:
[0359]
[0360] where ||s j -μ S (x i )|| represents the Euclidean norm of a vector.
[0361] 4) Time variance A measure of how dispersed neighboring points are in time:
[0362]
[0363] 5) Covariance Cov(x) i )(Optional): If it is considered that the sample x i There is a correlation between the spatial and temporal dimensions of (for example, meteorological data, satellite navigation trajectory data, remote sensing image data, geo-tagged social media data, traffic flow data, etc., which contain not only spatial information but also temporal information), and their covariance can be calculated:
[0364]
[0365] ″
[0366] Here, s j and t j They are the spatial and time coordinates after being centered (i.e., subtracting their respective means)
[0367] The value of μ S (x i ) and μ T (x i ) are the spatial and temporal means after centralization, which are actually both 0.
[0368] It should be noted that these statistics are added as new features to the feature set, resulting in an extended feature set. This extended feature set contains more information about the relationship between data points and their neighbors, which helps improve the performance of subsequent retrieval tasks.
[0369] Specifically, regarding step S1032, construct a new feature set: the statistics (mean, variance, covariance) calculated above are used as new features, together with the features of the original data points to form an extended feature set. This new feature set will be used as the input of the DBSCAN algorithm. First, the original data point xi Eigenvectorization of :
[0370] F(x i )=[f1(x i ),f2(x i ),...,f n (x i )];
[0371] Where n is the number of original features. Based on the above statistics (spatial mean, temporal mean, spatial variance, temporal variance and possible covariance).
[0372] It is understandable that f1(x i ),f2(x i ),...,f n (x i ) is the characteristic function of the vector, that is, the original sample x i are mapped to different dimensions in the feature space.
[0373] For example, in image processing, f1(x i ),f2(x i ),...,f n (x i ) represents the conventional method of extracting features such as grayscale value, color channel value, gradient size, edge direction, etc. of pixel points in an image.
[0374] For example, in text processing, f1(x i ),f2(x i ),...,f n (x i ) represents a conventional method for extracting word frequency, TF-IDF value, n-gram features, etc. of words in a text.
[0375] Now add these statistics to the end of the original eigenvector to form an expanded eigenvector F extended (x i ):
[0376]
[0377] It is understandable that for each data point x i will be represented by an extended eigenvector F extended (x i ). This extended feature vector contains the original features and the newly calculated statistical features, thus providing richer information.
[0378] It should be noted that if the scales of the original features and statistics are very different (for example, some features range from 0 to 1, while other features range from 1000 to 10000), it is helpful to perform feature scaling before merging them. The feature scaling can be performed by scaling the range of features to a similar scale using conventional standardization or normalization. Doing so helps ensure that all features have similar influence in the subsequent clustering algorithm.
[0379] Exemplarily, a normalization method is used to scale the value of each feature to a distribution with a mean of 0 and a variance of 1.
[0380] Preferably, the normalization method is the Z-Score algorithm (also known as standard score normalization). For a given set of feature values, the Z-Score algorithm performs:
[0381]
[0382] Among them, F extended (x i ) old is the original sample (data point) x i The original expanded eigenvector F extended (x i ) value; F extended (x i ) new is the eigenvalue standardized by the Z-Score algorithm; μ is the mean of the eigenvalue set; σ is the standard deviation (square root of the variance) of the eigenvalue set.
[0383] In S1032 of this embodiment, an extended feature set is finally obtained, in which each sample x i Each of them is represented by an extended eigenvector F extended (x i ). This extended feature set can be directly used as the input of the DBSCAN algorithm for further optimization, or directly used for training multimodal models.
[0384] It is understandable that feature engineering is a key step in the data preprocessing of this embodiment, which involves extracting and constructing new features from raw data that help the machine learning algorithm learn. This is especially important in the context of multimodal data in this embodiment, because multimodal data often contains information from different sources (e.g., text, images, sounds, etc.), and this information may have different representations and characteristics. When feature engineering techniques are used to extract the spatiotemporal characteristics of data and encode them into new features, this means that the DBSCAN algorithm is looking for and utilizing temporal and spatial patterns in the data.
[0385] For example, in video analysis, the movement trajectory of an object may contain both spatial location information and time information. By calculating the statistics of neighboring points in time and space (such as mean, variance, etc.), these patterns can be captured and encoded as new features.
[0386] It is further understood that these new features have several important roles:
[0387] 1) Information Capture: The new features can capture information that may not be obvious in the original data but is very important when analyzing. For example, in video analysis, the speed or acceleration of an object may be an important feature, but it will not appear directly as a raw pixel value.
[0388] 2) Dimensionality reduction: Data dimensionality reduction can be achieved by encoding complex data patterns into a more compact set of features. But this does not mean that information is lost; on the contrary, key information is retained (or even highlighted) through a more efficient representation. In this new, lower-dimensional feature space, the similarities and differences between samples are more obvious, thus simplifying the subsequent learning task.
[0389] 3) Computational efficiency: Reducing the data dimension can greatly improve computational efficiency. Many machine learning algorithms (especially those involving a large number of mathematical operations or iterative optimization) can be very slow when running on high-dimensional data. By reducing the number of features that need to be processed, the technical solution provided in this embodiment can speed up operations such as sample selection and position adjustment.
[0390] 4) Enhanced robustness: Some machine learning algorithms may suffer from the "curse of dimensionality" in high-dimensional space, that is, as the dimension increases, the data becomes very sparse, resulting in a decrease in algorithm performance. By reducing the dimension through the above-mentioned feature engineering, the robustness of the "extended DBSCAN algorithm" featured in this embodiment can be enhanced.
[0391] It is understandable that when the above extended DBSCAN algorithm can identify sample x i After the temporal and spatial characteristics of the extended DBSCAN algorithm are obtained, compared with conventional clustering methods such as the traditional K-means algorithm, the extended DBSCAN algorithm maintains its original characteristics, that is, it does not need to know the number of clusters to be formed in advance, and can also find clusters of arbitrary shapes and identify noise points. i The order of input is not sensitive, that is, the input order has little effect on the result. At the same time, for samples at the boundary between clusters, their belonging to the spatial domain fluctuates according to which cluster is detected first.
[0392] It should be pointed out that the so-called "expanded feature set" actually enriches the original dataset by adding new features, but in a broad sense, if the new feature set more effectively represents the underlying structure of the data and does so with fewer features, then it can also be regarded as a kind of dimensionality reduction. The "dimensionality reduction" here does not refer to explicitly reducing the number of features through techniques such as principal component analysis (PCA), but refers to re-representing the data in a more compact and information-rich way through feature engineering.
[0393] Furthermore, from the perspective of minimizing the time complexity of sample selection and data position adjustment required by the multimodal model, the spatiotemporal characteristics of the data are extracted through feature engineering technology and encoded into new features. This process not only captures important information about the data in the time and space domains, but also reduces the dimension of the data by constructing a more effective and compact feature representation. This dimensionality reduction process helps to reduce the number of features that need to be considered in subsequent processing, thereby reducing the time complexity of sample selection and position adjustment. By using the calculated statistics (such as mean, variance, etc.) as new features, together with the features of the original data points, an extended feature set is formed. This extended feature set provides richer and more discriminative information than the original data, allowing subsequent clustering or classification algorithms to work more efficiently. Due to the improved quality of the feature set, the algorithm can converge to the optimal solution faster when performing sample selection and position adjustment. At the same time, the extended feature set is finally used as input. Due to the previous feature processing and dimensionality reduction work, the clustering algorithm can operate in a lower dimensional data space, thereby reducing the computational complexity. At the same time, the high-quality feature set also enables the clustering algorithm to find structures and patterns in the data faster.
[0394] In this embodiment, regarding step S2, information quantity measurement strategy: this step selects to execute the LOF algorithm (Local Outlier Factor, LOF) as the information quantity measurement function I(x i ) to measure the sample x i The maximum amount of information is achieved by calculating the local outlier factor of the sample. The core idea of the LOF algorithm is that the density of the outlier point (or abnormal point) should be smaller than the density of other points in its neighborhood. Therefore, the algorithm determines whether the point is an abnormal point by comparing the density of each point with its neighborhood points. It specifically includes four sub-steps from S200 to S203.
[0395] Specifically, regarding step S200, a neighborhood is defined: for a given sample x i and a radius ε (which can be regarded as a threshold in this step), first define the sample x i The ε-neighborhood of x. This neighborhood contains all iSample points whose distance is less than or equal to ε. The ε-neighborhood is chosen instead of the traditional k-distance neighborhood because it can complement the DBSCAN algorithm.
[0396] It is understandable that the ε parameter in the DBSCAN algorithm allows the size of the neighborhood to be controlled to adapt to data sets of different densities. By adjusting the value of ε, the sensitivity of the algorithm can be controlled, allowing it to capture meaningful clustering structures in data of different scales. This flexibility makes the ε-neighborhood a powerful tool that complements the DBSCAN algorithm. While the traditional DBSCAN algorithm itself is able to identify outliers in the data, the LOF algorithm based on the ε-neighborhood further provides a quantitative assessment of these outliers (by calculating the local outlier factor). This synergy allows us to understand the structure of the data more comprehensively and effectively use outlier information to optimize model training.
[0397] It is understandable that the ε-neighborhood in the DBSCAN algorithm provides an ε parameter that allows the algorithm to adapt more flexibly to data sets of different densities. By adjusting the size of ε, the range of the neighborhood can be controlled to capture local anomalies of different scales. In addition, when the density of the data set changes, the ε-neighborhood allows the algorithm to use neighborhoods of different sizes in areas of different densities to better capture local abnormal patterns.
[0398] Specifically, regarding step S201, the local reachability density (Local Reachability Density) is calculated:
[0399] For the sample x i and any point o in its ε-neighborhood, the reachable distance reachDist(o,x i ) is defined as the distance from point o to point x i The maximum value between the distance and ε, that is:
[0400] reachDist(o,x i )=max(|ox i |,ε);
[0401] Sample x i The local reachability density lrd ε (x i ) is defined as sample x i All points in the ε-neighborhood of the point and x i The reciprocal of the sum of the reciprocals of the reachable distances, that is:
[0402]
[0403] If N εIf (x) is empty, it needs to be lrd ε (x i ) defines an infinity to handle this situation.
[0404] Specifically, regarding step S202, the local outlier factor is calculated: sample x i The local outlier factor LOF ε (x) is obtained by comparing the local reachability density of the points in its ε-neighborhood with the sample x i It is calculated by the local reachable density.
[0405] Furthermore, it is a sample x i The average local reachability density lrd of all points in the ε-neighborhood ε (o) with sample x i The local reachability density lrd ε (x), that is:
[0406]
[0407] Among them, |N ε (x i )| represents sample x i The number of points in the ε-neighborhood of .
[0408] It is understandable that this ratio reflects the sample x i How different a point's density is relative to its neighborhood.
[0409] Specifically, regarding step S203, the LOF score is interpreted as an information quantity measure: a LOF score greater than 1 indicates that sample x i is sparser than its neighbors in the ε-neighborhood and may be an outlier; close to 1 means that the sample x i has a similar density to its neighbors in the ε-neighborhood; if it is less than 1, it means that the sample x i is denser than its neighbors in the ε-neighborhood. Consider the LOF score as a sample x i The information quantity measure.
[0410] It is understandable that a high LOF score means that sample x i It is abnormal relative to its neighbors in the ε-neighborhood, so it carries more information. In this case, maximizing the amount of information is equivalent to finding the sample with the highest LOF score; therefore, we can use this as a basis and distribute the samples to form the reduced training set.
[0411] Specifically, the above allocation steps include the following P1 to P5:
[0412] P1. Calculate the LOF score of all samples: First, for each sample in the dataset, its LOF score needs to be calculated. This involves determining the neighborhood size ε, calculating the local reachable density, and finally deriving the local outlier factor of each sample.
[0413] P2. Sort samples: Sort the calculated LOF scores from high to low or from low to high, depending on whether the multimodal model wants to focus on outliers or common points. If the focus is on outliers (with higher LOF scores), sort the scores in descending order.
[0414] P3. Select threshold or number of samples: Define the threshold of LOF score according to actual needs, or directly determine the number of samples you want to keep in the training set.
[0415] Exemplarily, the training of the multimodal model selects to retain only samples whose LOF scores are in the top N%, or selects samples whose LOF scores exceed a certain threshold.
[0416] P4. Assign samples to training sets: Based on the above selection criteria, eligible samples are assigned to new training sets. These samples are considered to carry more information, perhaps because they are outliers or represent important patterns in the data set.
[0417] P5. Processing of remaining samples: For the samples that are not selected, they can be processed according to the actual situation. They can be completely ignored or retained for other subsequent analyses, such as as part of the validation set or test set.
[0418] In this embodiment, regarding step S3, contribution measurement strategy: this solution selects the contribution measurement strategy as distance-based weighting as the contribution measurement function C(x i ); that is, the contribution of the sample point to the model is inversely proportional to its distance from the model center. In other words, the sample point closer to the model center contributes more to the model, while the sample point farther away contributes less. Specifically, it includes five sub-steps from S300 to S304.
[0419] Specifically, regarding step S300, determining the model center or reference point: the traditional distance-based weighting method is to determine a model center or reference point, but for this solution, each sample x i The ε-neighborhood center of is the reference point itself. Therefore, there is no need to calculate an additional model center or reference point. This reduces the computational difficulty and also establishes a connection with the DBSCAN algorithm mentioned above.
[0420] Specifically, regarding step S301, calculate the distance: for each sample x i, calculate its distance to all other samples, that is, which points fall on x i For any two sample points x i and o, if the distance between them |x i -o|≤ε, then it is called "o falls on x i "within the ε-neighborhood of .
[0421] Specifically, regarding step S302, calculate the contribution: define a contribution function based on the number of sample points in the ε-neighborhood, and calculate all samples x i There are two options:
[0422] 1) Solution 1: For each sample x i , its contribution function C(x i The output of )(is proportional to the number of sample points in its ε-neighborhood:
[0423] C(x i )=|N ε (x i )|;
[0424] Among them, N ε (x i ) represents the sample x i is the set of sample points in the ε-neighborhood of , and |·| represents the number of elements in the set.
[0425] It can be understood that the contribution function C(x i ) is equal to the output of sample x i This scheme is simple and intuitive, and can reflect the density information of sample points in the local area.
[0426] 2) Scheme 2: Different from Scheme 1, this scheme hopes that the contribution is related to the inverse of the distance, so we can further consider the distance-weighted variant:
[0427]
[0428] Here δ is a small positive number used to avoid division by zero.
[0429] It can be understood that this scheme can more finely characterize the contribution of sample points to the model, taking into account the influence of distance factors.
[0430] It can be understood that no matter which of the above schemes is used, the contribution function C(x i ) is the output of this x i The contribution value of .
[0431] Specifically, regarding step S303, standardization (optional): if it is desired to standardize the contribution so that the sum of the contribution of all sample points is 1, then:
[0432]
[0433] Where X represents the set of all sample points. C′(x i ) is the standardized contribution function.
[0434] Specifically, regarding step S304, application: Finally, during the model training process, we can determine which samples are most important or have priority to the model based on the calculated contribution or the standardized contribution.
[0435] For example, in the training of the classifier, a higher misclassification cost can be assigned to sample points with higher contribution, so as to form a reduced training set. In this way, the learning bias of the model can be optimized, and the performance and generalization ability of the model can be improved. At the same time, this contribution-based sample selection strategy can also help multimodal models more effectively utilize limited computing resources and improve training efficiency.
[0436] In this embodiment, regarding step S4, an optimized training set is constructed: after completing steps S1 to S3, the complexity of each sample is minimized (S1), and each sample is assigned a corresponding contribution and priority (S2~S3); next, the goal of step S4 is to perform training on the multimodal model based on the optimized training set of S1~S3 (including the samples that are most valuable for model training), and this process improves the training efficiency of the multimodal model.
[0437] Embodiment 2: Based on Embodiment 1, this embodiment further provides a method for determining the weight w s and weight w T The assignment scheme is:
[0438] The weights are automatically determined by minimizing the clustering quality index, which requires the use of a gradient descent algorithm: the clustering quality index is J, which is considered to be related to the weight w s and weight w T The objective function is denoted as J(w s ,w T ). This function is a criterion for evaluating the closeness of clustering. The goal is to find a set of weights that minimizes J.
[0439] It should be noted that the goal of the clustering algorithm is to cluster similar data points into the same cluster, while making the data points in different clusters as different as possible. Cohesion is an important aspect of evaluating the clustering effect, which measures the similarity or proximity between data points in the same cluster. Therefore, this embodiment preferably uses cohesion as the objective function J(w s ,w T )’s evaluation criteria.
[0440] Preferably, for compactness as the objective function J(w s ,w T ) evaluation criteria, this embodiment selects the DBI (Davies-Bouldin Index) indicator, which takes into account the average distance within the cluster and the distance between different clusters. The smaller the DBI value, the better the clustering effect. When DBI is used as the objective function J(w s ,w T ), its goal is to find the weight w s and weight w T , so that the DBI value obtained after distance calculation and clustering according to this weight is the smallest; the method for obtaining the DBI indicator is:
[0441]
[0442] Here, k is the number of clusters. is the sum of all samples in the ith cluster and the cluster center c i The average distance between . is the sum of all samples in the jth cluster and the cluster center c j The average distance between i , c j ) is the cluster center c i With cluster center c j The distance between.
[0443] When using DBI as the objective function, this embodiment suggests adding an additional step to enhance the accuracy, that is, according to the weight w s and weight w R The Euclidean distance is calculated, then clustering is performed, and finally the DBI value is calculated based on the clustering results.
[0444] In this embodiment, the gradient descent algorithm searches for the minimum by iteratively updating the weights. In each iteration, the weights are updated in the direction of the negative gradient of the loss function in the hope of reaching a local minimum. The gradient descent algorithm is considered as an update rule in this embodiment, expressed as:
[0445]
[0446]
[0447] and is the new weight w output by each iteration s and weight w T The value of and is the weight w of the previous iteration in each iteration s and weight w T The value of ; η is the learning rate, a positive decimal used to control the step size of each update. It is a partial differential character; and They are loss function J versus weight w s and w T The partial derivative (also known as the gradient) of .
[0448] It should be pointed out that the choice of learning rate η has a great influence on the performance and convergence speed of the gradient descent algorithm, and the specific value assignment depends on the balanced allocation of computing resources and η in actual operation. If the learning rate is too large, the algorithm will oscillate around the minimum value and fail to converge; if the learning rate is too small, the algorithm will converge too slowly. Therefore, in actual application, technical personnel in this field need to exercise their subjective initiative, debug the learning rate η multiple times, and assign values to it.
[0449] It is understandable that the key issue here is how to define the clustering quality index J and how to calculate and This depends on the specific clustering quality evaluation criteria chosen. This technical solution chooses to define a custom loss function based on the distance between samples.
[0450] Exemplarily, the loss function is defined as the average or sum of the combined distances of all samples to other samples in their ε-neighborhood:
[0451]
[0452]
[0453] Among them, ε(i) is the ε-neighborhood;
[0454] It can be understood that the above formula calculates the average of the squares of the combined distances of all samples to other sample points in their ε-neighborhood, which is used to quantify the compactness or loss of clustering. In the process of calculating this average value, the contributions of all sample points are added up and then divided by the total number of sample points N. Therefore, the contribution of each sample point to the loss function is taken into account equally.
[0455] It should be pointed out that in this case, the partial derivative of the loss function with respect to the weight needs to be calculated, because the partial derivative of the loss function with respect to the weight represents the gradient direction of the loss function in the weight space. Calculating the partial derivative can guide how to adjust the weights to minimize the loss function:
[0456]
[0457]
[0458] Specifically, the partial derivative indicates the sensitivity of the loss function value to the change of weight. If the partial derivative is positive, it means that increasing the weight will increase the loss function value, so the weight should be reduced; if the partial derivative is negative, it means that increasing the weight will decrease the loss function value, so the weight should be increased. By calculating the partial derivative of the loss function with respect to the weight and using it in the weight update rule of the gradient descent algorithm, the weight can be iteratively adjusted so that the loss function gradually decreases, thereby optimizing the clustering effect.
[0459] That is, once these partial derivatives are calculated, the standard gradient descent algorithm can be used to iteratively update the weights. By continuously iteratively updating the weights, the value of the loss function can be gradually reduced, thereby optimizing the clustering effect. The iterative process will continue until a satisfactory clustering effect is achieved or the stopping criteria are met (such as the gradient is small enough or the maximum number of iterations is reached).
[0460] For example, if the value of the loss function decreases very slowly or almost no longer decreases in several consecutive iterations, it means that the gradient is small enough, or the optimization is close to a local minimum, then the “gradient is small enough”.
[0461] Embodiment 3: Based on Embodiment 1, this embodiment further provides a scheme for assigning the threshold value T1 and the threshold value T2:
[0462] In this embodiment, regarding the threshold T1:
[0463] P1. First, for each pair of spatial clusters C S and time cluster C T , calculate the number of data points shared between them |C S ∩C T |.
[0464] P2. Collect the number of shared data points of all pairs of spatial clusters and temporal clusters to form a distribution.
[0465] P3. Analyze this distribution and choose any of the following statistics as the basis for assigning T1:
[0466] 1) Mean of the distribution:
[0467] T1=Mean(|C S ∩C T |For all distributions);
[0468] 2) Median of the distribution:
[0469] T1=Median(|C S ∩C T |For all distributions);
[0470] 3) A percentile of the distribution, such as the 75th percentile:
[0471] T1=75th Percentile(|C_S∩C_T|For all distributions);
[0472] In the above formula, “For all distributions” is the “for all distributions” operation; Mean is the mean operation of the distribution, Median is the median operation of the distribution, and Percentile is the percentage operation of the distribution.
[0473] In this embodiment, regarding the threshold T2:
[0474] P1. First, for each pair of spatial clusters C S and time cluster C T , calculate the number of data points shared between them |C S ∩C T |.
[0475] P2. Collect the distances between all pairs of spatial cluster centers and temporal cluster centers to form a distribution.
[0476] P3. Analyze this distribution and choose any of the following statistics as the basis for assigning T2:
[0477] 1) Mean of the distribution:
[0478] T2=Mean(D(C S , C T )For all distributions);
[0479] 2) Standard Deviation of the distribution, used in conjunction with the mean:
[0480] T2=Mean(D(C S , C T ))+k*StdDev(D(CS , C R ));
[0481] where k is the adjustment factor.
[0482] 3) A percentile of the distribution, such as the 90th percentile:
[0483] T2=90th Percentile(D(C S , C T ) for all distributions).
[0484] Among them, "For all distributions" is the "for all distributions" operation; Mean is the mean operation of the distribution, StdDev is the standard deviation operation of the distribution, and Percentile is the percentage operation of the distribution.
[0485] Embodiment 4: Figure 4 As shown, this embodiment executes the DS evidence theory algorithm on the basis of the embodiment one. The algorithm further introduces an adaptive correction strategy (step S5) for the solution of the embodiment one, so that the training set can consider the historical contribution and historical priority of each sample to correct steps S2 and S3; step S5 specifically includes four sub-steps from S500 to S503.
[0486] In this embodiment, regarding step S500, firstly, evidence set A and evidence set B are collected:
[0487] A=[LOF ε (x i ) 1 ,LOF ε (x i ) 2 ,…,LOF ε (x i ) N ];
[0488] Among them, LOF ε (x i ) 1 ,LOF ε (x i ) 2 , ..., LOF ε (x i ) N is the sample x i The historical LOF score values are evenly divided according to a certain time step, and the maximum number of the time step is N;
[0489] B=[C(x i )1 ,C(x i ) 2 ,…,C(x i ) N ];
[0490] Among them, C(x i ) 1 ,C(x i ) 2 , ..., C(x i ) N The same sample x i The historical contribution value is also evenly divided according to a certain time step, and the maximum number of the time step is also N;
[0491] In this embodiment, regarding step S501, evidence A and evidence B are combined using Dempster's combination principle, that is, for a given set of evidence A1, A2, ..., A n (Same as evidence B), Dempster's combination rule calculates the set of combined confidence assignments Bel(C), where C is the possible hypothesis or state space. In addition, the combined uncertainty assignment Pl(C) is calculated:
[0492]
[0493] Combined uncertainty allocation Pl(C):
[0494]
[0495] It should be pointed out that A i and B i are a subset of evidence A and evidence B respectively; mass is the weight (divided according to the average amount of evidence); C is the "possible set"; represents the empty set;
[0496] Then we get the joint trust function Bel(A∪B):
[0497]
[0498] Bel(A) and Pl(A) are the confidence and uncertainty distributions of the set of evidence A;
[0499] Bel(B) and Pl(B) are the confidence and uncertainty distributions of the set of evidence B;
[0500] (Pl(A)∩Pl(B)) is the uncertainty distribution of the intersection of evidence A and evidence B:
[0501]
[0502] A i and B i are subsets of evidence A and evidence B respectively. The numerator is the sum of the mass of evidence supporting A∩B, and 1 minus this sum gives Pl(A∩B), which indicates the degree of uncertainty about A∩B.
[0503] in, Represents any subset A in evidence A i The intersection with a subset Bi in evidence B is not empty. That is, it searches for a subset A that exists in the objective i , the mass of this subset in A is not zero, and there is a subset B i , the mass of this subset in B is also not zero, that is, the two subsets have an intersection. It can be understood that Responsible for finding some elements in hypothesis set C that are supported by both evidence A and evidence B. Then, when calculating the combined trust distribution Bel(C), these common elements must be taken into account because they contribute to the support of the hypothesis set C.
[0504] It can be understood that, in practical terms, the joint trust function Bel(A∪B) provides comprehensive evidence information, reflecting the support and uncertainty of the changes output by the multimodal model after training in the historical data collected at the current time and in the previous time period. Through this trust function, the support for different hypotheses or states can be quantified and used to correct each sample x in the training set. i priority and importance.
[0505] In this embodiment, regarding step S502, the joint trust function Bel(A∪B) is mapped to an interval value between [0,1] as the correction factor γ through the sigmoid function:
[0506]
[0507] e is the base of natural logarithm, which is approximately equal to 2.718; the input of sigmoid function is the output of Bel(A∪B). The characteristic of sigmoid function is that its output range is between [0,1] regardless of the input.
[0508] It is understandable that the size of the correction factor γ will be affected by Bel(A∪B), thereby adjusting the state transition function in the system. The output value of the sigmoid function approaches 1 when Bel(A∪B) is large, and approaches 0 when Bel(A∪B) is small. Therefore, the size of the correction factor γ reflects the size of Bel(A∪B). This mapping preserves the causal relationship, that is, the change of γ is consistent with the change of Bel(A∪B). Through this correction, the system can introduce a certain uncertainty correction when considering the credibility of historical evidence, so as to adapt to different situations more flexibly. This design helps the system to be more adaptive and robust when facing new data and changes.
[0509] In this embodiment, regarding step S503, the following is modified:
[0510] 1) For S2:
[0511]
[0512] 2) For S3:
[0513]
[0514] It can be understood that multiplying the correction factor γ is actually a weighted adjustment to the original function. The purpose of this adjustment is to introduce dependence on the trust of the correction factor γ, so as to adaptively modify the model according to the current evidence (reflected by γ). That is, if γ approaches 1 (constrained by evidence A), then the sample x i The priority (information content) of x is more important than the repetition. The multimodal model considers the sample x i Due to its rich information, further training is needed; vice versa.
[0515] The above embodiments only express the implementation methods of the relevant practical applications of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
[0516] For those skilled in the art, it can be further appreciated that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are 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.
[0517] At the same time, those skilled in the art can understand that all or part of the processes in all the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium, and when the computer program is executed, the storage medium may include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media by the methods provided in this application and used in the embodiments may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), Synchlink, RAMbus direct RAM (RDRAM), direct RAMbus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.
Claims
1. A multimodal model optimization retrieval training method, comprising a multimodal model and a training set thereof, wherein the training set comprises N samples x=x1,x2,...,x N , where any sample x i Represents an audio, text or video training data, characterized by: The following optimization retrieval steps are performed for the training of the multimodal model: S1. Sample selection strategy: Execute the DBSCAN algorithm for all samples x in the training set i The temporal and spatial characteristics of the sample are combined to capture and determine the range of the ε-neighborhood of each sample. The spatial distance and temporal distance of each data point are combined through the combined distance function. The optimization strategy is used to find all samples x i The minimum value of the data points is then used to perform hierarchical clustering analysis and select representative samples to form the reduced training set; S100, define a spatiotemporal neighborhood: the spatiotemporal neighborhood includes a spatial neighborhood and a temporal neighborhood, the spatiotemporal neighborhood considers both spatial proximity and temporal proximity, and represents the sample x i The temporal and spatial characteristics of all samples x i ε-neighborhood of ; S101, execute the multi-metric DBSCAN algorithm: for all samples x i It is necessary to consider both the spatial neighborhood and the temporal neighborhood at the same time, and a point must meet the density requirements under both metrics to be considered as a core point; In the S101, it includes: S1010, combined distance function D C (P,Q): Combine the spatial distance and temporal distance of the spatial neighborhood and the temporal neighborhood, respectively, and use weights to adjust their influence: Among them, w s and w T are the weights of spatial distance and temporal distance, and their sum is 1; D S (P,Q) is a spatial distance metric, representing the spatial distance; D T (P,Q) is a temporal distance metric representing the temporal distance; S1011. Cluster analysis: Get the combined distance metric D C After (P,Q), the data set is clustered and several clusters are generated. The center point or representative sample of each cluster is selected as training data; S102, hierarchical clustering: independently cluster the samples x i Cluster the spatial and temporal dimensions of the data, and for all samples x i The ε-neighborhood of is judged and whether it is a core point; S1020, Spatiotemporal Clustering: In the S1020, for spatial clustering: determine the cluster based on the spatial distance between the data points; read the optimized training set X reduced For each sample x in i The spatial vector represents the coordinates of the data point in space; spatial clustering includes S10200~S10203: S10200, define neighborhood radius ε S And the minimum number of points MinPts; for each sample x i ∈X reduced , find all points in its ε-neighborhood, that is, satisfy the spatial distance All data points x j ; S10201. If a sample x i The ε-neighborhood of i Mark as core point; S10202. Starting from any core point, recursively find all points that can be reached by its density to form a cluster; S10203, repeat S10202 until all core points have been visited and their clusters have been completely determined; In S1020, for time clustering: determine clusters based on the time distance between data points; given an optimized training set X reduced , focusing on the time attribute of each sample; the time clustering includes S10204~S10207: S10204. For each sample x i ∈X reduced , find all points in its ε-neighborhood, that is, satisfy the time distance All data points x j ; S10205. If a sample x i The ε-neighborhood of i Mark as core point; S10206. Starting from any core point, recursively find all points that can be reached by its density to form a cluster; S10207, repeat S10206 until all core points have been visited and their clusters have been completely determined; S1021, merging strategy: merging these independent clustering results into a coarse spatiotemporal clustering hierarchy based on the number of shared data points or the distance between cluster centers; the coarse spatiotemporal clustering hierarchy includes a number of coarse-grained spatiotemporal clusters; S1022, constructing a fine spatiotemporal clustering hierarchy: within each coarse-grained cluster, applying the multi-metric DBSCAN algorithm again to perform fine-grained clustering, and gradually refining the cluster structure; through the merging strategy described in S1021, merging the clustering results at different levels again into a spatiotemporal clustering hierarchy; Recursively perform the process on all core points to form a cluster and merge them into a spatiotemporal clustering hierarchy; S103. Feature Engineering: Calculate each sample x i The statistics of the data points and their neighboring points in time and space are used as new features to construct an extended feature set, which is then used as the dataset after dimensionality reduction. S2, information measurement strategy: For any sample x i , read the range of their ε-neighborhood, and execute the LOF algorithm to calculate each sample x i The local reachability density of the ε-neighborhood and its local outlier factor are used to construct the LOF score; by interpreting the LOF score as any sample x i The information content measurement of S3. Contribution measurement strategy: For any sample x i , calculate it for all other samples x i The distance is weighted by the contribution function and each sample x is calculated. i The contribution C(x i ), take this as all samples x i Assign different weights; S300, determine the reference point: each sample x i The ε-neighborhood center of is the reference point; S301, calculate the distance: for any two samples x i and o, if the distance between them satisfies |x i -o|≤ε, then sample o falls within sample x i ε-neighborhood of ; S302, calculate contribution: define a contribution function C(x) based on the number of sample points in the ε-neighborhood i ), calculate all samples x i The contribution function C(x i ) and sample x i It is proportional to the number of sample points in the ε-neighborhood of: C(x i )=|N ε (x i )|; Among them, N ε (x i ) represents the sample x i The set of sample points in the ε-neighborhood of , |·| represents the number of elements in the set; After executing S302, determine which samples x i The most important or priority for the model, during the model training process, the sample x is ranked according to its contribution i Assign different weights; S4. After S1 to S3 are executed, a training set with reduced samples will be formed, and the multimodal model will be trained by using the training set.
2. The multimodal model optimization retrieval training method according to claim 1, characterized in that: In the S100, it includes: S1000, combine the spatial distance and the temporal distance: for any two data points P and Q, their coordinates in space are (x P ,y P ,z P ) and (x Q ,y Q ,z Q ); Define the space-time distance metric D ST (P,Q) is: Among them, D S (P,Q) 2 is the spatial distance between points P and Q; D T (P,Q) is the temporal distance between points P and Q; S1001. Capture and determine neighborhood range: based on spatiotemporal distance measurement D S (P,Q) 2 Determine for each sample x i ε-neighborhood; For a given data point P and distance threshold ε, point Q belongs to the ε-neighborhood of P if and only if: D S (P,Q) 2 <ε.
3. The multimodal model optimization retrieval training method according to claim 2, characterized in that: In the S1011, it includes: S10110. Clustering the data set: Based on the combined distance metric D C (P,Q) determines which samples x i Belong to the same cluster; consider both spatial distance and temporal distance, and require that points meet density requirements under both metrics to be considered core points; S10111. Determine the center point: For each formed cluster, select the center point CK as a representative sample; calculate the average value of all points in the cluster to obtain the center point CK, and perform weighted averaging in the spatial and temporal dimensions: Among them, C k represents the kth cluster, |C k | is cluster C k number of points in, x i is a point in the cluster; S10112. Optimize the training set: After clustering, K clusters are obtained: C={C1,C2,...,C K }; For each cluster C i Select a representative sample r to form an optimized training set X reduced : X reduced ={r1,r2,...,r K}; Optimize training set X reduced A representative sample of each cluster is included.
4. The multimodal model optimization retrieval training method according to claim 3, characterized in that: In S103, the statistics include the spatial mean μ S (x i ), time mean μ T (x i ), spatial variance and time variance Together with the features of the original data points, they form an extended feature set; the original data x i Eigenvectorization of : F(x i )=[f1(x i ),f2(x i ),...,f n (x i )]; Among them, f1(x i ),f2(x i ),...,f n (x i ) is the feature function; n is the number of original features; These statistics are added to the end of the original eigenvector to form an expanded eigenvector F extended (x i ): Get the extended feature set, where each sample x i Each of them is represented by an extended eigenvector F extended (x i )express.
5. The multimodal model optimization retrieval training method according to claim 4, characterized in that: In said S2, it includes: S200, define the neighborhood: for any given sample x i and a radius ε, the sample x i The ε-neighborhood N ε (x i ) is defined as all i The set of sample points whose distance is less than or equal to ε; S201. Calculate the local reachable density: for sample x i and any point o in its ε-neighborhood, the reachable distance reachDist(o,x i ) is the point from o to x i The maximum value between the distance and ε: reachDist(o,x i )=max(|ox i |,ε); Sample x i The local reachability density lrd ε (x) is defined as sample x i All points in the ε-neighborhood of the sample x i The reciprocal of the sum of the reciprocals of the reachable distances: S202, calculate the local outlier factor: for sample x i The average local reachability density lrd of all points in the ε-neighborhood ε (o) with sample x i The local reachability density lrd ε (x i ) is the mean of the ratios: Among them, |N ε (x i )| represents sample x i The number of points in the ε-neighborhood of ; S203, interpret the LOF score as a measure of information quantity: use this as a basis and distribute the samples to form a reduced training set.
6. A storage medium, characterized in that: The storage medium stores program instructions for executing the multimodal model optimization retrieval training method as described in any one of claims 1 to 5.
