Data storage method and apparatus
By associating the parsing results with the original files when storing unstructured data, and using AI chips for text extraction and layout parsing, the problem of users having a large workload in secondary file processing is solved, improving access efficiency and resource utilization.
Patent Information
- Application Number
- PCT/CN2025/075324
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-08-14
- Filing Date
- 2025-01-26
- Publication Date
- 2026-02-19
AI Technical Summary
In existing technologies, after unstructured data is stored, users need to manually configure algorithms to extract the data, resulting in a large workload for secondary file processing.
When storing unstructured data, the parsing results are associated with the original file, and an AI chip is used to extract text or parse the layout to generate outline information, which is then accessed quickly through a mapping table.
It reduces the amount of secondary processing work required for users to access unstructured data each time, improves access efficiency and resource utilization, and adapts to the hardware conditions of different computing devices.
Smart Images

Figure CN2025075324_19022026_PF_FP_ABST
Abstract
Description
Data storage method and device
[0001] The present application claims priority to the Chinese Patent Application No. 202411118825.3, filed on August 14, 2024, entitled “Data storage method and device”, the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD
[0002] The present application relates to the field of storage, and in particular, to a data storage method and device. BACKGROUND
[0003] Generally, for unstructured data, the data structure is irregular or incomplete, there is no predefined data model, and it is not convenient to use a two-dimensional logical table of a database to represent it. For example, unstructured data includes all formats of office documents, texts, pictures, extensible markup language (XML) data, images, and audio / video information, etc.
[0004] In the current scheme, after the unstructured data is stored, if a user wants to access the unstructured data to extract the required data, the user needs to manually configure the corresponding algorithm to parse the unstructured data according to different data content extraction requirements for the stored unstructured data, which has the problem of a large amount of work for the user to process the file twice. SUMMARY
[0005] The present application provides a data storage method and device to solve the problem of a large amount of work for the user to process the file twice.
[0006] In a first aspect, a data storage method is provided, applied to a computing device. The method includes: obtaining a PDF file; parsing the PDF file to obtain a parsing result; the parsing result includes text information obtained by text extraction of the PDF file, or outline information of the PDF file; associating the parsing result and the PDF file to obtain a to-be-stored file; the to-be-stored file includes the PDF file and the parsing result; and storing the to-be-stored file.
[0007] Based on the above data storage method, when storing unstructured data such as a PDF file, in addition to storing the original file of the PDF file, the parsing result of the PDF file is associated with the PDF file and then stored together. In this way, when a user subsequently accesses the PDF file, the user can simultaneously access the parsing result corresponding to the PDF file, avoiding the user manually performing algorithm parsing on the PDF file each time to obtain the required data, and reducing the amount of work for the user to process the file twice.
[0008] With reference to the data storage method provided in the first aspect, as a possible implementation manner, the PDF file and the parsing result corresponding to the PDF file are associated. For example, the file identifier of the PDF file is mapped with the file identifier of the parsing result in a mapping table. In this way, the PDF file and the parsing result are associated based on the file identifier, and the parsing result of the PDF file can be obtained at any time when the user accesses the PDF file after the PDF file and the parsing result are stored, thereby improving the access efficiency of the user to the PDF file.
[0009] With reference to the data storage method provided in the first aspect, as a possible implementation manner, the parsing result of the PDF file can be matched with the hardware basis of the device of the user. For example, it is detected whether the computing device includes an AI chip; if the computing device does not include the AI chip, text extraction is performed on the PDF file to obtain a parsing result; the parsing result includes text information obtained by text extraction; the file to be stored includes the text information obtained by text extraction and the PDF file; if the computing device includes the AI chip, the PDF file is parsed using the AI chip to obtain a parsing result; the parsing result includes outline information.
[0010] In this way, when the unstructured data is stored in the form of a PDF file, the storage manner of the unstructured data can be determined in combination with the hardware condition of the computing device, so that the storage of the unstructured data conforms to the hardware condition of the computing device of the user, the resource utilization rate of the AI chip or the conventional central processing unit (CPU) of the computing device is improved, and the flexibility of storing the unstructured data is improved.
[0011] With reference to the data storage method provided in the first aspect, as a possible implementation manner, the computing device can input the PDF file into a layout parsing model running on the AI chip to obtain a layout parsing result output by the layout parsing model. The layout parsing result includes elements of various categories in the PDF file and coordinate frames of the elements of various categories. Then, the computing device determines the outline information according to the positional relationship between the coordinate frames of the elements of various categories. In this way, the layout of the PDF file is parsed by the AI chip and the outline information is output, thereby avoiding subsequent manual algorithm parsing of the user based on the parsing result of the PDF file, and reducing the workload of the user for processing the file twice.
[0012] Optionally, the categories include a title and a body, and the title includes at least one level of title.
[0013] With reference to the data storage method provided in the first aspect, as a possible implementation manner, the computing device determines the association relationship between the headings of at least one level and the body text according to the positional relationship between the coordinate frames of the elements of the categories; the association relationship is used to indicate the body text associated with any level of heading. The computing device extracts the content information of the body text associated with the headings of each level, and determines the outline information according to the association relationship and the content information of the body text associated with the headings of each level. In this way, the outline information is generated according to the association relationship between the headings of each level and the body text in the PDF file, thereby ensuring the accuracy of the outline information.
[0014] With reference to the data storage method provided in the first aspect, as a possible implementation manner, the body text includes text.
[0015] Optionally, the computing device inputs the headings of each level and the text associated with the headings of each level into an optical character recognition model running on the AI chip to obtain the text content of the text of the headings of each level and the text associated with the headings of each level output by the optical character recognition model; and matches the headings of each level, the text content of the text associated with the headings of each level, and the coordinate frames of the elements of the categories, respectively.
[0016] With reference to the data storage method provided in the first aspect, as a possible implementation manner, the body text includes a table.
[0017] Optionally, the computing device inputs the headings of each level into an optical character recognition model running on the AI chip to obtain the text content of the text of the headings of each level output by the optical character recognition model; inputs the table associated with the headings of each level into a structure detection model running on the AI chip to obtain at least one cell of the table associated with the headings of each level output by the structure detection model; inputs the at least one cell into an optical character recognition model running on the AI chip to obtain the text content contained in the at least one cell output by the optical character recognition model; clusters the text content contained in the at least one cell based on the row and column division of the cell to obtain the index types of the rows and columns of the at least one cell output by the table recognition model; and matches the headings of each level, the index types of the table associated with the headings of each level, and the coordinate frames of the elements of the categories, respectively.
[0018] In this way, for different types of data such as text and tables in the body text, corresponding content extraction methods can be used to extract content information, thereby improving the applicability of the data storage method provided in the embodiments of the present application.
[0019] With reference to the data storage method provided in the first aspect, as a possible implementation manner, the computing device extracts semantic information of the headings of each level and the body text associated with the headings of each level, and corrects the association relationship between the headings of each level and the body text in the outline information according to the semantic information. In this way, the association relationship between the headings of each level and the body text in the outline information is corrected in combination with the semantic information, thereby improving the accuracy of the outline information.
[0020] With the data storage method provided in the first aspect, as a possible implementation manner, the computing device can further return the PDF file and the parsing result corresponding to the PDF file to the user when the PDF file is accessed after storing the file to be stored. The computing device receives a data access request; the data access request includes a file identifier of the PDF file; queries the file identifier of the parsing result in the mapping table according to the file identifier of the PDF file; queries the metadata according to the file identifier of the PDF file and the file identifier of the parsing result to obtain the storage address of the PDF file and the storage address of the parsing result; returns a data access response; the data access response includes data stored in the storage address of the PDF file and data stored in the storage address of the parsing result.
[0021] In a second aspect, a data storage apparatus is provided. The data storage apparatus includes an obtaining module, a parsing module and a storage module. The obtaining module is configured to obtain a PDF file. The parsing module is configured to parse the PDF file to obtain a parsing result, the parsing result including text information obtained by text extraction on the PDF file or outline information of the PDF file. The parsing module is further configured to associate the parsing result with the PDF file to obtain a file to be stored, the file to be stored including the PDF file and the parsing result. The storage module is configured to store the file to be stored.
[0022] With the data storage apparatus provided in the second aspect, as a possible implementation manner, the parsing module is specifically configured to map the file identifier of the PDF file and the file identifier of the parsing result in a mapping table.
[0023] With the data storage apparatus provided in the second aspect, as a possible implementation manner, the parsing module is specifically configured to detect whether the computing device includes an AI chip; if the computing device does not include the AI chip, perform text extraction on the PDF file to obtain the parsing result, the parsing result including text information obtained by the text extraction; if the computing device includes the AI chip, use the AI chip to parse the PDF file to obtain the parsing result, the parsing result including outline information.
[0024] With the data storage apparatus provided in the second aspect, as a possible implementation manner, the parsing module is specifically configured to input the PDF file into a layout parsing model running on the AI chip to obtain a layout parsing result output by the layout parsing model, the layout parsing result including elements of various categories in the PDF file and coordinate frames of the elements of various categories; and determine the outline information according to the positional relationship between the coordinate frames of the elements of various categories.
[0025] With the data storage apparatus provided in the second aspect, as a possible implementation manner, the categories include a title and a body, and the title includes at least one level of title.
[0026] With reference to the data storage apparatus provided in the second aspect, as a possible implementation manner, the parsing module is specifically configured to: determine the association relationship between the headings of at least one level and the body text according to the positional relationship between the coordinate frames of the elements of each category; the association relationship is used to indicate the body text associated with any level heading; extract content information of the body text associated with the headings of each level; and determine the outline information according to the association relationship and the content information of the body text associated with the headings of each level.
[0027] With reference to the data storage apparatus provided in the second aspect, as a possible implementation manner, the body text includes text. The parsing module is specifically configured to: input the headings of each level and the text associated with the headings of each level into an optical character recognition model running on the AI chip to obtain text content of the headings of each level and the text associated with the headings of each level output by the optical character recognition model; and match the headings of each level, the text content of the text associated with the headings of each level, and the coordinate frames of the elements of each category, respectively.
[0028] With reference to the data storage apparatus provided in the second aspect, as a possible implementation manner, the body text includes a table. The parsing module is specifically configured to: input the headings of each level into an optical character recognition model running on the AI chip to obtain text content of the text of the headings of each level output by the optical character recognition model; input the table associated with the headings of each level into a structure detection model running on the AI chip to obtain at least one cell of the table associated with the headings of each level output by the structure detection model; input the at least one cell into an optical character recognition model running on the AI chip to obtain text content contained in the at least one cell output by the optical character recognition model; cluster the text content contained in the at least one cell based on row and column division of the cell to obtain index types of rows and columns of the at least one cell output by the table recognition model; and match the headings of each level, the index types of the table associated with the headings of each level, and the coordinate frames of the elements of each category, respectively.
[0029] With reference to the data storage apparatus provided in the second aspect, as a possible implementation manner, the body text includes a table. The parsing module is specifically configured to: extract semantic information of the headings of each level and the body text associated with the headings of each level; and correct the association relationship between the headings of each level and the body text in the outline information according to the semantic information.
[0030] With reference to the data storage apparatus provided in the second aspect, as a possible implementation manner, the data storage apparatus further includes a query module and a response module. The obtaining module is further configured to receive a data access request, and the data access request includes the file identifier of the PDF file. The query module is configured to query, according to the file identifier of the PDF file, the file identifier of the parsing result in the mapping table, and query, according to the file identifier of the PDF file and the file identifier of the parsing result, the metadata to obtain the storage address of the PDF file and the storage address of the parsing result. The response module is configured to return a data access response, and the data access response includes data stored in the storage address of the PDF file and data stored in the storage address of the parsing result.
[0031] With reference to the data storage apparatus provided in the second aspect, as a possible implementation manner, the data storage apparatus can further include other modules for performing the operation steps of the data storage method of the first aspect.
[0032] For the technical principles and beneficial effects of the second aspect, reference can be made to the related description of the first aspect, which will not be repeated here.
[0033] In the third aspect, a computing device is provided, including a memory and a processor, and the memory stores at least one instruction, which is loaded and executed by the processor to implement the data storage method of any possible implementation manner of the first aspect.
[0034] In the fourth aspect, a computer program (product) is provided, which includes computer program code, and when the computer program code is run by a computer, the computer device executes the data storage method of any possible implementation manner of the first aspect.
[0035] In the fifth aspect, a chip is provided, including a processor, which is used to call and run instructions stored in a memory, so that a computing device installed with the chip executes the data storage method of any possible implementation manner of the first aspect.
[0036] In the sixth aspect, another chip is provided, including an input interface, an output interface, a processor and a memory, which are connected through internal connection paths. The processor is used to execute code in the memory, and when the code is executed, the processor is used to execute the data storage method of any possible implementation manner of the first aspect.
[0037] In a seventh aspect, a computer readable storage medium is provided, and the storage medium stores at least one instruction, which is loaded and executed by a processor to implement the data storage method according to any possible implementation manner of the first aspect. BRIEF DESCRIPTION OF DRAWINGS
[0038] Fig. 1 is a structural schematic diagram of a data storage system provided by the present application;
[0039] Fig. 2 is a structural schematic diagram of a controller provided by the present application;
[0040] Fig. 3a is a flow schematic diagram of a data storage method provided by the present application;
[0041] Fig. 3b is a flow schematic diagram of an analysis step of a PDF file provided by the present application;
[0042] Fig. 4 is a schematic diagram of a category of elements provided by the present application;
[0043] Fig. 5 is a schematic diagram of outline information provided by the present application;
[0044] Fig. 6 is a flow schematic diagram of an analysis step of outline information provided by the present application;
[0045] Fig. 7 is a structural schematic diagram of a data storage device provided by the present application;
[0046] Fig. 8 is a structural schematic diagram of a computing device provided by the present application. DETAILED DESCRIPTION
[0047] Unstructured data analysis refers to analyzing unstructured data to extract effective data required by a user. For example, an enterprise or an individual produces a technical document in a portable document format (PDF) format in a certain technical field, and the document contains technical processes or statistical data required by the enterprise or the individual. Therefore, the enterprise or the individual needs to perform unstructured data analysis on the unstructured data, i.e., the technical document.
[0048] The application provides a data storage method and device. The data storage method is executed by a computing device. The computing device obtains a PDF file, parses the PDF file, and obtains a parsing result. The parsing result includes text information obtained by text extraction of the PDF file or outline information of the PDF file. Then, the computing device associates the parsing result with the PDF file, obtains a to-be-stored file, and stores the to-be-stored file. In this way, when storing unstructured data such as a PDF file, the parsing result of the PDF file is associated with the PDF file and stored together. In this way, when a user subsequently accesses the PDF file, the user can simultaneously access the parsing result corresponding to the PDF file, avoiding manual algorithm parsing of the PDF file each time the user accesses the PDF file to obtain required data, and reducing the workload of the user for processing the file again.
[0049] The technical solutions involved in the application can be applied not only to the current storage field or storage device, but also to future storage fields or storage devices, or storage systems including storage devices. The terms used in the embodiment part of the application are only used to explain the specific embodiments of the application, and are not intended to limit the application. First, some concepts that may be involved in the application are briefly introduced.
[0050] Unstructured data: refers to data that cannot be represented and stored in a traditional tabular structure (table, database) and lacks a clear pattern and format. In contrast, structured data has a clear data structure and format, and is easy to organize and analyze. Unstructured data includes but is not limited to text, images, audio, video, and other forms of data, such as PDF files.
[0051] AI chip: also known as AI accelerator or computing card, is a module specially designed for processing large amounts of computing tasks in artificial intelligence applications. For example, graphics processing units (GPUs) with AI processing capabilities, neural network processing units (NPUs), etc.
[0052] In order to make the purpose, technical solutions and advantages of the application clearer, the application will be described in further detail below with reference to the accompanying drawings.
[0053] Hereinafter, the terms "first", "second", etc. are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined with "first", "second", etc. can explicitly or implicitly include one or more features. In the description of the application, unless otherwise stated, the meaning of "multiple" is two or more.
[0054] In addition, in the present application, the orientation terms such as "upper", "lower" and the like are defined with respect to the orientation in which the components are placed in the drawings, and it should be understood that these directional terms are relative concepts, which are used for relative description and clarification, and can be changed accordingly according to the change of the orientation in which the components are placed in the drawings.
[0055] For unstructured data such as a PDF file, text extraction of the PDF file can be implemented in some existing ways. For example, open source tools such as a Python library can implement text extraction of the PDF file. However, after the PDF file is written to a disk, the user needs to manually configure corresponding algorithms to parse the unstructured data according to different data content extraction requirements when the user accesses the PDF file to obtain the required data, which causes the problem of large workload of the user for secondary processing of the file.
[0056] To solve the above problem, the scene to which the embodiments of the present application are applied will be first introduced below in combination with the drawings.
[0057] FIG. 1 is a structural schematic diagram of a data storage system provided by the present application. The data storage system includes a data access device 100 and a storage device 120. In the application scenario shown in FIG. 1, the user accesses data through an application program (not shown in FIG. 1) in the data access device 100. The computer (such as the data access device 100) running these application programs can be referred to as a "computing device".
[0058] The data access device 100 can be a physical machine, a virtual machine, or a container. The physical machine can include one or both of a user end and a smart NIC. For example, the data access device 100 includes a user end. The user end can refer to a client, such as a host, a desktop computer, a server, a notebook computer, a mobile device, and the like. For another example, the data access device 100 includes a smart NIC. The smart NIC, also referred to as a smart network adapter, provides a built-in programmable and configurable hardware acceleration engine in addition to the network transmission function of a standard network card, improves the performance of an application, and greatly reduces the consumption of a CPU in communication in a host connected to the smart NIC, and provides more CPU resources for the application. For example, in a highly virtualized environment, a CPU in a host needs to run open virtual switch (OVS) related tasks, and the CPU in the host also needs to process storage, online or offline encryption and decryption of data packets, deep packet inspection, firewall, complex routing, and the like. These operations not only consume a large amount of CPU resources, but also cause the performance of services to be unable to be best due to the contention of CPU resources among different services. The smart NIC serves as a hub connecting various services, and accelerates the services on the smart NIC.
[0059] In one possible example, the data access device 100 accesses the storage device 120 through a network to access data. For example, the network can include the switch 110.
[0060] In another possible example, the data access device 100 can also communicate with the storage device 120 through a wired connection, such as a universal serial bus (USB) or a peripheral component interconnect express (PCIe) bus, and the like.
[0061] The storage device 120 shown in FIG. 1 can be a centralized storage system. The centralized storage system has the feature of having a unified entrance through which all data from external devices passes, and the entrance is an engine 121 of the centralized storage system. The engine 121 has a management function, and many advanced functions of the storage system are implemented therein.
[0062] As shown in FIG. 1, the engine 121 can have one or more controllers. FIG. 1 illustrates an example in which the engine 121 includes one controller. In one possible example, if the engine 121 has multiple controllers, any two controllers can have a mirror channel to implement a function of backing up each other, so as to avoid a hardware failure leading to an unavailability of the entire storage device 120. It should be understood that if the engine 121 includes multiple controllers, the engine 121 can also be referred to as an array controller of the storage device 120.
[0063] The engine 121 also includes a front-end interface 1211 and a back-end interface 1214. The front-end interface 1211 is configured to communicate with the data access device 100, so as to provide a data access service for the data access device 100. The back-end interface 1214 is configured to communicate with the hard disks, so as to expand the capacity of the storage device 120. Through the back-end interface 1214, the engine 121 can connect more hard disks, so as to form a very large storage resource pool.
[0064] In hardware, as shown in FIG. 1, the controller includes at least a processor 1212 and a memory 1213. The processor 1212 is a central processing unit (CPU) configured to process a data access request from outside the storage device 120 (a server or other storage system), and also configured to process a request generated inside the storage device 120. For example, when the processor 1212 receives a write data request sent by the data access device 100 through the front-end interface 1211, the processor 1212 temporarily stores data in the write data request in the memory 1213. When the total amount of data in the memory 1213 reaches a certain threshold, the processor 1212 sends the data stored in the memory 1213 to at least one of the mechanical hard disk 1221, the solid state drive (SSD) 1222, or other hard disks 1224 through the back-end interface, for persistent storage.
[0065] The memory 1213 refers to an internal memory that exchanges data directly with the processor. It can read and write data at any time and has a very fast speed, and is used as a temporary data storage for the operating system or other programs running at the moment. The memory includes at least two types of memories, for example, the memory can be a random access memory or a read only memory (ROM). For example, the random access memory is a DRAM or an SCM. The DRAM is a semiconductor memory, and like most random access memories (RAMs), it is a volatile memory device. However, the DRAM and the SCM are only exemplary in this embodiment, and the memory can also include other random access memories, such as static random access memories (SRAM) and the like. As for the read only memory, for example, it can be a programmable read only memory (PROM), an erasable programmable read only memory (EPROM), and the like. In addition, the memory 1213 can also be a dual in-line memory module (DIMM), that is, a module composed of dynamic random access memories (DRAM), and can also be an SSD. In practical applications, multiple memories 1213 can be configured in the controller, and memories 1213 of different types can also be configured. The number and type of the memory 1213 are not limited in this embodiment. In addition, the memory 1213 can be configured to have a power retention function. The power retention function refers to that when the system is powered off and then powered on again, the data stored in the memory 1213 will not be lost. The memory with the power retention function is called a non-volatile memory. The memory 1213 stores software programs, and the processor 1212 runs the software programs in the memory 1213 to achieve the management of the hard disk. For example, the hard disk is abstracted as a storage resource pool, and the storage resource pool is provided to the server in the form of a logical unit number (LUN). The LUN is actually the hard disk seen on the server. Of course, some centralized storage systems themselves are file servers, which can provide shared file services for servers.
[0066] As shown in FIG. 1, in the system, the engine 121 can not have a hard disk slot, and the hard disk needs to be placed in the hard disk frame 122, and the back-end interface 1214 communicates with the hard disk frame 122. The back-end interface 1214 exists in the engine 121 in the form of an adapter card, and two or more back-end interfaces 1214 can be used simultaneously on one engine 121 to connect multiple hard disk frames. Alternatively, the adapter card can also be integrated on the mainboard, at which time the adapter card can communicate with the processor 1212 through the PCIe bus.
[0067] It should be noted that only one engine 121 is shown in FIG. 1, but in actual application, two or more engines 121 can be included in the storage system, and redundancy or load balancing is performed between the multiple engines 121.
[0068] The hard disk frame 122 includes a control unit 1225 and several hard disks. The control unit 1225 can have various forms. In one case, the hard disk frame 122 belongs to a smart disk frame as shown in FIG. 1, and the control unit 1225 includes a CPU and a memory. The CPU is used to perform address conversion and read and write data operations. The memory is used to temporarily store data to be written to the hard disk or data read from the hard disk to be sent to the controller. In another case, the control unit 1225 is a programmable electronic component, such as a data processing unit (DPU). The DPU has the versatility and programmability of the CPU, but is more specialized and can efficiently operate on network packets, storage requests, or analysis requests. The DPU is distinguished from the CPU by a greater degree of parallelism (a large number of requests need to be processed). Optionally, the DPU here can also be replaced by a graphics processing unit (GPU), an embedded neural-network processing unit (NPU), etc. In general, the number of control units 1225 can be one, two, or more. The functions of the control unit 1225 can be offloaded to the network card 1226. In other words, in this embodiment, the hard disk frame 122 does not have a control unit 1225 inside, but the data read and write, address conversion, and other computing functions are completed by the network card 1226. At this time, the network card 1226 is a smart network card. It can contain a CPU and a memory. The CPU is used to perform address conversion and read and write data operations. The memory is used to temporarily store data to be written to the hard disk or data read from the hard disk to be sent to the controller. It can also be a programmable electronic component, such as a DPU. There is no ownership relationship between the network card 1226 and the hard disks in the hard disk frame 122, and the network card 1226 can access any hard disk in the hard disk frame 122 (such as the mechanical hard disk 1221, the solid state disk 1222, and the other hard disk 1224 shown in FIG. 1), so it is relatively convenient to expand the hard disk when the storage space is insufficient. In the embodiments of the present application, the other hard disk 1224 can be any type of memory, such as a tape medium memory.
[0069] According to the type of communication protocol between the engine 121 and the hard disk frame 122, the hard disk frame 122 can be a serially connected small computer system interface (SAS) hard disk frame, an NVMe (Non-Volatile Memory express) hard disk frame, and other types of hard disk frames. The SAS hard disk frame adopts the SAS3.0 protocol, and each frame supports 25 SAS hard disks. The engine 121 is connected with the hard disk frame 122 through a built-in SAS interface or a SAS interface module. The NVMe hard disk frame is more like a complete computer system, and the NVMe hard disk is inserted into the NVMe hard disk frame. The NVMe hard disk frame is connected with the engine 121 through an RDMA port. In some cases, the engine 121 can also be referred to as a hard disk management device or a storage controller.
[0070] In terms of hardware implementation, the hard disk frame 122 can be installed in a storage system, or the hard disk frame 122 can be packaged and independently arranged. When the hard disk frame 122 exists independently, the hard disk frame 122 can also be referred to as a storage device or a storage system, which is not limited in the present application.
[0071] In an optional implementation, the storage device 120 is a centralized storage system with a disk control integrated, and the storage device 120 does not have the hard disk frame 122 described above, and the engine 121 is used to manage a plurality of hard disks connected through hard disk slots. The function of the hard disk slot can be implemented by the back-end interface 1214.
[0072] In some optional implementation, the storage device 120 is a distributed storage system. The distributed storage system includes a computing node cluster and a storage node cluster, the computing node cluster includes one or more computing nodes, and each computing node can communicate with each other. The computing node can be a server, a desktop computer, or a controller of a storage array, etc. In hardware, the computing node can include a processor, a memory, a network card, etc. Among them, the processor is a CPU, which is used to process data access requests from outside the computing node, or requests generated inside the computing node. For example, when the processor receives a write data request sent by a user, the processor temporarily saves the data in the write data request in the memory. When the total amount of data in the memory reaches a certain threshold, the processor sends the data stored in the memory to the storage node for persistent storage. In addition, the processor is also used for data computing or processing, such as metadata management, deduplication, data compression, virtual storage space, address translation, etc. In the embodiments provided in the present application, the storage node can be a tape medium storage or other types of hard disk, etc. It can be understood that the storage system described in the embodiments of the present application can be an integrated storage and computing distributed storage system, or a storage and computing separated distributed storage system, which is not limited in the present application.
[0073] For example, the distributed storage system can be implemented by network attached storage (NAS) technology. NAS refers to a network storage architecture that provides storage resources through file-level data access and sharing based on an Internet Protocol (IP) network. In the NAS scenario, the NAS is an external device for the server / host, and the NAS is used to provide file-level storage space for the server / host in the distributed storage system.
[0074] It is worth noting that the above examples only provide possible implementations of the data access system provided by the present embodiment, and should not be construed as a limitation of the present application. For example, the storage device 120 shown in FIG. 1 stores data in the form of files on each hard disk. The files stored in each hard disk constitute a file storage system, which can be a distributed file system, for example. For example, the NAS system can be implemented by the NFS protocol. The network file system is a low-cost network file sharing option that enables users and applications to access, store, and update files on remote computers, just like using direct-attached storage. The network file system uses a remote procedure call protocol to route requests between clients and servers. Although the devices involved need to support the network file system, they do not need to understand the details of the network. It is worth noting that remote procedure calls can not be secure, so the network file system should only be deployed on trusted networks behind a firewall. Although Windows supports the protocol, the protocol is mainly used in the Linux environment.
[0075] For the above controller, an optional example provided by an embodiment of the present application is provided, as shown in FIG. 2, which is a structural schematic diagram of a controller provided by the present application. The controller 200 can be used to implement the function of the controller in the engine 121 of the storage device 120 described above.
[0076] Next, the controller will be described by way of example in conjunction with FIG. 2. The controller 200 includes a computing module 201, an I / O interface 202, and a preprocessing module 203. In addition to describing the controller 200 in FIG. 2, related devices (not shown in FIG. 1) that can be in communication connection with the controller 200 are also described by way of example, such as a training device 204, a database 205, a data storage system 206, a data acquisition device 207, and the like.
[0077] The training device 204 can be an AI chip, a terminal, or other computing devices that support integer computing, such as servers or cloud devices, etc.
[0078] As a possible embodiment, the controller 200 and the training device 204 are deployed on different physical devices (such as a server or a server in a cluster), or the controller 200 and the training device 204 are different physical devices. For example, the controller 200 and the training device 204 are AI chips deployed on different physical devices. For example, the execution device 110 can be a GPU, other general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware component, etc. The training device 204 can be a GPU, NPU, microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the program execution of the scheme of the present application.
[0079] In another possible embodiment, the controller 200 and the training device 204 are deployed on the same physical device, or the controller 200 and the training device 204 are the same physical device.
[0080] The data collection device 207 is used to collect training data and store the training data in the database 205. The data collection device 207 and the controller 200 can be the same or different devices.
[0081] The training device 204 is used to train the neural network using the training data until the loss function in the neural network converges and the loss function value is less than a certain threshold, and the neural network training is completed, so that the neural network reaches a certain accuracy. For example, the training device 204 uses the unstructured data such as the PDF file as the input training data, and uses the outline information as the output, to train the neural network. For another example, the training device 204 uses the table as the input training data, and uses the predicted index type of the row and column of the table as the output, to train the neural network. For another example, the training device 204 uses a page of the PDF file as the input training data, and uses the recognized text content as the output, to train the neural network.
[0082] The training device 204 performs backpropagation according to the loss function during the training process to update the parameters of the neural network with gradients until the value of the loss function is less than a certain threshold. Alternatively, all the training data in the database 205 is used for training, and then the neural network training is completed, so that the trained neural network has the target functions such as layout analysis, character recognition, and table structure recognition. Further, the training device 204 configures the trained neural network 208 to the controller 200. The controller 200 is configured to realize the function of analyzing and storing the unstructured data such as PDF files according to the trained neural network 208.
[0083] The neural network 208 described above can be a model with a single function or a model with multiple functions composed of multiple models. For example, the neural network 208 includes a layout analysis model, an optical character recognition model, and / or a structure detection model.
[0084] The present application does not limit the specific implementation of the layout analysis model, the optical character recognition model, and / or the structure detection model described above. Illustratively, the layout analysis model can be based on a swin transformer as a backbone, with deformable attention as an encoder and a decoder. The optical character recognition model can be an optical character recognition (OCR) network based on a convolutional recurrent neural network (CRNN) adding a transformer. The structure detection model can be a structure detection network based on yolo9.
[0085] In some embodiments, the controller 200 and the training device 204 are the same computing device, which can configure the trained neural network 208 to itself and realize the target functions described above using the trained neural network 208.
[0086] In other embodiments, the training device 204 can configure the trained neural network 208 to multiple controllers 200. Each controller 200 realizes the target functions described above using the trained neural network 208.
[0087] It should be noted that in actual applications, the training data maintained in the database 205 does not necessarily all come from the data acquisition device 207, but can also be received from other devices or apparatuses. In addition, the training device 204 does not necessarily train the neural network based on the training data maintained in the database 205, but can also obtain the training data from the cloud or other places to train the neural network. The above description should not be regarded as a limitation on the embodiments of the present application.
[0088] Further, according to the functions performed by the controller 200, the sub-architectures of the controller 200, such as the computing module 201, the I / O interface 202 and the preprocessing module 203, are described in the following.
[0089] Taking the controller 200 as a storage controller, the computing module 201 can be an AI-capable GPU, CPU, other general-purpose processor, DSP, ASIC, FPGA or other programmable logic device, discrete gate or transistor logic device, discrete hardware component, etc. on the storage controller. The computing module 201 can include one or more AI chips with AI capabilities, or a combination of AI chips and CPUs without AI capabilities, without limitation. For example, the computing module 201 is a functional module corresponding to the processor 1212 in the controller shown in FIG. 1.
[0090] For example, the computing module 201 is configured to run the neural network 208 to implement the function of layout analysis of the neural network 208, to obtain the parsed outline information.
[0091] For another example, the computing module 201 is configured to run the neural network 208 to implement the function of character recognition of the neural network 208, to obtain the text content.
[0092] For another example, the computing module 201 is configured to run the neural network 208 to implement the function of table structure recognition of the neural network 208, to obtain the index types of the rows and columns of the table.
[0093] The I / O interface 202 is configured to interact with external devices or apparatuses. The user can input data to the I / O interface 202 through the external devices or apparatuses, for example, instructions for instructing the controller 200 to start executing the data storage method. In addition, the input data can also come from the database 205.
[0094] The preprocessing module 203 is configured to preprocess the input data received by the I / O interface 202. In the embodiments of the present application, the preprocessing module 203 can be configured to generate training data, such as training set, validation set and test set, according to the input data received from the I / O interface 202.
[0095] During the preprocessing of the input data by the controller 200, or during the calculation and other related processes performed by the calculation module 201 of the controller 200, the controller 200 can call data, codes and the like in the data storage system 206 for corresponding processing, and can also store data and instructions obtained through corresponding processing in the data storage system 206. For example, the data storage system 206 can be the memory 1213 or the hard disk frame 122 shown in FIG. 1.
[0096] Finally, the I / O interface 202 can return the processing result to the user terminal, so as to provide the user with the processing result for viewing.
[0097] FIG. 2 is only a schematic diagram provided by the embodiments of the present application, and the positional relationship between the devices, apparatuses, components and modules shown in FIG. 2 does not constitute any limitation. For example, in FIG. 2, the data storage system 206 is an external memory relative to the controller 200, and in other cases, the data storage system 206 can also be placed in the controller 200.
[0098] The following will be exemplarily described by taking the controller 200 performing the data storage method provided by the embodiments of the present application as an example.
[0099] FIG. 3a is a flow schematic diagram of a data storage method provided by the present application, which can be applied to the controller shown in FIG. 1 or FIG. 2. In possible embodiments of the present application, the execution subject of the data storage method is not limited, for example, the data storage method can also be applied to any device with calculation capability and data processing function, for example, the data storage method can be applied to a processor of a computing device with storage function and the like.
[0100] In the embodiments of the present application, the controller is configured with an AI chip and corresponding layout analysis model, optical character recognition model and / or structure detection model. Please refer to FIG. 3a, the data storage method provided by the embodiments of the present application can include the following steps 301-304.
[0101] Step 301, the controller obtains a PDF file.
[0102] The controller obtains a PDF file to be stored. Exemplarily, the PDF file can be generated by an internal application of the computing device to which the controller belongs, or can be sent to the controller by the data access device 100.
[0103] Step 302, the controller analyzes the PDF file to obtain an analysis result.
[0104] The controller selects a mode for analyzing the PDF file according to the hardware of the computing device to which the controller belongs, analyzes the PDF file in the selected mode, and obtains an analysis result.
[0105] Wherein, the hardware of the computing device can refer to whether the computing device is configured with an AI chip. If the computing device is configured with an AI chip, the controller invokes the AI chip to parse the PDF file. If the computing device is not configured with an AI chip, the controller invokes a general processor (such as a CPU) to parse the PDF file.
[0106] As shown in FIG. 3b, the parsing step of the PDF file can include steps 3021-3023.
[0107] Step 3021, the controller detects whether the computing device includes an AI chip.
[0108] The controller detects whether the computing device to which the controller belongs is configured with an AI chip.
[0109] As a possible implementation, the controller queries the hardware information of the computing device to which the controller belongs (for example, the controller can query by command), and determines whether the computing device is configured with an AI chip according to the hardware information.
[0110] Optionally, the controller uses different commands to query the hardware information under different operating systems or development environments. In the case that the hardware information queried by the controller includes information of an AI chip, it is determined that the computing device to which the controller belongs is configured with an AI chip.
[0111] For example, when the operating system is Linux, the corresponding command is grep UUID (universally unique identifier), when the operating system is Windows, the corresponding command is ManagementObjectSearcher, and when the development environment is Python, the corresponding command is psutil or platform.
[0112] Optionally, the computing device to which the controller belongs can refer to the controller itself, and the AI chip can be the computing module 201 of the controller. The computing device to which the controller belongs can also be the storage device 120, and the AI chip can be a GPU or NPU with AI inference capability in the storage device 120 that is in communication connection with the controller.
[0113] Step 3022, if the computing device does not include an AI chip, the controller performs text extraction on the PDF file to obtain a parsing result.
[0114] The controller performs text extraction on the PDF file to obtain a parsing result in the case that the computing device to which the controller belongs is not configured with an AI chip. Wherein, the parsing result includes the text information extracted from the PDF file.
[0115] As a possible implementation, the controller uses a processor without AI inference capability such as a CPU to perform text extraction on the PDF file.
[0116] Optionally, the text extraction described above can be implemented based on a library with a text extraction function in Python, and the application does not limit this.
[0117] The analysis result described above only contains simple text information inside a simple PDF file, occupies less computing resource of a controller or a computing device, and is suitable for a computing device without an AI chip.
[0118] In step 3023, if the computing device includes an AI chip, the controller uses the AI chip to analyze the PDF file to obtain an analysis result.
[0119] The controller analyzes the PDF file to obtain an analysis result in the case that the computing device to which the controller belongs is configured with an AI chip. The analysis result includes outline information parsed from the PDF file.
[0120] As a possible implementation manner, the controller uses an AI chip with AI inference capability to intelligently analyze the PDF file.
[0121] Optionally, the analysis of the outline information described above can be implemented based on a layout analysis model, an optical character recognition model, and a structure detection model.
[0122] For example, the controller runs a layout analysis model through the AI chip to obtain coordinate frames of elements of various categories in the PDF file and the elements of various categories, and outputs the outline information according to the positional relationship between the coordinate frames of the elements of various categories. The controller runs a structure recognition model through the AI chip to output at least one cell of an element of a table type. The controller runs an optical character recognition model through the AI chip to perform text recognition on the elements of various categories, and outputs text content contained in the elements of various categories.
[0123] As shown in FIG. 4, the categories of the elements can include a header, a footer, a title, text, a table, a picture, and the like. As shown in FIG. 5, the outline information includes titles such as title 1, title 2, and title 3, and content information of a body corresponding to the titles 1-3, respectively.
[0124] The analysis process of the outline information described above is only a principle introduction, and the specific analysis steps of the outline information are shown in steps 601-604 in FIG. 6, which are not described herein again.
[0125] The analysis result contains outline information of the PDF file, has a high requirement on the computing resource of the controller or the computing device, needs to use an AI chip for model inference, is suitable for a computing device configured with an AI chip, has a high utilization rate of the hardware resource of the user, avoids instant analysis of the PDF file and subsequent manual algorithm analysis when the user needs to access the PDF file to obtain valid information, and reduces the workload of the user for secondary processing of the file.
[0126] In step 303, the controller associates the analysis result and the PDF file to obtain a to-be-stored file.
[0127] The controller stores the analysis result and the PDF file in association according to the file identifier of the analysis result and the PDF file, to obtain the to-be-stored file.
[0128] As a possible implementation manner, the controller stores a mapping table, which is used to represent the association between the analysis result and the PDF file.
[0129] Optionally, the PDF file has a unique file identifier in the file system, and the analysis result has a unique file identifier in the file system. For example, the file identifier is a file name, an index, or the like.
[0130] Optionally, the mapping table includes a plurality of key-value pairs, and one PDF file and one or more analysis results corresponding to the PDF file correspond to one key-value pair in the mapping table. For example, the file identifier of the PDF file is “A”, the file identifiers of two analysis results corresponding to the PDF file are “B” and “C” respectively, the data of the key of the corresponding key-value pair in the mapping table is “A”, and the data of the value corresponding to the key includes “B” and “C”.
[0131] In step 304, the controller stores the to-be-stored file.
[0132] The controller performs disk storage on the to-be-stored file. Corresponding to step 3022, the disk-stored file includes the PDF file and the extracted text information in the PDF file. Corresponding to step 3023, the disk-stored file includes the PDF file and the analyzed outline information in the PDF file.
[0133] As a possible implementation manner, the controller sends the to-be-stored file in the memory to the hard disk frame 122, and performs persistent storage on the to-be-stored file.
[0134] As a possible implementation, when the controller performs the disk storage of the to-be-stored file, the metadata of the to-be-stored file is generated, so that the user can obtain the parsing result corresponding to the PDF file according to the metadata when accessing the PDF file. For example, the metadata of the PDF file includes the file identifier and the storage address (such as a physical address, a logical address, etc.) of the PDF file, and the metadata of the parsing result corresponding to the PDF file includes the file identifier and the storage address of the parsing result. In addition, the metadata can also include data size, access records, and other types of information, which will not be described here.
[0135] Based on the above steps 301-304, when storing unstructured data such as a PDF file, in addition to storing the original file of the PDF file, the parsing result of the PDF file is also associated with the PDF file and stored together. In this way, when the user subsequently accesses the PDF file, the user can also access the parsing result corresponding to the PDF file, avoiding the user manually parsing the PDF file to obtain the required data each time the user accesses the PDF file, and reducing the workload of the user processing the file twice.
[0136] When storing unstructured data such as a PDF file, the storage method of the unstructured data can be determined in combination with the hardware condition of the computing device, so that the storage of the unstructured data conforms to the hardware condition of the user's computing device, improves the resource utilization rate of the AI chip or the conventional CPU of the computing device, and thus improves the flexibility of storing the unstructured data.
[0137] In addition, in the case of a large number of file streams simultaneously accessing the data storage system for storage, since the concurrent efficiency of the AI chip such as NPU and GPU is high, only a small number of AI chips are needed to complete the parsing and storage of the unstructured data, reducing the dependence on processor resources and reducing the hardware cost of the user.
[0138] After the controller performs the disk storage of the to-be-stored file in the above step 304, the data access device 100 can access the PDF file in the storage device 120. In order to avoid the user accessing the PDF file and parsing the PDF file again, the controller of the storage device 120 can return the PDF file and the corresponding parsing result to the data access device 100.
[0139] Exemplarily, the specific steps of the controller returning the PDF file and the corresponding parsing result according to the data access request of the data access device 100 can include the following steps 305-308 (not shown in FIG. 3a).
[0140] Step 305, the controller receives a data access request.
[0141] The data access request includes the file identifier of the PDF file.
[0142] Step 306, the controller queries the file identifier of the parsing result according to the file identifier of the PDF file in the mapping table.
[0143] The file identifier of the PDF file and the file identifier of the parsing result in the mapping table are described in detail in step 303 of FIG. 3a, and will not be repeated here.
[0144] Step 307, the controller queries the metadata according to the file identifier of the PDF file and the file identifier of the parsing result, to obtain the storage address of the PDF file and the storage address of the parsing result.
[0145] The metadata is generated when the to-be-stored file is landed, and the specific content is described in detail in step 304 of FIG. 3a, and will not be repeated here.
[0146] Step 308, the controller returns a data access response.
[0147] The controller returns a data access response to the data access device 100. The data access response includes the data stored in the storage address of the PDF file and the data stored in the storage address of the parsing result.
[0148] In this way, after the user lands the PDF file and its corresponding parsing result, the user can obtain the corresponding parsing result of the PDF file when accessing the PDF file, avoiding manual algorithm parsing of the PDF file each time the user accesses the PDF file to obtain the required data, and reducing the workload of the user to process the file twice.
[0149] The data storage method provided by the embodiment of the application is described in detail above in combination with FIG. 3a, and the parsing step of the outline information will be described in detail in combination with FIG. 6.
[0150] Referring to FIG. 6, FIG. 6 is a flowchart of a parsing step of outline information provided by the application. As shown in FIG. 6, taking the parsing step of the outline information executed by the AI chip as an example, the parsing step of the outline information can include the following steps 601-604.
[0151] Step 601, performing layout analysis on the PDF file using a layout analysis model to obtain a layout analysis result output by the layout analysis model.
[0152] The input of the layout analysis model is the PDF file, and the output is the layout analysis result of the PDF file.
[0153] As a possible implementation manner, the layout analysis model performs layout analysis on the PDF file to obtain a layout analysis result, and the layout analysis result includes elements of various categories in the PDF file and coordinate frames of the elements of various categories.
[0154] Optionally, the categories of the elements in the PDF file can include a title and a body. The title can include at least one level of title, such as a first level of title, a second level of title, and a third level of title (the embodiment only takes the third level of title as an example, but is not limited to only including the third level of title).
[0155] Optionally, the categories of the elements in the PDF file can further include a header, a footer, and the like, which will not be described here.
[0156] For example, as shown in FIG. 4, in one page of the PDF file, there are a header 1, a first level of title 1, a body 1, a second level of title 1, a body 2, a second level of title 2, a body 3, a body 4, a body 5, a body 6, a body 7, and a footer 1.
[0157] The body includes text, tables, pictures, and the like. For example, the body 1, the body 2, the body 3, the body 5, the body 6, and the body 7 are text, and the body 4 is a picture.
[0158] Step 602: determining the association relationship between the levels of title and the body according to the positional relationship between the coordinate frames of the elements of the categories.
[0159] As a possible implementation manner, the positional relationship between the coordinate frames of the elements of the categories includes the positional relationship between the levels of title and the body, and the positional relationship between the levels of title.
[0160] Optionally, the association relationship between the levels of title and the body is determined according to the positional relationship between the levels of title and the body, and the positional relationship between the levels of title.
[0161] For example, it is determined that the first level of title 1 has an association relationship with the body 1, because the position of the first level of title 1 in the layout of the PDF file is located before the second level of title 1 and the second level of title 2, and the position of the body 2 in the layout of the PDF file is located between the first level of title 1 and the second level of title 1. It is determined that the second level of title 1 has an association relationship with the body 3, because the position of the second level of title 1 in the layout of the PDF file is located between the first level of title 1 and the second level of title 2, and the position of the body 3 in the layout of the PDF file is located between the second level of title 1 and the second level of title 2.
[0162] In the embodiment of the present application, the determination of the association relationship can be implemented by the AI chip using a layout analysis model.
[0163] As a possible implementation manner, the AI chip can further verify the association relationship between the levels of title and the body in combination with the semantics of the levels of title and the semantics of the body corresponding to the levels of title, so as to improve the accuracy of the association relationship.
[0164] Step 603: extracting content information of the body associated with the levels of title.
[0165] As a possible implementation manner, the body includes text.
[0166] Optionally, the AI chip runs an optical character recognition model, inputs the titles at all levels and the texts associated with the titles at all levels into the optical character recognition model, and obtains the text content of the titles at all levels and the texts associated with the titles at all levels output by the optical character recognition model. Then, the text content of the titles at all levels and the texts associated with the titles at all levels is matched with the coordinate boxes of the elements of each category respectively.
[0167] Exemplarily, the text content of the first-level title 1 is matched with the coordinate box of the first-level title 1 in the layout of the PDF file, the text content of the second-level title 1 is matched with the coordinate box of the first-level title 1 in the layout of the PDF file, the text content of the second-level title 2 is matched with the coordinate box of the first-level title 2 in the layout of the PDF file, and the text content of the body 2 is matched with the coordinate box of the body 2 in the layout of the PDF file. In this way, the positions of the text content of the titles at all levels and the body in the layout of the PDF file are determined, so that the content information of the titles at all levels and the corresponding body is corresponded, thereby facilitating the accuracy of subsequent output of the outline information.
[0168] The text content of the text can be key information such as an abstract or a summary of the text.
[0169] As a possible implementation manner, the body includes a table.
[0170] Optionally, the extraction of the content information of the table can be implemented by the AI chip running an optical character recognition model, and can include the following substeps 1-5.
[0171] Substep 1: input the titles at all levels into the optical character recognition model running on the AI chip, and obtain the text content of the text of the titles at all levels output by the optical character recognition model.
[0172] Substep 2: input the table associated with the titles at all levels into the structure detection model running on the AI chip, and obtain at least one cell of the table associated with the titles at all levels output by the structure detection model.
[0173] Substep 3: input the at least one cell into the optical character recognition model running on the AI chip, and obtain the text content contained in the at least one cell output by the optical character recognition model.
[0174] Substep 4: cluster the text content contained in the at least one cell based on the row and column division of the cell, and obtain the index type of the row and column of the at least one cell output by the table recognition model.
[0175] The clustering refers to dividing a set of physical or abstract objects into multiple classes composed of similar objects. The embodiments of the present application do not limit the algorithm of clustering. For example, the clustering algorithm can be hierarchical methods, partition-based methods, density-based methods, etc.
[0176] For example, for the content shown in Table 1, Table 1 is divided into 12 cells based on the row and column of the cells. In the order from top to bottom of each column, the content of each cell is "Name A", "Name B", "Name C", "Male", "Male", "Female", "15", "17", and "16". The clustering result of Table 1 can be that the index type of the first column is name, the index type of the second column is gender, and the index type of the third column is age.
[0177] Table 1
[0178] Sub-step 5, match the index types of each level of title and the table associated with each level of title with the coordinate frame of the elements of each category, respectively.
[0179] Step 604, determine the outline information according to the association relationship and the content information of the text associated with each level of title.
[0180] According to the format of the outline information, the text associated with each level of title is set at the position corresponding to each level of title to obtain the outline information.
[0181] For example, as shown in FIG. 5, the next level of title included in the first level of title 1 is the second level of title 1 and the second level of title 2, the text corresponding to the second level of title 1 is the content information of the text 2, and the text corresponding to the second level of title 2 is the content information of the text 3-7. Among them, the text 4 is a picture, and the picture can be directly displayed in the outline information.
[0182] Based on the above steps 601-604, in the case that the computing device of the user has an AI chip or AI processing capability, the AI chip can be called to intelligently analyze the PDF file to obtain the outline information of the PDF file, thereby avoiding the user to manually select the corresponding algorithm to analyze the PDF file and reducing the workload of the user to process the file twice.
[0183] In order to cooperate with the above data storage method provided by the embodiments of the present application, the embodiments of the present application also provide a data storage device 700, which is used to execute the above data storage method. As shown in FIG. 7, the data storage device 700 includes:
[0184] The acquisition module 710 is configured to acquire a PDF file.
[0185] The parsing module 720 is configured to parse the PDF file to obtain a parsing result. The parsing result includes text information obtained by text extraction on the PDF file or outline information of the PDF file.
[0186] The parsing module 720 is further configured to associate the parsing result with the PDF file to obtain a to-be-stored file.
[0187] The storage module 730 is configured to store the to-be-stored file.
[0188] As a possible implementation manner, the parsing module 720 is specifically configured to map, in the mapping table, a file identifier of the PDF file and a file identifier of the parsing result.
[0189] As a possible implementation manner, the parsing module 720 is specifically configured to: detect whether the computing device includes an AI chip; if the computing device does not include the AI chip, perform text extraction on the PDF file to obtain the parsing result; the parsing result includes text information obtained by the text extraction; if the computing device includes the AI chip, use the AI chip to parse the PDF file to obtain the parsing result; and the parsing result includes outline information.
[0190] As a possible implementation manner, the parsing module 720 is specifically configured to: input the PDF file into a layout parsing model running on the AI chip to obtain layout parsing result output by the layout parsing model; the layout parsing result includes elements of various categories in the PDF file and coordinate frames of the elements of various categories; and determine the outline information according to a positional relationship between the coordinate frames of the elements of various categories.
[0191] As a possible implementation manner, the categories include a title and a body, and the title includes at least one level of title.
[0192] As a possible implementation manner, the parsing module 720 is specifically configured to: determine, according to the positional relationship between the coordinate frames of the elements of various categories, an association relationship between the at least one level of title and the body; the association relationship is used to indicate the body associated with any level of title; extract content information of the body associated with the at least one level of title; and determine the outline information according to the association relationship and the content information of the body associated with the at least one level of title.
[0193] As a possible implementation manner, the body includes text. The parsing module 720 is specifically configured to: input the at least one level of title and the text associated with the at least one level of title into an optical character recognition model running on the AI chip to obtain text content of the at least one level of title and the text associated with the at least one level of title output by the optical character recognition model; and match the at least one level of title, the text content of the at least one level of title, and the coordinate frames of the elements of various categories, respectively.
[0194] As a possible implementation manner, the body includes a table. The parsing module 720 is specifically configured to: input the titles at each level into an optical character recognition model running on an AI chip to obtain text content of text of the titles at each level output by the optical character recognition model; input the table associated with the titles at each level into a structure detection model running on the AI chip to obtain at least one cell of the table associated with the titles at each level output by the structure detection model; input the at least one cell into the optical character recognition model running on the AI chip to obtain text content contained in the at least one cell output by the optical character recognition model; and cluster the text content contained in the at least one cell based on row and column division of the cell to obtain index types of rows and columns of the at least one cell output by a table recognition model; and match the titles at each level and the index types of the table associated with the titles at each level with coordinate boxes of elements of each category, respectively.
[0195] As a possible implementation manner, the body includes a table. The parsing module 720 is specifically configured to: extract semantic information of the titles at each level and the body associated with the titles at each level; and correct an association relationship between the titles at each level and the body in the outline information according to the semantic information.
[0196] As a possible implementation manner, the data storage device further includes a query module and a response module. The obtaining module 710 is further configured to: receive a data access request; the data access request includes a file identifier of the PDF file. The query module is configured to: query the file identifier of the parsing result in the mapping table according to the file identifier of the PDF file; and query metadata according to the file identifier of the PDF file and the file identifier of the parsing result to obtain a storage address of the PDF file and a storage address of the parsing result. The response module is configured to: return a data access response; the data access response includes data stored in the storage address of the PDF file and data stored in the storage address of the parsing result.
[0197] It should be understood that the apparatus provided in the above Figure 7 is only exemplified by the above-mentioned division of each functional module when realizing its functions, and in actual application, the above-mentioned functions can be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus and method embodiments provided in the above-mentioned embodiments belong to the same concept, and the specific implementation process is detailed in the method embodiments, which will not be described here.
[0198] Figure 8 is a structural schematic diagram of a computing device provided in the embodiment. As shown in Figure 8, the computing device 800 includes a processor 810, a bus 820, a memory 830, a communication interface 840 and a memory unit 850 (which can also be referred to as a main memory unit). The processor 810, the memory 830, the memory unit 850 and the communication interface 840 are connected through the bus 820.
[0199] It should be understood that in this embodiment, the processor 810 can be a CPU, and the processor 810 can also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs) or other programmable logic devices, discrete gates or transistor logic, discrete hardware components, and the like. The general-purpose processor can be a microprocessor or any conventional processor, and the like.
[0200] The processor can also be a graphics processor (GPU), a neural network processor (NPU), a microprocessor, or one or more integrated circuits for controlling program execution of the solutions of the present application.
[0201] The communication interface 840 is configured to realize communication between the computing device 800 and external devices or devices. In this embodiment, when the computing device 800 is configured to realize the function of the storage device 120 in FIG. 1, the communication interface 840 is configured to serve as a physical port for transmitting data.
[0202] The bus 820 can include a path for transmitting information between the above-mentioned components (such as the processor 810, the memory unit 850, and the storage 830). The bus 820 can include a data bus in addition to a power bus, a control bus, and a status signal bus, and the like. However, for the purpose of clear illustration, various buses are marked as the bus 820 in the figure. The bus 820 can be a Peripheral Component Interconnect Express (PCIe) bus, or an Extended Industry Standard Architecture (EISA) bus, a Unified Bus (Ubus or UB), a Compute Express Link (CXL), a Cache Coherent Interconnect for Accelerators (CCIX), and the like. The bus 820 can be divided into an address bus, a data bus, a control bus, and the like.
[0203] As an example, computing device 800 can include a plurality of processors. The processors can be a multi-CPU processor. A processor herein can refer to one or more devices, circuits, and / or computing units for processing data (e.g., computer program instructions).
[0204] It is worth noting that in FIG. 8, only an example in which the computing device 800 includes 1 processor 810 and 1 memory 830 is taken, and here the processor 810 and the memory 830 are respectively used to indicate a type of device or equipment. In specific embodiments, the number of each type of device or equipment can be determined according to business needs.
[0205] The memory unit 850 can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically EPROM (EEPROM) or a flash memory. The volatile memory can be a random access memory (RAM) used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced SDRAM (ESDRAM), synchlink DRAM (SLDRAM) and direct rambus RAM (DR RAM).
[0206] The memory 830 can correspond to the storage medium used to store computer instructions and other information in the above method embodiments, for example, a magnetic disk such as a mechanical hard disk or a solid state disk.
[0207] The above computing device 800 can be a general-purpose device or a special-purpose device. For example, the computing device 800 can be an edge device (e.g., a box with a processing-capable chip) and the like. Alternatively, the computing device 800 can also be a network device, a server or other device with computing or storage capabilities.
[0208] It should be appreciated that the computing device 800 according to the present embodiment can correspond to the data storage apparatus 700 in the present embodiment, and can correspond to performing respective subjects in the method according to FIG. 3a, and the above and other operations and / or functions of the respective modules in the data storage apparatus 700 are respectively for implementing respective flows of the method according to FIG. 3a, and for brevity, will not be repeated here.
[0209] The method steps in the present embodiment can be implemented by means of hardware, or by means of software instructions executed by a processor. The software instructions can be composed of respective software modules, which can be stored in a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an erasable programmable read-only memory, an electrically erasable programmable read-only memory, a register, a hard disk, a mobile hard disk, a CD-ROM, or any other form of storage medium well known in the art. An exemplary storage medium is coupled to the processor, so that the processor can read information from, and write information to, the storage medium. Of course, the storage medium can also be an integral part of the processor. The processor and the storage medium can be located in an ASIC. In addition, the ASIC can be located in an electronic device (such as a network device). Of course, the processor and the storage medium can also exist as discrete components in an electronic device.
[0210] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer programs or instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are performed. The computer can be a general purpose computer, a special purpose computer, a computer network, a network device, a user equipment or other programmable apparatus. The computer programs or instructions can be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another computer readable storage medium, for example, the computer programs or instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center through wired or wireless manner. The computer readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center and the like integrated with one or more available media. The available media can be a magnetic medium, for example, a floppy disk, a hard disk, a magnetic tape; or an optical medium, for example, a digital video disc (digital video disc, DVD); or a semiconductor medium, for example, a solid state disk (solid state drive, SSD). The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto, any person skilled in the art can easily think of various equivalent modifications or replacements within the technical range disclosed in the present application, and these modifications or replacements should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A data storage method, characterized by, Applied to a computing device, the method comprises: obtaining a PDF file; parsing the PDF file to obtain a parsing result; the parsing result comprises text information obtained by text extraction on the PDF file, or outline information of the PDF file; associating the parsing result and the PDF file to obtain a to-be-stored file; the to-be-stored file comprises the PDF file and the parsing result; storing the to-be-stored file.
2. The method of claim 1, wherein, The association of the parsing result and the PDF file comprises: mapping the file identifier of the PDF file and the file identifier of the parsing result in a mapping table.
3. The method according to claim 1 or 2, characterized in that, The parsing of the PDF file to obtain a parsing result comprises: detecting whether the computing device comprises an AI chip; if the computing device does not comprise the AI chip, performing text extraction on the PDF file to obtain a parsing result; the parsing result comprises text information obtained by text extraction; if the computing device comprises the AI chip, using the AI chip to parse the PDF file to obtain a parsing result; the parsing result comprises outline information.
4. The method of claim 3, wherein, The parsing of the original PDF file using the AI chip comprises: inputting the PDF file into a layout parsing model running on the AI chip to obtain a layout parsing result output by the layout parsing model; the layout parsing result comprises elements of various categories in the PDF file and coordinate frames of the elements of various categories; determining the outline information according to the positional relationship between the coordinate frames of the elements of various categories.
5. The method of claim 4, wherein, The categories comprise titles and texts, and the titles comprise at least one level of titles.
6. The method of claim 5, wherein, The determination of the outline information according to the positional relationship between the coordinate frames of the elements of various categories comprises: determining the association relationship between the titles of various levels and texts in the at least one level of titles according to the positional relationship between the coordinate frames of the elements of various categories; the association relationship is used to indicate the texts associated with any level of titles; extracting content information of the texts associated with the titles of various levels; determining the outline information according to the association relationship and the content information of the texts associated with the titles of various levels.
7. The method of claim 6, wherein, The texts comprise text information, and the extraction of the content information of the texts associated with the titles of various levels comprises: inputting the titles of various levels and the texts associated with the titles of various levels into an optical character recognition model running on the AI chip to obtain text content of the titles of various levels and the texts associated with the titles of various levels output by the optical character recognition model; matching the titles of various levels, the text content of the texts associated with the titles of various levels, and the coordinate frames of the elements of various categories respectively.
8. The method of claim 6, wherein, The texts comprise table information, and the extraction of the content information of the texts associated with the titles of various levels comprises: inputting the titles of various levels into an optical character recognition model running on the AI chip to obtain text content of the texts of the titles of various levels output by the optical character recognition model; inputting the tables associated with the titles of various levels into a structure detection model running on the AI chip to obtain at least one cell of the tables associated with the titles of various levels output by the structure detection model; input the at least one cell into an optical character recognition model running on the AI chip to obtain text content contained in the at least one cell output by the optical character recognition model; cluster the text content contained in the at least one cell based on row and column division of the cell to obtain an index type of a row and a column of the at least one cell output by the table recognition model; match the respective levels of titles, the index types of the tables associated with the respective levels of titles, and the coordinate boxes of the elements of the respective categories.
9. The method according to any one of claims 6-8, characterized in that, The method further includes: extracting semantic information of the respective levels of titles and the texts associated with the respective levels of titles; correcting an association relationship of the respective levels of titles and the texts in the outline information according to the semantic information.
10. The method according to any one of claims 1-9, characterized in that, The method further includes: receiving a data access request; the data access request includes a file identifier of the PDF file; obtaining a storage address of the PDF file and a storage address of the analysis result according to the file identifier of the PDF file; returning a data access response according to the storage address of the PDF file and the storage address of the analysis result; the data access response includes the PDF file or the analysis result.
11. A data storage device, characterized by comprise: an acquisition module configured to acquire a PDF file; an analysis module configured to analyze the PDF file to obtain an analysis result; the analysis result includes text information obtained by text extraction on the PDF file or outline information of the PDF file; the analysis module is further configured to associate the analysis result and the PDF file to obtain a to-be-stored file; the to-be-stored file includes the PDF file and the analysis result; a storage module configured to store the to-be-stored file.
12. A computing device, comprising: comprise a processor and a memory; the processor is configured to execute instructions stored in the memory, so that the computing device executes the method in any one of claims 1-10.
13. A computer program product comprising instructions, characterized in that, When the instructions are executed by a computing device, the computing device executes the method in any one of claims 1-10.
14. A computer-readable storage medium, characterized in that, comprise computer program instructions, when the computer program instructions are executed by a computing device, the computing device executes the method in any one of claims 1-10.
Citation Information
Patent Citations
PDF file-based knowledge element extraction method and device and medium
CN113722278A
Financial PDF document structuring method and device
CN115346228A
Document management method, document management system and computing equipment
CN116340259A
PDF (Portable Document Format) document analysis method and device, equipment and storage medium
CN116451677A