CN117057345B - Role relation acquisition method and related products - Google Patents

Role relation acquisition method and related products Download PDF

Info

Publication number
CN117057345B
CN117057345B CN202311313777.9A CN202311313777A CN117057345B CN 117057345 B CN117057345 B CN 117057345B CN 202311313777 A CN202311313777 A CN 202311313777A CN 117057345 B CN117057345 B CN 117057345B
Authority
CN
China
Prior art keywords
entity
text
module
relationship
relation
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202311313777.9A
Other languages
Chinese (zh)
Other versions
CN117057345A (en
Inventor
梁宇轩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202311313777.9A priority Critical patent/CN117057345B/en
Publication of CN117057345A publication Critical patent/CN117057345A/en
Application granted granted Critical
Publication of CN117057345B publication Critical patent/CN117057345B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/284Lexical analysis, e.g. tokenisation or collocates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/289Phrasal analysis, e.g. finite state techniques or chunking
    • G06F40/295Named entity recognition

Abstract

The application discloses a method for acquiring a role relationship and related products, wherein the method comprises the following steps: extracting the text to be processed based on the entity extraction model to obtain an entity of the character type as a first candidate entity; determining a target vocabulary from the text to be processed as a second candidate entity according to the solidification degree and the degree of freedom of the vocabulary; the target vocabulary is vocabulary with the solidification degree larger than or equal to a preset solidification degree threshold value and the degree of freedom larger than or equal to a preset degree of freedom threshold value; the second candidate entity comprises an entity of a persona type; based on the text to be processed, classifying the first candidate entity and the second candidate entity through an entity classification model to obtain a classification result, and taking a plurality of entities with the classification result of character types as target entities; the character type is a subtype of the character type; based on the text to be processed, predicting the relation among the plurality of target entities through a relation prediction model to obtain a predicted relation among the plurality of target entities. This can improve the extraction effect of the relationship of the character entities.

Description

Role relation acquisition method and related products
Technical Field
The present disclosure relates to the field of data processing technologies, and in particular, to a method for acquiring a role relationship and a related product.
Background
A character graph generally refers to a type of vertical knowledge graph that contains characters and character relationships in text. The role atlas is displayed in a visual mode, so that a user can conveniently and intuitively inquire the role information. In the related art, entity extraction may be performed on the character, and then the character relation may be extracted, so as to construct a character map of the text.
However, in books with excessive text contents such as long novels, the naming and the relation of characters in the text are complex and rich, and the extraction of character entities and the extraction of relations are easy to have inaccurate problems. The extracted character relation is inaccurate, which affects the accuracy of the constructed character pattern and further affects the application effect of the character pattern.
Disclosure of Invention
The embodiment of the application provides a role relationship acquisition method and related products, so as to improve the extraction effect of the relationship between a role entity and a role entity.
In a first aspect, an embodiment of the present application provides a method for acquiring a role relationship, including:
extracting the text to be processed based on the entity extraction model to obtain an entity of the character type as a first candidate entity;
determining a target vocabulary from the text to be processed as a second candidate entity according to the solidification degree and the freedom degree of the vocabulary; the target vocabulary is vocabulary with the solidification degree larger than or equal to a preset solidification degree threshold value and the degree of freedom larger than or equal to a preset degree of freedom threshold value; the second candidate entity comprises an entity of a persona type;
Based on the text to be processed, classifying the first candidate entity and the second candidate entity through an entity classification model to obtain a classification result, and taking a plurality of entities with the classification result being character types as target entities; the character type is a subtype of the character type;
and predicting the relation among the target entities through a relation prediction model based on the text to be processed to obtain a predicted relation among the target entities.
In a second aspect, an embodiment of the present application provides an apparatus for acquiring a role relationship, including:
the entity extraction module is used for extracting the text to be processed based on the entity extraction model to obtain an entity of the character type as a first candidate entity;
the target vocabulary determining module is used for determining target vocabularies from the text to be processed as second candidate entities according to the solidification degree and the freedom degree of the vocabularies; the target vocabulary is vocabulary with the solidification degree larger than or equal to a preset solidification degree threshold value and the degree of freedom larger than or equal to a preset degree of freedom threshold value; the second candidate entity comprises an entity of a persona type;
the entity classification module is used for classifying the first candidate entity and the second candidate entity through an entity classification model based on the text to be processed to obtain a classification result, and taking a plurality of entities with the classification result being character types as target entities; the character type is a subtype of the character type;
And the relation prediction module is used for predicting the relation among the plurality of target entities through a relation prediction model based on the text to be processed to obtain a predicted relation among the plurality of target entities.
In a third aspect, an embodiment of the present application provides an apparatus for acquiring a role relationship, where the apparatus includes a processor and a memory:
the memory is used for storing a computer program and transmitting the computer program to the processor;
the processor is configured to execute the steps of the method for acquiring a role relationship provided in the first aspect according to instructions in the computer program.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium storing a computer program, which when executed by a computer device, implements the steps of the method for acquiring a role relationship provided in the first aspect.
In a fifth aspect, embodiments of the present application provide a computer program product comprising a computer program or instructions which, when executed by a computer device, implement the steps of the method for obtaining a relationship of roles provided in the first aspect.
From the above technical solutions, the embodiments of the present application have the following advantages:
In the embodiment of the present application, in the entity extraction stage, firstly, the text to be processed may be extracted based on the entity extraction model, so as to obtain an entity of a character type as a first candidate entity, and then, in combination with the degree of solidification and the degree of freedom of the vocabulary, a target vocabulary with the degree of solidification greater than or equal to a preset degree of solidification threshold and the degree of freedom greater than or equal to a preset degree of freedom threshold is determined from the text to be processed as a second candidate entity, where the second candidate entity includes an entity of the character type. Then, based on the text to be processed, the first candidate entity and the second candidate entity can be classified through an entity classification model to obtain a classification result, and a plurality of entities with the classification result being the character type are taken as target entities, wherein the character type is the subtype of the character type. Therefore, the entity of the character type can be classified into the entity of the character type with finer granularity, so that the classification accuracy of the entity is improved. In the relation extraction stage, the relation among the plurality of target entities can be predicted through a relation prediction model based on the text to be processed, so as to obtain the predicted relation among the plurality of target entities. By combining the above processes, the entity extraction model is introduced, and new words are found by combining the solidification degree and the degree of freedom, so that the entity with the character type label can be effectively and accurately extracted, then the character entity is classified into the character entity with finer granularity through the entity classification model, the classification accuracy of the entity can be improved, and the entity relationship prediction is conveniently carried out through the relationship prediction model, so that the extraction accuracy of the character entity relationship is improved. Thus, the accuracy of the entity and the relationship for constructing the character map can be improved from various aspects, and the accuracy of the finally constructed character map can be improved.
Drawings
FIG. 1a is a schematic diagram of an entity extraction stage according to an embodiment of the present disclosure;
FIG. 1b is a schematic diagram of a relationship extraction stage according to an embodiment of the present disclosure;
fig. 2 is a flowchart of a method for obtaining a role relationship according to an embodiment of the present application;
FIG. 3 is a schematic diagram of an entity classification model according to an embodiment of the present disclosure;
FIG. 4a is a schematic diagram of a sample dataset of an entity classification model according to an embodiment of the present application;
FIG. 4b is a schematic diagram of a sample dataset of another entity classification model according to an embodiment of the present application;
FIG. 5 is a schematic diagram of a connection text according to an embodiment of the present application;
FIG. 6a is a flowchart of another method for obtaining a role relationship according to an embodiment of the present disclosure;
fig. 6b is a schematic diagram of a role atlas according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of an acquiring device for a role relationship according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a server according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of a terminal device according to an embodiment of the present application.
Detailed Description
As described above, in books with excessive text content such as long novels, the naming and relationship of characters in the text are complex and rich, and the extraction of character entities and relationship is easy to be inaccurate. The extracted character relation is inaccurate, which affects the accuracy of the constructed character pattern and further affects the application effect of the character pattern. For ease of understanding, the entity extraction results in the related art are described in the form of table 1, and the relationship extraction results in the related art are described in the form of table 2.
TABLE 1
In the related art, for extracting the person, since the person is named as complex and special, it is difficult to accurately determine the extraction boundary of the entity, which results in inaccuracy of the extracted entity. For example, as shown in table 1, "qin-yan-ya" is extracted as "qin-yan-ya", and "dong Hua Hao-y" is extracted as "dong Hua Hao". In addition, there is also a problem that classification is inaccurate for entity types, for example, "Xiao Zong" in which an entity type is a genre of a person is classified as a type of a person, and "Shi Laike" in which an entity type is a school is classified as a type of a person.
TABLE 2
In the related art, since expressions of different authors are different, a large amount of information capable of confusing entity relationships exists in the text. For example, in table 2 above, it is actually unreasonable to consider "An Xin" and "Tang Feng" as "parent-child" relationships, and it is also unreasonable to consider "Jiang Caiping" and "Zhou Zeyun" as "partner" relationships.
Based on the above problems, an embodiment of the present application provides a method for acquiring a role relationship, where the method includes: in the entity extraction stage, firstly, the text to be processed can be extracted based on an entity extraction model to obtain an entity of a character type as a first candidate entity, and then, the solidification degree and the degree of freedom of the vocabulary are combined, and a target vocabulary with the solidification degree greater than or equal to a preset solidification degree threshold value and the degree of freedom greater than or equal to a preset degree of freedom threshold value is determined from the text to be processed and used as a second candidate entity, wherein the second candidate entity comprises the entity of the character type. Then, based on the text to be processed, the first candidate entity and the second candidate entity can be classified through an entity classification model to obtain a classification result, and a plurality of entities with the classification result being the character type are taken as target entities, wherein the character type is the subtype of the character type. Therefore, the entity of the character type can be classified into the entity of the character type with finer granularity, so that the classification accuracy of the entity is improved. In the relation extraction stage, the relation among the plurality of target entities can be predicted through a relation prediction model based on the text to be processed, so as to obtain the predicted relation among the plurality of target entities. By combining the above processes, the entity extraction model is introduced, and new words are found by combining the solidification degree and the degree of freedom, so that the entity with the character type label can be effectively and accurately extracted, then the character entity is classified into the character entity with finer granularity through the entity classification model, the classification accuracy of the entity can be improved, and the entity relationship prediction is conveniently carried out through the relationship prediction model, so that the extraction accuracy of the character entity relationship is improved. In this manner, the accuracy of the elements used to construct the character map can be improved from a variety of aspects, thereby improving the accuracy of the finally constructed character map.
Next, several terms that may be involved in the implementation of the present application are explained first.
The character map refers to a sagged class knowledge map containing characters and character relations in the text. The role atlas is displayed in a visual mode, so that a user can conveniently and intuitively inquire the role information.
Remote supervision is a supervised learning method based on external knowledge, and aims to automatically annotate text data by using known knowledge patterns, thereby being used for model training.
Information flow data refers to a large amount of data that is input, shared, distributed, and propagated by users over the internet.
Artificial intelligence (Artificial Intelligence, AI) is the theory, method, technique and application system that uses a digital computer or a machine controlled by a digital computer to simulate, extend and extend human intelligence, sense the environment, acquire knowledge and use the knowledge to obtain optimal results. In other words, artificial intelligence is an integrated technology of computer science that attempts to understand the essence of intelligence and to produce a new intelligent machine that can react in a similar way to human intelligence. Artificial intelligence, i.e. research on design principles and implementation methods of various intelligent machines, enables the machines to have functions of sensing, reasoning and decision. In the scene of acquiring the character relationship provided by the embodiment of the application, the artificial intelligence technology can sense texts such as books with excessive text contents by using a machine, and acquire entities and relationships required for constructing the character pattern from the texts, so that the accurate character pattern can be constructed conveniently, and the application effect of the character pattern can be improved.
The artificial intelligence technology is a comprehensive subject, and relates to the technology with wide fields, namely the technology with a hardware level and the technology with a software level. Artificial intelligence infrastructure technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and other directions.
The method for acquiring the role relationship and the related products mainly relate to machine learning. Among them, machine Learning (ML) is a multi-domain interdisciplinary, and involves multiple disciplines such as probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory, etc. It is specially studied how a computer simulates or implements learning behavior of a human to acquire new knowledge or skills, and reorganizes existing knowledge structures to continuously improve own performance. In the embodiment of the application, the entity extraction capability and the relation extraction capability of the entity can be continuously improved by means of machine learning, and accurate role entities and relations among the role entities can be extracted from texts. Machine learning is the core of artificial intelligence, a fundamental approach to letting computers have intelligence, which is applied throughout various areas of artificial intelligence. Machine learning and deep learning typically include techniques such as artificial neural networks, confidence networks, reinforcement learning, transfer learning, induction learning, teaching learning, and the like.
In order to facilitate understanding of the technical solution provided by the embodiments of the present application, the following describes an overall architecture of the method for obtaining a role relationship provided by the embodiments of the present application with reference to the accompanying drawings. In the overall architecture, the text to be processed is taken as a novel example, and the purpose is to acquire novel roles and novel role relationships so as to construct a role map of the novel. Specifically, the process of acquiring the role relationship in the embodiment of the present application is divided into two parts, namely an entity extraction phase and a relationship extraction phase.
FIG. 1a is a schematic diagram of an entity extraction stage according to an embodiment of the present disclosure; fig. 1b is a schematic diagram of a relationship extraction stage according to an embodiment of the present application. In the entity extraction stage, the novel word discovery model and the entity extraction model are used for processing the novel text to obtain candidate entities of the character type, as shown in fig. 1a and 1 b. The entity extraction model can be used for named entity recognition, such as a BERT-MRC model, so that a character entity is obtained as a first candidate entity; the new word discovery model may be used to mine a new entity, for example, an N-Gram model, where in order to reduce noise words generated when the new word discovery model mines a new entity, the new word discovery may be performed in combination with the degree of solidification and the degree of freedom of the vocabulary, so as to obtain a second candidate entity, where the second candidate entity includes a character entity. And then, classifying the first candidate entity and the second candidate entity through a more fine-grained entity classification model, such as a LABEL-GCN model, so as to obtain the entity of the role type in the classification result. The entity classification model can be used for classifying more fine granularity to obtain role entities, wherein the role types are subtypes of the person types. Thus, the character entities can be accurately and effectively extracted from the novel text, and the novel character vocabulary is obtained for subsequent character relation extraction. Then, in the relation extraction stage, a relation prediction model can predict the relation between the role entities in the novel role vocabulary. The relationship prediction model may be a BERT-RC model, which needs to use an entity pair in the same sentence in a novel, and a context corresponding to the entity pair as a model input, so in the embodiment of the present application, the relationship prediction needs to be performed by combining the novel role vocabulary and the context of the novel text to generate the context of the entity pair. Then, in order to improve the accuracy of the predicted relationship output by the relationship prediction model, the black-and-white list of the preset relationship words can be filtered, and the confidence and/or occurrence frequency of the predicted relationship are combined for filtering, so that the more accurate novel role relationship is obtained. Thus, the accuracy of elements for constructing the character pattern can be improved from various aspects, so that more accurate character patterns can be constructed conveniently.
It should be noted that, the embodiments of the present application are not limited to the execution body for executing the technical solution of the present application. For example, the method for acquiring the role relationship in the embodiment of the present application may be applied to a terminal device or a server, or may be cooperatively processed by the terminal device and the server. As one example, terminal devices include, but are not limited to, cell phones, desktop computers, tablet computers, notebook computers, palm computers, intelligent voice interaction devices, intelligent appliances, vehicle terminals, aircraft, and the like. The servers may be stand alone servers, clustered servers, or cloud servers.
In order to better understand the solution of the present invention, the following description will clearly and completely describe the solution of the embodiment of the present application with reference to the accompanying drawings in the embodiment of the present application, and it is obvious that the described embodiment is only a part of the embodiment of the present application, not all the embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
Fig. 2 is a flowchart of a method for obtaining a role relationship according to an embodiment of the present application. Referring to fig. 2, the method for acquiring a role relationship provided in the embodiment of the present application may include:
S201: extracting the text to be processed based on the entity extraction model to obtain an entity of the character type as a first candidate entity.
The text to be processed may refer to text for which a character map needs to be constructed. The entity of the character type may refer to an entity constituted by the name of a character in the text to be processed. For example, for the text content of "although three pairs of variant souls are also known somewhat," the entity of the character type "three pairs of" Tang "can be extracted therefrom as the first candidate entity based on the entity extraction model.
S202: and determining the target vocabulary from the text to be processed as a second candidate entity according to the solidification degree and the freedom degree of the vocabulary.
The target vocabulary may be a vocabulary with a degree of solidification greater than or equal to a preset degree of solidification threshold and a degree of freedom greater than or equal to a preset degree of freedom threshold. The degree of solidification can represent the association degree of each component word of a vocabulary, and the higher the degree of solidification is, the higher the association degree between each component word is, so that the vocabulary is more reasonable. For example, the solidification degree of "cinema" is greater than that of "movie", so the word "cinema" is more reasonable. The degree of freedom can represent the abundance of adjacent words of a vocabulary, and the higher the degree of freedom, the more the adjacent words of the vocabulary are, and therefore, the more complete the vocabulary is. For example, the degree of freedom of "chocolate" is greater than that of "chocolate", and thus the term "chocolate" is more complete.
Therefore, based on the degree of solidification and the degree of freedom of the vocabulary, more entities can be found in the text to be processed as second candidate entities. The second candidate entity may include a person type entity and also include a non-person type entity.
S203: based on the text to be processed, classifying the first candidate entity and the second candidate entity through an entity classification model to obtain a classification result, and taking a plurality of entities with the classification result of character types as target entities.
In practical applications, although the entity extraction model may provide an entity classification function, for text with more content, there may still be a problem of classification errors, and the second candidate entity may also include entities other than the person type. Based on this, in the embodiment of the present application, the entity classification model is used to classify the first candidate entity and the second candidate entity in a finer granularity, so that a plurality of entities whose classification results are character types can be screened out. Wherein a finer granularity of classification may be embodied as further subdividing the persona types into persona types, that is, persona types that are sub-types of persona types. For example, the entity of the character type is subdivided into individual character entities such as "actor", "composer", "athlete", and the like.
S204: based on the text to be processed, predicting the relation among the plurality of target entities through a relation prediction model to obtain a predicted relation among the plurality of target entities.
In the relation extraction stage, the accurate target entity obtained in the entity extraction stage is predicted by means of a relation prediction model, so that the extraction accuracy of the role entity relation is improved. In this manner, the accuracy of the elements used to construct the character map can be improved from a variety of aspects, thereby improving the accuracy of the finally constructed character map.
In this embodiment of the present application, for the above step S201, a named entity recognition model based on sequence labeling, for example, a BiLSTM-CRF or BERT-BiLSTM model, may be used to label the entity type of the text to extract the entity. However, for nested entities, such as "Sichuan" nested in the entity "Sichuan university", the above model requires very complex labeling of the text to complete extraction of the nested entities, and it is difficult to ensure good extraction results. Therefore, with respect to the above step S201, the embodiment of the present application may provide an entity extraction model to improve the extraction effect on nested entities. For ease of understanding, the training process of the entity extraction model is described below as an example.
As an example, the entity extraction model to be trained may include a first encoding module, a first prediction module, a second prediction module, and a third prediction module. Correspondingly, the entity extraction model can be obtained through training in the following steps 11-14 (it should be noted that, steps 11-14 are not shown in the figure):
step 11: and encoding the spliced data through a first encoding module to obtain word vectors.
The spliced data refers to data obtained by splicing the first sample text and the description information of the entity type in the first sample text. In the embodiment of the application, the description of the entity type by the encyclopedia platform can be adopted as the description information of the entity type. For example, if the first text includes an entity of a character type, and the description information of the character type is a name of the character, the concatenation data may be represented as: [ name of character Ming 1975 created Ming company together with friend Ming; if the first sample includes an entity of an organization type, and the description information of the organization type is the name of the organization, the splice data may be embodied as [ the name of the organization is created by Ming Summit 1975 with the friend's Ming Sum ].
In addition, the first encoding module may be implemented using a pre-trained language model (Bidirectional Encoder Representations from Transformers, BERT). And encoding the spliced data through the BERT model to obtain the word vector.
Step 12: the word vector is used as input of a first prediction module, the first prediction module predicts the starting position information of the entity corresponding to the description information in the first sample text, and determines a first loss value corresponding to the first prediction module; and taking the word vector as input of a second prediction module, predicting end position information of the entity corresponding to the description information in the first sample text through the second prediction module, and determining a second loss value corresponding to the second prediction module.
The first prediction module and the second prediction module can be implemented by adopting a classification model. And the two classification models are used for respectively predicting the start position information and the end position information of the entity corresponding to the description information in the first sample text, so that the extraction boundary of the entity can be accurately judged, and the extraction effect is improved.
Step 13: and taking the start position information and the end position information as inputs of a third prediction module, predicting the probability that the first text segment formed from the start position information to the end position information is an entity through the third prediction module, and determining a third loss value corresponding to the third prediction module.
The third prediction module may also be implemented by using a classification model. The probability that the first text segment formed from the starting position information to the ending position information is the entity is predicted through the classification model, so that the entity can be accurately extracted, and the extraction effect is improved.
Step 14: and iteratively updating parameters of the entity extraction model to be trained based on the first loss value, the second loss value and the third loss value until the updated model meets the first training cut-off condition, and ending training to obtain the entity extraction model.
In the training process of the entity extraction model, the sum of the first loss value, the second loss value and the third loss value can be used as a total loss value, and the parameters of the entity extraction model to be trained are iteratively updated by the total loss value until the training is finished when the first training cut-off condition is met. The first training cutoff condition may include a model iteration round being greater than or equal to a first preset round threshold and/or a total loss value being less than or equal to a second preset loss threshold.
In this way, the embodiment of the application adds the description information of the entity type as the prior information, and adopts the three classifiers to perform combined training, so that the processing performance of the finally trained entity extraction model is improved.
Further, it is mentioned that in the entity extraction stage, the new word discovery model may be used to mine a new entity, for example, an N-Gram model, where in order to reduce noise words generated when the new word discovery model mines a new entity, the new word discovery may be performed in combination with the degree of solidification and the degree of freedom of the vocabulary, so as to obtain a second candidate entity. Based on this, in the embodiment of the present application, the above-mentioned determining process of the second candidate entity, that is, step S202, may specifically include steps 21 to 23:
step 21: splitting the text to be processed to obtain a plurality of candidate words.
For ease of understanding, the text to be processed is exemplified by "abcde", which may be split into two candidate words, "abc" and "de". It should be noted that, the embodiment of the present application may not specifically limit the splitting manner of the text to be processed, and may be implemented by any existing or future method capable of splitting text content.
Step 22: aiming at a first candidate vocabulary in the plurality of candidate vocabularies, determining the solidification degree of the first candidate vocabulary according to the occurrence frequency corresponding to the plurality of component words in the first candidate vocabulary and the common occurrence frequency of the plurality of component words; and determining the degree of freedom of the first candidate vocabulary according to the left adjacent word information entropy and the right adjacent word information entropy of the first candidate vocabulary.
For the degree of solidification of the vocabulary, embodiments of the present application may be determined using the following equation (1-1):
(1-1)
where pmi (x, y) represents the degree of solidification of the word "xy", P (xy) represents the probability of co-occurrence of the constituent words "x" and "y", P (x) represents the probability of occurrence of the constituent word "x", and P (y) represents the probability of occurrence of the constituent word "y".
In addition, for "abc" in the above example, the vocabulary is composed of three words "a", "b" and "c", so, in order to calculate the degree of solidification, the three words may be first internally spliced to obtain a new component word, which may specifically include two cases of "a" and "bc" or "ab" and "c". In this regard, when calculating the degree of solidification, it is necessary to consider the above two cases, and to take the minimum degree of solidification corresponding to the case where the degree of solidification is minimum as the degree of solidification of the whole word "abc". For ease of understanding, the following equation (1-2) is used to describe the manner in which the above-described degree of solidification is calculated:
(1-2)
wherein,word ++representing 1 st to m-th constituent words>Is used for the solidification degree of the glass fiber,representation vocabulary->Each component word->Is (are) co-occurrence probability of->Representation vocabulary->Each of the constituent words of (a) The product of the respective occurrence probabilities.
For the degree of solidification of the vocabulary, embodiments of the present application may be determined by the following equation (2):
(2)
wherein,representation vocabulary->Freedom of (A)>Representing the vocabulary->Is the left-neighbor word information entropy of (c),representing the vocabulary->Right neighbor information entropy of (c).
Step 23: and determining the vocabulary with the solidification degree larger than or equal to a preset solidification degree threshold value and the vocabulary with the freedom degree larger than or equal to a preset freedom degree threshold value from the plurality of candidate vocabularies as target vocabularies according to the solidification degree and the freedom degree respectively corresponding to the plurality of candidate vocabularies.
In this way, the embodiment of the application finds new words by introducing the solidification degree and the degree of freedom of the words, and can effectively and accurately determine the entity comprising the character type.
Further, in the embodiment of the present application, the first candidate entity and the second candidate entity may be classified in a finer granularity by the entity classification model, i.e., a plurality of entities whose classification results are character types may be screened out. Based on this, the embodiment of the application can provide an entity classification model to improve the entity classification effect. For ease of understanding, the process of classifying the first candidate entity and the second candidate entity using the entity classification model, that is, the above step S203, will be described below with reference to the embodiments and the drawings.
Fig. 3 is a schematic diagram of an entity classification model according to an embodiment of the present application. Referring to fig. 3, the entity classification model includes a second encoding module, an attention module, a composition module, a graph convolution module, and a dot product module. The first candidate entity and the second candidate entity are both subordinate to a candidate entity set of the text to be processed. In correspondence with this, step S203 may specifically include steps 31 to 35 (it should be noted that steps 31 to 35 are not shown in the figure):
step 31: and encoding the context fragments of the plurality of candidate entities in the candidate entity set in the text to be processed respectively through a second encoding module to obtain the context vector of each candidate entity.
In fig. 3, the second encoding module may include a vector model and a neural network model. The vector model may be specifically used to obtain a word vector and a corresponding position vector; the neural network model may be implemented by a two-way long and short term memory network. And the context segments of the candidate entities in the text to be processed are used as the input of the second coding module, and the context vectors of the candidate entities can be obtained by coding the candidate entities through a vector model and a neural network model.
Step 32: and taking each candidate entity and the corresponding context vector as input of an attention module, and determining the association relationship between each candidate entity and the corresponding context vector as a first association relationship through the attention module.
In fig. 3, the attention module may be composed of three parts, an attention mechanism, a self-attention mechanism, and an interaction model. The candidate entities and the corresponding context vectors are used as input of an attention mechanism, a result is output to an interaction model through the attention mechanism, the context vectors of the candidate entities are also required to be used as input of a self-attention mechanism, the result is output through the self-attention mechanism, and the association relationship between the candidate entities and the corresponding context vectors, namely the first association relationship, is obtained by splicing the result output by the interaction model.
Step 33: and processing the character type labels of the candidate entities through the composition module to obtain a label graph structure.
In the step, nodes in the label graph structure are used for representing preset labels with various character types, and edges in the label graph structure are used for representing that the labels with various character types are associated; the character type tag is a sub-tag of the person type tag. As shown in fig. 3, in the tag map structure, the preset character type tags may include actors, architects, doctors, athletes, and composers, and the preset character type tags are all sub-tags of the character type tags and have a relationship therebetween.
Step 34: and using the label graph structure as input of a graph rolling module, processing the label graph structure through the graph rolling module, and determining the association relationship among the labels of various role types as a second association relationship.
As shown in connection with fig. 3, a graph rolling network and a linear transformation module may be included in the graph rolling module. The label graph structure is processed by the label graph structure and the association relation among the labels of various role types, namely the second association relation, is output.
Step 35: and carrying out dot product operation on the first association relation and the second association relation through a dot product module to obtain classification results of each candidate entity.
Since the aforementioned second candidate entity may include a person-type entity or a non-person-type entity, the more fine-grained classification result obtained by the entity classification model may also include a character type and a non-character type. Then, the entity with the classification result being the role type can be used as the target entity. Therefore, the classification accuracy of the entities can be improved through finer-granularity classification, and the relationship prediction can be conveniently carried out according to accurate role entities.
In addition, for the entity classification model, the embodiment of the application can also introduce the training process of the model. As an example, the entity classification model is trained based on the sample entity, the context segment of the text in which the sample entity is located, and the role type label of the sample entity. The sample entity, the context segment of the text in which the sample entity is located, and the sample entity role type tag are all subordinate to the sample data set of the entity classification model. For ease of understanding, the acquisition process of these sample data sets is described below.
As an example, a sample entity, a context fragment of the text in which the sample entity is located, and a role type tag of the sample entity may be obtained by: acquiring an entity of a role type from the second sample text as a sample entity, and acquiring the upper and lower Wen Pianduan of the sample entity in the second sample text; and marking the role type of the sample entity to obtain a role type label. Fig. 4a is a schematic diagram of a sample dataset of an entity classification model according to an embodiment of the present application. In practical application, in order to improve the effect of classifying the entities of the text with excessive contents, the sample entities may be directly obtained from the character dictionary corresponding to one or more novels, and the sample entities are correspondingly marked in the second sample text, so as to obtain the sample data set.
In addition, in order to further improve the entity classification effect, in the embodiment of the application, the sample data set can be expanded, which is helpful for training the entity classification model by using various entities. In particular, the expansion process of the sample dataset may comprise: acquiring a hotword entity; hotword entities are hotwords used to represent entities; generating a second text segment comprising the hotword entity based on the information stream data, and acquiring a type tag of the hotword entity through a crowdsourcing platform for data annotation; the sample data set is augmented with a hotword entity, a second text segment, and a type tag for the hotword entity. Fig. 4b is a schematic diagram of a sample dataset of another entity classification model according to an embodiment of the present application. And (4) expanding the role dictionary by using the hot word entity to obtain an entity dictionary, wherein the entity dictionary can comprise various entities such as person type entities, place type entities and the like, and correspondingly, marking the hot word entity in a second text segment corresponding to the hot word entity to finish the expansion of the sample data set.
In the embodiment of the present application, for the step S204, a conventional relationship classification policy may be adopted, for example, a method such as template matching or pulse coupling neural network, but these methods have limited utilization of semantic information and entity types of text, which results in inaccurate prediction of entity relationships. Therefore, with respect to the above step S204, the embodiment of the present application may provide a relationship prediction model to improve the prediction effect on the relationship between entities. For ease of understanding, the training process of the relational prediction model is exemplarily described below.
As an example, the relational prediction model may be trained by the following steps 41 to 45 (it should be noted that steps 41 to 45 are not shown in the figure):
step 41: a plurality of entity pairs is determined from the third sample text.
Here, a first entity pair of the plurality of entity pairs includes a first entity and a second entity, the first entity and the second entity being located in a same text segment of the third sample text. For example, if the third sample text includes a text segment of "it is Liu Xuan and Liu Shanshan siblings", the first entity may be "Liu Xuan" and the second entity may be "Liu Shanshan", both of which are located in the text segment.
In the embodiment of the present application, in order to effectively use semantic information and entity types of a text and improve accuracy of a relationship prediction result, all entity pairs in the third sample text and text fragments corresponding to each entity pair may be enumerated, so as to facilitate subsequent training of a relationship prediction model.
Step 42: for the first entity pair, inserting a first identifier before the text start position of the first entity, inserting a second identifier after the text end position of the first entity, and inserting a third identifier before the text start position of the second entity, and inserting a fourth identifier after the text end position of the second entity, to obtain the identification text of the first entity pair.
In an embodiment of the present application, the first identifier and the second identifier each include a type tag of the first entity, and the third identifier and the fourth identifier each include a type tag of the second entity.
For example, a first entity pair includes a first entity "object" and a second entity "object". Correspondingly, for a first entity "subject", the first identifier may be denoted as < S: person >, and the second identifier may be denoted as </S: person >, where Person may represent the entity type of the first entity "subject"; for the second entity "object", the third identifier may be denoted as < O: person >, and the fourth identifier may be denoted as </O: person >, wherein Person may represent the entity type of the second entity "object". The above-mentioned only one possible representation of the identifier is not particularly limited to the actual representation.
Step 43: and connecting the first identifier and the third identifier in the identification text through the relation prediction model to be trained to obtain a connection text, and processing the connection text to obtain the relation between the first entity and the second entity as the relation between the first entity pair.
Wherein the first identifier and the third identifier can be implemented by a connection function in the connection layer to obtain a connection text. Processing the connection text may be implemented by a normalized exponential function in the classification layer to obtain a relationship between the first entity pair.
For ease of understanding, step 43 is described below in conjunction with the accompanying figures. Fig. 5 is a schematic diagram of a connection text according to an embodiment of the present application. In FIG. 5, < S: md > is a first identifier corresponding to one entity in a pair of entities, and < S: md > is a second identifier corresponding to the entity; < O: md > is a third identifier corresponding to the other entity in the pair of entities, and < O: md > is a fourth identifier corresponding to the other entity. By connecting the first identifier < S: md > and the third identifier < O: md > and classifying, the target relationship "HYPONYM-OF" OF the entity pair can be obtained.
Step 44: and selecting a target relation from the relations respectively corresponding to the entities.
Here, the target relationship is a relationship of n before confidence ranking in the relationships respectively corresponding to the plurality of entities; n is a positive integer.
Step 45: updating the target relation based on the relation label corresponding to the target relation, and iteratively updating parameters of the relation prediction model to be trained based on the updated target relation until the updated model meets the second training cut-off condition, so as to obtain the relation prediction model.
The second training cutoff condition may include a model iteration round being greater than or equal to a second preset round threshold, and/or a loss value being less than or equal to a second preset loss threshold. Therefore, the target relation with higher predicted confidence is updated by the relation label, and the model is iteratively trained based on the updated target relation, so that the accuracy of the model is improved.
Further, in order to effectively utilize the relation prediction model and improve the accuracy of the prediction result, a black-and-white list of the relation words can be preset to filter the text to be processed, and then the relation prediction can be carried out on the filtered text. Based on this, in the embodiment of the present application, the process of obtaining the prediction relationship between the target entities, that is, the step S204 described above, may specifically include steps 51 to 54 (it should be noted that, steps 51 to 54 are not shown in the figures):
Step 51: based on the text to be processed, predicting the relation among the plurality of target entities through a relation prediction model to obtain a first relation among the plurality of target entities.
For example, the text to be processed, taking as an example "Jiang Caiping persist and Zhou Zeyun marriage", the target entity may include "Jiang Caiping" and "Zhou Zeyun". Thus, the first relation between the two can be obtained as a spouse relation through the relation prediction model.
Step 52: and acquiring a relationship word white list and a relationship word black list corresponding to the first relationship.
Wherein the relationship word whitelist includes first relationship words positively correlated with the first relationship and the relationship word blacklist includes second relationship words negatively correlated with the first relationship. In short, the first relation word is positively related to the first relation, which means that the meaning of the first relation word and the first relation word are the same or similar. The second relationship word is inversely related to the first relationship, meaning that the second relationship word is different from the first relationship. For ease of understanding, still taking the spouse relationship in the above example as an example, the relationship word blacklist and the relationship word whitelist corresponding to the spouse relationship are described below in the form of table 3.
TABLE 3 Table 3
Step 53: filtering text fragments which do not comprise the first relation word from the text to be processed based on the relation word white list; and filtering text segments including the second relationship word from the text to be processed based on the relationship word blacklist.
Because the first relation word is positively correlated with the first relation, and the second relation word is inversely correlated with the first relation, the text to be processed can be noise-reduced by filtering the text fragments not including the first relation word and the text fragments including the second relation word, so that the accurate prediction relation can be obtained later.
Step 54: and predicting the relation among the plurality of target entities again through a relation prediction model based on the filtered text to be processed, and obtaining a second relation among the plurality of target entities as a predicted relation.
In this way, the relationship between the target entities is predicted twice through the relationship prediction model, and the next prediction can be realized based on the text to be processed after the previous prediction result is filtered, so that the accurate prediction relationship is facilitated to be obtained.
In the foregoing, the purpose of improving the extraction effect of the entity and the extraction effect of the entity relationship is to construct a more accurate role atlas, so the embodiment of the present application may provide another role relationship obtaining method to construct a role atlas. The method of acquiring the relationship of roles will be described below with reference to the embodiments and drawings, respectively.
FIG. 6a is a flowchart of another method for obtaining a role relationship according to an embodiment of the present disclosure; fig. 6b is a schematic diagram of a role map according to an embodiment of the present application. Referring to fig. 6a, the method for acquiring a role relationship provided in the embodiment of the present application may include:
S601: extracting the text to be processed based on the entity extraction model to obtain an entity of the character type as a first candidate entity.
S602: and determining the target vocabulary from the text to be processed as a second candidate entity according to the solidification degree and the freedom degree of the vocabulary.
S603: based on the text to be processed, classifying the first candidate entity and the second candidate entity through an entity classification model to obtain a classification result, and taking a plurality of entities with the classification result of character types as target entities.
S604: based on the text to be processed, predicting the relation among the plurality of target entities through a relation prediction model to obtain a predicted relation among the plurality of target entities.
It should be noted that, in the embodiment of the present application, the technical details of step S601 to step S604 may be referred to the related descriptions of step S201 to step S204 in the foregoing embodiment, which are not described herein again.
S605: and constructing a character map of the text to be processed based on the plurality of target entities and the predictive relation among the plurality of target entities.
For step S605, in conjunction with fig. 6b, in the character map of the text to be processed, the nodes of the character map may represent target entities, and the arrow and the description information of the edges between the nodes may represent the prediction relationships between the target entities, so that the character map may be constructed.
In addition, in order to further improve accuracy of the role atlas, in the embodiment of the present application, the role atlas may be reconstructed after the predicted relationship is filtered again. Specifically, the method for acquiring the role relationship may further include: confidence degrees and/or occurrence frequencies of prediction relations among a plurality of target entities are respectively obtained; and filtering the prediction relation with confidence coefficient lower than a preset confidence coefficient threshold value and/or occurrence frequency lower than a preset frequency threshold value from the prediction relation among the plurality of target entities to obtain a filtered prediction relation. Based on this, the implementation manner of constructing the character map of the text to be processed based on the prediction relationships between the plurality of target entities may specifically include: and constructing a role map of the text to be processed based on the plurality of target entities and the filtered prediction relationship. Therefore, the method is beneficial to constructing the role atlas with more accurate prediction relation by filtering out the prediction relation with insufficient confidence and/or lower occurrence frequency, thereby improving the accuracy of the role atlas.
Based on the method for acquiring the role relationships provided in the foregoing embodiment, the embodiment of the present application may also correspondingly provide an apparatus for acquiring the role relationships. The acquisition means of the character relationship will be described below with reference to the embodiments and drawings, respectively.
Fig. 7 is a schematic structural diagram of an acquiring device for a role relationship according to an embodiment of the present application. Referring to fig. 7, an apparatus 700 for acquiring a role relationship according to an embodiment of the present application includes:
the entity extraction module 701 is configured to extract a text to be processed based on the entity extraction model, so as to obtain an entity of a character type as a first candidate entity;
a target vocabulary determining module 702, configured to determine, according to the degree of solidification and the degree of freedom of the vocabulary, a target vocabulary from the text to be processed as a second candidate entity; the target vocabulary is vocabulary with the solidification degree larger than or equal to a preset solidification degree threshold value and the degree of freedom larger than or equal to a preset degree of freedom threshold value; the second candidate entity comprises an entity of a persona type;
the entity classification module 703 is configured to classify, based on the text to be processed, the first candidate entity and the second candidate entity through an entity classification model, obtain a classification result, and take a plurality of entities with the classification result being character types as target entities; the character type is a subtype of the character type;
and the relationship prediction module 704 is configured to predict relationships among the plurality of target entities through a relationship prediction model based on the text to be processed, so as to obtain a predicted relationship among the plurality of target entities.
Optionally, the entity extraction model to be trained includes a first coding module, a first prediction module, a second prediction module, and a third prediction module;
the entity extraction model is obtained through training of the following modules:
the first training module is used for encoding the spliced data through the first encoding module to obtain word vectors; the spliced data are data obtained by splicing the first sample text and the description information of the entity type in the first sample text;
the second training module is used for taking the word vector as the input of the first prediction module, predicting the starting position information of the entity corresponding to the description information in the first sample text through the first prediction module, and determining a first loss value corresponding to the first prediction module; and taking the word vector as input of the second prediction module, predicting end position information of an entity corresponding to the description information in the first sample text through the second prediction module, and determining a second loss value corresponding to the second prediction module;
the third training module is used for taking the starting position information and the ending position information as the input of the third prediction module, predicting the probability that a first text segment formed from the starting position information to the ending position information is an entity through the third prediction module, and determining a third loss value corresponding to the third prediction module;
And the fourth training module is used for iteratively updating the parameters of the entity extraction model to be trained based on the first loss value, the second loss value and the third loss value until the updated model meets a first training cut-off condition, and finishing training to obtain the entity extraction model.
Optionally, the target vocabulary determination module 702 includes:
the first determining submodule is used for splitting the text to be processed to obtain a plurality of candidate vocabularies;
the second determining submodule is used for determining the solidification degree of a first candidate vocabulary in a plurality of candidate vocabularies according to the occurrence frequency corresponding to a plurality of component words in the first candidate vocabulary and the common occurrence frequency of a plurality of component words; determining the degree of freedom of the first candidate vocabulary according to the left neighbor word information entropy and the right neighbor word information entropy of the first candidate vocabulary;
and the third determination submodule is used for determining the vocabulary with the solidification degree larger than or equal to the preset solidification degree threshold value and the degree of freedom larger than or equal to the preset degree of freedom threshold value from the candidate vocabularies as the target vocabulary according to the solidification degree and the degree of freedom respectively corresponding to the candidate vocabularies.
Optionally, the first candidate entity and the second candidate entity are both subordinate to the candidate entity set of the text to be processed; the entity classification model comprises a second coding module, an attention module, a composition module, a graph rolling module and a dot product module;
the entity classification module 703 includes:
the first classifying sub-module is used for respectively encoding context fragments of a plurality of candidate entities in the candidate entity set in the text to be processed through the second encoding module to obtain context vectors of the candidate entities;
the second classification sub-module is used for taking each candidate entity and the corresponding context vector as the input of the attention module, and determining the association relationship between each candidate entity and the corresponding context vector as a first association relationship through the attention module;
the third classification sub-module is used for processing the character type labels of the candidate entities through the composition module to obtain a label graph structure; the nodes in the label graph structure are used for representing a plurality of preset role type labels, and the edges in the label graph structure are used for representing that the plurality of role type labels are associated; the character type tag is a sub-tag of the person type tag;
The fourth classification sub-module is used for taking the label graph structure as the input of the graph rolling module, processing the label graph structure through the graph rolling module and determining the association relationship among the multiple role type labels as a second association relationship;
a fifth classification sub-module, configured to perform a dot product operation on the first association relationship and the second association relationship through the dot product module, to obtain a classification result of each candidate entity; the classification result includes a character type and a non-character type.
Optionally, the entity classification model is obtained by training based on a sample entity, a context segment of a text in which the sample entity is located, and a role type label of the sample entity;
the sample entity, the context fragment of the text in which the sample entity is located, and the role type tag of the sample entity are obtained through the following modules:
the sample acquisition module is used for acquiring an entity of a role type from a second sample text as the sample entity and acquiring the upper and lower Wen Pianduan of the sample entity in the second sample text;
and the type labeling module is used for labeling the role type of the sample entity to obtain the role type label.
Optionally, the sample entity, the context segment of the text in which the sample entity is located, and the role type tag of the sample entity are all subordinate to the sample data set of the entity classification model;
the role relationship acquiring device 700 further includes:
the hotword entity acquisition module is used for acquiring hotword entities; the hotword entity is a hotword for representing the entity;
the hotword entity processing module is used for generating a second text segment comprising the hotword entity based on the information stream data and acquiring a type tag of the hotword entity through a crowdsourcing platform for data labeling;
and the sample expansion module is used for expanding the sample data set by the hotword entity, the second text fragment and the type label of the hotword entity.
Optionally, the relation prediction model is obtained through training of the following modules:
a fifth training module for determining a plurality of entity pairs from the third sample text; a first entity pair of the plurality of entity pairs includes a first entity and a second entity, the first entity and the second entity being located in a same text segment of the third sample text;
a sixth training module, configured to insert, for the first entity pair, a first identifier before a text start position of the first entity, a second identifier after a text end position of the first entity, and a third identifier before a text start position of the second entity, and a fourth identifier after a text end position of the second entity, to obtain an identification text of the first entity pair; the first identifier and the second identifier each comprise a type tag of the first entity, and the third identifier and the fourth identifier each comprise a type tag of the second entity;
A seventh training module, configured to use the identification text as an input of a relationship prediction model to be trained, connect a first identifier and a third identifier in the identification text through the relationship prediction model to be trained to obtain a connection text, and process the connection text to obtain a relationship between the first entity and the second entity, where the relationship is used as a relationship between the first entity pair;
the eighth training module is used for selecting a target relationship from the relationships respectively corresponding to the entities; the target relationship is a relationship with n top confidence ranks in the relationships respectively corresponding to the entities; n is a positive integer;
and a ninth training module, configured to update the target relationship based on a relationship label corresponding to the target relationship, and iteratively update parameters of the relationship prediction model to be trained based on the updated target relationship, until the updated model meets a second training deadline condition, and obtain the relationship prediction model.
Optionally, the relationship prediction module 704 includes:
the first prediction submodule is used for predicting the relation among a plurality of target entities through the relation prediction model based on the text to be processed to obtain a first relation among the plurality of target entities;
The second prediction sub-module is used for acquiring a relationship word white list and a relationship word black list corresponding to the first relationship; the relationship word whitelist includes a first relationship word positively correlated with the first relationship, the relationship word blacklist includes a second Guan Jici inversely correlated with the first relationship;
the third prediction sub-module is used for filtering text fragments which do not comprise the first relation word from the text to be processed based on the relation word white list; filtering text fragments comprising the second related words from the text to be processed based on the related word blacklist;
and the fourth prediction sub-module is used for predicting the relation among the plurality of target entities again through the relation prediction model based on the filtered text to be processed, so as to obtain a second relation among the plurality of target entities as the prediction relation.
Optionally, the obtaining device 700 of the role relationship further includes:
and the role atlas construction module is used for constructing the role atlas of the text to be processed based on the prediction relations between the target entities.
Optionally, the obtaining device 700 of the role relationship further includes:
The parameter acquisition module is used for respectively acquiring confidence degrees and/or occurrence frequencies of the prediction relations among a plurality of target entities;
the filtering module is used for filtering the prediction relation with confidence coefficient lower than a preset confidence coefficient threshold value and/or occurrence frequency lower than a preset frequency threshold value from the prediction relation among the target entities to obtain the filtered prediction relation;
the role atlas construction module includes:
and the construction submodule is used for constructing the role atlas of the text to be processed based on the target entities and the filtered prediction relations.
The configuration of the control device that implements the above method of acquiring a role relationship will be described below in terms of a server form and a terminal device form, respectively.
The embodiment of the application provides a role relation acquisition device, which can be a server. Fig. 8 is a schematic diagram of a server according to an embodiment of the present application, where the server 900 may have a relatively large difference between configurations or performances, and may include one or more central processing units (central processing units, CPU) 922 (e.g., one or more processors) and a memory 932, and one or more storage media 930 (e.g., one or more mass storage devices) storing application programs 942 or data 944. Wherein the memory 932 and the storage medium 930 may be transitory or persistent. The program stored in the storage medium 930 may include one or more modules (not shown), each of which may include a series of instruction operations on a server. Still further, the central processor 922 may be arranged to communicate with a storage medium 930 to execute a series of instruction operations in the storage medium 930 on the server 900.
The server 900 may also include one or more power supplies 926, one or more wired or wireless network interfaces 950, one or more input/output interfaces 958, and/or one or more operating systems 941.
The steps performed by the server in the above embodiments may be based on the server structure shown in fig. 8.
Wherein, CPU 922 is configured to perform the steps of:
extracting the text to be processed based on the entity extraction model to obtain an entity of the character type as a first candidate entity;
determining a target vocabulary from the text to be processed as a second candidate entity according to the solidification degree and the freedom degree of the vocabulary; the target vocabulary is vocabulary with the solidification degree larger than or equal to a preset solidification degree threshold value and the degree of freedom larger than or equal to a preset degree of freedom threshold value; the second candidate entity comprises an entity of a persona type;
based on the text to be processed, classifying the first candidate entity and the second candidate entity through an entity classification model to obtain a classification result, and taking a plurality of entities with the classification result being character types as target entities; the character type is a subtype of the character type;
and predicting the relation among the target entities through a relation prediction model based on the text to be processed to obtain a predicted relation among the target entities.
The embodiment of the application also provides another role relation acquisition device, which can be a terminal device. As shown in fig. 9, for convenience of explanation, only the portions related to the embodiments of the present application are shown, and specific technical details are not disclosed, please refer to the method portions of the embodiments of the present application. The terminal can be any terminal equipment including a mobile phone, a tablet personal computer, a personal digital assistant (English full name: personal Digital Assistant, english abbreviation: PDA), a Sales terminal (English full name: point of Sales, english abbreviation: POS), a vehicle-mounted computer and the like, taking the mobile phone as an example of the terminal:
fig. 9 is a block diagram showing a part of the structure of a mobile phone related to a terminal provided in an embodiment of the present application. Referring to fig. 9, the mobile phone includes: radio Frequency (RF) circuit 1010, memory 1020, input unit 1030, display unit 1040, sensor 1050, audio circuit 1060, wireless fidelity (wireless fidelity, wiFi) module 1070, processor 1080, and power source 1090. It will be appreciated by those skilled in the art that the handset construction shown in fig. 9 is not limiting of the handset and may include more or fewer components than shown, or may combine certain components, or a different arrangement of components.
The following describes the components of the mobile phone in detail with reference to fig. 9:
the RF circuit 1010 may be used for receiving and transmitting signals during a message or a call, and particularly, after receiving downlink information of a base station, the signal is processed by the processor 1080; in addition, the data of the design uplink is sent to the base station. Generally, RF circuitry 1010 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (English full name: low Noise Amplifier, english abbreviation: LNA), a duplexer, and the like. In addition, the RF circuitry 1010 may also communicate with networks and other devices via wireless communications. The wireless communication may use any communication standard or protocol, including but not limited to global system for mobile communications (english: global System of Mobile communication, english: GSM), general packet radio service (english: general Packet Radio Service, GPRS), code division multiple access (english: code Division Multiple Access, english: CDMA), wideband code division multiple access (english: wideband Code Division Multiple Access, english: WCDMA), long term evolution (english: long Term Evolution, english: LTE), email, short message service (english: short Messaging Service, SMS), and the like.
The memory 1020 may be used to store software programs and modules that the processor 1080 performs various functional applications and data processing of the handset by executing the software programs and modules stored in the memory 1020. The memory 1020 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program (such as a sound playing function, an image playing function, etc.) required for at least one function, and the like; the storage data area may store data (such as audio data, phonebook, etc.) created according to the use of the handset, etc. In addition, memory 1020 may include high-speed random access memory and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state memory device.
The input unit 1030 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the handset. In particular, the input unit 1030 may include a touch panel 1031 and other input devices 1032. The touch panel 1031, also referred to as a touch screen, may collect touch operations thereon or thereabout by a user (e.g., operations of the user on the touch panel 1031 or thereabout using any suitable object or accessory such as a finger, stylus, etc.), and drive the corresponding connection device according to a predetermined program. Alternatively, the touch panel 1031 may include two parts, a touch detection device and a touch controller. The touch detection device detects the touch azimuth of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch detection device and converts it into touch point coordinates, which are then sent to the processor 1080 and can receive commands from the processor 1080 and execute them. Further, the touch panel 1031 may be implemented in various types such as resistive, capacitive, infrared, and surface acoustic wave. The input unit 1030 may include other input devices 1032 in addition to the touch panel 1031. In particular, other input devices 1032 may include, but are not limited to, one or more of a physical keyboard, function keys (e.g., volume control keys, switch keys, etc.), a track ball, a mouse, a joystick, etc.
The display unit 1040 may be used to display information input by a user or information provided to the user and various menus of the mobile phone. The display unit 1040 may include a display panel 1041, and alternatively, the display panel 1041 may be configured in the form of a liquid crystal display (english full name: liquid Crystal Display, acronym: LCD), an Organic Light-Emitting Diode (OLED), or the like. Further, the touch panel 1031 may overlay the display panel 1041, and when the touch panel 1031 detects a touch operation thereon or thereabout, the touch panel is transferred to the processor 1080 to determine a type of touch event, and then the processor 1080 provides a corresponding visual output on the display panel 1041 according to the type of touch event. Although in fig. 9, the touch panel 1031 and the display panel 1041 are two independent components for implementing the input and output functions of the mobile phone, in some embodiments, the touch panel 1031 and the display panel 1041 may be integrated to implement the input and output functions of the mobile phone.
The handset may also include at least one sensor 1050, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 1041 according to the brightness of ambient light, and the proximity sensor may turn off the display panel 1041 and/or the backlight when the mobile phone moves to the ear. The accelerometer sensor can be used for detecting the acceleration in all directions (generally three axes), detecting the gravity and the direction when the accelerometer sensor is static, and can be used for identifying the gesture of a mobile phone (such as transverse and vertical screen switching, related games, magnetometer gesture calibration), vibration identification related functions (such as pedometer and knocking), and other sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors which are also configured by the mobile phone are not repeated herein.
Audio circuitry 1060, a speaker 1061, and a microphone 1062 may provide an audio interface between a user and a cell phone. Audio circuit 1060 may transmit the received electrical signal after audio data conversion to speaker 1061 for conversion by speaker 1061 into an audio signal output; on the other hand, microphone 1062 converts the collected sound signals into electrical signals, which are received by audio circuit 1060 and converted into audio data, which are processed by audio data output processor 1080 for transmission to, for example, another cell phone via RF circuit 1010 or for output to memory 1020 for further processing.
WiFi belongs to a short-distance wireless transmission technology, and a mobile phone can help a user to send and receive emails, browse webpages, access streaming media and the like through a WiFi module 1070, so that wireless broadband Internet access is provided for the user. Although fig. 9 shows a WiFi module 1070, it is understood that it does not belong to the necessary constitution of the handset, and can be omitted entirely as required within the scope of not changing the essence of the invention.
Processor 1080 is the control center of the handset, connects the various parts of the entire handset using various interfaces and lines, performs various functions and processes of the handset by running or executing software programs and/or modules stored in memory 1020, and invoking data stored in memory 1020, thereby performing overall data and information collection for the handset. Optionally, processor 1080 may include one or more processing units; preferably, processor 1080 may integrate an application processor primarily handling operating systems, user interfaces, applications, etc., with a modem processor primarily handling wireless communications. It will be appreciated that the modem processor described above may not be integrated into processor 1080.
The handset further includes a power source 1090 (e.g., a battery) for powering the various components, which may preferably be logically connected to the processor 1080 by a power management system, such as to provide for managing charging, discharging, and power consumption by the power management system.
Although not shown, the mobile phone may further include a camera, a bluetooth module, etc., which will not be described herein.
In the embodiment of the present application, the processor 1080 included in the terminal further has the following functions:
extracting the text to be processed based on the entity extraction model to obtain an entity of the character type as a first candidate entity;
determining a target vocabulary from the text to be processed as a second candidate entity according to the solidification degree and the freedom degree of the vocabulary; the target vocabulary is vocabulary with the solidification degree larger than or equal to a preset solidification degree threshold value and the degree of freedom larger than or equal to a preset degree of freedom threshold value; the second candidate entity comprises an entity of a persona type;
based on the text to be processed, classifying the first candidate entity and the second candidate entity through an entity classification model to obtain a classification result, and taking a plurality of entities with the classification result being character types as target entities; the character type is a subtype of the character type;
And predicting the relation among the target entities through a relation prediction model based on the text to be processed to obtain a predicted relation among the target entities.
The embodiments of the present application further provide a computer readable storage medium storing a computer program, where the computer program when executed on a computer device causes the computer device to perform any one of the foregoing methods for acquiring a role relationship according to the foregoing embodiments.
The embodiments of the present application also provide a computer program product including a computer program, which when executed on a computer device, causes the computer device to execute any implementation of the method for acquiring a role relationship described in the foregoing embodiments.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, which are not repeated herein.
In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods may be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in each embodiment of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be embodied in essence or a part contributing to the prior art or all or part of the technical solution in the form of a software product stored in a storage medium, including several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: u disk, mobile hard disk, read-Only Memory (ROM), random access Memory (Random Access Memory, RAM), magnetic disk or optical disk, etc.
The above embodiments are only for illustrating the technical solution of the present application, and are not limiting thereof; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the corresponding technical solutions.

Claims (20)

1. The character relation acquisition method is characterized by comprising the following steps:
extracting the text to be processed based on the entity extraction model to obtain an entity of the character type as a first candidate entity;
determining a target vocabulary from the text to be processed as a second candidate entity according to the solidification degree and the freedom degree of the vocabulary; the target vocabulary is vocabulary with the solidification degree larger than or equal to a preset solidification degree threshold value and the degree of freedom larger than or equal to a preset degree of freedom threshold value; the second candidate entity comprises an entity of a persona type;
based on the text to be processed, classifying the first candidate entity and the second candidate entity through an entity classification model to obtain a classification result, and taking a plurality of entities with the classification result being character types as target entities; the character type is a subtype of the character type;
Based on the text to be processed, predicting the relation among a plurality of target entities through a relation prediction model to obtain a predicted relation among the plurality of target entities;
wherein the first candidate entity and the second candidate entity are both subordinate to the candidate entity set of the text to be processed; the entity classification model comprises a second coding module, an attention module, a composition module, a graph rolling module and a dot product module; the classifying the first candidate entity and the second candidate entity through an entity classification model based on the text to be processed to obtain a classification result comprises the following steps:
the context segments of a plurality of candidate entities in the candidate entity set in the text to be processed are respectively encoded through the second encoding module, so that context vectors of the candidate entities are obtained;
taking each candidate entity and the corresponding context vector as input of the attention module, and determining the association relationship between each candidate entity and the corresponding context vector as a first association relationship through the attention module;
processing the character type labels of the candidate entities through the composition module to obtain a label graph structure; the nodes in the label graph structure are used for representing a plurality of preset role type labels, and the edges in the label graph structure are used for representing that the plurality of role type labels are associated; the character type tag is a sub-tag of the person type tag;
The label graph structure is used as input of the graph rolling module, the graph rolling module is used for processing the label graph structure, and the association relationship among the role type labels is determined to be used as a second association relationship;
performing dot product operation on the first association relation and the second association relation through the dot product module to obtain classification results of each candidate entity; the classification result includes a character type and a non-character type.
2. The method for acquiring a role relationship according to claim 1, wherein the entity extraction model to be trained comprises a first coding module, a first prediction module, a second prediction module and a third prediction module;
the entity extraction model is obtained through training the following steps:
encoding the spliced data through the first encoding module to obtain word vectors; the spliced data are data obtained by splicing the first sample text and the description information of the entity type in the first sample text;
the word vector is used as input of a first prediction module, the first prediction module predicts the starting position information of the entity corresponding to the description information in the first sample text, and determines a first loss value corresponding to the first prediction module; and taking the word vector as input of the second prediction module, predicting end position information of an entity corresponding to the description information in the first sample text through the second prediction module, and determining a second loss value corresponding to the second prediction module;
Taking the starting position information and the ending position information as the input of a third prediction module, predicting the probability that a first text segment formed from the starting position information to the ending position information is an entity through the third prediction module, and determining a third loss value corresponding to the third prediction module;
and iteratively updating parameters of the entity extraction model to be trained based on the first loss value, the second loss value and the third loss value until the updated model meets a first training cut-off condition, and finishing training to obtain the entity extraction model.
3. The method for obtaining a character relationship according to claim 1, wherein the determining the target vocabulary from the text to be processed according to the degree of solidification and the degree of freedom of the vocabulary comprises:
splitting the text to be processed to obtain a plurality of candidate words;
determining the solidification degree of a first candidate vocabulary in the candidate vocabularies according to the occurrence frequency corresponding to a plurality of component words in the first candidate vocabulary and the common occurrence frequency of the component words; determining the degree of freedom of the first candidate vocabulary according to the left neighbor word information entropy and the right neighbor word information entropy of the first candidate vocabulary;
And determining the vocabulary with the solidification degree larger than or equal to the preset solidification degree threshold and the degree of freedom larger than or equal to the preset degree of freedom threshold from the candidate vocabularies as the target vocabulary according to the solidification degree and the degree of freedom respectively corresponding to the candidate vocabularies.
4. The method for acquiring a role relationship according to claim 1, wherein the entity classification model is obtained by training based on a sample entity, a context segment of a text in which the sample entity is located, and a role type tag of the sample entity;
the sample entity, the context fragment of the text in which the sample entity is located, and the role type tag of the sample entity are obtained by the following steps:
acquiring an entity of a role type from a second sample text as the sample entity, and acquiring the upper and lower Wen Pianduan of the sample entity in the second sample text;
and marking the role type of the sample entity to obtain the role type label.
5. The method for obtaining a role relationship according to claim 4, wherein the sample entity, a context segment of a text in which the sample entity is located, and a role type tag of the sample entity are all subordinate to a sample data set of the entity classification model;
The method further comprises the steps of:
acquiring a hotword entity; the hotword entity is a hotword for representing the entity;
generating a second text segment comprising the hotword entity based on information flow data, and acquiring a type tag of the hotword entity through a crowdsourcing platform for data labeling;
and expanding the sample data set by using the type labels of the hotword entity, the second text fragment and the hotword entity.
6. The method for acquiring a character relationship according to claim 1, wherein the relationship prediction model is obtained by training:
determining a plurality of entity pairs from the third sample text; a first entity pair of the plurality of entity pairs includes a first entity and a second entity, the first entity and the second entity being located in a same text segment of the third sample text;
for the first entity pair, inserting a first identifier before a text start position of the first entity, inserting a second identifier after a text end position of the first entity, inserting a third identifier before a text start position of the second entity, and inserting a fourth identifier after a text end position of the second entity to obtain an identification text of the first entity pair; the first identifier and the second identifier each comprise a type tag of the first entity, and the third identifier and the fourth identifier each comprise a type tag of the second entity;
The identification text is used as input of a relation prediction model to be trained, a first identifier and a third identifier are connected in the identification text through the relation prediction model to be trained to obtain a connection text, and the connection text is processed to obtain the relation between the first entity and the second entity, and the relation is used as the relation between the first entity pair;
selecting a target relationship from the relationships respectively corresponding to the entities; the target relationship is a relationship with n top confidence ranks in the relationships respectively corresponding to the entities; n is a positive integer;
updating the target relation based on the relation label corresponding to the target relation, and iteratively updating parameters of the relation prediction model to be trained based on the updated target relation until the updated model meets a second training cut-off condition, and obtaining the relation prediction model.
7. The method for obtaining a role relationship according to any one of claims 1 to 6, wherein predicting, based on the text to be processed, a relationship between a plurality of target entities by a relationship prediction model to obtain a predicted relationship between a plurality of target entities includes:
Based on the text to be processed, predicting the relation among a plurality of target entities through the relation prediction model to obtain a first relation among the plurality of target entities;
acquiring a relationship word white list and a relationship word black list corresponding to the first relationship; the relationship word whitelist includes a first relationship word positively correlated with the first relationship, the relationship word blacklist includes a second Guan Jici inversely correlated with the first relationship;
filtering text fragments which do not comprise the first related words from the text to be processed based on the related word white list; filtering text fragments comprising the second related words from the text to be processed based on the related word blacklist;
and predicting the relation among the target entities again through the relation prediction model based on the filtered text to be processed, so as to obtain a second relation among the target entities as the prediction relation.
8. The method for acquiring a role relationship according to any one of claims 1 to 6, characterized in that the method further comprises:
and constructing a role map of the text to be processed based on the predictive relation between the target entities.
9. The method of acquiring a relationship between roles according to claim 8, further comprising:
confidence degrees and/or occurrence frequencies of prediction relations among a plurality of target entities are respectively obtained;
filtering a prediction relation with confidence coefficient lower than a preset confidence coefficient threshold value and/or occurrence frequency lower than a preset frequency threshold value from the prediction relations among a plurality of target entities to obtain the filtered prediction relation;
the constructing a role atlas of the text to be processed based on the predictive relationships between the target entities, includes:
and constructing a role map of the text to be processed based on the target entities and the filtered prediction relations.
10. An apparatus for acquiring a relationship between roles, comprising:
the entity extraction module is used for extracting the text to be processed based on the entity extraction model to obtain an entity of the character type as a first candidate entity;
the target vocabulary determining module is used for determining target vocabularies from the text to be processed as second candidate entities according to the solidification degree and the freedom degree of the vocabularies; the target vocabulary is vocabulary with the solidification degree larger than or equal to a preset solidification degree threshold value and the degree of freedom larger than or equal to a preset degree of freedom threshold value; the second candidate entity comprises an entity of a persona type;
The entity classification module is used for classifying the first candidate entity and the second candidate entity through an entity classification model based on the text to be processed to obtain a classification result, and taking a plurality of entities with the classification result being character types as target entities; the character type is a subtype of the character type;
the relation prediction module is used for predicting the relation among the target entities through a relation prediction model based on the text to be processed to obtain a predicted relation among the target entities;
wherein the first candidate entity and the second candidate entity are both subordinate to the candidate entity set of the text to be processed; the entity classification model comprises a second coding module, an attention module, a composition module, a graph rolling module and a dot product module; the entity classification module comprises:
the first classifying sub-module is used for respectively encoding context fragments of a plurality of candidate entities in the candidate entity set in the text to be processed through the second encoding module to obtain context vectors of the candidate entities;
the second classification sub-module is used for taking each candidate entity and the corresponding context vector as the input of the attention module, and determining the association relationship between each candidate entity and the corresponding context vector as a first association relationship through the attention module;
The third classification sub-module is used for processing the character type labels of the candidate entities through the composition module to obtain a label graph structure; the nodes in the label graph structure are used for representing a plurality of preset role type labels, and the edges in the label graph structure are used for representing that the plurality of role type labels are associated; the character type tag is a sub-tag of the person type tag;
the fourth classification sub-module is used for taking the label graph structure as the input of the graph rolling module, processing the label graph structure through the graph rolling module and determining the association relationship among the multiple role type labels as a second association relationship;
a fifth classification sub-module, configured to perform a dot product operation on the first association relationship and the second association relationship through the dot product module, to obtain a classification result of each candidate entity; the classification result includes a character type and a non-character type.
11. The apparatus for acquiring a role relationship according to claim 10, wherein the entity extraction model to be trained includes a first encoding module, a first prediction module, a second prediction module, and a third prediction module;
The entity extraction model is obtained through training of the following modules:
the first training module is used for encoding the spliced data through the first encoding module to obtain word vectors; the spliced data are data obtained by splicing the first sample text and the description information of the entity type in the first sample text;
the second training module is used for taking the word vector as the input of the first prediction module, predicting the starting position information of the entity corresponding to the description information in the first sample text through the first prediction module, and determining a first loss value corresponding to the first prediction module; and taking the word vector as input of the second prediction module, predicting end position information of an entity corresponding to the description information in the first sample text through the second prediction module, and determining a second loss value corresponding to the second prediction module;
the third training module is used for taking the starting position information and the ending position information as the input of the third prediction module, predicting the probability that a first text segment formed from the starting position information to the ending position information is an entity through the third prediction module, and determining a third loss value corresponding to the third prediction module;
And the fourth training module is used for iteratively updating the parameters of the entity extraction model to be trained based on the first loss value, the second loss value and the third loss value until the updated model meets a first training cut-off condition, and finishing training to obtain the entity extraction model.
12. The apparatus for acquiring a relationship between roles according to claim 10, wherein the target vocabulary determining module comprises:
the first determining submodule is used for splitting the text to be processed to obtain a plurality of candidate vocabularies;
the second determining submodule is used for determining the solidification degree of a first candidate vocabulary in a plurality of candidate vocabularies according to the occurrence frequency corresponding to a plurality of component words in the first candidate vocabulary and the common occurrence frequency of a plurality of component words; determining the degree of freedom of the first candidate vocabulary according to the left neighbor word information entropy and the right neighbor word information entropy of the first candidate vocabulary;
and the third determination submodule is used for determining the vocabulary with the solidification degree larger than or equal to the preset solidification degree threshold value and the degree of freedom larger than or equal to the preset degree of freedom threshold value from the candidate vocabularies as the target vocabulary according to the solidification degree and the degree of freedom respectively corresponding to the candidate vocabularies.
13. The apparatus for acquiring a role relationship according to claim 10, wherein the entity classification model is obtained by training based on a sample entity, a context segment of a text in which the sample entity is located, and a role type tag of the sample entity;
the sample entity, the context fragment of the text in which the sample entity is located, and the role type tag of the sample entity are obtained through the following modules:
the sample acquisition module is used for acquiring an entity of a role type from a second sample text as the sample entity and acquiring the upper and lower Wen Pianduan of the sample entity in the second sample text;
and the type labeling module is used for labeling the role type of the sample entity to obtain the role type label.
14. The apparatus for acquiring a role relationship according to claim 13, wherein the sample entity, a context segment of a text in which the sample entity is located, and a role type tag of the sample entity are all subordinate to a sample data set of the entity classification model;
the apparatus further comprises:
the hotword entity acquisition module is used for acquiring hotword entities; the hotword entity is a hotword for representing the entity;
The hotword entity processing module is used for generating a second text segment comprising the hotword entity based on the information stream data and acquiring a type tag of the hotword entity through a crowdsourcing platform for data labeling;
and the sample expansion module is used for expanding the sample data set by the hotword entity, the second text fragment and the type label of the hotword entity.
15. The apparatus for acquiring a relationship between roles according to claim 10, wherein the relationship prediction model is trained by:
a fifth training module for determining a plurality of entity pairs from the third sample text; a first entity pair of the plurality of entity pairs includes a first entity and a second entity, the first entity and the second entity being located in a same text segment of the third sample text;
a sixth training module, configured to insert, for the first entity pair, a first identifier before a text start position of the first entity, a second identifier after a text end position of the first entity, and a third identifier before a text start position of the second entity, and a fourth identifier after a text end position of the second entity, to obtain an identification text of the first entity pair; the first identifier and the second identifier each comprise a type tag of the first entity, and the third identifier and the fourth identifier each comprise a type tag of the second entity;
A seventh training module, configured to use the identification text as an input of a relationship prediction model to be trained, connect a first identifier and a third identifier in the identification text through the relationship prediction model to be trained to obtain a connection text, and process the connection text to obtain a relationship between the first entity and the second entity, where the relationship is used as a relationship between the first entity pair;
the eighth training module is used for selecting a target relationship from the relationships respectively corresponding to the entities; the target relationship is a relationship with n top confidence ranks in the relationships respectively corresponding to the entities; n is a positive integer;
and a ninth training module, configured to update the target relationship based on a relationship label corresponding to the target relationship, and iteratively update parameters of the relationship prediction model to be trained based on the updated target relationship, until the updated model meets a second training deadline condition, and obtain the relationship prediction model.
16. The apparatus according to any one of claims 10 to 15, wherein the relationship prediction module includes:
the first prediction submodule is used for predicting the relation among a plurality of target entities through the relation prediction model based on the text to be processed to obtain a first relation among the plurality of target entities;
The second prediction sub-module is used for acquiring a relationship word white list and a relationship word black list corresponding to the first relationship; the relationship word whitelist includes a first relationship word positively correlated with the first relationship, the relationship word blacklist includes a second Guan Jici inversely correlated with the first relationship;
the third prediction sub-module is used for filtering text fragments which do not comprise the first relation word from the text to be processed based on the relation word white list; filtering text fragments comprising the second related words from the text to be processed based on the related word blacklist;
and the fourth prediction sub-module is used for predicting the relation among the plurality of target entities again through the relation prediction model based on the filtered text to be processed, so as to obtain a second relation among the plurality of target entities as the prediction relation.
17. The apparatus according to any one of claims 10 to 15, characterized in that the apparatus further comprises:
and the role atlas construction module is used for constructing the role atlas of the text to be processed based on the prediction relations between the target entities.
18. The apparatus for acquiring a relationship between roles according to claim 17, further comprising:
the parameter acquisition module is used for respectively acquiring confidence degrees and/or occurrence frequencies of the prediction relations among a plurality of target entities;
the filtering module is used for filtering the prediction relation with confidence coefficient lower than a preset confidence coefficient threshold value and/or occurrence frequency lower than a preset frequency threshold value from the prediction relation among the target entities to obtain the filtered prediction relation;
the role atlas construction module includes:
and the construction submodule is used for constructing the role atlas of the text to be processed based on the plurality of target entities and the filtered prediction relation.
19. A computer device, the computer device comprising a processor and a memory:
the memory is used for storing a computer program and transmitting the computer program to the processor;
the processor is configured to execute the method for acquiring a role relationship according to any one of claims 1 to 9 according to instructions in the computer program.
20. A computer-readable storage medium storing a computer program which, when executed by a character relationship acquisition device, implements the steps of the character relationship acquisition method of any one of claims 1 to 9.
CN202311313777.9A 2023-10-11 2023-10-11 Role relation acquisition method and related products Active CN117057345B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311313777.9A CN117057345B (en) 2023-10-11 2023-10-11 Role relation acquisition method and related products

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311313777.9A CN117057345B (en) 2023-10-11 2023-10-11 Role relation acquisition method and related products

Publications (2)

Publication Number Publication Date
CN117057345A CN117057345A (en) 2023-11-14
CN117057345B true CN117057345B (en) 2024-01-30

Family

ID=88664811

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311313777.9A Active CN117057345B (en) 2023-10-11 2023-10-11 Role relation acquisition method and related products

Country Status (1)

Country Link
CN (1) CN117057345B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019174422A1 (en) * 2018-03-16 2019-09-19 北京国双科技有限公司 Method for analyzing entity association relationship, and related apparatus
CN111125367A (en) * 2019-12-26 2020-05-08 华南理工大学 Multi-character relation extraction method based on multi-level attention mechanism
CN113704420A (en) * 2021-03-19 2021-11-26 腾讯科技(深圳)有限公司 Method and device for identifying role in text, electronic equipment and storage medium
CN115238092A (en) * 2022-07-21 2022-10-25 联想(北京)有限公司 Entity relationship extraction method, device, equipment and storage medium
CN115599903A (en) * 2021-07-07 2023-01-13 腾讯科技(深圳)有限公司(Cn) Object tag obtaining method and device, electronic equipment and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109165385B (en) * 2018-08-29 2022-08-09 中国人民解放军国防科技大学 Multi-triple extraction method based on entity relationship joint extraction model

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019174422A1 (en) * 2018-03-16 2019-09-19 北京国双科技有限公司 Method for analyzing entity association relationship, and related apparatus
CN111125367A (en) * 2019-12-26 2020-05-08 华南理工大学 Multi-character relation extraction method based on multi-level attention mechanism
CN113704420A (en) * 2021-03-19 2021-11-26 腾讯科技(深圳)有限公司 Method and device for identifying role in text, electronic equipment and storage medium
CN115599903A (en) * 2021-07-07 2023-01-13 腾讯科技(深圳)有限公司(Cn) Object tag obtaining method and device, electronic equipment and storage medium
CN115238092A (en) * 2022-07-21 2022-10-25 联想(北京)有限公司 Entity relationship extraction method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN117057345A (en) 2023-11-14

Similar Documents

Publication Publication Date Title
CN109145303B (en) Named entity recognition method, device, medium and equipment
KR102646667B1 (en) Methods for finding image regions, model training methods, and related devices
KR102360659B1 (en) Machine translation method, apparatus, computer device and storage medium
CN108304846B (en) Image recognition method, device and storage medium
CN111428516B (en) Information processing method and device
CN110704661B (en) Image classification method and device
CN109902296B (en) Natural language processing method, training method and data processing equipment
CN111553162A (en) Intention identification method and related device
CN111177371B (en) Classification method and related device
CN110019840B (en) Method, device and server for updating entities in knowledge graph
CN111914113A (en) Image retrieval method and related device
CN111597804B (en) Method and related device for training entity recognition model
CN113723378B (en) Model training method and device, computer equipment and storage medium
CN113821589A (en) Text label determination method and device, computer equipment and storage medium
CN113761122A (en) Event extraction method, related device, equipment and storage medium
CN112749252A (en) Text matching method based on artificial intelligence and related device
CN112328783A (en) Abstract determining method and related device
CN117057345B (en) Role relation acquisition method and related products
CN112307198B (en) Method and related device for determining abstract of single text
CN113569043A (en) Text category determination method and related device
CN113220848A (en) Automatic question answering method and device for man-machine interaction and intelligent equipment
CN113806532B (en) Training method, device, medium and equipment for metaphor sentence judgment model
CN116975295B (en) Text classification method and device and related products
CN113806533B (en) Metaphor sentence type characteristic word extraction method, metaphor sentence type characteristic word extraction device, metaphor sentence type characteristic word extraction medium and metaphor sentence type characteristic word extraction equipment
CN115905416A (en) Data processing method and related device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant