Data classification method and device, electronic equipment and computer readable medium
By using word vector model and category base table matrix calculation in the logistics mini program, the problem of low efficiency and accuracy of matching items in the waybill entrusted items is solved, and efficient and accurate waybill matching and category determination are achieved.
Patent Information
- Application Number
- CN202411230442.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-03
- Publication Date
- 2025-01-03
AI Technical Summary
The matching functions of existing search engines used in the logistics mini program for waybill mailing items are low, resulting in the inability to determine the waybill mailing items, affecting the effectiveness of waybill mailing items.
By obtaining the text data to be classified, the word elements are obtained, and the intermediate word list is called according to the word element length to match. If the match fails, the word element vector model is used to convert the word elements into vectors, and the category base table matrix is similar to the priority calculation. , determine the target category, and use intermediate vocabulary list and high-performance vector matrix calculation to achieve efficient matching.
It improves the determination efficiency and accuracy of the category of mailing items by waybills, realizes high reliability of online high-performance computing and inference results, and improves the accuracy and efficiency of category matching.
Smart Images

Figure CN119248928A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a data classification method, device, electronic device and computer-readable medium. Background Art
[0002] At present, based on real-time and efficient search engines, data classification matching results can be returned through word segmentation and text similarity calculation. At present, the mini program has realized similar prefix matching and character full matching functions through the search engine. However, relatively fuzzy matching functions cannot be realized. From the function of the search engine itself, in addition to changing the category base table, the search matching function cannot be upgraded and iterated. At present, the logistics mini program has a daily traffic of about 600,000 to 700,000 orders. Only about half of the waybills can be queried through the search engine to the corresponding consignment category, and for the remaining half of the waybills, the consignment category cannot be classified. Therefore, the problem derived is that it is impossible to determine what the consignment of this waybill is, and the efficiency and accuracy of determining the category are low. Summary of the invention
[0003] In view of this, the embodiments of the present application provide a data classification method, device, electronic device and computer-readable medium, which can solve the existing problems of low efficiency and accuracy in determining categories.
[0004] To achieve the above objective, according to one aspect of an embodiment of the present application, a data classification method is provided, comprising:
[0005] Obtaining text data to be classified, and obtaining corresponding word units based on text data processing;
[0006] Determine the text length of the word unit, and call the corresponding intermediate word table according to the text length to perform the category data matching process;
[0007] In response to a match failure, calling a word-element vector model to convert a word-element into a word-element vector, and determining similarity data of each category corresponding to the category-element vector matrix based on the word-element vector, the category-element vector matrix, and a preset word-element priority;
[0008] Based on the similarity data, determine the target category corresponding to the text data.
[0009] Optionally, based on the word element vector, the category base table vector matrix and the preset word element priority, determining the similarity data of each category corresponding to the category base table vector matrix includes:
[0010] In response to the word-unit type being a long text, the word-unit is segmented to obtain individual segmented word-units, and the individual segmented word-units are converted into individual segmented word-unit vectors;
[0011] Determine the preset word unit priority corresponding to each word segmentation word unit, and calculate the similarity data between each word segmentation word unit vector and each category vector in the category base table vector matrix according to the word unit priority.
[0012] Optionally, determine the text length of the token, including:
[0013] Get the number of tokens;
[0014] Determine the amount as the length of the text in terms of tokens.
[0015] Optionally, before calling the corresponding intermediate vocabulary, the method further includes:
[0016] In response to the text length being less than a preset threshold, determining that the corresponding intermediate vocabulary is a short text category hash table;
[0017] In response to the text length being greater than a preset threshold, the corresponding intermediate vocabulary is determined to be a long text category mapping table.
[0018] Optionally, determining a preset word unit priority corresponding to each word segmentation word unit includes:
[0019] Determine the word unit priority of the word unit belonging to the word in each word unit as the first priority;
[0020] Determine the word unit priority of the word unit belonging to the character in each word unit as the second priority;
[0021] The first priority is higher than the second priority.
[0022] Optionally, the similarity data between each word segmentation word element vector and each category vector in the category base table vector matrix is calculated according to the word element priority, including:
[0023] Calculate each first similarity data between the segmentation word element corresponding to the first priority and each category vector in the category base table vector matrix. In response to each first similarity data being lower than a preset similarity threshold, calculate each second similarity data between the segmentation word element corresponding to the second priority and each category vector in the category base table vector matrix to determine each second similarity data as the similarity data between each segmentation word element vector and each category vector in the category base table vector matrix.
[0024] Optionally, determining a target category corresponding to the text data based on the similarity data includes:
[0025] The category corresponding to the category vector corresponding to the second similarity greater than the preset similarity threshold is determined as the target category corresponding to the text data.
[0026] Optionally, the method further comprises:
[0027] Regularly count the high-frequency text data in the non-intermediate word list that appears frequently online, input the high-frequency text data into the classification model, and output the category inference results corresponding to the high-frequency text data;
[0028] Send category reasoning results and high-frequency text data to offline nodes for review, and receive the review results;
[0029] Update the online intermediate vocabulary based on the review results.
[0030] In addition, the present application also provides a data classification device, including:
[0031] An acquisition unit is configured to acquire text data to be classified and obtain corresponding word units based on the text data processing;
[0032] A matching unit is configured to determine the text length of the word unit, and according to the text length, call the corresponding intermediate word table to perform the category data matching process;
[0033] A similarity data determination unit is configured to, in response to a matching failure, call a word-element vector model to convert a word-element into a word-element vector, and then determine similarity data of each category corresponding to the category-element vector matrix based on the word-element vector, the category-element vector matrix, and a preset word-element priority;
[0034] The target category determination unit is configured to determine the target category corresponding to the text data according to the similarity data.
[0035] Optionally, the similarity data determining unit is further configured to:
[0036] In response to the word-unit type being a long text, the word-unit is segmented to obtain individual segmented word-units, and the individual segmented word-units are converted into individual segmented word-unit vectors;
[0037] Determine the preset word unit priority corresponding to each word unit, and calculate the similarity between each word unit vector and each category vector in the category base table vector matrix according to the word unit priority;
[0038] Based on the similarity, determine the category corresponding to the text data.
[0039] Optionally, the matching unit is further configured to:
[0040] Get the number of tokens;
[0041] Determine the amount as the length of the text in terms of tokens.
[0042] Optionally, the matching unit is further configured to:
[0043] In response to the text length being less than a preset threshold, determining that the corresponding intermediate vocabulary is a short text category hash table;
[0044] In response to the text length being greater than a preset threshold, the corresponding intermediate vocabulary is determined to be a long text category mapping table.
[0045] Optionally, the similarity data determining unit is further configured to:
[0046] Determine the word unit priority of the word unit belonging to the word in each word unit as the first priority;
[0047] Determine the word unit priority of the word unit belonging to the character in each word unit as the second priority;
[0048] The first priority is higher than the second priority.
[0049] Optionally, the similarity data determining unit is further configured to:
[0050] Calculate each first similarity data between the segmentation word element corresponding to the first priority and each category vector in the category base table vector matrix. In response to each first similarity data being lower than a preset similarity threshold, calculate each second similarity data between the segmentation word element corresponding to the second priority and each category vector in the category base table vector matrix, so as to determine each second similarity data as the similarity data between each segmentation word element vector and each category vector in the category base table vector matrix.
[0051] Optionally, the target category determination unit is further configured to:
[0052] The category corresponding to the category vector corresponding to the second similarity greater than the preset similarity threshold is determined as the target category corresponding to the text data.
[0053] Optionally, the data classification device further includes an intermediate vocabulary updating unit configured to:
[0054] Regularly count the high-frequency text data in the non-intermediate word list that appears frequently online, input the high-frequency text data into the classification model, and output the category inference results corresponding to the high-frequency text data;
[0055] Send category reasoning results and high-frequency text data to offline nodes for review, and receive the review results;
[0056] Update the online intermediate vocabulary based on the review results.
[0057] In addition, the present application also provides a data classification electronic device, including: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by one or more processors, the one or more processors implement the data classification method as described above.
[0058] In addition, the present application also provides a computer-readable medium on which a computer program is stored, and when the program is executed by a processor, the data classification method as described above is implemented.
[0059] To achieve the above objective, according to another aspect of the embodiments of the present application, a computer program product is provided.
[0060] A computer program product according to an embodiment of the present application includes a computer program, and when the program is executed by a processor, the data classification method provided by the embodiment of the present application is implemented.
[0061] One embodiment of the above invention has the following advantages or beneficial effects: the present application obtains the text data to be classified, obtains the corresponding word element based on the text data processing; determines the text length of the word element, and calls the corresponding intermediate word table according to the text length to execute the category data matching process; in response to the matching failure, calls the word element vector model to convert the word element into a word element vector, and then determines the similarity data of each category corresponding to the category base table vector matrix based on the word element vector, the category base table vector matrix and the preset word element priority; determines the target category corresponding to the text data according to the similarity data. Intermediate word table matching and high-performance category base table vector matrix calculation are applied to the text to be classified, achieving high-performance online computing and high reliability of reasoning results, and improving the efficiency and accuracy of category determination.
[0062] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] The accompanying drawings are used to better understand the present application and do not constitute an improper limitation on the present application.
[0064] Figure 1 It is a schematic diagram of the main process of the data classification method provided according to an embodiment of the present application;
[0065] Figure 2 It is a schematic diagram of the main process of the data classification method provided according to an embodiment of the present application;
[0066] Figure 3 It is a schematic diagram of an online process of a category matching service of a data classification method provided according to an embodiment of the present application;
[0067] Figure 4 is a schematic diagram of a neural network constructed according to a data classification method provided in one embodiment of the present application;
[0068] Figure 5 is a schematic diagram of main units of a data classification device according to an embodiment of the present application;
[0069] Figure 6 is an exemplary system architecture diagram to which the embodiments of the present application can be applied;
[0070] Figure 7 It is a structural diagram of a computer system of a terminal device or server suitable for implementing an embodiment of the present application. DETAILED DESCRIPTION
[0071] The following is an explanation of the exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description. It should be noted that in the technical solution of the present disclosure, the collection, collection, update, analysis, processing, use, transmission, storage and other aspects of user personal information involved are in compliance with the provisions of relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. Take necessary measures for user personal information to prevent illegal access to user personal information data and maintain user personal information security, network security and national security.
[0072] Figure 1 is a schematic diagram of the main process of the data classification method provided according to an embodiment of the present application, such as Figure 1 As shown, the data classification methods include:
[0073] Step S101, obtaining text data to be classified, and obtaining corresponding word units based on the text data processing.
[0074] In response to a data classification request, text data to be classified is obtained, and corresponding word units are obtained based on preprocessing of the obtained text data. The text data to be classified can be obtained by converting numbers, dates, images, audio and video, etc.
[0075] In this embodiment, the execution subject of the data classification method (for example, a server) can receive a data classification request through a wired connection or a wireless connection. Specifically, the data classification request can be a request to classify the consignment data to determine the category to which the consignment belongs. After receiving the data classification request, the execution subject can obtain the text data corresponding to the request, such as the consignment attribute text data. The obtained text data is preprocessed, for example, regular disambiguation and text segmentation can be performed to filter out interference words in the text data and then process them to obtain corresponding word units.
[0076] Step S102, determining the text length of the word unit, and calling the corresponding intermediate word table according to the text length to execute the category data matching process.
[0077] Specifically, determining the text length of a word unit includes: obtaining the number of word units; and determining the number as the text length of the word unit.
[0078] The execution subject can determine the number of word units obtained after processing the text data as the text length of the word unit, so as to accurately execute the subsequent corresponding data classification strategy according to the text length.
[0079] Specifically, before calling the corresponding intermediate vocabulary, the data classification method also includes: in response to the text length being less than a preset threshold, determining the corresponding intermediate vocabulary as a short text category hash table; in response to the text length being greater than a preset threshold, determining the corresponding intermediate vocabulary as a long text category mapping table.
[0080] The preset threshold can be set to 10. The embodiment of the present application does not specifically limit the preset threshold. That is, when the number of intermediate word lists (text length) is less than 10, it can be determined that the type of word element obtained by text data processing is short text, and the corresponding intermediate word list can be determined to be a short text category hash table. For example, the short text category hash table may include data from the base table, a database of third-level categories, words with high instance frequency, etc. The embodiment of the present application does not specifically limit the data in the short text category hash table.
[0081] When the number of intermediate word lists (text length) is greater than 10, it can be determined that the type of word units obtained by text data processing is long text, and the corresponding intermediate word list can be determined to be a long text category hash table. For example, the long text category hash table can include enough historical user input texts and corresponding categories.
[0082] The corresponding word element obtained based on text data processing is mapped and matched with the corresponding intermediate word table called. If the match is successful, the corresponding category is output. If the match fails, subsequent re-matching operations are performed according to the type of word element.
[0083] Step S103, in response to a matching failure, calling the word-unit vector model to convert the word-unit into a word-unit vector, and then determining the similarity data of each category corresponding to the category-unit vector matrix based on the word-unit vector, the category-unit vector matrix and a preset word-unit priority.
[0084] After the word unit obtained by processing the text data fails to match the corresponding intermediate word list, if the type of the word unit is long text, the execution body can re-segment the word unit. For example, the word unit (Xiao A mobile phone) is segmented again to obtain segmented word units (Xiao A) and (mobile phone), so as to perform further similarity matching based on the segmented word unit and each category vector in the category base table vector matrix in the improved word unit vector model.
[0085] Specifically, the execution subject can call the word unit vector model to convert each word unit into a corresponding word unit vector based on word embedding. Based on the order of the preset word unit priority corresponding to each word unit, the similarity data of each word unit vector and each category vector in the category base table vector matrix are calculated in sequence.
[0086] The embodiment of the present application sets the priority of words in the word segmentation word unit to be higher than the priority of characters, so that words containing more contextual information and semantic information can be preferentially calculated with each category in the category base table vector matrix to improve the accuracy of data classification.
[0087] When each first similarity data between each word in the word segmentation word unit and each category vector in the category base table vector matrix is lower than the preset similarity threshold, that is, no matching category vector is obtained when the words in the word segmentation word unit are matched with each category vector by similarity, at this time, the characters in the word segmentation word unit are further matched with each category vector by similarity to obtain each second similarity data. Then, the size of each second similarity data and the preset similarity threshold can be continuously compared to accurately obtain the matching category vector.
[0088] Step S104: determining the target category corresponding to the text data according to the similarity data.
[0089] Specifically, determining the target category corresponding to the text data includes: sorting the obtained similarity data in descending order, and determining the category corresponding to the category vector corresponding to the first preset number of similarity data as the target category corresponding to the text data, thereby improving the accuracy of determining the target category.
[0090] This embodiment obtains the text data to be classified, obtains the corresponding word based on the text data processing; determines the text length of the word, and calls the corresponding intermediate word table according to the text length to execute the category data matching process; in response to the matching failure, calls the word element vector model to convert the word element into a word element vector, and then determines the similarity data of each category corresponding to the category base table vector matrix based on the word element vector, the category base table vector matrix and the preset word element priority; and determines the target category corresponding to the text data according to the similarity data. Intermediate word table matching and high-performance category base table vector matrix calculation are applied to the text to be classified, achieving high-performance online computing and high reliability of reasoning results, and improving the efficiency and accuracy of category determination.
[0091] Figure 2 is a schematic diagram of the main flow of a data classification method provided according to an embodiment of the present application, such as Figure 2 As shown, the data classification methods include:
[0092] Step S201, obtaining text data to be classified, and obtaining corresponding word units based on the text data processing.
[0093] In response to a data classification request, the text data to be classified is obtained, and corresponding word units are obtained based on the text data processing. The text data to be classified can be obtained by converting numbers, dates, images, audio and video, etc.
[0094] After receiving the data classification request, the execution subject can segment the text data according to the acquired text data and the preset segmentation dimension to obtain word units corresponding to the preset segmentation dimension. The preset segmentation dimension can be a punctuation dimension, a noise word dimension, etc., so as to accurately pre-process the text data to be classified to obtain word units.
[0095] Step S202, determining the text length of the word unit, and calling the corresponding intermediate word table according to the text length to execute the category data matching process.
[0096] Determine the text length of the word unit, call the corresponding intermediate word table based on the text length to perform the category data matching process, and determine the type of the word unit in response to a matching failure.
[0097] The text length of a word unit can be represented by the number of bytes occupied by all word units. The execution subject can determine the type of the corresponding word unit according to the text length, and the type of the word unit can include short text and long text.
[0098] Specifically, the data classification method also includes: regularly counting high-frequency text data in non-intermediate vocabulary that appears frequently online, inputting the high-frequency text data into a classification model to output category inference results corresponding to the high-frequency text data; sending the category inference results and high-frequency text data to offline nodes for review, and receiving the review results; and updating the online intermediate vocabulary based on the review results.
[0099] The execution subject can call the offline module to expand the intermediate vocabulary of the online module. When expanding the intermediate vocabulary of the online module, the execution subject can call the offline module to regularly count the high-frequency text data in the non-intermediate vocabulary that appears frequently online, and input the high-frequency text data into the classification model (such as the offline large model) to output the category reasoning results. And by sending the category reasoning results and high-frequency text data to the offline node for manual review, the intermediate vocabulary data to be updated is determined based on the manual review results, and then the online intermediate vocabulary is updated based on the determined intermediate vocabulary data to be updated, so as to ensure the accuracy of the intermediate vocabulary used in real time, thereby improving the accuracy of data classification.
[0100] Step S203, in response to the matching failure, calling the word-gram vector model, and in response to the word-gram type being a long text, segmenting the word-gram to obtain individual segmented word-grams, and converting each segmented word-gram into individual segmented word-gram vectors.
[0101] A two-layer neural network is constructed in the word-element vector model, and a downstream classification task is constructed to update parameters, that is, to update the word embedding vector. In the word-element vector model, the output of the first hidden layer corresponding to each word-element (i.e., token) is used as the word-element vector of the word-element. After the matching fails, the execution subject can determine the type of the word-element according to the number of word-element. When the type of the word-element is determined to be a long text, the execution subject can perform word segmentation on the word-element to obtain each word-element, and input each word-element into the word-element vector model, so as to use the output of the first hidden layer of the word-element vector model as the word-element vector of the corresponding word-element. Thereby, the accuracy of determining the word-element vector can be improved.
[0102] Step S204, determining the preset word-unit priority corresponding to each segmentation word-unit, and calculating the similarity data between each segmentation word-unit vector and each category vector in the category base table vector matrix according to the word-unit priority.
[0103] Specifically, the preset word-unit priority corresponding to each word-partition word-unit is determined, including: determining the word-unit priority of the word-partition word-unit belonging to the word in each word-partition word-unit as the first priority; determining the word-unit priority of the word-partition word-unit belonging to the character in each word-partition word-unit as the second priority; the first priority is higher than the second priority.
[0104] The embodiment of the present application sets the priority of words in the word segmentation word unit to be higher than the priority of characters, so that words containing more contextual information and semantic information can be preferentially calculated with each category in the category base table vector matrix to improve the accuracy of data classification.
[0105] Specifically, similarity data between each word segmentation word element vector and each category vector in the category base table vector matrix is calculated according to the word element priority, including: calculating each first similarity data between the word segmentation word element corresponding to the first priority and each category vector in the category base table vector matrix, and in response to each first similarity data being lower than a preset similarity threshold, calculating each second similarity data between the word segmentation word element corresponding to the second priority and each category vector in the category base table vector matrix, so as to determine each second similarity data as the similarity data between each word segmentation word element vector and each category vector in the category base table vector matrix.
[0106] When calculating similarity data, the words in the word-unit are preferentially matched with the category vectors in the category base table vector matrix for similarity. If there is no matching result, the characters in the word-unit are then matched with the category vectors in the category base table vector matrix for similarity until the similarity data that meets the preset similarity threshold requirements is accurately obtained. By setting the priority of the words in the segmentation word-unit to be higher than the priority of the characters, the words containing more contextual information and semantic information can be preferentially calculated with the categories in the category base table vector matrix for similarity, so as to improve the accuracy of data classification.
[0107] Step S205: determining the target category corresponding to the text data according to the similarity data.
[0108] Specifically, determining the target category corresponding to the text data according to the similarity data includes: determining the category corresponding to the category vector corresponding to the second similarity greater than a preset similarity threshold as the target category corresponding to the text data.
[0109] When no corresponding category can be matched based on the words in each word segmentation word unit, the execution entity may compare the similarity (i.e., the second similarity) obtained after calculating the similarity between the characters in each word segmentation word unit and each category vector in the category base table vector matrix with a preset similarity threshold, and determine the category corresponding to the category vector corresponding to the similarity (i.e., the second similarity) greater than the preset similarity threshold as the category corresponding to the text data, so as to improve the accuracy of determining the category.
[0110] The embodiment of the present application can realize the rapid classification of short texts input by users. Based on the word embedding of text tokens and the application of the offline and online loop system of the large-scale model BERT, the technical problem of low category text matching coverage is solved. On the basis of ensuring high online reasoning performance, high-speed iterability and reliability of reasoning results are achieved. The reasoning time of online services maintains the reasoning speed of TP99 <= 20ms under the peak request of 6000 times / min, reducing the original 50ms to 20ms. At the same time, the offline large-scale model loop part uses BERT to perform offline training on tens of millions of text data, ensuring the correctness of offline annotation of long texts and accelerating the iteration speed of the online service part. At the same time, cache hash table matching and high-performance matrix calculation are applied to short texts, and the semantic similarity between texts is represented by the word embedding matrix of words, achieving high-performance online calculation and high reliability of reasoning results.
[0111] Figure 3It is a schematic diagram of the online process of the category matching service of the data classification method provided according to an embodiment of the present application. The online category matching service involves mini-programs, online services and offline modules. Users can input text data through the mini-programs, and the online service obtains the input text data and performs text preprocessing. In the online service, the word segmentation algorithm of the word segmenter is the most basic component of the natural language processing large model. Based on the word segmenter, the text data can be converted into an independent word unit list, and then converted into a word unit vector into an input form that the computer can understand. The online category matching service of the data classification method involves the mini-programs, online services and offline modules of the online module. The online service provides real-time text classification capabilities on the mini-program side for the C-side (i.e., consumers and individual users), with advantages such as fast reasoning speed and rapid iteration. In order to ensure reasoning speed and accuracy, the online service sets up a multi-layer strategy to process the text data input by users: first, the text is preprocessed, which includes regular disambiguation and text tokenization (a token can be a word or a punctuation mark), filtering out interference words in the text data and processing them into word units; then the length of the text data (i.e., the number of word units) is determined. Here, based on the statistical analysis of the text input by historical users, the text length threshold is set to 10, that is, different processing strategies are used depending on whether the text length exceeds 10. Here, it is considered that text with a length of more than 10 contains sufficient contextual information and semantic information, and is suitable for reasoning of large models such as transformer-type deep models. When the text length is less than 10, the user input query is considered to be a short text, and greater than or equal to 10 is considered to be a long text.
[0112] For short texts, the online service uses an intermediate vocabulary (in the form of a hash table, which can include data from the base table, a database of third-level products, and words with a sufficiently high frequency in history) to directly perform key-value matching. When there is a matching category in the intermediate vocabulary, the matching category data in the corresponding value is returned, that is, the matching category is obtained; for unmatched queries (that is, when there is no matching category in the intermediate vocabulary), an improved word element vector model is used to solve the problem, and a word element list is obtained through word embedding (that is, token embedding, which is updated by obtaining the last layer output of the hidden layer of the offline module), that is, a token list. <token>, based on each token in the token list, the word meta vector, i.e. the query vector, is calculated, and the word meta vector corresponding to each token is averaged (average pooling is the average value of the local receptive field), and the word meta vector corresponding to the text data is calculated, and the word meta vector of the text data (i.e. the embedding vector) and the embedding vector (i.e. each category vector) of the category base table vector matrix (i.e. the category vector metric, obtained by calculating the category vector metric in the offline module) are respectively calculated based on the matrix cosine similarity (i.e. cosine similarity), and the topk similarities are obtained, and the corresponding topk categories are returned as candidate categories for matching category data. In order to ensure the efficiency of online calculation, the category base table vector matrix is normalized, and the dot product calculation of the word meta vector and each category vector in the category base table vector matrix is adopted to obtain the similarity matrix, and the topk similar categories are returned by sorting the similarity matrix in reverse order.
[0113] When the word unit type is a long text, the execution subject can directly input the long text into the trained classification model, so that the long text can be segmented by the word segmenter in the classification model and the classifier (such as bert-finetune-classifer) can be called based on the obtained word segmentation to obtain the topk probabilities, and the topk probabilities can be screened based on the preset probability threshold to predict the corresponding categories and output them. Specifically, the category corresponding to the probability greater than the preset probability threshold in the topk probabilities can be determined as the category predicted by the classification model. Ensure the accuracy of category prediction. For long texts, the embodiment of the present application constructs a mapping table from a large amount of non-standard input text to the third-level categories on the logistics side. For each text data entered by the user (i.e., query in the embodiment of the present application), the corresponding category in the mapping table is queried online, and the category data is returned at a constant speed. The online implementation of semantic understanding and natural language inference of long texts will result in large fluctuations in time consumption and instability, which will seriously affect the user experience. Through the research and analysis on time series, we found that the distribution of long query texts is highly stable in the time dimension, that is, it is feasible to use the historical distribution of long query texts to predict future queries; therefore, based on the historical distribution of user input texts, we built a sufficiently large intermediate word list (i.e., mapping table), and regularly updated it according to the distribution changes of user queries, replenished the text data queries that do not exist in the word list (List), and corrected the categories that may be removed from the category library. This method can improve both timeliness and accuracy.
[0114] The offline module is based on the NLP (Natural Language Processing, NLP) capability, providing the online module with the iteration of the intermediate word list, word element vector, and large NLP model, and decoupling from the online module during iteration, ensuring that the online and offline modules do not affect each other. Relying on retail data assets, there is a large amount of product name information and corresponding retail category data, which provides a large amount of high-quality training data for the NLP model. The offline module fine-tunes the model (finetune word2vec4sim) and fine-tunes the classification (finetune bert-classifer) through the retail category data. The output of the last layer of the hidden layer is obtained through model fine-tuning for word embedding (token embedding). The core capability provided by the offline module is to expand the intermediate vocabulary (of the online module), which is also the part with the largest online benefits at present. That is, a large amount of high-quality (query, label) annotation data is updated to the intermediate vocabulary at a high frequency and regularly. The expansion data of this part comes from the offline large model reasoning. The implementation process is to regularly collect high-frequency words and classification results in the non-intermediate vocabulary corresponding to the online matching category results, and then provide the high-frequency words and model reasoning results to the annotators for manual review and update the corresponding intermediate vocabulary based on the manual review classification results. In this solution, the classification capability of the large model is used for offline reasoning, and the trained large classification model is used to make model predictions for high-frequency word-word queries. The predicted topk category results are manually reviewed. Compared with manual annotation of each word-word query separately, the expansion efficiency of the vocabulary is increased from 500 words / day to 3000 words / day. As the top-level data of the overall data flow of the waybill, the online category matching service provides more data foundation for downstream services that rely on various different categories of consigned goods. The offline module calculates the category bottom table vector matrix and provides it to the online service for use in matrix calculation to obtain the similarity topk.
[0115] The embodiment of the present application uses an offline loop and an online loop to promote each other, and uses a large language model in offline annotation, so that it can quickly promote the update and iteration of the online module, thereby achieving high iterativeness and high computing performance of the service; the offline module adopts an idea similar to fine-tuning BERT FineTune, redistributes the weights of the vectors in the word meta-vector model within the subdivided field, and achieves a faster matching speed through online high-performance matrix calculations.
[0116] Constructing an intermediate vocabulary: Based on the deep learning model fine-tuned for multi-classification tasks, offline inference is performed on historical user input data, and an offline vocabulary is constructed through manual annotation and correction, and long texts are matched with the vocabulary online. Using a pre-trained deep learning model, the information of daily outbound orders on the retail side for five consecutive days is used to define the input as the order product name, and the prediction label as the third-level category on the retail side. After deduplication based on the product name, a total of 9 million training sample data are constructed, and the deep learning model is fine-tuned for multi-classification prediction tasks. At the same time, a mapping relationship between 4,000+ third-level categories on the retail side and 3,000+ third-level categories on the logistics side is constructed through manual annotation, so that after each query is input into the model, the model output result is obtained and the corresponding third-level category on the logistics side is returned. The proposed solution can achieve extremely fast online matching, 100% correct matching results, and timely update of the intermediate vocabulary.
[0117] The current pre-trained word meta-vector model uses a large amount of encyclopedia data to build a two-layer fully connected network through a continuous bag of words (CBOW) model or a continuous skip-gram model to compress the vocabulary-size one-hot sparse word meta-vector into a finite-dimensional continuous word embedding vector. Each word meta-token corresponds to the first hidden layer ( Figure 4 The output of the hidden layer (W1) in the pre-trained model is used as the word2vecembedding vector of the token. Since the training of this method is based on a large amount of general data, and the name design of the third-level logistics category is irrelevant to the model, directly using the word element vector of the pre-trained model to calculate the similarity for category matching will lead to large deviations. In order to make different input texts under the same category have higher similarity, a downstream classification task is constructed on the pre-trained model to update the parameters, that is, to update the word embedding vector. Figure 4 The two-layer neural network shown.
[0118] Figure 4 Schematic diagram of a neural network constructed according to a data classification method provided in one embodiment of the present application. The first layer is the embedding layer, which obtains each input token (such as X1, X2, ..., X n-1 , X n ) word vector (i.e. word2vec embedding), and perform weighted average pooling (i.e. weighted pooling, for the tokenized input X=(X1, X2, …, X n-1 , X n ), the output of the pooling layer is:
[0119]
[0120] Where λ>0.5 is the weight of word embedding. The second hidden layer maps the finite-dimensional embedding to the three-level categories on the logistics side. The loss function is constructed based on the cross entropy loss:
[0121]
[0122] Among them, W2 is the weight matrix of the second hidden layer, N is the number of labels, and y n is the label indicator of the text data. The training data uses the intermediate vocabulary built based on the BERT model, with the query as the input text and the corresponding three-level categories as labels. After multiple rounds of iterations, the first hidden layer (e.g. Figure 4 The output of the hidden layer (W1) in the process is used as the word2vec embedding vector of each token. The online reasoning is based on the updated word2vec embedding vector of each token and the similarity between each category vector in the category base table vector matrix to perform category matching and output (i.e., output (W2)). This method can provide a better word element vector model, which learns the similarity relationship between the names of items in the logistics field more specifically, so that the category matching by calculating the cosine similarity has higher accuracy and generalization ability. This method needs to be used online with high-performance databases such as redis and high-performance matrix computing frameworks such as ejml (java). The extracted embedding vector needs to be stored in the cache redis in advance, and the word element token input online is used as the query key value (Key) list of the database. The corresponding embedding vector is queried in redis, and averaged and randomly pooled. At the same time, the concept of cache is introduced, and the category data base table is vectorized in the same way to obtain the vector matrix of the category base table. Do the dot product between the embedding compressed from the token and the vector matrix, obtain the cosine similarity data between the input text data query and each category in the category table, and recall the topk most similar category results based on the similarity.
[0123] The embodiment of the present application can realize the design of the overall data flow architecture of the online module, realize the innovative strategy of offline loop and online loop architecture, and use the large language model BERT in the offline module, so that it can quickly promote the update and iteration of the online module; use the redis / ejml high-performance computing framework in the online module to achieve high iterability and high computing performance of the service. The structural innovation model redistributes the weights of the vectors in the word element vector model within the subdivided field, and achieves a faster matching speed through online high-performance matrix calculations. The weight ratio of words relative to characters is increased, the disturbance of characters to the distribution of vector space is reduced, and the representation of word meaning is enhanced.
[0124] Figure 5 Schematic diagram of the main units of the data classification device according to an embodiment of the present application. Figure 5 As shown, the data classification device 500 includes an acquisition unit 501, a matching unit 502, a similarity data determination unit 503 and a target category determination unit 504.
[0125] The acquisition unit 501 is configured to acquire text data to be classified, and obtain corresponding word units based on the text data processing.
[0126] The matching unit 502 is configured to determine the text length of the word unit, and call the corresponding intermediate word table according to the text length to perform the category data matching process.
[0127] The similarity data determination unit 503 is configured to call the word-merge vector model in response to a matching failure to convert a word-merge into a word-merge vector, and then determine the similarity data of each category corresponding to the category base-merge vector matrix based on the word-merge vector, the category base-merge vector matrix and a preset word-merge priority.
[0128] The target category determination unit 504 is configured to determine the target category corresponding to the text data according to the similarity data.
[0129] In some embodiments, the similarity data determination unit 503 is further configured to: in response to the word-gram type being a long text, segment the word-gram to obtain individual word-gram segmentation words, and convert each word-gram segmentation word-gram into each word-gram segmentation word-gram vector; determine the preset word-gram priority corresponding to each word-gram segmentation word-gram, and calculate the similarity between each word-gram segmentation word-gram vector and each category vector in the category base table vector matrix according to the word-gram priority; based on the similarity, determine the category corresponding to the text data.
[0130] In some embodiments, the matching unit 502 is further configured to: obtain the number of word-grams; and determine the number as the text length of the word-grams.
[0131] In some embodiments, the matching unit 502 is further configured to: in response to the text length being less than a preset threshold, determine the corresponding intermediate vocabulary as a short text category hash table; in response to the text length being greater than a preset threshold, determine the corresponding intermediate vocabulary as a long text category mapping table.
[0132] In some embodiments, the similarity data determination unit 503 is further configured to: determine the word-unit priority of the word-unit belonging to the word in each word-unit as the first priority; determine the word-unit priority of the word-unit belonging to the character in each word-unit as the second priority; the first priority is higher than the second priority.
[0133] In some embodiments, the similarity data determination unit 503 is further configured to: calculate each first similarity data between the segmentation word element corresponding to the first priority and each category vector in the category base table vector matrix, and in response to each first similarity data being lower than a preset similarity threshold, calculate each second similarity data between the segmentation word element corresponding to the second priority and each category vector in the category base table vector matrix, so as to determine each second similarity data as the similarity data between each segmentation word element vector and each category vector in the category base table vector matrix.
[0134] In some embodiments, the target category determination unit 504 is further configured to: determine the category corresponding to the category vector corresponding to the second similarity greater than a preset similarity threshold as the target category corresponding to the text data.
[0135] In some embodiments, the data classification device further includes Figure 5 The intermediate vocabulary update unit not shown in the figure is configured to: regularly count the high-frequency text data in the non-intermediate vocabulary that appears frequently online, input the high-frequency text data into the classification model to output the category inference result corresponding to the high-frequency text data; send the category inference result and the high-frequency text data to the offline node for review, and receive the review result; update the online intermediate vocabulary based on the review result.
[0136] It should be noted that the data classification method and data classification device of the present application have a corresponding relationship in terms of specific implementation content, so the repeated content will not be described again.
[0137] Figure 6 An exemplary system architecture 600 to which the data classification method or data classification device according to the embodiment of the present application can be applied is shown.
[0138] like Figure 6 As shown, system architecture 600 may include terminal devices 601, 602, 603, network 604 and server 605. Network 604 is used to provide a medium for communication links between terminal devices 601, 602, 603 and server 605. Network 604 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0139] The user can use the terminal devices 601, 602, 603 to interact with the server 605 through the network 604 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 601, 602, 603, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).
[0140] The terminal devices 601, 602, 603 may be various electronic devices having a data classification processing screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0141] Server 605 can be a server that provides various services, such as a background management server that provides support for data classification requests submitted by users using terminal devices 601, 602, and 603 (only as an example). The background management server can obtain text data to be classified, obtain corresponding word units based on text data processing; determine the text length of the word unit, and call the corresponding intermediate word table according to the text length to perform the category data matching process; in response to a matching failure, call the word unit vector model to convert the word unit into a word unit vector, and then determine the similarity data of each category corresponding to the category base table vector matrix based on the word unit vector, the category base table vector matrix and the preset word unit priority; determine the target category corresponding to the text data according to the similarity data. Intermediate word table matching and high-performance category base table vector matrix calculation are applied to the text to be classified, achieving high-performance online computing and high reliability of reasoning results, and improving the efficiency and accuracy of category determination.
[0142] It should be noted that the data classification method provided in the embodiment of the present application is generally executed by the server 605 , and accordingly, the data classification device is generally set in the server 605 .
[0143] It should be understood that Figure 6 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0144] Reference below Figure 7 , which shows a schematic diagram of the structure of a computer system 700 of a terminal device suitable for implementing an embodiment of the present application. Figure 7 The terminal device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0145] like Figure 7 As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 to a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the computer system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other through a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0146] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed so that a computer program read therefrom is installed into the storage section 708 as needed.
[0147] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-mentioned functions defined in the system of the present application are executed.
[0148] It should be noted that the computer-readable medium shown in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. Computer-readable storage media may include, for example, but are not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0149] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the above-mentioned module, program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0150] The units involved in the embodiments described in the present application may be implemented by software or hardware. The units described may also be set in a processor, for example, it may be described as: a processor includes an acquisition unit, a matching unit, a similarity data determination unit, and a target category determination unit. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0151] As another aspect, the present application also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently and not be assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by a device, the device obtains the text data to be classified, obtains the corresponding word element based on the text data processing; determines the text length of the word element, and calls the corresponding intermediate word table according to the text length to perform the category data matching process; in response to the matching failure, calls the word element vector model to convert the word element into a word element vector, and then determines the similarity data of each category corresponding to the category base table vector matrix based on the word element vector, the category base table vector matrix and the preset word element priority; and determines the target category corresponding to the text data according to the similarity data. Intermediate word table matching and high-performance category base table vector matrix calculation are applied to the text to be classified, achieving high-performance online computing and high reliability of reasoning results, and improving the efficiency and accuracy of category determination.
[0152] The computer program product of the present application includes a computer program, and when the computer program is executed by a processor, the data classification method in the embodiment of the present application is implemented.
[0153] According to the technical solution of the embodiment of the present application, intermediate vocabulary matching and high-performance category base table vector matrix calculation are applied to short texts, achieving high-performance online computing and high reliability of reasoning results, and improving the efficiency and accuracy of category determination.
[0154] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.< / token>
Claims
1. A data classification method, characterized in that: include: Acquire text data to be classified, and obtain corresponding word units based on the text data processing; Determine the text length of the word element, and call the corresponding intermediate word table according to the text length to perform the category data matching process; In response to a match failure, calling a word-element vector model to convert the word-element into a word-element vector, and then determining similarity data of each category corresponding to the category-element vector matrix based on the word-element vector, the category-element vector matrix, and a preset word-element priority; According to the similarity data, a target category corresponding to the text data is determined.
2. The method according to claim 1, characterized in that The determining, based on the word element vector, the category base table vector matrix and the preset word element priority, the similarity data of each category corresponding to the category base table vector matrix includes: In response to the type of the word-gram being a long text, segmenting the word-gram to obtain individual segmented word-grams, and converting the individual segmented word-grams into individual segmented word-gram vectors; Determine the preset word unit priority corresponding to each of the segmentation word units, and calculate the similarity data between each of the segmentation word unit vectors and each category vector in the category base table vector matrix according to the word unit priority.
3. The method according to claim 1, characterized in that The determining of the text length of the word element comprises: Obtaining the number of the word units; The number is determined as the text length of the word-gram.
4. The method according to claim 1, characterized in that: Before calling the corresponding intermediate vocabulary, the method further includes: In response to the text length being less than a preset threshold, determining that the corresponding intermediate vocabulary is a short text category hash table; In response to the text length being greater than a preset threshold, the corresponding intermediate vocabulary is determined to be a long text category mapping table.
5. The method according to claim 2, characterized in that: The step of determining the preset word unit priority corresponding to each of the word segmentation word units includes: Determine the word-unit priority of the word-unit belonging to the word among the word-units as the first priority; Determine the word unit priority of the word unit belonging to the character in each word unit as the second priority; The first priority is higher than the second priority.
6. The method according to claim 5, characterized in that The calculating, according to the word unit priority, the similarity data between each word segmentation word unit vector and each category vector in the category base table vector matrix includes: Calculate each first similarity data between the word segmentation word corresponding to the first priority and each category vector in the category base table vector matrix. In response to the first similarity data being lower than a preset similarity threshold, calculate each second similarity data between the word segmentation word corresponding to the second priority and each category vector in the category base table vector matrix to determine each second similarity data as the similarity data between each word segmentation word element vector and each category vector in the category base table vector matrix.
7. The method according to claim 6, characterized in that Determining the target category corresponding to the text data according to the similarity data includes: The category corresponding to the category vector corresponding to the second similarity greater than the preset similarity threshold is determined as the target category corresponding to the text data.
8. The method according to claim 1, characterized in that: The method further comprises: Regularly count the high-frequency text data in the non-intermediate word list that appears frequently online, and input the high-frequency text data into the classification model to output the category inference result corresponding to the high-frequency text data; Sending the category inference result and the high-frequency text data to an offline node for review, and receiving the review result; The online intermediate vocabulary is updated based on the audit result.
9. A data classification device, characterized in that: include: An acquisition unit is configured to acquire text data to be classified, and obtain corresponding word units based on the text data; A matching unit is configured to determine the text length of the word unit, and call the corresponding intermediate word table according to the text length to perform a category data matching process; A similarity data determination unit is configured to, in response to a matching failure, call a word-element vector model to convert the word-element into a word-element vector, and then determine similarity data of each category corresponding to the category-element vector matrix based on the word-element vector, the category-element vector matrix, and a preset word-element priority; The target category determination unit is configured to determine the target category corresponding to the text data according to the similarity data.
10. A data classification electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 8.
11. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
