A method for applying archival data based on large models
Through the application method of archival data based on large models, the problem of difficulty in comprehensively searching archive information in the prior art is solved, efficient screening and extraction of relevant information is achieved, and the work burden of employees and the reading of repeated information is reduced.
Patent Information
- Application Number
- CN202411443162.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2044-10-16
AI Technical Summary
The prior art is difficult to search out all the archive information required in a comprehensive and concise manner, resulting in employees facing a large amount of burden and duplicate information during the information screening process.
Using the big model-based archival data application method, the archival information can be realized through the steps of establishing historical labels, word segmentation extraction and vectorization, similarity calculation and F1 value maximum area selection, word segmentation classification, document set association and undirected graph construction. Efficient screening and extraction.
The comprehensive extraction of relevant information is achieved, duplicate information is reduced, the workload of employees is reduced, and the efficiency and accuracy of information screening is improved.
Smart Images

Figure CN118964599B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of archival data application, and in particular to an archival data application method based on a large model. Background Art
[0002] When carrying out projects involving historical materials such as museums, historical buildings and exhibition halls, for example, in exhibition halls, some exhibits need to be introduced and their relevant information displayed to tourists in the form of text. In order to have a more comprehensive understanding of the historical archives of the exhibits, employees are required to search the relevant historical archives of the exhibits and select the correct information required from the archives for display.
[0003] However, at present, when searching for relevant archives, customers can only enter relevant keywords to search for archives. It is difficult to comprehensively search for all archival information related to the exhibits, and omissions often occur. In addition, a large amount of duplicate information will be searched out during the search process. Therefore, a lot of burden is placed on employees' information screening work. Summary of the invention
[0004] In view of the deficiencies of the prior art, the present invention provides an archival data application method based on a large model, which solves the problem that it is difficult to comprehensively and concisely search for all required archival information when searching for archival information by entering keywords.
[0005] To achieve the above object, the present invention provides the following technical solutions:
[0006] A method for applying archival data based on a large model, the method comprising the following steps:
[0007] S1. Establishing several historical tags including people, time, place, building and event, and acquiring historical documents including several historical tags based on the big model to generate a first historical data set;
[0008] S2, extracting and vectorizing the first historical data set by word segmentation, calculating the similarity of any two word segmentations and arranging them by numerical value, selecting the first region with the largest F1 value from the similarity values, and unifying the two word segmentations corresponding to the same similarity value in the first region and the corresponding word segmentations in the first historical data set to obtain the second historical data set;
[0009] S3, classifying the word segments in the second historical data set into different historical labels;
[0010] S4, establishing document sets corresponding to the word segmentation sources in each of the first historical data sets according to the second historical data set, and associating each document set with a corresponding historical tag, and constructing an undirected graph with the document set as a node;
[0011] S5. Generate first interaction data according to the document set, history tags and word segments selected by the user, and obtain all word segments containing the first interaction data from the first data set to output the document set with the least number of word segments according to an undirected graph.
[0012] Preferably, in step S2, the following steps are specifically included:
[0013] S21, marking the part of speech of each word, and setting a number of word groups according to the part of speech, and classifying the word groups into training sets and test sets;
[0014] S22, use the pre-trained BERT model to train each word in the training set and the test set, and take the average pooling results of the last two layers to obtain the word vector of each word;
[0015] S23, calculating the similarity between any two participles according to the participle vectors of each participle;
[0016] S24, arranging the similarities in the training set according to the numerical values and selecting the first region with the largest F1 value;
[0017] S25, obtaining a similarity value range for the first region in the training set, and replacing two participles corresponding to the same similarity value in the test set within the similarity value range with any one of the participles.
[0018] Preferably, in step S24, the following steps are specifically included:
[0019] S241, setting a similarity threshold, an initial F1 value of 0, an initial number of iterations of 1, and arranging the similarities of the word segments according to the numerical values, and selecting a number of similarity values with adjacent numerical values as the first region;
[0020] S242, marking the similarity values outside the first area as a second area;
[0021] S243, setting a stepping interval, exchanging the similarity values of the second region with those of the first region to obtain the first region with the maximum F1 value, and making the similarity values in the first region always continuous;
[0022] S244, determining whether the first region after the first iteration is the same as the initial first region;
[0023] If yes, output a prompt that the first area is too large, and return to step S241;
[0024] If not, proceed to step S245;
[0025] S245, determining whether the first region after the current iteration is the same as the first region before the iteration;
[0026] If yes, then output a number of similarity values corresponding to the first region with the largest F1 value, and proceed to step S25;
[0027] If not, return to step S242.
[0028] Preferably, in step S25, the following steps are specifically included:
[0029] S251, obtaining a similarity value range of a first region in a training set and a similarity value in a test set that is within the similarity value range, and marking the similarity value as a first similarity value;
[0030] S252, obtaining all participles corresponding to the first similarity value, and marking the participle as the first participle;
[0031] S253, selecting any first participle in turn, selecting all first similarities containing the first participle, and marking the first similarity value as the second similarity value;
[0032] S254: Replace all the participles in the first historical data set corresponding to all the second similarity values with the corresponding first participles.
[0033] Preferably, in step S3, the following steps are specifically included:
[0034] S31, input the word segmentation vector in the second historical data set into the Transformer layer of the BERT model to obtain the self-attention matrix of the word segmentation vector;
[0035] S32. Use the self-attention mask model to mask the word segmentation vectors in the self-attention matrix to obtain a word segmentation vector mask matrix, and mark the masked words as the first mask words; the expression of the word segmentation vector mask matrix is:
[0036] ;
[0037] In the above formula, represents the word segmentation vector mask matrix, Indicates setting a mask on the word vector in the self-attention matrix through the self-attention masking mechanism;
[0038] S33, mapping the word segmentation vector mask matrix to a low-dimensional vector space to obtain a first vector; the expression of the first vector is:
[0039] ;
[0040] In the above formula, represents the first vector, for Word Embedding Model, Indicates that The word embedding model maps the word segmentation vector mask matrix to a low-dimensional vector space;
[0041] S34, obtain the part of speech of each word corresponding to the first vector, and input the first vector and the corresponding part of speech into the BERT model to obtain a second vector; the expression of the second vector is:
[0042] ;
[0043] In the above formula, represents the second vector, Represents data including the first vector and the part of speech of each word corresponding to the first vector;
[0044] S35. The BERT model is trained according to the second vector and the word segmentation vector in the second historical data set to obtain the most robust model parameters and the corresponding BERT model. The formula for training the BERT model is as follows:
[0045] ;
[0046] In the above formula, Represents the model parameters Optimize to minimize the loss function. Represents the samples in the input data set R Perform expected calculation, where x is the input data, i.e. the second vector, and y is the historical label corresponding to the input data. It means to find the largest disturbance in the disturbance space. The disturbance space is the set of corresponding word segments in the first region. This disturbance is to maximize the loss function. It means that after adding disturbance to the input data x, the model parameters The prediction loss of the model for the sample;
[0047] S36. Input the first vector into the trained BERT model and obtain the output vector of each layer of Transformer and the output vector of the last layer; the expression of the output vector of each layer of Transformer is:
[0048] ;
[0049] In the above formula, represents the output vector of the i-1th layer Transformer, Represents the Encoder structure of Transformer;
[0050] S37, classify each word into the corresponding historical label according to the output vector of the last layer of Transformer;
[0051] ;
[0052] In the above formula, represents the probability that the i-th word segment is each historical label, Represents the output vector of the last layer of Transformer, represents the weight, represents the bias, Indicates that The function performs the operation, Represents the output classification result, Indicates taking the maximum value, It indicates the probability that the label corresponding to the word segmentation is y given the input data set R.
[0053] Preferably, in step S4, the following steps are specifically included:
[0054] S41, establishing each document set, and setting each history tag under each document set;
[0055] S42, setting the segmented words in the first historical data set under the corresponding historical tags according to the second historical data set;
[0056] S43, taking document sets as nodes, and connecting any two document sets with edges to construct an undirected graph, wherein the nodes contain historical tags and word segments.
[0057] Preferably, in step S5, the following steps are specifically included:
[0058] S51, generating first interaction data according to the document set, history tags and word segmentations selected by the user, and obtaining all word segmentations containing the first interaction data from the first data set, and marking them as a second word segmentation set;
[0059] S52, set the maximum number of iterations T, importance factor , heuristic function importance factor , in each iteration, a number of snails are randomly generated at any node of the undirected graph and move along the edge of the undirected graph. When the snail moves, it leaves a total amount of mucus Q on each edge;
[0060] S53, counting the word segments of the nodes that the snail passes through during the movement, marking them as a third word segmentation set, and the number of nodes passed through, and when the third word segmentation set is equal to the second word segmentation set, the snail stops moving;
[0061] S54. When a snail moves, the probability of choosing the edge to move to is positively correlated with the total amount of mucus on each edge;
[0062] S55, after each iteration, updating the total amount of residual mucus on several paths where the snail passes through the least number of nodes;
[0063] S56, determining whether the maximum number of iterations has been reached;
[0064] If so, output the document set corresponding to each node on the path with the least number of nodes passed by the snail;
[0065] If not, return to step S54.
[0066] Preferably, in step S55, the following steps are specifically included:
[0067] S551, sorting the number of nodes on the path passed by each snail in ascending or descending order;
[0068] S552, select a number of paths with the least number of nodes of a certain number ratio from all the paths to update the total amount of residual mucus; the calculation formula of the number ratio is:
[0069] ;
[0070] In the above formula, The proportion of the pathways for updating the total amount of residual mucus, is the base, M is the total number of paths, R is the current number of iterations, is a constant;
[0071] S553: Update the total amount of residual mucus in the selected plurality of paths.
[0072] Preferably, in step S54, the probability of the snail moving to the next node at any node is:
[0073] ;
[0074] In the above formula, is the probability of the snail moving to node j after reaching node i, node m is all nodes adjacent to node i and not visited, is the total amount of residual mucus on the edge from node i to node j of the snail at the tth iteration, is the total amount of residual mucus on the edge of the snail from node i to node m at the tth iteration. The total amount of residual mucus is 0 in the initial state. is the importance factor, β is the importance factor of the heuristic function, is the set of nodes that the snail has not visited in t iterations.
[0075] Preferably, in step S553, the updated calculation formula for the total amount of residual mucus is:
[0076] ;
[0077] In the above formula, Indicated in The path at the iteration The total amount of residual mucus on is the percentage of mucus residue, , Indicated in The path at the iteration The total amount of residual mucus on For the Kth snail on the path The total amount of residual mucus left on the surface is Q. represents the number of snails generated at each iteration, Indicates that all snails on the path The total amount of residual mucus left on is the first cut-off factor, whose value is 1 or 0, Q is the total amount of mucus left on each edge when the snail moves, is the length of the path with the least number of nodes that the snail passes through, C is the second cut-off factor, and its value is 0 or 1. The shortest path at the iteration passes through the path When , it takes 1, otherwise it takes 0. For slime add ratio.
[0078] Compared with the prior art, the present invention provides an archival data application method based on a large model, which has the following beneficial effects:
[0079] 1. The present invention reduces the number of each participle through the first area, associates it with the document set and establishes an undirected graph of the document set. Based on the first interaction data selected by the user, all the participles related to the first interaction data are first screened out, and then the document set with the least number of all related participles is selected based on the undirected graph, thereby achieving the purpose of comprehensively selecting the least number of documents, thereby facilitating employees to select the required information, greatly reducing duplicate information, and reducing the workload of employees.
[0080] 2. The present invention can prevent abnormal similarity judgment caused by unreasonable setting of similarity threshold by selecting the first area with the largest F1 value. The appropriate similarity range can be automatically selected through the selection of the first area, so that the judgment of similar participles can be realized more accurately, and the merging of similar participles can be realized more accurately.
[0081] 3. The present invention realizes the classification of each participle by classifying each participle into different historical tags, so that when the user selects the participle later, he can first select the historical tag and then find the corresponding participle under the corresponding historical tag, thereby greatly reducing the difficulty of searching the participle.
[0082] 4. The present invention constructs an undirected graph based on a document set, and in the process of searching for a corresponding document set, updates the total amount of residual mucus on several paths through which the snail passes the least number of nodes. On the one hand, it can reduce the amount of calculation, and on the other hand, it can quickly eliminate document sets that do not meet the requirements, thereby improving the speed of finding the optimal solution. BRIEF DESCRIPTION OF THE DRAWINGS
[0083] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0084] Figure 1 The flowchart of the archival data application method based on the large model of the present invention. DETAILED DESCRIPTION
[0085] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific implementation methods, so that the implementation process of how the present application uses technical means to solve technical problems and achieve technical effects can be fully understood and implemented accordingly.
[0086] Those skilled in the art can understand that all or part of the steps in the following embodiments can be completed by instructing the relevant hardware through a program, so the present application can be in the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application can be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0087] In order to solve the problem that it is difficult to search all the required archival information comprehensively and concisely when searching archival information by inputting keywords, the present invention provides an archival data application method based on a large model, which can automatically generate segmentation words for users to choose from according to archival information, thereby eliminating the need for customers to manually input keywords, and can automatically filter out the minimum number of archives according to the user's selection, thereby ensuring the comprehensiveness of archival information and maximally reducing the amount of archival information to be read, thereby greatly improving the work efficiency of employees, such as Figure 1 As shown, the method comprises the following steps:
[0088] S1. Establish several historical tags including people, time, place, building and events, and obtain historical documents including several historical tags based on the big model to generate the first historical data set. The setting of historical tags is related to the company's business. For example, when it involves related businesses such as building introduction, person introduction and place introduction, historical tags for buildings, people and places will be set;
[0089] S2, extracting and vectorizing the first historical data set, calculating the similarity of any two segmented words and arranging them according to the numerical value, selecting the first region with the largest F1 value from the similarity values, and unifying the two segmented words corresponding to the same similarity value in the first region and the corresponding segmented words in the first historical data set to obtain the second historical data set; the traditional method of determining whether two segmented words are similar by setting a similarity threshold has extremely high requirements for setting the similarity threshold. In order to improve the accuracy of similarity determination, similar segmented words are selected by selecting the first region with the largest F1 value. In step S2, the following steps are specifically included:
[0090] S21. Mark the part of speech of each word, and set several word groups according to the part of speech, and classify the word groups into training sets and test sets. Two words with different parts of speech must be dissimilar. Therefore, this method can reduce the amount of data calculation for subsequent similarity judgment. For the recognition of part of speech, in practical applications, Python provides a variety of libraries and tools to support part-of-speech tagging and text analysis, such as the jieba library.
[0091] S22. Use the pre-trained BERT model to train each word in the training set and the test set, and take the average pooling results of the last two layers to obtain the word vector of each word; the expression of the word vector is as follows:
[0092] ;
[0093] In the above formula, represents the word segmentation vector, Indicates the word segmentation of the input through the BERT model Train to obtain word segmentation vectors. It is a special marker of the BERT model;
[0094] S23. Calculate the similarity between any two word segments according to the word segmentation vectors of each word segmentation; the similarity calculation formula is:
[0095] ;
[0096] In the above formula, represents the similarity between the i-th participle and the j-th participle, and Represent the word segmentation vectors of the i-th word and the j-th word respectively;
[0097] S24, arranging the similarities in the training set according to the numerical values and selecting the first region with the largest F1 value; in order to automatically select the first region with the largest F1 value from the training set, in step S24, the following steps are specifically included:
[0098] S241, setting a similarity threshold, an initial F1 value of 0, an initial number of iterations of 1, and arranging the similarities of the word segments according to the numerical values, and selecting a number of similarity values with adjacent numerical values as the first region;
[0099] S242, marking the similarity values outside the first area as a second area;
[0100] S243, setting a stepping interval, exchanging the similarity values of the second region with those of the first region to obtain the first region when the F1 value is the largest, and making the similarity values in the first region always continuous; in order to further describe the method of exchanging the similarity values of the second region with those of the first region, in step S243, the following steps are specifically included:
[0101] S2431, setting the stepping interval;
[0102] S2432, adding a number of similarity values in the second region that are adjacent to the maximum value in the first region to the first region to form a third region;
[0103] S2433, adding a number of similarity values in the second region that are adjacent to the minimum value in the first region to the first region to form a fourth region;
[0104] S2434, merging the third region and the fourth region to generate a fifth region;
[0105] S2435, respectively calculate the F1 values of the third region, the fourth region, and the fifth region, and output a number of similarity values corresponding to the region with the largest F1 value, and mark the region as the first region; the calculation formula of the F1 value is:
[0106] ;
[0107] In the above formula, F1 represents the F1 value, and Represent the precision and recall of the model respectively;
[0108] S244, determining whether the first region after the first iteration is the same as the initial first region;
[0109] If yes, output a prompt that the first area is too large, and return to step S241;
[0110] If not, proceed to step S245;
[0111] S245, determining whether the first region after the current iteration is the same as the first region before the iteration;
[0112] If yes, then output a number of similarity values corresponding to the first region with the largest F1 value, and proceed to step S25;
[0113] If not, return to step S242;
[0114] S25, obtaining the similarity value range of the first region in the training set, and replacing the two segmentations corresponding to the same similarity value in the test set within the similarity value range with any one of the segmentations; for a large number of segmentations, there are a large number of words with the same meaning, which easily leads to a large number of segmentations. By merging and reducing synonymous segmentations, the difficulty of subsequent user selection of segmentations and the amount of subsequent calculation based on segmentations and segmentation vectors can be greatly reduced. In step S25, the following steps are specifically included:
[0115] S251, obtaining a similarity value range of a first region in a training set and a similarity value in a test set that is within the similarity value range, and marking the similarity value as a first similarity value;
[0116] S252, obtaining all participles corresponding to the first similarity value, and marking the participle as the first participle;
[0117] S253, selecting any first participle in turn, selecting all first similarities containing the first participle, and marking the first similarity value as the second similarity value;
[0118] S254: Replace all the participles in the first historical data set corresponding to all the second similarity values with the corresponding first participles.
[0119] S3, classifying the segmented words in the second historical data set into different historical tags; for different historical tags set, the extracted segmented words need to be automatically classified into different historical tags, so that when the subsequent user selects the segmented words, they can be searched from the corresponding historical tags, reducing the difficulty of finding the segmented words. In the classification process, in order to solve the interference of irrelevant information such as typos that may exist in the segmented words, step S3 specifically includes the following steps:
[0120] S31, input the word segmentation vector in the second historical data set into the Transformer layer of the BERT model to obtain the self-attention matrix of the word segmentation vector;
[0121] S32. Use the self-attention mask model to mask the word segmentation vectors in the self-attention matrix to obtain a word segmentation vector mask matrix, and mark the masked words as the first mask words; the expression of the word segmentation vector mask matrix is:
[0122] ;
[0123] In the above formula, represents the word segmentation vector mask matrix, Indicates setting a mask on the word vector in the self-attention matrix through the self-attention masking mechanism;
[0124] S33, mapping the word segmentation vector mask matrix to a low-dimensional vector space to obtain a first vector; the expression of the first vector is:
[0125] ;
[0126] In the above formula, represents the first vector, for Word Embedding Model, Indicates that The word embedding model maps the word segmentation vector mask matrix to a low-dimensional vector space;
[0127] S34, obtain the part of speech of each word corresponding to the first vector, and input the first vector and the corresponding part of speech into the BERT model to obtain a second vector; the expression of the second vector is:
[0128] ;
[0129] In the above formula, represents the second vector, Represents data including the first vector and the part of speech of each word corresponding to the first vector;
[0130] S35. The BERT model is trained according to the second vector and the word segmentation vector in the second historical data set to obtain the most robust model parameters and the corresponding BERT model. The formula for training the BERT model is as follows:
[0131] ;
[0132] In the above formula, Represents the model parameters Optimize to minimize the loss function. Represents the samples in the input data set R Perform expected calculation, where x is the input data, i.e. the second vector, and y is the historical label corresponding to the input data. It means to find the largest disturbance in the disturbance space. The disturbance space is the set of corresponding word segments in the first region. This disturbance is to maximize the loss function. It means that after adding disturbance to the input data x, the model parameters The prediction loss of the model for the sample;
[0133] S36. Input the first vector into the trained BERT model and obtain the output vector of each layer of Transformer and the output vector of the last layer; the expression of the output vector of each layer of Transformer is:
[0134] ;
[0135] In the above formula, represents the output vector of the i-1th layer Transformer, Represents the Encoder structure of Transformer;
[0136] S37, classify each word into the corresponding historical label according to the output vector of the last layer of Transformer;
[0137] ;
[0138] In the above formula, represents the probability that the i-th word segment is each historical label, Represents the output vector of the last layer of Transformer, represents the weight, represents the bias, Indicates that The function performs the operation, Represents the output classification result, Indicates taking the maximum value, It indicates the probability that the label corresponding to the word segmentation is y given the input data set R.
[0139] S4, establishing document sets corresponding to the sources of the word segments in the first historical data set according to the second historical data set, and associating each document set with the corresponding historical tag, and constructing an undirected graph with the document set as a node; that is, one-to-one correspondence is made between each word segment in the first historical data set and the document in the historical archive. In step S4, the following steps are specifically included:
[0140] S41, establishing each document set, and setting each history tag under each document set;
[0141] S42, according to the second historical data set, the segmented words in the first historical data set are set under the corresponding historical tags; the second historical data set and the historical tags are in one-to-one correspondence, and some synonymous segmented words in the first historical data set are unified to form the second historical data set, so the segmented words in the first historical data set and the historical tags are in one-to-one correspondence with each other using the second data set as a medium;
[0142] S43, taking document sets as nodes, and connecting any two document sets with edges to construct an undirected graph, wherein the nodes contain historical tags and word segments.
[0143] S5. Generate first interactive data according to the document set, historical tags and word segmentation selected by the user, and obtain all word segmentations containing the first interactive data from the first data set, so as to output a document set containing all word segmentations and the least number according to an undirected graph. For example, if the user selects a certain document set and a word segmentation for a location, all word segmentations related to the location will be obtained from the first data set. The method of obtaining can be based on big data or knowledge graphs. In practice, the connection between word segmentations is obtained based on the knowledge graph. The construction of the knowledge graph is an existing technology and will not be repeated here. After obtaining all word segmentations related to the location, a number of document sets with the least number will be further selected based on the document set selected by the user. The selected document set will contain all word segmentations related to the location word segmentation, thereby reducing the user's reading volume, and the data information contained is also relatively comprehensive. In step S5, the following steps are specifically included:
[0144] S51, generating first interaction data according to the document set, history tags and word segmentations selected by the user, and obtaining all word segmentations containing the first interaction data from the first data set, and marking them as a second word segmentation set;
[0145] S52, set the maximum number of iterations T, importance factor , heuristic function importance factor , each iteration randomly generates a number of snails moving along the edge of the undirected graph at any node of the undirected graph. When the snail moves, it leaves a total amount of mucus Q on each edge; the white mucus left by the snail when it moves is a kind of mucus secreted by the foot gland. The main function of this mucus is to help the snail crawl. The snail secretes this mucus to reduce the direct friction between the ventral foot and the ground, thereby protecting the ventral foot from damage. At the same time, the slippery nature of the mucus helps the snail move on various surfaces, including rough or sharp surfaces. In addition, this mucus can also form a trace where the snail crawls. This trace will become shiny after drying and is easy to observe. The components of the mucus include snails, proteins, a small amount of calcium carbonate, mucopolysaccharides, etc. These components make the mucus have a certain viscosity and protective effect. When the mucus comes into contact with the air, it will become more viscous and dry, forming a thin film. This film not only helps the snail move, but also plays a role in marking the path to a certain extent, so that the snail is more inclined to the path with more mucus during the movement.
[0146] S53, counting the word segments of the nodes that the snail passes through during the movement, marking them as a third word segmentation set, and the number of nodes passed through, and when the third word segmentation set is equal to the second word segmentation set, the snail stops moving;
[0147] S54. When a snail moves, the probability of choosing an edge to move to is positively correlated with the total amount of mucus on each edge; then the probability of a snail moving to the next node at any node is:
[0148] ;
[0149] In the above formula, is the probability of the snail moving to node j after reaching node i, node m is all nodes adjacent to node i and not visited, is the total amount of residual mucus on the edge from node i to node j of the snail at the tth iteration, is the total amount of residual mucus on the edge of the snail from node i to node m at the tth iteration. The total amount of residual mucus is 0 in the initial state. is the importance factor, β is the importance factor of the heuristic function, is the set of nodes that the snail has not visited in t iterations;
[0150] S55, after each iteration, updating the total amount of residual mucus on several paths where the snail passes through the least number of nodes;
[0151] Since there may be a large number of snails, if the total amount of residual mucus on the path passed by each snail is calculated, the amount of calculation is relatively large. In addition, only calculating the paths with the least number of nodes passed by the snail can also quickly eliminate some paths with more nodes, so as to speed up the search. In step S55, the following steps are specifically included:
[0152] S551, sorting the number of nodes on the path passed by each snail in ascending or descending order;
[0153] S552, select a number of paths with the least number of nodes of a certain number ratio from all the paths to update the residual mucus content; the calculation formula of the number ratio is:
[0154] ;
[0155] In the above formula, For the path ratio of the residual mucus content update, is the base, M is the total number of paths, R is the current number of iterations, is a constant;
[0156] S553, the total amount of residual mucus of the selected several paths is updated, and the calculation formula of the updated total amount of residual mucus is:
[0157] ;
[0158] In the above formula, Indicated in The path at the iteration The total amount of residual mucus on is the percentage of mucus residue, , Indicated in The path at the iteration The total amount of residual mucus on For the Kth snail on the path The total amount of residual mucus left on the surface is Q. represents the number of snails generated at each iteration, Indicates that all snails on the path The total amount of residual mucus left on is the first cut-off factor, whose value is 1 or 0, Q is the total amount of mucus left on each edge when the snail moves, is the length of the path with the least number of nodes that the snail passes through, C is the second cut-off factor, and its value is 0 or 1. The shortest path at the iteration passes through the path When , it takes 1, otherwise it takes 0. For slime add ratio.
[0159] S56, determining whether the maximum number of iterations has been reached;
[0160] If so, output the document set corresponding to each node on the path with the least number of nodes passed by the snail;
[0161] If not, return to step S54.
[0162] The present invention performs word segmentation extraction and vectorization on the first historical data set, selects the area with the largest F1 value after calculating the similarity value, and merges the word segments within the F1 value to greatly reduce the number of each word segmentation, and further classifies each word segmentation into different historical labels, so as to further facilitate users to select word segmentations, and associate each word segmentation with a document set, and establishes an undirected graph of each document set, and then selects the document set based on the undirected graph according to the first interactive data generated by the user's selection, and selects the least number of document sets and all word segments related to the first interactive data, so as to achieve the purpose of comprehensive extraction of relevant information and the least number of extracted documents, which can greatly improve the work efficiency of employees.
[0163] The above implementation methods have been described in detail. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A method for applying archival data based on a large model, characterized in that: The method comprises the following steps: S1. Establishing several historical tags including people, time, place, building and event, and acquiring historical documents including several historical tags based on the big model to generate a first historical data set; S2, extracting and vectorizing the first historical data set by word segmentation, calculating the similarity of any two word segmentations and arranging them by numerical value, selecting the first region with the largest F1 value from the similarity values, and unifying the two word segmentations corresponding to the same similarity value in the first region and the corresponding word segmentations in the first historical data set to obtain the second historical data set; In step S2, the following steps are specifically included: S21, marking the part of speech of each word, and setting a number of word groups according to the part of speech, and classifying the word groups into training sets and test sets; S22, use the pre-trained BERT model to train each word in the training set and the test set, and take the average pooling results of the last two layers to obtain the word vector of each word; S23, calculating the similarity between any two participles according to the participle vectors of each participle; S24, arranging the similarities in the training set according to the numerical values and selecting the first region with the largest F1 value; the calculation formula of the F1 value is: ; In the above formula, F1 represents the F1 value, and Represent the precision and recall of the model respectively; S25, obtaining a similarity value range of the first region in the training set, and replacing two participles corresponding to the same similarity value in the test set within the similarity value range with any one of the participles; S3, classifying the word segments in the second historical data set into different historical labels; S4, establishing document sets corresponding to the word segmentation sources in each of the first historical data sets according to the second historical data set, and associating each document set with a corresponding historical tag, and constructing an undirected graph with the document set as a node; S5, generating first interaction data according to the document set, historical tags and word segmentations selected by the user, and obtaining all word segmentations containing the first interaction data from the first data set, so as to output a document set containing the least number of all word segmentations according to an undirected graph; In step S5, the following steps are specifically included: S51, generating first interaction data according to the document set, history tags and word segmentations selected by the user, and obtaining all word segmentations containing the first interaction data from the first data set, and marking them as a second word segmentation set; S52, set the maximum number of iterations T, importance factor , heuristic function importance factor , in each iteration, a number of snails are randomly generated at any node of the undirected graph and move along the edge of the undirected graph. When the snail moves, it leaves a total amount of mucus Q on each path; S53, counting the word segments of the nodes that the snail passes through during the movement, marking them as a third word segmentation set, and the number of nodes passed through, and when the third word segmentation set is equal to the second word segmentation set, the snail stops moving; S54. When a snail moves, the probability of choosing the edge to move to is positively correlated with the total amount of mucus on each edge; S55, after each iteration, updating the total amount of residual mucus on several paths where the snail passes through the least number of nodes; S56, determining whether the maximum number of iterations has been reached; If so, output the document set corresponding to each node on the path with the least number of nodes passed by the snail; If not, return to step S54; In step S55, the following steps are specifically included: S551, sorting the number of nodes on the path passed by each snail in ascending or descending order; S552, select a number of paths with the least number of nodes of a certain number ratio from all the paths to update the residual mucus content; the calculation formula of the number ratio is: ; In the above formula, For the path ratio of the residual mucus content update, is the base, M is the total number of paths, R is the current number of iterations, is a constant; S553, updating the total amount of residual mucus of the selected plurality of paths; In step S54, the probability of the snail moving to the next node at any node is: ; In the above formula, is the probability of the snail moving to node j after reaching node i, node m is all nodes adjacent to node i and not visited, is the total amount of residual mucus on the edge from node i to node j of the snail at the tth iteration, is the total amount of residual mucus on the edge of the snail from node i to node m at the tth iteration. The total amount of residual mucus is 0 in the initial state. is the importance factor, β is the importance factor of the heuristic function, is the set of nodes that the snail has not visited in t iterations; In step S553, the updated calculation formula for the total amount of residual mucus is: ; In the above formula, Indicated in The path at the iteration The total amount of residual mucus on is the percentage of mucus residue, , Indicated in The path at the iteration The total amount of residual mucus on For the Kth snail on the path The total amount of residual mucus left on the surface is Q. represents the number of snails generated at each iteration, Indicates that all snails on the path The total amount of residual mucus left on is the first cut-off factor, whose value is 1 or 0, Q is the total amount of mucus left on each edge when the snail moves, is the length of the path with the least number of nodes that the snail passes through, C is the second cut-off factor, and its value is 0 or 1. The shortest path at the iteration passes through the path When , it takes 1, otherwise it takes 0. For slime add ratio.
2. The archival data application method according to claim 1, characterized in that: In step S24, the following steps are specifically included: S241, setting a similarity threshold, an initial F1 value of 0, an initial number of iterations of 1, and arranging the similarities of the word segments according to the numerical values, and selecting a number of similarity values with adjacent numerical values as the first region; S242, marking the similarity values outside the first area as a second area; S243, setting a stepping interval, exchanging the similarity values of the second region with those of the first region to obtain the first region with the maximum F1 value, and making the similarity values in the first region always continuous; In step S243, the following steps are specifically included: S2431, setting the stepping interval; S2432, adding a number of similarity values in the second region that are adjacent to the maximum value in the first region to the first region to form a third region; S2433, adding a number of similarity values in the second region that are adjacent to the minimum value in the first region to the first region to form a fourth region; S2434, merging the third region and the fourth region to generate a fifth region; S2435, respectively calculate the F1 values of the third region, the fourth region, and the fifth region, and output a number of similarity values corresponding to the region with the largest F1 value, and mark the region as the first region; the calculation formula of the F1 value is: ; In the above formula, F1 represents the F1 value, and Represent the precision and recall of the model respectively; S244, determining whether the first region after the first iteration is the same as the initial first region; If yes, output a prompt that the first area is too large, and return to step S241; If not, proceed to step S245; S245, determining whether the first region after the current iteration is the same as the first region before the iteration; If yes, then output a number of similarity values corresponding to the first region with the largest F1 value, and proceed to step S25; If not, return to step S242.
3. The archival data application method according to claim 1, characterized in that: In step S25, the following steps are specifically included: S251, obtaining a similarity value range of a first region in a training set and a similarity value in a test set that is within the similarity value range, and marking the similarity value as a first similarity value; S252, obtaining all participles corresponding to the first similarity value, and marking the participle as the first participle; S253, selecting any first participle in turn, selecting all first similarities containing the first participle, and marking the first similarity value as the second similarity value; S254: Replace all the participles in the first historical data set corresponding to all the second similarity values with the corresponding first participles.
4. The archival data application method according to claim 1, characterized in that: In step S3, the following steps are specifically included: S31, input the word segmentation vector in the second historical data set into the Transformer layer of the BERT model to obtain the self-attention matrix of the word segmentation vector; S32, using the self-attention mask model to mask the word segmentation vectors in the self-attention matrix to obtain a word segmentation vector mask matrix, and marking the masked words as the first masked words; The expression of the word segmentation vector mask matrix is: ; In the above formula, represents the word segmentation vector mask matrix, Indicates setting a mask on the word vector in the self-attention matrix through the self-attention masking mechanism; S33, mapping the word segmentation vector mask matrix to a low-dimensional vector space to obtain a first vector; the expression of the first vector is: ; In the above formula, represents the first vector, for Word Embedding Model, Indicates that The word embedding model maps the word segmentation vector mask matrix to a low-dimensional vector space; S34, obtain the part of speech of each word corresponding to the first vector, and input the first vector and the corresponding part of speech into the BERT model to obtain a second vector; the expression of the second vector is: ; In the above formula, represents the second vector, Represents data including the first vector and the part of speech of each word corresponding to the first vector; S35. The BERT model is trained according to the second vector and the word segmentation vector in the second historical data set to obtain the most robust model parameters and the corresponding BERT model. The formula for training the BERT model is as follows: ; In the above formula, Represents the model parameters Optimize to minimize the loss function. Represents the samples in the input data set R Perform expected calculation, where x is the input data, i.e. the second vector, and y is the historical label corresponding to the input data. It means to find the largest disturbance in the disturbance space. The disturbance space is the set of corresponding word segments in the first region. This disturbance is to maximize the loss function. It means that after adding disturbance to the input data x, the model parameters The prediction loss of the model for the sample; S36. Input the first vector into the trained BERT model and obtain the output vector of each layer of Transformer and the output vector of the last layer; the expression of the output vector of each layer of Transformer is: ; In the above formula, represents the output vector of the i-1th layer Transformer, Represents the Encoder structure of Transformer; S37, classify each word into the corresponding historical label according to the output vector of the last layer of Transformer; ; In the above formula, represents the probability that the i-th word segment is each historical label, Represents the output vector of the last layer of Transformer, represents the weight, Indicates bias, Indicates that The function performs the operation, Represents the output classification result, Indicates taking the maximum value, It indicates the probability that the label corresponding to the word segmentation is y given the input data set R.
5. The archival data application method according to claim 1, characterized in that: In step S4, the following steps are specifically included: S41, establishing each document set, and setting each history tag under each document set; S42, setting the segmented words in the first historical data set under the corresponding historical tags according to the second historical data set; S43, taking document sets as nodes, and connecting any two document sets with edges to construct an undirected graph, wherein the nodes contain historical tags and word segments.
Citation Information
Patent Citations
OD flow direction clustering method based on multi-path image cutting criterion and ant colony optimization
CN113516309A
Document retrieval method based on knowledge graph and related equipment thereof
CN114780746A