Information extraction method and device based on large model and electronic equipment
Through the method of phased processing and dynamic adjustment of the propt, the problem of low accuracy of information extraction in the existing technology is solved, efficient and automated information extraction is achieved, and high-quality triple information is generated.
Patent Information
- Application Number
- CN202510440623.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-09
- Publication Date
- 2025-07-22
AI Technical Summary
In single-stage processing, the existing information extraction technology has low accuracy of the extraction results and high risk of error accumulation due to language complexity and data diversity.
Through phased processing and dynamic adjustment of the propt, first identify the entity domain and relational domain, and then match the target propt template in the preset big model to generate triple information.
It improves the accuracy and automation of information extraction, reduces labor costs, realizes high-quality entity and relationship information extraction, and the generated triple information is more accurate and comprehensive.
Smart Images

Figure CN120353879A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing, and specifically relates to an information extraction method, device, and electronic device based on a large model. Background Art
[0002] With the rapid development of the information age, the amount of data has grown exponentially, especially the widespread dissemination of text data on the Internet. Enterprises and research institutions are increasingly relying on automated tools to process and analyze this data in order to extract valuable information. This information includes, but is not limited to, market trends, user behavior, scientific research data, etc., which are of great significance for decision-making support, product development, and scientific research.
[0003] Currently existing information extraction technologies mainly rely on a single-stage extraction data processing mode. In practical applications, the information extraction system needs to accurately identify information such as entities, attributes, and relationships from a large amount of unstructured data and organize it into a structured form. However, due to the complexity of language, the diversity of data, and the professionalism of knowledge in different fields, all processing and decision-making in the single-stage extraction process of the large model are completed in one step, which increases the risk of error accumulation and results in a low accuracy of the extraction results.
[0004] Therefore, there is an urgent need for an information extraction method, device, and electronic device based on a large model. Summary of the Invention
[0005] This application provides an information extraction method, device, and electronic device based on a large model, which improves the accuracy of information extraction through staged processing and dynamic adjustment of prompts.
[0006] In the first aspect of this application, an information extraction method based on a large model is provided. The method includes: obtaining the text to be recognized; performing entity domain recognition on the text to be recognized to obtain a target entity domain, and performing relationship domain recognition on the text to be recognized to obtain a target relationship domain; based on the target entity domain and the target relationship domain, inputting the text to be recognized into a preset large model for matching to obtain a target prompt template, where the preset large model includes multiple prompt templates; generating a corresponding target triple based on the target entity domain, the target relationship domain, and the target prompt template.
[0007] By adopting the above technical solution, by obtaining the text to be recognized, performing entity domain recognition and relationship domain recognition on it, obtaining the target entity domain and the target relationship domain, then matching the target prompt template in the preset large model based on the target entity domain and the target relationship domain, and finally generating the target triple based on the target entity domain, the target relationship domain and the target prompt template, this method can make full use of the rich knowledge contained in the preset large model, and guide the large model to generate triple information that conforms to the semantics of the text to be recognized through the prompt template. This method realizes automated and intelligent information extraction through the preset large model, reducing the labor cost. At the same time, through entity domain recognition and relationship domain recognition, this method can accurately understand the semantics of the text to be recognized, extract high-quality entity and relationship information, and the generated triple information is more accurate and comprehensive, laying a good data foundation for subsequent knowledge storage, reasoning and application. This method is a large model information extraction method with multi-stage dynamic prompts, and each stage is specifically optimized for different tasks (such as entity recognition, relationship recognition and prompt template matching), and the automation and accuracy of information extraction are improved through staged processing and dynamic adjustment of prompts.
[0008] Optionally, the entity domain recognition of the text to be recognized to obtain the target entity domain specifically includes: performing part-of-speech tagging and named entity recognition on the text to be recognized to obtain a candidate entity set, the candidate entity set including multiple entities; using a preset entity embedding model to map each of the entities to a low-dimensional dense vector space to obtain entity vectors corresponding to each of the entities; based on the entity vectors, using a clustering algorithm to cluster the candidate entity set to obtain a clustering result; if it is determined that the clustering results corresponding to the first entity and the second entity are the same, then it is determined that the first entity and the second entity belong to the same entity domain, and thus the target entity domain is obtained, the first entity and the second entity being any two entities among the multiple entities.
[0009] By adopting the above technical solution, through performing part-of-speech tagging and named entity recognition on the text to be recognized, a candidate entity set is obtained. Then, a preset entity embedding model is used to map the entities into a low-dimensional dense vector space to obtain entity vectors. Next, clustering is performed based on the entity vectors, and according to the clustering results, the entity domain to which the entities belong is determined, so as to obtain the target entity domain. This method can automatically identify the entities in the text to be recognized, perform fine-grained semantic representation and clustering on the entities, and realize the automatic division of entity domains. This method can achieve the automatic discovery and division of entity domains, improving the accuracy and completeness of entity domain recognition. By using the preset entity embedding model to map the entities into a vector space, this method can capture the semantic similarity between entities, making entities with similar semantics closer in the vector space, which helps to achieve accurate entity clustering and entity domain division. At the same time, the vectorized representation can reduce the dimension of entity representation and improve the efficiency of entity processing.
[0010] Optionally, the recognition of the relationship domain for the text to be recognized to obtain the target relationship domain specifically includes: inputting the text to be recognized into a preset relationship extraction model to obtain a candidate relationship set, where the candidate relationship set includes multiple candidate relationships, and the candidate relationships include a head entity, a tail entity, and a relationship type; for each of the candidate relationships, determining whether the head entity and the tail entity exist in the target entity domain at the same time; if it is determined that the head entity and the tail entity exist in the target entity domain at the same time, then determining the candidate relationship as the target relationship and determining the target relationship as the target relationship domain; if it is determined that the head entity or the tail entity does not exist in the target entity domain, then extracting the text fragment between the head entity and the tail entity in the text to be recognized and using the text fragment as the relationship description text of the target relationship.
[0011] By adopting the above technical solution, by inputting the text to be recognized into a preset relationship extraction model to obtain a candidate relationship set, and then determining whether the head entity and the tail entity of the candidate relationship exist in the target entity domain at the same time. If they exist, the candidate relationship is determined as the target relationship and the target relationship is determined as the target relationship domain. If not, the text fragment between the head entity and the tail entity is extracted as the relationship description text. This method can automatically extract candidate relationships from the text to be recognized, screen out the target relationships related to the target entity domain according to the entity domain information, and at the same time retain the semantic description information of the relationships, realizing the automatic recognition and construction of the relationship domain. By automatically extracting candidate relationships through the preset relationship extraction model, this method has good domain adaptability and scalability and can automatically adapt to relationship extraction tasks in different domains. This method realizes the automatic recognition and construction of the relationship domain, does not require pre-defining the relationship domain, has better domain adaptability and scalability, and improves the generality and practicality of the method.
[0012] Optionally, matching in a preset large model based on the target entity domain and the target relationship domain to obtain a target prompt template specifically includes: converting the text to be recognized into a first string based on the target entity domain and the target relationship domain; converting each of the prompt templates included in the preset large model into a corresponding string to obtain a plurality of target strings, where one prompt template corresponds to one target string; calculating the similarity between the first string and a second string, where the second string is any one of the plurality of target strings; if it is determined that the similarity is greater than or equal to a preset similarity threshold, determining the prompt template corresponding to the second string as the target prompt template.
[0013] By adopting the above technical solution, by converting the text to be recognized into a first string based on the target entity domain and the target relationship domain, converting the prompt templates in the preset large model into target strings, then calculating the similarity between the first string and the target strings, and determining the target prompt template according to the comparison result between the similarity and the preset similarity threshold, this method can automatically match the prompt template with the highest semantic similarity to the text to be recognized, realizing the adaptive selection of the prompt template. This method improves the efficiency and accuracy of the matching by quickly matching the optimal prompt template. By uniformly converting the text and the template into string representations, this method can conveniently calculate the similarity between them, providing a quantifiable index for the matching of the prompt template.
[0014] Optionally, the specific calculation formula for calculating the similarity between the first string and the second string is: ; where Similarity is the similarity, α is a weight coefficient, S1 is the first string, S2 is the second string, cos(S1, S2) is the cosine similarity between the first string and the second string, EditDistance(S1, S2) is the edit distance between the first string and the second string, len(S1) is the length of the first string, and len(S2) is the length of the second string.
[0015] By adopting the above technical solution, by comprehensively considering the cosine similarity and edit distance between the first string and the second string, and introducing a weight coefficient, the similarity is calculated. When comparing the string similarity, this similarity calculation formula not only considers the semantic similarity of the strings, but also considers the edit distance of the strings, and can more comprehensively and accurately evaluate the similarity degree between the strings. The cosine similarity measures the directional similarity of the strings in the vector space, and the edit distance measures the literal difference of the strings. The combination of the two can comprehensively consider the semantic and literal similarity of the strings and obtain a more accurate similarity score. By introducing a weight coefficient, this formula can flexibly adjust the influence weights of the cosine similarity and edit distance in the similarity calculation to adapt to different application scenarios and requirements. By adjusting the weight coefficient, the emphasis on semantic similarity and literal similarity can be balanced according to the actual task, improving the flexibility and adaptability of the similarity calculation. This similarity calculation formula can provide a reliable and comprehensive similarity evaluation, which helps to improve the accuracy of prompt template matching, thereby improving the quality and efficiency of information extraction.
[0016] Optionally, generating the corresponding target triple based on the target entity domain, the target relationship domain, and the target prompt template specifically includes: matching the relationship type of each target relationship in the target relationship domain with the relationship placeholder in the target prompt template to obtain a relationship description template; retrieving the corresponding entity attribute information in the target entity domain according to the head entity and the tail entity of the target relationship; filling the entity attribute information into the entity placeholder in the relationship description template to obtain a relationship description text; performing natural language reasoning on the relationship description text to extract the triple information of the entity, relationship, and attribute included in the relationship description text; splicing the head entity, the tail entity of the target relationship, and the triple information to generate a knowledge graph subgraph centered on the target relationship as the target triple.
[0017] By adopting the above technical solution, by matching the relationship type of the target relationship with the relationship placeholder in the target prompt template, a relationship description template is obtained. Then, entity attribute information is retrieved from the target entity domain based on the head entity and the tail entity of the target relationship, and the entity attribute information is filled into the relationship description template to obtain a relationship description text. Next, natural language inference is performed on the relationship description text to extract triple information. Finally, the head entity, the tail entity, and the triple information of the target relationship are concatenated to generate a knowledge graph subgraph centered on the target relationship as the target triple. This method can automatically match the corresponding relationship description template according to the type of the target relationship, generate a detailed relationship description text by filling in entity attribute information, and use natural language inference to extract rich triple information from the relationship description text, and finally generate a knowledge graph subgraph centered on the target relationship, realizing the automatic conversion from unstructured text to a structured knowledge graph.
[0018] Optionally, the method further includes: obtaining unlabeled text corpora and labeled data from multiple domains, where the domains include technology, finance, healthcare, and sports, and the labeled data includes entity relationship annotation corpora and question-answer annotation corpora; performing preprocessing operations on the unlabeled text corpora to obtain target text corpora, where the preprocessing operations include word segmentation, part-of-speech tagging, and named entity recognition; training the target text corpora through an unsupervised pre-training method to obtain an initial large model, where the pre-training method includes GPT pre-training based on an autoregressive task and BERT pre-training based on an autoencoding task; optimizing the initial large model through a supervised fine-tuning method based on the labeled data to obtain the preset large model, and embedding multiple prompt templates for different domains in the preset large model, where the fine-tuning method includes joint fine-tuning based on multi-task learning.
[0019] By adopting the above technical solution, by obtaining unlabeled text corpora and labeled data from multiple domains, preprocessing the unlabeled text corpora to obtain target text corpora, then training the target text corpora through an unsupervised pre-training method to obtain an initial large model, and further optimizing the initial large model through a supervised fine-tuning method based on the labeled data to obtain the preset large model, and embedding multiple prompt templates for different domains in the preset large model, this method utilizes unlabeled text corpora and labeled data, and constructs a preset large model containing multi-domain knowledge and prompt templates through a combination of unsupervised pre-training and supervised fine-tuning, realizing the application of the large model in multi-domain information extraction tasks. The training method combining unsupervised pre-training and supervised fine-tuning makes full use of unlabeled text corpora and labeled data, enabling the preset large model to simultaneously possess the general language understanding ability and domain-specific knowledge, and improving the performance and generalization ability of the preset large model in multi-domain information extraction tasks.
[0020] In a second aspect of the present application, an information extraction device based on a large model is provided. The device includes an acquisition module and a processing module, where: the acquisition module is used to acquire the text to be recognized; the processing module is used to perform entity domain recognition on the text to be recognized to obtain a target entity domain, and perform relationship domain recognition on the text to be recognized to obtain a target relationship domain; the processing module is further used to input the text to be recognized into a preset large model for matching based on the target entity domain and the target relationship domain to obtain a target prompt template, and the preset large model includes a plurality of prompt templates; the processing module is further used to generate a corresponding target triple based on the target entity domain, the target relationship domain, and the target prompt template.
[0021] In a third aspect of the present application, an electronic device is provided, including a processor, a memory, a user interface, and a network interface. The memory is used to store instructions, and both the user interface and the network interface are used to communicate with other devices. The processor is used to execute the instructions stored in the memory so that the electronic device executes the method described in any one of the above.
[0022] In a fourth aspect of the present application, a computer-readable storage medium is provided. The computer-readable storage medium stores instructions, and when the instructions are executed, the method described in any one of the above is executed.
[0023] In summary, one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages: 1. By acquiring the text to be recognized, performing entity domain recognition and relationship domain recognition on it to obtain a target entity domain and a target relationship domain, then matching the target entity domain and the target relationship domain in a preset large model to obtain a target prompt template, and finally generating a target triple based on the target entity domain, the target relationship domain, and the target prompt template, this method can make full use of the rich knowledge contained in the preset large model, and guide the large model to generate triple information that conforms to the semantics of the text to be recognized through the prompt template. This method realizes automated and intelligent information extraction through the preset large model, reducing labor costs. At the same time, through entity domain recognition and relationship domain recognition, this method can accurately understand the semantics of the text to be recognized, extract high-quality entity and relationship information, and the generated triple information is more accurate and comprehensive, laying a good data foundation for subsequent knowledge storage, reasoning, and application. This method uses a multi-stage dynamic prompt large model information extraction method, and each stage is specifically optimized for different tasks (such as entity recognition, relationship recognition, and prompt template matching). By processing in stages and dynamically adjusting the prompt, the automation and accuracy of information extraction are improved.
[0024] 2. By performing part-of-speech tagging and named entity recognition on the text to be recognized, a set of candidate entities is obtained. Then, a preset entity embedding model is used to map the entities into a low-dimensional dense vector space to obtain entity vectors. Next, clustering is performed based on the entity vectors, and the entity domain to which the entities belong is determined according to the clustering results, thereby obtaining the target entity domain. This method can automatically identify the entities in the text to be recognized, perform fine-grained semantic representation and clustering on the entities, and achieve automatic division of the entity domain. This method can achieve automatic discovery and division of the entity domain, improving the accuracy and completeness of entity domain recognition. By mapping the entities into a vector space through a preset entity embedding model, this method can capture the semantic similarity between entities, making entities with similar semantics closer in the vector space, which helps to achieve accurate entity clustering and entity domain division. At the same time, the vectorized representation can reduce the dimension of entity representation and improve the efficiency of entity processing.
[0025] 3. By converting the text to be recognized into a first string based on the target entity domain and the target relationship domain, and converting the prompt template in the preset large model into a target string, then calculating the similarity between the first string and the target string, and determining the target prompt template according to the comparison result between the similarity and the preset similarity threshold, this method can automatically match the prompt template with the highest semantic similarity to the text to be recognized, realizing the adaptive selection of the prompt template. This method improves the efficiency and accuracy of matching by quickly matching the optimal prompt template. By uniformly converting the text and the template into string representations, this method can conveniently calculate the similarity between them, providing a quantifiable index for the matching of the prompt template. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 is a schematic flowchart of an information extraction method based on a large model disclosed in an embodiment of the present application; Figure 2 is a schematic block diagram of an information extraction device based on a large model disclosed in an embodiment of the present application; Figure 3 is a schematic structural diagram of an electronic device disclosed in an embodiment of the present application.
[0027] Description of the reference numerals: 201, acquisition module; 202, processing module; 300, electronic device; 301, processor; 302, communication bus; 303, user interface; 304, network interface; 305, memory. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0028] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this specification. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments.
[0029] In the description of the embodiments of this application, words such as "for example" or "for illustration" are used to give examples, illustrations or explanations. Any embodiment or design solution described as "for example" or "for illustration" in the embodiments of this application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, the use of words such as "for example" or "for illustration" is intended to present the relevant concepts in a specific manner.
[0030] In the description of the embodiments of this application, the term "plurality" means two or more. For example, a plurality of systems means two or more systems, and a plurality of screen terminals means two or more screen terminals. In addition, the terms "first" and "second" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance or implicitly indicating the technical features indicated. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of such features. The terms "include", "comprise", "have" and their variants all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0031] This application provides an information extraction method based on a large model. Refer to Figure 1 , Figure 1 is a schematic flowchart of an information extraction method based on a large model provided in the embodiments of this application. This method is applied to a server. The server is a server that executes an information extraction program based on a large model. The server can be a single server, a server cluster composed of multiple servers, or a cloud computing service center. This method includes steps S101 to S104. The above steps are as follows: Step S101: Obtain the text to be recognized.
[0032] In step S101, the server can obtain the text to be recognized in various ways. One way is to receive the text input by the user through the user interface. For example, the server can provide a web page or a mobile application where the user can input or paste the text content to be recognized. After the server receives the text submitted by the user, it uses the text as the text to be recognized for subsequent processing. Another way to obtain the text to be recognized is to automatically obtain it from a specified data source. The data source can be a local file system, a database, an online document platform, etc. The server can periodically or according to trigger conditions (such as scheduled tasks, event-driven, etc.) scrape or read the text content from the data source. For example, the server can monitor a certain folder, and when a new text file appears in the folder, it automatically processes the file content as the text to be recognized.
[0033] Step S102: Perform entity domain recognition on the text to be recognized to obtain the target entity domain, and perform relationship domain recognition on the text to be recognized to obtain the target relationship domain.
[0034] In step S102, performing entity domain recognition on the text to be recognized to obtain the target entity domain specifically includes: performing part-of-speech tagging and named entity recognition on the text to be recognized to obtain a candidate entity set, where the candidate entity set includes multiple entities; using a preset entity embedding model to map each entity to a low-dimensional dense vector space to obtain an entity vector corresponding to each entity; based on the entity vectors, using a clustering algorithm to cluster the candidate entity set to obtain a clustering result; if it is determined that the clustering results corresponding to the first entity and the second entity are the same, then it is determined that the first entity and the second entity belong to the same entity domain, and thus the target entity domain is obtained, where the first entity and the second entity are any two entities among the multiple entities.
[0035] Specifically, the server performs part-of-speech tagging and named entity recognition on the text to be recognized. In the embodiments of the present application, part-of-speech tagging can be understood as tagging the part of speech (such as noun, verb, adjective, etc.) of each word in the text to be recognized, and named entity recognition is to recognize the named entities (such as person names, place names, organization names, etc.) in the text to be recognized. The server uses machine learning or deep learning-based methods to perform the above two tasks, such as conditional random fields, recurrent neural networks, etc. The server can select pre-trained part-of-speech tagging and named entity recognition models. After part-of-speech tagging and named entity recognition, the server obtains a candidate entity set that contains all potential entities in the text to be recognized.
[0036] Next, the server uses a preset entity embedding model to map each entity in the candidate entity set into a low-dimensional dense vector space. The preset entity embedding model is an embedding method based on neural networks, such as Word2Vec, or it can also be an embedding method based on knowledge graphs, such as TransE. Through entity embedding, each entity is represented as an entity vector of a fixed dimension. The entity vector captures the semantic information of the entity, and entities with similar semantics are closer in the vector space. Then, based on the entity vectors, the server uses a clustering algorithm to cluster the candidate entities. The clustering algorithm can be a traditional distance-based clustering method, such as K-means, hierarchical clustering, etc., or it can be a graph-based clustering method, such as spectral clustering, Louvain algorithm. Preferably, in the embodiment of the present application, the server uses the K-means clustering algorithm to perform clustering analysis on each entity in the candidate entity set. The server uses the K-means clustering algorithm to aggregate entities with similar semantics into the same cluster, and each cluster represents a potential entity domain.
[0037] Finally, the server determines the target entity domain by analyzing the clustering results. Specifically, the server determines whether the clustering results corresponding to any two entities (the first entity and the second entity) in the candidate entity set are the same. If the first entity and the second entity belong to the same clustering cluster, the server determines that they belong to the same entity domain. In this way, the server can find out the entities belonging to the same entity domain from the candidate entity set, and then integrate multiple entity domains to obtain the target entity domain, which includes multiple entity domains.
[0038] For example, assume that the text to be recognized is "Xiaoming and Xiaohong are classmates and they both study in Beijing. Xiaoming's hobby is playing basketball, and Xiaohong likes playing the piano." After part-of-speech tagging and named entity recognition, the server obtains a candidate entity set, including "Xiaoming", "Xiaohong", "Beijing", "basketball", "piano", etc. Then, the server uses the entity embedding model to map these entities into entity vectors and uses a clustering algorithm for clustering. The clustering result may be: {"Xiaoming", "Xiaohong"} belong to the same class, {"Beijing"} is a separate class, and {"basketball", "piano"} belong to the same class. According to the clustering results, the server determines that "Xiaoming" and "Xiaohong" belong to the same entity domain (person entity domain), "Beijing" belongs to another entity domain (location entity domain), and "basketball" and "piano" belong to the third entity domain (hobby entity domain). Finally, the server obtains the target entity domain, including the person entity domain, the location entity domain, and the hobby entity domain.
[0039] In step S102, perform relationship domain recognition on the text to be recognized to obtain the target relationship domain, which specifically includes: inputting the text to be recognized into a preset relationship extraction model to obtain a candidate relationship set. The candidate relationship set includes multiple candidate relationships, and a candidate relationship includes a head entity, a tail entity, and a relationship type; for each candidate relationship, determine whether the head entity and the tail entity exist in the target entity domain at the same time; if it is determined that the head entity and the tail entity exist in the target entity domain at the same time, then determine the candidate relationship as the target relationship and determine the target relationship as the target relationship domain; if it is determined that the head entity or the tail entity does not exist in the target entity domain, then extract the text fragment between the head entity and the tail entity in the text to be recognized and use the text fragment as the relationship description text of the target relationship.
[0040] Specifically, the server performs relationship domain recognition on the text to be recognized to obtain the target relationship domain. Specifically, the server first inputs the text to be recognized into a preset relationship extraction model to obtain a candidate relationship set. The candidate relationship set contains multiple relationships that may exist in the text, and each candidate relationship consists of a head entity, a tail entity, and a relationship type. The preset relationship extraction model is based on deep learning algorithms such as convolutional neural networks and recurrent neural networks. Through training on a large-scale labeled dataset, it can automatically identify the relationships between entities in the text. Then, the server judges each candidate relationship in the candidate relationship set to determine whether its head entity and tail entity exist in the target entity domain obtained from the previous recognition at the same time. The purpose of this step is to screen out the relationships related to the target entity domain and exclude the irrelevant relationships.
[0041] If both the head entity and the tail entity of the candidate relationship are in the target entity domain, the server determines the candidate relationship as the target relationship and includes it in the target relationship domain. The target relationship domain is a set of relationships associated with the target entity domain and contains the semantic relationships between the target entities.
[0042] If the head entity or the tail entity of the candidate relationship is not in the target entity domain, the candidate relationship may be irrelevant to the target entity domain. However, in order to obtain more relationship information as much as possible, the server will further analyze the candidate relationship. Specifically, the server will extract the text fragment between the head entity and the tail entity in the text to be recognized and use it as the relationship description text of the candidate relationship. The relationship description text provides the context information about the relationship and helps to understand the semantic connection between the head entity and the tail entity.
[0043] For example, for the text to be recognized "Xiaoming and Xiaohong are classmates and they both study in Beijing. Xiaoming's hobby is playing basketball and Xiaohong likes playing the piano.", assume that the following candidate relationships are obtained through a relationship extraction model: (Xiaoming, Xiaohong, classmate relationship); (Xiaoming, Beijing, study location); (Xiaohong, Beijing, study location); (Xiaoming, basketball, hobby). According to the previous entity domain recognition results, the target entity domains include the person entity domain, the location entity domain, and the hobby entity domain. The server determines one by one whether the head entity and the tail entity of the candidate relationship exist in the target entity domain at the same time. For the candidate relationship (Xiaoming, Xiaohong, classmate relationship), both the head entity "Xiaoming" and the tail entity "Xiaohong" belong to the person entity domain, so this relationship is determined as the target relationship and included in the target relationship domain. Similarly, for the relationships (Xiaoming, Beijing, study location), (Xiaohong, Beijing, study location), (Xiaoming, basketball, hobby), and (Xiaohong, piano, hobby), the head entities and the tail entities also belong to the corresponding entity domains respectively, so they are all included in the target relationship domain. Through the above steps, the server realizes the relationship domain recognition of the text to be recognized, automatically discovers the semantic relationships between entities in the text to be recognized, and filters out the target relationships related to the target entity domain according to the limitation of the entity domain to construct the target relationship domain. This process makes full use of the entity domain information, effectively reduces the difficulty of relationship extraction, and improves the accuracy of relationship recognition.
[0044] Step S103: Based on the target entity domain and the target relationship domain, input the text to be recognized into a preset large model for matching to obtain a target prompt template, and multiple prompt templates are included in the preset large model.
[0045] In step S103, based on the target entity domain and the target relationship domain, perform matching in the preset large model to obtain a target prompt template, which specifically includes: converting the text to be recognized into a first string based on the target entity domain and the target relationship domain; converting each prompt template included in the preset large model into a corresponding string to obtain multiple target strings, and one prompt template corresponds to one target string; calculating the similarity between the first string and a second string, where the second string is any one of the multiple target strings; if it is determined that the similarity is greater than or equal to the preset similarity threshold, then determine the prompt template corresponding to the second string as the target prompt template.
[0046] Specifically, the server inputs the text to be recognized into a preset large model for matching based on the target entity domain and the target relationship domain to obtain the target prompt template. The preset large model is a language model trained based on a large amount of data, such as BERT, which contains a large amount of language knowledge and common sense knowledge. In the preset large model, multiple predefined prompt templates are stored, and these prompt templates correspond to entity domains and relationship domains in different fields, and are used to guide the extraction of entities and relationships.
[0047] Specifically, the server first converts the text to be recognized into a string representation based on the target entity domain and the target relationship domain, which is called the first string. The server can connect the entities in the target entity domain and the relationships in the target relationship domain with special delimiters to form an entity-relationship sequence. Then, the server concatenates the sequence with the text to be recognized to obtain the first string. Next, the server also converts each prompt template in the preset large model into the corresponding string representation to obtain multiple target strings. Each target string corresponds to a prompt template and contains information about the entity domain and relationship domain applicable to the template.
[0048] Then, the server calculates the similarity between the first string and each target string. Finally, the server determines the most matching prompt template according to the calculation result of the similarity. Specifically, the server determines whether the similarity between the first string and each target string is greater than or equal to the preset similarity threshold. The setting of the preset similarity threshold can be adjusted according to actual needs to balance the precision and recall rate of the matching, and this application does not make a limitation on this. If the similarity between the first string and a certain target string exceeds the preset similarity threshold, the prompt template corresponding to the target string is determined as the target prompt template.
[0049] For example, for the text to be recognized "Xiaoming and Xiaohong are classmates and they both study in Beijing.", assuming the target entity domain is {person, location} and the target relationship domain is {classmate relationship, study location}. The server combines the information of the text to be recognized, the entity domain, and the relationship domain into the first string, such as "Xiaoming and Xiaohong are classmates and they both study in Beijing, [person][location][classmate relationship][study location]". Then, the server converts the prompt templates in the preset large model into target strings, such as: "[Person 1] and [Person 2] are [relationship], and they both [relationship] in [location]" "The [relationship] of [Person 1] is [Person 2], and [Person 1] studies in [location]" The server calculates the similarity between the first string and each target string and finds that the similarity of the first target string is the highest, exceeding the preset similarity threshold. Therefore, the server determines the prompt template corresponding to the first target string as the target prompt template for subsequent information extraction and triple generation. Through the above steps, the server uses the preset large model to achieve automatic matching and selection of the target prompt template.
[0050] In a possible implementation manner, the specific calculation formula for calculating the similarity between the first string and the second string is: ; where Similarity is the similarity, α is the weight coefficient, S1 is the first string, S2 is the second string, cos(S1, S2) is the cosine similarity between the first string and the second string, EditDistance(S1, S2) is the edit distance between the first string and the second string, len(S1) is the length of the first string, and len(S2) is the length of the second string.
[0051] Specifically, the similarity calculation formula consists of two parts, namely cosine similarity and edit distance similarity, and their contributions are balanced by the weight coefficient α. The cosine similarity cos(S1, S2) measures the cosine value of the angle between two strings in the semantic space, reflecting their semantic similarity degree. To calculate the cosine similarity, the server first needs to convert the strings S1 and S2 into vector representations. A word embedding model, such as Word2Vec, can be used to map each word in the string to a real-valued vector of a fixed dimension, and then the word vectors are weighted and averaged to obtain the vector representation of the string. Then, the server calculates the dot product of the two string vectors and divides it by their L2 norms to obtain the cosine similarity. The value range of the cosine similarity is [-1, 1], and the larger the value, the higher the semantic similarity.
[0052] The edit distance similarity measures the literal similarity between two strings, that is, the minimum number of edit operations such as insertion, deletion, and replacement required to transform one string into another. The smaller the edit distance, the more similar the strings are. The server uses a dynamic programming algorithm to calculate the edit distance, specifically, the Levenshtein distance can be used. To convert the edit distance into a similarity, the server divides it by the maximum of the lengths of the two strings and subtracts this ratio from 1 to obtain a similarity score in the range of [0, 1]. Finally, the server uses a weight coefficient α to perform a weighted sum of the cosine similarity and the edit distance similarity to obtain the final similarity score Similarity. The value range of α is [0, 1]. The larger α is, the greater the weight of the cosine similarity and the more important the semantic similarity is; the smaller α is, the greater the weight of the edit distance similarity and the more important the literal similarity is. The server can adjust the value of α according to the specific task and domain.
[0053] Step S104: Generate a corresponding target triple based on the target entity domain, the target relationship domain, and the target prompt template.
[0054] In step S104, generating a corresponding target triple based on the target entity domain, the target relationship domain, and the target prompt template specifically includes: matching the relationship type of each target relationship in the target relationship domain with the relationship placeholder in the target prompt template to obtain a relationship description template; retrieving the corresponding entity attribute information in the target entity domain according to the head entity and the tail entity of the target relationship; filling the entity attribute information into the entity placeholder in the relationship description template to obtain a relationship description text; performing natural language inference on the relationship description text to extract the triple information of the entity, relationship, and attribute included in the relationship description text; concatenating the head entity, the tail entity, and the triple information of the target relationship to generate a knowledge graph subgraph centered on the target relationship as the target triple.
[0055] Specifically, the server matches the relationship type of each target relationship in the target relationship domain with the relationship placeholder in the target prompt template to obtain a relationship description template. The relationship placeholder is a reserved space in the prompt template for filling in the specific relationship type. By matching the relationship type with the placeholder, the server can generate corresponding relationship description templates according to different relationship types. Next, the server retrieves the corresponding entity attribute information in the target entity domain based on the head entity and tail entity of the target relationship. The entity attribute information is descriptive information about the entity. Then, the server fills the retrieved entity attribute information into the entity placeholder in the relationship description template to obtain a complete relationship description text. The entity placeholder is a reserved space in the relationship description template for filling in the specific entity attribute information. By filling the entity attribute information into the placeholder, the server can generate personalized relationship description texts according to different entities.
[0056] Next, the server performs natural language reasoning on the generated relationship description text to extract the triple information of entities, relationships, and attributes contained in the text. Natural language reasoning is a deep learning-based technology that extracts implicit knowledge by semantically understanding and reasoning about the text. The server uses natural language reasoning models such as BERT and GPT to analyze the relationship description text, identify the entities, relationships, and attributes therein, and organize them into triple form.
[0057] Finally, the server concatenates the head entity, tail entity of the target relationship, and the extracted triple information to generate a knowledge graph subgraph centered on the target relationship as the final target triple. A knowledge graph subgraph is a local view of the knowledge graph that expands around a central entity or relationship and includes the entities and relationships directly connected to it. By concatenating the head entity, tail entity, and triple information, the server can construct a knowledge graph subgraph centered on the target relationship, reflecting the semantic associations and attribute information between entities.
[0058] For example, for the target relationship "(Xiaoming, Beijing, study location)", assuming the target prompt template is "[Person] is at [Location] [Relationship]", and the relationship description template is "[Person] studies at [Location]". The server retrieves the attribute information of the head entity "Xiaoming" in the target entity domain as "Age: 18 years old, Major: Computer Science", and fills it into the relationship description template to obtain the relationship description text "Xiaoming studies in Beijing. Xiaoming is 18 years old and majors in Computer Science". Then, the server performs natural language reasoning on the relationship description text to extract the triples "(Xiaoming, Age, 18 years old)" and "(Xiaoming, Major, Computer Science)". Finally, the server concatenates the head entity, tail entity, and triple information to generate a knowledge graph subgraph centered on the target relationship, that is, the target triple.
[0059] In a possible implementation, the method further includes: obtaining unannotated text corpora and annotated data from multiple fields, where the fields include technology, finance, healthcare, and sports, and the annotated data includes entity relationship annotation corpora and question-and-answer annotation corpora; performing preprocessing operations on the unannotated text corpora to obtain target text corpora, and the preprocessing operations include word segmentation, part-of-speech tagging, and named entity recognition; training the target text corpora through an unsupervised pre-training method to obtain an initial large model, and the pre-training method includes GPT pre-training based on autoregressive tasks and BERT pre-training based on autoencoding tasks; optimizing the initial large model through a supervised fine-tuning method based on the annotated data to obtain a preset large model, and multiple prompt templates for different fields are built into the preset large model, and the fine-tuning method includes joint fine-tuning based on multi-task learning.
[0060] Specifically, the server crawls from the network or obtains a large amount of unannotated text corpora from a local database. These corpora come from different fields, such as technology news, financial reports, medical cases, sports events, etc. Unannotated text corpora refer to the original text data that has not been manually annotated and contain domain knowledge and language patterns. At the same time, the server also obtains some annotated data, including entity relationship annotation corpora and question-and-answer annotation corpora. Entity relationship annotation corpora refer to the text data in which the relationships between entities have been annotated, and question-and-answer annotation corpora refer to the text data in which question-and-answer pairs have been annotated. These annotated data can be used as supervision signals to guide the model to learn specific tasks.
[0061] Next, the server performs preprocessing operations on the unannotated text corpus, converting it into a structured target text corpus. The preprocessing operations include word segmentation, part-of-speech tagging, and named entity recognition, etc. Word segmentation is to split continuous text into independent words or phrases. Part-of-speech tagging is to label the part of speech of each word (such as noun, verb, adjective, etc.). Named entity recognition is to identify named entities in the text (such as person names, place names, organization names, etc.). Then, the server uses an unsupervised pre-training method to train an initial large model on the target text corpus. Pre-training is a self-supervised learning method. By designing appropriate pre-training tasks, the model learns general language representations and knowledge from large-scale unannotated data. The server can adopt two pre-training methods: GPT pre-training based on autoregressive tasks and BERT pre-training based on autoencoding tasks. GPT pre-training aims at a language model and learns context relationships by predicting the next word. BERT pre-training aims at a masked language model and learns bidirectional context relationships by predicting the masked words. Finally, the server optimizes the initial large model through supervised fine-tuning based on annotated data to obtain a preset large model. Fine-tuning is a transfer learning method. By adding a task-specific output layer on the basis of the pre-trained model and training with a small amount of annotated data, the model is adapted to specific downstream tasks. The server adopts a joint fine-tuning method based on multi-task learning, that is, fine-tuning the model on multiple tasks simultaneously, such as entity relation extraction, question answering generation, etc. Multi-task learning can promote knowledge transfer and generalization between different tasks, improving the robustness and efficiency of the model. During the fine-tuning process, the server also builds multiple prompt templates for different domains in the preset large model, such as "[Product][Release Time][Release]" in the technology field, "[Company][Acquisition][Target Company][Amount]" in the financial field, etc. These prompt templates can serve as prior knowledge to guide the model to generate structured information in specific domains.
[0062] For example, the server crawls a large number of technology news from the Internet. After preprocessing operations, a structured target text corpus is obtained. Then, the server pre-trains a GPT-2 model on these text corpora to learn the general language knowledge in the technology field. Next, the server uses some technology news that have been annotated with entity relationships and trains an entity relation extraction model on the basis of the pre-trained model through joint fine-tuning. During the fine-tuning process, the server also builds some prompt templates in the technology field, such as "[Company][Released][Product]", etc. Finally, the server obtains a preset large model that can automatically generate structured entity relation knowledge according to the input technology news.
[0063] Refer to Figure 2, this application also provides an information extraction device based on a large model. The device is a server, and the server includes an acquisition module 201 and a processing module 202. The acquisition module 201 and the processing module 202 are as follows: The acquisition module 201 is used to acquire the text to be recognized; the processing module 202 is used to perform entity domain recognition on the text to be recognized to obtain the target entity domain, and perform relationship domain recognition on the text to be recognized to obtain the target relationship domain; the processing module 202 is further used to input the text to be recognized into a preset large model for matching based on the target entity domain and the target relationship domain to obtain the target prompt template. The preset large model includes multiple prompt templates; the processing module 202 is further used to generate a corresponding target triple based on the target entity domain, the target relationship domain, and the target prompt template.
[0064] In a possible implementation manner, the processing module 202 performs entity domain recognition on the text to be recognized to obtain the target entity domain, which specifically includes: the processing module 202 performs part-of-speech tagging and named entity recognition on the text to be recognized to obtain a candidate entity set, and the candidate entity set includes multiple entities; the processing module 202 uses a preset entity embedding model to map each entity to a low-dimensional dense vector space to obtain an entity vector corresponding to each entity; the processing module 202 performs clustering on the candidate entity set based on the entity vector by using a clustering algorithm to obtain a clustering result; if the processing module 202 determines that the clustering results corresponding to the first entity and the second entity are the same, it determines that the first entity and the second entity belong to the same entity domain, and then obtains the target entity domain. The first entity and the second entity are any two entities in the multiple entities.
[0065] In a possible implementation manner, the processing module 202 performs relationship domain recognition on the text to be recognized to obtain the target relationship domain, which specifically includes: the processing module 202 inputs the text to be recognized into a preset relationship extraction model to obtain a candidate relationship set, and the candidate relationship set includes multiple candidate relationships. The candidate relationship includes a head entity, a tail entity, and a relationship type; for each candidate relationship, the processing module 202 determines whether the head entity and the tail entity exist in the target entity domain at the same time; if the processing module 202 determines that the head entity and the tail entity exist in the target entity domain at the same time, it determines the candidate relationship as the target relationship and determines the target relationship as the target relationship domain; if the processing module 202 determines that the head entity or the tail entity does not exist in the target entity domain, it extracts the text segment between the head entity and the tail entity in the text to be recognized and uses the text segment as the relationship description text of the target relationship.
[0066] In a possible implementation, the processing module 202 performs matching in a preset large model based on the target entity domain and the target relationship domain to obtain a target prompt template, specifically including: the processing module 202 converts the text to be recognized into a first string based on the target entity domain and the target relationship domain; the processing module 202 converts each prompt template included in the preset large model into a corresponding string to obtain a plurality of target strings, where one prompt template corresponds to one target string; the processing module 202 calculates the similarity between the first string and the second string, and the second string is any one of the plurality of target strings; if the processing module 202 determines that the similarity is greater than or equal to a preset similarity threshold, it determines that the prompt template corresponding to the second string is the target prompt template.
[0067] In a possible implementation, the specific calculation formula for the processing module 202 to calculate the similarity between the first string and the second string is: ; where Similarity is the similarity, α is the weight coefficient, S1 is the first string, S2 is the second string, cos(S1, S2) is the cosine similarity between the first string and the second string, EditDistance(S1, S2) is the edit distance between the first string and the second string, len(S1) is the length of the first string, and len(S2) is the length of the second string.
[0068] In a possible implementation, the processing module 202 generates a corresponding target triple based on the target entity domain, the target relationship domain, and the target prompt template, specifically including: the processing module 202 matches the relationship type of each target relationship in the target relationship domain with the relationship placeholder in the target prompt template to obtain a relationship description template; the processing module 202 retrieves the corresponding entity attribute information in the target entity domain according to the head entity and the tail entity of the target relationship; the processing module 202 fills the entity attribute information into the entity placeholder in the relationship description template to obtain a relationship description text; the processing module 202 performs natural language reasoning on the relationship description text to extract the triple information of the entity, relationship, and attribute included in the relationship description text; the processing module 202 splices the head entity, the tail entity, and the triple information of the target relationship to generate a knowledge graph subgraph centered on the target relationship as the target triple.
[0069] In a possible implementation, the method further includes: an acquisition module 201 acquires unannotated text corpora and annotated data from multiple fields, where the fields include technology, finance, healthcare, and sports, and the annotated data includes entity relationship annotation corpora and question-and-answer annotation corpora; a processing module 202 performs preprocessing operations on the unannotated text corpora to obtain target text corpora, and the preprocessing operations include word segmentation, part-of-speech tagging, and named entity recognition; the processing module 202 trains the target text corpora through an unsupervised pre-training method to obtain an initial large model, and the pre-training method includes GPT pre-training based on an autoregressive task and BERT pre-training based on an autoencoding task; the processing module 202 optimizes the initial large model through a supervised fine-tuning method based on the annotated data to obtain a preset large model, and multiple prompt templates for different fields are built into the preset large model, and the fine-tuning method includes joint fine-tuning based on multi-task learning.
[0070] It should be noted that: when the device provided in the above embodiment realizes its functions, only the above-mentioned division of each functional module is used for illustration. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process can be seen in the method embodiment, which will not be elaborated here.
[0071] This application also provides an electronic device. Referring to Figure 3 , Figure 3 is a schematic structural diagram of an electronic device provided in an embodiment of this application. The electronic device 300 may include: at least one processor 301, at least one network interface 304, a user interface 303, a memory 305, and at least one communication bus 302.
[0072] Among them, the communication bus 302 is used to realize the connection and communication between these components.
[0073] Among them, the user interface 303 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 303 may further include a standard wired interface and a wireless interface.
[0074] Among them, the network interface 304 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface).
[0075] Among them, the processor 301 may include one or more processing cores. The processor 301 connects various parts within the entire server through various interfaces and circuits. By running or executing instructions, programs, code sets, or instruction sets stored in the memory 305, and by invoking the data stored in the memory 305, it performs various functions of the server and processes data. Optionally, the processor 301 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), or programmable logic array (PLA). The processor 301 may integrate a combination of one or more of a central processing unit (CPU), a graphics processing unit (GPU), and a modem, etc. Among them, the CPU mainly processes the operating system, user interface, application programs, etc.; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communication. It can be understood that the above-mentioned modem may not be integrated into the processor 301 and may be implemented separately by a single chip.
[0076] Among them, the memory 305 may include random access memory (RAM) and may also include read-only memory. Optionally, the memory 305 includes a non-transitory computer-readable storage medium. The memory 305 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 305 may include a program storage area and a data storage area. Among them, the program storage area may store instructions for implementing the operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store the data involved in the above-mentioned various method embodiments. Optionally, the memory 305 may also be at least one storage device located far from the aforementioned processor 301. Refer to Figure 3 , the memory 305, as a computer storage medium, may include an operating system, a network communication module, a user interface module, and an application program for an information extraction method based on a large model.
[0077] In Figure 3In the electronic device 300 shown, the user interface 303 is mainly used to provide an interface for the user to input and obtain the data input by the user; and the processor 301 can be used to call the application program stored in the memory 305 that is an information extraction method based on a large model. When executed by one or more processors 301, the electronic device 300 is caused to execute one or more of the methods as described in the foregoing embodiments. It should be noted that for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that this application is not limited by the described action sequence, because according to this application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0078] This application also provides a computer-readable storage medium storing instructions. When executed by one or more processors 301, the electronic device 300 is caused to execute one or more of the methods as described in the foregoing embodiments.
[0079] In the foregoing embodiments, the descriptions of the respective embodiments have their own emphases. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0080] In several implementation manners provided by this application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some service interfaces. The indirect couplings or communication connections of the devices or units can be in electrical or other forms.
[0081] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they can be located in one place, or can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0082] In addition, in each embodiment of this application, the functional units can be integrated in one processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
[0083] When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a memory and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present application. The aforementioned memory includes various media that can store program codes, such as USB flash drives, mobile hard disks, magnetic disks, or optical discs.
[0084] The above are only exemplary embodiments of the present disclosure, and the scope of the present disclosure cannot be limited thereby. That is, any equivalent changes and modifications made in accordance with the teachings of the present disclosure still fall within the scope covered by the present disclosure. After considering the specification and the disclosure of the practical truth, those skilled in the art will easily think of other implementation manners of the present disclosure.
[0085] The present application aims to cover any variations, uses, or adaptive changes of the present disclosure. These variations, uses, or adaptive changes follow the general principles of the present disclosure and include well-known common knowledge or conventional technical means in the technical field not recorded in the present disclosure. The specification and the embodiments are only regarded as exemplary, and the scope and spirit of the present disclosure are defined by the claims.
Claims
1. An information extraction method based on a large model, characterized in that, The method includes: Obtaining the text to be recognized; Performing entity domain recognition on the text to be recognized to obtain a target entity domain, and performing relationship domain recognition on the text to be recognized to obtain a target relationship domain; Based on the target entity domain and the target relationship domain, inputting the text to be recognized into a preset large model for matching to obtain a target prompt template, where the preset large model includes multiple prompt templates; Generating a corresponding target triple based on the target entity domain, the target relationship domain, and the target prompt template.
2. The method according to claim 1, characterized in that, The performing entity domain recognition on the text to be recognized to obtain a target entity domain specifically includes: Performing part-of-speech tagging and named entity recognition on the text to be recognized to obtain a candidate entity set, where the candidate entity set includes multiple entities; Using a preset entity embedding model to map each of the entities to a low-dimensional dense vector space to obtain an entity vector corresponding to each of the entities; Based on the entity vectors, using a clustering algorithm to cluster the candidate entity set to obtain a clustering result; If it is determined that the clustering results corresponding to the first entity and the second entity are the same, then it is determined that the first entity and the second entity belong to the same entity domain, and thus the target entity domain is obtained, where the first entity and the second entity are any two of the multiple entities.
3. The method according to claim 2, characterized in that, The performing relationship domain recognition on the text to be recognized to obtain a target relationship domain specifically includes: Inputting the text to be recognized into a preset relationship extraction model to obtain a candidate relationship set, where the candidate relationship set includes multiple candidate relationships, and the candidate relationship includes a head entity, a tail entity, and a relationship type; For each of the candidate relationships, determining whether the head entity and the tail entity exist in the target entity domain at the same time; If it is determined that the head entity and the tail entity exist in the target entity domain at the same time, then the candidate relationship is determined as the target relationship, and the target relationship is determined as the target relationship domain; If it is determined that the head entity or the tail entity does not exist in the target entity domain, then extracting the text segment between the head entity and the tail entity in the text to be recognized, and using the text segment as the relationship description text of the target relationship.
4. The method according to claim 1, wherein The performing matching in the preset large model based on the target entity domain and the target relationship domain to obtain a target prompt template specifically includes: Based on the target entity domain and the target relationship domain, converting the text to be recognized into a first string; Converting each of the prompt templates included in the preset large model into a corresponding string to obtain multiple target strings, where one prompt template corresponds to one target string; Calculating the similarity between the first string and a second string, where the second string is any one of the multiple target strings; If it is determined that the similarity is greater than or equal to a preset similarity threshold, then determining the prompt template corresponding to the second string as the target prompt template.
5. The method according to claim 4, wherein The specific calculation formula for calculating the similarity between the first string and the second string is as follows: ; Where Similarity is the similarity, α is the weight coefficient, S1 is the first string, S2 is the second string, cos(S1, S2) is the cosine similarity between the first string and the second string, EditDistance(S1, S2) is the edit distance between the first string and the second string, len(S1) is the length of the first string, and len(S2) is the length of the second string.
6. The method according to claim 3, characterized in that, Generating the corresponding target triple based on the target entity domain, the target relationship domain, and the target prompt template specifically includes: Matching the relationship type of each target relationship in the target relationship domain with the relationship placeholder in the target prompt template to obtain a relationship description template; Retrieving the corresponding entity attribute information in the target entity domain according to the head entity and the tail entity of the target relationship; Filling the entity attribute information into the entity placeholder in the relationship description template to obtain a relationship description text; Performing natural language inference on the relationship description text to extract the triple information of entities, relationships, and attributes included in the relationship description text; Concatenating the head entity, the tail entity of the target relationship, and the triple information to generate a knowledge graph subgraph centered on the target relationship as the target triple.
7. The method according to claim 1, characterized in that, The method further includes: Obtaining unlabeled text corpora and labeled data from multiple fields, where the fields include technology, finance, healthcare, and sports, and the labeled data includes entity relationship annotation corpora and question and answer annotation corpora; Performing preprocessing operations on the unlabeled text corpora to obtain target text corpora, and the preprocessing operations include word segmentation, part-of-speech tagging, and named entity recognition; Training the target text corpora through an unsupervised pre-training method to obtain an initial large model, and the pre-training method includes GPT pre-training based on an autoregressive task and BERT pre-training based on an autoencoding task; Optimizing the initial large model through a supervised fine-tuning method based on the labeled data to obtain the preset large model, and multiple prompt templates for different fields are built into the preset large model, and the fine-tuning method includes joint fine-tuning based on multi-task learning.
8. An information extraction device based on a large model, characterized in that, The device includes an acquisition module (201) and a processing module (202), where: The acquisition module (201) is used to acquire the text to be recognized; The processing module (202) is used to perform entity domain recognition on the text to be recognized to obtain a target entity domain, and perform relationship domain recognition on the text to be recognized to obtain a target relationship domain; The processing module (202) is further used to input the text to be recognized into a preset large model for matching based on the target entity domain and the target relationship domain to obtain a target prompt template, and the preset large model includes multiple prompt templates; The processing module (202) is further configured to generate a corresponding target triple based on the target entity domain, the target relationship domain, and the target prompt template.
9. An electronic device, characterized in that, It includes a processor (301), a memory (305), a user interface (303), and a network interface (304). The memory (305) is used to store instructions. The user interface (303) and the network interface (304) are used to communicate with other devices. The processor (301) is configured to execute the instructions stored in the memory (305) so that the electronic device (300) executes the method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed, execute the method according to any one of claims 1-7.
Citation Information
Cited By
Generative knowledge object extraction method and system based on context learning
CN120930750A
A context learning-based generative knowledge object extraction method and system
CN120930750B
Medical database information management system and method
CN121434379A