Transform model-based literature classification method and system and electronic equipment
By employing a visual feature learning method based on the Transformer model and combining visual feature information from the first and last pages of a document, the problem of insufficient accuracy and weak generalization ability in document classification in existing technologies is solved, achieving efficient and accurate automatic document classification.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANGHAI UNIV OF ENG SCI
- Filing Date
- 2026-02-12
- Publication Date
- 2026-05-12
AI Technical Summary
Existing document classification methods rely too heavily on text semantic extraction and ignore the unique visual layout features of journals, resulting in insufficient classification accuracy and weak generalization ability, especially when dealing with scanned versions or documents with messy text layer encoding.
We employ a document classification method based on the Transformer model. By image processing of the first and last pages of documents, we extract visual feature information and train the model using data augmentation techniques and multi-dimensional evaluation indicators to capture the differences in the layout of journals and achieve accurate classification.
It significantly improves the automation and accuracy of document classification, adapts to the differences in the layout characteristics of different journals, reduces the cost of manual intervention, and improves the generalization ability and stability of the model.
Smart Images

Figure CN122019482A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of document classification technology, and in particular to a document classification method, system and electronic device based on the Transformer model. Background Technology
[0002] With the continuous expansion of the scale of digitized academic literature, a large number of PDF journal articles are stored in a scattered manner. Manual classification and sorting is not only inefficient, but also prone to classification errors, making it difficult to meet the needs of efficient retrieval and management in academic research, literature management and other scenarios.
[0003] Existing document classification methods mostly rely on keyword matching of text content or single feature extraction, ignoring the unique visual features of journal articles in terms of layout (such as the first page header or the last page footer), resulting in insufficient classification accuracy and weak generalization ability.
[0004] For example, Chinese patent application CN119760138A discloses an automatic classification method for journal documents based on random forest. This method extracts text information from the first page of a PDF document, uses a TF-IDF vectorizer to convert the text data into numerical features, and then inputs these features into a random forest model for classification. However, this approach has significant limitations: First, it relies heavily on text content extraction and semantic analysis, meaning it struggles to extract effective features from scanned image-based PDFs or documents with poorly encoded text layers, thus limiting its applicability. Second, this method focuses only on the statistical text features of the first page, completely ignoring the important visual layout information (such as unique header designs, font styles, and page structures) and the last page (which typically contains copyright information, submission dates, and other key features). Due to the lack of comprehensive modeling of the visual features of the first and last pages, relying solely on random forests to process text features often fails to achieve high-precision differentiation when dealing with documents in similar content domains but belonging to different journals.
[0005] In summary, current document classification technologies suffer from problems such as over-reliance on text semantic extraction, neglect of the unique visual layout features of journals at the beginning and end, and difficulty in handling non-textual documents, resulting in insufficient classification accuracy and generalization ability. Summary of the Invention
[0006] The purpose of this invention is to overcome the shortcomings of the existing technology and provide a document classification method, system and electronic device based on the Transformer model.
[0007] The objective of this invention can be achieved through the following technical solutions: According to one aspect of the present invention, a document classification method based on the Transformer model is provided, characterized in that the method steps include: S1. Obtain the classified document sample files and save each document sample file to the folder corresponding to its respective journal, with the folder name corresponding to the journal name; S2. Perform image processing on each document sample file, extract the portion of the first page containing the header features as the first image, and extract the portion of the last page containing the footer features as the second image; combine the first and second images to generate a third image; store the third image in the corresponding folder of the journal. S3. Extract visual feature information from all third images to form a visual feature dataset; and form a category label set based on the journal category corresponding to each third image. S4. Train the Transformer classification model using the visual feature dataset and category label set; output the trained Transformer classification model. S5. Obtain the document to be classified. Use the same image processing, cropping and integration methods as in S2 to generate a corresponding third image and extract visual feature information from the third image. Use the trained Transformer classification model to classify the document based on the extracted visual feature information, output the journal to which the document belongs, and archive the classified document to the corresponding folder of the journal.
[0008] As a preferred technical solution, the methods for cropping the first and second images in S2 include: The top half of the homepage is used as the first image, and the bottom half of the last page is used as the second image.
[0009] As a preferred technical solution, cropping the upper half of the homepage as the first image and cropping the lower half of the last page as the second image specifically means: Starting from the top edge of the homepage, select an area whose height accounts for 30% to 50% of the total page height as the first image; Starting from the bottom edge of the last page, select an area whose height accounts for 30% to 50% of the total page height as the second image.
[0010] As a preferred technical solution, S2 specifically includes integrating the first image and the second image to generate the third image, including: The first and second images are vertically stitched together in an adjacent order. The stitched images are standardized to the preset pixel size required for the input layer of the Transformer classification model; and the pixel values of the standardized images are normalized.
[0011] As a preferred technical solution, the visual feature information in S3 includes the text layout of the header, the text layout of the footer, the font style, the layout structure, and the logo elements.
[0012] As a preferred technical solution, before extracting visual feature information from all third images in S3, data augmentation processing of the third images is also included. Data augmentation processes include horizontal flipping, random rotation, and color dithering.
[0013] As a preferred technical solution, the process of training the Transformer classification model also includes introducing data ablation experiments and policy optimization steps, specifically: Multiple sets of data augmentation ablation experiments were constructed. The complete strategy containing all data augmentation processes was set as the baseline group, and experimental groups were set up to remove horizontal flipping, random rotation, or color dithering operations in sequence. By comparing the convergence characteristics of the loss curves and the trend of the accuracy curves of each experimental group and the baseline group during the training and validation processes, the classification performance of each experimental group is evaluated and the contribution of each data augmentation treatment to the classification performance is quantified, and the contribution ranking is obtained. Optimization strategies are implemented based on contribution ranking and classification performance: enhancements for journals with high contributions exceeding the preset contribution threshold are retained or strengthened; for journal categories with poor classification performance, operations such as supplementing literature sample files, adjusting the weights of the Transformer classification model's attention mechanism, or optimizing the image cropping area are performed.
[0014] As a preferred technical solution, a multi-dimensional evaluation index was used to assess the contribution of different visual features to the classification effect. Multi-dimensional evaluation metrics include accuracy, recall, and F1 score; the process of training the Transformer classification model iterates parameters with the objective function of maximizing the F1 score on the validation set.
[0015] According to another aspect of the present invention, a document classification system based on the Transformer model is provided, characterized in that the system includes a sample management module, an image generation module, a feature construction module, a model training module, and a classification and archiving module; The sample management module is used to obtain classified document sample files and save each document sample file to the folder corresponding to its respective journal. The image generation module is used to perform image processing on each document sample file, extract the portion of the first page containing header features as the first image, and extract the portion of the last page containing footer features as the second image; integrate the first and second images to generate a third image; and store the third image in the corresponding folder of the journal. The feature construction module is used to extract visual feature information from all third images to form a visual feature dataset; and to form a category label set based on the journal category corresponding to each third image. The model training module is used to train a Transformer classification model using a visual feature dataset and a category label set; it outputs the trained Transformer classification model. The classification and archiving module is used to call the output of the document to be classified after being processed by the image generation module and the feature construction module, and input the output into the trained Transformer classification model to classify the document. The classification and archiving module outputs the journal to which the document to be classified belongs; and archives the classified document to the folder corresponding to the journal.
[0016] According to another aspect of the present invention, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the program to implement the method described above.
[0017] Compared with the prior art, the present invention has the following beneficial effects: 1. This invention employs a visual feature learning method based on the Transformer model, abandoning the traditional text analysis approach. Instead, it performs image processing on the documents and classifies them using the extracted visual feature information through a trained Transformer classification model. This method combines the visual feature information of the document files with the self-attention mechanism of the Transformer model to capture differentiated information (such as layout structure and identifiers) in the first page header and last page footer, solving the problems of text dependence and layout neglect. This effectively addresses the difficulty of classifying scanned versions or documents lacking text layers, achieving accurate visual classification, significantly improving the automation and accuracy of document classification, reducing manual intervention costs, and adapting to the layout differences of different journals.
[0018] 2. In this invention, by extracting 30%-50% of the area from the top edge of the first page and 30%-50% of the area from the bottom edge of the last page as feature extraction sources, the most recognizable areas of the journal can be accurately identified. These areas typically contain the journal logo, ISSN number, copyright information, and special layout. Simultaneously, this extraction method effectively eliminates semantic interference from the main text content on the classification model. This specific extraction method fully leverages the unique visual layout features of journal articles, ensuring the model focuses on the most distinctive visual information, thereby significantly improving classification accuracy and making it suitable for intelligent classification of various types of journal articles.
[0019] 3. This invention vertically stitches together the first and second images and performs standardization and normalization processing, enabling the model to jointly learn the visual correspondence between the header and footer, enhancing feature association and model robustness, and accelerating model convergence. At the same time, data augmentation processing such as horizontal flipping, random rotation, or color jitter is introduced before feature extraction to simulate the tilt or noise that may occur in scanned documents in reality, expanding the diversity of training samples, preventing model overfitting, and thus improving the model's generalization ability and stability when processing actual documents to be classified.
[0020] 4. This invention introduces data ablation experiments and multi-dimensional evaluation metrics during the training process. By comparing experiments, the contribution of different visual features is evaluated, and the attention mechanism weights or network parameters of the Transformer model are dynamically adjusted accordingly. This process aims to maximize the F1 score on the validation set, making model training more scientific and transparent, ensuring an optimal balance between recall and precision, and further guaranteeing the reliability of the classification results. Attached Figure Description
[0021] Figure 1 This is a schematic diagram illustrating the steps of the document classification method based on the Transformer model in this invention; Figure 2 This is a flowchart illustrating the specific implementation of document classification based on the Transformer model in this embodiment. Figure 3a This is a schematic diagram of the loss curve during model training in the embodiment; Figure 3b This is a schematic diagram of the accuracy curve during model training in the embodiment; Figure 3c This is a schematic diagram of the accuracy curve during model training in the embodiment; Figure 3d This is a schematic diagram of the recall rate and F1 curve of the model on the test set in the embodiment; Figure 4a This is a schematic diagram of the baseline loss curve under the complete data augmentation strategy in the embodiment; Figure 4b This is a schematic diagram of the baseline accuracy curve under the complete data augmentation strategy in the embodiment; Figure 5a This is a schematic diagram of the loss curve after removing the "flip" enhancement in the embodiment; Figure 5b This is a schematic diagram of the accuracy curve after removing the "flip" enhancement in the example. Figure 6a This is a schematic diagram of the loss curve after removing the "color jitter" enhancement in the example; Figure 6bThis is a schematic diagram of the accuracy curve after removing the "color jitter" enhancement in the example; Figure 7a This is a schematic diagram of the loss curve after removing the "rotation" enhancement in the embodiment; Figure 7b This is a schematic diagram of the accuracy curve after removing the "rotation" enhancement in the example. Figure 8a This is a schematic diagram of the loss curve when no data augmentation is used at all in the example; Figure 8b This is a schematic diagram of the accuracy curve when no data augmentation is used in the example. Detailed Implementation
[0022] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0023] Visual feature learning methods based on the Transformer model, with their powerful feature extraction and modeling capabilities, have become an effective approach to address the problems of insufficient classification accuracy and weak generalization ability in current document classification. This solution utilizes this Transformer model-based visual feature learning method to propose a more accurate and efficient automatic document classification method that combines the visual layout features of PDF documents, reducing manual intervention and adapting to the differences in layout features among different journals.
[0024] Example 1 In this embodiment, a document classification method based on the Transformer model is adopted to address the problems of existing document classification methods relying on single features and having low accuracy. By extracting visual features of specific regions of PDF (Portable Document Format) documents and combining them with the Transformer model for feature learning and classification, the journal to which the document belongs can be automatically identified. The method steps are as follows: Figure 1 As shown, it specifically includes: S1. Obtain the classified document sample files and save each document sample file to the folder corresponding to its respective journal, with the folder name corresponding to the journal name; S2. Perform image processing on each document sample file, extract the portion of the first page containing the header features as the first image, and extract the portion of the last page containing the footer features as the second image; combine the first and second images to generate a third image; store the third image in the corresponding folder of the journal. S3. Extract visual feature information from all third images to form a visual feature dataset; and form a category label set based on the journal category corresponding to each third image. S4. Train the Transformer classification model using the visual feature dataset and category label set; output the trained Transformer classification model. S5. Obtain the document to be classified. Use the same image processing, cropping and integration methods as in S2 to generate a corresponding third image and extract visual feature information from the third image. Use the trained Transformer classification model to classify the document based on the extracted visual feature information, output the journal to which the document belongs, and archive the classified document to the corresponding folder of the journal.
[0025] This method first organizes the PDF documents to be processed, categorizes them into corresponding journal folders, and extracts visual feature images of specified areas. The extracted visual images are then integrated to construct a feature dataset labeled with journal categories. Next, a classification network is built based on the Transformer model, and the model is trained using the dataset to learn the layout features of different journals. Finally, the visual features of the documents to be classified are predicted to determine their respective journal categories. The method incorporates data ablation experiments and multi-dimensional evaluation metrics to verify and optimize the model's classification performance. This method effectively leverages the visual layout features of journal articles, improving classification accuracy, while multi-dimensional evaluation ensures model reliability, making it suitable for intelligent classification of various types of journal literature.
[0026] The Transformer classification model is trained using the Transformer algorithm. The training process determines the journal category of a document by calculating the similarity between the visual features of the document to be classified and the visual features of papers in various journals. Furthermore, core parameters of the Transformer classification model, such as the number of attention heads and the dimension of hidden layers, can be adjusted according to the characteristics of the actual document data.
[0027] The extracted visual features include the text layout, font style, page structure, and logo elements of the header / footer. These features are used together as input features into the classification model.
[0028] The integrated image information, along with the journal label and file path information of the corresponding PDF document, is stored in a triplet format (image, journal_label, file_path). The categorized document files retain their original filenames and are archived according to the journal category to the specified directory path. The categorization results are synchronously stored as text files in the corresponding journal folders.
[0029] The Transformer classification model used is built on the PyTorch / TensorFlow framework. During training, the input feature matrix is a dataset containing visual features, and the labels are the category label sets corresponding to each journal. The Transformer classification model predicts the visual features of the documents to be classified, and the output prediction results are used to determine the journal category to which the document belongs, and the classification label and confidence score of each document are recorded.
[0030] The classification steps include: using the journal category labels output by the Transformer model, archiving the documents to be classified to the corresponding journal folders.
[0031] The training process includes: training the Transformer model using the training dataset, introducing data ablation experiments to evaluate the impact of different visual features on classification performance, evaluating classification performance using metrics such as accuracy, recall, and F1 score, and adjusting the parameters of the Transformer model to improve classification performance.
[0032] This method is applicable to classifying multiple collections of articles from different journals within the same storage directory. It can automatically identify the visual boundaries of articles from different journals and complete accurate classification and archiving. It can reduce manual classification intervention, adapt to the page layout characteristics of different journals, and provide efficient and automated document classification and archiving functions.
[0033] The specific implementation process of this method is as follows: Figure 2 As shown, the details are as follows: PDF document preprocessing and visual feature extraction: The PDF documents to be processed are stored in the folder corresponding to the journal name according to the naming rules of "journal name", thus establishing the initial correspondence between "journal-document".
[0034] For each PDF document, use a PDF processing tool (such as PyMuPDF) to locate the top half of the first page and the bottom half of the last page, and then capture images of these two areas respectively.
[0035] Combine two cropped images from the same document into a single complete visual feature image using a fixed format (such as stitching them together vertically), and save it to the journal folder to which the document belongs, naming it as "document filename.png".
[0036] Constructing a feature and label dataset: Feature construction: The integrated visual feature images are standardized (e.g., uniform size, normalized pixel values) and converted into tensor formats that the model can recognize, which serve as the core features of the feature matrix X.
[0037] Labeling: The journal to which the document belongs is used as the classification label. Each visual feature image is labeled with the corresponding journal category label (e.g., journal A is labeled as 0, journal B is labeled as 1). The label information is stored in the label vector y.
[0038] Dataset partitioning: The feature matrix X and label vector y are divided into training set, validation set and test set according to a preset ratio (e.g., 7:2:1). The training set is used for model learning, the validation set is used for parameter tuning, and the test set is used for final performance evaluation.
[0039] Transformer classification model training: A classification network is built based on the Transformer architecture, which includes a visual feature encoding layer, a multi-head attention layer, and a fully connected classification layer. The encoding layer is responsible for converting image features into sequence features, the attention layer captures key feature differences in the layout of journals, and the classification layer outputs the probability distribution of journal categories.
[0040] Input the training set into the Transformer model, set hyperparameters such as batch size and number of iterations, and optimize the model parameters through backpropagation.
[0041] Use a validation set to monitor the model training effect in real time. If overfitting occurs, adjust the regularization parameters, model depth, etc., to ensure the model's generalization ability.
[0042] Literature and Journal Classification Prediction: For PDF documents without journal category labels, repeat the image cropping and integration operation in step 1 to generate visual feature images.
[0043] Input the visual feature image to be classified into the trained Transformer model, and the model outputs the probability values of each journal to which the document belongs.
[0044] The category with the highest probability value is selected as the journal category to which the document belongs, thus completing the automatic classification.
[0045] Model performance evaluation: The accuracy, recall, and F1 score of the model on the test set were calculated to quantify the model's classification performance. Accuracy reflects the proportion of correctly classified documents out of the total number of test documents; recall measures the completeness of single-class identification, representing the proportion of correctly identified documents from a particular journal out of the total number of test documents in that journal; and the F1 score is the harmonic mean of accuracy and recall, reflecting the overall classification performance of the model. Related results are shown below. Figures 3a-3d As shown.
[0046] Figure 3a The curves show the training and validation loss of the model. The blue line represents the training loss and the orange line represents the validation loss. Both the training loss and the validation loss show a rapid downward trend. Although there are some fluctuations in the early stage, they gradually become stable as the number of training rounds increases. The validation loss eventually stabilizes at a low level, indicating that the model has good convergence and there is no obvious overfitting or underfitting. Figure 3b The graph shows the training and validation accuracy curves of the model. The blue line represents the training accuracy, and the orange line represents the validation accuracy. Both curves rise rapidly and then gradually stabilize. The training accuracy eventually stabilizes at around 97%, and the validation accuracy stabilizes at over 95%. The small difference between the two curves indicates that the model has a high overall classification accuracy on the test set and good generalization ability. Figure 3c The curves show the training and validation accuracy of the model. The blue line represents the training accuracy, and the orange line represents the validation accuracy. The training accuracy and validation accuracy increase in tandem. Although there are slight fluctuations in the middle stage, they are stable at over 95% in the later stage. The difference between the validation accuracy and the training accuracy is very small, indicating that among the samples predicted by the model as belonging to a certain journal category, the proportion that actually belongs to that category is high, and the classification accuracy is excellent. Figure 3d The graph shows the training and validation recall and F1 score curves for the model. The blue line represents the training recall, the orange line represents the validation recall, the green line represents the training F1 score, and the red line represents the validation F1 score. In the graph, the training recall, validation recall, training F1 score, and validation F1 score all rise rapidly and then stabilize. The validation recall and validation F1 score eventually stabilize above 90%, matching the performance of precision and accuracy. This indicates that the model effectively captures the characteristics of each journal category, has high completeness in identifying documents of each category, and demonstrates excellent overall classification performance while maintaining both accuracy and completeness. The various metrics show good synergy. In summary, the model achieves high levels of accuracy, recall, and F1 score on the test set, with a smooth convergence of the loss curve and no significant abnormal fluctuations in the performance metrics. This demonstrates that the constructed Transformer classification model possesses good convergence, stability, and generalization ability in the task of classifying journal documents, and its classification effect is reliable.
[0047] Data ablation experiments: Multiple ablation experiments were designed, sequentially removing different feature dimensions such as "horizontal flip operation," "rotation operation," and "color dithering operation." The changes in evaluation metrics for each experimental group were compared to verify the contribution of different visual features to the classification results. As shown in Figures 4-8, multiple ablation experiments were designed, using the complete data augmentation strategy as a baseline (…). Figure 4a and Figure 4b ), and remove individual enhancement operations in sequence ( Figures 5a-7b ) and not using data augmentation at all Figure 8a and Figure 8b The characteristics of the changes in the loss curves and accuracy curves of each group were compared.
[0048] Figure 4a The loss curves under the complete data augmentation strategy are shown below. The blue line represents the training loss and the orange line represents the validation loss, which are used to reflect the convergence speed and generalization stability of the model training under the complete augmentation strategy. Figure 4b The graph shows the accuracy curves under the complete data augmentation strategy. The blue line represents the training accuracy, and the orange line represents the validation accuracy, illustrating the changing trend of the overall correct classification ratio of the model under the complete augmentation strategy. Figure 4a loss curve and Figure 4b As shown in the accuracy curves, under the complete augmentation strategy, the training loss and validation loss of the model decrease rapidly and synchronously, and tend to stabilize in the later stage. The validation loss fluctuates little and has a low final value. The training and validation accuracies rise rapidly and stabilize at around 96%, with a very small difference between the two. There is no obvious overfitting, and the model has the best convergence, stability and classification performance.
[0049] Figure 5a The loss curve after removing the horizontal flip enhancement operation is shown in blue. The blue line represents the training loss and the orange line represents the validation loss. This is used to reflect the convergence and generalization characteristics of the model training after removing the flip enhancement. Figure 5b The accuracy curves after removing the horizontal flip enhancement are shown. The blue line represents training accuracy, and the orange line represents validation accuracy, illustrating the trend of model classification accuracy after removing the flip enhancement. Figure 5a loss curve and Figure 5b As shown in the accuracy curve, after removing the horizontal flipping operation, the loss decrease trend is close to the baseline, but the validation loss fluctuates slightly more and the final value is slightly higher, the accuracy is slightly lower than the baseline, and the model stability decreases slightly, indicating that horizontal flipping has a certain auxiliary contribution to the classification effect.
[0050] Figure 6a The loss curve after removing color jitter enhancement is shown. The blue line represents the training loss and the orange line represents the validation loss, which are used to reflect the convergence and generalization characteristics of the model training after removing color jitter enhancement. Figure 6bThe accuracy curves after removing color jitter enhancement are shown. The blue line represents training accuracy, and the orange line represents validation accuracy, illustrating the trend of model classification accuracy after removing color jitter enhancement. Figure 6a loss curve and Figure 6b As shown in the accuracy curve, after removing the color jitter operation, the loss curve decreased most smoothly, verifying that the loss fluctuation was the smallest and the final value was even lower than the baseline. The accuracy was basically the same as the baseline, indicating that the contribution of color jitter to the classification effect was low.
[0051] Figure 7a The loss curve after removing the rotation enhancement operation is shown in blue. The blue line represents the training loss and the orange line represents the validation loss. This is used to reflect the convergence and generalization characteristics of the model training after removing the rotation enhancement. Figure 7b The accuracy curves after removing rotation enhancement are shown. The blue line represents training accuracy, and the orange line represents validation accuracy, illustrating the trend of model classification accuracy after removing rotation enhancement. Figure 7a loss curve and Figure 7b As shown in the accuracy curves, after removing the rotation operation, the validation loss exhibited sharp peak fluctuations, with the final loss value significantly higher than the baseline; the validation accuracy experienced a sharp precipitous drop, although it recovered somewhat later, the final value was still lower than the baseline and fluctuated wildly, indicating that rotation is the core augmentation operation affecting the classification performance.
[0052] Figure 8a The loss curve is shown without any data augmentation. The blue line represents the training loss and the orange line represents the validation loss, reflecting the convergence and generalization characteristics of the model training under no augmentation conditions. Figure 8b The accuracy curves without any data augmentation are shown below. The blue line represents training accuracy, and the orange line represents validation accuracy, illustrating the trend of model classification accuracy under no augmentation conditions. Figure 8a loss curve and Figure 8b As shown in the accuracy curves, when no data augmentation is used, the model loss converges slowly, the validation loss fluctuates greatly throughout the process and has the highest final value; the accuracy increases slowly and has the lowest final value among all groups, the training and validation accuracy are significantly different, there is obvious overfitting, and the classification effect is the worst.
[0053] In summary, the contribution of each data augmentation operation to the classification effect is ranked as follows: rotation operation > horizontal flip operation > color dithering operation. A complete data augmentation strategy can significantly improve model convergence speed, reduce loss fluctuations, increase final classification accuracy, and effectively alleviate overfitting, making it crucial for ensuring the classification performance of literature and journal articles.
[0054] Based on the evaluation results, if the classification effect of a certain type of journal is not good, the literature feature samples of that journal can be supplemented, the weight of the attention mechanism of the Transformer model can be adjusted, or the image cropping area can be optimized to improve the classification accuracy.
[0055] Classification result output and storage: Automatically move / copy the classified documents to the corresponding journal folder according to the predicted journal category; (e.g., C: / Users / XXX / Output).
[0056] Generate a classification results report, recording the file name, predicted journal category, classification confidence (probability value), and evaluation index data for each document, and save it to a specified directory (e.g., C: / Users / XXX / Classification_Report).
[0057] In summary, this method inputs the dataset into the Transformer classification model for training. During training, data ablation experiments are introduced to evaluate the contribution of different visual features to the classification effect. Accuracy, recall, and F1 score are used as core evaluation indicators to dynamically optimize the model parameters. Finally, the trained model is used to predict the visual features of the documents to be classified, outputting journal category labels and classification confidence scores, thereby realizing the automated classification and archiving of documents by journal category.
[0058] By leveraging the self-attention mechanism of the Transformer model to capture differentiated information on the visual features of journal articles, and combining multi-dimensional evaluation indicators and ablation experiments to ensure classification performance, this method significantly improves the automation and accuracy of document classification, reduces the cost of manual intervention, and is suitable for large-scale classification scenarios of document collections from multiple journal sources.
[0059] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A document classification method based on the Transformer model, characterized in that, The method steps include: S1. Obtain the classified document sample files and save each document sample file to the folder corresponding to its respective journal, with the folder name corresponding to the journal name; S2. Perform image processing on each document sample file, extract the portion of the first page containing the header features as the first image, and extract the portion of the last page containing the footer features as the second image; combine the first and second images to generate a third image; store the third image in the corresponding folder of the journal. S3. Extract visual feature information from all third images to form a visual feature dataset; and form a category label set based on the journal category corresponding to each third image. S4. Train the Transformer classification model using the visual feature dataset and category label set; output the trained Transformer classification model. S5. Obtain the document to be classified. Use the same image processing, cropping and integration methods as in S2 to generate a corresponding third image and extract visual feature information from the third image. Use the trained Transformer classification model to classify the document based on the extracted visual feature information, output the journal to which the document belongs, and archive the classified document to the corresponding folder of the journal.
2. The document classification method based on the Transformer model according to claim 1, characterized in that, The methods for cropping the first and second images in S2 include: The top half of the homepage is used as the first image, and the bottom half of the last page is used as the second image.
3. The document classification method based on the Transformer model according to claim 2, characterized in that, The phrase "capturing the top half of the homepage as the first image and the bottom half of the last page as the second image" specifically refers to: Starting from the top edge of the homepage, select an area whose height accounts for 30% to 50% of the total page height as the first image; Starting from the bottom edge of the last page, select an area whose height accounts for 30% to 50% of the total page height as the second image.
4. The document classification method based on the Transformer model according to claim 1, characterized in that, The step S2, which integrates the first and second images to generate the third image, specifically includes: The first image and the second image are vertically stitched together in an adjacent order. The stitched images are standardized to the preset pixel size required for the input layer of the Transformer classification model; and the pixel values of the standardized images are normalized.
5. The document classification method based on the Transformer model according to claim 1, characterized in that, The visual feature information in S3 includes the text layout of the header, the text layout of the footer, the font style, the layout structure, and the logo elements.
6. The document classification method based on the Transformer model according to claim 1, characterized in that, Before extracting visual feature information from all third images in step S3, data augmentation processing of the third images is also included. The data augmentation processes include horizontal flipping, random rotation, and color dithering.
7. A document classification method based on the Transformer model according to claim 6, characterized in that, The process of training the Transformer classification model also includes introducing data ablation experiments and policy optimization steps, specifically: Multiple sets of data augmentation ablation experiments were constructed. The complete strategy containing all data augmentation processes was set as the baseline group, and experimental groups were set up to remove horizontal flipping, random rotation, or color dithering operations in sequence. By comparing the convergence characteristics of the loss curves and the trend of the accuracy curves of each experimental group and the baseline group during the training and validation processes, the classification performance of each experimental group is evaluated and the contribution of each data augmentation treatment to the classification performance is quantified, and the contribution ranking is obtained. Optimization strategies are implemented based on contribution ranking and classification performance: enhancements for journals with high contributions exceeding the preset contribution threshold are retained or strengthened; for journal categories with poor classification performance, operations such as supplementing literature sample files, adjusting the weights of the Transformer classification model's attention mechanism, or optimizing the image cropping area are performed.
8. A document classification method based on the Transformer model according to claim 7, characterized in that, The evaluation of the contribution of different visual features to the classification effect adopted a multi-dimensional evaluation index. The multi-dimensional evaluation metrics include accuracy, recall, and F1 score; the process of training the Transformer classification model iterates parameters with the objective function of maximizing the F1 score on the validation set.
9. A document classification system based on the Transformer model, characterized in that, The system applies a document classification method based on the Transformer model as described in any one of claims 1-8. The system includes a sample management module, an image generation module, a feature construction module, a model training module, and a classification and archiving module. The sample management module is used to obtain classified literature sample files and save each literature sample file to the folder corresponding to its respective journal. The image generation module is used to perform image processing on each document sample file, extract the portion of the first page containing header features as the first image, and extract the portion of the last page containing footer features as the second image; integrate the first image and the second image to generate a third image; and store the third image in the corresponding folder of the journal. The feature construction module is used to extract visual feature information from all third images to form a visual feature dataset. A category tag set is formed by the journal category corresponding to each third image; The model training module is used to train a Transformer classification model using a visual feature dataset and a category label set; and outputs the trained Transformer classification model. The classification and archiving module is used to call the output of the document to be classified after being processed by the image generation module and the feature construction module in sequence, and input the output into the trained Transformer classification model to classify the document. The classification and archiving module outputs the journal to which the document to be classified belongs; and archives the classified document to the folder corresponding to the journal.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method as described in any one of claims 1-8.