Vector index supported tense knowledge graph searching method and system
Through the tense knowledge graph search method supported by vector index, the problem of inefficient time search of tense knowledge graphs is solved, efficient query and reasoning capabilities are achieved, and support for the application of dynamic tense knowledge graphs.
Patent Information
- Application Number
- CN202411791659.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2025-03-28
AI Technical Summary
The existing tense knowledge graph embedding model has low time efficiency in searching on tense knowledge graphs, which hinders its wide application in practical applications.
Using the tense knowledge graph search method supported by vector index, the search space is divided by training entity vectors and using clustering algorithms, and the quantizer and cluster vector index library of Voronoi units are established to achieve complete and efficient query of incomplete tense knowledge graphs.
It significantly improves the search efficiency on the tense knowledge graph, and accelerates the query process while ensuring the accuracy of the search, providing strong support for the search and reasoning tasks of the dynamic tense knowledge graph.
Smart Images

Figure CN119719385A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of temporal knowledge graph approximate query based on embedding, and in particular relates to a temporal knowledge graph search method and system supported by vector indexing. Background Art
[0002] With the advent of the information age, knowledge graph (KG) has become an important tool for connecting information. KG is a structured data representation method that represents the semantic information between entities and relationships as a graph model and is widely used in search recommendation, question-answering systems, natural language processing, and other fields.
[0003] The basic structure of KG can be formally represented as a triple<subject,predicate / relation,object> or<s,p / r,o> , where s, p / r, and o represent the subject, predicate / relation, and object, respectively. Processing large-scale KGs often faces the challenges of high dimensionality, sparsity, and complexity. Therefore, knowledge graph embedding (KGE) came into being. Starting with the classic translation model TransE and its variant models, KGE has gradually become a very active research field. It gives KG more intelligent expression capabilities, allowing machine learning models to easily adapt to KG completion and query tasks.
[0004] In recent years, with the continuous increase in data volume and the expansion of application scenarios, the modeling and reasoning of dynamic temporal knowledge graphs (TKGs) have emerged. Unlike traditional static KGs, entities, relationships, and facts in TKGs evolve over time. This change may be cyclical or sudden, and is complex and diverse. For example, a person's work, study, family, and other status will change over time, and a company's shareholders, business scope, market value and other attributes will also change over time. This temporal property makes TKG important in many practical applications.
[0005] However, in search-intensive applications of large-scale knowledge bases (KBs), when the embedding dimension is too high, the dense vectors learned by TKGE are inefficient for similarity calculation. Most existing KGE models focus on improving the accuracy of searching on KGs, while ignoring the time efficiency of searching on dynamic KGs, especially in the face of time-sensitive TKGs, which hinders the widespread application of TKGE models in real-world KG searches. Therefore, how to improve the search efficiency of TKGs while ensuring search accuracy has become an important issue in current research. Summary of the invention
[0006] In order to address the deficiencies in the prior art, the present invention provides a temporal knowledge graph search method and system supported by a vector index to solve the problem of low time efficiency of searching on the temporal knowledge graph by the existing temporal knowledge graph embedding model, thereby performing efficient query and reasoning capabilities on the temporal knowledge graph.
[0007] In order to solve the above technical problems, the present invention adopts the following technical solutions.
[0008] The present invention first discloses a temporal knowledge graph search method supported by vector index, which comprises the following steps:
[0009] The entity vectors are trained using the temporal knowledge graph embedding model. The entity vectors are divided into different search spaces according to the clustering algorithm of the vector database. A quantizer for the Voronoi unit is established for each entity vector in the search space. A clustering vector index is established on the trained entity vector. An entity vector index library for incomplete temporal knowledge graphs is constructed to complete the incomplete temporal knowledge graphs.
[0010] According to the temporal knowledge graph vector output by the temporal knowledge graph embedding model, a query vector set and an entity answer set containing time information are established. Based on the entity vector index library, an approximate search mapping between the query vector and the entity answer vector is established using a similarity algorithm to implement approximate query of the temporal knowledge graph supported by vector index.
[0011] The present invention further includes the following preferred embodiments:
[0012] The method of using the temporal knowledge graph embedding model to train entity vectors, dividing the entity vectors into different search spaces according to the clustering algorithm of the vector database, establishing a quantizer where the Voronoi unit is located for each entity vector in the search space, establishing a clustering vector index on the trained entity vector, and constructing an entity vector index library for the incomplete temporal knowledge graph further includes:
[0013] Generate a fully trained temporal knowledge graph vector database based on the temporal knowledge graph embedding model; the initial stage of the vector database includes the vectorized representation of the head entity, tail entity, relationship and time, and uses the long short-term memory neural network to learn the time-aware representation of the relationship type, thereby obtaining a fully trained vector database of entity vectors and time-relationship vectors;
[0014] An efficient entity vector index library is constructed by using the vector database. The input of the entity vector index library is a set of all entity vectors that have been trained completely. All entity vectors are divided into multiple Voronoi cells by using a clustering algorithm, and each entity vector falls into one of the cells. During the search, only the entity vector contained in the cell where the query vector is located is compared with the adjacent query vector.
[0015] Another index, namely a quantizer, is constructed based on the entity vector index library to assign entity vectors to Voronoi cells, each cell being defined by a centroid, and finding the Voronoi cell where a vector is located includes finding the nearest neighbor of the vector in the set of centroids.
[0016] The method of learning a time-aware representation of a relationship type using a long short-term memory neural network further comprises:
[0017] Given a temporal knowledge graph triple, it is expanded to (s, r, o, t) with time information t, where s is the head entity, r is the relationship, and o is the tail entity. The temporal knowledge graph triple is represented as (s, r t ,o) triples, where the relation sequence r t Includes temporal information, used as input to long short-term memory neural networks;
[0018] The relationship sequence r t Each token of is first mapped to its corresponding d-dimensional embedding through a linear layer, and the resulting embedding sequence is used as the input of the LSTM. Each relation sequence of length N is represented by the last hidden state of the LSTM, i.e., r t =h N ; Define the time-relation vector embedding as:
[0019] r t (r,t)=LSTM(r,t)
[0020] The scoring function embedded in the temporal knowledge graph carries the relational sequence representation of time information:
[0021]
[0022] Where q represents the query vector, e represents the entity vector, and all parameters of the scoring function are learned together using stochastic gradient descent and LSTM parameters. L2 represents the 2-norm.
[0023] The corresponding loss function is defined as:
[0024]
[0025] Among them, (s,r t ,o)∈ξ,(s',rt ,o),(s,r t ,o')∈ξ' are the positive and negative samples of the temporal triples respectively, and γ>0 represents the interval hyperparameter.
[0026] The method of establishing an approximate search mapping between a query vector and an entity answer vector based on the entity vector index library by using a similarity algorithm to implement an approximate query of a temporal knowledge graph supported by a vector index further includes:
[0027] A query set and an answer set containing time information are constructed using a well-trained temporal knowledge graph vector database. Each query vector in the query set consists of a vector of an entity vector and its corresponding time-relation vector. The answer set consists of all well-trained entity vectors output by the temporal knowledge graph embedding model.
[0028] Based on the entity vector index library and the query vector and answer vector database, an approximate query combining vector similarity calculation and index search technology is established; based on a given number of centroids, for each query vector, its distance to the given number of centroids is first calculated, and then the first N nearest Voronoi cells are selected, and only the distance between the query vector and the entity answer vector within the N Voronoi cells is calculated, and the distance and index closest to the answer vector are returned.
[0029] The method of establishing an approximate query combining vector similarity calculation and index search technology based on the entity vector index library and the query vector and answer vector database further includes:
[0030] Based on the output of the temporal knowledge graph embedding model, the entity vector set is input into the index library, and the entity index is defined as:
[0031]
[0032] Among them, quantizer represents the quantizer, d represents the dimension of the embedded entity vector, add() represents adding the id of the entity vector set to the constructed index library so that the entity vector and the corresponding index correspond to each other, and nlist represents the number of division units, that is, the number of cluster centers.
[0033] The present invention also discloses a temporal knowledge graph search system supported by a vector index using the temporal knowledge graph search method supported by a vector index, comprising:
[0034] The temporal knowledge graph completion module is used to train entity vectors using the temporal knowledge graph embedding model, divide the entity vectors into different search spaces according to the clustering algorithm of the vector database, establish a quantizer where the Voronoi unit is located for each entity vector in the search space, establish a clustering vector index on the trained entity vector, and build an entity vector index library for incomplete temporal knowledge graphs to complete the incomplete temporal knowledge graphs;
[0035] The temporal knowledge graph query module is used to establish a query vector set and an entity answer set containing time information based on the temporal knowledge graph vector output by the temporal knowledge graph embedding model, and to establish an approximate search mapping between the query vector and the entity answer vector using a similarity algorithm based on the entity vector index library, so as to realize approximate query of the temporal knowledge graph supported by the vector index.
[0036] Accordingly, the present application also discloses a terminal, including a processor and a storage medium;
[0037] The storage medium is used to store instructions;
[0038] The processor is used to operate according to the instructions to execute the steps of the temporal knowledge graph search method supported by the aforementioned vector index.
[0039] Correspondingly, the present application also discloses a computer-readable storage medium on which a computer program is stored, which, when executed by a processor, implements the steps of the aforementioned vector index-supported temporal knowledge graph search method.
[0040] The beneficial effect of the present invention lies in that, compared with the prior art, the present invention provides a temporal knowledge graph search method and system supported by a vector index, which establishes a vector index library on the basis of completing the incomplete temporal knowledge graph, significantly improves the search efficiency on the temporal knowledge graph, and can accelerate the query process while ensuring the search accuracy, providing strong support for the search and reasoning tasks of dynamic temporal knowledge graphs. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 It is a flowchart of the temporal knowledge graph search method supported by vector index in the present invention.
[0042] Figure 2 The figure is the overall architecture diagram of the method of the present invention.
[0043] Figure 3 It is a time-relationship joint representation graph. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solution and advantages of the present invention more clear, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0045] The embodiments described in this application are only some embodiments of the present invention, not all embodiments. Based on the spirit of the present invention, other embodiments obtained by ordinary technicians in this field without creative work are all within the protection scope of the present invention.
[0046] In view of the shortcomings of the prior art, the present invention proposes a temporal knowledge graph search method and system supported by vector index, which jointly encodes entity, relationship and time information into vector space, and uses long short-term memory neural network (LSTM) to learn the time perception information of relationship type, and uses vector database to establish a vector index library (IndexIVFFlat) of large-scale TKG. The index library divides the search space by clustering operation, thereby greatly reducing the search complexity. The establishment of the vector index library greatly improves the search efficiency on TKG, and can accelerate the query process while ensuring the accuracy of the search, providing strong support for the search and reasoning tasks of dynamic TKG. First, the incomplete temporal knowledge graph is completed by using the temporal knowledge graph embedding model, and a clustering vector index library (IndexIVFFlat) is established on the trained entity vector, so as to effectively organize and manage the entity vector, and provide efficient query and reasoning capabilities; then, the temporal knowledge graph approximate query supported by vector index is realized, and the trained entity vector and time-relation vector are composed of a query vector set, and an efficient approximate query algorithm is established by using the vector index library (IndexIVFFlat). This query method combines vector similarity calculation and index search technology to quickly locate entity sets similar to the query vector.
[0047] See also Figure 1 As shown, the temporal knowledge graph search method supported by vector index disclosed in the present invention includes the following steps:
[0048] Step 1: Use the temporal knowledge graph embedding model to train entity vectors, divide the entity vectors into different search spaces according to the clustering algorithm of the vector database, establish a quantizer for the Voronoi unit for the entity vector in each search space, establish a clustering vector index on the trained entity vector, and build an entity vector index library for incomplete temporal knowledge graphs to complete the incomplete temporal knowledge graphs.
[0049] The step 1 further comprises:
[0050] Step 1.1: Generate a fully trained temporal knowledge graph vector database based on the temporal knowledge graph embedding model; the initial stage of the vector database includes the vectorized representation of head entities, tail entities, relations and time, and the completion stage includes using long short-term memory neural networks to learn the time-aware representation of relationship types, thereby obtaining a vector database of fully trained entity vectors and time-relationship vectors.
[0051] Step 1.2: Use the vector database to build an efficient entity vector index library (IndexIVFFlat). The input of IndexIVFFlat is a set of all entity vectors that have been trained. At the same time, a clustering algorithm is used to divide all entity vectors into multiple Voronoi cells, and each entity vector falls into one of the cells. During the search, only the entity vector contained in the cell where the query vector is located is compared with a few adjacent query vectors, that is, the search space is divided.
[0052] Step 1.3: Based on the index library IndexIVFFlat, another index IndexFlatL2, i.e., a quantizer, is constructed to assign entity vectors to Voronoi cells. Each cell is defined by a centroid, and finding the Voronoi cell where a vector is located includes finding the nearest neighbor of the vector in the centroid set.
[0053] Step 2: According to the temporal knowledge graph vector output by the temporal knowledge graph embedding model, a query vector set and an entity answer set containing time information are established. Based on the entity vector index library, an approximate search mapping between the query vector and the entity answer vector is established using a similarity algorithm to implement approximate query of the temporal knowledge graph supported by vector index.
[0054] The step 2 further comprises:
[0055] Step 2.1: Use the well-trained temporal knowledge graph vector database to build a query set and answer set containing time information. Each query vector in the query set consists of a vector of an entity vector and its corresponding time-relation vector. The answer set consists of all well-trained entity vectors output by the temporal knowledge graph embedding model.
[0056] Step 2.2: Based on the entity vector index library IndexIVFFlat and the query vector and answer vector database, an approximate query combining vector similarity calculation and index search technology is established. Based on the given number of centroids, for each query vector, its distance to the given number of centroids is first calculated, and then the top-N Voronoi cells with the closest distance are selected. Only the distance between the query vector and the entity answer vector within the N Voronoi cells is calculated, and the distance and index closest to the answer vector are returned. Among them, the distance calculation uses the Euclidean distance calculated by similarity.
[0057] The overall flow chart of the present invention is as follows: Figure 2 shown. Figure 3 Represents the joint encoding of time and relationship.
[0058] The temporal knowledge graph embedding model adopts the following time-aware representation. Given a temporal knowledge graph triple, it is expanded to (s, r, o, t) with time information t, where s is the head entity, r is the relationship, and o is the tail entity. The given time is decomposed into a sequence consisting of the following time tags:
[0059]
[0060] Among them, year, month and day represent the year, month and day of a given time respectively. The vocabulary size of the tense tags is 32 in total. In addition, for each triple, a relation tag sequence can be extracted, which consists of a relation type tag and a tense modifier tag.
[0061] In LSTM-based time series encoding, the union of the relational sequence (s, r, o, t) and the time series is called the time-relational sequence r t Therefore, the temporal knowledge graph triple is represented as (s,r t ,o) triples, where the relation sequence r t (i.e., time-relation vector embedding) can include time information, and its calculation method will be described in detail below. Based on the time series tags defined above, namely year, month and day, they are used as the input of the long short-term memory neural network. Figure 3 shown.
[0062] Long short-term memory (LSTM) is suitable for modeling sequence data, and the formula is:
[0063]
[0064] Where i, f, o and g are the input, forget, output and input modulation gates respectively. n and h nare the nth unit and hidden state respectively. U and W are weight matrices, where W connects the input of the current time step to each gate; U connects the hidden state of the previous time step to each gate. All vectors are in is the representation of the nth element of the sequence. Set h = d (the dimension of the input vector), σ g , σ c and σ h is the activation function.
[0065] Relation sequence r t Each token of is first mapped to its corresponding d-dimensional embedding through a linear layer, and the resulting embedding sequence is used as the input of the LSTM. Each relation sequence of length N is represented by the last hidden state of the LSTM, i.e., r t =h N . Define the time-relation vector embedding as:
[0066] r t (r,t)=LSTM(r,t)
[0067] Among them, r t Represents a sequence of time-relation vectors.
[0068] The scoring function embedded in the temporal knowledge graph carries the relational sequence representation of time information and can be combined with the subject and object embedding in the classic scoring function:
[0069]
[0070] Where q represents the query vector and e represents the entity vector. All parameters of the scoring function are learned together with the parameters of LSTM using stochastic gradient descent. L2 represents the 2-norm.
[0071] The corresponding loss function is defined as:
[0072]
[0073] Among them, (s,r t ,o)∈ξ,(s',r t ,o),(s,r t ,o')∈ξ' are positive and negative samples of temporal triples respectively. γ>0 indicates the interval hyperparameter.
[0074] In order to speed up the search, the well-trained entity vector database can be clustered to divide the search space. Voronoi cells are defined in the d-dimensional vector space, and each entity vector falls into one of the cells. When searching, only the entity vectors contained in the cell where the query vector is located are compared with a few adjacent query vectors. Thus, an efficient entity vector index library IndexIVFFlat is established.
[0075] The IndexIVFFlat index is trained using the function train(), which is performed on any set of vectors with the same distribution as the entity vector. At the same time, the index also requires another index IndexFlatL2, the quantizer, which assigns the entity vector to the Voronoi cell. Each cell is defined by a centroid, and finding the Voronoi cell where an entity vector is located consists of finding the nearest neighbor of the entity vector in the set of centroids.
[0076] Based on the output of the above temporal knowledge graph embedding model, the entity vector set is input into the index library, and the entity index is defined as:
[0077]
[0078] Among them, quantizer represents the quantizer. d represents the dimension of the embedded entity vector. add() represents adding the id of the entity vector set to the constructed index library so that the entity vector and the corresponding index correspond to each other. nlist represents the number of division units, that is, the number of cluster centers.
[0079] Use the IndexIVFFlat index library to perform approximate search. Given a temporal knowledge graph query vector q, and set the top k most similar entity vectors to be returned, the approximate search is defined as:
[0080]
[0081] Where nprobe represents the number of cells visited during the search. Distance and Index represent the distance and index of the top_k most similar vectors returned, respectively.
[0082] When using the IndexIVFFlat index structure, nlist and nprobe are two key parameters, and appropriate values need to be selected according to specific application requirements. nprobe is a way to adjust search efficiency and accuracy. When nprobe=nlist, the search method has the same result as the brute force search. The value of nlist can be set to about the square root of the data set size. For larger data sets, the value of nlist can be increased to improve the accuracy of search results. The best value is found by tuning according to the size and distribution of features of different data sets. In a preferred embodiment, nprobe is set to a smaller ratio of nlist, for example, nlist / 10 or nlist / 20. For larger data sets or situations where higher search accuracy is required, the value of nprobe can be appropriately increased. Increasing the value of nprobe will increase the computational and memory access overhead of the search, which may result in longer search times, so a trade-off needs to be made based on specific performance requirements and resource constraints.
[0083] The beneficial effect of the present invention lies in that, compared with the prior art, the present invention provides a temporal knowledge graph search method and system supported by a vector index, which establishes a vector index library on the basis of completing the incomplete temporal knowledge graph, significantly improves the search efficiency on the temporal knowledge graph, and can accelerate the query process while ensuring the search accuracy, providing strong support for the search and reasoning tasks of dynamic temporal knowledge graphs.
[0084] The present invention may be a system, a method and / or a computer program product. The present invention also discloses a vector index supported temporal knowledge graph search system based on the above-mentioned vector index supported temporal knowledge graph search method, comprising:
[0085] The temporal knowledge graph completion module is used to train entity vectors using the temporal knowledge graph embedding model, divide the entity vectors into different search spaces according to the clustering algorithm of the vector database, establish a quantizer where the Voronoi unit is located for each entity vector in the search space, establish a clustering vector index on the trained entity vector, and build an entity vector index library for incomplete temporal knowledge graphs to complete the incomplete temporal knowledge graphs;
[0086] The temporal knowledge graph query module is used to establish a query vector set and an entity answer set containing time information based on the temporal knowledge graph vector output by the temporal knowledge graph embedding model, and to establish an approximate search mapping between the query vector and the entity answer vector using a similarity algorithm based on the entity vector index library, so as to realize approximate query of the temporal knowledge graph supported by the vector index.
[0087] Based on the spirit of the present invention, those skilled in the art can easily think that a computer program product can be obtained based on the temporal knowledge graph search method supported by the aforementioned vector index. The computer program product may include a computer-readable storage medium, which carries computer-readable program instructions for enabling a processor to implement various aspects of the present disclosure. That is, the present application also includes a terminal, including a processor and a storage medium; the storage medium is used to store instructions; the processor is used to operate according to the instructions to execute the steps of the temporal knowledge graph search method supported by the aforementioned vector index.
[0088] Computer readable storage medium can be a tangible device that can keep and store the instructions used by the instruction execution device. Computer readable storage medium can be, for example, - but not limited to - electrical storage device, magnetic storage device, optical storage device, electromagnetic storage device, semiconductor storage device or any suitable combination of the above. More specific examples (non-exhaustive list) of computer readable storage medium include: portable computer disk, hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disk read-only memory (CD-ROM), digital versatile disk (DVD), memory stick, floppy disk, mechanical encoding device, for example, punch card or groove protrusion structure with instructions stored thereon and any suitable combination of the above. Computer readable storage medium used here is not interpreted as instantaneous signal itself, such as radio wave or other free propagating electromagnetic wave, electromagnetic wave propagated by waveguide or other transmission medium (for example, light pulse by optical fiber cable) or electrical signal transmitted by wire.
[0089] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0090] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages-such as Smalltalk, C++, etc., and conventional procedural programming languages-such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network-including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA) may be personalized by utilizing the state information of a computer-readable program instruction, and the electronic circuit may execute a computer-readable program instruction, thereby realizing various aspects of the present disclosure.
[0091] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents, and any modifications or equivalent replacements that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A temporal knowledge graph search method supported by vector index, characterized in that: The following steps are involved: The entity vectors are trained using the temporal knowledge graph embedding model. The entity vectors are divided into different search spaces according to the clustering algorithm of the vector database. A quantizer for the Voronoi unit is established for each entity vector in the search space. A clustering vector index is established on the trained entity vector. An entity vector index library for incomplete temporal knowledge graphs is constructed to complete the incomplete temporal knowledge graphs. According to the temporal knowledge graph vector output by the temporal knowledge graph embedding model, a query vector set and an entity answer set containing time information are established. Based on the entity vector index library, an approximate search mapping between the query vector and the entity answer vector is established using a similarity algorithm to implement approximate query of the temporal knowledge graph supported by vector index.
2. The temporal knowledge graph search method supported by vector index according to claim 1, characterized in that: The method of using the temporal knowledge graph embedding model to train entity vectors, dividing the entity vectors into different search spaces according to the clustering algorithm of the vector database, establishing a quantizer where the Voronoi unit is located for each entity vector in the search space, establishing a clustering vector index on the trained entity vector, and constructing an entity vector index library for the incomplete temporal knowledge graph further includes: Generate a fully trained temporal knowledge graph vector database based on the temporal knowledge graph embedding model; the initial stage of the vector database includes the vectorized representation of the head entity, tail entity, relationship and time, and uses the long short-term memory neural network to learn the time-aware representation of the relationship type, thereby obtaining a fully trained vector database of entity vectors and time-relationship vectors; An efficient entity vector index library is constructed by using the vector database. The input of the entity vector index library is a set of all entity vectors that have been trained completely. All entity vectors are divided into multiple Voronoi cells by using a clustering algorithm, and each entity vector falls into one of the cells. During the search, only the entity vector contained in the cell where the query vector is located is compared with the adjacent query vector. Another index, namely a quantizer, is constructed based on the entity vector index library to assign entity vectors to Voronoi cells, each cell being defined by a centroid, and finding the Voronoi cell where a vector is located includes finding the nearest neighbor of the vector in the set of centroids.
3. The temporal knowledge graph search method supported by vector index according to claim 2 is characterized in that: The method of learning a time-aware representation of a relationship type using a long short-term memory neural network further comprises: Given a temporal knowledge graph triple, it is expanded to (s, r, o, t) with time information t, where s is the head entity, r is the relationship, and o is the tail entity. The temporal knowledge graph triple is represented as (s, r t ,o) triples, where the relation sequence r t Includes temporal information, used as input to long short-term memory neural networks; The relationship sequence r t Each token of is first mapped to its corresponding d-dimensional embedding through a linear layer, and the resulting embedding sequence is used as the input of the LSTM. Each relation sequence of length N is represented by the last hidden state of the LSTM, i.e., r t =h N ; Define the time-relation vector embedding as: r t (r,t)=LSTM(r,t) The scoring function embedded in the temporal knowledge graph carries the relational sequence representation of time information: Where q represents the query vector, e represents the entity vector, and all parameters of the scoring function are learned together using stochastic gradient descent and LSTM parameters. L2 represents the 2-norm. The corresponding loss function is defined as: Among them, (s,r t ,o)∈ξ,(s',r t ,o),(s,r t ,o')∈ξ' are the positive and negative samples of the temporal triples respectively, and γ>0 represents the interval hyperparameter.
4. The temporal knowledge graph search method supported by vector index according to claim 3 is characterized in that: The method of establishing an approximate search mapping between a query vector and an entity answer vector based on the entity vector index library by using a similarity algorithm to implement an approximate query of a temporal knowledge graph supported by a vector index further includes: A query set and an answer set containing time information are constructed using a well-trained temporal knowledge graph vector database. Each query vector in the query set consists of a vector of an entity vector and its corresponding time-relation vector. The answer set consists of all well-trained entity vectors output by the temporal knowledge graph embedding model. Based on the entity vector index library and the query vector and answer vector database, an approximate query combining vector similarity calculation and index search technology is established; based on a given number of centroids, for each query vector, its distance to the given number of centroids is first calculated, and then the first N nearest Voronoi cells are selected, and only the distance between the query vector and the entity answer vector within the N Voronoi cells is calculated, and the distance and index closest to the answer vector are returned.
5. The temporal knowledge graph search method supported by vector index according to claim 4 is characterized in that: The method of establishing an approximate query combining vector similarity calculation and index search technology based on the entity vector index library and the query vector and answer vector database further includes: Based on the output of the temporal knowledge graph embedding model, the entity vector set is input into the index library, and the entity index is defined as: Among them, quantizer represents the quantizer, d represents the dimension of the embedded entity vector, add() represents adding the id of the entity vector set to the constructed index library so that the entity vector and the corresponding index correspond to each other, and nlist represents the number of division units, that is, the number of cluster centers.
6. A temporal knowledge graph search system supported by vector index, characterized in that: include: The temporal knowledge graph completion module is used to train entity vectors using the temporal knowledge graph embedding model, divide the entity vectors into different search spaces according to the clustering algorithm of the vector database, establish a quantizer where the Voronoi unit is located for each entity vector in the search space, establish a clustering vector index on the trained entity vector, and build an entity vector index library for incomplete temporal knowledge graphs to complete the incomplete temporal knowledge graphs; The temporal knowledge graph query module is used to establish a query vector set and an entity answer set containing time information based on the temporal knowledge graph vector output by the temporal knowledge graph embedding model, and to establish an approximate search mapping between the query vector and the entity answer vector using a similarity algorithm based on the entity vector index library, so as to realize approximate query of the temporal knowledge graph supported by the vector index.
7. The temporal knowledge graph search system supported by vector index according to claim 6, characterized in that: The temporal knowledge graph completion module is further used to: Generate a fully trained temporal knowledge graph vector database based on the temporal knowledge graph embedding model; the initial stage of the vector database includes the vectorized representation of the head entity, tail entity, relationship and time, and uses the long short-term memory neural network to learn the time-aware representation of the relationship type, thereby obtaining a fully trained vector database of entity vectors and time-relationship vectors; An efficient entity vector index library is constructed by using the vector database. The input of the entity vector index library is a set of all entity vectors that have been trained completely. All entity vectors are divided into multiple Voronoi cells by using a clustering algorithm, and each entity vector falls into one of the cells. During the search, only the entity vector contained in the cell where the query vector is located is compared with the adjacent query vector. Another index, namely a quantizer, is constructed based on the entity vector index library to assign entity vectors to Voronoi cells, each cell being defined by a centroid, and finding the Voronoi cell where a vector is located includes finding the nearest neighbor of the vector in the set of centroids.
8. The temporal knowledge graph search system supported by vector index according to claim 7, characterized in that: The temporal knowledge graph completion module is further used to: Given a temporal knowledge graph triple, it is expanded to (s, r, o, t) with time information t, where s is the head entity, r is the relationship, and o is the tail entity. The temporal knowledge graph triple is represented as (s, r t ,o) triples, where the relation sequence r t Includes temporal information, used as input to long short-term memory neural networks; The relationship sequence r t Each token of is first mapped to its corresponding d-dimensional embedding through a linear layer, and the resulting embedding sequence is used as the input of the LSTM. Each relation sequence of length N is represented by the last hidden state of the LSTM, i.e., r t =h N ; Define the time-relation vector embedding as: r t (r,t)=LSTM(r,t) The scoring function embedded in the temporal knowledge graph carries the relational sequence representation of time information: Where q represents the query vector, e represents the entity vector, and all parameters of the scoring function are learned together using stochastic gradient descent and LSTM parameters. L2 represents the 2-norm. The corresponding loss function is defined as: Among them, (s,r t ,o)∈ξ,(s',r t ,o),(s,r t ,o')∈ξ' are the positive and negative samples of the temporal triples respectively, and γ>0 represents the interval hyperparameter.
9. The temporal knowledge graph search system supported by vector index according to claim 8, characterized in that: The temporal knowledge graph query module is further used to: A query set and an answer set containing time information are constructed using a well-trained temporal knowledge graph vector database. Each query vector in the query set consists of a vector of an entity vector and its corresponding time-relation vector. The answer set consists of all well-trained entity vectors output by the temporal knowledge graph embedding model. Based on the entity vector index library and the query vector and answer vector database, an approximate query combining vector similarity calculation and index search technology is established; based on a given number of centroids, for each query vector, its distance to the given number of centroids is first calculated, and then the first N nearest Voronoi cells are selected, and only the distance between the query vector and the entity answer vector within the N Voronoi cells is calculated, and the distance and index closest to the answer vector are returned.
10. The temporal knowledge graph search system supported by vector index according to claim 9, characterized in that: The temporal knowledge graph query module is further used to: Based on the output of the temporal knowledge graph embedding model, the entity vector set is input into the index library, and the entity index is defined as: Among them, quantizer represents the quantizer, d represents the dimension of the embedded entity vector, add() represents adding the id of the entity vector set to the constructed index library so that the entity vector and the corresponding index correspond to each other, and nlist represents the number of division units, that is, the number of cluster centers.
11. A terminal comprising a processor and a storage medium; characterized in that: The storage medium is used to store instructions; The processor is used to operate according to the instructions to execute the steps of the temporal knowledge graph search method supported by vector indexes according to any one of claims 1-5.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the temporal knowledge graph search method supported by vector indexes described in any one of claims 1 to 5 are implemented.