Document vectorization parallel acceleration method and system
By splitting the document vectorization process into multiple parallel processing stages and using thread pools and container structures, the problem of inefficiency in vectorization of large-scale document libraries is solved, efficient utilization of hardware resources is achieved, and document vectorization is significantly improved. performance.
Patent Information
- Application Number
- CN202410822551.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-06-25
AI Technical Summary
The inefficiency of vectorization in large-scale document libraries results in underutilization of computing resources and becomes a bottleneck in the data processing process.
By splitting the document vectorization process into multiple independent stages, and using parallel processing methods, using file containers, OCR result containers, slicing result containers, and vectorization result containers respectively, a thread pool is constructed for document splitting, OCR recognition, and slicing. and vectorization operations to achieve streaming parallel processing.
It makes full use of hardware resources and significantly improves the performance of document vectorization. It is suitable for large-scale document vectorization problems and has high practical and innovative value.
Smart Images

Figure CN118379750B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of document processing, and in particular to a document vectorization parallel acceleration method and system. Background Art
[0002] With the acceleration of digital transformation, enterprises and government departments have accumulated a large amount of text data, including but not limited to emails, reports, articles, books, etc. Many data are often stored in the form of scanned copies, and OCR (Optical Character Recognition in English, translated into Chinese as optical character recognition) related technologies are needed for text recognition. Document vectorization is a key step in natural language processing. It involves converting text data into a format that can be processed by machine learning models. It is a key technical link in the application and implementation of large models. The vectorization of large-scale document libraries usually involves a lot of computing resources and time. If the vectorization process is inefficient, it will become a bottleneck in the entire data processing process. In order to improve processing efficiency, more machines and equipment are often required to process simultaneously. In fact, some current document vectorization solutions are not applicable to the vectorization problem of large-scale documents. The computing resources of the hardware are not fully utilized. The way to increase the speed by stacking hardware resources is essentially a waste of resources.
[0003] The low efficiency of vectorization of large-scale document libraries is a technical problem that needs to be solved. Summary of the invention
[0004] The technical task of the present invention is to address the above shortcomings and provide a document vectorization parallel acceleration method and system to solve the technical problem of low vectorization efficiency of large-scale document libraries.
[0005] In a first aspect, the present invention provides a document vectorization parallel acceleration method, comprising the following steps:
[0006] Split the scanned document into images according to page numbers and store all image file names in a file container;
[0007] Define and initialize an OCR result container, where the OCR result container is used to store the output result of the OCR recognition model;
[0008] Build an OCR thread pool. Each thread obtains an image from the image file, recognizes the text content of the image through the OCR recognition model, and stores the text content in the OCR result container.
[0009] Define and initialize a slicing result container, the slicing result container is used to store the document content slicing result, the document content slicing result includes document metadata information, and the document metadata information includes a document page number and a fragment ID;
[0010] Build a model slicing thread pool. Each model slicing thread obtains a piece of data from the OCR result container, slices the obtained data using a predefined slicing method, and obtains the document content slicing result.
[0011] Define and initialize a vectorization result container, where the vectorization result container is used to store the document content vectorization result;
[0012] Build a document vectorization thread pool. Each document vectorization thread pool obtains a piece of data from the slice result container, performs vectorization operations on the obtained data based on a predefined text vectorization model, and obtains the document content vectorization result.
[0013] Integrate document vectorization results based on the metadata information of the vectorization results and downstream needs, and store the document vectorization results in a specified database or temporary container.
[0014] Preferably, the file container, OCR result container, slice result container, and vectorization result container include arrays or linked lists.
[0015] Preferably, the segmentation method includes segmentation by word count and segmentation by paragraphs.
[0016] Preferably, the text vectorization model supports customization and supports various text vectorization models.
[0017] In a second aspect, the present invention provides a document vectorization parallel acceleration system, which is used to implement document vectorization parallel acceleration through a document vectorization parallel acceleration method as described in any one of the first aspects, the system comprising a document splitting module, a result container definition module, an OCR thread pool construction module, a slice result container definition module, a slice thread pool construction module, a vectorization result container construction module, a document vectorization thread pool construction module, and a document vectorization result construction module;
[0018] The document splitting module is used to perform the following: split the scanned document into pictures according to page numbers, and store all picture file names in a file container;
[0019] The result container definition module is used to perform the following: define and initialize an OCR result container, and the OCR result container is used to store the output result of the OCR recognition model;
[0020] The OCR thread pool construction module is used to perform the following: construct an OCR thread pool, each thread obtains an image from an image file, and recognizes the text content of the image through an OCR recognition model, and stores the text content in an OCR result container;
[0021] The slicing result container definition module is used to perform the following: define and initialize a slicing result container, the slicing result container is used to store the document content slicing result, the document content slicing result includes document metadata information, and the document metadata information includes a document page number and a fragment ID;
[0022] The slicing thread pool construction module is used to perform the following: construct a model slicing thread pool, each model slicing thread obtains a piece of data from the OCR result container, slices the obtained data using a predefined slicing method, and obtains a document content slicing result;
[0023] The vectorization result container construction module is used to perform the following: define and initialize a vectorization result container, and the vectorization result container is used to store the document content vectorization result;
[0024] The document vectorization thread pool construction module is used to perform the following: construct a document vectorization thread pool, each document vectorization thread pool obtains a piece of data from the slice result container, performs vectorization operation on the obtained data based on a predefined text vectorization model, and obtains the document content vectorization result;
[0025] The document vectorization result construction module is used to perform the following: integrate the document vectorization results, integrate the document vectorization results according to the metadata information of the vectorization results and in combination with downstream needs, and store the document vectorization results in a specified database or temporary container.
[0026] Preferably, the file container, OCR result container, slice result container, and vectorization result container include arrays or linked lists.
[0027] Preferably, the segmentation method includes segmentation by word count and segmentation by paragraphs.
[0028] Preferably, the text vectorization model supports customization and supports various text vectorization models.
[0029] The document vectorization parallel acceleration method and system of the present invention have the following advantages:
[0030] 1. First, analyze the document vectorization process and divide it into multiple independent stages. Each stage uses a parallel approach to obtain data from the container and put the processing results into a new container. The interaction between the data processing thread and the container is controlled by a sleep-wake mechanism.
[0031] 2. Since each stage is completely independent, streaming parallelism can also be achieved;
[0032] 3. It can make full use of hardware resources and greatly improve the performance of document vectorization. It is suitable for the vectorization problem of large-scale documents and has high practical and innovative value. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0034] The present invention is further described below in conjunction with the accompanying drawings.
[0035] Figure 1 This is a flowchart of a document vectorization parallel acceleration method according to Example 1. DETAILED DESCRIPTION
[0036] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it. However, the embodiments are not intended to limit the present invention. In the absence of conflict, the embodiments of the present invention and the technical features in the embodiments may be combined with each other.
[0037] The embodiments of the present invention provide a document vectorization parallel acceleration method and system for solving the technical problem of low vectorization efficiency of large-scale document libraries.
[0038] Embodiment 1: A document vectorization parallel acceleration method of the present invention comprises the following steps:
[0039] Step S100 splits the scanned document into pictures according to page numbers, and stores all picture file names in a file container, which includes an array, a linked list, and the like.
[0040] Step S200 defines and initializes an OCR result container, which is used to store the output result of the OCR recognition model. The OCR result container includes an array, a linked list, etc.
[0041] Step S300 builds an OCR thread pool, each thread obtains a picture from the picture file, recognizes the text content of the picture through the OCR recognition model, and stores the text content in the OCR result container.
[0042] Step S400 defines and initializes a slicing result container, which is used to store document content slicing results. The document content slicing results include document metadata information, which includes document page numbers and fragment IDs. The slicing result container includes arrays, linked lists, etc.
[0043] Step S500 builds a model slicing thread pool. Each model slicing thread obtains a piece of data from the OCR result container, slices the obtained data using a predefined slicing method, and obtains a document content slicing result. The predefined slicing methods include slicing by word count, slicing by paragraph, and the like.
[0044] Step S600 defines and initializes a vectorization result container, which is used to store the vectorization result of the document content. The vectorization result container includes an array, a linked list, and the like.
[0045] Step S700 builds a document vectorization thread pool, each document vectorization thread pool obtains a piece of data from the slice result container, performs vectorization operation on the obtained data based on a predefined text vectorization model, and obtains a document content vectorization result.
[0046] Step S800 integrates the document vectorization results according to the metadata information of the vectorization results and in combination with downstream needs, and stores the document vectorization results in a designated database or temporary container.
[0047] The method of this embodiment analyzes the process of document vectorization and divides the document vectorization process into multiple independent stages. Each stage uses a parallel method to obtain data from the container and put the processing results into a new container. The interaction between the data processing thread and the container is controlled by a sleep wake-up mechanism. At the same time, since each stage is completely independent, streaming parallelism can also be achieved. Through the above method, hardware resources can be fully utilized, the performance of document vectorization can be greatly improved, and it is suitable for the vectorization problem of large-scale documents, with high practical value and innovation value.
[0048] Embodiment 2: The present invention provides a document vectorization parallel acceleration system, comprising a document splitting module, a result container definition module, an OCR thread pool construction module, a slicing result container definition module, a slicing thread pool construction module, a vectorization result container construction module, a document vectorization thread pool construction module, and a document vectorization result construction module. The system can execute the method disclosed in Embodiment 1 to achieve document vector parallelization acceleration.
[0049] The document splitting module is used to perform the following: split the scanned document into pictures according to page numbers, and store all picture file names in a file container, which includes an array, a linked list, etc.
[0050] The result container definition module is used to perform the following: define and initialize an OCR result container, the OCR result container is used to store the output result of the OCR recognition model, and the OCR result container includes an array, a linked list, etc.
[0051] The OCR thread pool construction module is used to perform the following: construct an OCR thread pool, each thread obtains an image from the image file, and recognizes the text content of the image through the OCR recognition model, and stores the text content in the OCR result container.
[0052] The slicing result container definition module is used to perform the following: define and initialize a slicing result container, which is used to store document content slicing results. The document content slicing results include document metadata information. The document metadata information includes document page numbers and fragment IDs. The slicing result container includes arrays, linked lists, etc.
[0053] The slicing thread pool construction module is used to perform the following: build a model slicing thread pool, each model slicing thread obtains a piece of data from the OCR result container, slices the obtained data using a predefined slicing method, and obtains the document content slicing result. The predefined slicing methods include slicing by word count, slicing by paragraph, and other methods.
[0054] The vectorization result container construction module is used to perform the following: define and initialize a vectorization result container, the vectorization result container is used to store the vectorization result of the document content, and the vectorization result container includes an array, a linked list, etc.
[0055] The document vectorization thread pool construction module is used to perform the following: construct a document vectorization thread pool, each document vectorization thread pool obtains a piece of data from the slice result container, performs vectorization operations on the obtained data based on a predefined text vectorization model, and obtains the document content vectorization result.
[0056] The document vectorization result construction module is used to perform the following: integrate the document vectorization results, integrate the document vectorization results according to the metadata information of the vectorization results and in combination with downstream needs, and store the document vectorization results in a specified database or temporary container.
[0057] The present invention has been shown and described in detail above through the accompanying drawings and preferred embodiments. However, the present invention is not limited to these disclosed embodiments. Based on the above multiple embodiments, those skilled in the art can know that the means in the above different embodiments can be combined to obtain more embodiments of the present invention, and these embodiments are also within the protection scope of the present invention.
Claims
1. A document vectorization parallel acceleration method, characterized in that: The steps include: Split the scanned document into images according to page numbers and store all image file names in a file container; Define and initialize an OCR result container, where the OCR result container is used to store the output result of the OCR recognition model; Build an OCR thread pool. Each thread obtains an image from the image file, recognizes the text content of the image through the OCR recognition model, and stores the text content in the OCR result container. Define and initialize a slicing result container, the slicing result container is used to store the document content slicing result, the document content slicing result includes document metadata information, and the document metadata information includes a document page number and a fragment ID; Build a model slicing thread pool. Each model slicing thread obtains a piece of data from the OCR result container, slices the obtained data using a predefined slicing method, and obtains the document content slicing result. Define and initialize a vectorization result container, where the vectorization result container is used to store the document content vectorization result; Build a document vectorization thread pool. Each document vectorization thread pool obtains a piece of data from the slice result container, performs vectorization operations on the obtained data based on a predefined text vectorization model, and obtains the document content vectorization result. Integrate document vectorization results based on the metadata information of the vectorization results and downstream needs, and store the document vectorization results in a specified database or temporary container.
2. The document vectorization parallel acceleration method according to claim 1, characterized in that: The file container, OCR result container, slice result container, and vectorization result container include arrays or linked lists.
3. The document vectorization parallel acceleration method according to claim 1, characterized in that: Slicing methods include segmentation by word count and segmentation by paragraphs.
4. The document vectorization parallel acceleration method according to claim 1, characterized in that: The text vectorization model supports customization and supports various text vectorization models.
5. A document vectorization parallel acceleration system, characterized in that: Used to realize document vectorization parallel acceleration by a document vectorization parallel acceleration method according to any one of claims 1 to 4, the system comprising a document splitting module, a result container definition module, an OCR thread pool construction module, a slice result container definition module, a slice thread pool construction module, a vectorization result container construction module, a document vectorization thread pool construction module, and a document vectorization result construction module; The document splitting module is used to perform the following: split the scanned document into pictures according to page numbers, and store all picture file names in a file container; The result container definition module is used to perform the following: define and initialize an OCR result container, and the OCR result container is used to store the output result of the OCR recognition model; The OCR thread pool construction module is used to perform the following: construct an OCR thread pool, each thread obtains an image from an image file, and recognizes the text content of the image through an OCR recognition model, and stores the text content in an OCR result container; The slicing result container definition module is used to perform the following: define and initialize a slicing result container, the slicing result container is used to store the document content slicing result, the document content slicing result includes document metadata information, and the document metadata information includes a document page number and a fragment ID; The slicing thread pool construction module is used to perform the following: construct a model slicing thread pool, each model slicing thread obtains a piece of data from the OCR result container, slices the obtained data using a predefined slicing method, and obtains a document content slicing result; The vectorization result container construction module is used to perform the following: define and initialize a vectorization result container, and the vectorization result container is used to store the document content vectorization result; The document vectorization thread pool construction module is used to perform the following: construct a document vectorization thread pool, each document vectorization thread pool obtains a piece of data from the slice result container, performs vectorization operation on the obtained data based on a predefined text vectorization model, and obtains the document content vectorization result; The document vectorization result construction module is used to perform the following: integrate the document vectorization results, integrate the document vectorization results according to the metadata information of the vectorization results and in combination with downstream needs, and store the document vectorization results in a specified database or temporary container.
Citation Information
Patent Citations
General crawler engine system used for WEB service and working method thereof
CN102184227A
Document processing method and system based on natural language and knowledge graph
CN116501875A
