Electronic archive retrieval method, device and medium based on dynamically constructed prompt words
Through text recognition and key information extraction models, prompt words are dynamically constructed, which solves the problem that traditional electronic archive retrieval is difficult to process unstructured data, achieves fast and accurate retrieval of non-text content in electronic archives, and improves retrieval efficiency and accuracy. .
Patent Information
- Application Number
- CN202411045211.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2024-10-08
- Estimated Expiration
- 2044-08-01
AI Technical Summary
Traditional electronic archive full-text retrieval is difficult to effectively retrieve unstructured data, such as electronic voucher attachments, making it difficult for users to find the required information quickly and accurately, reducing the practicality and user experience of the electronic archive system.
Obtain out-of-order text data through text recognition, use pre-trained key information extraction models to extract key attributes and information, dynamically construct prompt words, and combine full-text search constraint statements to call large models for retrieval to achieve fast and accurate retrieval of non-text content. .
Convert out-of-order text data into ordered key information, dynamically construct prompt words, and integrate full-text search libraries to improve the retrieval efficiency and accuracy of non-text content in electronic archives and achieve fast and accurate retrieval of unstructured data.
Smart Images

Figure CN118568056B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of electronic data processing, and in particular to an electronic archive retrieval method, device and medium based on dynamically constructed prompt words. Background Art
[0002] Electronic archives play an indispensable role in managing and providing services for archival entities and archival information, due to their excellent characteristics such as non-human readability of information, high density of information storage, separability between information and carriers, and inheritance of multiple information media.
[0003] With the application of electronic archives, it is particularly important to ensure the accuracy of various information and to conduct efficient retrieval.
[0004] Traditional full-text searches of electronic archives are usually limited to fields on structured archive data such as the affiliation unit, creation time, and document title, but it is difficult to effectively search for unstructured data such as electronic voucher image attachments. This results in the difficulty for users to quickly and accurately retrieve the required electronic vouchers (including invoices, receipts, contracts, etc.) through the electronic archive attachment system in actual applications. This limitation has greatly reduced the practicality and user experience of the electronic archive system. Summary of the invention
[0005] In order to solve the above problems, this application proposes an electronic archive retrieval method based on dynamically constructed prompt words, including:
[0006] Acquire an electronic file, and perform text recognition on non-text content in the electronic file to obtain corresponding disordered text data;
[0007] Based on a pre-trained key information extraction model, the key attributes to be extracted are obtained, and the disordered text data is extracted to obtain ordered key information corresponding to the key attributes;
[0008] According to the key attribute, the ordered key information and the preset full-text search constraint statement, a prompt word is dynamically constructed;
[0009] The prompt word is used as input and the corresponding search result is output through the large model.
[0010] On the other hand, the present application also proposes an electronic archive retrieval device based on dynamically constructed prompt words, comprising:
[0011] at least one processor; and,
[0012] a memory communicatively connected to the at least one processor; wherein,
[0013] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the electronic archive retrieval method based on dynamically constructed prompt words as described in the above example.
[0014] On the other hand, the present application also proposes a non-volatile computer storage medium storing computer executable instructions, wherein the computer executable instructions are configured as: the electronic archive retrieval method based on dynamically constructed prompt words as described in the above example.
[0015] The electronic archive retrieval method based on dynamically constructed prompt words proposed in this application can bring the following beneficial effects:
[0016] To address the problem of retrieval limitations, after the full text of the electronic archive attachment, the key information extraction model is used to convert the disordered text data into ordered key information, so that prompt words can be dynamically constructed through the key attributes to be extracted and the ordered key information, and the full-text retrieval constraints adapted to the electronic archive full-text retrieval library are integrated, and the corresponding large model is called for induction and conclusion to obtain extraction results with guiding significance for full-text retrieval, thereby achieving fast and accurate retrieval of non-text content in electronic archives. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0018] Figure 1 A schematic diagram of the process of an electronic archive retrieval method based on dynamically constructed prompt words in an embodiment of the present application;
[0019] Figure 2 It is a schematic diagram of an electronic archive retrieval device based on dynamically constructed prompt words in an embodiment of the present application. DETAILED DESCRIPTION
[0020] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0021] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0022] To solve the problem of retrieval limitations, we can use text recognition + content transfer to achieve text-to-image search, in which the file attachment information can also be retrieved. However, when the file attachment is large and the text content is too much, full-text recognition retrieval will reduce the retrieval efficiency. In addition, the full-text recognition results can be directly delivered to the large model for structured information extraction, so that only key information is extracted during file retrieval. Although it can improve the retrieval efficiency to a certain extent, the process of directly handing over the full-text recognition results to the large model for extraction is uncontrollable, mainly reflected in the uncontrollable extraction results and extraction format.
[0023] Based on this, Figure 1 As shown, the embodiment of the present application provides an electronic archive retrieval method based on dynamically constructed prompt words, including:
[0024] S101: Acquire an electronic file, and perform text recognition on non-text content in the electronic file to obtain corresponding disordered text data.
[0025] Electronic files usually include text content and non-text content. Text content refers to data in text form, which is usually stored in word, txt and other formats. Non-text content can include invoices, receipts, business licenses, billing documents, etc., which are usually stored in PNG, JPG, JPEG, JPE, BMP, tif, tiff, etc., as well as PDF file formats.
[0026] For text content, corresponding searches can usually be performed directly. For non-text content, text recognition is required to obtain the corresponding disordered text data. Among them, the text recognition method can be optical character recognition (OCR). Through the recognized text data, only the text information of the text data itself and its position coordinates in the non-text content can be determined, and the positional relationship and association between the text data cannot be determined. For example, when the non-text content is an invoice issued by Transport Company A, the recognized text data may include: "Carrier", "Carrier Number", "Date", "A Transport Company", "ABC1234", "2021-01-01", etc. Among them, A Transport Company and ABC1234 respectively refer to exemplary descriptions of a certain carrier number of a certain transport company. Although these text data can be identified here, the relationship between the text data cannot be identified. For example, it is difficult to determine that "transportation company" corresponds to "A transportation company", "transportation number" corresponds to "ABC1234", "date" corresponds to "2021-01-01", etc. The relationship between the text data is chaotic and disordered, so it is called disordered text data, and it is difficult to extract orderly text content from it. If it is used directly for retrieval, it will not only increase the difficulty of retrieval, but also may cause misunderstandings when users analyze archives.
[0027] S102: Based on a pre-trained key information extraction model, key attributes to be extracted are obtained, and the disordered text data is extracted to obtain ordered key information corresponding to the key attributes.
[0028] The key attribute refers to the attribute required for this search. For example, it can include "company name", "registration number", "type", "address", "date of establishment", etc. according to different scenario requirements. The ordered key information refers to the text information corresponding to the key attribute after the association between the disordered text data is established. For example, the key attribute to be extracted is "transportation company", and the key information finally extracted is "A transportation company".
[0029] The training process of the key information extraction model includes: obtaining corresponding non-text content in multiple electronic archives, and obtaining corresponding disordered text data through text recognition. Multiple electronic archives can be obtained through data in historical records.
[0030] For the disordered text data, determine the key attributes and key information contained therein, and generate a data set. Key attributes refer to the attributes used to describe the information category, such as "carrier", "carrier number", "date", etc., while key information refers to the specific value of the information category in this electronic file, such as "A transport company", "ABC1234", "2021-01-01", etc.
[0031] For the data set, the mapping relationship between key attributes and key information is annotated. The annotation may include whether each text data belongs to a key attribute or key information, and the corresponding relationship between different key attributes and key information may also be annotated.
[0032] The labeled data set is used as training samples, and the training samples are divided into training set and test set to train the Universal Information Extraction (UIE) pre-training model to obtain the key information extraction model.
[0033] Among them, for the general information extraction unified framework pre-trained model, you can obtain the general information extraction unified framework pre-trained model based on the Paddle framework and set the model training parameters; among them, the model training parameters include: initial learning rate, number of input data samples, maximum number of text tokens, and number of training rounds. For example, the initial learning rate is set to 1e-5, the number of input data samples for each model training is 32, the maximum number of text tokens is 512, and the number of training rounds is 100.
[0034] Based on the model training parameters, the general information extraction unified framework pre-training model is trained to obtain a key information extraction model, which can find the key attributes to be extracted and the corresponding key information in the disordered text data of the electronic archives.
[0035] S103: dynamically construct prompt words according to the key attributes, the ordered key information and the preset full-text search constraint statement.
[0036] The full-text search constraint statement refers to the constraint command that needs to be performed during the search. The prompt word refers to the relevant content that needs to be input into the big model when issuing a search task to the big model.
[0037] Specifically, determine the business field to which the electronic archives belong, which may include the financial field, procurement field, etc. Of course, it can be further divided. For example, under the procurement field, it may include: office supplies procurement, raw materials procurement, etc.
[0038] Each business domain can be set up with multiple templates in advance. At this time, the specified template containing the key attributes to be extracted is searched among the multiple templates preset in the business domain. The specified template includes multiple statements, including retrieval requirement statements and full-text retrieval constraint statements. The full-text retrieval constraint statement is used to constrain the retrieval process or to provide corresponding original materials (including the content of electronic archives, the correspondence between key attributes and key information, etc.), while the retrieval requirement statement describes the retrieval requirements by asking questions or making requests.
[0039] At this time, the search requirement statements that do not belong to the key attributes to be extracted are deleted. Among the remaining search requirement statements, the search requirement statements with preset variables are completed by ordered key information. Thus, a complete prompt word is obtained according to the completed search requirement statement and the full-text search constraint statement.
[0040] Among them, for different search requirement statements, corresponding preset variables may be set, and different preset variables are used to represent different ordered key information. For example, in the remaining search requirement statements, the search requirement statements with preset variables are determined as: capturing prompt information, such as additional information such as the first key attribute, so as to facilitate the issuance of prompts to {first preset variable}. Among them, the first key attribute and the first preset variable are described in an example manner. When actually generating content, the first key attribute and the first preset variable can be replaced with actual relevant content. Here, it is assumed that the key attribute represented by the first preset variable is "user". Here, the key attribute "user" can be used directly as a replacement for the preset variable, and a similar effect can be achieved. However, the specific value corresponding to the user is filled in in the form of preset variables, which can make the information in the prompt word more complete and closer to the actual expression content of the electronic archive this time, so that the large model can give the corresponding emphasis when capturing the prompt information. Of course, the form of "so as to facilitate the issuance of prompts to the user {first preset variable}" can also be adopted here. On the basis of explaining that the key attribute is the user, the identity information corresponding to the value of the first preset variable is pointed out, thereby improving the retrieval accuracy of the large model.
[0041] At this time, for each preset variable, determine its corresponding variable name, select the corresponding ordered key information according to the variable name, and place it in the location of the preset variable to complete the remaining search requirement statement.
[0042] S104: taking the prompt word as input, and outputting corresponding search results through the large model.
[0043] After obtaining the prompt word, it is used as a large model, and the large model can realize the corresponding search and return the corresponding search results according to the search requirement statement and the full-text search constraint statement. The large model can be a large language model, or a large model trained in certain specific fields.
[0044] The large model has powerful comprehension and summary writing capabilities. It can deeply understand and analyze identification information based on key attributes and ordered key information, generate more ordered and clear archival information relative to tabular data, digital electrical invoices and other information, and optimize the full-text retrieval library to make it clearer and easier to search.
[0045] To address the problem of retrieval limitations, after the full text of the electronic archive attachment, the key information extraction model is used to convert the disordered text data into ordered key information, so that prompt words can be dynamically constructed through the key attributes to be extracted and the ordered key information, and the full-text retrieval constraints adapted to the electronic archive full-text retrieval library are integrated, and the corresponding large model is called for induction and conclusion to obtain extraction results with guiding significance for full-text retrieval, thereby achieving fast and accurate retrieval of non-text content in electronic archives.
[0046] In one embodiment, in addition to non-text content, the electronic archive generally also has corresponding text content, which is often used as the main body of the electronic archive, while the non-text content is usually used as an attachment.
[0047] Based on this, the text content in the electronic archive can be directly used in the corresponding retrieval process. Of course, for the ordered key information, if the corresponding key attribute is set with a preset mark (the preset mark is based on manual marking, and often marks the most important key attribute), it means that the key attribute is very important, or in other words, it is very important for the accuracy of the retrieval results. At this time, it is generally believed that the attachment as non-text content is related to the main text as text content, and there is a high probability that there will be consistent words between the two for the ordered key information. Therefore, the text content in the electronic archive is searched according to the ordered key information to determine whether there is content consistent with the ordered key information in the text content of the electronic archive.
[0048] If there is consistent content, it is considered that there is no error in the text recognition process, and the identified disordered text data is correct, and no corresponding processing is performed. For example, the key attribute with a preset mark is "transportation company", and its corresponding key information is "A transportation company". If "A transportation company" is retrieved in the text content, it is considered that the recognition is correct. If it does not exist, it is considered that there may be a recognition error, such as missed recognition or recognition error, and "A transportation company" is recognized as "B transportation company". At this time, the key attributes or ordered key information are marked in the prompt words (for example, changing the font color, size, background color, etc.), so that the user can perform corresponding checks before entering it into the large model, thereby solving the recognition errors of disordered text data.
[0049] In one embodiment, in some cases (for example, the identified disordered text data is lost, or the key information extraction model makes a recognition error), it may cause the key information extraction model to fail to extract the ordered key information corresponding to the specified key attribute to be extracted.
[0050] At this time, the position coordinates of the designated key attributes in the electronic archive are determined based on the disordered text data. When identifying disordered text data, its corresponding coordinate position is often identified, and the coordinate position is a range coordinate, and its corresponding ordered key information is often around it.
[0051] Based on this, the coordinate position is extended in the preset direction of the coordinate position (the preset direction usually includes at least two directions, such as the right and the bottom. Of course, the preset direction may also include fewer or more directions). When extending, the preset direction is extended, and the vertical direction of the preset direction remains unchanged until the coordinate position corresponding to other data in the disordered text data is reached, that is, it intersects with other data. For example, if the preset direction is the right, the upper and lower heights are kept unchanged and extended to the right until the coordinate information of other data is reached, or the boundary is reached. If there are multiple preset directions, the priority of the preset direction is set according to the type of electronic file (including invoices, receipts, etc.), and the preset direction with a higher priority is extended first.
[0052] It is usually believed that the ordered key information is around the key attribute, and because it is not identified, it is blank in the electronic file, that is, it does not contain location coordinates, so it can usually be included by extension.
[0053] The expanded position coordinates are screenshotted, and the screenshot is used as the ordered key information of the specified key attribute. At this time, the screenshot does not need to be identified, but is loaded into the prompt word in the form of an additional drawing, and the user manually identifies and fills in or deletes it.
[0054] In one embodiment, after the search is completed, the search results and the search process corresponding to the search results can also be stored in the ES full-text search library (Elasticsearch); wherein the search results include: the archive identifier corresponding to the electronic archive, the key attributes to be extracted, the ordered key information, the prompt words, and at least a plurality of the model identifiers corresponding to the large model, so as to improve the efficiency and accuracy of the full-text search and perform the corresponding tracing later.
[0055] like Figure 2 As shown, the embodiment of the present application also provides an electronic archive retrieval device based on dynamically constructed prompt words, including:
[0056] at least one processor; and,
[0057] a memory communicatively connected to the at least one processor; wherein,
[0058] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the electronic archive retrieval method based on dynamically constructed prompt words as described in any of the above embodiments.
[0059] The embodiment of the present application also provides a non-volatile computer storage medium storing computer executable instructions, wherein the computer executable instructions are configured as: the electronic archive retrieval method based on dynamically constructed prompt words as described in any of the above embodiments.
[0060] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0061] The devices and media provided in the embodiments of the present application correspond one-to-one to the methods. Therefore, the devices and media also have similar beneficial technical effects as the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the devices and media will not be repeated here.
[0062] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0063] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0064] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0065] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0066] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0067] Memory may include non-permanent storage in a computer-readable medium, in the form of random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0068] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0069] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0070] The above is only the embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. An electronic archive retrieval method based on dynamically constructed prompt words, It is characterized in that include: Acquire an electronic file, and perform text recognition on non-text content in the electronic file to obtain corresponding disordered text data; Based on a pre-trained key information extraction model, the key attributes to be extracted are obtained, and the disordered text data is extracted to obtain ordered key information corresponding to the key attributes; According to the key attribute, the ordered key information and the preset full-text search constraint statement, a prompt word is dynamically constructed; Taking the prompt word as input, outputting the corresponding search result through the large model; According to the key attribute, the ordered key information and the preset full-text search constraint statement, the prompt word is dynamically constructed, specifically including: Determine the business area to which the electronic record belongs; Searching for a designated template containing the key attribute to be extracted from a plurality of templates preset in the business field; the designated template includes a plurality of statements, and the plurality of statements include a search requirement statement and a full-text search constraint statement; Deleting the search requirement statements that do not belong to the key attributes to be extracted, and among the remaining search requirement statements, completing the search requirement statements with preset variables by using the ordered key information; According to the completed search requirement statement and the full-text search constraint statement, a prompt word is obtained.
2. The method according to claim 1, It is characterized in that The training process of the key information extraction model includes: Obtaining corresponding non-text contents in multiple electronic archives, and obtaining corresponding disordered text data through text recognition; For the disordered text data, determining key attributes and key information contained therein, and generating a data set; For the data set, annotating the mapping relationship between the key attributes and the key information; The labeled data set is used as a training sample, and the training sample is divided into a training set and a test set to train the general information extraction unified framework pre-training model to obtain the key information extraction model.
3. The method according to claim 2, It is characterized in that The general information extraction unified framework pre-training model is trained to obtain the key information extraction model, which specifically includes: Get the pre-trained model of the unified framework for general information extraction based on the Paddle framework; Setting model training parameters; wherein the model training parameters include: initial learning rate, number of input data samples, maximum number of tokens in text, and number of training rounds; Based on the model training parameters, the general information extraction unified framework pre-training model is trained to obtain the key information extraction model.
4. The method according to claim 1, It is characterized in that Among the remaining search requirement statements, the search requirement statements with preset variables are completed by the ordered key information, specifically including: Among the remaining search requirement statements, determine the search requirement statements with preset variables, and for each preset variable, determine its corresponding variable name; According to the variable name, the corresponding ordered key information is selected and placed in the location of the preset variable to complete the remaining search requirement statement.
5. The method according to claim 1, It is characterized in that The method further comprises: Obtaining text content in the electronic archive; For the ordered key information, if the key attribute corresponding to the ordered key information is set with a preset mark, searching the text content in the electronic archive according to the ordered key information to determine whether there is content consistent with the ordered key information in the text content in the electronic archive; If not present, the key attribute or the ordered key information is marked in the prompt word.
6. The method according to claim 1, It is characterized in that The method further comprises: For the designated key attribute to be extracted, if the ordered key information corresponding to the designated key attribute cannot be extracted through the key information extraction model, then determining the position coordinates of the designated key attribute in the electronic file according to the disordered text data; Expanding the coordinate position in a preset direction of the coordinate position until reaching the coordinate position corresponding to other data in the disordered text data; The expanded position coordinates are screenshotted, and the screenshot is used as the ordered key information of the designated key attribute.
7. The method according to claim 1, It is characterized in that The method further comprises: The search results and the search process corresponding to the search results are stored in the ES full-text search library; wherein the search results include: the file identification corresponding to the electronic file, the key attributes to be extracted, the ordered key information, the prompt words, and the model identification corresponding to the large model.
8. An electronic archive retrieval device based on dynamically constructed prompt words, It is characterized in that include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the electronic archive retrieval method based on dynamically constructed prompt words as described in any one of claims 1 to 7.
9. A non-volatile computer storage medium storing computer executable instructions, It is characterized in that The computer executable instructions are configured as: an electronic archive retrieval method based on dynamically constructed prompt words as described in any one of claims 1 to 7.
