Information extraction method, device and equipment, computer readable storage medium and computer program product
By analyzing the relationship extraction results of text segmentation and associated fragments, the problem of low accuracy of text relationship extraction in the prior art is solved, and a higher accuracy of relationship extraction is achieved.
Patent Information
- Application Number
- CN202411472416.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2025-03-28
AI Technical Summary
In text relationship extraction, the prior art relies on zero-sample learning, resulting in the error or incomplete relationship extraction results, and the context understanding and generalization capabilities of the large model are weak.
By segmenting the text, the first fragment associated with the text fragment is determined and its relationship extraction result is obtained. The text fragment is extracted based on this information, rather than relying on a fixed and unchanging candidate relationship list.
The above understanding ability during relationship extraction is enhanced, and the pattern of relationship extraction is implied, thereby improving the accuracy of relationship extraction.
Smart Images

Figure CN119719327A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of machine learning, and in particular to an information extraction method, apparatus, device, computer-readable storage medium, and computer program product. Background Art
[0002] In the field of Natural Language Processing (NLP), text relation extraction is an important task. Text extraction is to identify and parse various relationships between entities from text data. These relationships can include identity, causality, hyponymy, part-whole, opposition, synonymy, antonymy, etc. For example, when processing the sentence "Apple is a kind of fruit", the goal of text relation extraction is to identify the hyponymy relationship between "apple" and "fruit".
[0003] Text relation extraction is a key technology for understanding and analyzing the relationships between entities in text, and has a wide range of applications in information retrieval, question-answering systems, recommendation systems, text understanding, and data mining. By extracting relational information from text, the meaning and context of the text can be understood more accurately, thereby improving the accuracy and efficiency of text processing and providing strong support for various application scenarios. Summary of the invention
[0004] The embodiments of the present application provide an information extraction method, apparatus, device, computer-readable storage medium, and computer program product, which can improve the accuracy of relationship extraction.
[0005] The technical solution of the embodiment of the present application is implemented as follows:
[0006] The present invention provides an information extraction method, which includes:
[0007] Segment the text to obtain multiple text segments;
[0008] Determine a first segment associated with the text segment, and obtain a first relationship extraction result of the first segment;
[0009] Based on the text segment, the first segment and the first relationship extraction result, relationship extraction is performed on the text segment to obtain a second relationship extraction result of the text segment.
[0010] The present application provides an information extraction device, the device comprising:
[0011] A segmentation module is used to segment the text to obtain multiple text segments;
[0012] A first determination module, configured to determine a first segment associated with the text segment and obtain a first relationship extraction result of the first segment;
[0013] The relationship extraction module is used to perform relationship extraction on the text segment based on the text segment, the first segment and the first relationship extraction result to obtain a second relationship extraction result of the text segment.
[0014] An embodiment of the present application provides a computer device, including:
[0015] A memory for storing computer executable instructions;
[0016] The processor is used to implement the information extraction method provided in the embodiment of the present application when executing the computer executable instructions stored in the memory.
[0017] An embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions for causing a processor to execute the information extraction method provided in the embodiment of the present application.
[0018] An embodiment of the present application provides a computer program product, including a computer program or computer executable instructions. When the computer program or computer executable instructions are executed by a processor, the information extraction method provided in the embodiment of the present application is implemented.
[0019] The embodiments of the present application have the following beneficial effects:
[0020] In the embodiment of the present application, the first segment associated with the text segment will be determined first, that is, the first segment will be retrieved first; when performing relationship extraction, the relationship extraction of the text segment is based on the text segment, the first segment and the first relationship extraction result of the first segment, rather than based on the text segment and a fixed candidate relationship list. In this way, the context comprehension ability during relationship extraction can be enhanced based on the associated first segment and the first relationship extraction result, and the relationship extraction pattern can be implied, thereby ultimately improving the accuracy of relationship extraction. In addition, the first segment is not fixed, but the first segment associated with the text segment is determined based on the text segment, that is, the first segment is always a segment associated with the text segment, rather than an arbitrary segment or a fixed segment. In this way, the first segment and the first relationship extraction result can be used as effective reference information in the relationship extraction process, thereby correctly guiding the relationship extraction process, avoiding the problem of relationship extraction errors, and improving the accuracy of relationship extraction. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 It is a schematic diagram of an implementation framework of a relationship extraction method in related technologies;
[0022] Figure 2 is a schematic diagram of a network architecture of the information extraction system 100 provided in an embodiment of the present application;
[0023] Figure 3 is a schematic diagram of the structure of the server 400 provided in an embodiment of the present application;
[0024] Figure 4 It is a flow chart of the information extraction method provided in the embodiment of the present application;
[0025] Figure 5 This is a schematic diagram of a process for determining a first segment provided in an embodiment of the present application;
[0026] Figure 6 It is a flow chart of a relationship extraction method provided in an embodiment of the present application;
[0027] Figure 7 It is a flow chart of constructing an example template provided in an embodiment of the present application;
[0028] Figure 8 It is a schematic diagram of an implementation framework of the relationship extraction method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.
[0030] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0031] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0032] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0033] Unless otherwise defined, all technical and scientific terms used in the embodiments of the present application have the same meanings as those commonly understood by those skilled in the art. The terms used in the embodiments of the present application are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.
[0034] The relevant data collection and processing in the embodiments of this application should be strictly in accordance with the requirements of relevant laws and regulations when applied in examples, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing within the scope of authorization of laws and regulations and the personal information subject.
[0035] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.
[0036] 1) Large Language Model (LLM) refers to a natural language processing model with a large number of parameters. This model usually requires a lot of computing resources and training data to train, so it can handle various complex natural language tasks, including language understanding, generation, translation, etc.
[0037] Large language models are a rapidly developing direction in the field of artificial intelligence in recent years. Large language models usually have billions or more parameters and can be trained through large-scale text data to learn the structure, patterns and associations of language. Large language models have shown excellent performance in a variety of natural language processing tasks, such as text generation, text classification, machine translation, question-answering systems, etc.
[0038] Here are some key features and applications of large language models:
[0039] Key feature 1: Large-scale parameters: Large language models use a large number of neural network parameters, which are learned by training a large amount of text data. This large-scale parameter enables the model to capture the complexity and diversity of language.
[0040] Key feature 2: Self-supervised learning: Large language models are usually trained using self-supervised learning, which means that the model learns language knowledge by predicting missing parts in the text (such as masked words) without manually labeled data.
[0041] Key feature 3, unsupervised and semi-supervised learning: Large language models can be used for unsupervised learning and semi-supervised learning, which means that the model can improve its performance by interacting with unlabeled data when there is only a small amount of labeled data.
[0042] Key feature 4, fine-tuning and transfer learning: Large language models are usually pre-trained on large-scale general corpora, and can then be adapted to specific downstream tasks such as sentiment analysis and question-answering systems through fine-tuning.
[0043] Key feature 5, multimodal learning: With the development of technology, some large language models have also begun to support multimodal learning, which means that the model can process multiple types of data such as text, images, and sounds at the same time.
[0044] Key Feature 6, Generative: Large language models are usually generative, which means that the model can generate coherent and meaningful text, which is very useful in tasks such as large-scale text generation, story creation, and code generation.
[0045] Key feature 7, context learning ability: Large language models, especially those based on the Transformer architecture, have good context learning capabilities and can understand and generate text related to a given context.
[0046] 2) Retrieval-Augmented Generation (RAG) method first retrieves relevant information from external knowledge sources (such as search engines, databases, or knowledge graphs), and then combines this information with the model’s internal knowledge to generate more accurate and complete text.
[0047] RAG is an innovative machine learning approach that aims to improve the quality of content generated by AI systems and the speed of information updates by integrating real-time data and external knowledge bases. This technology is particularly suitable for complex tasks that require processing the latest information or professional knowledge.
[0048] In traditional pre-trained language models, the models rely on knowledge learned during the training phase, which makes them limited in processing real-time updates or domain-specific knowledge. The emergence of RAG technology solves this problem. RAG combines the capabilities of LLM and retrieval systems, allowing the model to dynamically retrieve external knowledge sources when generating answers, thereby generating more accurate, timely, and rich outputs.
[0049] Specifically, the RAG workflow generally includes: retrieval stage, generation stage, fusion and optimization.
[0050] 3) Zero-Shot-Prompting, which means that the model can predict data for new tasks without seeing any specific examples. It relies on the extensive knowledge gained by the model from pre-training to understand the semantics and context of the task, so that it can be directly applied to new, unseen tasks.
[0051] Zero-shot learning is a cutting-edge research direction in the field of machine learning. It breaks through the limitation of traditional machine learning methods that require a large amount of annotated data (i.e. labeled data) when dealing with unknown categories. In the zero-shot learning framework, the model is trained to understand and process categories that it has never directly encountered. In other words, during the training phase, the model does not come into contact with specific samples of these categories, but learns on high-level concepts, attributes or features related to these categories.
[0052] The core idea of zero-shot learning is to use prior knowledge and external information to infer unknown categories. For example, by learning the associations between categories, attributes, attribute-category relationships, text descriptions, etc., zero-shot learning enables the model to transfer the learned knowledge to new, unseen categories.
[0053] There are several main methods for zero-shot learning, including semantic-based methods, metric learning-based methods, model-based methods, generative model-based methods, etc.
[0054] The advantage of zero-shot learning is that it can handle large amounts of unlabeled data, which is very useful when labeling is expensive or when it is not possible to obtain large amounts of labeled data.
[0055] 4) Few-Shot-Prompting allows the model to use a small number of samples to learn task-specific patterns when solving new tasks, and then apply this knowledge to new data.
[0056] Few-shot learning is an important research direction in the field of machine learning. Few-shot learning focuses on how to enable the model to quickly adapt to and effectively learn new categories or tasks when only receiving a small number of samples (usually 1 to a few samples). Compared with zero-shot learning, few-shot learning requires the model to learn from some specific samples instead of relying solely on category-level descriptions or attributes.
[0057] Application scenarios of few-shot learning include: new category recognition, adaptive migration, personalized recommendations, etc.
[0058] The key challenge of few-shot learning is how to effectively utilize limited samples and ensure that the model can generalize to new samples. To this end, many different techniques and strategies have been proposed, including: meta-learning, model compression and distillation, data augmentation, metric learning-based methods, model architecture selection, etc.
[0059] With the continuous advancement of artificial intelligence technology, few-sample learning is expected to be more widely used in various fields, such as medical diagnosis, personalized recommendations, and autonomous driving.
[0060] In order to better understand the information extraction method provided in the embodiments of the present application, the information extraction method in the related art and its existing shortcomings are first described.
[0061] Related technologies usually use zero-shot learning to extract text relationships, which requires relying entirely on the knowledge obtained from pre-training of large models to understand the semantics and context of the task, resulting in erroneous or incomplete relationship extraction results.
[0062] With the continuous rise of the level of informatization in modern society, the informatization construction in various fields is also advancing rapidly. Therefore, information extraction for text is also widely used in the informatization construction in various fields. Taking the judicial field as an example, various judicial institutions output various judicial documents such as judgments, rulings, mediation documents, etc. as the results of cases every day. Among them, the court judgment documents contain a large amount of case information, case trial information and court judgment information. Through in-depth analysis and research on court judgment documents, we can reveal the laws of judicial trials, discover possible problems, and provide important reference for the optimization of the judicial system. It is of great significance to improve judicial fairness, protect citizens' rights, and maintain social fairness and justice.
[0063] In the actual work of the courts, various types of judgment documents usually exist in the form of semi-structured text. When processing these texts, traditional relationship extraction methods usually rely on manual entry or experience-based extraction of the required legal relationship types. This method not only consumes a lot of manpower and material resources, but also faces complex situations, such as involving multiple parties and multiple appraisal agencies. Traditional rule parsing methods often cannot guarantee a high accuracy rate. In addition, another problem with this traditional information extraction method is that it has low reusability and the extraction rules are difficult to adapt to different cases and scenarios. Therefore, it needs to be constantly adjusted and maintained, which significantly increases the maintenance cost.
[0064] With the development of large language models, related technologies have proposed a method for extracting judicial document relations based on large language model prompt words. The process of the method for extracting judicial document relations includes the following steps S01 to S04:
[0065] Step S01, define in advance a set of relationship types to be extracted.
[0066] Step S02, divide the judgment document into sentences to obtain a sentence set.
[0067] Step S03, traverse each sentence, extract entities contained in the sentence, and obtain an entity list.
[0068] Step S04: Combining the sentence, entity list, and relation type candidate list to obtain relation extraction prompt information (prompt) is input into the large language model to obtain the result of relation extraction. The relation type candidate list is obtained from the relation type set.
[0069] Figure 1 It is a schematic diagram of an implementation framework of the relationship extraction method in related technologies. Figure 1 In the example, the judgment document 11 is segmented according to line breaks to obtain document segments 1 to N; taking document segment 1 as an example, the document segment 1 is input into the large language model 12, so as to use the large language model 12 to perform entity extraction on the document segment 1, and obtain entity extraction result 13; then the document segment 1, the entity extraction result 13 and the relationship type candidate list 14 are combined to obtain prompt information; finally, the prompt information is input into the large language model 15, so as to use the large language model 15 to perform relationship extraction on the document segment 1 based on the prompt information, and obtain relationship extraction result 16.
[0070] The above-mentioned judicial document relationship extraction method has the advantages of not requiring labeled training samples and having low implementation cost. However, the above-mentioned method belongs to zero-sample learning and needs to rely entirely on the knowledge obtained by the large model from pre-training to understand the semantics and context of the task, which will lead to erroneous or incomplete relationship extraction results.
[0071] Combining the above-mentioned related technologies, it can be seen that the disadvantages of the related technologies include at least: first, the relationship extraction results are wrong or incomplete, that is, the accuracy of relationship extraction is low; second, the context understanding and generalization capabilities of large models are weak.
[0072] The embodiments of the present application provide an information extraction method, apparatus, computer device, computer-readable storage medium, and computer program product, which can improve the accuracy of relationship extraction. The following describes an exemplary application of the computer device provided in the embodiments of the present application. The computer device provided in the embodiments of the present application can be implemented as various types of terminals such as laptops, tablet computers, desktop computers, set-top boxes, smart phones, smart speakers, smart watches, smart TVs, and vehicle-mounted terminals, and can also be implemented as servers. Below, an exemplary application when the computer device is implemented as a server will be described.
[0073] See also Figure 2 , Figure 2 It is a schematic diagram of the network architecture of the information extraction system 100 provided in an embodiment of the present application. To support an information extraction application, the server 400 is connected to the terminal 200 via the network 300. The network 300 may be a wide area network or a local area network, or a combination of the two.
[0074] Terminal 200 is used to receive an information extraction instruction for a text and generate an information extraction request for the text. Terminal 200 also sends the information extraction request to server 400, and the information extraction request carries text. Server 400 is used to segment the text to obtain multiple text fragments; determine a first fragment associated with the text fragment, and obtain a first relationship extraction result of the first fragment; based on the text fragment, the first fragment and the first relationship extraction result, perform relationship extraction on the text fragment to obtain a second relationship extraction result of the text fragment; server 400 also sends the second relationship extraction result to terminal 200, so that terminal 200 displays the second relationship extraction result of the text fragment.
[0075] In the embodiment of the present application, the server 400 will first determine the first segment associated with the text segment, that is, first retrieve the first segment; when performing relationship extraction, the relationship extraction of the text segment is based on the text segment, the first segment and the first relationship extraction result of the first segment, rather than based on the text segment and the fixed candidate relationship list. In this way, the context comprehension ability during relationship extraction can be enhanced based on the associated first segment and the first relationship extraction result, and the relationship extraction mode can be implied, thereby ultimately improving the accuracy of relationship extraction. In addition, the first segment is not fixed, but the first segment associated with the text segment is determined based on the text segment, that is, the first segment is always a segment associated with the text segment, rather than an arbitrary segment or a fixed segment. In this way, the first segment and the first relationship extraction result can be used as effective reference information in the relationship extraction process, thereby correctly guiding the relationship extraction process, avoiding the problem of relationship extraction errors, and improving the accuracy of relationship extraction.
[0076] In some embodiments, the server 400 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms. The terminal and the server may be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiments of the present application.
[0077] See also Figure 3, Figure 3 is a schematic diagram of the structure of the server 400 provided in an embodiment of the present application, Figure 3 The server 400 shown includes: at least one processor 410, a memory 450, at least one network interface 420 and a user interface 430. The various components in the server 400 are coupled together via a bus system 440. It is understood that the bus system 440 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 440 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 440 is not described in detail. Figure 3 Various buses are labeled as bus system 440 .
[0078] The processor 410 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0079] The user interface 430 includes one or more output devices 431 that enable presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 430 also includes one or more input devices 432, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.
[0080] The memory 450 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard disk drives, optical disk drives, etc. The memory 450 may optionally include one or more storage devices that are physically remote from the processor 410.
[0081] The memory 450 includes a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memories. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 450 described in the embodiments of the present application is intended to include any suitable type of memory.
[0082] In some embodiments, memory 450 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplarily described below.
[0083] Operating system 451, including system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks;
[0084] A network communication module 452, used to reach other electronic devices via one or more (wired or wireless) network interfaces 420, exemplary network interfaces 420 include: Bluetooth, Wireless Compatibility Certification (WiFi), and Universal Serial Bus (USB), etc.;
[0085] a presentation module 453 for enabling presentation of information via one or more output devices 431 (e.g., display screen, speaker, etc.) associated with the user interface 430 (e.g., a user interface for operating peripherals and displaying content and information);
[0086] The input processing module 454 is used to detect one or more user inputs or interactions from one of the one or more input devices 432 and translate the detected inputs or interactions.
[0087] In some embodiments, the device provided in the embodiments of the present application can be implemented in software. Figure 3 The information extraction device 455 stored in the memory 450 is shown, which can be software in the form of a program and a plug-in, etc., and includes the following software modules: a segmentation module 4551, a first determination module 4552 and a relationship extraction module 4553. These modules are logical, so they can be arbitrarily combined or further divided according to the functions implemented. The functions of each module will be explained below.
[0088] In other embodiments, the device provided in the embodiments of the present application can be implemented in hardware. As an example, the device provided in the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the information extraction method provided in the embodiments of the present application. For example, the processor in the form of a hardware decoding processor can adopt one or more application specific integrated circuits (Application Specific Integrated Circuit, ASIC), DSP, programmable logic device (Programmable Logic Device, PLD), complex programmable logic device (Complex Programmable Logic Device, CPLD), field programmable gate array (Field-Programmable Gate Array, FPGA) or other electronic components.
[0089] In some embodiments, the server can implement the information extraction method provided in the embodiment of the present application by running various computer executable instructions or computer programs. For example, computer executable instructions can be commands, machine instructions or software instructions at the microprogram level. The computer program can be a native program or software module in the operating system; it can be a local (Native) application (APPlication, APP), that is, a program that needs to be installed in the operating system to run, such as a relationship extraction APP; it can also be a small program that can be embedded in any APP, that is, a program that can be run only by downloading it to a browser environment. In short, the above-mentioned computer executable instructions can be instructions in any form, and the above-mentioned computer program can be an application, module or plug-in in any form.
[0090] The information extraction method provided in the embodiment of the present application will be explained in combination with the exemplary application and implementation of the server provided in the embodiment of the present application.
[0091] The following describes the information extraction method provided by the embodiment of the present application. As mentioned above, the computer device implementing the information extraction method of the embodiment of the present application can be a terminal, a server, or a combination of the two. Therefore, the execution subject of each step will not be repeatedly described below.
[0092] It should be noted that the examples of the information extraction method below are based on the judicial documents as an example. Those skilled in the art can apply the information extraction method provided in the embodiments of the present application to the information extraction of other types of objects, including historical documents, news reports, literature and novels, biomedical documents, etc., based on their understanding of the following. The embodiments of the present application can also be applied to various scenarios, including but not limited to justice, literature, digital media, education and training, artificial intelligence, smart transportation, etc.
[0093] See also Figure 4 , Figure 4 This is a first flow chart of the information extraction method provided in the embodiment of the present application, which will be combined with Figure 4 The steps shown are used to illustrate the information extraction method provided in the embodiment of the present application. Figure 4 The execution subject is the server.
[0094] In step S101, the text is segmented to obtain a plurality of text segments.
[0095] In the embodiment of the present application, the text may be referred to as the text to be processed, and the text may also be referred to as the text to be extracted. The text is the object of information extraction in the embodiment of the present application. Exemplarily, the text may be a judicial document, historical document, news report, literature, novel, etc.
[0096] In some embodiments, the text may be obtained from a public platform, for example, the text may be obtained from a public database or a published book.
[0097] In some embodiments, the text segmentation process can be implemented by one of the following methods:
[0098] Method 1: segmentation based on fixed length: This method has the feature of being easy to implement, such as setting the length of each text segment to 100 characters, and then segmenting the text character by character from the beginning until the end.
[0099] Method 2: Sentence or paragraph segmentation: If the text is structured, for example, there are obvious separators (such as periods, commas, etc.) after each paragraph or sentence, these separators can be identified through regular expressions and other methods, and the text can be segmented based on the separators.
[0100] Method 3: Segmentation based on topics: For texts without obvious separators, segmentation can be performed based on the topic or key information of the text content. This usually requires natural language processing (NLP) technology, such as text clustering, topic modeling, etc. Among them, the topic model can be Latent Dirichlet Allocation (LDA).
[0101] Method 4: Context-based segmentation: In some cases, the text can be segmented based on contextual information. For example, when discussing a certain topic, the text can be segmented based on topic transition points to obtain text fragments.
[0102] Method 5: Use specialized segmentation tools or libraries: For example, in Python, you can use the Natural Language Toolkit (NLTK) library for sentence segmentation, and use Generative Models for Topic Modeling (GENSIM) for text segmentation.
[0103] In step S102, a first segment associated with the text segment is determined, and a first relationship extraction result of the first segment is obtained.
[0104] In an embodiment of the present application, for each text fragment, a first fragment associated with it is determined from multiple second fragments, wherein the multiple second fragments are text fragments collected in advance and belonging to the same field as the text. Since the text fragment in the text is a known and determined text fragment, and the text fragment has its own personalized characteristics, based on this, a first fragment associated with the text fragment is determined from multiple second fragments, and the first fragment can be a second fragment that meets the similarity condition with the text fragment.
[0105] In some embodiments, the second segment is a text segment that has completed the relationship extraction in advance. The relationship extraction result corresponding to the second segment can be recorded as the third relationship extraction result, and each second segment can correspond to at least one third relationship extraction result. Based on this, since the first segment belongs to the second segment, the relationship extraction result corresponding to the first segment is recorded as the first relationship extraction result. The first relationship extraction result refers to the semantic relationship between entities identified from the first segment, usually presented in the form of structured data. The first relationship extraction result includes entities and relationships. The representation form of the first relationship extraction result can be a triple (entity 1, relationship, entity 2). For example, the first segment "Zhang San was born in Province A", the first relationship extraction result can be (Zhang San was born in Province A). The first relationship extraction result can be converted into structured data, which is convenient for use in downstream tasks, such as knowledge graph construction, information retrieval, etc.
[0106] In some embodiments, after determining the first segment, the embodiments of the present application further obtain a first relationship extraction result of the first segment.
[0107] In some embodiments, see Figure 5 , the "determining the first segment associated with the text segment" in the above step S102 can be implemented by the following steps S1021 to S1023, which are described in detail below.
[0108] In step S1021, a first feature vector of the second segment is obtained from a vector database.
[0109] In some embodiments, a vector database is constructed in advance, and the vector database stores the first feature vector of each second segment and the segment identifier of the second segment. Based on this, the first feature vectors of multiple second segments can be obtained from the vector data based on the segment identifier of the second segment. The first feature vector is obtained by extracting features from the second segment.
[0110] In some embodiments, before obtaining the first feature vector, it is necessary to first construct a vector database, that is, before executing the above step S1021, the following steps S001 to S002 may also be executed, which are described in detail below.
[0111] In step S001, feature extraction is performed on the second segment to obtain a first feature vector of the second segment.
[0112] In some embodiments, the second segment can be obtained first. For example, taking the text as a judicial document, all the relationship types corresponding to the judicial document are first determined, and then the segment with the highest frequency of occurrence of each relationship type is obtained, and the segment with the highest frequency of occurrence is determined as the second segment of the relationship type, so as to obtain multiple second segments. Among them, the high frequency of occurrence can refer to the frequency of occurrence being higher than the preset frequency threshold, and the high frequency of occurrence can also refer to the frequency of occurrence being ranked in the top S, where S is a positive integer, and for example, the value of S can be 4, 5, or 6.
[0113] In an embodiment of the present application, multiple second fragments can be obtained from a public platform through file reading, data query, etc.
[0114] In the embodiment of the present application, feature extraction of the second segment may be achieved by at least one of the following methods:
[0115] Method 1, Bag of Words model: first, split the second segment into words or phrases; then, regardless of the order of the words, only count the number of times each word appears in the second segment; finally, convert the word counts into a vector of a fixed size, which is called the first feature vector of the second segment.
[0116] Method 2, Term Frequency-Inverse Document Frequency (TF-IDF): is a weighted bag-of-words model, in which term frequency (TF) considers the relative frequency of words in the second segment, while inverse document frequency (IDF) penalizes words that frequently appear in all second segments; the resulting first feature vector can better reflect the importance of words and is useful for distinguishing different second segments.
[0117] Method 3: Word Embeddings: Word embedding models (such as Word2Vec, GloVe, and FastText) learn low-dimensional continuous vector representations of words, which can capture the semantic information of words. Through word embedding, a first feature vector containing semantic information can be obtained.
[0118] Method 4: Topic Models: For example, the Latent Dirichlet Allocation (LDA) model can learn the topic distribution in the document collection and generate a topic distribution for each document and word. The topic model can reveal the deep structure of the second segment and generate a topic-related first feature vector for the second segment.
[0119] Method 5: Stemming / Lemmatization: Stemming is the process of simplifying a word into its basic form, such as simplifying "running" to "run". Lemmatization is the process of converting a word into its standard form in a dictionary, such as converting "running" to "run". Both stemming and lemmatization can reduce vocabulary dimensions, which helps simplify the feature extraction process and improve the efficiency of feature extraction.
[0120] Method 6: Parsing: Parsing is a process of decomposing the second segment into syntactic structures, such as dependency syntactic analysis, phrase structure analysis, etc. By analyzing the syntactic structure of the second segment, a first feature vector related to the meaning of the sentence can be extracted.
[0121] Method 7: Feature extraction based on deep learning: Deep learning models such as Convolutional Neural Networks (CNN), Recurrent Neural Networks (RNN), and Long Short-Term Memory (LSTM) can automatically learn useful features from the second input segment to obtain the first feature vector. Deep learning models can capture complex patterns and relationships when processing text data.
[0122] In step S002, a vector database is constructed using the first feature vector.
[0123] In the embodiment of the present application, an empty initial vector database may be created first, and then each first feature vector obtained in step S001 and the fragment identifier of the second fragment may be added to the initial vector database to complete the construction of the vector database.
[0124] The vector database can be constructed through the above steps S001 to S002. The above steps S001 to S002 can also be executed before the above step S101, that is, before information extraction, the creation of vector data is completed in advance, which can improve the efficiency of subsequent information extraction.
[0125] In some embodiments, the vector database may also be updated, that is, after the above step S002, the following steps S003 to S005 may also be performed, which are described in detail below.
[0126] In step S003, in response to the database update instruction, the third segment to be added is obtained.
[0127] In some embodiments, the database update instruction may be automatically triggered. For example, when a new type of relationship is detected, a segment with a high frequency of occurrence of the new type of relationship is obtained, and the segment with a high frequency of occurrence of the new type of relationship is determined as the third segment.
[0128] In some embodiments, the database update instruction may also be triggered based on a touch or click operation. For example, when a click operation of clicking the "Update" control is received, it is determined that the database update instruction is received; then the third segment is obtained from the "Content Edit Box". The content edit box is used to receive the third segment corresponding to the new relationship type.
[0129] In step S004, feature extraction is performed on the third segment to obtain a third feature vector.
[0130] In some embodiments, the implementation process of step S004 is similar to the implementation process of step S001 described above. Therefore, the implementation process of step S004 may refer to the implementation process of step S001 described above.
[0131] In step S005, the vector database is updated using the third feature vector.
[0132] In some embodiments, the third feature vector is added to the vector database, thereby completing the update of the vector database.
[0133] Through the above steps S003 to S005, real-time updating of vector data can be achieved, and the third feature vector corresponding to the new relationship type can be added to the vector database in time, thereby improving the generalization ability of the vector database, so that a first segment with high accuracy can be determined based on the vector database.
[0134] Continue to see Figure 5 , and the description continues with step S1021 above.
[0135] In step S1022, feature extraction is performed on the text segment to obtain a second feature vector of the text segment.
[0136] In the embodiment of the present application, in order to improve the consistency and comparability between the first feature vector and the second feature vector, the method of extracting features from the text segment is the same as the feature extraction method used in the above step S001.
[0137] In some embodiments, the implementation process of the above step S1022 is similar to the implementation process of the above step S001, and therefore, the implementation process of step S1022 may refer to the implementation process of the above step S001.
[0138] In step S1023, based on the first feature vector and the second feature vector, a first segment associated with the text segment is determined.
[0139] In the embodiment of the present application, the first segment associated with the text segment can be understood as a segment similar to the text segment, and the above step S1023 determines the first segment similar to the text segment from multiple second segments based on the first feature vector and the second feature vector.
[0140] In some embodiments, the first feature similarity between each second segment and the text segment can be determined based on the first feature vector and the second feature vector; and then based on the first feature similarity, a first segment associated with the text segment can be determined from the plurality of second segments. The first segment associated with the text segment can be considered as a second segment that meets the similarity condition with the text segment.
[0141] In some embodiments, the above step S1023 can be implemented by following the steps S231 to S233, which are described in detail below.
[0142] In step S231 , the first feature similarity between each first feature vector and the second feature vector is determined.
[0143] In some embodiments, the first feature similarity may be determined by any of the following methods:
[0144] Method 1, Cosine Similarity: Cosine similarity is a method to measure the cosine value of the angle between two vectors. Cosine similarity is to determine the ratio of the dot product of two feature vectors to the product of their respective modulus lengths to obtain the first feature similarity. The cosine value ranges from -1 to 1, 1 means that the two vectors are in exactly the same direction, -1 means they are in completely opposite directions, and 0 means that the two vectors are orthogonal, that is, there is no angle between the two vectors.
[0145] Method 2: Hamming distance: Hamming distance is a method to measure the difference between two strings of equal length. The Hamming distance calculates the number of different characters in the corresponding positions of the two strings. The larger the Hamming distance, the greater the difference between the second segment and the text segment.
[0146] Method 3, Euclidean distance: Euclidean distance is the straight-line distance between two points in Euclidean space. In the case of the first eigenvector and the second eigenvector, Euclidean distance calculates the distance between the two vectors.
[0147] Method 4: Manhattan Distance: Manhattan distance is the sum of the absolute distances between two points on each coordinate axis in a standard coordinate system. Manhattan distance gives equal importance to each element in the first eigenvector and the second eigenvector.
[0148] Method 5, Dot Product: Dot product is another way to measure the directional relationship between two vectors. The result of dot product is the same as cosine similarity.
[0149] Method 6: Longest Common Subsequence (LCS): LCS is a sequence alignment technique used to find the longest common subsequence between the second segment and the text segment. In text similarity calculation, the length of LCS can be used as a measure of the similarity between the second segment and the text segment.
[0150] Method 7: Cosine similarity weighted by term frequency-inverse document frequency TF-IDF: After vectorizing the second segment and the text segment using TF-IDF, the cosine similarity of the weighted feature vectors can be calculated. This method takes into account the importance of each word in the document, so it is more effective in calculating text similarity.
[0151] In step S232, the first feature similarity that satisfies the similarity condition is determined.
[0152] In the embodiment of the present application, the similarity condition may be greater than a similarity threshold; the similarity condition may also be the first S with the highest similarity.
[0153] In some embodiments, when the similarity condition is greater than a similarity threshold, the first feature similarity greater than the similarity threshold is determined as the first feature similarity that satisfies the similarity condition; when the similarity condition is the top 5 with the highest similarities, the top 5 first feature similarities with the highest values are determined as the first feature similarities that satisfy the similarity condition.
[0154] In step S233, the second segment corresponding to the first feature similarity that satisfies the similarity condition is determined as the first segment associated with the text segment.
[0155] In some embodiments, based on the first feature similarity that satisfies the similarity condition, a similar first feature vector corresponding to the first feature similarity that satisfies the similarity condition can be determined; then a similar segment identifier of the similar first feature vector can be obtained from a vector database; finally, the second segment corresponding to the similar segment identifier is determined as the first segment associated with the text segment. That is, the embodiment of the present application determines the second segment corresponding to the first feature similarity that satisfies the similarity condition as the first segment; in this way, the embodiment of the present application determines the first segment associated with the text segment from multiple second segments.
[0156] Through the above steps S231 to S233, based on the first feature vector and the second feature vector, the first segment can be quickly and accurately retrieved and screened out from the plurality of second segments.
[0157] Through the above steps S1021 to S1023, the first feature vector and the second feature vector are obtained, and the first feature vector and the second feature vector are obtained using the same feature extraction method. In this way, based on the first feature vector and the second feature vector, a reference vector with high accuracy can be quickly and accurately determined, that is, the first segment that is truly similar to the text segment is determined.
[0158] Continue to see Figure 4 , and the description continues with step S102 above.
[0159] In step S103, based on the text segment, the first segment and the first relationship extraction result, relationship extraction is performed on the text segment to obtain a second relationship extraction result of the text segment.
[0160] In the embodiment of the present application, the relationship extraction may be performed in any of the following ways:
[0161] Approach 1: Machine Learning-Based Approach: Use machine learning algorithms to train models to identify relationships in text fragments. This approach can be supervised learning, where labeled data is used to train the model, or unsupervised learning, such as clustering methods.
[0162] Method 2: Deep Learning-Based Approach: Use deep learning models, such as convolutional neural networks (CNN), recurrent neural networks (RNN), and long short-term memory networks (LSTM), to automatically learn relational features in text fragments. Deep learning-based methods perform well in processing complex language structures and abstract concepts.
[0163] Method 3: Graph Neural Network-Based Approach: Use graph neural networks to represent text fragment data, where entities and relationships are represented as nodes and edges in the graph, and then learn their features and relationships through graph neural networks. This method is suitable for processing complex entity relationships and multi-hop reasoning.
[0164] Method 4: Multi-Task Learning: Simultaneously train multiple related tasks, such as entity recognition, relationship extraction, event extraction, etc., to improve the generalization ability and performance of the model.
[0165] In some embodiments, taking the above-mentioned method 2 as an example, prompt information can be constructed based on the text segment, the first segment and the first relationship extraction result, and the prompt information includes an example template, so that during the relationship extraction process, the deep learning model can be correctly guided by the example template to generate an accurate second relationship extraction result.
[0166] In some embodiments, performing relation extraction on a text segment refers to identifying and extracting the relationship between entities from a given text segment, and the second relation extraction result obtained in this way can be the relationship between entities in the text segment. Relation extraction usually involves natural language processing (NLP) tasks, which include two subtasks: entity recognition and relation classification.
[0167] For entity recognition: First, you need to identify the key entities in the text fragment, such as names, places, organizations, dates, etc. These entities are the "objects" discussed in the text fragment, and entities are the basis for relationship extraction.
[0168] For relation classification: After entity recognition, the next step is to determine the relationship between these entities. This requires identifying the predicate or relation words in the text fragment and associating them with the previously identified entities. For example, in the sentence "A was born in Ulm", "A" and "Ulm" are entities, while "was born in" is a relation word that indicates that the relationship between the entities is "place of birth".
[0169] The task of relation extraction can be further divided into multiple subtasks, such as named entity relation extraction (NERE), event extraction, and event relation extraction. Relation extraction is one of the key technologies for building knowledge graphs and semantic networks. Relation extraction has a wide range of applications in information retrieval, recommendation systems, question-answering systems, and other fields.
[0170] In some embodiments, see Figure 6 The above step S103 can be implemented by the following steps S1031 to S1033, which are described in detail below.
[0171] In step S1031, an example template is constructed based on each first segment and each first relationship extraction result.
[0172] In the embodiment of the present application, each first segment and the corresponding first relationship extraction result can be spliced to obtain an example template. Alternatively, each first segment and the corresponding first relationship extraction result can be sorted to obtain sorted first segments and corresponding first relationship extraction results; and then the sorted first segments and the corresponding first relationship extraction results can be spliced to obtain an example template.
[0173] In the embodiments of the present application, the example template refers to some exemplary text provided in the prompt information, which is intended to provide the model with examples and guidance on how to complete the task. In natural language processing (NLP), prompt information is an effective technology that guides the model to generate corresponding text or make predictions by providing clues and context.
[0174] The roles of example templates include providing guidance, promoting generation diversity, improving generation quality, alleviating the problem of insufficient data, enhancing generalization ability, and promoting interaction.
[0175] For providing guidance, the example template provides the model with examples of how to generate relationship extraction results, helping the model to better understand and complete tasks. For promoting generation diversity, by providing different example templates, the model can be encouraged to generate more diverse and innovative relationship extraction results. For improving generation quality, the example template can serve as a quality reference for the relationship extraction results generated by the model, helping the model to generate more accurate and relevant second relationship extraction results. For alleviating the problem of insufficient data, in the case of insufficient training data, the example template can help the model better understand the task and generate higher quality relationship extraction results. For enhancing generalization ability, by providing example templates in different fields, the model can improve its generalization ability in different tasks and fields. For promoting interaction, in interactive tasks, the example template can serve as a bridge between users and models to promote better understanding and communication between the two parties.
[0176] In some embodiments, see Figure 7 The above step S1031 can be implemented by the following steps S311 to S313, which are described in detail below.
[0177] In step S311, the second feature similarity between the text segment and each first segment is obtained.
[0178] In some embodiments, the similarity between each first segment and the text segment may be determined as the second feature similarity. Similar to the above step S231, the second feature similarity may be determined based on the first feature vector and the second feature vector of each first segment.
[0179] In some embodiments, since the first segment is included in the second segment, the second feature similarity is also included in the first feature similarity. Based on this, the segment identifier of the first segment can be obtained first, and then the second feature similarity can be obtained from the first feature similarity based on the segment identifier.
[0180] In step S312, each first segment is sorted in descending order of the second feature similarity to obtain sorted segments.
[0181] In an embodiment of the present application, the second feature similarities are sorted in descending order from high to low to obtain sorted second feature similarities; then the first fragments are sorted in the order of the sorted second feature similarities to obtain sorted fragments, that is, the first fragments are sorted in the order of the second feature similarities from high to low.
[0182] In step S313, each sorted segment and the first relationship extraction result of the sorted segments are determined as an example template.
[0183] In the embodiment of the present application, the first relationship extraction results corresponding to each sorted segment and sorted fragment are spliced to obtain an example template.
[0184] Through the above steps S311 to S313, the first fragments are first sorted in descending order according to the second feature similarity, and then each sorted fragment and the first relationship extraction result corresponding to the sorted fragment are determined as an example template; in this way, the first fragments and the first relationship extraction results with high similarity and strong correlation are placed in the front position, thereby increasing the attention paid to the first fragments and the first relationship extraction results with high similarity and strong correlation in the relationship extraction model, and ultimately improving the accuracy of relationship extraction.
[0185] Continue to see Figure 6 , and the description continues with step S1031 above.
[0186] In step S1032, prompt information is determined based on the text segment and the example template.
[0187] In the embodiment of the present application, the text segment and the example template can be combined to obtain prompt information. It is also possible to first perform entity extraction on the text segment to obtain an entity extraction result, and then combine the text segment, the example template and the entity extraction result to obtain prompt information.
[0188] In some embodiments, the effects of prompt information include guiding generation, improving coherence, improving response quality, reducing model difficulty, alleviating data deficiency problems, adaptability and flexibility, and enhancing understanding.
[0189] For the role of guiding generation, prompt information provides the initial input or context for the relation extraction model to help the model start the generation process. For the role of improving coherence, prompt information can ensure that the generated relation extraction results are consistent in theme and style. For the role of improving the quality of replies, in interactive systems such as chatbots and virtual assistants, prompt information can help generate more natural and useful replies. For the role of reducing model difficulty, prompt information provides additional information to the model, which helps the model understand and complete more complex tasks. For the role of alleviating the problem of insufficient data, when training data is limited, prompt information can help the model generate richer text and alleviate the impact of insufficient data. For the role of adaptability and flexibility, prompt information can be customized according to different needs and task scenarios, making the model more adaptable to different usage environments. For the role of enhancing understanding, prompt information can help the model better understand intent and needs, thereby generating more expected relation extraction results.
[0190] In some embodiments, the above step S1032 can be implemented by the following steps S321 and S322, which are described in detail below.
[0191] In step S321, entity extraction is performed on the text segment to obtain an entity extraction result.
[0192] In some embodiments, entity extraction may be achieved by following steps S211 to S215, which are described in detail below.
[0193] In step S211, tokenization is performed.
[0194] Here, the text fragment is segmented into words or phrases. This step is to identify the basic units in the text fragment, such as words, punctuation marks, etc.
[0195] In step S212, part-of-speech tagging is performed.
[0196] Here, each tokenized unit is tagged with part-of-speech, such as noun, verb, adjective, etc., which helps in identifying entities in the text fragment.
[0197] In step S213, named entity recognition (NER) is performed.
[0198] Here, named entities such as people, places, organizations, time, currency, etc. are identified in text snippets. This usually involves training an entity extraction model using supervised or unsupervised learning methods.
[0199] In step S214, entity linking.
[0200] Here, the identified entities are associated with entities in a knowledge base (such as a dictionary, a database, etc.) to ensure the accuracy of entity recognition.
[0201] In step S215, post-processing.
[0202] Here, the entity extraction results are cleaned and optimized, for example, by removing misidentified entities.
[0203] The description will continue with step S321 above.
[0204] In step S322, the text fragment, the example template and the entity extraction result are combined to obtain prompt information.
[0205] In some embodiments, the text fragment, the example template, and the entity extraction result can be spliced in the order to obtain prompt information. The example template, the text fragment, and the entity extraction result can also be spliced in the order to obtain prompt information. The entity extraction result, the example template, and the text fragment can also be spliced in the order to obtain prompt information. That is, when splicing, the embodiment of the present application does not limit the order of the text fragment, the example template, and the entity extraction result.
[0206] Through the above steps S321 to S322, entity extraction results are first obtained through entity extraction, and then the text fragment, example template and entity extraction results are combined to obtain prompt information, so as to obtain prompt information with strong relevance and high clarity.
[0207] Continue to see Figure 6 , and the description continues with step S1032 above.
[0208] In step S1033, a relation extraction model is used to extract a relation from the text segment based on the prompt information to obtain a second relation extraction result of the text segment.
[0209] In an embodiment of the present application, the relationship extraction model is a trained model, which can handle relationship extraction tasks.
[0210] In some embodiments, prompt information can be input into the relationship extraction model. Since the prompt information includes text fragments, example templates and entity extraction results, based on this, the relationship extraction model predicts the text fragment based on the example template to obtain a prediction result, that is, the relationship between the entities contained in the text fragment is obtained. The prediction result is the second relationship extraction result.
[0211] In some embodiments, the prediction results may be post-processed to remove erroneous relationships, merge similar relationships, etc., so as to obtain a second relationship extraction result, which can improve the accuracy and reliability of the second relationship extraction result.
[0212] Through the above steps S1031 to S1033, an example template is constructed based on the first fragment and the first relationship extraction result, and then prompt information is constructed based on the text fragment and the example template. Based on this, in the process of performing relationship extraction based on the prompt information, since the example template can provide correct guidance, a second relationship extraction result with high accuracy can be obtained.
[0213] Through the above steps S101 to S103, the first segment associated with the text segment will be determined from multiple second segments, that is, the first segment will be retrieved first; and an example template will be constructed based on the first segment and the first relationship extraction result, and then the prompt information will be constructed based on the text segment and the example template. Based on this, in the process of performing relationship extraction based on the prompt information, since the example template can provide correct guidance, a second relationship extraction result with high accuracy can be obtained. The embodiment of the present application does not perform relationship extraction based on the text segment and the fixed candidate relationship list, so that the context comprehension ability during relationship extraction can be enhanced based on the prompt information containing the example template, and the mode of relationship extraction can be implied, thereby ultimately improving the accuracy of relationship extraction. In addition, the first segment is not fixed, but the first segment associated with the text segment is determined from multiple second segments according to the text segment, that is, the first segment is always a segment associated with the text segment, rather than an arbitrary segment or a fixed segment. In this way, the first segment and the first relationship extraction result can be used as effective reference information in the relationship extraction process, thereby correctly guiding the relationship extraction process, avoiding the problem of relationship extraction errors, and improving the accuracy of relationship extraction. Before information extraction, a vector database can be constructed in advance, and during the information extraction process, the vector database can be updated in real time. This can improve the efficiency of information extraction and the generalization ability of the vector database, so that a first segment with high accuracy can be determined based on the vector database.
[0214] The following is an explanation of an exemplary application of the embodiments of the present application in a practical application scenario.
[0215] In order to solve the problem of low accuracy of relationship extraction in judicial documents by large models, the retrieval enhancement generation method is used in relationship extraction. The embodiment of the present application proposes an information extraction method. In the first step, the types of relationships to be extracted from judicial documents are first defined, assuming that there are M types, where judicial document 11 corresponds to the text in other embodiments. In the second step, common context descriptions and relationship extraction results corresponding to each type of relationship are collected. Assuming that each type of relationship has K common context descriptions, multiple descriptions are then passed through a pre-trained vector model to obtain corresponding vectors, and the obtained vectors are stored in a vector database, where the vector corresponds to the first feature vector in other embodiments, and the context description corresponds to the second segment in other embodiments. In the third step, the text of the judicial document is segmented according to periods to obtain a segmentation list, where the segmentation list corresponds to multiple text segments in other embodiments; in the third step, entity extraction is also performed on each segmented text segment to obtain a list of all entities in the segment. In the fourth step, the text fragment of the segment is also input into the same pre-trained vector model as in the second step above to obtain the corresponding vector, which corresponds to the second feature vector in other embodiments, and the S context descriptions and relationship extraction results most similar to the second feature vector are retrieved from the vector library, which is the retrieval process. In the fifth step, the S most similar context description segments retrieved and their relationship extraction results are added to the prompt word as examples, which is the enhancement process, wherein the prompt word corresponds to the prompt information in other embodiments. In the last step, the text fragment of the segment, the entity extraction result of the segment, and the example template are combined into a prompt word (Prompt) and input into the large model, and the large model is allowed to extract all the entity relationship lists of the segment, which is the generation process, wherein the large model corresponds to the relationship extraction model in other embodiments.
[0216] In the embodiment of the present application, S context fragments and their relationship extraction results that are most similar to the semantics of the context fragment are retrieved from the vector database by vector retrieval. These context fragments and their relationship extraction results are input into the big model as examples, which can enhance the context understanding ability of the big model, imply the mode of solving the problem, enhance the generalization ability of the big model, and thus improve the accuracy of relationship extraction.
[0217] Figure 8 is a schematic diagram of an implementation framework of the relationship extraction method provided in the embodiment of the present application. Figure 8In the example, the judicial document 11 is segmented according to line breaks to obtain document segments 1 to N, wherein the document segments correspond to the text segments in other embodiments; taking the document segment 1 as an example, the document segment 1 is input into the large language model 12, so as to use the large language model 12 to perform entity extraction on the document segment 1, and obtain the entity extraction result 13; then the pre-trained vector model 81 is used to extract features from the document segment 1 to obtain the second feature vector of the document segment 1; then, the S first feature vectors that are most similar to the second feature vector of the document segment 1 are determined from the vector database 82, and the similar descriptions corresponding to the most similar S first feature vectors are determined, and the similar descriptions are also obtained. The relation extraction results of the document segment 1 are obtained by performing the most similar description and relation extraction results 1 to the most similar description and relation extraction results S, wherein the similar description corresponds to the first segment in other embodiments, and the relation extraction results of the similar description correspond to the first relation extraction results in other embodiments; then, the document segment 1, the entity extraction result 13, and the most similar description and relation extraction results 1 to the most similar description and relation extraction results S are combined to obtain the prompt information; finally, the prompt information is input into the large language model 15, so as to use the large language model 15 to perform relation extraction on the document segment 1 based on the prompt information, and obtain the relation extraction result 16, wherein the large language model 16 corresponds to the relation extraction model in other embodiments.
[0218] In some embodiments, see Figure 8 , you can first obtain the preset M relationship types, and for each relationship type, continue to obtain the relationship type description and at least one relationship extraction result corresponding to the description, Figure 8 In the figure, they are recorded as relationship type 1 description and relationship extraction result 1 to relationship type 1 description and relationship extraction result K, relationship type 2 description and relationship extraction result 1 to relationship type 2 description and relationship extraction result K, relationship type M description and relationship extraction result 1 to relationship type M description and relationship extraction result K. The pre-trained vector model 81 is then used to perform feature extraction on each description to obtain the first feature vector of each description, and each first feature vector is stored in the vector database 82. The description corresponds to the text segment in other embodiments.
[0219] The information extraction method of the embodiment of the present application can be implemented through the following steps S901 to S907, which are described in detail below.
[0220] In step S901, define the relationship types to be extracted from the judicial documents, assuming there are M types.
[0221] In some embodiments, M may be several tens, and by way of example, M may be 15, 20, 25, etc.
[0222] In step S902, common descriptions of each relationship type to be extracted and corresponding relationship extraction results are collected.
[0223] In some embodiments, assuming that there are a total of K common descriptions for each relationship type to be extracted, more common descriptions can be collected for relationship types that are more difficult to extract. In this case, the value of K can be 15; and fewer common descriptions can be collected for relationship types that are easier to extract. In this case, the value of K can be 5.
[0224] In the embodiments of the present application, the common description corresponds to the second segment in other embodiments.
[0225] In step S903, the collected common descriptions of relationship types are subjected to a pre-trained vector model to obtain corresponding vectors, which are then stored in a vector database.
[0226] In the embodiment of the present application, the vector obtained in step S903 corresponds to the first feature vector in other embodiments.
[0227] In step S904, the judgment document text to be extracted is segmented according to "." to obtain N judgment document text segments, and then one text segment is taken each time for entity extraction to obtain the corresponding entity extraction result.
[0228] In the embodiment of the present application, the value of N may be several hundred, and for example, the value of N may be 200, 300, 400, etc. The text segment of the judgment document corresponds to the text segment in other embodiments.
[0229] In step S905, the text segment is simultaneously subjected to the same pre-trained vector model as in step S903 to obtain a vector corresponding to the text segment, and the S context descriptions and relationship extraction results most similar to the text vector are retrieved from the vector database.
[0230] In the embodiment of the present application, the vector of the text segment corresponds to the second feature vector in other embodiments, and the value of S can be 5, 6, 7, etc. The S context descriptions and relationship extraction results that are most similar to the text vector correspond to the first segment and the first relationship extraction results in other embodiments.
[0231] In step S906, the S context descriptions and relationship extraction results that are most similar to the text segment to be extracted are sorted from high to low according to similarity as a few-shot example of relationship extraction for the text segment.
[0232] In the embodiment of the present application, the few-sample example corresponds to the example template in other embodiments.
[0233] In step S907, the entity extraction result, the text segment to be extracted and the few-shot example are combined to obtain prompt information, and the prompt information is input into the large language model to obtain the relationship extraction result.
[0234] In the embodiment of the present application, the large language model corresponds to the relationship extraction model in other embodiments.
[0235] In the embodiment of the present application, common descriptions of the relationship types to be extracted and the corresponding relationship extraction results are collected, and the number can be determined according to the different relationship extraction difficulties. The collected results can be added to the vector database after feature extraction, so that they can be easily reused in different types of judicial document scenarios.
[0236] In the embodiment of the present application, the text fragment of the judicial document is transformed into a vector (embedding) through a pre-trained vector model, and then the S most similar context descriptions and relationship extraction results are retrieved from the vector database. They are sorted from high to low according to the similarity as a few-shot example of the relationship extraction of the text fragment, which can significantly improve the accuracy of relationship extraction.
[0237] The information extraction method provided by the embodiment of the present application is to sort the retrieved S most similar context description fragments and their relationship extraction results from high to low according to similarity as the few-shot examples of the text fragment relationship extraction, and input them into the big model, so as to enhance the context understanding ability of the big model, imply the mode of problem solving, and enhance the generalization ability of the big model, thereby improving the accuracy of relationship extraction. At the same time, for different judicial document text fragments, different most similar S context description fragments and their relationship extraction results can be adaptively selected as few-shot examples, which significantly enhances the generalization of the relationship extraction prompt information.
[0238] Through the information extraction method provided in the embodiment of the present application, when encountering a new type of judicial document text fragment, the S most similar context descriptions and relationship extraction results can be retrieved from the vector database as a few-shot example, which significantly reduces the reuse cost. At the same time, it is also easy to add the context description and relationship extraction results of the new type of judicial document to the vector database, so that the vector database has a stronger generalization and can adapt to different types of judicial documents.
[0239] The embodiment of the present application is to apply the retrieval enhancement generation method to relation extraction. First, the vector is used to retrieve the S context description fragments and their relation extraction results that are most similar to the text fragment of the judicial document to be extracted, and then the recall results are sorted from high to low according to the similarity as the few-shot examples of relation extraction, and then the text fragment of the judicial document to be extracted, the entity list, and the few-shot example combination are input into the large model for relation extraction. Extracting the S context description fragments and their relation extraction results that are most semantically similar to the text fragment of the judicial document to be extracted as the few-shot examples can enhance the context understanding ability of the large model, imply a mode for solving problems, and enhance the generalization ability of the large model, thereby improving the accuracy of relation extraction. At the same time, for different judicial document text fragments, different most similar S context description fragments and their relation extraction results can be adaptively selected as the few-shot examples, which significantly enhances the generalization of the relation extraction prompt information. At the same time, it is also easy to add the context description and relation extraction results of new types of judicial documents to the knowledge base, so that the knowledge base has a stronger generalization and can adapt to different types of judicial documents.
[0240] It can be understood that in the embodiments of the present application, the collection, use and processing of data related to the text, the second segment, the first relationship extraction result, the first feature vector, the third segment, etc. need to comply with relevant laws, regulations and standards.
[0241] The following is a description of an exemplary structure of the information extraction device 455 provided in the embodiment of the present application implemented as a software module. In some embodiments, Figure 3 As shown, the software modules stored in the information extraction device 455 of the memory 450 may include:
[0242] The segmentation module 4551 is used to segment the text to obtain multiple text segments;
[0243] A first determination module 4552, configured to determine a first segment associated with the text segment and obtain a first relationship extraction result of the first segment;
[0244] The relationship extraction module 4553 is used to perform relationship extraction on the text segment based on the text segment, the first segment and the first relationship extraction result to obtain a second relationship extraction result of the text segment.
[0245] In some embodiments, the first determining module 4552 is further configured to:
[0246] Acquire a first feature vector of a second segment from a vector database; perform feature extraction on the text segment to obtain a second feature vector of the text segment; and determine a first segment associated with the text segment based on the first feature vector and the second feature vector.
[0247] In some embodiments, the first determining module 4552 is further configured to:
[0248] Determine a first feature similarity between each of the first feature vectors and the second feature vector; determine a first feature similarity that satisfies a similarity condition;
[0249] The second segment corresponding to the first feature similarity that satisfies the similarity condition is determined as the first segment associated with the text segment.
[0250] In some embodiments, the relationship extraction module 4553 is further used to:
[0251] Based on each of the first fragments and each of the first relationship extraction results, an example template is constructed; prompt information is determined based on the text fragment and the example template; and a relationship extraction model is used to perform relationship extraction on the text fragment based on the prompt information to obtain a second relationship extraction result of the text fragment.
[0252] In some embodiments, the relationship extraction module 4553 is further used to:
[0253] Obtain the second feature similarity between the text segment and each of the first segments; sort each of the first segments in descending order of the second feature similarity to obtain sorted segments; extract the first relationship result between each of the sorted segments and the sorted segments, and determine it as an example template.
[0254] In some embodiments, the relationship extraction module 4553 is further used to:
[0255] Entity extraction is performed on the text fragment to obtain an entity extraction result; and the text fragment, the example template and the entity extraction result are combined to obtain the prompt information.
[0256] In some embodiments, the software modules in the information extraction device 455 may include:
[0257] A first feature extraction module, used for performing feature extraction on the second segment to obtain a first feature vector of the second segment;
[0258] A construction module is used to construct the vector database using the first feature vector.
[0259] In some embodiments, the software modules in the information extraction device 455 may include:
[0260] An acquisition module, configured to acquire a third segment to be added in response to a database update instruction;
[0261] A second feature extraction module, used for performing feature extraction on the third segment to obtain a third feature vector;
[0262] An updating module is used to update the vector database using the third feature vector.
[0263] The embodiment of the present application provides a computer program product or a computer program, which includes computer executable instructions, and the computer executable instructions are stored in a computer readable storage medium. The processor of the computer device reads the computer executable instructions from the computer readable storage medium, and the processor executes the computer executable instructions, so that the computer device executes the information extraction method described in the embodiment of the present application.
[0264] The embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, the processor will be caused to execute the information extraction method provided by the embodiment of the present application, for example, Figure 4 The information extraction method shown.
[0265] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface storage, optical disk, or CD-ROM; or it may be various devices including one or any combination of the above memories.
[0266] In some embodiments, computer executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.
[0267] As an example, computer-executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).
[0268] By way of example, computer executable instructions may be deployed to be executed on one computing device or on multiple computing devices located at one site or on multiple computing devices distributed across multiple sites and interconnected by a communication network.
[0269] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.
Claims
1. An information extraction method, characterized in that: The method comprises: Segment the text to obtain multiple text segments; Determine a first segment associated with the text segment, and obtain a first relationship extraction result of the first segment; Based on the text segment, the first segment and the first relationship extraction result, relationship extraction is performed on the text segment to obtain a second relationship extraction result of the text segment.
2. The method according to claim 1, characterized in that The determining of a first segment associated with the text segment includes: Obtaining a first feature vector of the second segment from a vector database; Performing feature extraction on the text segment to obtain a second feature vector of the text segment; A first segment associated with the text segment is determined based on the first feature vector and the second feature vector.
3. The method according to claim 2, characterized in that The determining, based on the first feature vector and the second feature vector, a first segment associated with the text segment includes: Determining a first feature similarity between each of the first feature vectors and the second feature vector; Determining a first feature similarity that satisfies a similarity condition; The second segment corresponding to the first feature similarity that satisfies the similarity condition is determined as the first segment associated with the text segment.
4. The method according to claim 1, characterized in that: The step of performing relation extraction on the text segment based on the text segment, the first segment and the first relation extraction result to obtain a second relation extraction result of the text segment includes: constructing an example template based on each of the first fragments and each of the first relationship extraction results; Determine prompt information based on the text segment and the example template; The relation extraction model is used to perform relation extraction on the text segment based on the prompt information to obtain a second relation extraction result of the text segment.
5. The method according to claim 4, characterized in that The extracting result based on each of the first fragments and each of the first relations, constructing an example template, comprises: Obtaining a second feature similarity between the text segment and each of the first segments; Sorting each of the first segments in descending order of the second feature similarity to obtain sorted segments; The first relationship extraction result between each of the sorted segments and the sorted segments is determined as an example template.
6. The method according to claim 4, characterized in that The determining of prompt information based on the text segment and the example template includes: Performing entity extraction on the text fragment to obtain an entity extraction result; The text fragment, the example template and the entity extraction result are combined to obtain the prompt information.
7. The method according to claim 2 or 3, characterized in that: Before acquiring the first feature vector of the second segment from the vector database, the method further includes: Performing feature extraction on the second segment to obtain a first feature vector of the second segment; The vector database is constructed using the first feature vector.
8. The method according to claim 7, characterized in that After constructing the vector database using the first feature vector, the method further includes: In response to the database update instruction, obtaining a third segment to be added; Performing feature extraction on the third segment to obtain a third feature vector; The vector database is updated using the third feature vector.
9. An information extraction device, characterized in that: The device comprises: A segmentation module is used to segment the text to obtain multiple text segments; A first determination module, configured to determine a first segment associated with the text segment and obtain a first relationship extraction result of the first segment; The relationship extraction module is used to perform relationship extraction on the text segment based on the text segment, the first segment and the first relationship extraction result to obtain a second relationship extraction result of the text segment.
10. A computer device, characterized in that: The computer device comprises: A memory for storing computer executable instructions; A processor, configured to implement the information extraction method according to any one of claims 1 to 8 when executing the computer executable instructions stored in the memory.
11. A computer-readable storage medium storing computer-executable instructions, characterized in that: When the computer executable instructions are executed by a processor, the information extraction method according to any one of claims 1 to 8 is implemented.
12. A computer program product comprising a computer program or computer executable instructions, characterized in that: When the computer program or computer executable instructions are executed by a processor, the information extraction method according to any one of claims 1 to 8 is implemented.