CN113935326A - Knowledge extraction method, device, equipment and storage medium - Google Patents

Knowledge extraction method, device, equipment and storage medium Download PDF

Info

Publication number
CN113935326A
CN113935326A CN202111175771.0A CN202111175771A CN113935326A CN 113935326 A CN113935326 A CN 113935326A CN 202111175771 A CN202111175771 A CN 202111175771A CN 113935326 A CN113935326 A CN 113935326A
Authority
CN
China
Prior art keywords
entity
extracted
character element
statement
target
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.)
Pending
Application number
CN202111175771.0A
Other languages
Chinese (zh)
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.)
Ecovacs Commercial Robotics Co Ltd
Original Assignee
Ecovacs Commercial Robotics 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 Ecovacs Commercial Robotics Co Ltd filed Critical Ecovacs Commercial Robotics Co Ltd
Priority to CN202111175771.0A priority Critical patent/CN113935326A/en
Publication of CN113935326A publication Critical patent/CN113935326A/en
Pending legal-status Critical Current

Links

Images

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/289Phrasal analysis, e.g. finite state techniques or chunking
    • G06F40/295Named entity recognition
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention provides a knowledge extraction method, a knowledge extraction device, knowledge extraction equipment and a storage medium, wherein the method comprises the following steps: obtaining a statement to be extracted and a plurality of attribute relations, wherein the attribute relations are used for describing the relation between different entities in the statement to be extracted; determining the relevance of the statement to be extracted and each attribute relation; determining a target attribute relation contained in the statement to be extracted in the plurality of attribute relations based on the correlation degree; inputting the target attribute relationship and the statement to be extracted into a reading understanding model, and determining an entity with the target attribute relationship in the statement to be extracted based on a result output by the reading understanding model; and outputting the entity with the target attribute relationship and the target attribute relationship. By adopting the method and the device, the entity with the target attribute relationship and the target attribute relationship can be accurately extracted from the sentence to be extracted based on the semantics of the sentence to be extracted and the attribute relationship, the flexibility of knowledge extraction is high, and the accuracy of the extraction result is high.

Description

