A physical object encoding method, device, electronic device and storage medium
By introducing the ontology knowledge of entity objects into the knowledge graph and using the co-occurrence and non-co-occurrence relationships of the tree structure, the problem of large coding errors of entity objects with a small amount of data is solved, and the accuracy of entity object coding and downstream tasks are improved. quality.
Patent Information
- Application Number
- CN202110144797.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-02
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2041-02-02
AI Technical Summary
In the knowledge graph, entity objects with a small amount of data have a small number of triples related to them, resulting in a large error in the learned entity encoding, which affects the accuracy of machine learning tasks based on the knowledge graph.
By introducing the ontology knowledge of entity objects and using the co-occurrence and non-co-occurrence relationships in the tree structure, the encoding process of entity objects is guided, so that less relevant entity objects are farther away in the encoding space and more relevant entity objects are closer, thus Improve encoding quality and accuracy.
Effectively improves the accuracy of entity object encoding, allowing each entity object in the knowledge graph to more accurately utilize the relationships pointed out by its ontology, improving the quality of downstream tasks, such as synonym mining, knowledge clustering and question and answer task performance .
Smart Images

Figure CN113609233B
Abstract
Description
Background Art
[0002] In the knowledge graph, knowledge is represented in the form of triples. Currently, various machine learning methods based on knowledge graphs need to first express the triple information in the knowledge graph as entity encoding information. Therefore, entity object encoding is very important for tasks based on knowledge graphs. In related technologies, the main method used for entity object encoding is a method based on deep learning. This method is essentially solving a deep learning task "learning the entity encoding of the knowledge graph: the input of the task is the triples in the knowledge graph, and the output of the task is the encoding of each entity object. For entity objects with a small amount of data, due to the small number of triplets related to them, the learned encoding will have a large error. Summary of the invention
[0003] Embodiments of the present application provide a physical object encoding method, device, electronic device, and storage medium to improve the accuracy of physical object encoding.
[0004] An embodiment of the present application provides a method for encoding an entity object, including:
[0005] Obtaining each entity object in the knowledge graph to be encoded, wherein the knowledge graph to be encoded includes association relationships between the entity objects;
[0006] Encode each entity object to obtain entity embedding features corresponding to each entity object, and encode each entity category of each entity object to obtain category embedding features corresponding to the entity category of each entity object, wherein the entity category of each entity object is determined by performing category semantic analysis on the corresponding entity embedding features;
[0007] The entity embedding features and the corresponding category embedding features corresponding to each entity object are fused respectively to obtain the entity encoding information corresponding to each entity object.
[0008] An embodiment of the present application provides a physical object encoding device, including:
[0009] An acquisition unit, used to acquire each entity object in the knowledge graph to be encoded, wherein the knowledge graph to be encoded includes the association relationship between the entity objects;
[0010] an encoding unit, configured to encode each of the entity objects respectively to obtain entity embedding features corresponding to each of the entity objects, and to encode the entity categories of each of the entity objects respectively to obtain category embedding features corresponding to the entity categories of each of the entity objects, wherein the entity categories of each of the entity objects are determined by performing category semantic analysis on the corresponding entity embedding features;
[0011] The fusion unit is used to fuse the entity embedding features and the corresponding category embedding features corresponding to each entity object to obtain the entity encoding information corresponding to each entity object.
[0012] Optionally, the encoding unit is specifically used for:
[0013] Inputting the knowledge graph to be encoded into a trained entity object encoding model, encoding each entity object based on the entity object embedding subnetwork in the entity object encoding model, and obtaining entity embedding features corresponding to each entity object;
[0014] The entity embedding features corresponding to the various entity objects are input into the link subnetwork in the entity object encoding model, and category semantic analysis is performed on the entity embedding features of the various entity objects based on the link subnetwork to obtain category embedding features corresponding to the entity categories of the various entity objects.
[0015] Optionally, the device further comprises a training unit, configured to obtain the entity object encoding model through training in the following manner:
[0016] According to the training samples in the training sample data set, the entity object coding model is subjected to cyclic iterative training, and when the training is completed, the trained entity object coding model is output; wherein the following operations are performed during one cyclic iterative training process:
[0017] Selecting a group of training samples from the training sample data set, the group of training samples comprising a first sample knowledge graph and a second sample knowledge graph, wherein the first sample knowledge graph and the second sample knowledge graph contain at least one pair of entity objects that are synonyms;
[0018] Inputting the first sample knowledge graph and the second sample knowledge graph into the entity object embedding subnetwork of the entity object encoding model, encoding each entity object in the first sample knowledge graph and the second sample knowledge graph based on the entity object embedding subnetwork, and obtaining entity embedding features corresponding to each entity object; and adjusting parameters of the entity object embedding subnetwork based on the predicted entity embedding features corresponding to each entity object;
[0019] The entity embedding features corresponding to the various entity objects are input into the link sub-network of the entity object encoding model; based on the link sub-network, category semantic analysis is performed on the predicted entity embedding features of the various entity objects to obtain first predicted category embedding features corresponding to the entity categories of the various entity objects; and based on the first predicted category embedding features corresponding to the entity categories of the various entity objects, parameters of the link sub-network are adjusted.
[0020] Optionally, the group of training samples further includes an entity category knowledge set, the entity category knowledge set includes entity categories of each entity object in the first sample knowledge graph and the second sample knowledge graph, and there is a hierarchical relationship between the entity categories; the entity object encoding model further includes an entity category knowledge embedding subnetwork; the training unit is further used to:
[0021] The entity category knowledge set is input into the entity category knowledge embedding subnetwork of the entity object encoding model, each entity category in the entity category knowledge set is encoded based on the entity category knowledge embedding subnetwork to obtain a second predicted category embedding feature corresponding to each entity category; and based on the second predicted category embedding feature corresponding to each entity category, the entity category knowledge embedding subnetwork is parameter adjusted.
[0022] Optionally, the entity object encoding model further includes an embedding optimization subnetwork; and the training unit is further used for:
[0023] After obtaining the second prediction category embedding features corresponding to each entity category, based on the embedding optimization sub-network, obtain the conflict probability between every two entity categories in the entity category knowledge set, and adjust the second prediction category embedding features corresponding to each two entity categories based on the conflict probability; and adjust the parameters of the embedding optimization sub-network based on the adjusted second prediction entity category embedding features; wherein the conflict probability is used to characterize the degree of category conflict between the two entity categories.
[0024] Optionally, the training unit is specifically used for:
[0025] Based on the predicted entity embedding features corresponding to the respective entity objects, determine the vector difference corresponding to the triples containing the respective entity objects, wherein the predicted entity embedding features are embedding representation vectors, and the vector difference corresponding to the triples containing the respective entity objects is the sum of the embedding representation vector of the head entity object and the relationship embedding representation vector in the triple, and the difference between the embedding representation vector of the tail entity object;
[0026] An entity object embedding loss function is constructed based on a vector difference corresponding to a first positive sample and a vector difference corresponding to a first negative sample, and parameters of the entity object embedding subnetwork are adjusted based on the entity object embedding loss function, wherein the first positive sample is a triple in the first sample knowledge graph or the second sample knowledge graph, and the first negative sample is generated by randomly replacing a head entity object or a tail entity object in the first positive sample.
[0027] Optionally, the training unit is specifically used for:
[0028] According to the hierarchical relationship between the entity categories in the entity category knowledge set, a plurality of entity category pairs are obtained, wherein each entity category pair includes a subcategory and a parent category to which the subcategory belongs;
[0029] The following operations are performed for each entity category pair: for one entity category pair of each entity category pair, a nonlinear conversion feature between a subclass in the entity category pair and a parent class to which the subclass belongs is obtained, wherein the nonlinear conversion feature is used to characterize a nonlinear conversion relationship between a second prediction category embedding feature corresponding to the subclass in the entity category pair and a second prediction category embedding feature corresponding to the parent class to which the subclass belongs;
[0030] Based on the nonlinear conversion features corresponding to the second positive sample and the nonlinear conversion features corresponding to the second negative sample, an entity category knowledge embedding loss function is constructed, and parameters of the entity category knowledge embedding subnetwork are adjusted based on the entity category knowledge embedding loss function, wherein the second positive sample is an entity category pair in the entity category knowledge set, and the second negative sample is generated by randomly replacing a subclass or a parent class in the second positive sample.
[0031] Optionally, the training unit is specifically used for:
[0032] For every two entity categories in the entity category knowledge set, the following operations are respectively performed: for two entity categories in the every two entity categories, based on the distance between the adjusted second predicted category embedding features corresponding to the two entity categories and the conflict probability corresponding to the two entity categories determined according to the category conflict matrix, a negative log-likelihood loss function is constructed;
[0033] Based on the negative log-likelihood loss function, parameters of the embedding optimization subnetwork in the entity object encoding model are adjusted so that the distance between the second prediction category embedding features corresponding to the two entity categories that are expected to conflict is greater than the distance between the second prediction category embedding features corresponding to the two entity categories that are not in conflict.
[0034] Optionally, the training unit is specifically used for:
[0035] For each entity object in the first sample knowledge graph or the second sample knowledge graph, the following operations are performed respectively: for one entity object among the entity objects, a link loss function is constructed based on an error between a first prediction category embedding feature corresponding to the one entity object and a second prediction category embedding feature corresponding to the one entity object;
[0036] Parameters of a link sub-network in the entity object encoding model are adjusted based on the link loss function.
[0037] Optionally, the entity object encoding model further includes a joint representation subnetwork, and the training unit is further used for:
[0038] Inputting entity encoding information of each entity object into the joint representation subnetwork, and marking unrecognized synonyms in the first sample knowledge graph and the second sample knowledge graph based on the joint representation subnetwork; and
[0039] Based on the synonyms of the entity object coding model tags, parameters of the entity object coding model are adjusted.
[0040] Optionally, the training unit is specifically used for:
[0041] For two entity objects that are synonyms, a joint representation loss function is constructed based on the entity encoding information of the two entity objects;
[0042] Parameters of the entity object encoding model are adjusted based on the joint representation loss function.
[0043] Optionally, the device further includes a task execution unit, configured to perform one of the following operations:
[0044] Perform synonym mining based on the entity encoding information of each entity object to determine the synonyms in the knowledge graph to be encoded;
[0045] Performing knowledge clustering based on entity encoding information of each entity object;
[0046] Path inference is performed based on the entity encoding information of each entity object to obtain the corresponding intention path, and the knowledge graph result pointed to by the intention path is used as the question and answer result.
[0047] An electronic device provided in an embodiment of the present application includes a processor and a memory, wherein the memory stores program code, and when the program code is executed by the processor, the processor executes the steps of the above-mentioned entity object encoding method.
[0048] The embodiment of the present application provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps of any one of the above-mentioned entity object encoding methods.
[0049] An embodiment of the present application provides a computer-readable storage medium, which includes a program code. When the program product is run on an electronic device, the program code is used to enable the electronic device to execute the steps of the above-mentioned entity object encoding method.
[0050] The beneficial effects of this application are as follows:
[0051] The embodiments of the present application provide an entity object encoding method, device, electronic device and storage medium. The embodiments of the present application introduce ontology knowledge of entity categories used to represent entity objects into the process of entity object encoding. Since the ontology is a tree-structured knowledge, the farther apart the nodes are in the tree, the closer the nodes are, and the less similar the nodes are. Therefore, in the embodiments of the present application, with the help of ontology knowledge, entity objects with less data are guided to overcome their errors, so that the encodings of less relevant entities are far apart in the encoding space, and the encodings of more relevant entities are close in the encoding space, so that each entity object in the knowledge graph can use the co-occurrence relationship and non-co-occurrence relationship indicated by its ontology, thereby improving the encoding quality of the entity object and improving the accuracy of the entity object encoding.
[0052] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0054] Figure 1A An optional schematic diagram of an application scenario in an embodiment of the present application;
[0055] Figure 1B A schematic diagram of a knowledge graph in an embodiment of the present application;
[0056] Figure 2 It is an optional flowchart of a method for encoding an entity object in an embodiment of the present application;
[0057] Figure 3 It is an optional flow chart of an entity object coding method implemented based on an entity object coding model in an embodiment of the present application;
[0058] Figure 4A This is a flowchart of the first downstream task execution method in an embodiment of the present application;
[0059] Figure 4B This is a flow chart of a second downstream task execution method in an embodiment of the present application;
[0060] Figure 4C This is a flowchart of a third downstream task execution method in an embodiment of the present application;
[0061] Figure 5 A simple flow chart of a method for training an entity object encoding model in an embodiment of the present application;
[0062] Fig. 6A A schematic diagram of the structure of an entity object coding model in an embodiment of the present application;
[0063] Figure 6B A schematic diagram of an entity category knowledge set in an embodiment of the present application;
[0064] Figure 7 A complete flow chart of a method for training an entity object encoding model in an embodiment of the present application;
[0065] Figure 8 A schematic diagram of the structure of a physical object encoding device in an embodiment of the present application;
[0066] Fig. 9 A schematic diagram of a hardware structure of an electronic device to which an embodiment of the present application is applied;
[0067] Fig.10 The present invention is a schematic diagram of the hardware structure of another electronic device to which the embodiments of the present application are applied. DETAILED DESCRIPTION
[0068] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the technical solution of the present application, rather than all of the embodiments. Based on the embodiments recorded in the application documents, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the technical solution of the present application.
[0069] The following is an introduction to some concepts involved in the embodiments of the present application.
[0070] Knowledge Graph (KG): It is a structured semantic knowledge base used to quickly describe concepts and their relationships in the physical world. It is composed of some interconnected entity objects (referred to as objects) and their attributes. In other words, the knowledge graph is composed of pieces of knowledge, each of which is represented by a subject-predicate-object (SPO) triple. For example: a cat is an animal. Value, cat: subject; is: predicate, a term used to describe or determine the properties, characteristics, or associations between objects; animal: object. The knowledge graph describes concepts, entity objects, and their associations in the objective world in a structured form. Technically, it stores data in the form of triples one by one. A collection of knowledge graphs is linked together to form a graph, where each node is an entity object and each edge is a relationship, or a fact.
[0071] Entity objects and association relationships: Entity objects refer to something that is distinguishable and exists independently. They are the most basic elements in the knowledge graph. Different entity objects have different association relationships. Entity objects are an abstraction and generalization of real objects. They refer to concrete things that exist objectively. They usually refer to nouns such as organizations, institutions, objects, and people that actually exist and function. The Subject and Object in the triple are both entity objects, where the Subject can also be called the head entity object and the Object can also be called the tail entity object. Association relationships are used to connect different entity objects and refer to the connection between entity objects. The nodes in the knowledge graph are connected through relationship nodes to form a large graph.
[0072] Ontology: refers to the abstract category of entity objects. In fact, it is a formal expression of a set of concepts in a specific field and their relationships. Popular understanding: Ontology defines the worldview of a knowledge system, telling us that there are people, mountains, water, water is liquid, people need to drink water, etc. in this knowledge system. In the embodiment of the present application, the ontology is a tree-structured knowledge. The farther apart the nodes are in the tree, the closer their semantics are, and the closer the nodes are, the less similar their semantics are.
[0073] Coding: Since the deep learning algorithm itself is difficult to process discrete variables, it is necessary to express discrete variables as continuous variables. This process is called encoding. The entity encoding information in the embodiment of the present application is a continuous variable obtained based on the encoding of the entity object.
[0074] Translating Embedding (TransE): is a method based on embedding representation learning, specifically refers to translating triples into embedding word vectors. Triples are in the form of (head entity object, association relationship, tail entity object), and the head entity object and the tail entity object are collectively referred to as entity objects. For simplicity, (h, r, t) is used to represent triples in the embodiments of this application.
[0075] Path coverage: refers to selecting enough test data so that every possible path of the program is executed at least once (if there is a loop in the program graph, each loop is required to be passed at least once). In the embodiment of the present application, the path is a path from a certain category to the root node determined in the ontology knowledge set based on the hierarchical relationship and transitivity between entity categories, and each node in the path represents an entity category.
[0076] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making.
[0077] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics and other technologies. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0078] Among them, machine learning (ML) is a multi-disciplinary interdisciplinary subject, involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and self-learning.
[0079] Natural language processing is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can achieve effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field will involve natural language, that is, the language people use in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question answering, knowledge graph and other technologies.
[0080] In the embodiment of the present application, when encoding the entity objects in the knowledge graph, the entity object encoding model of machine learning is adopted. The method for training the entity object encoding model proposed in the embodiment of the present application can be divided into two parts, including a training part and an application part; wherein, the training part involves the technical field of machine learning. In the training part, the entity object encoding model is trained by the machine learning technology, so that the training sample data set containing at least one first sample knowledge graph, a second sample knowledge graph and an ontology knowledge set provided in the embodiment of the present application is used to train the entity object encoding model. After the training sample passes through the entity object encoding model, the output result of the entity object encoding model is obtained, and the model parameters are continuously adjusted by the optimization algorithm in combination with the output result; the application part is used to use the entity object encoding model obtained by the training in the training part to encode each entity object in the knowledge graph to be encoded, ontology recognition, etc., and finally obtain the entity embedding features of each entity object, and the category embedding features of the entity category of each entity object, and then the entity embedding features of each entity object and the corresponding category embedding features are fused to obtain the entity encoding information corresponding to each entity object. In addition, it should be noted that the entity object encoding model in the embodiment of the present application can be either online training or offline training, which is not specifically limited here. In the embodiments of the present application, offline training is taken as an example for illustration.
[0081] The following is a brief introduction to the design concept of the embodiment of the present application:
[0082] In the knowledge graph, knowledge is represented by triples. Currently, various machine learning methods based on knowledge graphs need to first express the triple information in the knowledge graph as entity encoding information. Therefore, entity object encoding is very important for tasks based on knowledge graphs.
[0083] In the related art, in addition to the deep learning-based methods listed above, the main methods used for entity object encoding are also common methods based on probability statistics. Specifically, this method will count multiple conditional probability values between triples, for example, for a certain entity object, P(Subject|Predicate, Object), P(Predicate|Subject, Object), P(Object|Subject, Predicate) are calculated, and then these probability values are constructed as the encoding of the entity object. The encoding constructed in the above manner is relatively rigid, and it strictly depends on the conditional probability in the data set, which makes it more affected by the bias of the data set, has poor universality, and is not easy to control the vector dimension of the encoding. The encoding learned by the deep learning-based method will have a large error, which is manifested as the encoding of less relevant entity objects being too close in the encoding space, or the encoding of more relevant entity objects being too far apart in the encoding space.
[0084] In view of this, the embodiments of the present application propose an entity object encoding method, device, electronic device and storage medium. Specifically, the embodiments of the present application introduce the ontology knowledge of the entity category used to represent the entity object into the process of entity object encoding. Since the ontology is a tree-structured knowledge, the nodes that are farther apart in the tree are closer in semantics, and the nodes that are closer in semantics are less similar. Therefore, in the embodiments of the present application, with the help of ontology knowledge, entity objects with less data are guided to overcome their errors, so that the encodings of less relevant entities are far apart in the encoding space, and the encodings of more relevant entities are close in the encoding space, so that each entity object in the knowledge graph can use the co-occurrence relationship and non-co-occurrence relationship indicated by its ontology, thereby improving the encoding quality of the entity object and improving the accuracy of the entity object encoding.
[0085] The preferred embodiments of the present application are described below in conjunction with the drawings in the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application. In addition, the embodiments and features in the embodiments of the present application may be combined with each other if there is no conflict.
[0086] like Figure 1A As shown, it is a schematic diagram of an application scenario of an embodiment of the present application. The application scenario diagram includes two terminal devices 110 and a server 120. The terminal device 110 and the server 120 can communicate with each other through a communication network.
[0087] In an optional implementation, the communication network is a wired network or a wireless network. The terminal device 110 and the server 120 may be directly or indirectly connected via wired or wireless communication, which is not limited in the present application.
[0088] In the embodiment of the present application, the terminal device 110 is an electronic device used by the user, which can be a personal computer, mobile phone, tablet computer, notebook, e-book reader, etc., which has certain computing power and runs instant messaging software and websites or social software and websites. Each terminal device 110 is connected to the server 120 through a wireless network. The server 120 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and big data and artificial intelligence platforms. The terminal can be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, etc., but is not limited to this. The terminal and the server can be directly or indirectly connected by wired or wireless communication, and this application is not limited here.
[0089] Among them, the entity object coding model can be deployed on the server 120 for training, and a large number of training samples can be stored in the server 120 for training the entity object coding model. Optionally, after the entity object coding model is trained based on the training method in the embodiment of the present application, the trained entity object coding model can be directly deployed on the server 120 or the terminal device 110. Generally, the entity object coding model is directly deployed on the server 120. In the embodiment of the present application, the entity object coding model is mainly used to encode each entity object in the knowledge graph to be encoded, and obtain the entity coding information corresponding to each entity object. Furthermore, based on the entity coding information of the entity object, various knowledge graph-related downstream tasks can be performed to effectively improve the quality of downstream tasks. Common downstream tasks include: synonym mining, knowledge clustering, graph-based question and answer, etc.
[0090] The knowledge graph effectively processes, handles and integrates the data of complex documents, converting them into simple and clear triplets of "entity object-association relationship-entity object", and finally aggregates a large amount of knowledge to achieve rapid response and reasoning of knowledge.
[0091] like Figure 1B As shown, it is a schematic diagram of a knowledge graph in an embodiment of the present application. If there is a relationship between two nodes, they will be connected by an undirected edge. In this embodiment of the present application, this node is called an entity object, and the edge between them is called an association relationship in the embodiment of the present application. In other words, Figure 1BEach node in the graph is an entity object, and the edge between entity objects is the association relationship. The basic unit of the knowledge graph is the triple of "entity object-association relationship-entity object", which is also the core of the knowledge graph.
[0092] For example, Figure 1B In the above example, "country D", "city d", "x1 square kilometers" and so on are all entity objects. The association relationship is used to connect different entity objects, such as Figure 1B “Population”, “capital”, “area”, etc.
[0093] In a possible application scenario, the training samples in this application can be stored using cloud storage technology. Cloud storage is a new concept that extends and develops from the concept of cloud computing. A distributed cloud storage system (hereinafter referred to as a storage system) refers to a storage system that uses cluster applications, grid technology, and distributed storage file systems to bring together a large number of different types of storage devices (storage devices are also called storage nodes) in the network through application software or application interfaces to work together and provide external data storage and business access functions.
[0094] In a possible application scenario, in order to reduce communication latency, servers 120 may be deployed in various regions, or different servers 120 may serve the regions corresponding to the terminal devices 10 for load balancing. Multiple servers 120 can share data through blockchain, and multiple servers 120 are equivalent to a data sharing system composed of multiple servers 120. For example, the terminal device 110 is located at location a and is in communication connection with the server 120, and the terminal device 110 is located at location b and is in communication connection with other servers 120.
[0095] Each server 120 in the data sharing system has a node identifier corresponding to the server 120. Each server 120 in the data sharing system can store the node identifiers of other servers 120 in the data sharing system, so that the generated blocks can be broadcast to other servers 120 in the data sharing system according to the node identifiers of other servers 120. Each server 120 can maintain a node identifier list as shown in the following table, and store the server 120 name and the node identifier in the node identifier list. Among them, the node identifier can be the Internet Protocol (IP) address of the interconnection protocol between networks and any other information that can be used to identify the node. Table 1 only takes the IP address as an example for explanation.
[0096] Table 1
[0097] Server Name Node ID Node 1 119.115.151.174 Node 2 118.116.189.145 … … Node N 119.124.789.258
[0098] The object trajectory recognition method provided by the exemplary embodiment of the present application is described below in combination with the application scenarios described above and with reference to the accompanying drawings. It should be noted that the above application scenarios are only shown to facilitate understanding of the spirit and principles of the present application, and the implementation of the present application is not limited in this respect.
[0099] See also Figure 2 As shown, it is an implementation flow chart of an entity object encoding method provided in an embodiment of the present application. The specific implementation process of the method is as follows:
[0100] S21: Obtain each entity object in the knowledge graph to be encoded, wherein the knowledge graph to be encoded includes the association relationship between each entity object;
[0101] The Subject and Object in the triple are both entity objects, where Subject is the head entity, which can be represented by h in the embodiment of the present application, and Object is the tail entity, which can be represented by t. Predicate is used to represent the association relationship between h and t, which can be represented by r. For example, common association relationships include parent-child relationship, husband-wife relationship, employment relationship, position relationship, etc.
[0102] For example: Building A is located in City B. Here, h is Building A, t is City B, and the relationship between them is expressed as located in, that is, the location relationship.
[0103] S22: respectively encoding each entity object to obtain entity embedding features corresponding to each entity object, and respectively encoding the entity category of each entity object to obtain category embedding features corresponding to the entity category of each entity object, wherein the entity category of each entity object is determined by performing category semantic analysis on the corresponding entity embedding features;
[0104] In the embodiment of the present application, the entity category can also be called ontology, which refers to the abstract category of the entity object. For example, for the entity object of pencil, it belongs to stationery, that is, the entity category of pencil is stationery.
[0105] S23: Fuse the entity embedding features and the corresponding category embedding features corresponding to each entity object respectively to obtain the entity encoding information corresponding to each entity object.
[0106] Specifically, when the entity embedding features and the category embedding features are fused, common fusion methods include: feature vector concatenation, dot product, weighted summation, etc., which are not specifically limited here.
[0107] In the above implementation, the ontology knowledge of the entity category used to represent the entity object is introduced into the process of entity object encoding. Since the ontology is a tree-structured knowledge, the farther apart the nodes are in the tree, the closer their semantics are, and the closer the nodes are, the less similar their semantics are. Therefore, in the embodiment of the present application, with the help of ontology knowledge, entity objects with less data are guided to overcome their errors, so that the encodings of less relevant entities are far apart in the encoding space, and the encodings of more relevant entities are close in the encoding space, so that each entity object in the knowledge graph can use the co-occurrence relationship and non-co-occurrence relationship indicated by its ontology, thereby improving the encoding quality of the entity object and improving the accuracy of the entity object encoding.
[0108] It should be noted that the method in the embodiment of the present application can also be implemented based on a machine learning model, such as the entity object coding model in the embodiment of the present application. Figure 3 The flowchart shown implements step S22, comprising the following steps:
[0109] S301: Input the knowledge graph to be encoded into the trained entity object encoding model, encode each entity object based on the entity object embedding subnetwork in the entity object encoding model, and obtain the entity embedding features corresponding to each entity object;
[0110] Among them, the entity embedding subnetwork is mainly used to encode entity objects. For example, the subnetwork can adopt a TransE network or other models, such as an MTransE network, which is not specifically limited here.
[0111] Taking the TransE network as an example, the process of encoding each entity object means: translating the entity object into an embedding word vector and using the embedding word vector as the entity embedding feature.
[0112] S302: Input the entity embedding features corresponding to each entity object into the link sub-network in the entity object encoding model, perform category semantic analysis on the entity embedding features of each entity object based on the link sub-network, and obtain the category embedding features corresponding to the entity category of each entity object.
[0113] In an embodiment of the present application, the input of the link subnetwork module is the vector representation of the entity object, that is, the embedding word vector obtained based on step S301, and the output is the vector representation of the entity corresponding to the entity object, that is, the category embedding feature corresponding to the entity category of the entity object.
[0114] It should be noted that the entity object encoding method proposed in the embodiment of the present application can effectively improve the quality of downstream tasks after being applied to downstream tasks. Common downstream tasks include: synonym mining, knowledge clustering, graph-based question answering, etc. That is, after step S23, step S24 can also be performed, which specifically includes one of the following operations:
[0115] (I) After step S23, when the synonym mining task is performed, the specific process is as follows: Figure 4A As shown:
[0116] In step S24: Synonym mining is performed based on the entity encoding information of each entity object to determine the synonyms in the knowledge graph to be encoded.
[0117] In the synonym mining task, the possibility of two words being synonyms is mainly determined by comparing the distance between two word vectors in the coding space. In an embodiment of the present application, the entity coding information (representable by word vectors) obtained based on steps S21 to S23 is used to replace the word vectors originally obtained by random initialization or using a pre-trained model in the synonym mining task. Furthermore, in S24, by comparing the distance between the entity coding information corresponding to the two entity objects in the coding space, the probability that the two entity objects are synonyms is obtained, and the synonyms in the knowledge graph to be encoded are determined based on the determined probability.
[0118] In the above implementation, after using the word vector of the embodiment of the present application, the encoding of each synonym can be made more compact in the encoding space, and the encoding distance between different word meanings is farther, which improves the accuracy of mining. From the perspective of application scenarios, the synonym mining technology listed above can be applied to application scenarios such as knowledge graph construction, terminology standardization, public opinion monitoring, etc., which are not specifically limited in the embodiments of the present application.
[0119] (ii) After step S23, when the knowledge clustering task is performed, the specific process is as follows: Figure 4B As shown:
[0120] In step S24: knowledge clustering is performed based on the entity encoding information of each entity object.
[0121] In the knowledge clustering task, it is mainly necessary to vectorize each knowledge expression, and then use a series of methods to classify knowledge with specific characteristics into the same category. Similarly, in the embodiment of the present application, the knowledge encoding (i.e., entity encoding information) obtained based on steps S21 to S23 is used to replace the knowledge vector obtained by random initialization or pre-training model in the original knowledge clustering task. Furthermore, in S24, a series of methods are used to classify knowledge with specific characteristics into the same category.
[0122] In the above implementation, after using the knowledge encoding of the embodiment of the present application, there can be a clearer classification boundary, so the clustering error rate is lower. From the perspective of application scenarios, the above-listed knowledge clustering technology can be applied to application scenarios such as medical big data analysis, institutional insurance fraud analysis, and identification of high-risk groups for diseases.
[0123] (III) After step S23, when executing the graph-based question-answering task, the specific process is as follows: Figure 4C As shown:
[0124] In step S24: path inference is performed based on the entity encoding information of each entity object to obtain the corresponding intention path, and the knowledge graph result pointed to by the intention path is used as the question and answer result.
[0125] In the graph-based question-answering task, the entity encoding information obtained by the method of the embodiment of the present application is also used to replace the original entity object encoding, and then the subsequent graph-based question-answering process is performed.
[0126] In the above implementation, after using the entity coding information of the embodiment of the present application, the coding of scarce entity objects is improved, so that there is a significant performance improvement on long-tail problems. From the perspective of application scenarios, the graph-based question-answering technology can be applied to: automatic question-answering for patient consultation, intelligent medical guidance, irrational medication and other application scenario capabilities.
[0127] For example, in the application scenario of automatic question-answering for patient consultation, the knowledge graph entity objects may include words related to diseases, symptoms, parts, patients, diagnostic items, medical departments, doctors, hospitals, treatment, diet, and exercise, etc.; the associations between entity objects include but are not limited to: diseases, symptoms, parts, and patients belong to the relationship of determining the condition, diagnostic items, medical departments, doctors, hospitals, and treatment belong to the relationship of diagnosis and treatment, and treatment, diet, and exercise belong to the relationship of daily care. Correspondingly, the entity categories of entity objects include: disease name, disease introduction, cause, treatment method, treatment probability, preventive measures, cure probability, susceptible population, and daily care, etc.
[0128] In the automatic question-answering system, the question sentences raised by the user are firstly processed by word segmentation and stop word removal; then the key entity objects in the question are identified by combining with the local entity object dictionary. Then, the identified key entity objects are encoded using the method in the embodiment of the present application to obtain the corresponding entity encoding information. Then, path inference is performed based on the entity encoding information to obtain the corresponding intent path, and the knowledge graph result pointed to by the intent path is used as the question-answering result.
[0129] For example, in the application scenario of intelligent medical guidance, a symptom-disease-department knowledge graph can be constructed. The nodes in the knowledge graph are disease words and symptom words related to the concepts of diseases and symptoms extracted from the medical encyclopedia website. Then, the "disease-symptom" association relationship between the disease node and the disease keyword is established through the symptom-related words appearing on the medical encyclopedia website, and the "disease-department" association relationship is established through the department corresponding to the disease in the clinical medical data, and so on.
[0130] Among them, the entity category of the entity object includes gender and age group, etc. For example, the age attribute of "Children's Cold" is "Children", etc. The purpose of this entity category is to filter and integrate the patient's gender and age information. In the embodiment of the present application, the user's symptom description information can be collected, and based on the symptom-disease-department knowledge graph, the symptoms and disease words in the patient's chief complaint can be identified, and then the entity coding information is obtained based on the entity object coding method in the embodiment of the present application. The entity coding information integrates the patient's gender and age group information, and then the hospital and department that the patient should register for are obtained through the intelligent guidance algorithm, realizing simple and efficient intelligent guidance.
[0131] It should be noted that the several specific implementation methods combined with the application scenarios listed above are only examples. In addition, other application scenarios related to question-answering technology based on knowledge graphs, or application scenarios related to knowledge clustering, synonym mining and other technologies are also applicable and will not be listed one by one here.
[0132] See Table 2, which shows the effects of the method in the embodiment of the present application on the several downstream tasks listed above:
[0133] Table 2
[0134]
[0135] Obviously, the encoding quality of the entity encoding information obtained based on the method in the embodiment of the present application is higher, and on this basis, the accuracy of task execution can be improved.
[0136] It should be noted that the entity object coding model listed above includes an entity object embedding subnetwork and a link subnetwork. When training the entity object coding model, it is necessary to perform cyclic iterative training on the entity object coding model according to the training samples in the training sample data set, and output the trained entity object coding model when the training is completed; wherein the condition for the completion of training may be that the entity object coding model converges, or the number of cyclic iterations reaches a certain upper limit, etc., which is not specifically limited here.
[0137] Specifically, the following operations need to be performed during a cycle of iterative training, see Figure 5 As shown:
[0138] S501: Select a group of training samples from a training sample data set, where the group of training samples includes a first sample knowledge graph and a second sample knowledge graph, wherein the first sample knowledge graph and the second sample knowledge graph contain at least one pair of entity objects that are synonyms;
[0139] For example, a knowledge graph can be defined as G = (E, R, T), where E, R, and T are the entity set, relationship set, and triple set of the KG, respectively. Each triple contains a head entity h, a relationship r, and a tail entity t. The bold h, r, and t correspond to the embedded features (also called embedded representations) of h, r, and t, respectively.
[0140] Then, for the first sample knowledge graph G i =(E i , R i , T i ), and the second sample knowledge graph G j =(E j , R j , T j ). These two KGs contain a certain number of synonym seeds, where the synonym seeds can be expressed as
[0141] Specifically, the first sample knowledge graph and the second sample knowledge graph can be knowledge graphs in different languages for the same knowledge. For example, the first sample knowledge graph is a Chinese knowledge graph, and the second sample knowledge graph is an English knowledge graph. In this case, it can also be considered that the two KGs contain a certain number of synonym seeds. In addition, the first sample knowledge graph and the second sample knowledge graph can also be knowledge graphs in the same language for different knowledge, and the two KGs contain a certain number of synonym seeds, etc., which are not specifically limited here.
[0142] S502: Input the first sample knowledge graph and the second sample knowledge graph into the entity object embedding subnetwork of the entity object encoding model, encode each entity object in the first sample knowledge graph and the second sample knowledge graph based on the entity object embedding subnetwork, and obtain entity embedding features corresponding to each entity object; and adjust parameters of the entity object embedding subnetwork based on the predicted entity embedding features corresponding to each entity object;
[0143] S503: Input the entity embedding features corresponding to each entity object into the link sub-network of the entity object encoding model, perform category semantic analysis on the predicted entity embedding features of each entity object based on the link sub-network, and obtain the first predicted category embedding features corresponding to the entity category of each entity object; and adjust the parameters of the link sub-network based on the first predicted category embedding features corresponding to the entity category of each entity object.
[0144] For example, during the training process, two different knowledge graphs are needed. For example, there are 10,000 nodes in graph A (i.e., the first sample knowledge graph) and 1,000 nodes in graph B (i.e., the second sample knowledge graph). Some nodes between graph A and graph B can correspond to each other. If there are 500 correspondences in total, 50 of them are marked as synonyms. These 50 nodes are synonym seeds, and the corresponding relationship between the remaining 450 nodes can be learned through the training model. In the application process of the model, you only need to input a knowledge graph, and by analyzing the category semantic information of each entity object in the knowledge graph, determine the corresponding entity category, and finally fuse the entity embedding features and the category embedding features to obtain the entity encoding information of the entity object.
[0145] See also Fig. 6A As shown, it is a schematic diagram of the structure of an entity object coding model in an embodiment of the present application. Fig. 6A In the model shown, in addition to the entity object embedding subnetwork and link subnetwork listed above, it can also include entity category knowledge embedding subnetwork, embedding optimization subnetwork, and joint representation subnetwork. Among them, the entity object embedding subnetwork is mainly used to extract the knowledge in KG (knowledge graph); the entity category knowledge embedding subnetwork is mainly used to vectorize the ontology knowledge; the embedding optimization subnetwork is mainly used to optimize the vectorized expression of the ontology knowledge; the link subnetwork is mainly used to integrate the knowledge in KG and ontology knowledge; the joint representation subnetwork is mainly used to combine the knowledge information obtained by the link subnetwork with specific downstream tasks.
[0146] In addition, it should be noted that Fig. 6A The "downstream task" module in the gray part does not belong to the entity object encoding model. Each downstream task has independent processing logic. In the embodiment of the present application, the algorithm in the embodiment of the present application can be combined with each downstream task through the "joint representation subnetwork" to improve the effect of the method in the embodiment of the present application on downstream tasks.
[0147] In an optional implementation, the training samples in the training sample data set include at least one first sample knowledge graph and at least one second sample knowledge graph listed above, and also include at least one entity category knowledge set (also called ontology knowledge set), the entity category knowledge set includes the entity categories of each entity object in the first sample knowledge graph and the second sample knowledge graph, and there is a hierarchical relationship between the entity categories. That is, in addition to the two KGs at the entity layer, the embodiment of the present application also introduces an ontology knowledge set G o =(E o , R o , T o), defines the hierarchical relationship between entity categories, and the connection between entities and ontology knowledge can be expressed as: M = {(e, c)|e∈{KG i , KG j},c∈E o}, which is equivalent to a newly added triple, which defines the entity category corresponding to each entity in the entity layer in the ontology knowledge.
[0148] The following is a detailed introduction to each sub-network:
[0149] For the entity object embedding subnetwork, the subnetwork can use the TransE network, MTransE network, etc. Since the subnetwork is mainly used to extract the knowledge in the KG, when adjusting the parameters of the entity object embedding subnetwork based on the predicted entity embedding features corresponding to each entity object, the main process is as follows:
[0150] Based on the predicted entity embedding features corresponding to each entity object, determine the vector difference corresponding to the triple containing each entity object, wherein the predicted entity embedding features are embedding representation vectors, and the vector difference corresponding to the triple containing each entity object is the sum of the embedding representation vector of the head entity object and the relationship embedding representation vector in the triple, and the difference between the embedding representation vector of the tail entity object;
[0151] An entity object embedding loss function is constructed based on the vector difference corresponding to the first positive sample and the vector difference corresponding to the first negative sample, and parameters of the entity object embedding subnetwork are adjusted based on the entity object embedding loss function, wherein the first positive sample is a triple in the first sample knowledge graph or the second sample knowledge graph, and the first negative sample is generated by randomly replacing the head entity object or the tail entity object in the first positive sample.
[0152] For example, for KG, and T′ o , TransE encoding is used to obtain entity embedding features, specifically including the head entity object embedding representation vector h, and the tail entity object embedding representation vector t. In addition, r represents the relationship embedding representation vector. The vector difference in the embodiment of the present application is h+rt. The rationality of the embedding representation can be measured according to the following scoring function:
[0153] f E (h, r, t) = ||h + rt||2;
[0154] In the embodiment of the present application, the following limit-based loss is used to calculate the entity object embedding loss function, and the entity object embedding sub-network is optimized. The calculation formula is as follows:
[0155]
[0156] Where [x] + =max(0,x); γ1, γ2 are hyperparameters, which are used to control the distance between the first positive sample and the first negative sample respectively; α is a hyperparameter for balancing the ratio of the first positive sample and the first negative sample; T is the first positive sample, h, r, t all belong to the first positive sample, that is, the triple in the first sample knowledge graph or the second sample knowledge graph; T′ is the negative sample generated by randomly replacing the head entity or the tail entity in the first negative sample triple.
[0157] In an optional implementation, the entity object encoding model further includes an entity category knowledge embedding subnetwork; in the embodiment of the present application, the entity categories in the entity category knowledge set can be encoded based on the entity category knowledge embedding subnetwork.
[0158] See also Figure 6B As shown in FIG. 1 , it is a schematic diagram of an entity category knowledge set (also called ontology knowledge set) in an embodiment of the present application. The set includes multiple nodes, which are used to represent entity categories of the entity object ontology, where the root node is the topmost node. There is a hierarchical relationship between entity categories, such as Figure 6B As shown, there is a connection relationship between nodes, which means that there is a hierarchical relationship between corresponding entity categories, for example, tools include transportation tools, kitchen tools, auto repair tools, etc. Transportation tools include cars, buses, subways, bicycles, trains, etc.
[0159] For the entity category knowledge embedding sub-network, the sub-network is mainly used to encode the subject used to represent the entity category. Therefore, the sub-network can also adopt the TransE network, MTransE network, etc., which is not specifically limited here.
[0160] Specifically, after the entity category knowledge set is input into the entity category knowledge embedding subnetwork of the entity object encoding model, each entity category in the entity category knowledge set is encoded based on the entity category knowledge embedding subnetwork to obtain the second predicted category embedding feature corresponding to each entity category, that is, the ontology embedding representation; then, based on the second predicted category embedding feature corresponding to each entity category, the parameters of the entity category knowledge embedding subnetwork are adjusted.
[0161] In an optional implementation, when adjusting the parameters of the entity category knowledge embedding subnetwork based on the second predicted category embedding features corresponding to each entity category, the following process is specifically included:
[0162] First, according to the hierarchical relationship between each entity category in the entity category knowledge set, multiple entity category pairs are obtained, wherein each entity category pair includes a subclass and the parent class to which the subclass belongs; for example, the subclass is pencil and the parent class is pen; the subclass is: pen and the parent class is: stationery; for another example, the subclass is: bicycle and the parent class is: transportation; the subclass is: transportation and the parent class is: tool, and so on.
[0163] Furthermore, the following operations are performed for each entity category pair: for an entity category pair of each entity category pair, a nonlinear conversion feature between a subclass in an entity category pair and a parent class to which the subclass belongs is obtained, wherein the nonlinear conversion feature is used to characterize the nonlinear conversion relationship between a second predicted category embedding feature corresponding to a subclass in an entity category pair and a second predicted category embedding feature corresponding to the parent class to which the subclass belongs.
[0164] For example, for the ontology knowledge set G o , TransE can also be used as an encoding method for entity categories, but there are two problems with TransE: First, TransE cannot handle one-to-many, many-to-one, and many-to-many mappings; second, ontology knowledge has a clear hierarchical structure (for example, people can be divided into engineers, mathematicians, etc.), and entity categories are transferable (for example, bicycles are transportation tools, transportation tools are tools, and bicycles are tools), which is difficult for TransE to model. In order to encode the hierarchical structure of the ontology, given an entity category pair (c h , c t ), where c t It is c h The parent class of c h That is, the subclass in the entity category pair. In the embodiment of the present application, such a hierarchical structure is modeled as a nonlinear transformation from a subclass to an associated parent class, and the calculation formula is as follows:
[0165] f O (c h , c t )=||σ(w O c h +b O )-c t ||2;
[0166] in, is a learnable parameter (referring to the variable that needs to be learned / updated), σ(·) is the tanh activation function, and d o is the dimension of the category embedding representation.
[0167] Based on the above method, the nonlinear transformation feature f corresponding to each sample can be determined O (c h , ct ), and then based on the nonlinear transformation features corresponding to the second positive sample and the nonlinear transformation features corresponding to the second negative sample, an entity category knowledge embedding loss function is constructed, and parameters of the entity category knowledge embedding subnetwork are adjusted based on the entity category knowledge embedding loss function. The second positive sample is an entity category pair in the entity category knowledge set, and the second negative sample is generated by randomly replacing the subclass or parent class in the second positive sample.
[0168] For example, the following limit-based loss is also used to calculate the entity category knowledge embedding loss function and optimize the entity category knowledge embedding subnetwork. The calculation formula is as follows:
[0169]
[0170] Among them, T o That is, the second positive sample represents a pair of entity categories, in which the hierarchical relationship between the child and parent categories in the entity category pair is correct, T′ o is obtained by randomly replacing c h or c t For the second negative sample generated, the hierarchical relationship between the child and parent classes in the entity category pair is wrong, that is, it is not actually a child or parent class.
[0171] In an optional embodiment, the entity object encoding model also includes an embedding optimization subnetwork; the subnetwork is used to obtain the conflict probability between every two entity categories in the entity category knowledge set after obtaining the second prediction category embedding features corresponding to each entity category, and adjust the second prediction category embedding features corresponding to every two entity categories based on the conflict probability. For example, the greater the conflict probability, the greater the distance between the two adjusted second prediction category embedding features; the smaller the conflict probability, the closer the distance between the two adjusted second prediction category embedding features; wherein the conflict probability is used to characterize the degree of category conflict between two entity categories.
[0172] In order to detect category conflicts in the embodiment of the present application, the following category conflict matrix V is designed based on the ontology meta-relation “owl:disjointWith” (indicating that category A and category B are absolutely impossible to intersect, such as people and inorganic objects), path coverage rules, and supervised synonym seeds, where category c i and category c j The conflict probability is defined as follows:
[0173]
[0174] Among them, 0 means no conflict. According to the transitivity of entity categories, P(c i ) is c i The set of categories that appear on the path to the root node, i.e. ci ancestor; similarly, P(c j ) is c j The set of categories that appear on the path to the root node, i.e. c j ancestor.
[0175] Specifically, each item in the formula is explained as follows:
[0176] The first item: indicates that if two categories c i and c j If they are equal, no conflict occurs, and the corresponding conflict probability value is 0;
[0177] The second item: represents the category c corresponding to two entities (seed alignment AS) that belong to the synonym relationship i and c j It does not belong to the conflict relationship either, and the corresponding conflict probability value is 0;
[0178] The third item: indicates that according to the ontological meta-relationship, if two categories have a disjoint relationship, a conflict occurs, and the corresponding conflict probability value is 1; that is, if the two categories are determined to be disjoint based on external knowledge, such as humans and inorganic substances, then the two categories conflict, and the corresponding conflict probability value is 1.
[0179] The fourth item: If two entity categories do not belong to the above three conditions, the conflict probability between them is calculated according to the path coverage rule. The calculation method depends on the longest common path between the two. If the longest common path is longer, the distance between the two is shorter and the probability of conflict is smaller. If the longest common path is shorter, the distance between the two is longer and the probability of conflict is greater.
[0180] For example, according to the transitivity of entity categories, for entity category c i Bicycle: Bicycle-Transportation-Tool-Root Node A, these four categories constitute the category set P (c i ); for entity category c j Gear: Gear-Parts-Tools-Root Node A, four categories form the category set P (c j ).
[0181] Among them, the longest common path between the two is: tool-root node A. P(c i ) and P(c j ) has 2 categories in total, namely tools and root node A, and 6 categories in total, namely driving, transportation, gear, parts, tools and root node A. Therefore, the corresponding conflict probability is: 1-2 / 6=2 / 3.
[0182] In an optional implementation, when the parameters of the embedding optimization subnetwork are adjusted, it is mainly implemented based on the adjusted embedding features of each second prediction category, and the specific process is as follows:
[0183] For every two entity categories in the entity category knowledge set, the following operations are performed respectively: for every two entity categories in the entity category, a negative log-likelihood loss function is constructed based on the distance between the adjusted second prediction category embedding features corresponding to the two entity categories and the conflict probability corresponding to the two entity categories determined according to the category conflict matrix; based on the negative log-likelihood loss function, parameters of the embedding optimization subnetwork in the entity object encoding model are adjusted so that the distance between the second prediction category embedding features corresponding to the two entity categories that are expected to conflict is greater than the distance between the second prediction category embedding features corresponding to the two entity categories that do not conflict.
[0184] In the embodiment of the present application, in order to enable ontology knowledge to represent category conflicts, it is expected that the embedding representations corresponding to the two conflicting categories are as far apart as possible, while the embedding representations corresponding to the two non-conflicting categories are as close as possible. The distance between the category embedding representations can be measured using the cosine distance, and the calculation formula is as follows:
[0185] P con (c i , c j )=1-cos(c i , c j )
[0186] Furthermore, the following negative log-likelihood loss function is used as the loss function for optimizing the embedding optimization subnetwork, and the calculation formula is as follows:
[0187]
[0188] In an optional implementation, when adjusting the parameters of the link sub-network based on the first predicted category embedding features corresponding to each entity category, the following process is specifically included:
[0189] For each entity object in the first sample knowledge graph or the second sample knowledge graph, the following operations are performed respectively: for one entity object among the entity objects, a link loss function is constructed based on the error between the first prediction category embedding feature corresponding to the entity object and the second prediction category embedding feature corresponding to the entity object; and parameters of the link subnetwork in the entity object encoding model are adjusted based on the link loss function. Fig. 6AThe entity object encoding model shown includes an entity category knowledge embedding subnetwork, which is mainly used to vectorize entity categories. These entity categories are the ontologies of each entity object in the sample knowledge graph. During the training process of the entity object encoding model, the ontology corresponding to the entity object is known, and the input of the link subnetwork is the vectorized expression of the entity object, and the output is the ontology corresponding to the entity object (prediction result). Therefore, when adjusting the link subnetwork, the model parameters can be adjusted according to the second prediction category embedding features and the corresponding first prediction category embedding features.
[0190] In addition, in an embodiment of the present application, the entity embedding representation and the ontology knowledge embedding representation encode entities and categories into low-dimensional dense spaces, respectively. It makes sense to jointly learn the two embedding spaces, so that the category semantic information can be encoded into the entity representation, and the model can perceive that the class semantics of two entities belonging to a synonym relationship should be consistent. In an embodiment of the present application, the relationship between the two can also be modeled by nonlinear transformation, and then jointly learned. For example, given an entity e and its corresponding category c, the relationship between the two is modeled as a nonlinear transformation from an entity to an associated category:
[0191] f M (e, c) = ||σ(W M e+b M )-c||2;
[0192] in, is a learnable parameter, σ(·) is the tanh activation function, and d e is the dimension of the entity embedding representation.
[0193] Then, the above formula is optimized using limit-based loss:
[0194]
[0195] Among them, M is a positive sample containing an entity e and its corresponding category c, and M′ is a negative sample generated by randomly replacing c, which contains an entity e′ and a category c′.
[0196] In an optional implementation, the entity object encoding model in the embodiment of the present application also includes a joint representation subnetwork. The subnetwork is used to combine the knowledge information obtained by the link subnetwork with a specific downstream task. Specifically, the result obtained by the link subnetwork directly replaces the input in the original downstream task. This does not change the model structure of the downstream task, thereby ensuring the ease of use of the method in the embodiment of the present application, and can be easily applied to a variety of downstream tasks. This subnetwork modifies the training process of the model, that is, by modifying the optimization target, the optimization targets of the above-mentioned subnetworks are added to the optimization target of the original downstream task. Therefore, the entity encoding finally trained in the embodiment of the present application not only utilizes the ontological knowledge, but also utilizes the characteristics of the downstream task, thereby better improving the effect of the method in the embodiment of the present application on the downstream task.
[0197] In the embodiment of the present application, a synonym mining task is taken as an example for illustration. Specifically: the entity encoding information of each entity object is input into the joint representation subnetwork, and based on the joint representation subnetwork, the unrecognized synonyms in the first sample knowledge graph and the second sample knowledge graph are marked; and based on the synonyms marked by the entity object encoding model, the parameters of the entity object encoding model are adjusted.
[0198] In the synonym mining task, we need to find entities that have not been discovered in two KGs. and Mark as synonyms, where
[0199] In an optional embodiment, when adjusting the parameters of the entity object coding model based on the synonyms marked by the entity object coding model, the specific process is: for two entity objects that are synonyms, construct a joint representation loss function based on the entity coding information of the two entity objects; and adjust the parameters of the entity object coding model based on the joint representation loss function.
[0200] Taking the synonym mining task as an example, the first formula below is the calculation process of the synonym mining task itself, in which the output of the link subnetwork will replace the original e1 and e2 in the embodiment of the present application. The second formula is the final optimization goal in the embodiment of the present application.
[0201] For two synonymous entities (e1, e2), it is expected that their corresponding embedding representations are as close as possible after mapping. The corresponding calculation formula is the first formula, based on which the joint representation subnetwork can be optimized:
[0202]
[0203] in, represents learnable parameters.
[0204] The final optimization loss is as follows:
[0205]
[0206] Among them, λ1, λ2, λ3 are weight hyperparameters for balancing different sub-networks. The above loss is optimized by iterative training. Based on this formula, i.e. the second formula, the overall parameters of the entity object encoding model are adjusted.
[0207] In an embodiment of the present application, by introducing a class conflict matrix to detect class conflict problems in the prediction results, the recall rate of the model and the ranking of entities with synonymous relationships can be improved. In addition, the method in the embodiment of the present application can be combined with any model to improve the performance of the model, reflecting the robustness and effectiveness of the method in the embodiment of the present application. In addition, it should be noted that the embedding representation of class non-co-occurrence (class conflict) can also be used in addition to the initialization method used in the embodiment of the present application, such as the shortest distance, etc., which is not specifically limited here.
[0208] In summary, different from the entity encoding method in the related art, the method in the embodiment of the present application utilizes the hierarchical category structure in the ontology knowledge to guide the process of downstream tasks. By jointly learning the entity layer and the ontology knowledge embedding representation, the category semantic information can be encoded into the entity representation, so that the downstream tasks can have better performance.
[0209] See also Figure 7 As shown in FIG. 1 , a complete flow chart of a training method for an entity object encoding model is shown. The specific implementation process of the method is as follows:
[0210] Step S701: Select a group of training samples from the training sample data set, where the group of training samples includes a first sample knowledge graph, a second sample knowledge graph, and an entity category knowledge set;
[0211] Step S702: input the first sample knowledge graph, the second sample knowledge graph, and the entity category knowledge set into the entity object encoding model, encode each entity category in the entity category knowledge set based on the entity category knowledge embedding subnetwork in the entity object encoding model, and obtain the category embedding features corresponding to each entity category;
[0212] Step S703: adjusting parameters of the entity category knowledge embedding sub-network based on the category embedding features corresponding to each entity category;
[0213] Step S704: inputting the category embedding features corresponding to each entity category into the embedding optimization sub-network in the entity object encoding model, obtaining the conflict probability between every two categories in the entity category knowledge set based on the embedding optimization sub-network, and adjusting the category embedding features corresponding to every two categories based on the conflict probability;
[0214] Step S705: adjusting parameters of the embedding optimization sub-network based on the adjusted embedding features of each entity category;
[0215] Step S706: Based on the entity object embedding subnetwork in the entity object encoding model, encode each entity object in the first sample knowledge graph and the second sample knowledge graph to obtain entity embedding features corresponding to each entity object;
[0216] Step S707: adjusting the entity object embedding sub-network based on the entity embedding features corresponding to each entity object;
[0217] Step S708: Input the entity embedding features corresponding to each entity object into the link sub-network, and perform category semantic analysis on the predicted entity embedding features of each entity object based on the link sub-network to obtain a first predicted category embedding feature corresponding to the entity category of each entity object;
[0218] Step S709: adjusting parameters of the link sub-network based on the first prediction category embedding features corresponding to the entity category of each entity object and the corresponding second prediction category embedding features;
[0219] Step S710: Inputting entity encoding information of each entity object into the joint representation subnetwork, and marking unrecognized synonyms in the first sample knowledge graph and the second sample knowledge graph based on the joint representation subnetwork;
[0220] Step S711: adjusting parameters of the entity object coding model based on synonyms marked by the entity object coding model;
[0221] Step S712: determine whether the entity object coding model converges, if so, execute step S713, otherwise, return to step S701;
[0222] Step S713: Output the trained entity object coding model.
[0223] Based on the same inventive concept, the present application also provides a physical object encoding device. Figure 8 As shown, it is a schematic diagram of the structure of a physical object encoding device 800 in an embodiment of the present application, which may include:
[0224] An acquisition unit 801 is used to acquire each entity object in the knowledge graph to be encoded, wherein the knowledge graph to be encoded includes the association relationship between each entity object;
[0225] The encoding unit 802 is used to encode each entity object respectively to obtain entity embedding features corresponding to each entity object, and to encode the entity category of each entity object respectively to obtain category embedding features corresponding to the entity category of each entity object, wherein the entity category of each entity object is determined by performing category semantic analysis on the corresponding entity embedding features;
[0226] The fusion unit 803 is used to fuse the entity embedding features and the corresponding category embedding features corresponding to each entity object to obtain the entity encoding information corresponding to each entity object.
[0227] Optionally, the encoding unit 802 is specifically configured to:
[0228] Input the knowledge graph to be encoded into the trained entity object encoding model, encode each entity object based on the entity object embedding subnetwork in the entity object encoding model, and obtain the entity embedding features corresponding to each entity object;
[0229] The entity embedding features corresponding to each entity object are input into the link sub-network in the entity object encoding model, and category semantic analysis is performed on the entity embedding features of each entity object based on the link sub-network to obtain the category embedding features corresponding to the entity category of each entity object.
[0230] Optionally, the apparatus further includes a training unit 804, configured to obtain the entity object encoding model through training in the following manner:
[0231] According to the training samples in the training sample data set, the entity object coding model is subjected to cyclic iterative training, and when the training is completed, the trained entity object coding model is output; wherein the following operations are performed during one cyclic iterative training process:
[0232] Selecting a group of training samples from a training sample data set, the group of training samples includes a first sample knowledge graph and a second sample knowledge graph, wherein the first sample knowledge graph and the second sample knowledge graph contain at least one pair of entity objects that are synonyms;
[0233] Inputting the first sample knowledge graph and the second sample knowledge graph into the entity object embedding subnetwork of the entity object encoding model, encoding each entity object in the first sample knowledge graph and the second sample knowledge graph based on the entity object embedding subnetwork, and obtaining entity embedding features corresponding to each entity object; and adjusting parameters of the entity object embedding subnetwork based on the predicted entity embedding features corresponding to each entity object;
[0234] The entity embedding features corresponding to each entity object are input into the link sub-network of the entity object encoding model, and based on the link sub-network, category semantic analysis is performed on the predicted entity embedding features of each entity object to obtain the first predicted category embedding features corresponding to the entity category of each entity object; and based on the first predicted category embedding features corresponding to the entity category of each entity object, parameters of the link sub-network are adjusted.
[0235] Optionally, a group of training samples further includes an entity category knowledge set, the entity category knowledge set includes entity categories of each entity object in the first sample knowledge graph and the second sample knowledge graph, and there is a hierarchical relationship between the entity categories; the entity object encoding model further includes an entity category knowledge embedding subnetwork; the training unit 804 is further used to:
[0236] The entity category knowledge set is input into the entity category knowledge embedding subnetwork of the entity object encoding model, each entity category in the entity category knowledge set is encoded based on the entity category knowledge embedding subnetwork, and a second predicted category embedding feature corresponding to each entity category is obtained; and based on the second predicted category embedding feature corresponding to each entity category, parameters of the entity category knowledge embedding subnetwork are adjusted.
[0237] Optionally, the entity object encoding model further includes an embedding optimization subnetwork; the training unit 804 is further used for:
[0238] After obtaining the second prediction category embedding features corresponding to each entity category, based on the embedding optimization sub-network, the conflict probability between every two entity categories in the entity category knowledge set is obtained, and the second prediction category embedding features corresponding to every two entity categories are adjusted based on the conflict probability; and the embedding optimization sub-network is parameterized based on the adjusted second prediction entity category embedding features; wherein the conflict probability is used to characterize the degree of category conflict between two entity categories.
[0239] Optionally, the training unit 804 is specifically used for:
[0240] Based on the predicted entity embedding features corresponding to each entity object, determine the vector difference corresponding to the triple containing each entity object, wherein the predicted entity embedding features are embedding representation vectors, and the vector difference corresponding to the triple containing each entity object is the sum of the embedding representation vector of the head entity object and the relationship embedding representation vector in the triple, and the difference between the embedding representation vector of the tail entity object;
[0241] An entity object embedding loss function is constructed based on the vector difference corresponding to the first positive sample and the vector difference corresponding to the first negative sample, and parameters of the entity object embedding subnetwork are adjusted based on the entity object embedding loss function, wherein the first positive sample is a triple in the first sample knowledge graph or the second sample knowledge graph, and the first negative sample is generated by randomly replacing the head entity object or the tail entity object in the first positive sample.
[0242] Optionally, the training unit 804 is specifically used for:
[0243] According to the hierarchical relationship between each entity category in the entity category knowledge set, a plurality of entity category pairs are obtained, wherein each entity category pair includes a subcategory and a parent category to which the subcategory belongs;
[0244] The following operations are performed for each entity category pair: for an entity category pair of each entity category pair, a nonlinear conversion feature between a subclass in an entity category pair and a parent class to which the subclass belongs is obtained, wherein the nonlinear conversion feature is used to characterize a nonlinear conversion relationship between a second predicted category embedding feature corresponding to a subclass in an entity category pair and a second predicted category embedding feature corresponding to a parent class to which the subclass belongs;
[0245] Based on the nonlinear conversion features corresponding to the second positive sample and the nonlinear conversion features corresponding to the second negative sample, an entity category knowledge embedding loss function is constructed, and parameters of the entity category knowledge embedding subnetwork are adjusted based on the entity category knowledge embedding loss function, wherein the second positive sample is an entity category pair in the entity category knowledge set, and the second negative sample is generated by randomly replacing the subclass or parent class in the second positive sample.
[0246] Optionally, the training unit 804 is specifically used for:
[0247] For every two entity categories in the entity category knowledge set, the following operations are performed respectively: for every two entity categories in the entity category knowledge set, a negative log-likelihood loss function is constructed based on the distance between the adjusted second predicted category embedding features corresponding to the two entity categories and the conflict probability corresponding to the two entity categories determined according to the category conflict matrix;
[0248] Based on the negative log-likelihood loss function, the parameters of the embedding optimization subnetwork in the entity object encoding model are adjusted so that the distance between the second prediction category embedding features corresponding to the two entity categories that are expected to conflict is greater than the distance between the second prediction category embedding features corresponding to the two entity categories that do not conflict.
[0249] Optionally, the training unit 804 is specifically used for:
[0250] For each entity object in the first sample knowledge graph or the second sample knowledge graph, the following operations are performed respectively: for one entity object among the entity objects, a link loss function is constructed based on an error between a first prediction category embedding feature corresponding to the entity object and a second prediction category embedding feature corresponding to the entity object;
[0251] The parameters of the link sub-network in the entity object encoding model are adjusted based on the link loss function.
[0252] Optionally, the entity object encoding model further includes a joint representation subnetwork, and the training unit 804 is further used for:
[0253] Inputting entity encoding information of each entity object into the joint representation subnetwork, and marking unrecognized synonyms in the first sample knowledge graph and the second sample knowledge graph based on the joint representation subnetwork; and
[0254] Based on synonyms of the entity object coding model tags, parameters of the entity object coding model are adjusted.
[0255] Optionally, the training unit 804 is specifically used for:
[0256] For two entity objects that are synonyms, a joint representation loss function is constructed based on the entity encoding information of the two entity objects;
[0257] Parameters of the entity object encoding model are adjusted based on the joint representation loss function.
[0258] Optionally, the device further includes a task execution unit 805, configured to perform one of the following operations:
[0259] Synonym mining is performed based on the entity encoding information of each entity object to determine the synonyms in the knowledge graph to be encoded;
[0260] Knowledge clustering based on entity encoding information of each entity object;
[0261] Path inference is performed based on the entity encoding information of each entity object to obtain the corresponding intention path, and the knowledge graph result pointed to by the intention path is used as the question and answer result.
[0262] For the convenience of description, the above parts are divided into modules (or units) according to their functions and described separately. Of course, when implementing this application, the functions of each module (or unit) can be implemented in the same or multiple software or hardware.
[0263] Those skilled in the art will appreciate that various aspects of the present application may be implemented as a system, method or program product. Therefore, various aspects of the present application may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to as "circuit", "module" or "system" herein.
[0264] Based on the same inventive concept as the above method embodiment, an electronic device is also provided in the embodiment of the present application. The electronic device can be used to encode entity objects in the knowledge graph. In one embodiment, the electronic device can be a server, such as Figure 1A In this embodiment, the structure of the electronic device can be as follows: Fig. 9 As shown, it includes a memory 901 , a communication module 903 and one or more processors 902 .
[0265] The memory 901 is used to store computer programs executed by the processor 902. The memory 901 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and programs required for running the instant messaging function, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.
[0266] The memory 901 may be a volatile memory, such as a random-access memory (RAM); the memory 901 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); or the memory 901 may be any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 901 may be a combination of the above memories.
[0267] The processor 902 may include one or more central processing units (CPU) or a digital processing unit, etc. The processor 902 is used to implement the above entity object encoding method when calling the computer program stored in the memory 901 .
[0268] The communication module 903 is used to communicate with terminal devices and other servers.
[0269] The specific connection medium between the memory 901, the communication module 903 and the processor 902 is not limited in the embodiment of the present application. Fig. 9 In the embodiment, the memory 901 and the processor 902 are connected via a bus 904. The bus 904 is connected to the processor 902 via a bus 904. Fig. 9 The connections between other components are shown in bold lines, and are not intended to be limiting. Bus 904 can be divided into address bus, data bus, control bus, etc. For ease of representation, Fig. 9 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0270] The memory 901 stores a computer storage medium, and the computer storage medium stores computer executable instructions, and the computer executable instructions are used to implement the entity object encoding method of the embodiment of the present application. The processor 902 is used to execute the above-mentioned entity object encoding method, such as Figure 2 shown.
[0271] In another embodiment, the electronic device may also be other electronic devices, such as Figure 1A The terminal device 110 shown in FIG. 1 is a terminal device 110 shown in FIG. 1 . In this embodiment, the structure of the electronic device can be as follows: Fig.10 As shown, it includes: a communication component 1010, a memory 1020, a display unit 1030, a camera 1040, a sensor 1050, an audio circuit 1060, a Bluetooth module 1070, a processor 1080 and other components.
[0272] The communication component 1010 is used to communicate with the server. In some embodiments, a wireless fidelity (WiFi) module may be included. The WiFi module belongs to a short-range wireless transmission technology. The electronic device can help the user to send and receive information through the WiFi module.
[0273] The memory 1020 can be used to store software programs and data. The processor 1080 executes various functions and data processing of the terminal device 110 by running the software programs or data stored in the memory 1020. The memory 1020 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. The memory 1020 stores an operating system that enables the terminal device 110 to run. In the present application, the memory 1020 can store an operating system and various application programs, and can also store code for executing the entity object encoding method of the embodiment of the present application.
[0274] The display unit 1030 can also be used to display information input by the user or information provided to the user and a graphical user interface (GUI) of various menus of the terminal device 110. Specifically, the display unit 1030 may include a display screen 1032 disposed on the front of the terminal device 110. The display screen 1032 may be configured in the form of a liquid crystal display, a light-emitting diode, etc. The display unit 1030 can be used to display the execution interface, execution results, etc. of the downstream tasks related to the knowledge graph in the embodiment of the present application.
[0275] The display unit 1030 can also be used to receive input digital or character information and generate signal input related to user settings and function control of the terminal device 110. Specifically, the display unit 1030 may include a touch screen 1031 arranged on the front of the terminal device 110, which can collect user touch operations on or near it, such as clicking a button, dragging a scroll box, etc.
[0276] The touch screen 1031 may be covered on the display screen 1032, or the touch screen 1031 and the display screen 1032 may be integrated to realize the input and output functions of the terminal device 110, and the integrated touch screen may be referred to as a touch display screen. In the present application, the display unit 1030 may display the application and the corresponding operation steps.
[0277] Camera 1040 can be used to capture static images, and users can upload comments on images taken by camera 1040 through a video client. Camera 1040 can be one or more. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the processor 1080 to convert it into a digital image signal.
[0278] The terminal device may further include at least one sensor 1050, such as an acceleration sensor 1051, a distance sensor 1052, a fingerprint sensor 1053, and a temperature sensor 1054. The terminal device may also be configured with other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, a light sensor, and a motion sensor.
[0279] The audio circuit 1060, the speaker 1061, and the microphone 1062 can provide an audio interface between the user and the terminal device 110. The audio circuit 1060 can transmit the electrical signal converted from the received audio data to the speaker 1061, which is converted into a sound signal for output. The terminal device 110 can also be configured with a volume button for adjusting the volume of the sound signal. On the other hand, the microphone 1062 converts the collected sound signal into an electrical signal, which is received by the audio circuit 1060 and converted into audio data, and then the audio data is output to the communication component 1010 to be sent to, for example, another terminal device 110, or the audio data is output to the memory 1020 for further processing.
[0280] The Bluetooth module 1070 is used to exchange information with other Bluetooth devices having Bluetooth modules through the Bluetooth protocol. For example, the terminal device can establish a Bluetooth connection with a wearable electronic device (such as a smart watch) that also has a Bluetooth module through the Bluetooth module 1070 to exchange data.
[0281] The processor 1080 is the control center of the terminal device. It uses various interfaces and lines to connect various parts of the entire terminal. It executes various functions of the terminal device and processes data by running or executing software programs stored in the memory 1020 and calling data stored in the memory 1020. In some embodiments, the processor 1080 may include one or more processing units; the processor 1080 may also integrate an application processor and a baseband processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the baseband processor mainly processes wireless communications. It is understandable that the above-mentioned baseband processor may not be integrated into the processor 1080. In the present application, the processor 1080 can run the operating system, application programs, user interface display and touch response, as well as the entity object encoding method of the embodiment of the present application. In addition, the processor 1080 is coupled to the display unit 1030.
[0282] In some optional implementations, various aspects of the entity object encoding method provided in the present application may also be implemented in the form of a program product, which includes program code. When the program product is run on a computer device, the program code is used to enable the computer device to execute the steps of the entity object encoding method according to various exemplary implementations of the present application described above in this specification. For example, the computer device may execute the following steps: Figure 2 Follow the steps shown in .
[0283] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0284] The program product of the embodiment of the present application may adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a computing device. However, the program product of the present application is not limited thereto. In the embodiment of the present application, the readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with a command execution system, device or device.
[0285] The readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, wherein the readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with a command execution system, apparatus, or device.
[0286] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0287] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0288] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A method for encoding an entity object, It is characterized in that The method includes: Obtaining each entity object in the knowledge graph to be encoded, wherein the knowledge graph to be encoded includes association relationships between the entity objects; Based on the trained entity object encoding model, each entity object is encoded respectively to obtain entity embedding features corresponding to each entity object, and the entity category of each entity object is encoded respectively to obtain category embedding features corresponding to the entity category of each entity object, wherein the entity category of each entity object is determined by performing category semantic analysis on the corresponding entity embedding features; The entity embedding features and the corresponding category embedding features corresponding to each entity object are respectively fused to obtain entity encoding information corresponding to each entity object; When training the entity object encoding model, the following operations are performed in each loop iteration: Selecting a set of training samples from a training sample data set, the set of training samples comprising: a first sample knowledge graph and a second sample knowledge graph containing at least one pair of entity objects as synonyms; The first sample knowledge graph and the second sample knowledge graph are input into the entity object encoding model, and each entity object in the first sample knowledge graph and the second sample knowledge graph is encoded respectively. Based on the obtained predicted entity embedding features corresponding to each entity object, the vector difference corresponding to the triple containing each entity object is determined, and the predicted entity embedding features are embedding representation vectors, wherein the vector difference corresponding to the triple containing each entity object is the sum of the embedding representation vector of the head entity object and the relationship embedding representation vector in the triple, and the difference between the embedding representation vector of the tail entity object; based on the vector difference corresponding to the first positive sample and the vector difference corresponding to the first negative sample, the parameters of the entity object encoding model are adjusted, the first positive sample is a triple in the first sample knowledge graph or the second sample knowledge graph, and the first negative sample is generated by randomly replacing the head entity object or the tail entity object in the first positive sample.
2. The method according to claim 1, It is characterized in that The encoding of each entity object based on the trained entity object encoding model to obtain entity embedding features corresponding to each entity object, and encoding the entity category of each entity object to obtain category embedding features corresponding to the entity category of each entity object, include: Inputting the knowledge graph to be encoded into the trained entity object encoding model, encoding each entity object based on the entity object embedding subnetwork in the trained entity object encoding model, and obtaining entity embedding features corresponding to each entity object; The entity embedding features corresponding to the various entity objects are input into the link subnetwork in the trained entity object encoding model, and category semantic analysis is performed on the entity embedding features of the various entity objects based on the link subnetwork to obtain category embedding features corresponding to the entity categories of the various entity objects.
3. The method according to claim 1, It is characterized in that The step of inputting the first sample knowledge graph and the second sample knowledge graph into the entity object encoding model and encoding each entity object in the first sample knowledge graph and the second sample knowledge graph respectively includes: Inputting the first sample knowledge graph and the second sample knowledge graph into the entity object embedding subnetwork of the entity object encoding model, encoding each entity object in the first sample knowledge graph and the second sample knowledge graph based on the entity object embedding subnetwork, and obtaining predicted entity embedding features corresponding to each entity object; And, adjusting parameters of the entity object coding model based on the vector difference corresponding to the first positive sample and the vector difference corresponding to the first negative sample includes: Constructing an entity object embedding loss function based on a vector difference corresponding to the first positive sample and a vector difference corresponding to the first negative sample, and adjusting parameters of the entity object embedding subnetwork based on the entity object embedding loss function; And, each loop iteration also does the following: The predicted entity embedding features corresponding to the various entity objects are input into the link sub-network of the entity object encoding model; based on the link sub-network, category semantic analysis is performed on the predicted entity embedding features of the various entity objects to obtain first predicted category embedding features corresponding to the entity categories of the various entity objects; and based on the first predicted category embedding features corresponding to the entity categories of the various entity objects, parameters of the link sub-network are adjusted.
4. The method according to claim 3, It is characterized in that The set of training samples further includes an entity category knowledge set, wherein the entity category knowledge set includes entity categories of each entity object in the first sample knowledge graph and the second sample knowledge graph, and there is a hierarchical relationship between the entity categories; The entity object encoding model also includes an entity category knowledge embedding sub-network; The method further comprises: Inputting the entity category knowledge set into the entity category knowledge embedding subnetwork of the entity object encoding model, encoding each entity category in the entity category knowledge set based on the entity category knowledge embedding subnetwork, and obtaining a second prediction category embedding feature corresponding to each entity category; And, based on the second predicted category embedding features corresponding to each entity category, parameters of the entity category knowledge embedding sub-network are adjusted.
5. The method according to claim 4, It is characterized in that The entity object encoding model also includes an embedding optimization subnetwork; After obtaining the second predicted category embedding features corresponding to each entity category, the method further includes: Based on the embedding optimization subnetwork, the conflict probability between every two entity categories in the entity category knowledge set is obtained, and the second prediction category embedding features corresponding to the every two entity categories are adjusted based on the conflict probability; and the parameters of the embedding optimization subnetwork are adjusted based on the adjusted second prediction entity category embedding features; wherein the conflict probability is used to characterize the degree of category conflict between the two entity categories.
6. The method according to claim 4, It is characterized in that The step of adjusting parameters of the entity category knowledge embedding subnetwork based on the second predicted category embedding features corresponding to each entity category includes: According to the hierarchical relationship between the entity categories in the entity category knowledge set, a plurality of entity category pairs are obtained, wherein each entity category pair includes a subcategory and a parent category to which the subcategory belongs; The following operations are performed for each entity category pair: for one entity category pair of each entity category pair, a nonlinear conversion feature between a subclass in the entity category pair and a parent class to which the subclass belongs is obtained, wherein the nonlinear conversion feature is used to characterize a nonlinear conversion relationship between a second prediction category embedding feature corresponding to the subclass in the entity category pair and a second prediction category embedding feature corresponding to the parent class to which the subclass belongs; Based on the nonlinear conversion features corresponding to the second positive sample and the nonlinear conversion features corresponding to the second negative sample, an entity category knowledge embedding loss function is constructed, and parameters of the entity category knowledge embedding subnetwork are adjusted based on the entity category knowledge embedding loss function, wherein the second positive sample is an entity category pair in the entity category knowledge set, and the second negative sample is generated by randomly replacing a subclass or a parent class in the second positive sample.
7. The method according to claim 5, It is characterized in that The step of adjusting parameters of the embedding optimization subnetwork based on the adjusted embedding features of each second prediction category includes: For every two entity categories in the entity category knowledge set, the following operations are respectively performed: for two entity categories in the every two entity categories, based on the distance between the adjusted second predicted category embedding features corresponding to the two entity categories and the conflict probability corresponding to the two entity categories determined according to the category conflict matrix, a negative log-likelihood loss function is constructed; Based on the negative log-likelihood loss function, parameters of the embedding optimization subnetwork in the entity object encoding model are adjusted so that the distance between the second prediction category embedding features corresponding to the two entity categories that are expected to conflict is greater than the distance between the second prediction category embedding features corresponding to the two entity categories that are not in conflict.
8. The method according to claim 6 or 7, It is characterized in that The step of adjusting parameters of the link sub-network based on the first predicted category embedding features corresponding to each entity category includes: For each entity object in the first sample knowledge graph or the second sample knowledge graph, the following operations are performed respectively: for one entity object among the entity objects, a link loss function is constructed based on an error between a first prediction category embedding feature corresponding to the one entity object and a second prediction category embedding feature corresponding to the one entity object; Parameters of a link sub-network in the entity object encoding model are adjusted based on the link loss function.
9. The method according to claim 3, It is characterized in that The entity object coding model also includes a joint representation subnetwork, and the method further includes: Inputting entity encoding information of each entity object into the joint representation subnetwork, and marking unrecognized synonyms in the first sample knowledge graph and the second sample knowledge graph based on the joint representation subnetwork; and Based on the synonyms of the entity object coding model tags, parameters of the entity object coding model are adjusted.
10. The method according to claim 9, It is characterized in that The step of adjusting parameters of the entity object coding model based on the synonyms marked by the entity object coding model includes: For two entity objects that are synonyms, a joint representation loss function is constructed based on the entity encoding information of the two entity objects; Parameters of the entity object encoding model are adjusted based on the joint representation loss function.
11. The method according to any one of claims 1 to 7, 9 to 10, It is characterized in that The method further comprises one of the following operations: Perform synonym mining based on the entity encoding information of each entity object to determine the synonyms in the knowledge graph to be encoded; Performing knowledge clustering based on entity encoding information of each entity object; Path inference is performed based on the entity encoding information of each entity object to obtain the corresponding intention path, and the knowledge graph result pointed to by the intention path is used as the question and answer result.
12. A physical object encoding device, It is characterized in that include: An acquisition unit, used to acquire each entity object in the knowledge graph to be encoded, wherein the knowledge graph to be encoded includes the association relationship between the entity objects; an encoding unit, configured to encode the entity objects based on the trained entity object encoding model to obtain entity embedding features corresponding to the entity objects, and to encode the entity categories of the entity objects to obtain category embedding features corresponding to the entity categories of the entity objects, wherein the entity categories of the entity objects are determined by performing category semantic analysis on the corresponding entity embedding features; A fusion unit, used to fuse the entity embedding features and the corresponding category embedding features corresponding to each entity object, to obtain entity encoding information corresponding to each entity object; The device further comprises a training unit, which is used to perform the following operations in each loop iteration when training the entity object encoding model: Selecting a set of training samples from a training sample data set, the set of training samples comprising: a first sample knowledge graph and a second sample knowledge graph containing at least one pair of entity objects as synonyms; The first sample knowledge graph and the second sample knowledge graph are input into the entity object encoding model, and each entity object in the first sample knowledge graph and the second sample knowledge graph is encoded respectively. Based on the obtained predicted entity embedding features corresponding to each entity object, the vector difference corresponding to the triple containing each entity object is determined, and the predicted entity embedding features are embedding representation vectors, wherein the vector difference corresponding to the triple containing each entity object is the sum of the embedding representation vector of the head entity object and the relationship embedding representation vector in the triple, and the difference between the embedding representation vector of the tail entity object; based on the vector difference corresponding to the first positive sample and the vector difference corresponding to the first negative sample, the parameters of the entity object encoding model are adjusted, the first positive sample is a triple in the first sample knowledge graph or the second sample knowledge graph, and the first negative sample is generated by randomly replacing the head entity object or the tail entity object in the first positive sample.
13. An electronic device, It is characterized in that The method comprises a processor and a memory, wherein the memory stores program codes, and when the program codes are executed by the processor, the processor executes the steps of any one of the methods in claims 1 to 11.
14. A computer-readable storage medium, It is characterized in that The method comprises a program code. When the program code is run on an electronic device, the program code is used to enable the electronic device to execute the steps of any method described in claims 1 to 11.
