Information extraction method and device, electronic equipment and computer readable storage medium
Through the pre-trained information extraction model and large language model, combined with entity recognition and relationship extraction, the problem of low information extraction efficiency in text is solved, fast and accurate information extraction is achieved, labor costs are reduced, and high-quality data support is provided .
Patent Information
- Application Number
- CN202411088796.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-08
- Publication Date
- 2024-11-22
AI Technical Summary
The prior art is inefficient and accurate when extracting information from text, especially when facing a large amount of redundant information, resulting in low efficiency of information analysis and high labor costs.
Using a pre-trained information extraction model, combining the target entity type and relationship description information, through named entity recognition and entity relationship extraction, obtain specific entity information in the text, and use prompt information and large language models for supplementary extraction when necessary, or Get matching rules based on text categories to improve extraction accuracy.
It realizes the rapid and accurate extraction of required information from text, improves the efficiency of information analysis and reduces labor costs, and provides high-quality data support.
Smart Images

Figure CN119005191A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and more specifically, to an information extraction method, device, electronic device and computer-readable storage medium. Background Art
[0002] The continuous development of Internet technology and the continuous growth of data volume have made information analysis increasingly important, but the text contains a lot of redundant information. Therefore, extracting the required information from the text through traditional information extraction methods is an inefficient and low-accuracy task for analysts. Summary of the invention
[0003] In view of this, embodiments of the present invention provide an information extraction method, device, electronic device and computer-readable storage medium to quickly and accurately extract required information from text and provide data support for subsequent information analysis.
[0004] In a first aspect, an embodiment of the present invention provides an information extraction method, the method comprising:
[0005] Get the text to be extracted;
[0006] An information extraction result of the text to be extracted is obtained according to the text to be extracted, the target entity type in the text to be extracted and a pre-trained first information extraction model, wherein the information extraction result includes entity information corresponding to the target entity type in the text to be extracted, and the first information extraction model is obtained by training based on a first sample set, wherein the first sample set includes multiple first sample texts, the target entity type and a first answer corresponding to the target entity type, and the first answer is determined based on a predetermined field in the first sample file.
[0007] Optionally, the obtaining the information extraction result of the text to be extracted according to the text to be extracted, the target entity type in the text to be extracted and a pre-trained first information extraction model includes:
[0008] Acquire relationship description information of the target entity type, where the relationship description information is used to describe the relationship between the target entity types;
[0009] The information extraction result is obtained according to the text to be extracted, the target entity type, the relationship description information and the first information extraction model.
[0010] Optionally, the method further comprises:
[0011] In response to failing to obtain the information extraction result according to the first information extraction model, determining prompt information of the text to be extracted according to the text to be extracted and the target entity type;
[0012] The information extraction result is obtained according to the prompt information and a pre-trained second information extraction model, the second information extraction model is trained according to a second sample set, the second sample set includes multiple second sample files, sample prompt information and second answers corresponding to the sample prompt information, the sample prompt information is determined according to the target entity type, and the second answer is determined according to a predetermined field in the second sample text.
[0013] Optionally, the determining the prompt information of the text to be extracted according to the text to be extracted and the target entity type includes:
[0014] Obtaining a first vector corresponding to each candidate sentence in the text to be extracted;
[0015] Acquire a question statement according to the target entity type;
[0016] Obtaining a second vector corresponding to the question statement;
[0017] respectively determining similarity parameters between each of the first vectors and the second vector;
[0018] Determining, from the candidate sentences, a related sentence corresponding to the question sentence according to the similarity parameter;
[0019] The prompt information is determined according to the associated sentence and the question sentence.
[0020] Optionally, determining the associated sentence corresponding to the question sentence from the candidate sentences according to the similarity parameter includes:
[0021] The candidate sentences whose similarity parameters satisfy a preset similarity condition are determined as the associated sentences.
[0022] Optionally, the method further comprises:
[0023] In response to the failure to obtain the information extraction result according to the first information extraction model, obtaining a corresponding target matching rule according to the category information of the text to be extracted, wherein the target matching rule is used to characterize the position distribution of each entity type in a specified category text, and the specified category text is of the same category as the text to be extracted;
[0024] The information extraction result is determined according to the target matching rule and the target entity type.
[0025] Optionally, obtaining the text to be extracted includes:
[0026] Obtaining a file to be identified, wherein the format of the file to be identified is a portable file format;
[0027] Performing optical character recognition on the file to be recognized to obtain a recognition result of the file to be recognized;
[0028] The text to be extracted is determined according to the recognition result.
[0029] Optionally, determining the text to be extracted according to the recognition result includes:
[0030] Correcting the recognition result based on a preset fuzzy matching algorithm;
[0031] The text to be extracted is determined according to the corrected recognition result.
[0032] In a second aspect, an embodiment of the present invention provides an information extraction device, the device comprising:
[0033] A text acquisition unit, used to acquire the text to be extracted;
[0034] A result acquisition unit is used to obtain an information extraction result of the text to be extracted based on the text to be extracted, the target entity type in the text to be extracted and a pre-trained first information extraction model, wherein the information extraction result includes entity information corresponding to the target entity type in the text to be extracted, the first information extraction model is obtained by training based on a first sample set, the first sample set includes multiple first sample texts, the target entity type and a first answer corresponding to the target entity type, and the first answer is determined based on a predetermined field in the first sample text.
[0035] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory and a processor, wherein the memory is used to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement a method as described in any one of the first aspects.
[0036] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method as described in any one of the first aspects is implemented.
[0037] In a fifth aspect, an embodiment of the present invention provides a computer program product, wherein the computer program product comprises a computer program / instructions, and when the computer program / instructions are executed by a processor, the method as described in any one of the first aspects is implemented.
[0038] After obtaining the text to be extracted, the embodiment of the present invention obtains entity information corresponding to the specific entity type as the information extraction result of the text to be extracted according to the text to be extracted, the specific entity type in the text to be extracted and the pre-trained information extraction model. In the above manner, the embodiment of the present invention can quickly and accurately extract the required information from the text and provide data support for subsequent information analysis. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] The above and other objects, features and advantages of the present invention will become more apparent through the following description of the embodiments of the present invention with reference to the accompanying drawings, in which:
[0040] Figure 1 is a flow chart of the information extraction method according to the first embodiment of the present invention;
[0041] Figure 2 is a flow chart of an information extraction method according to a second embodiment of the present invention;
[0042] Figure 3 It is a flowchart of obtaining the text to be extracted in an optional implementation manner of an embodiment of the present invention;
[0043] Figure 4 is a flowchart of determining text to be extracted in an optional implementation of an embodiment of the present invention;
[0044] Figure 5 It is a flow chart of determining prompt information of a text to be extracted in an optional implementation manner of an embodiment of the present invention;
[0045] Figure 6 is a data flow diagram for determining prompt information in the method of an embodiment of the present invention;
[0046] Figure 7 is a data flow chart of the information extraction method according to an embodiment of the present invention
[0047] Figure 8 is a schematic diagram of an information extraction device according to a third embodiment of the present invention;
[0048] Fig. 9 is a schematic diagram of an electronic device according to a fourth embodiment of the present invention. DETAILED DESCRIPTION
[0049] The present application is described below based on embodiments, but the present application is not limited to these embodiments. In the detailed description of the present application below, some specific details are described in detail. It is possible for those skilled in the art to fully understand the present application without the description of these details. In order to avoid confusing the essence of the present application, known methods, processes, flows, components and circuits are not described in detail.
[0050] In addition, persons of ordinary skill in the art will appreciate that the drawings provided herein are for illustration purposes and are not necessarily drawn to scale.
[0051] Unless the context clearly requires otherwise, the words "include", "comprising" and similar words throughout the application should be interpreted as including rather than exclusive or exhaustive; that is, the meaning is "including but not limited to".
[0052] In the description of this application, it should be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, the meaning of "plurality" is two or more.
[0053] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0054] The continuous development of Internet technology and the continuous growth of data volume have made information analysis more and more important. The entities contained in the text, such as people, addresses, dates, etc., are usually the most important information in the text, but the text also contains a lot of redundant information. Therefore, extracting the required information from the text through traditional information extraction methods is inefficient and inaccurate, and the labor cost is also high.
[0055] Figure 1 FIG. 1 is a flow chart of the information extraction method according to the first embodiment of the present invention. Figure 1 As shown, the method of this embodiment may include the following steps:
[0056] Step S100, obtaining the text to be extracted.
[0057] In this step, texts can be obtained in various ways, such as papers, legal documents (including contracts, judgments, etc.), and the obtained texts are determined as the texts to be extracted. For example, an image of a paper document captured by an image acquisition device (such as a scanner, a smart phone, etc.) can be obtained, and optical character recognition (OCR, Optical Character Recognition) can be performed on the image of the paper document to obtain the text information in the paper document as the text to be extracted; or, speech recognition can be performed on the obtained audio file or video file, and the speech recognition result can be determined as the text to be extracted; for another example, the text to be extracted can also be various existing text files, such as text files in *.txt format, text files in *.doc format, text files in *.docx format, etc., which are not limited in this embodiment.
[0058] Step S200, obtaining an information extraction result of the text to be extracted according to the text to be extracted, the target entity type in the text to be extracted, and a pre-trained first information extraction model.
[0059] In this embodiment, the target entity type is a specific entity type among the entity types included in the text to be extracted. For example, if the entity types included in the text to be extracted are person, address and time, then the target entity type may be at least one of place name and time. For another example, if the text to be extracted includes entity types such as person, location, time, date, etc., and the entity type of person further includes user and merchant, then the target entity type may be either person or at least one of user and merchant.
[0060] The first information extraction model is a deep learning model for implementing named entity recognition (NER), which can be a neural network model, such as convolutional neural networks (CNN), recurrent neural networks (RNN), conditional random fields (CRF), BERT (Bidirectional Encoder Representations from Transformers), etc., which is not limited in this embodiment. Furthermore, the first information extraction model can be a pre-trained model, that is, a trained neural network model.
[0061] In an optional implementation, named entity recognition (NER) can be performed through the first information extraction model, and the goal of named entity recognition is to identify entities with specific meanings in the text to be extracted. Therefore, in the training process of the first information extraction model, multiple first sample texts and target entity types in the first sample set can be used as inputs of the first information extraction model, and the first answer corresponding to the target entity type can be used as the training target to train or fine-tune the first information extraction model until the first information extraction model reaches the training target, such as the loss function converges, the accuracy meets the preset accuracy conditions, etc.
[0062] Among them, the first answer is determined according to the predetermined field in the first sample text. For example, the text to be extracted is "XX smartphone, as the latest generation of smart terminals, integrates high performance, high appearance and excellent experience, and is specially designed for you who pursue quality life. Using the latest processor technology and equipped with a high-definition display, it can bring a smooth and unparalleled operating experience whether it is daily use or entertainment games. Equipped with XX series flagship processors, using advanced process technology, powerful performance, lower power consumption, whether it is multi-tasking or large-scale game running, it can easily cope with it. Equipped with XX-inch AMOLED (Active-matrix Organic Light-emitting Diode, active matrix organic light-emitting diode) full screen, with a resolution of up to XXXX*XXXX pixels, rich colors, high contrast, and support for HDR display, bringing you an immersive visual feast. Built-in XX mAh large-capacity battery, supports XXW super-fast charging technology, which can quickly recover power in a short time, keeping your phone away from battery anxiety. The rear XX-megapixel super-sensitive main camera + XX-megapixel ultra-wide-angle lens + XX-megapixel telephoto lens support a variety of photo modes, whether it is scenery, portraits or night scenes, you can easily take a blockbuster look. "Among them, the target entity types are product name, processor name, and display name. The first answer corresponding to the product name can be "xx smartphone", the first answer corresponding to the processor name can be "xx series flagship processor", and the first answer corresponding to the display name can be "AMOLED full screen".
[0063] Therefore, in this step, the text to be extracted and the target entity type in the text to be extracted can be used as the input of the first information processing model to obtain the information extraction result of the text to be extracted.
[0064] In another optional implementation, entity relationship extraction (RE) can be performed through the first information extraction model, and the goal of entity relationship extraction is to identify the relationship between entities from the text to be extracted. Therefore, in the training process of the first information extraction model, multiple first sample texts in the first sample set, target entity types and relationship description information of the target entity types can be used as inputs of the first information extraction model, and the first answer corresponding to the target entity type can be used as the training target to train or fine-tune the first information extraction model until the first information extraction model reaches the training target, such as the loss function converges, the accuracy meets the preset accuracy conditions, etc.
[0065] The relationship description information of the target entity type is used to represent the relationship between the target entity types. For example, if the text to be extracted is "Product A's production date is August 1, 2024, and its validity period is July 31, 2025", and the target entity type is the product name and date, then both "Product production date" and "Product validity period" can be the relationship description information of the target entity type, and the first answer corresponding to the product production date can be "August 1, 2024", and the first answer corresponding to the product validity period can be "July 31, 2025".
[0066] Therefore, in this step, the text to be extracted, the target entity type in the text to be extracted, and the relationship description information of the target entity type can be used as inputs of the first information processing model to obtain the information extraction result of the text to be extracted.
[0067] After obtaining the text to be extracted, the embodiment of the present invention obtains entity information corresponding to the specific entity type as the information extraction result of the text to be extracted according to the text to be extracted, the specific entity type in the text to be extracted and the pre-trained information extraction model. In the above manner, the embodiment of the present invention can quickly and accurately extract the required information from the text and provide data support for subsequent information analysis.
[0068] Figure 2 FIG. 1 is a flow chart of the information extraction method according to the second embodiment of the present invention. Figure 2 As shown, the method of this embodiment includes the following steps:
[0069] Step S100', obtaining the text to be extracted.
[0070] Figure 3 FIG. 1 is a flowchart of obtaining text to be extracted in an optional implementation of an embodiment of the present invention. Figure 3 As shown, in an optional implementation of this embodiment, step S100' may include the following steps:
[0071] Step S110', obtaining the file to be identified.
[0072] In real life, in order to ensure the security of legal documents to the greatest extent and maintain the layout of various elements (including text, images, tables, etc.) in legal documents, legal documents are usually stored in a portable document format (PDF, Portable Document Format). Therefore, in an optional implementation of this embodiment, a portable document format file of the legal document can be obtained as a file to be identified.
[0073] Step S120 ′: perform optical character recognition on the document to be recognized, and obtain a recognition result of the document to be recognized.
[0074] In order to facilitate the first information extraction model to extract information from the file to be recognized, in this step, optical character recognition can be performed on the file to be recognized, and the recognition result of the file to be recognized can be obtained. Common optical character recognition methods include connectionist text proposal network (CTPN), efficient and accurate scene text detector (EAST), convolutional recurrent neural network (CRNN), etc.
[0075] Optionally, an optical character recognition service in a third-party interface may be called to obtain a recognition result of the file to be recognized.
[0076] Step S130', determining the text to be extracted according to the recognition result.
[0077] In this step, after obtaining the recognition result of the file to be recognized, the recognition result can be directly determined as the text to be extracted.
[0078] Figure 4 FIG. 1 is a flowchart of determining the text to be extracted in an optional implementation of an embodiment of the present invention. Figure 4 As shown, in an optional implementation, step S130' may include the following steps:
[0079] Step S131 ′, correcting the recognition result based on a preset fuzzy matching algorithm.
[0080] In order to improve the accuracy of the recognition results, after obtaining the recognition results, the recognition results can also be corrected based on the preset fuzzy matching algorithm. Fuzzy matching is a data matching technology that can correct the text based on the similarity between the words in the text and the words in the preset vocabulary library to reduce the negative impact of spelling errors, dialects, and non-standard expressions on the recognition results.
[0081] Common fuzzy matching algorithms include vector similarity calculation methods, that is, calculating the similarity between the words in the text and the vectors of the words in the preset word library, such as the Edit (Levenshtein) distance, Jaccard similarity, Cosine similarity, Smith-Waterman distance, etc., and also include pronunciation similarity calculation methods, that is, calculating the similarity between the pronunciation of the words in the text and the pronunciation of the words in the preset word library, such as the Soundex algorithm, Metaphone algorithm, etc., and also include model-based fuzzy matching algorithms, including n-gram, etc., which can be set according to actual needs and are not limited in this embodiment.
[0082] Step S132’, determine the text to be extracted according to the corrected recognition result.
[0083] After correcting the recognition result, the corrected recognition result can be determined as the text to be extracted. For example, if the file to be recognized is a portable file format file of a legal document, and the recognition result of the file to be recognized includes the word "matter head", the word "matter head" in the recognition result can be replaced with the word "fact" based on the preset fuzzy matching algorithm to obtain the corrected recognition result, so as to determine the text to be extracted corresponding to the file to be recognized according to the corrected recognition result.
[0084] Step S200’, obtain the information extraction result of the text to be extracted according to the text to be extracted, the target entity type in the text to be extracted, and the pre-trained first information extraction model.
[0085] In this embodiment, the first information extraction model can be a Universal Information Extraction (UIE) model. The UIE model aims to implement various information extraction tasks such as named entity recognition and entity relationship extraction through a general framework. When obtaining the entity information corresponding to the target entity type, the UIE model can regard the target entity type or the relationship description information of the target entity type as a schema, and perform named entity recognition or entity relationship extraction on the text to be extracted based on the schema to obtain the entity information corresponding to the target entity type.
[0086] In this step, the training process of the UIE model and the method of obtaining the information extraction result of the text to be extracted can refer to step S200, and this embodiment is not limited.
[0087] Step S300’, in response to the inability to obtain the information extraction result according to the first information extraction model, determine the prompt information of the text to be extracted according to the text to be extracted and the target entity type.
[0088] The UIE model has a strong information extraction capability for short texts, but a relatively weak information extraction capability for long texts. Therefore, in an optional implementation method of this embodiment, if the entity information of some target entity types in the text to be extracted cannot be obtained through the UIE model, the information extraction result of the text to be extracted can be obtained according to the second information extraction model.
[0089] The second information extraction model is a large language model (LLM). Therefore, in this step, a question statement (query) can be obtained according to the target entity type, and the prompt information (promt) of the text to be extracted can be obtained according to the text to be extracted and the question statement, so as to obtain the information extraction result of the text to be extracted according to the prompt information.
[0090] Figure 5 FIG. 1 is a flow chart of determining prompt information of a text to be extracted in an optional implementation of an embodiment of the present invention. Figure 5 As shown, in an optional implementation of this embodiment, step S300' may include the following steps:
[0091] Step S310 ′, obtaining a first vector corresponding to each candidate sentence in the text to be extracted.
[0092] In this step, the text to be extracted can be divided into multiple sentences as candidate sentences according to punctuation marks in the text to be extracted, such as commas, periods, semicolons, etc., and each candidate sentence is converted into a vector by various existing methods to obtain a first vector corresponding to each candidate sentence. Optionally, the first vector can be obtained by Word2Vec model, GloVe (Global Vectors for Word Representation, a word embedding technology), TF-IDF algorithm, BERT, etc., which is not limited in this embodiment.
[0093] Step S320', obtaining a question statement according to the target entity type.
[0094] In this step, a question statement can be obtained according to a preset question template and target entity type. For example, if the question template is: Who is __(target entity type) and the target entity type is "plaintiff", then a question statement can be obtained: Who is the plaintiff?
[0095] The question statement can also be obtained based on the preset question template and the relationship description information of the target entity type. For example, if the question template is: What is __(the relationship description information of the target entity type), and the relationship description information of the target entity type is "the defendant's habitual residence", then the question statement can be obtained: What is the defendant's habitual residence?
[0096] Optionally, the question statement may also be obtained in other ways, which are not limited in this embodiment.
[0097] Step S330', obtaining a second vector corresponding to the question statement.
[0098] After obtaining the question sentence, the question sentence can be converted into a vector by various existing methods to obtain a second vector corresponding to the question sentence. The method for obtaining the second vector is similar to the method for obtaining the first vector, and will not be repeated here.
[0099] Step S340', respectively determining similarity parameters between each first vector and the second vector.
[0100] After determining the first vector corresponding to each candidate sentence and the second vector corresponding to the question sentence, the similarity parameters between each first vector and the second vector can be calculated respectively by a pre-set similarity calculation method. Common similarity calculation methods include cosine similarity, Pearson correlation coefficient, Euclidean distance, Manhattan distance, etc., which can be set according to actual needs and are not limited in this embodiment.
[0101] Optionally, a similarity calculation service in a third-party interface, such as Faiss (an open source similarity search tool), may be called to obtain similarity parameters between each first vector and the second vector.
[0102] Step S350', determining the associated sentence corresponding to the question sentence from the candidate sentences according to the similarity parameter.
[0103] After determining the similarity parameters between each candidate sentence and the question sentence, the candidate sentence with a higher similarity to the question sentence can be selected as the associated sentence corresponding to the question sentence. Specifically, the candidate sentence whose similarity parameter satisfies the preset similarity condition can be determined as the associated sentence corresponding to the question sentence. The preset similarity condition can be set according to actual needs, for example, it is set to that the similarity parameter is higher than a preset threshold, the similarity parameter is ranked in the largest first n (n is a preset integer greater than or equal to 1) digits, the similarity parameter is ranked in the largest first n digits and is higher than the preset threshold, etc., and this embodiment does not limit it.
[0104] Step S360', determining prompt information according to the associated sentence and the question sentence.
[0105] After determining the associated sentences, the prompt information of the text to be extracted can be determined based on the associated sentences and the question sentence. In this way, the candidate sentences with low correlation parameters with the question sentence can be removed from the context of the question sentence, thereby improving the accuracy of information extraction while reducing the consumption of computing resources and improving the efficiency of information extraction.
[0106] In this step, each associated sentence can be spliced with the question sentence to obtain prompt information. For example, the associated sentences include "Plaintiff: Person A, Entrusted Litigation Agent: Person B" and "Defendant: Person C, Entrusted Litigation Agent: Person D", and the question sentence is "Who is the plaintiff's entrusted litigation agent?", then the above sentences can be spliced to obtain "Plaintiff: Person A, Entrusted Litigation Agent: Person B, Defendant: Person C, Entrusted Litigation Agent: Person D, Who is the plaintiff's entrusted litigation agent?" as prompt information.
[0107] Figure 6 is a data flow diagram for determining prompt information in the method of an embodiment of the present invention. Figure 6 As shown, in this embodiment, the text 61 as the text to be extracted can be segmented, multiple sentences 62 can be obtained as candidate sentences, and the sentences 62 can be embedded in text to obtain vectors 63 as the first vectors corresponding to each sentence 62, and then the Faiss index 64 corresponding to each sentence 62 can be obtained according to the vector 63. At the same time, the question sentence 65 can be embedded in text to obtain vectors 66 as the second vectors corresponding to the question sentence 65. Then, the similarity parameters between the vector 66 and each vector 63 are obtained through Faiss search, and k related sentences 67 are selected from the sentence 62 according to the similarity parameters, and then the k related sentences 67 are spliced to obtain the context 68 of the text 61, so as to obtain the prompt information 69 corresponding to the text 61 according to the context 68 and the question sentence 65.
[0108] Step S400', obtaining an information extraction result according to the prompt information and a pre-trained second information extraction model.
[0109] The second information extraction model is a deep learning model that can understand the meaning of language text, and can be a neural network model, such as a convolutional neural network, a recurrent neural network, a conditional random field, BERT, etc., which is not limited in this embodiment. Common large language models include GPT (Generative Pre-trained Transformer), BERT, XLNet, RoBERTa, etc. Furthermore, the second information extraction model can be a pre-trained model, that is, a trained neural network model.
[0110] In this embodiment, the second information extraction model can be obtained by training based on the second sample set. The second sample set includes multiple second sample texts, sample prompt information, and second answers corresponding to the sample prompt information. Similar to the way of obtaining the prompt information, the sample prompt information can also be determined based on the target entity type; similar to the way of obtaining the first answer, the second answer can also be determined based on a predetermined field in the second sample text, which will not be repeated here.
[0111] During the training process of the second information extraction model, the sample prompt information corresponding to each second sample text in the second sample set can be used as the input of the second information extraction model, and the second answer corresponding to each sample prompt information can be used as the training target to train or fine-tune the second information extraction model until the second information extraction model reaches the training target, such as the loss function converges and the accuracy meets the preset accuracy conditions.
[0112] Therefore, in this step, the prompt information corresponding to the text to be extracted can be used as the input of the second information extraction model to obtain the information extraction result of the text to be extracted.
[0113] Step S500': in response to failure to obtain information extraction results according to the first information extraction model, obtaining corresponding target matching rules according to category information of the text to be extracted.
[0114] Texts of the same category usually have similar structures, especially for highly standardized documents such as legal documents. Therefore, in an optional implementation of this embodiment, if the entity information of some target entity types in the text to be extracted cannot be obtained through the UIE model, the corresponding target matching rules can be obtained according to the category information of the text to be extracted.
[0115] For example, if the category of the text to be extracted is a contract, the matching rule corresponding to the contract text can be determined as the target matching rule; if the category of the text to be extracted is an indictment, the matching rule corresponding to the indictment text can be determined as the target matching rule.
[0116] The target matching rule is a rule matching method used to characterize the position distribution of each entity type in the text of the same category as the text to be extracted, that is, the text of the specified category. For example, for the indictment text, the plaintiff's personal information, including the plaintiff's name, ID number, contact information, etc., is usually recorded in the first paragraph of the text, the defendant's personal information is usually recorded in the second paragraph of the text, and the facts and reasons are usually recorded in one to five paragraphs before "Sincerely".
[0117] Step S600', determining the information extraction result according to the target matching rule and the target entity type.
[0118] After determining the target matching rule, the position distribution of the target entity type in the text to be extracted can be determined in the text to be extracted according to the target matching rule, and the corresponding field can be extracted as the information extraction result of the text to be extracted.
[0119] Optionally, the accuracy of rule matching may be different for different categories of text, so in this embodiment, the priority of the second information extraction model and the target matching rule can be set according to actual needs, that is, the order of execution of steps S300'-step S400' and S500'-step S600'. Optionally, only S300'-step S400', or only S500'-step S600' can be executed. This embodiment does not limit this.
[0120] Figure 7 is a data flow chart of the information extraction method according to an embodiment of the present invention. Figure 7 As shown, after obtaining a PDF file 71 as a file to be recognized, optical character recognition can be performed on the file to be recognized to obtain text 61. Then, the schema 62 corresponding to the text 61 is obtained according to the target entity type in the text 61, and the text 61 and the schema 62 are used as inputs of the UIE model to obtain the result 73. If the result 73 cannot be obtained according to the UIE model, the prompt information 69 can be obtained according to the text 61, and the prompt information 69 can be used as the input of the large language model to obtain the result 73; the corresponding matching rule can also be obtained according to the category 74 of the text 61, and the result 73 can be determined in the text 61 according to the matching rule.
[0121] After obtaining the text to be extracted, the embodiment of the present invention obtains entity information corresponding to the specific entity type as the information extraction result of the text to be extracted according to the text to be extracted, the specific entity type in the text to be extracted and a pre-trained first information extraction model, and when the information extraction result cannot be obtained according to the first information extraction model, the prompt information is determined according to the text to be extracted and the specific entity type, and the information extraction result is obtained according to the pre-trained second information extraction model; the corresponding matching rules can also be determined according to the category information of the text to be extracted, so as to obtain the information extraction result according to the position distribution of the specific entity type in the text to be extracted. Through the above methods, the embodiment of the present invention can quickly and accurately extract the required information from the text in at least one way, and provide data support for subsequent information analysis.
[0122] Figure 8 Schematic diagram of the information extraction device of the third embodiment of the present invention. Figure 8 As shown, the information extraction device of this embodiment includes a text acquisition unit 81 and a result acquisition unit 82.
[0123] Among them, the text acquisition unit 81 is used to acquire the text to be extracted; the result acquisition unit 82 is used to acquire the information extraction result of the text to be extracted based on the text to be extracted, the target entity type in the text to be extracted and a pre-trained first information extraction model, the information extraction result includes the entity information corresponding to the target entity type in the text to be extracted, the first information extraction model is obtained by training based on a first sample set, the first sample set includes multiple first sample texts, the target entity type and a first answer corresponding to the target entity type, and the first answer is determined based on a predetermined field in the first sample text.
[0124] Furthermore, the result acquisition unit 82 includes a first information acquisition subunit and a first result acquisition subunit.
[0125] Among them, the first information acquisition subunit is used to obtain the relationship description information of the target entity type, and the relationship description information is used to describe the relationship between the target entity types; the first result acquisition subunit is used to obtain the information extraction result based on the text to be extracted, the target entity type, the relationship description information and the first information extraction model.
[0126] Furthermore, the device also includes an information acquisition unit and a second result acquisition unit.
[0127] Among them, the information acquisition unit is used to determine the prompt information of the text to be extracted according to the text to be extracted and the target entity type in response to the inability to obtain the information extraction result according to the first information extraction model; the second result acquisition unit is used to obtain the information extraction result according to the prompt information and a pre-trained second information extraction model, the second information extraction model is trained according to a second sample set, the second sample set includes multiple second sample texts, sample prompt information and second answers corresponding to the sample prompt information, the sample prompt information is determined according to the target entity type, and the second answer is determined according to a predetermined field in the second sample text.
[0128] Furthermore, the information acquisition unit includes a first vector acquisition subunit, a sentence acquisition subunit, a second vector acquisition subunit, a parameter acquisition subunit and a sentence determination subunit.
[0129] Among them, the first vector acquisition subunit is used to obtain the first vector corresponding to each candidate sentence in the text to be extracted; the sentence acquisition subunit is used to obtain the question sentence according to the target entity type; the second vector acquisition subunit is used to obtain the second vector corresponding to the question sentence; the parameter acquisition subunit is used to respectively determine the similarity parameters of each first vector and the second vector; the sentence determination subunit is used to determine the associated sentence corresponding to the question sentence from the candidate sentences according to the similarity parameters; the information determination subunit is used to determine the prompt information according to the associated sentence and the question sentence.
[0130] Furthermore, the sentence determination subunit is further used to determine the candidate sentences whose similarity parameters meet a preset similarity condition as the associated sentences.
[0131] Furthermore, the device also includes a rule acquisition unit and a result determination unit.
[0132] Among them, the rule acquisition unit is used to obtain the corresponding target matching rule according to the category information of the text to be extracted in response to the inability to obtain the information extraction result according to the first information extraction model, and the target matching rule is used to characterize the position distribution of each entity type in the specified category text, and the specified category text is of the same category as the text to be extracted; the result determination unit is used to determine the information extraction result according to the target matching rule and the target entity type.
[0133] Furthermore, the text acquisition unit 81 includes a file acquisition subunit, a file identification subunit and a text determination subunit.
[0134] Among them, the file acquisition subunit is used to acquire the file to be identified, and the format of the file to be identified is a portable file format; the file identification subunit is used to perform optical character recognition on the file to be identified and obtain the identification result of the file to be identified; the text determination subunit is used to determine the text to be extracted based on the recognition result.
[0135] Furthermore, the text determination subunit includes a correction module and a text determination module.
[0136] Among them, the correction module is used to correct the recognition result based on a preset fuzzy matching algorithm; the text determination module is used to determine the text to be extracted according to the corrected recognition result.
[0137] After obtaining the text to be extracted, the embodiment of the present invention obtains entity information corresponding to the specific entity type as the information extraction result of the text to be extracted according to the text to be extracted, the specific entity type in the text to be extracted and a pre-trained first information extraction model, and when the information extraction result cannot be obtained according to the first information extraction model, the prompt information is determined according to the text to be extracted and the specific entity type, and the information extraction result is obtained according to the pre-trained second information extraction model; the corresponding matching rules can also be determined according to the category information of the text to be extracted, so as to obtain the information extraction result according to the position distribution of the specific entity type in the text to be extracted. Through the above methods, the embodiment of the present invention can quickly and accurately extract the required information from the text in at least one way, and provide data support for subsequent information analysis.
[0138] Fig. 9 Schematic diagram of an electronic device according to a fourth embodiment of the present invention. In this embodiment, the electronic device 9 includes a server, a terminal, etc. Fig. 9 As shown, the electronic device 9 includes: at least one processor 91; a memory 92 connected to the at least one processor 91 for communication; and a communication component 93 connected to the scanning device for communication, the communication component 93 receives and sends data under the control of the processor 91; wherein the memory 92 stores instructions executable by at least one processor 91, and the instructions are executed by at least one processor 91 to implement the above-mentioned information extraction method.
[0139] Specifically, the electronic device includes: one or more processors 91 and a memory 92, Fig. 9 A processor 91 is taken as an example. The processor 91 and the memory 92 may be connected via a bus or other means. Fig. 9 In the example, the bus connection is used. The memory 92 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The processor 91 executes various functional applications and data processing of the device by running the non-volatile software programs, instructions and modules stored in the memory 92, that is, realizing the above-mentioned information extraction method.
[0140] The memory 92 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and applications required for at least one function; the data storage area may store a list of options, etc. In addition, the memory 92 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 92 may optionally include a memory remotely arranged relative to the processor 91, and these remote memories may be connected to an external device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0141] One or more modules are stored in the memory 92, and when executed by one or more processors 91, the information extraction method in any of the above method embodiments is executed.
[0142] The above-mentioned product can execute the method provided in the embodiment of the present application, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not fully described in this embodiment, please refer to the method provided in the embodiment of the present application.
[0143] After obtaining the text to be extracted, the embodiment of the present invention obtains entity information corresponding to the specific entity type as the information extraction result of the text to be extracted according to the text to be extracted, the specific entity type in the text to be extracted and a pre-trained first information extraction model, and when the information extraction result cannot be obtained according to the first information extraction model, the prompt information is determined according to the text to be extracted and the specific entity type, and the information extraction result is obtained according to the pre-trained second information extraction model; the corresponding matching rules can also be determined according to the category information of the text to be extracted, so as to obtain the information extraction result according to the position distribution of the specific entity type in the text to be extracted. Through the above methods, the embodiment of the present invention can quickly and accurately extract the required information from the text in at least one way, and provide data support for subsequent information analysis.
[0144] Another embodiment of the present invention relates to a non-volatile storage medium for storing a computer-readable program, wherein the computer-readable program is used for a computer to execute part or all of the above method embodiments.
[0145] That is, those skilled in the art can understand that all or part of the steps in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a program, and the program is stored in a storage medium, including a number of instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0146] The above description is only a preferred 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 modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. An information extraction method, It is characterized in that The method comprises: Get the text to be extracted; An information extraction result of the text to be extracted is obtained according to the text to be extracted, the target entity type in the text to be extracted and a pre-trained first information extraction model, wherein the information extraction result includes entity information corresponding to the target entity type in the text to be extracted, the first information extraction model is obtained by training based on a first sample set, the first sample set includes multiple first sample texts, the target entity type and a first answer corresponding to the target entity type, and the first answer is determined based on a predetermined field in the first sample text.
2. The method according to claim 1, It is characterized in that The step of obtaining the information extraction result of the text to be extracted according to the text to be extracted, the target entity type in the text to be extracted, and the pre-trained first information extraction model comprises: Acquire relationship description information of the target entity type, where the relationship description information is used to describe the relationship between the target entity types; The information extraction result is obtained according to the text to be extracted, the target entity type, the relationship description information and the first information extraction model.
3. The method according to claim 1, It is characterized in that The method further comprises: In response to failing to obtain the information extraction result according to the first information extraction model, determining prompt information of the text to be extracted according to the text to be extracted and the target entity type; The information extraction result is obtained according to the prompt information and a pre-trained second information extraction model, the second information extraction model is trained according to a second sample set, the second sample set includes multiple second sample texts, sample prompt information and second answers corresponding to the sample prompt information, the sample prompt information is determined according to the target entity type, and the second answer is determined according to a predetermined field in the second sample text.
4. The method according to claim 3, It is characterized in that The step of determining the prompt information of the text to be extracted according to the text to be extracted and the target entity type includes: Obtaining a first vector corresponding to each candidate sentence in the text to be extracted; Acquire a question statement according to the target entity type; Obtaining a second vector corresponding to the question statement; respectively determining similarity parameters between each of the first vectors and the second vector; Determining, from the candidate sentences, a related sentence corresponding to the question sentence according to the similarity parameter; The prompt information is determined according to the associated sentence and the question sentence.
5. The method according to claim 4, It is characterized in that Determining the associated sentence corresponding to the question sentence from the candidate sentences according to the similarity parameter includes: The candidate sentences whose similarity parameters satisfy a preset similarity condition are determined as the associated sentences.
6. The method according to claim 1 or 3, It is characterized in that The method further comprises: In response to the failure to obtain the information extraction result according to the first information extraction model, obtaining a corresponding target matching rule according to the category information of the text to be extracted, wherein the target matching rule is used to characterize the position distribution of each entity type in a specified category text, and the specified category text is of the same category as the text to be extracted; The information extraction result is determined according to the target matching rule and the target entity type.
7. The method according to claim 1, It is characterized in that The obtaining of the text to be extracted comprises: Obtaining a file to be identified, wherein the format of the file to be identified is a portable file format; Performing optical character recognition on the file to be recognized to obtain a recognition result of the file to be recognized; The text to be extracted is determined according to the recognition result.
8. The method according to claim 7, It is characterized in that Determining the text to be extracted according to the recognition result includes: Correcting the recognition result based on a preset fuzzy matching algorithm; The text to be extracted is determined according to the corrected recognition result.
9. An information extraction device, It is characterized in that The device comprises: A text acquisition unit, used to acquire the text to be extracted; A result acquisition unit is used to obtain an information extraction result of the text to be extracted based on the text to be extracted, the target entity type in the text to be extracted and a pre-trained first information extraction model, wherein the information extraction result includes entity information corresponding to the target entity type in the text to be extracted, the first information extraction model is obtained by training based on a first sample set, the first sample set includes multiple first sample texts, the target entity type and a first answer corresponding to the target entity type, and the first answer is determined based on a predetermined field in the first sample text.
10. An electronic device comprising a memory and a processor, It is characterized in that The memory is used to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement the method according to any one of claims 1 to 8.
11. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
12. A computer program product, It is characterized in that The computer program product comprises a computer program / instructions, which implement the method according to any one of claims 1 to 8 when executed by a processor.
Citation Information
Cited By
Key information extraction method, system and terminal
CN121501976A