Knowledge extraction method, device, equipment and storage medium
Technical Field
The invention relates to the technical field of artificial intelligence, in particular to a knowledge extraction method, a knowledge extraction device, knowledge extraction equipment and a storage medium.
Background
In the related technology, the attribute relationship between entities in the statement to be extracted can be extracted in a knowledge extraction mode, and a triple is output according to the extraction result, wherein the triple is composed of a first entity, a second entity and the attribute relationship between the two entities. For example, for the sentence to be extracted, where "capital of china is beijing", the triple < china, capital, beijing > may be output, where "china" is the first entity, "beijing" is the second entity, and "capital" is the attribute relationship between "china" and "beijing". The premise that the triples can be successfully extracted from the sentences to be extracted is that the sentences to be extracted need to be edited through a limited sentence pattern structure. However, in practical application, the information editing modes are various, if the sentence to be extracted is not edited according to the limited sentence pattern structure, it is difficult to extract the triple from the sentence to be extracted, and the flexibility of the knowledge extraction mode in the related technology is poor.
Disclosure of Invention
The embodiment of the invention provides a knowledge extraction method, a knowledge extraction device, knowledge extraction equipment and a storage medium, which are used for improving the flexibility of knowledge extraction.
In a first aspect, an embodiment of the present invention provides a knowledge extraction method, where the method includes:
obtaining a statement to be extracted and a plurality of attribute relations, wherein the attribute relations are used for describing the relation between different entities in the statement to be extracted;
determining the relevance of the statement to be extracted and each attribute relation;
determining a target attribute relation contained in the statement to be extracted in the plurality of attribute relations based on the correlation;
inputting the target attribute relationship and the statement to be extracted into a reading understanding model, and determining an entity with the target attribute relationship in the statement to be extracted based on a result output by the reading understanding model;
and outputting the entity with the target attribute relationship and the target attribute relationship.
In a second aspect, an embodiment of the present invention provides a knowledge extraction apparatus, including:
the system comprises an acquisition module, a judgment module and a processing module, wherein the acquisition module is used for acquiring a statement to be extracted and a plurality of attribute relations, and the attribute relations are used for describing the relation between different entities in the statement to be extracted;
the calculation module is used for determining the relevance of the statement to be extracted and each attribute relation;
a determining module, configured to determine, based on the correlation, a target attribute relationship included in the to-be-extracted statement among the plurality of attribute relationships;
the extraction module is used for inputting the target attribute relationship and the statement to be extracted into a reading understanding model, and determining an entity with the target attribute relationship in the statement to be extracted based on a result output by the reading understanding model;
and the output module is used for outputting the entity with the target attribute relationship and the target attribute relationship.
In a third aspect, an embodiment of the present invention provides an electronic device, which includes a processor and a memory, where the memory stores executable code thereon, and when the executable code is executed by the processor, the processor is enabled to implement at least the knowledge extraction method in the first aspect.
In a fourth aspect, embodiments of the present invention provide a non-transitory machine-readable storage medium having stored thereon executable code, which when executed by a processor of an electronic device, causes the processor to implement at least the knowledge extraction method of the first aspect.
By adopting the method provided by the embodiment of the invention, the relevancy of the statement to be extracted and the attribute relationship can be calculated, the target attribute relationship contained in the statement to be extracted is matched based on the relevancy, and then the entity with the target attribute relationship in the statement to be extracted is determined by reading the understanding model. By adopting the mode, even if the sentence to be extracted is not edited according to the limited sentence structure, the entity with the target attribute relation and the target attribute relation can be accurately extracted from the sentence to be extracted based on the semantics of the sentence to be extracted and the attribute relation, the flexibility of knowledge extraction is high, and the accuracy of the extraction result is high.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on the drawings without creative efforts.
FIG. 1 is a flow chart diagram of a knowledge extraction method provided by an embodiment of the invention;
FIG. 2 is a schematic diagram of a vector model training scheme according to an embodiment of the present invention;
FIG. 3 is a schematic diagram illustrating a reading understanding model according to an embodiment of the present invention;
FIG. 4 is a flow chart diagram illustration of another knowledge extraction method provided by an embodiment of the invention;
FIG. 5 is a schematic structural diagram of a knowledge extraction apparatus according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terminology used in the embodiments of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in the examples of the present invention and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise, and "a plurality" typically includes at least two.
The words "if", as used herein, may be interpreted as "at … …" or "at … …" or "in response to a determination" or "in response to a detection", depending on the context. Similarly, the phrases "if determined" or "if detected (a stated condition or event)" may be interpreted as "when determined" or "in response to a determination" or "when detected (a stated condition or event)" or "in response to a detection (a stated condition or event)", depending on the context.
In addition, the sequence of steps in each method embodiment described below is only an example and is not strictly limited.
The embodiment of the invention provides a knowledge extraction method, which can be executed in electronic equipment. The electronic equipment can comprise equipment which has voice recognition and control functions and can perform voice interaction, such as a commercial service robot, a floor sweeping robot, a floor washing machine, a kitchen robot, an intelligent sound box, an intelligent mobile phone and the like. Fig. 1 is a flowchart of a knowledge extraction method according to an embodiment of the present invention, and as shown in fig. 1, the method includes the following steps:
101. the method comprises the steps of obtaining a statement to be extracted and a plurality of attribute relations, wherein the attribute relations are used for describing the relation between different entities in the statement to be extracted.
102. And determining the relevance of the statement to be extracted and each attribute relation.
103. And determining a target attribute relation contained in the statement to be extracted in the plurality of attribute relations based on the correlation.
104. And inputting the target attribute relationship and the sentence to be extracted into the reading understanding model, and determining an entity with the target attribute relationship in the sentence to be extracted based on a result output by the reading understanding model.
105. And outputting the entity with the target attribute relationship and the target attribute relationship.
The sentence to be extracted may be composed of a plurality of entities, and the entities may be phrases. There may be connections between different entities, and connections between different entities may be described by attribute relationships. It should be noted that the statement to be extracted may include one attribute relationship, may also include a plurality of attribute relationships, and may not include any attribute relationship, and whether the statement to be extracted includes an attribute relationship or not, and which attribute relationships are specifically included in the case of including an attribute relationship may be determined by the method provided in the embodiment of the present invention. The process of extracting the entities having the attribute relationship and the attribute relationship between the entities from the sentence to be extracted may be referred to as a knowledge extraction process.
In practical application, a large number of words for describing attribute relationships, such as words of authors, addresses, nationalities, prices, and the like, may be collected in advance, and then the relevancy between the sentence to be extracted and each of the words may be calculated. If the relevance between the statement to be extracted and some attribute relations is high, the probability that the attribute relations are contained in the statement to be extracted is high, and based on the fact, the target attribute relations contained in the statement to be extracted can be determined in the attribute relations based on the relevance. By adopting the mode of matching the target attribute relationship contained in the statement to be extracted based on the relevancy from the plurality of attribute relationships, the speed of determining the target attribute relationship can be improved, the accuracy of extracting the target attribute relationship can also be improved, the relevancy matching is carried out on the statement to be extracted and the attribute relationship, and the attribute relationship implicitly contained in the statement to be extracted can be extracted from the statement to be extracted.
Optionally, the above process of calculating the relevance of the statement to be extracted and each attribute relationship may be implemented as follows: inputting the sentence to be extracted into a first machine learning model to obtain a sentence vector corresponding to the sentence to be extracted; obtaining relationship vectors corresponding to the attribute relationships respectively, wherein the relationship vectors are obtained by inputting the attribute relationships into the second machine learning model respectively in advance; and determining the distance between the statement vector and each relationship vector as the correlation degree corresponding to the statement to be extracted and each attribute relationship.
The first machine learning model is used for mapping the sentences to be extracted into sentence vectors, and the second machine learning model is used for mapping the attribute relations into relation vectors. It can be understood that the statement vector or the relationship vector can be considered as a point in the n-dimensional space, and the point have a distance therebetween, and based on this, the distance between the statement vector and the relationship vector is calculated, so that the correlation between the statement to be extracted and the corresponding attribute relationship can be obtained.
In order to improve the extraction efficiency of the knowledge extraction method provided by the embodiment of the invention, a plurality of attribute relations can be respectively input into the second machine learning model in advance, the second machine learning model outputs the corresponding relation vectors of the attribute relations, and then the relation vectors can be stored into the relation database, so that the mapped relation vectors can be directly read from the relation database when the relation vectors are used, real-time mapping is not needed, re-mapping of the relation vectors used every time is avoided, and the efficiency of knowledge extraction can be further improved.
The first and second machine learning models described above may be provided as two parts of the same machine learning model, and the overall machine learning model may be referred to as a vector model. The training process of the vector model will be described below.
The vector model can be trained by adopting a training mode of contrast learning, namely, a positive sample and a negative sample are simultaneously adopted as sample training vector models, and the data form of the training samples can be as follows: statement-attribute relationship. An example of one type of training is shown in fig. 2. Suppose that the sentences to be extracted include "wu chen author of western notes", "a company is located in youxiang No. 18", "james is from usa", "this handset is sold 9600, too expensive", and the correct attribute relations contained in these sentences to be extracted are "author", "address", "nationality" and "price" in this order. The vector model can be trained by taking the correct attribute relationship between the statement to be extracted and the contained statement as a positive sample and taking the incorrect attribute relationship between the statement to be extracted and the not contained statement as a negative sample. For example, wu chen, an author of the western script, and nationality may be combined together as a negative example. In the example shown in fig. 2, the sentence to be extracted and the attribute relationship as the positive sample are connected by a solid line, and the sentence to be extracted and the attribute relationship as the negative sample are connected by a broken line.
After the positive and negative examples are obtained, the vector model may be trained based on the positive and negative examples. In the training process, the vector model can be trained by taking the target as a training target: and the distance between the statement to be extracted with the correct corresponding relation in the positive sample and the vector corresponding to the attribute relation is small, and the distance between the statement to be extracted without the correct corresponding relation in the negative sample and the vector corresponding to the attribute relation is large. Thus, after the vector model is trained, when a sentence to be extracted is input, if the sentence to be extracted contains a certain attribute relationship, the distance between the vectors corresponding to the sentence to be extracted is small, and if the sentence to be extracted does not contain a certain attribute relationship, the distance between the vectors corresponding to the sentence to be extracted is large. Based on the above, the trained vector model can identify the relation between the statement to be extracted and some attribute relation.
By the introduced method, distances corresponding to the statement vector and the plurality of relation vectors can be calculated respectively, then, in each relation vector, a preset number of target relation vectors with the distances from the statement vector meeting a preset condition can be determined, and the attribute relation corresponding to the target relation vectors is determined as the target attribute relation contained in the statement to be extracted.
In practical application, the relation vectors may be sorted in order of decreasing distance from the statement vector, then a preset number of target relation vectors sorted in the front are selected, and the attribute relation corresponding to the target relation vectors is determined as the target attribute relation contained in the statement to be extracted.
After the target attribute relationship contained in the statement to be extracted is determined, the target attribute relationship and the statement to be extracted may be input into the reading understanding model, and the entity having the target attribute relationship in the statement to be extracted is determined based on the result output by the reading understanding model.
It should be noted that the reading understanding model may be an improved reading understanding model. For the reading understanding model, before improvement, a question and a chapter containing an answer to the question may be input into the reading understanding model, and then a start position and an end position of the answer in the chapter may be determined according to a result output by the reading understanding model. In the process of improving the reading understanding model, the reading understanding model can be improved by replacing training samples, changing the output mode of the model output layer and the like. After the improvement, as shown in fig. 3, the reading understanding model may output a result according to the sentence D to be extracted and the target attribute relationship P, and then may determine an entity having the target attribute relationship in the sentence to be extracted according to the output result. The output result may be data representing probability distribution, and specifically may represent the probability that each word element in the sentence to be extracted becomes the start word element of the first entity S, the end word element of the first entity S, the start word element of the second entity O, and the end word element of the second entity O, where the first entity and the second entity are entities having a target attribute relationship.
For example, if the author of the "western script" is wu chen, "the" making "word may be a start word of the first entity, an end word of the first entity, a start word of the second entity, or an end word of the second entity, and the" making "word actually becomes the start word of the first entity, the end word of the first entity, the start word of the second entity, or the end word of the second entity, which correspond to a certain probability, respectively, such a probability can be calculated by the reading understanding model provided in the embodiment of the present invention. After reading the output result of the understanding model, the entities having the target attribute relationship in the sentence to be extracted can be determined based on the probability that each character element in the sentence to be extracted becomes the initial character element of the first entity, the end character element of the first entity, the initial character element of the second entity and the end character element of the second entity.
Optionally, the process of determining the entity having the target attribute relationship in the sentence to be extracted based on the probability that each character element in the sentence to be extracted becomes the start character element of the first entity, the end character element of the first entity, the start character element of the second entity, and the end character element of the second entity may be implemented as follows: generating a first entity candidate set and a second entity candidate set based on characters in a statement to be extracted, wherein the first entity candidate set comprises at least one candidate entity, and the second entity candidate set comprises at least one candidate entity; based on the probability that each character in the sentence to be extracted becomes the beginning character of the first entity, the ending character of the first entity, the beginning character of the second entity and the ending character of the second entity, the first entity is determined in the first entity candidate set, and the second entity is determined in the second entity candidate set.
The candidate entities in the first entity candidate set and the candidate entities in the second entity candidate set may be the same, and an embodiment of the present invention provides a method for generating the first entity candidate set and the second entity candidate set: and for the target character element in the statement to be extracted, determining the target character element as a starting character element of a candidate entity, and sequentially determining character elements except the target character element in the statement to be extracted as ending character elements of the candidate entity to obtain a first entity candidate set and a second entity candidate set, wherein the target character element is any character element in the statement to be extracted.
For example, if the sentence "the author of the western script is wu-chen" has 10 characters, the first entity is "western script" if "west" is the beginning character of the first entity and "swim" is the ending character of the first entity; if "west" is used as the start character of the first entity and "note" is used as the end character of the first entity, then the first entity is "West-run"; if "" wander "" is used as the start character of the first entity and "" do "" is used as the end character of the first entity, then the first entity is obtained as "" wander "" is used.
The possible character combinations can be determined by the above method to obtain the first physical candidate set and the second physical candidate set. In order to improve the efficiency of knowledge extraction, the first entity candidate set and the second entity candidate set may be screened to delete character combinations having no practical significance, specifically, character combinations of a start character positioned after an end character in a sentence to be extracted may be deleted. For example, assuming that the author of the western script is wu-chen's "wu" as the initial character and "do" as the final character, it is obvious that the combination of characters in which the initial character is located after the final character is not reasonable, and such combination of characters can be filtered out.
The following describes a manner of determining a first entity in a first entity candidate set and a second entity in a second entity candidate set based on output results of the reading understanding model:
for a target candidate entity in a first entity candidate set, determining the probability that a start character element forming the target candidate entity becomes a start character element of the first entity, determining the probability that an end character element forming the target candidate entity becomes an end character element of the first entity, and calculating a first sum of the determined probabilities, wherein the target candidate entity is any one candidate entity in the first entity candidate set; for a target candidate entity in a second entity candidate set, determining the probability that a start character element forming the target candidate entity becomes a start character element of the second entity, determining the probability that an end character element forming the target candidate entity becomes an end character element of the second entity, and calculating a second sum of the determined probabilities, wherein the target candidate entity is any one candidate entity in the second entity candidate set; in the first entity candidate set, the candidate entity with the largest first sum is determined as the first entity, and in the second entity candidate set, the candidate entity with the largest second sum is determined as the second entity.
For example, the sentence to be extracted is "West Duck author" Wu Cheng ", it is assumed that" Duck "is currently used as the initial character of the first entity, and" Do "is used as the end character of the first entity, and the target candidate entity is" Duck ". The probability of "wandering" as the start character of the first entity is 0.2, the probability of "doing" as the end character of the first entity is 0.1, and the corresponding first sum of "wandering" is 0.3. As described above, the probability that each character becomes the start character or the end character of different entities can be obtained by searching the output result of the reading understanding model.
By adopting the above-described manner, a first sum corresponding to any candidate entity in the first entity candidate set and a second sum corresponding to any candidate entity in the second entity candidate set can be calculated, and then a candidate entity with the largest first sum can be determined in the first entity candidate set as the first entity, and a candidate entity with the largest second sum can be determined in the second entity candidate set as the second entity. For example, taking the first entity candidate set as an example, the calculated maximum first sum is 0.8, and the candidate entity corresponding to the maximum value of the first sum is "western note", and then it can be determined that "western note" is the first entity.
In order to improve the accuracy of knowledge extraction and avoid extracting an erroneous entity, optionally, it may be further determined whether the sentence to be extracted really includes the target attribute relationship according to an output result of the reading understanding model, if the sentence to be extracted does include the target attribute relationship, the entity having the target attribute relationship is output, and if the sentence to be extracted does not actually include the target attribute relationship, the entity is not output. The method can be specifically realized as follows: if the probability that the initial character element of the candidate entity with the maximum first sum value becomes the initial character element of the first entity is larger than a preset threshold value, and the probability that the initial character element of the candidate entity with the maximum second sum value becomes the initial character element of the second entity is larger than a preset threshold value, it is determined that the sentence to be extracted really contains the target attribute relationship, and then the entity with the target attribute relationship is output.
For example, if the sentence to be extracted is "wu-chen author" in the term of "west-run", the target attribute relationship is book-formation time, the candidate entity with the largest sum is "west-run", the initial character element thereof is "west", the probability that west "becomes the initial character element of the first entity is 0.2, the probability that west" becomes the initial character element of the first entity is less than the preset threshold value of 0.5, and the result indicates that the "wu-chen author" has no book-formation time.
The method introduced by the embodiment of the invention can extract the entity with the target attribute relationship and the target attribute relationship from the sentence to be extracted, and then can output the entity with the target attribute relationship and the target attribute relationship according to the extraction result. Optionally, the extraction result may be output in the form of a triple, where the triple may be represented as < entity a, target attribute relationship, entity B >.
Optionally, the extraction result may be labeled in a manual labeling manner, so as to label whether the extraction result is correct. In one possible implementation, the extraction results marked as correct may be stored in a knowledge database for later use. In the case of correct extraction results, other conceivable attribute relationships that are not extracted can also be supplemented into the knowledge database by human labor. Optionally, the vector model and the reading understanding model mentioned above may be trained to continuously optimize the model and enhance the system capability by using the extraction result marked as correct as a positive sample and the extraction result marked as wrong as a negative sample.
In summary, an overall flowchart of the method provided by the embodiment of the present invention is shown in fig. 4. Firstly, a sentence to be extracted can be input into a vector model, the vector model maps the sentence to be extracted into a sentence vector, then a target relation vector matched with the sentence vector is retrieved in a storage relation database, a target attribute relation corresponding to the target relation vector is determined, the target attribute relation and the sentence to be extracted are input into a reading understanding model, an entity with the target attribute relation in the sentence to be extracted is extracted based on an output result of the reading understanding model, then the extraction result can be used as knowledge 1, the correctness of the knowledge 1 is labeled in a manual labeling mode to obtain knowledge 2, and the vector model and the reading understanding model are optimized through the knowledge 2.
By adopting the method provided by the embodiment of the invention, the relevancy of the statement to be extracted and the attribute relationship can be calculated, the target attribute relationship contained in the statement to be extracted is matched based on the relevancy, and then the entity with the target attribute relationship in the statement to be extracted is determined by reading the understanding model. By adopting the mode, even if the sentence to be extracted is not edited according to the limited sentence structure, the entity with the target attribute relation and the target attribute relation can be accurately extracted from the sentence to be extracted based on the semantics of the sentence to be extracted and the attribute relation, the flexibility of knowledge extraction is high, and the accuracy of the extraction result is high.
For convenience of understanding, taking the knowledge extraction method provided by the embodiment of the present invention as an example of applying the method to a commercial service robot, a specific implementation of the knowledge extraction method provided above is exemplarily described with reference to the following application scenarios.
The commercial service robot may be a service robot placed in a public service scene, for example, a lead robot placed in a hall of a first floor of a mall, and the user 1 may chat with the lead robot, so that the following dialog may occur in an actual human-computer interaction process:
user 1: what book you like to see?
Leading the robot: i like to see "West travel records".
User 1: wu Cheng Chen completes the writing of the journey to the West.
The leading robot can obtain the ' Wuchen West journey ' written by the user 1, and extract the knowledge in the sentence to be extracted by using the ' Wuchen Wan Cheng completes the ' West journey ' written by the user as the sentence to be extracted, wherein the specific extraction process is as follows:
the method comprises the steps of inputting 'writing of' journey to West 'by Wuchen in Teng Dynasty' in Teng Dynasty into a vector model arranged in a leading robot, mapping 'writing of' journey to West 'by Wuchen in Teng Dynasty' into a sentence vector A by the vector model, and matching the sentence vector A with a relation vector stored in a relation database to obtain a target relation vector. Assuming that the first four relationship vectors closest to the sentence vector a are target relationship vectors a, b, c, d, the target attribute relationships corresponding to the target relationship vectors a, b, c, d can be determined, and the target attribute relationships corresponding to the determined target relationship vectors a, b, c, d are "original", "description", "time", and "book forming time" in sequence.
Then, the 'original crop' and 'writing of' journey to the west 'by wu chen in the world of the perpetual calendar' can be input into the reading understanding model, and the extracted first entity and second entity are 'journey to the west' and 'wu chen' in turn; inputting 'description' and 'writing of' journey to West 'by Wuchen in Ten Dynasty' into a reading understanding model, wherein the obtained candidate entity with the maximum first sum is 'West', the initial character element of the candidate entity is 'West', the probability that the 'West' becomes the initial character element of the first entity is 0.2, the probability that the 'West' becomes the initial character element of the first entity is less than a preset threshold value of 0.5, and the 'West' indicates that 'writing of' journey to West 'by Wuchen in Ten Dynasty' does not have an attribute relation of 'description', so that the first entity and the second entity extracted by 'description' of the attribute relation are empty; inputting ' time ' and ' writing of ' journey to West ' by Wuchen in the perpetual calendar into a reading understanding model, wherein the extracted first entity and second entity are ' journey to West ' and ' perpetual calendar meta-year ' in sequence; inputting the book forming time and the writing of the journey of West journey made by Wuchen in the perpetual calendar into a reading understanding model, and extracting the first entity and the second entity to be the journey of West journey and the perpetual calendar.
In the above process, the target attribute relationship and the sentence to be extracted may be separated by the separator [ SEP ] and then combined, and the combined result may be input into the reading understanding model.
The lead robot extracts entities with the original relation based on the writing of the West travel record in the Wan calendar Yuan Cheng En completion by Wu Cheng in the New year, namely the user 1: wu Cheng and West Qu, extract the entities with time or book-forming time relationship as: the West notes and the perpetual calendar of the first year. The lead robot, after extracting the knowledge, may store the extracted knowledge. The more knowledge is stored in this way, the more fluency of human-computer interaction can be improved.
Based on the above knowledge stored, the user 2 can have the following dialog with the lead robot:
and (4) a user 2: what book you like to see?
Leading the robot: i like to see "West travel records".
And (4) a user 2: i examined you for who did the "journey to the west" was written?
Leading the robot: the "journey to the West" was written by Wu Cheng En.
And finally, labeling the knowledge extraction result in a manual labeling mode, wherein the manual labeling is correct for the extraction result in the example. Optionally, the extraction result may also be supplemented manually. For example, "the journey to the west" and "wu chen" have an attribute relationship of "author" in addition to the attribute relationship of "original" extracted, and the attribute relationship of "author" may be manually supplemented.
For convenience of understanding, taking the knowledge extraction method provided by the embodiment of the present invention as an example of applying the method to a commercial service robot, a specific implementation of the knowledge extraction method provided above is exemplarily described with reference to another application scenario.
For another example, the commercial service robot may be a service robot placed at the doorway of a mall restaurant, and the user 1 may have the following dialog with the service robot:
the service robot: in the morning, before the meal was eaten or not?
User 1: has already been eaten.
The service robot: you comment on the dishes eaten today in a bar and also help I provide suggestions to other buddies.
User 1: dish 1 in restaurant A is really delicious.
After receiving the voice information input by the user, the service robot can take' dish 1 of restaurant A is really good as a sentence to be extracted to extract the knowledge therein. The service robot can input the 'dish 1 of restaurant A is really good and delicious' into the vector model, the vector model maps the 'dish 1 of restaurant A is really good and delicious' into a statement vector X, and then the statement vector X is matched with the relation vector stored in the relation database to obtain a target relation vector. Assuming that the first two relation vectors closest to the statement vector X are target relation vectors a and b, target attribute relations corresponding to the target relation vectors a and b can be determined, and the determined target attribute relations corresponding to the target relation vectors a and b are "subordinate" and "descriptive" in sequence.
Then, the subordinate items and the dish true and delicious of the restaurant A can be input into the reading understanding model, and the extracted first entity and the extracted second entity are the restaurant A and the dish 1 in sequence; inputting the description and the dish 1 of restaurant A which is really good to eat into the reading understanding model, and extracting the first entity and the second entity which are the dish 1 and the dish 1 in turn.
The service robot extracts that the entity with the subordinate relationship is the restaurant A and the dish 1 and the entity with the description relationship is the dish 1 and the good based on the fact that the user says that the dish 1 of the restaurant A is really good. After extracting the knowledge, the service robot may store the extracted knowledge. When other users make the service robot recommend restaurants in the shopping mall, dishes 1 can be actively recommended to the other users entering the shopping mall based on the stored knowledge.
For convenience of understanding, taking the knowledge extraction method provided by the embodiment of the present invention as an example of applying the method to a commercial service robot, a specific implementation of the knowledge extraction method provided above is exemplarily described with reference to another application scenario.
For another example, the commercial service robot may be a service robot placed in a hospital, and the user 1 may generate the following dialog with the service robot:
the service robot: how do you get?
User 1: i had a cold with running nose.
The service robot: drink hot water more, pay attention to rest.
After receiving the voice information input by the user, the service robot can take 'I catch a cold and get a snivel' as a sentence to be extracted to extract knowledge in the sentence. The service robot can input the 'I has a cold with a running nose' into the vector model, the vector model maps the 'I has a cold with a running nose' into a statement vector Y, and then the statement vector Y is matched with the relation vector stored in the relation database to obtain a target relation vector. Assuming that the relation vector closest to the sentence vector Y is the target relation vector a, the target attribute relation corresponding to the target relation vector a can be determined, and the target attribute relation corresponding to the determined target relation vector a is "symptom".
Then, the symptoms and the cold and running nose are input into the reading understanding model, and the extracted first entity and the second entity are the cold and the running nose in sequence.
The service robot extracts entities with symptom relationship as cold and running nose based on the fact that the user says that the user has cold and running nose. After extracting the knowledge, the service robot may store the extracted knowledge. Based on the above knowledge stored, the user 2 can have the following dialog with the lead robot:
and (4) a user 2: what symptoms are there for the cold?
The service robot: it will run a nasal discharge.
By adopting the method provided by the embodiment of the invention, the relevancy of the statement to be extracted and the attribute relationship can be calculated, the target attribute relationship contained in the statement to be extracted is matched based on the relevancy, and then the entity with the target attribute relationship in the statement to be extracted is determined by reading the understanding model. By adopting the mode, even if the sentence to be extracted is not edited according to the limited sentence structure, the entity with the target attribute relation and the target attribute relation can be accurately extracted from the sentence to be extracted based on the semantics of the sentence to be extracted and the attribute relation, the flexibility of knowledge extraction is high, and the accuracy of the extraction result is high.
The knowledge extraction apparatus of one or more embodiments of the present invention will be described in detail below. Those skilled in the art will appreciate that these knowledge extraction means can be constructed by configuring the steps taught in the present scheme using commercially available hardware components.
Fig. 5 is a schematic structural diagram of a knowledge extraction apparatus according to an embodiment of the present invention, and as shown in fig. 5, the apparatus includes:
an obtaining module 51, configured to obtain a statement to be extracted and a plurality of attribute relationships, where the attribute relationships are used to describe relationships between different entities in the statement to be extracted;
a calculating module 52, configured to determine a degree of correlation between the statement to be extracted and each attribute relationship;
a determining module 53, configured to determine, based on the correlation, a target attribute relationship included in the to-be-extracted statement among the multiple attribute relationships;
the extracting module 54 is configured to input the target attribute relationship and the sentence to be extracted into a reading understanding model, and determine an entity having the target attribute relationship in the sentence to be extracted based on a result output by the reading understanding model;
an output module 55, configured to output the entity with the target attribute relationship and the target attribute relationship.
Optionally, the calculating module 52 is configured to:
inputting the sentence to be extracted into a first machine learning model to obtain a sentence vector corresponding to the sentence to be extracted;
obtaining relationship vectors corresponding to the attribute relationships respectively, wherein the relationship vectors are obtained by inputting the attribute relationships into a second machine learning model in advance;
and determining the distance between the statement vector and each relationship vector as the correlation degree corresponding to the statement to be extracted and each attribute relationship.
Optionally, the determining module 53 is configured to:
determining a preset number of target relation vectors with the distance between the target relation vectors and the statement vectors meeting a preset condition in each relation vector;
and determining the attribute relationship corresponding to the target relationship vector as the target attribute relationship contained in the statement to be extracted.
Optionally, the extracting module 54 is configured to:
inputting the target attribute relationship and the sentence to be extracted into a reading understanding model to obtain the probability that each character element in the sentence to be extracted becomes a starting character element of a first entity, an ending character element of the first entity, a starting character element of a second entity and an ending character element of the second entity, wherein the first entity and the second entity are entities with the target attribute relationship;
and determining the entity with the target attribute relation in the statement to be extracted based on the probability that each character element in the statement to be extracted becomes the starting character element of the first entity, the ending character element of the first entity, the starting character element of the second entity and the ending character element of the second entity.
Optionally, the extracting module 54 is configured to:
generating a first entity candidate set and a second entity candidate set based on characters in the statement to be extracted, wherein the first entity candidate set comprises at least one candidate entity, and the second entity candidate set comprises at least one candidate entity;
determining the first entity in the first entity candidate set and the second entity in the second entity candidate set based on the probability that each character element in the sentence to be extracted becomes the starting character element of the first entity, the ending character element of the first entity, the starting character element of the second entity and the ending character element of the second entity.
Optionally, the extracting module 54 is configured to:
and for the target character element in the statement to be extracted, determining the target character element as a start character element of the candidate entity, and sequentially determining character elements except the target character element in the statement to be extracted as end character elements of the candidate entity to obtain a first entity candidate set and a second entity candidate set, wherein the target character element is any character element in the statement to be extracted.
Optionally, the extracting module 54 is configured to:
for a target candidate entity in the first entity candidate set, determining a probability that a start character element constituting the target candidate entity becomes a start character element of the first entity, determining a probability that an end character element constituting the target candidate entity becomes an end character element of the first entity, and calculating a first sum of the determined probabilities, wherein the target candidate entity is any one candidate entity in the first entity candidate set;
for a target candidate entity in the second entity candidate set, determining a probability that a start character element constituting the target candidate entity becomes a start character element of the second entity, determining a probability that an end character element constituting the target candidate entity becomes an end character element of the second entity, and calculating a second sum of the determined probabilities, wherein the target candidate entity is any one candidate entity in the second entity candidate set;
in the first entity candidate set, the candidate entity with the largest first sum is determined as the first entity, and in the second entity candidate set, the candidate entity with the largest second sum is determined as the second entity.
Optionally, the extracting module 54 is configured to:
if the probability that the initial character element of the candidate entity with the largest sum becomes the initial character element of the first entity is larger than a preset threshold value, and the probability that the initial character element of the candidate entity with the largest sum becomes the initial character element of the second entity is larger than the preset threshold value, determining the candidate entity with the largest sum as the first entity in the first entity candidate set, and determining the candidate entity with the largest sum as the second entity in the second entity candidate set.
The apparatus shown in fig. 5 may perform the knowledge extraction method provided in the embodiments shown in fig. 1 to fig. 4, and the detailed implementation process and technical effect are described in the embodiments, which are not described herein again.
In one possible design, the above-mentioned structure of the knowledge extracting apparatus shown in fig. 5 may be implemented as an electronic device, as shown in fig. 6, which may include: a processor 91, and a memory 92. Wherein the memory 92 has stored thereon executable code, which when executed by the processor 91, causes the processor 91 to implement at least the knowledge extraction method as provided in the previous embodiments of fig. 1 to 4.
Optionally, the electronic device may further include a communication interface 93 for communicating with other devices.
In addition, an embodiment of the present invention provides a non-transitory machine-readable storage medium having stored thereon executable code, which when executed by a processor of an electronic device, causes the processor to implement at least the knowledge extraction method provided in the foregoing embodiments of fig. 1 to 4.
The above-described apparatus embodiments are merely illustrative, wherein the units described as separate components may or may not be physically separate. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course, can also be implemented by a combination of hardware and software. With this understanding in mind, the above-described aspects and portions of the present technology which contribute substantially or in part to the prior art may be embodied in the form of a computer program product, which may be embodied on one or more computer-usable storage media having computer-usable program code embodied therein, including without limitation disk storage, CD-ROM, optical storage, and the like.
The knowledge extraction method provided in the embodiment of the present invention may be executed by a certain program/software, where the program/software may be provided by a network side, and the electronic device mentioned in the foregoing embodiment may download the program/software into a local nonvolatile storage medium, and when it needs to execute the foregoing knowledge extraction method, read the program/software into a memory by a CPU, and then execute the program/software by the CPU to implement the knowledge extraction method provided in the foregoing embodiment, and an execution process may refer to the schematic in fig. 1 to fig. 4.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (11)

