Knowledge Matching Method, Device, Equipment and Medium Incorporating Context Semantic Constraints
By extracting knowledge and splicing the input statements and matching similarity with vector records in the knowledge base, the existing entity linking method has solved the problem of low efficiency and high cost in utilizing context semantic constraints, and achieved efficient and low-cost knowledge matching effect.
Patent Information
- Application Number
- CN202110509526.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-11
- Publication Date
- 2025-06-10
- Estimated Expiration
- 2041-05-11
AI Technical Summary
When existing entity linking methods process unstructured data, it is difficult to effectively utilize context semantic constraints, resulting in low efficiency and high cost in building entity linking and query.
By extracting knowledge from the input statements, the entity vector and the relation vector are obtained, and they are spliced with the text vector to form a target vector, and similarity matches with the vector records in the knowledge base, determine the set of similar vectors, and finally select the vector with the highest similarity as the matching result.
This method does not require additional data support, avoids the steps of processing and constructing additional data, improves efficiency, reduces the time and labor costs of producing labeled data, and can effectively utilize context information to improve the accuracy and uniqueness of knowledge matching.
Smart Images

Figure CN113392182B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, in particular to a knowledge matching method, device, equipment and medium integrating context semantic constraints. Background Art
[0002] With the development of artificial intelligence, it has experienced the stages from computational intelligence to perceptual intelligence and is now moving towards the stage of cognitive intelligence. To achieve cognitive intelligence, machines must, like humans, learn to understand, reason, and interpret knowledge, which is exactly a major problem that current artificial intelligence urgently needs to solve. Currently, by combining deep learning and knowledge graph reasoning, the semantic gap of human natural language can be well solved. A knowledge graph describes the relationships between concepts, entities, and their attributes in the objective world in a structured manner, usually represented as triples, i.e., [entity 1, relationship, entity 2] or [entity, attribute, attribute value]. A knowledge graph can better organize, manage, and understand the vast amount of information on the Internet, and can transform the information on the Internet into a form closer to the human cognitive world. Therefore, it is widely used in fields such as intelligent retrieval, intelligent question answering, and personalized recommendation.
[0003] In intelligent retrieval and intelligent question answering systems based on knowledge graphs, for unstructured data, its basic tasks include: construction of knowledge graphs, information extraction (entity extraction, relationship extraction, attribute extraction), entity linking, query construction, etc. The largest existing open-source Chinese knowledge graph has a scale of 140 million, and the knowledge graph construction technology has been very mature, and the required knowledge graph can be constructed quickly. Information extraction (IE) is a text processing technology for extracting factual information such as entities, attributes, relationships, and events from natural language texts. Driven by the needs of industrial applications and academic competitions, certain achievements have also been made in Chinese information extraction. However, due to the complexity of text semantics, the difficulty of entity linking and query construction has increased. The existence of polysemous words, homographs, demonstrative pronouns, etc. makes the same entity name ambiguous and corresponds to different specific entities. For example, the entity "apple", without context, can refer to "apple (fruit)" and "apple (technology company)". How to distinguish and correctly connect to the entity is the main research problem of entity linking and querying.
[0004] Existing entity linking methods mainly include two steps, namely entity mention recognition and entity disambiguation. For mention recognition, a mention-entity dictionary needs to be constructed first. For example, the titles of entity pages, disambiguation pages, and redirect pages in an encyclopedia are extracted as entity mentions to establish the mention-entity dictionary. Constructing this dictionary requires certain time and material costs, and the construction cost increases sharply with the data scale. Entity disambiguation mainly uses methods such as ranking learning and graph models, which rely on a large amount of labeled data. In addition, querying the extracted entity-relations using query languages such as SPARQL and Cypher and similarity matching of entity-relations are also common methods for linking knowledge bases currently, but this will face the problem of multiple possibilities in query results. For example, when inputting "Who starred in 'King of Comedy'? It was her debut work" in a question-answering system, entity relation extraction can obtain ['King of Comedy','starred in', '?'], where '?' represents a placeholder. Querying in the knowledge base using the above query languages may obtain results such as ['King of Comedy','starred in', 'Stephen Chow'], ['King of Comedy','starred in', 'Karen Mok'], ['King of Comedy','starred in', 'Cecilia Cheung'], etc. The same applies to similarity matching. Since the knowledge base usually only stores triple information, the machine cannot use the context information of "debut work" for constraint, so it is difficult to obtain the correct result of ['King of Comedy','starred in', 'Cecilia Cheung']. Summary of the Invention
[0005] In view of this, embodiments of the present invention provide a knowledge matching method, device, equipment and medium that are low-cost and high-efficiency and integrate context semantic constraints.
[0006] One aspect of the present invention provides a knowledge matching method that integrates context semantic constraints, including:
[0007] Perform knowledge extraction on the obtained input statement to obtain entity vectors and relation vectors in the input statement;
[0008] Convert the input statement into a text vector;
[0009] Concatenate the entity vectors, relation vectors, and the text vector to obtain a target vector;
[0010] Perform similarity matching between the target vector and the vector records in the knowledge base to determine a set of similar vectors;
[0011] Use the vector with the highest similarity in the set of similar vectors as the matching result.
[0012] Preferably, the method further includes a step of constructing a knowledge base, and this step includes:
[0013] Train word vectors according to the original training text;
[0014] Learn the vector representations of entities and relationships in each training text in the knowledge base to obtain entity training vectors and relationship training vectors;
[0015] Perform word segmentation on the original training text, and represent the result of the word segmentation as a vector according to the trained word vectors to obtain a first vector;
[0016] Complete the construction of the knowledge base through concatenation processing of the entity training vectors, the relationship training vectors, and the first vector.
[0017] Preferably, before the step of training word vectors according to the original training text, it further includes:
[0018] Preprocess the original training text, where the preprocessing includes stop word removal and word segmentation;
[0019] The stop word removal includes: deleting the useless words in the original training text, and the useless words include at least one of the following: modal particles, adverbs, prepositions, conjunctions;
[0020] The word segmentation includes: converting the text into a word sequence separated by spaces through the jieba word segmentation tool.
[0021] Preferably, the step of representing the result of the word segmentation as a vector according to the trained word vectors to obtain a first vector includes:
[0022] After adding the trained word vectors one by one and taking the average, the first vector is obtained.
[0023] Preferably, the step of completing the construction of the knowledge base through concatenation processing of the entity training vectors, the relationship training vectors, and the first vector includes:
[0024] Construct a first triple according to the entity and the relationship, and construct a second triple according to the attributes of the entity. The first triple is [first entity, relationship, second entity], and the second triple is [entity, attribute, attribute value];
[0025] Unify the representation of the first triple and the second triple as the first vector.
[0026] Preferably, the expression form of the target vector is: p = (e p,1 , r p , 0, t p );
[0027] Among them, p is the target vector; e p,1 is the entity vector; r p is the relationship vector; t p is the text vector; 0 is related to ep,1 , r p Zero vectors of the same dimension are used as placeholder vectors for the second entity.
[0028] Preferably, the determining the set of similar vectors by performing similarity matching between the target vector and the vector records in the knowledge base includes:
[0029] Calculating the similarity between the target vector and the vector records in the knowledge base through an improved cosine similarity calculation formula, and determining the set of similar vectors according to the calculated similarity;
[0030] Wherein, the cosine similarity calculation formula is:
[0031]
[0032] Wherein, e s,1 represents the first entity vector of the knowledge base; r s represents the relationship vector of the knowledge base; e s,2 represents the second entity vector of the knowledge base; t s represents the text semantic vector of the knowledge base; β represents the weight; e p,1 represents the first entity vector to be matched; r p represents the relationship vector to be matched; t p represents the text semantic vector to be matched.
[0033] Another aspect of the embodiments of the present invention further provides a knowledge matching device integrating context semantic constraints, including:
[0034] A knowledge extraction module, configured to perform knowledge extraction on the obtained input statement to obtain the entity vector and the relationship vector in the input statement;
[0035] A conversion module, configured to convert the input statement into a text vector;
[0036] A splicing module, configured to splice the entity vector, the relationship vector, and the text vector to obtain a target vector;
[0037] A similarity matching module, configured to perform similarity matching between the target vector and the vector records in the knowledge base to determine a set of similar vectors;
[0038] A determination module, configured to use the vector with the highest similarity in the set of similar vectors as the matching result.
[0039] Another aspect of the embodiments of the present invention further provides an electronic device, including a processor and a memory;
[0040] The memory is used to store programs;
[0041] The processor executes the program to implement the method as described above.
[0042] Another aspect of the embodiments of the present invention further provides a computer-readable storage medium. The storage medium stores a program, and the program is executed by a processor to implement the method as described above.
[0043] The embodiments of the present invention also disclose a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device can read the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to enable the computer device to execute the foregoing method.
[0044] The embodiments of the present invention perform knowledge extraction on the obtained input statement to obtain an entity vector and a relationship vector in the input statement; convert the input statement into a text vector; splice the entity vector, the relationship vector, and the text vector to obtain a target vector; perform similarity matching between the target vector and the vector records in the knowledge base to determine a set of similar vectors; use the vector with the highest similarity in the set of similar vectors as the matching result. The present invention uses a similarity matching method, without the need for additional data as support in entity linking, eliminating the steps of processing and constructing additional data, improving efficiency, and reducing the time cost and labor cost of making labeled data. Description of the Drawings
[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the accompanying drawings required for the description of the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0046] Figure 1 It is the overall step flow chart of the embodiments of the present invention;
[0047] Figure 2 It is an example diagram of word vectors provided by the embodiments of the present invention;
[0048] Figure 3 It is an example diagram of knowledge matching provided by the embodiments of the present invention. Detailed Embodiments
[0049] To make the objectives, technical solutions and advantages of the present application more clear and understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0050] In view of the problems existing in the prior art, an embodiment of the present invention provides a knowledge matching method that integrates context semantic constraints, including:
[0051] Perform knowledge extraction on the obtained input statement to obtain the entity vector and relationship vector in the input statement;
[0052] Convert the input statement into a text vector;
[0053] Concatenate the entity vector, relationship vector, and the text vector to obtain a target vector;
[0054] Perform similarity matching between the target vector and the vector records in the knowledge base to determine a set of similar vectors;
[0055] Use the vector with the highest similarity in the set of similar vectors as the matching result.
[0056] Preferably, the method further includes the step of constructing a knowledge base, and this step includes:
[0057] Train word vectors according to the original training text;
[0058] Learn the vector representations of entities and relationships in each training text in the knowledge base to obtain entity training vectors and relationship training vectors;
[0059] Perform word segmentation on the original training text, and perform vector representation on the result of the word segmentation according to the trained word vectors to obtain a first vector;
[0060] Complete the construction of the knowledge base according to the concatenation processing of the entity training vector, the relationship training vector, and the first vector.
[0061] Preferably, before the step of training word vectors according to the original training text, it further includes:
[0062] Perform preprocessing on the original training text, where the preprocessing includes stop word removal processing and word segmentation processing;
[0063] The stop word removal processing includes: deleting the useless words in the original training text, and the useless words include at least one of the following: modal particles, adverbs, prepositions, conjunctions;
[0064] The word segmentation processing includes: converting the text into a word sequence separated by spaces through the jieba word segmentation tool.
[0065] Preferably, representing the result of the word segmentation processing by using the trained word vectors to obtain a first vector includes:
[0066] After adding the trained word vectors one by one and taking the average, the first vector is obtained.
[0067] Preferably, completing the construction of the knowledge base by performing splicing processing on the entity training vector, the relationship training vector, and the first vector includes:
[0068] Constructing a first triple according to the entity and the relationship, and constructing a second triple according to the attributes of the entity, where the first triple is [first entity, relationship, second entity], and the second triple is [entity, attribute, attribute value];
[0069] Representing the first triple and the second triple uniformly as the first vector.
[0070] Preferably, the expression form of the target vector is: p = (e p,1 , r p , 0, t p );
[0071] where p is the target vector; e p,1 is the entity vector; r p is the relationship vector; t p is the text vector; 0 is a zero vector with the same dimension as e p,1 , r p , and is used as the placeholder vector for the second entity.
[0072] Preferably, determining the set of similar vectors by performing similarity matching between the target vector and the vector records in the knowledge base includes:
[0073] Calculating the similarity between the target vector and the vector records in the knowledge base by using an improved cosine similarity calculation formula, and determining the set of similar vectors according to the calculated similarity;
[0074] where the cosine similarity calculation formula is:
[0075]
[0076] where e s,1 represents the first entity vector of the knowledge base; r s represents the relationship vector of the knowledge base; e s,2 represents the second entity vector of the knowledge base; t s represents the text semantic vector of the knowledge base; β represents the weight; e p,1 represents the first entity vector to be matched; r p represents the relationship vector to be matched; t p represents the text semantic vector to be matched.
[0077] The following combines the accompanying drawings of the specification to describe in detail the specific implementation manners of the embodiments of the present invention:
[0078] As Figure 1 shown, the present invention includes two stages: building a knowledge base and knowledge matching. It should be noted that the present invention is carried out on the premise of an existing knowledge graph and the text data for constructing the knowledge graph.
[0079] (1) Building a knowledge base:
[0080] Step 1): Training word vectors: Using the text data for constructing the knowledge graph (hereinafter referred to as the source text), a text representation method is used to train word vectors. Further, it is necessary to perform preprocessing such as removing stop words and word segmentation on the source text. The removal of stop words is to save space and improve processing efficiency. According to the open-source stop word list, non-content words or words without actual semantic information in the text are deleted. These words are usually modal particles, adverbs, prepositions, conjunctions, etc., and finally only the keywords are retained. The word segmentation is to use word segmentation tools such as jieba to convert the text into a word sequence separated by spaces.
[0081] Specifically, the embodiments of the present invention perform word segmentation and cleaning operations on the text corpus for building the knowledge base. The text corpus comes from the dataset of the information extraction task in the "2019 Language and Intelligence Technology Competition" jointly organized by the China Computer Federation, the China Information Processing Society of China, and Baidu Inc. First, the corpus is specially processed and divided into two parts, one is the triple dataset, and the other is the source text dataset corresponding to the triples. After removing stop words from the source text dataset and performing word segmentation using word segmentation tools such as jieba, it is input into the open-source Glove model to train 300-dimensional word vectors. The resulting word vector representation is as Figure 2 shown.
[0082] Step 2): Training knowledge graph embedding: Similar to word vectors, knowledge graph embedding technology is used to learn the vector representations of entities and relationships in the knowledge base, and finally entity vectors and relationship vectors are obtained. Further, this knowledge graph embedding does not distinguish between relationships and attributes, and between entity 2 and attribute values, that is, [entity 1, relationship, entity 2] and [entity, attribute, attribute value] are uniformly represented as [E1, R, E2].
[0083] Specifically, in the embodiment of the present invention, the open-source knowledge graph embedding Complex model is used to convert the triple dataset obtained in step 1) into a vector representation. Suppose there is a triple [King of Comedy, starring, Cecilia Cheung], and after vectorization, it is e s,1 , r, e s,2 where e s,1 , r, e s,2 are all 100-dimensional, and the triple representation is similar to a word vector.
[0084] Step 3): Obtain the source text vector: For all the words after word segmentation and stop word removal of the source text, the vector t obtained by adding the trained word vectors one by one and taking the average is used to represent the entire source text.
[0085] Specifically, in the embodiment of the present invention, it is assumed that there is a statement in the source text dataset: "Cecilia Cheung's debut work is the movie King of Comedy directed by Stephen Chow". From step 1), the word sequence "Cecilia Cheung / debut / work / Stephen Chow / direct / King of Comedy" is obtained. The word vectors of each word in this word sequence are added and then averaged to obtain a 300-dimensional vector t s to represent the source text. Thus, all triples and the corresponding source texts have been vectorized.
[0086] Step 4) Knowledge splicing: Splice the three vectors e s,1 , r, e s,2 of the triple [E1, R, E2] in the knowledge base, and splice the representation vector t s of the source text of this triple together to obtain the vector s = (e s,1 , r s , e s,2 , t s ), that is, the vector s is spliced by the four vectors e s,1 , r, e s,2 , t s along the row vector direction, and finally includes triple information and source text semantic information. The representation vector t s of the source text is obtained from step 3). Thus, the entire knowledge base is constructed.
[0087] Specifically, in the embodiment of the present invention, the triple vector obtained in step 2) and the source text vector obtained in step 3) are spliced along the row vector direction to form a record in the knowledge base. The dimension of each record is 600-dimensional. In the present invention, the entire knowledge base has a total of 340,000 records, expressed as s = (e s,1 , r s , e s,2 , t s ).
[0088] (2) Knowledge matching stage:
[0089] Step 1): Perform knowledge extraction on the input statement, that is, extract the entities and relationships in the statement, and convert the entities into vectors e according to the knowledge graph embedding obtained in step 2) of the above knowledge base construction phase p,1 It is represented that the relationship is converted into a vector r p It should be noted that the focus of the present invention is not on the knowledge extraction step, so the related technologies of knowledge extraction will not be described in detail
[0090] Specifically, in the embodiment of the present invention, knowledge extraction is performed on the questions input to the question answering system. The knowledge extraction model can refer to the participating models announced in the 2019 Language and Intelligence Technology Competition. Assume that the input question is "Who starred in 'King of Comedy', and 'King of Comedy' is her debut work", then through the knowledge extraction model, [King of Comedy, starred in,?] can be obtained, where? is a placeholder. Then, according to the knowledge graph embedding trained in step 2) of the knowledge base construction phase, the entity "King of Comedy" and the relationship "starred in" are respectively vectorized into e p,1 , r p , and? is represented by a zero vector of the same dimension
[0091] Step 2): Convert the input statement into a text vector t p , and the method adopted is step 3) of the above knowledge base construction phase
[0092] Specifically, in the embodiment of the present invention, the input statement is converted into a text vector t p : Similar to step 3) of the knowledge base construction, "Who starred in 'King of Comedy', and 'King of Comedy' is her debut work" is processed into "Who / starred in / King of Comedy / King of Comedy / she / debut / work", and after this statement is vectorized, it is t p .
[0093] Step 3): Concatenate the entity vector e p,1 , the relationship vector r p and the text vector t p obtained in step 2) into p = (e p,1 , r p , 0, t p ), where 0 is a zero vector with the same dimension as e p,1 , r p , and is used as the placeholder vector for entity 2
[0094] Specifically, the concatenated vector p = (e p,1 , r p , 0, t p ) in the embodiment of the present invention is concatenated by the four vectors e p,1 , r p , 0, t p along the row vector direction
[0095] Step 4), use the improved cosine similarity to perform similarity matching on the vector obtained in Step 3) with the records in the knowledge base. The improved cosine similarity is expressed as:
[0096]
[0097] where, is obtained by multiplying the vector s by a weight coefficient β in the source text vector t s multiplied by a weight coefficient β.
[0098] is obtained by multiplying the vector p by a weight coefficient β in the source text vector t p multiplied by a weight coefficient β.
[0099] Specifically, in the embodiment of the present invention, the similarity matching between p and each record in the knowledge base s is performed, and the matching result is as Figure 3 shown. This similarity algorithm is the improved cosine similarity, and the calculation formula is:
[0100]
[0101] where, is obtained by multiplying the vector s by a weight coefficient β in the source text vector t s multiplied by a weight coefficient β.
[0102] is obtained by multiplying the vector p by a weight coefficient β in the source text vector t p multiplied by a weight coefficient β.
[0103] The optimal value of the weight coefficient β in the present invention is 1.8.
[0104] Step 5), sort the results obtained in Step 4), and take the one with the highest similarity as the final knowledge matching result.
[0105] Compared with the prior art, the beneficial effects of the present invention are as follows;
[0106] (1) By using the similarity matching method, there is no need for additional data as support as in entity linking, eliminating the steps of processing and constructing additional data, and reducing the time cost and labor cost of making annotation data. Further, compared with the method using query language, the knowledge matching result obtained by the present invention has no ambiguity and multiple selection.
[0107] (2) Different from the existing inventions, the constraint of context information is introduced, making the output of knowledge matching tend to be unique, and the weights of triple similarity and text similarity can be dynamically adjusted, and the matching result is better.
[0108] (3) The present invention can be applied to different fields, and the difference lies in the specific steps of the research plan, with relatively high generality.
[0109] An embodiment of the present invention further provides a knowledge matching device integrating context semantic constraints, including:
[0110] A knowledge extraction module, configured to perform knowledge extraction on the obtained input statement to obtain an entity vector and a relationship vector in the input statement;
[0111] A conversion module, configured to convert the input statement into a text vector;
[0112] A splicing module, configured to splice the entity vector, the relationship vector, and the text vector to obtain a target vector;
[0113] A similarity matching module, configured to perform similarity matching between the target vector and vector records in a knowledge base to determine a set of similar vectors;
[0114] A determination module, configured to use the vector with the highest similarity in the set of similar vectors as the matching result.
[0115] On the other hand, an embodiment of the present invention further provides an electronic device, including a processor and a memory;
[0116] The memory is used to store a program;
[0117] The processor executes the program to implement the method as described above.
[0118] On the other hand, an embodiment of the present invention further provides a computer-readable storage medium, where the storage medium stores a program, and the program is executed by a processor to implement the method as described above.
[0119] An embodiment of the present invention also discloses a computer program product or a computer program, which includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device can read the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method as described above.
[0120] An embodiment of the present invention also discloses a computer program product or a computer program, which includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device can read the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method as described above.
[0121] In some alternative embodiments, the functions / operations recited in the block diagrams may not occur in the order presented in the operational illustrations. For example, depending on the functions / operations involved, two blocks shown in succession may actually be executed substantially concurrently or the blocks can sometimes be executed in the reverse order. Additionally, the embodiments presented and described in the flowcharts of the present invention are provided by way of example in order to provide a more comprehensive understanding of the technology. The disclosed methods are not limited to the operations and logical flows presented herein. Alternative embodiments are contemplated in which the order of various operations is altered and in which sub-operations described as part of a larger operation are performed independently.
[0122] Furthermore, although the present invention has been described in the context of functional modules, it should be understood that, unless otherwise stated to the contrary, one or more of the described functions and / or features may be integrated in a single physical device and / or software module, or one or more functions and / or features may be implemented in separate physical devices or software modules. It should also be understood that a detailed discussion of the actual implementation of each module is not necessary for an understanding of the present invention. Rather, given the attributes, functions, and internal relationships of the various functional modules in the devices disclosed herein, the actual implementation of the modules will be understood within the ordinary skill of an engineer. Thus, those skilled in the art will be able to implement the present invention as set forth in the claims without undue experimentation. It should also be understood that the specific concepts disclosed are merely illustrative and are not intended to limit the scope of the present invention, the scope of which is determined by the full scope of the appended claims and their equivalents.
[0123] If the described functions are implemented in the form of software functional units and sold or used as independent products, they may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence or the part that contributes to the prior art or a part of this technical solution, may be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs.
[0124] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a definitional sequence of executable instructions for implementing logical functions, which can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, a system including a processor, or other systems that can fetch and execute instructions from the instruction execution system, apparatus, or device. As used in this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device.
[0125] More specific examples (non-exhaustive list) of computer-readable media include the following: an electrical connection part (electronic device) having one or more wirings, a portable computer diskette (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium can even be paper or other suitable media on which the program can be printed, as the program can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpretation, or other suitable processing as necessary, and then stored in a computer memory.
[0126] It should be understood that various parts of the present invention can be implemented by hardware, software, firmware, or a combination thereof. In the above-described embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any one or a combination of the following techniques well known in the art can be used: discrete logic circuits having logic gate circuits for implementing logical functions on data signals, application-specific integrated circuits having appropriate combinational logic gate circuits, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0127] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples", etc. means that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0128] Although embodiments of the present invention have been shown and described, those of ordinary skill in the art can understand that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of the present invention. The scope of the present invention is defined by the claims and their equivalents.
[0129] The above is a specific description of the preferred embodiments of the present invention, but the present invention is not limited to the described embodiments. Those skilled in the art can also make various equivalent deformations or substitutions without violating the spirit of the present invention, and these equivalent deformations or substitutions are all included in the scope defined by the claims of this application.
Claims
1. A knowledge matching method integrating context semantic constraints, characterized in that, it includes: Performing knowledge extraction on the obtained input statement to obtain entity vectors and relationship vectors in the input statement; Converting the input statement into a text vector; Concatenate the entity vector, the relation vector, and the text vector to obtain a target vector, and the expression form of the target vector is: p = (e p,1 , r p , 0, t p ), where p is the target vector; e p,1 is the entity vector; r p is the relation vector; t p is the text vector; 0 is a zero vector with the same dimension as e p,1 , r p , and is used as the placeholder vector for the second entity; Constructing a knowledge base, calculating the similarity between the target vector and the vector records in the knowledge base through an improved cosine similarity calculation formula, and determining a set of similar vectors according to the calculated similarity, wherein the improved cosine similarity calculation formula contains a weight β for adjusting the relative importance of triple similarity and text similarity; Taking the vector with the highest similarity in the set of similar vectors as the matching result.
2. The knowledge matching method integrating context semantic constraints according to claim 1, characterized in that, the constructing of the knowledge base includes: Training word vectors according to the original training text; Learning the vector representations of entities and relationships in each training text in the knowledge base to obtain entity training vectors and relationship training vectors; Performing word segmentation on the original training text, and performing vector representation on the result of the word segmentation according to the trained word vectors to obtain a first vector; Completing the construction of the knowledge base through splicing processing of the entity training vector, the relationship training vector and the first vector.
3. The knowledge matching method integrating context semantic constraints according to claim 2, characterized in that, before the step of training word vectors according to the original training text, it further includes: Preprocessing the original training text, wherein the preprocessing includes stop word removal processing and word segmentation processing; The stop word removal processing includes: deleting useless words in the original training text, and the useless words include at least one of the following: modal particles, adverbs, prepositions, conjunctions; The word segmentation processing includes: converting the text into a word sequence separated by spaces through the jieba word segmentation tool.
4. The knowledge matching method integrating context semantic constraints according to claim 2, characterized in that, the performing of vector representation on the result of the word segmentation according to the trained word vectors to obtain a first vector includes: After adding the trained word vectors one by one and taking the average, obtaining the first vector.
5. The knowledge matching method integrating context semantic constraints according to claim 2, characterized in that, the completing of the construction of the knowledge base through splicing processing of the entity training vector, the relationship training vector and the first vector includes: Constructing a first triple according to the entity and the relationship, and constructing a second triple according to the attributes of the entity, the first triple being [first entity, relationship, second entity], and the second triple being [entity, attribute, attribute value]; Unifying the first triple and the second triple into the first vector.
6. The knowledge matching method integrating context semantic constraints according to claim 1, characterized in that, the cosine similarity calculation formula is: Among them, e s,1 represents the first entity vector of the knowledge base; r s represents the relationship vector of the knowledge base; e s,2 represents the second entity vector of the knowledge base; t s represents the text semantic vector of the knowledge base; β represents the weight; e p,1 represents the first entity vector to be matched; r p represents the relationship vector to be matched; t p represents the text semantic vector to be matched.
7. A knowledge matching device integrating context semantic constraints, characterized in that, it includes: A knowledge extraction module for extracting knowledge from the obtained input statement to obtain entity vectors and relationship vectors in the input statement; A conversion module for converting the input statement into a text vector; A splicing module, which is used to splice the entity vector, the relationship vector and the text vector to obtain a target vector. The expression form of the target vector is: p = (e p,1 , r p , 0, t p ), where p is the target vector; e p,1 is the entity vector; r p is the relationship vector; t p is the text vector; 0 is a zero vector with the same dimension as e p,1 , r p , which is used as the placeholder vector of the second entity; A similarity matching module for constructing a knowledge base, calculating the similarity between the target vector and the vector records in the knowledge base through an improved cosine similarity calculation formula, and determining a set of similar vectors according to the calculated similarity. The improved cosine similarity calculation formula includes a weight β for adjusting the relative importance of triple similarity and text similarity; A determination module for using the vector with the highest similarity in the set of similar vectors as the matching result.
8. An electronic device, characterized in that, it includes a processor and a memory; the memory is used for storing programs; the processor executes the program to implement the method according to any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, the storage medium stores a program, and the program is executed by a processor to implement the method according to any one of claims 1-6.
Citation Information
Patent Citations
Method and equipment for constructing intelligent question-answering system through question generation data set
CN112100351A