1. A knowledge extraction method, comprising:
obtaining a statement to be extracted and a plurality of attribute relations, wherein the attribute relations are used for describing the relation between different entities in the statement to be extracted;
determining the relevance of the statement to be extracted and each attribute relation;
determining a target attribute relation contained in the statement to be extracted in the plurality of attribute relations based on the correlation;
inputting the target attribute relationship and the statement to be extracted into a reading understanding model, and determining an entity with the target attribute relationship in the statement to be extracted based on a result output by the reading understanding model;
and outputting the entity with the target attribute relationship and the target attribute relationship.
2. The method according to claim 1, wherein the determining the relevance of the sentence to be extracted and each attribute relation comprises:
inputting the sentence to be extracted into a first machine learning model to obtain a sentence vector corresponding to the sentence to be extracted;
obtaining relationship vectors corresponding to the attribute relationships respectively, wherein the relationship vectors are obtained by inputting the attribute relationships into a second machine learning model in advance;
and determining the distance between the statement vector and each relationship vector as the correlation degree corresponding to the statement to be extracted and each attribute relationship.
3. The method according to claim 2, wherein the determining, based on the correlation, a target attribute relationship included in the sentence to be extracted among the plurality of attribute relationships comprises:
determining a preset number of target relation vectors with the distance between the target relation vectors and the statement vectors meeting a preset condition in each relation vector;
and determining the attribute relationship corresponding to the target relationship vector as the target attribute relationship contained in the statement to be extracted.
4. The method according to claim 1, wherein the inputting the target attribute relationship and the sentence to be extracted into a reading understanding model, and determining an entity having the target attribute relationship in the sentence to be extracted based on a result output by the reading understanding model comprises:
inputting the target attribute relationship and the sentence to be extracted into a reading understanding model to obtain the probability that each character element in the sentence to be extracted becomes a starting character element of a first entity, an ending character element of the first entity, a starting character element of a second entity and an ending character element of the second entity, wherein the first entity and the second entity are entities with the target attribute relationship;
and determining the entity with the target attribute relation in the statement to be extracted based on the probability that each character element in the statement to be extracted becomes the starting character element of the first entity, the ending character element of the first entity, the starting character element of the second entity and the ending character element of the second entity.
5. The method of claim 4, wherein the determining the entity with the target attribute relationship in the sentence to be extracted based on the probability that each character element in the sentence to be extracted becomes the starting character element of the first entity, the ending character element of the first entity, the starting character element of the second entity and the ending character element of the second entity comprises:
generating a first entity candidate set and a second entity candidate set based on characters in the statement to be extracted, wherein the first entity candidate set comprises at least one candidate entity, and the second entity candidate set comprises at least one candidate entity;
determining the first entity in the first entity candidate set and the second entity in the second entity candidate set based on the probability that each character element in the sentence to be extracted becomes the starting character element of the first entity, the ending character element of the first entity, the starting character element of the second entity and the ending character element of the second entity.
6. The method of claim 5, wherein generating a first candidate set and a second candidate set based on the word element in the sentence to be extracted comprises:
and for the target character element in the statement to be extracted, determining the target character element as a start character element of the candidate entity, and sequentially determining character elements except the target character element in the statement to be extracted as end character elements of the candidate entity to obtain a first entity candidate set and a second entity candidate set, wherein the target character element is any character element in the statement to be extracted.
7. The method of claim 5, wherein the determining the first entity in the first entity candidate set and the second entity in the second entity candidate set based on the probability that each character element in the sentence to be extracted becomes a start character element of the first entity, an end character element of the first entity, a start character element of the second entity, and an end character element of the second entity comprises:
for a target candidate entity in the first entity candidate set, determining a probability that a start character element constituting the target candidate entity becomes a start character element of the first entity, determining a probability that an end character element constituting the target candidate entity becomes an end character element of the first entity, and calculating a first sum of the determined probabilities, wherein the target candidate entity is any one candidate entity in the first entity candidate set;
for a target candidate entity in the second entity candidate set, determining a probability that a start character element constituting the target candidate entity becomes a start character element of the second entity, determining a probability that an end character element constituting the target candidate entity becomes an end character element of the second entity, and calculating a second sum of the determined probabilities, wherein the target candidate entity is any one candidate entity in the second entity candidate set;
in the first entity candidate set, the candidate entity with the largest first sum is determined as the first entity, and in the second entity candidate set, the candidate entity with the largest second sum is determined as the second entity.
8. The method of claim 7, wherein determining the candidate entity with the largest first sum as the first entity in the first entity candidate set and determining the candidate entity with the largest second sum as the second entity in the second entity candidate set comprises:
if the probability that the initial character element of the candidate entity with the largest sum becomes the initial character element of the first entity is larger than a preset threshold value, and the probability that the initial character element of the candidate entity with the largest sum becomes the initial character element of the second entity is larger than the preset threshold value, determining the candidate entity with the largest sum as the first entity in the first entity candidate set, and determining the candidate entity with the largest sum as the second entity in the second entity candidate set.
9. A knowledge extraction apparatus, comprising:
the system comprises an acquisition module, a judgment module and a processing module, wherein the acquisition module is used for acquiring a statement to be extracted and a plurality of attribute relations, and the attribute relations are used for describing the relation between different entities in the statement to be extracted;
the calculation module is used for determining the relevance of the statement to be extracted and each attribute relation;
a determining module, configured to determine, based on the correlation, a target attribute relationship included in the to-be-extracted statement among the plurality of attribute relationships;
the extraction module is used for inputting the target attribute relationship and the statement to be extracted into a reading understanding model, and determining an entity with the target attribute relationship in the statement to be extracted based on a result output by the reading understanding model;
and the output module is used for outputting the entity with the target attribute relationship and the target attribute relationship.
10. An electronic device, comprising: a memory, a processor; wherein the memory has stored thereon executable code which, when executed by the processor, causes the processor to perform the knowledge extraction method of any of claims 1-8.
11. A non-transitory machine-readable storage medium having stored thereon executable code, which when executed by a processor of an electronic device, causes the processor to perform the knowledge extraction method of any of claims 1-8.
CN202111175771.0A 2021-10-09 2021-10-09 Knowledge extraction method, device, equipment and storage medium Pending CN113935326A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111175771.0A CN113935326A (en) 2021-10-09 2021-10-09 Knowledge extraction method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111175771.0A CN113935326A (en) 2021-10-09 2021-10-09 Knowledge extraction method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113935326A true CN113935326A (en) 2022-01-14

Family

ID=79278352

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111175771.0A Pending CN113935326A (en) 2021-10-09 2021-10-09 Knowledge extraction method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113935326A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116628230A (en) * 2023-07-25 2023-08-22 航天宏图信息技术股份有限公司 Method and device for expressing attribute association relationship, electronic equipment and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116628230A (en) * 2023-07-25 2023-08-22 航天宏图信息技术股份有限公司 Method and device for expressing attribute association relationship, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN109472033B (en) Method and system for extracting entity relationship in text, storage medium and electronic equipment
CN108829822B (en) Media content recommendation method and device, storage medium and electronic device
CN110019732B (en) Intelligent question answering method and related device
CN110795543A (en) Unstructured data extraction method and device based on deep learning and storage medium
CN108491486B (en) Method, device, terminal equipment and storage medium for simulating patient inquiry dialogue
CN104573130B (en) The entity resolution method and device calculated based on colony
CN110675944A (en) Triage method and device, computer equipment and medium
CN112667794A (en) Intelligent question-answer matching method and system based on twin network BERT model
CN110276023B (en) POI transition event discovery method, device, computing equipment and medium
CN112015917A (en) Data processing method and device based on knowledge graph and computer equipment
US20140351228A1 (en) Dialog system, redundant message removal method and redundant message removal program
CN113535974B (en) Diagnostic recommendation method and related device, electronic equipment and storage medium
CN109582799A (en) The determination method, apparatus and electronic equipment of knowledge sample data set
CN110580339B (en) Method and device for perfecting medical term knowledge base
WO2023207096A1 (en) Entity linking method and apparatus, device, and nonvolatile readable storage medium
CN111488468A (en) Geographic information knowledge point extraction method and device, storage medium and computer equipment
CN114595686A (en) Knowledge extraction method, and training method and device of knowledge extraction model
CN110110218A (en) A kind of Identity Association method and terminal
CN110969005B (en) Method and device for determining similarity between entity corpora
CN114969387A (en) Document author information disambiguation method and device and electronic equipment
CN113935326A (en) Knowledge extraction method, device, equipment and storage medium
CN109635004A (en) A kind of object factory providing method, device and the equipment of database
CN110287270B (en) Entity relationship mining method and equipment
CN114528851B (en) Reply sentence determination method, reply sentence determination device, electronic equipment and storage medium
CN114840642A (en) Event extraction method, device, equipment and storage medium

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