Question and answer method and device, electronic equipment and medium
By initializing vectors in real and complex space, constructing a mapping matrix, and interacting with complex vectors, the dimension allocation problem in TComplEx representation learning technology is solved, the ability to capture temporal evolution features is improved, and more accurate question-answering results are achieved.
Patent Information
- Application Number
- CN202511459547.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-13
- Publication Date
- 2026-02-03
AI Technical Summary
In existing technologies, TComplEx representation learning technology places relations and entities in the same vector space, which makes it difficult to balance the semantic accuracy of both sides in dimensional allocation, affecting the ability to capture complex temporal knowledge, and failing to fully capture temporal semantic features and relational semantic features when processing problem statements.
By initializing entity, relation, and time vectors in the real and complex spaces respectively, a mapping matrix is constructed to map entities to the relation space in the corresponding time. The temporal evolution of relations is simulated by the interaction of complex vectors to generate the target vector. The answer to the problem is determined by combining a multi-head attention mechanism and a graph convolutional network to enhance the use of temporal information.
It effectively distinguishes the semantic space between entities and relationships, enhances the capture of temporal evolution features, improves the understanding and reasoning ability of questions containing time information, and achieves more accurate question-and-answer results.
Smart Images

Figure CN121456087A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, specifically to a question-answering method, apparatus, electronic device, and medium. Background Technology
[0002] The essence of temporal knowledge graph representation learning technology is to determine the vector representations of multiple elements in the graph. Its core objective is to map the relationships and entities in the graph to a continuous, low-dimensional, and dense vector space, while simultaneously utilizing temporal information to capture the dynamic evolution of entities and relationships over time, reducing mutual interference between entity representations. Question answering methods based on this technology integrate temporal knowledge graph representation learning with natural language processing techniques, aiming to accurately extract information from the graph and answer questions about entities, relationships, and their changes over time.
[0003] The relevant technologies employ TComplEx representation learning to obtain vector representations of entities, relations, and time information in temporal knowledge graphs, and combine them with natural language processing technology to improve problem reasoning ability and interpretability from the perspective of reasoning path.
[0004] However, TComplEx representation learning techniques place relations and entities in the same vector space. The dimensionality allocation of the same space can limit the accuracy of semantic representation of both parties, thus affecting the ability to capture complex temporal knowledge when determining the answer to a question statement. Summary of the Invention
[0005] This application provides a question-and-answer method, apparatus, electronic device, and medium to address the issue of low security in question-and-answer systems in related technologies, significantly improve the security of gesture-based question-and-answer systems in metaverse trading scenarios, and reduce the risk of property loss due to misoperation or device theft.
[0006] In a first aspect, embodiments of this application provide a question-answering method, which includes: initializing multiple elements in a temporal knowledge graph into vectors in real and complex space to obtain real vectors and complex vectors, where the multiple elements include entities, relations, and time; the real vectors include entity real vectors, relation real vectors, and time real vectors; and the complex vectors include relation complex vectors and time complex vectors; mapping the entity real vectors and relation real vectors based on the time real vectors to construct a mapping matrix; determining target vectors for multiple elements in the temporal knowledge graph based on the mapping matrix, the relation complex vectors, and the time complex vectors, where the target vectors are vectors represented by complex numbers; and determining the question answer corresponding to the question statement based on the target vectors of the multiple elements when a question statement is obtained.
[0007] Secondly, embodiments of this application provide a question-and-answer device, the device comprising: An initialization unit is used to initialize multiple elements in a time-series knowledge graph in real and complex space to obtain real vectors and complex vectors. The multiple elements include entities, relations, and time. The real vectors include entity real vectors, relation real vectors, and time real vectors. The complex vectors include relation complex vectors and time complex vectors. The mapping unit is used to map the entity real vector and the relation real vector according to the time real vector to construct a mapping matrix; The first determining unit is used to determine the target vector of multiple elements in the time-series knowledge graph based on the mapping matrix, the relational complex vector and the time complex vector in the complex vector, wherein the target vector is a vector represented by a complex number; The second determining unit is used to determine the answer to the question statement based on the target vector of the plurality of elements when the question statement is obtained.
[0008] Thirdly, embodiments of this application provide an electronic device, including: a processor and a memory for storing a computer program capable of running on the processor, wherein, when the processor runs the computer program, it performs the method described in any embodiment of the first aspect.
[0009] Fourthly, embodiments of this application provide a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause a computer to perform the methods described in any embodiment of the first aspect.
[0010] Fifthly, embodiments of this application provide a computer program product including a computer program that, when executed by a processor, performs the method described in any embodiment of the first aspect.
[0011] This application provides a question-answering method that initializes entities, relations, and time into vectors in real and complex number spaces respectively. It then constructs a mapping matrix using the real number time vector to map entities to the relation space. By combining the interaction of complex number vectors, it obtains complex target vectors for each element. This effectively distinguishes the semantic spaces of entities and relations, enhances the capture of temporal evolution features, and improves the understanding and reasoning ability of questions containing time information when determining the answer to a question statement. This allows for more accurate acquisition of question answers from a temporal knowledge graph.
[0012] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0013] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are merely embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort, and this application can be applied to other similar scenarios based on the provided drawings.
[0014] Figure 1 A flowchart illustrating a question-and-answer method provided in an embodiment of this application; Figure 2 A flowchart illustrating the second question-and-answer method provided in this application embodiment; Figure 3 A schematic diagram illustrating a specific method for determining a target vector, as provided in an embodiment of this application; Figure 4 A flowchart illustrating the third question-and-answer method provided in this application embodiment; Figure 5 A schematic diagram of a specific problem characterization module provided in an embodiment of this application; Figure 6 A schematic diagram of a specific timing feature unit provided in an embodiment of this application; Figure 7 A schematic diagram of a specific question-and-answer system provided in this application embodiment; Figure 8 This application provides a schematic diagram illustrating a specific method for building a question-and-answer system. Figure 9 A schematic diagram of the structure of a question-and-answer device 900 provided in an embodiment of this application; Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0015] The present application will now be described in further detail with reference to the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. The described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0016] It should be noted that the terms "system," "device," "unit," and / or "module" used in this application are methods of distinguishing different components, elements, parts, sections, or assemblies at different levels. However, if other terms can achieve the same purpose, they can be replaced by other expressions.
[0017] Hereinafter, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first," "second," or "third" may explicitly or implicitly include one or more of that feature.
[0018] The essence of temporal knowledge graph representation learning technology is to determine the vector representation of multiple elements in a temporal knowledge graph. Its core objective is to map the relationships and entities in the graph to a continuous, low-dimensional, and dense vector space. Simultaneously, it fully utilizes temporal information to capture the dynamic evolution of entities and relationships over time, thereby reducing mutual interference between entity representations.
[0019] This question-answering method, based on temporal knowledge graphs, integrates temporal knowledge graph representation learning techniques with natural language processing techniques. The method aims to accurately extract information from temporal knowledge graphs to answer questions about entities, relationships, and their changes over time.
[0020] In related technologies, TComplEx representation learning technology is used to obtain vector representations of entities, relations and time information in temporal knowledge graphs. Combined with natural language processing technology, it improves problem reasoning ability and enhances interpretability from the perspective of reasoning path.
[0021] However, the TComplEx representation learning technique used in these technologies has certain limitations. Specifically, this technique represents relations and entities in the same vector space. This approach makes it difficult to balance the dimensionality allocation of the same space with the needs of both, thus limiting the accuracy of the semantic representation of relations and entities. Limited semantic representation accuracy ultimately affects the ability to capture complex temporal knowledge, making it difficult to accurately grasp the complex temporal information when determining the answer to a question. Furthermore, these technologies also suffer from insufficient capture of temporal and relational semantic features when processing question statements.
[0022] To address the problems in the aforementioned related technologies, this application first maps entities in the real vector space to the corresponding temporal relation vector space by constructing a mapping matrix. Then, the mapped entities, relations, and temporal information are represented in the complex vector space. Simultaneously, the temporal evolution of the relation representation is defined as a rotation in the complex vector space from the initial time to the current time. Finally, the vector representations of the entities, relations, and temporal information (i.e., the target vector of this application) are obtained. Upon receiving a question statement, techniques such as multi-head attention, graph convolution, graph attention, and convolutional neural networks are used to enhance the application of temporal information, thereby deriving the answer to the question.
[0023] The question-and-answer method provided in this application will be described in detail below with reference to the accompanying drawings.
[0024] Figure 1 A flowchart of a question-and-answer method provided in an embodiment of this application is shown. Figure 1 As shown, the question-and-answer method includes steps 101-104.
[0025] Step 101: Initialize multiple elements in the time-series knowledge graph into vectors in the real space and complex space to obtain real vectors and complex vectors.
[0026] In this application, multiple elements include entities, relations, and time. Real vectors include entity real vectors, relation real vectors, and time real vectors. Complex vectors include relation complex vectors and time complex vectors.
[0027] In the embodiments of this application, a temporal knowledge graph refers to a knowledge graph containing time-dimensional information. Its core storage unit is a quadruple, and each quadruple consists of a head entity, a tail entity, a relation, and time (e.g., "Zhang San (head entity) works for (relation) Company A (tail entity) 2020 (time)"). It is used to record the relationships between entities that change over time. The entity includes a head entity and a tail entity; therefore, the "multiple elements" in this application refer to the head entity, tail entity, relation, and time contained in the quadruple of the temporal knowledge graph.
[0028] Entities refer to the core elements in a time-series knowledge graph (such as people, organizations, and locations, e.g., "Zhang San" and "Company A"); relationships refer to the types of associations between entities (such as "employed at" and "located in"); and time refers to the point in time or period during which the relationship between entities occurs or exists (such as "2020").
[0029] Vector initialization in this application refers to converting non-numerical elements (entities, relations, time) into low-dimensional dense vectors (real or complex numbers) to facilitate computer processing and modeling of semantic features.
[0030] Real vectors are vectors whose elements are real numbers. They are used for auxiliary operations such as constructing mapping matrices, including: entity real vectors, relational real vectors, and time real vectors.
[0031] Entity real vectors refer to the representation of entities in the real number space, including entity mapping vectors used to construct mapping matrices, as well as entity semantic vectors used to capture core semantics, namely head entity semantic vectors, head entity mapping vectors, tail entity semantic vectors, and tail entity mapping vectors; relation real vectors refer to the representation of relations in the real number space, used to construct mapping matrices; time real vectors are the representation of time in the real number space, used to construct mapping matrices.
[0032] Complex vectors are vectors whose elements are complex numbers (including real and imaginary parts). They are used to capture core semantic features and include: relational complex vectors and temporal complex vectors. Relational complex vectors represent relations in complex space and are used to characterize the core semantics of relations; temporal complex vectors represent time in complex space and are used to characterize the core semantics and evolutionary features of time.
[0033] In one optional embodiment of this application, the head entity, tail entity, relation, and time information in the temporal knowledge graph quadruple can be vector-initialized: Specifically, the head entity is represented by two vectors h. The meaning of the entity captured by h is indicated. Used to construct mapping matrices, all are represented in the real number space. .
[0034] The tail entity is represented by two vectors t. The meaning of 't' is to be represented as 't'. Used to construct mapping matrices, all are represented in the real number space. .
[0035] The relation is represented by two vectors r. The representation is given by r, which captures the meaning of the relation, and represents it in the complex space. . Used to construct a mapping matrix, representing the real number space. .
[0036] Use time information as a vector , To express, The meaning of capturing time information is that in complex space, . Used to construct a mapping matrix, representing the real number space. .
[0037] Step 102: Based on the real vector of time, map the real vector of entities and the real vector of relations to construct a mapping matrix.
[0038] In the embodiments of this application, the element-wise product refers to the element-wise multiplication of the entity real vector and the relation real vector of the corresponding dimension (i.e., the Hadamard product), and the result is a real vector of the same dimension, which is used to fuse the real space features of entities and relations.
[0039] The transposed element-wise product refers to transposing the element-wise product vector (transforming a row vector into a column vector), so that the dimension of the subsequent vector changes from (1, d) to (d, 1) (d is the vector dimension), which prepares for subsequent matrix multiplication.
[0040] A real number mapping matrix is a matrix obtained by multiplying the element-wise product of a time real number vector and its transpose. It is used to map an entity from its own real number space to the relational real number space at the corresponding time. The dimension is (d, d) (where d is the vector dimension).
[0041] This application can calculate the element-wise product of the entity real vector and the relation real vector, achieving preliminary feature fusion of entities and relations in the real space and highlighting their correlation characteristics. Then, multiplying the time real vector by the element-wise product of its transpose essentially uses time features to weight and modulate the fused features of entities and relations, enabling the mapping matrix to carry specific time information and ensuring that subsequent entity mappings can adapt to the relation space at that time. The final real-number mapping matrix encodes the association between entities, relations, and time in the real space, "transforming" entities from their own space to the corresponding time-based relation space, thus solving the problem of adapting entities and relations in different spaces.
[0042] It is understandable that, since the entity includes a head entity and a tail entity, this application needs to construct a mapping matrix for the head entity based on the real vector of the head entity (specifically, the mapping vector of the head entity), and also needs to construct a mapping matrix for the tail entity based on the real vector of the tail entity (specifically, the mapping vector of the tail entity). That is, the real mapping matrix of this application includes the real mapping matrix of the head entity and the real mapping matrix of the tail entity.
[0043] Specifically, in one optional embodiment of this application, the head entity mapping vector used to construct the head entity mapping matrix is... First, use the relational real vectors to construct the mapping matrix. The interaction occurs through the element-wise product of corresponding vectors. To achieve this.
[0044] Will transpose and time real vector Multiply to construct the real number mapping matrix of the head entity. At the same time, an identity matrix is required. Initialize each mapping matrix. Then construct the real mapping matrix for the tail entity in the same manner. The formulas for calculating the two real number mapping matrices are as follows: , ; in, The real number mapping matrix of the head entity. It is a real vector of time. Let them be a real vector of relations. The head entity mapping vector is the real number vector of entities. The tail entity mapping vector in the real entity vector. is the real number mapping matrix of the tail entity.
[0045] Step 103: Based on the mapping matrix, the relational complex vector and the temporal complex vector in the complex vector, determine the target vector of multiple elements in the time-series knowledge graph. The target vector is a vector represented by a complex number.
[0046] In the embodiments of this application, the target vector includes a target time vector, a target entity vector, and a target relationship vector.
[0047] The target vector refers to the final complex representation vector obtained after processing each element (entity, relation, time) in the temporal knowledge graph. It is the core basis for subsequent question-answering reasoning and includes the target entity vector, target relation vector, and target time vector.
[0048] A target entity vector is a vector representing an entity (head entity, tail entity) after being transformed into a complex number representation using a mapping matrix. It is used to characterize the entity's association with a specific time and relationship in complex space. Target entity vectors include target head entity vectors and target tail entity vectors.
[0049] The target relation vector is the vector obtained by interacting the complex vector of the relation with the complex vector of time (such as the Hadamard product), which integrates the core semantics of the relation with the temporal evolution characteristics.
[0050] The target time vector refers to the core representation vector of time in complex space. It directly serves as the final complex representation of time features and is used to reflect the impact of the time dimension on entities and relationships.
[0051] This application can map entities from the real number space to the relational real number space under the corresponding time by using the head entity and tail entity mapping matrix obtained above. Then, the mapped real number vector is split into real and imaginary parts and converted into complex form to obtain the target entity vector. This realizes the crossing of entities from their own space to the relational and temporal association space to adapt to the complex characteristics of relations and time. At the same time, the relational complex vector and the temporal complex vector interact through element-wise product and other methods. By using the complex rotation properties, the dynamic changes of relations over time are simulated to generate a target relation vector that integrates time information. The temporal complex vector is directly reused as the target time vector to retain the time constraint effect.
[0052] Through the above processing, the target vector of this application unifies the representation of entities, relations and time in complex space, which not only preserves the independent characteristics of each element, but also strengthens the dynamic relationship among the three through spatial mapping and complex interaction, providing a precise vector foundation for subsequent question-answering reasoning based on temporal features.
[0053] Step 104: When the question statement is obtained, the answer to the question statement is determined based on the target vector of multiple elements.
[0054] In embodiments of this application, a question statement refers to an unanswered question entered by the user (such as "Where did Zhang San work in 2020?"), which may include entities, relationships, and time.
[0055] The target vector with multiple elements refers to the target entity vector (head entity, tail entity), target relation vector, and target time vector obtained in step 103. It is the final representation of each element in the temporal knowledge graph in the complex space.
[0056] The answer to the question is the result that matches the question statement (such as "Company A") selected from the time-series knowledge graph, which usually corresponds to a certain element in the quadruple (such as the tail entity or the head entity).
[0057] This application utilizes target vectors to establish a connection between questions and knowledge graphs, enabling temporal question-answering reasoning. Through the semantic association of target vectors, it achieves a precise understanding of the temporal information in the question, efficiently matches natural language questions with dynamic associations in the knowledge graph, and ultimately outputs an answer that conforms to temporal logic.
[0058] In summary, the question-answering method proposed in this application initializes entities, relations, and time into vectors in real and complex number spaces respectively. A mapping matrix is constructed using the real number time vector to realize the mapping from entity to relation space. The complex target vectors of each element are obtained by interaction with the complex number vectors. This effectively distinguishes the semantic spaces of entities and relations, enhances the capture of temporal evolution features, and improves the understanding and reasoning ability of questions containing time information when determining the answer to the question statement. It also allows for more accurate acquisition of question answers from the temporal knowledge graph.
[0059] As one possible implementation method, Figure 2 A flowchart of the second question-answering method is shown. Based on the above embodiments, the target vectors of multiple elements in the time-series knowledge graph are determined using the mapping matrix, relational complex vectors, and temporal complex vectors, including the following steps: Step 201: Determine the complex time vector as the target time vector corresponding to the time.
[0060] In the embodiments of this application, the complex vector of time itself has captured the core semantics of time, and this application can directly use it as the target time vector, preserving the constraint effect of time on entities and relationships.
[0061] Step 202: Convert the real entity vectors in the mapping matrix into complex entity vectors in complex representation, and determine the complex entity vectors as the target entity vectors corresponding to the entities.
[0062] In the embodiments of this application, the real number mapping matrix of the head entity and tail entity constructed in step 102 is used to map the entity from the real number space to the relational real number space under the corresponding time. Then, the mapped real number vector is split into real and imaginary parts and converted into complex form to obtain the target entity vector. This process realizes the crossing of the entity from its own space to the relational and temporal association space, so that it can be adapted to the complex features of relations and time.
[0063] Specifically, in one optional embodiment of this application, the head entity and tail entity in the real number mapping matrix after mapping to the relation space are represented in the complex vector space. Their corresponding vectors in the real number space are divided into two parts, with the first half as their real part and the second half as their imaginary part, as shown in the following formula: , ; in, The target head entity vector is the target entity vector within the target entity vector. The target tail entity vector is the target entity vector within the target entity vector. The real part of the target head entity vector. The imaginary part of the target head entity vector. Let the real part be the target tail entity vector. This is the imaginary part of the target tail entity vector.
[0064] Step 203: Determine the target relation vector based on the relation complex vector and the time complex vector. The target relation vector is associated with the time complex vector.
[0065] In the embodiments of this application, the complex vector of relations can be interacted with the complex vector of time (such as the Hadamard product), and the rotation properties of complex numbers can be used to simulate the dynamic changes of relations over time (such as the specific performance of the "employed" relation in different years) to generate a target relation vector that incorporates time information.
[0066] Specifically, in one optional embodiment of this application, a rotation operation can be used to obtain a target relation vector corresponding to a specific time complex vector by rotating the relation complex vector and the time complex vector. This rotation operation is performed by rotating the relation complex vector. With time complex vector This is achieved using the Hadamard product, and the specific formula is as follows: ; in, Let r be the target relation vector, and r be the complex relation vector. It is a complex vector of time.
[0067] In addition, based on Euler's formula (This indicates that a unit complex number can be viewed as a rotation on the complex plane), this application also needs to... Constraints are imposed on the modulus of each element, for example , Through this constraint, that is Another form represents the radians rotated counterclockwise around the origin of the complex plane. And it only affects the phase of the relation representation in the complex vector space.
[0068] Furthermore, after obtaining the target vectors of multiple elements, this application can determine whether the target vectors of the quadruples composed of multiple elements meet the preset correctness conditions based on a pre-constructed scoring function. If they do not meet the preset correctness conditions, the target vectors of each element in the quadruples that do not meet the preset correctness conditions need to be updated (by redetermining the target vectors of each element according to the above steps) to obtain the updated target vectors. If they meet the conditions, no processing is required. The preset correctness conditions refer to the fact that the target head entity vector plus the target relation vector corresponding to the target time vector equals the conjugate of the target tail entity vector.
[0069] Specifically, in an optional embodiment of this application, for a correct quadruple fact, the projected target entity vector and the target relation vector at a specific time (specific target time vector) should, as far as possible, satisfy the condition that the sum of the target head entity vector and the target relation vector at a specific time (specific target time vector) equals the conjugate of the target tail entity vector. This yields the scoring function, with the specific formula as follows: ; The target relation vector, The target head entity vector is the target entity vector within the target entity vector. The target tail entity vector is the target entity vector within the target entity vector. and It is the subscript of the norm, used to define how the norm of a vector is calculated. The norm is the sum of the absolute values of the elements of a vector, emphasizing the absolute contribution of each element, and is relatively sensitive to outliers. The norm, or Euclidean norm, is the square root of the sum of the squares of the elements of a vector. It is often used to measure the "length" of a vector and can make the solution smoother in optimization problems.
[0070] If the score result corresponding to the target vector in the quadruple is greater than or equal to the preset correct threshold, then the target vector in the quadruple is determined to meet the preset correct condition.
[0071] In the actual training process, a corresponding loss function should also be constructed for the scoring function, and the specific formula is as follows:
[0072] in It is a correct training quadruple. It is the set of correct quadruplets (quadruplets that exist in the time-series knowledge graph). It corresponds The i-th negative sample is formed by random replacement. The head or tail entity is generated. It is an activation function. This is a predefined boundary value; during training, the model aims to achieve high scores on positive samples and low scores on negative samples. Therefore, the boundary value is introduced. Increase the distance between them to allow the model to train better. It is the ratio between positive samples and negative samples during training.
[0073] The gradient descent algorithm is used to optimize the evaluation algorithm. In each iteration, the target entity vector, target relation vector, and target time vector in the target vector are updated. Training is completed when the set number of iterations is reached.
[0074] In summary, this application directly uses the complex time vector as the target time vector, splits the real entity vector into a complex target entity vector after mapping to the real space, and generates a target relation vector with fused temporal dynamics by performing a Hadamard product between the complex relation vector and the complex time vector. It also constructs a scoring function and loss function of "head entity + relation = tail entity conjugate" and optimizes it with gradient descent. Ultimately, this enables the model to accurately capture the temporal correlation of entities, relations, and time, improves the ability to identify correct quadruplets, and enhances the accuracy and reliability of temporal knowledge graphs in handling time dimension information in question answering and reasoning tasks.
[0075] For ease of understanding, such as Figure 3 As shown, this application further proposes a specific schematic diagram for determining the target vector.
[0076] Reference Figure 3 The leftmost space represents the real number space, where "Mbappe, Paris, Real Madrid" are represented by simple real number vectors (e.g., , , This indicates that this is the most basic semantic state of an entity, which only reflects that it "exists" but is not deeply bound to time or relationships.
[0077] When analyzing the relationship of "efficacy" And considering different times ( and When using a mapping matrix, a mapping matrix will be used. and , and This projects entities from the "basic real number space" to a real number space of a specific time-relationship. For example... In this context, Mbappe is reflected in Real Madrid was reflected in ; In this context, Mbappe is reflected in Paris is mapped to This step allows entities and " Time+ The "relationship" binding has acquired a more specific semantic meaning.
[0078] Upon entering the real space of a specific time-relation, the vectors of entity and time are decomposed into "real part (re)" and "imaginary part (im)" (e.g., , The elements are combined into a complex vector and placed in the rightmost relational complex space. The real part (re) retains the "basic attributes" of the entity / time (e.g., Mbappe is a player, Real Madrid is a club). The imaginary part (im) specifically stores the dynamic changes brought about by "time + relation" (e.g., ...). The connection between Mbappe and Real Madrid over time (The changing relationship between Mbappe and Paris).
[0079] In relational complex space, complex vectors (such as Mbappé's) Real Madrid This allows for the precise description of the complex binding of "time-relationship-entity" using both "real part (basic attribute)" and "imaginary part (dynamic association)". For example, the "phase rotation" of the imaginary part can simulate the relationship change between "Mbappe playing for Real Madrid in 2020" and "playing for Paris Saint-Germain in 2023", while the real part always remembers the basic fact that "Mbappe is a player".
[0080] As one possible implementation method, Figure 4 A flowchart of the third question-answering method is shown. Based on the above embodiments, when a question statement is obtained, the answer to the question statement is determined based on a target vector containing multiple elements, including the following steps: Step 301: Obtain the question statement.
[0081] In the embodiments of this application, the question statement refers to the natural language text input by the user, which is used to ask questions to the time-series knowledge graph. It needs to obtain information such as entities, relationships, and time (e.g., "Which company did Zhang San work for in 2020?"), and is the input content that triggers the knowledge graph question-answering process.
[0082] Step 302: Using a preset language model, determine the question elements in the question statement and the initial question representation vector corresponding to the question statement. The initial question representation vector is the initial vector of each question element in the question statement.
[0083] In the embodiments of this application, the pre-trained language model refers to a pre-trained natural language processing model (such as RoBERTa) that has the ability to convert natural language text into vector representations and can capture the semantic features of the text. Among them, RoBERTa is a pre-trained language model based on the Transformer architecture. Through training on massive amounts of text, it can effectively capture the contextual semantics of natural language, and the output of its last hidden layer is often used as the vector representation of the text.
[0084] Problem elements refer to the key information units contained in a problem statement, which typically include entities (such as "Zhang San"), relational words (such as "employed in"), time words (such as "2020"), and other core words, and are the basic elements that constitute the semantics of a problem.
[0085] The initial question representation vector is a vector representation obtained by processing the question statement through a pre-defined language model. It includes the vector of each word (question element) in the question, as well as the summary vector of the entire statement. It is a preliminary numerical expression of the question semantics.
[0086] Specifically, in one optional embodiment of this application, the application can utilize the RoBERTa model to encode the input question statement. RoBERTa, through a self-attention mechanism of a multi-layer Transformer structure, understands the contextual relationships between words in the question (such as the semantic binding between "2020" and "held office"), and transforms these relationships into low-dimensional dense vectors—the output of the last hidden layer contains vectors for each word (reflecting the semantics of a single question element), and can also generate a vector for the entire statement (reflecting the overall semantics of the question) through pooling and other methods.
[0087] In other words, this application can use the language model RoBERTa to obtain the initial problem representation vector. The corresponding vector comes from the last hidden layer: .
[0088] Step 303: Based on the problem element and the target vectors of multiple elements in the time-series knowledge graph, determine the problem element vector corresponding to the problem element.
[0089] In the embodiments of this application, the question element vector is the vector representation of the key elements such as the head entity, tail entity, and time extracted from the question statement. It is a mapping of the question element in the vector space of the temporal knowledge graph and is used to match the target vector of the element in the temporal knowledge graph.
[0090] The target vectors of multiple elements in the temporal knowledge graph are the target entity vectors (head entity, tail entity), target time vectors, etc. obtained in step 103. They are the final representation of the elements in the knowledge graph in the complex space, carrying the core semantics and related features of entities and time.
[0091] Specifically, for the head entity, tail entity, and time elements extracted from the question statement, the corresponding entities and times are found in the time-series knowledge graph. The target vectors of these question elements that have been constructed in the time-series knowledge graph are directly reused (e.g., "Zhang San" in the question corresponds to the target head entity vector of "Zhang San" in the knowledge graph, and "2020" corresponds to the target time vector of "2020" in the knowledge graph) as question element vectors.
[0092] This application, through this direct mapping, ensures that the vector representation of the question element and the target vector of the element in the temporal knowledge graph reside in the same complex space, guaranteeing that their semantic dimensions are consistent (as they are both complex vectors that integrate time and relational features). By binding the key elements in the question to the target vectors of the corresponding elements in the knowledge graph, this application achieves vector-level alignment between "question semantics" and "knowledge graph semantics," clearing spatial adaptation obstacles for subsequent answer reasoning based on vector matching.
[0093] Step 304: Based on the preset weight matrix and the initial problem representation vector, determine the problem relationship vector corresponding to the problem statement.
[0094] In the embodiments of this application, based on the initial question representation vector, a two-layer multi-head attention mechanism is used to continuously aggregate information from context words to obtain a target question representation vector with temporal features. In other words, this application can utilize graph attention networks and graph convolutional neural networks, combined with an initial question representation vector, to determine the target temporal semantic feature vector corresponding to the question statement; based on the question element vector and the initial question representation vector, to determine the initial relation vector corresponding to the question statement; and to fuse the target temporal semantic feature vector and the initial relation vector to obtain the target question representation vector. The target question standard vector is the final question representation that integrates the target temporal semantic features and the initial relation vector, containing both relational semantics and temporal features, and is the basis for generating the question relation vector.
[0095] The graph attention network includes a first graph attention network and a second graph attention network, and the graph convolutional neural network includes a first graph convolutional neural network and a second graph convolutional neural network. This application can utilize the first graph attention network and the first graph convolutional neural network to process the initial question representation vector to obtain the shallow temporal feature vector corresponding to the question statement; and utilize the second graph attention network and the second graph convolutional neural network to process the shallow temporal feature vector to obtain the target temporal feature vector corresponding to the question statement.
[0096] Then, based on the target problem representation vector and the preset weight matrix, the problem relationship vector corresponding to the problem statement is determined.
[0097] Specifically, in one optional embodiment of this application, the application can obtain a target problem representation vector with deep temporal features through a two-layer multi-head attention mechanism.
[0098] First, the first layer is to The resulting attention score matrix is input to the multi-head self-attention network (corresponding to the first graph attention network in this application). The top-k selector is used to retain k important words with contextual information. ; ; ; Among them, the total dimension of the model The dimensions of a single attention head are obtained by splitting the attention head evenly according to the number of heads K. Input features With trainable linear transformation matrix Multiplying them yields the vector used for the attention calculation; similarly, With trainable matrices Multiplying the two vectors yields the query vector used in the attention calculation. Multiplying the transpose of the query vector with the vector being queried yields the original attention score. Scaling the original scores helps alleviate the vanishing gradient problem caused by high dimensionality. This represents the attention score matrix calculated for each of the K attention heads. Summation is performed to integrate the attention information from multiple heads. The summed matrix is then filtered by attention score, retaining the top-k positions with the highest scores. These positions are considered to correspond to important words with contextual information. The output is... .
[0099] The matrix after top-k selection and As input to a graph convolutional network (corresponding to the first graph convolutional neural network of this application), the advantages of graph convolutional networks in feature extraction on graph structure data are utilized to obtain... Then, information is integrated through a convolutional layer and a feedforward layer, thereby obtaining a result with shallow temporal features. (Corresponding to the shallow temporal feature vector of this application). The feedforward layer consists of two linear layers with ReLU as the activation function. ; .
[0100] Next, the second layer will (The shallow temporal feature vector corresponding to that in this application) is used as the input to the second-layer multi-head self-attention (corresponding to the second graph attention network in this application), and then passed through a top-k selector to obtain a matrix. ,then and After fusion As input to the second-layer graph convolutional network (corresponding to the second graph convolutional neural network of this application), it extracts deeper feature representations with temporal semantics from the nodes and adjacent nodes contained in the problem. : ; ; ; Consistent with the meaning of the first layer, With trainable linear transformation matrix Multiplying them yields the vector used for the attention calculation; similarly, With trainable matrices Multiply to obtain the query vector in the attention calculation; multiply the transpose of the query vector with the vector being queried and then divide by . The second-layer single-head attention score matrix is obtained. argmax for The maximum attention value is selected position by position to highlight the most significant associations. The top-k values are then further filtered to obtain those with contextual structure information. . This indicates the concatenation of vectors, and... As input to the graph attention network, it extracts deeper representations with temporal features. .
[0101] Finally, information is integrated using a convolutional layer and a feedforward layer to obtain a result with deep temporal features. (Corresponding to the target time feature vector of this application).
[0102] ; In problem reasoning, it is often necessary to find the correct answer based on relations. Therefore, the relational semantic unit uses a method similar to the EaE model to obtain the semantic matching matrix of the problem. This matrix consists of the target time vector t, the target entity vector e, and the instruction vector obtained through the temporal knowledge graph representation learning method. (The instruction vector is the vector representation of each word after the question statement has passed through the RoBERTa model.) This is the summation of the vectors. When the label i in the instruction vector is an entity: ; When the tag When it is time information: ; When the tag When it is neither a physical entity nor a time: ; matrix Input a Transformer encoder to extract a relational representation. (Corresponding to the initial relation vector of this application). .
[0103] This application can also employ GRU networks to fuse relational representations. and time series characteristics Finally, a problem representation TR (corresponding to the target problem representation vector of this application) is obtained, containing these two parts of semantic information. In actual processing, the relation representation... With time series characteristics First, a concatenation operation is performed to obtain X, which is then input into the GRU network. .
[0104] Then, X is input into the GRU to obtain the output at each time step, and then a fully connected layer is used to obtain the final problem representation TR. TR=FC(GRU(X)).
[0105] Since this application can use quadruples to parse question statements, it can select the entity or time with the highest score as the answer based on the TCR-TransD scoring function (the scoring function corresponding to this application, which can be referred to in step 203, and will not be repeated here). Therefore, this application can first perform operations on the target question representation vector TR, which has time features and relational information, with two trainable weight matrices to generate two vectors. and These two vectors serve as relational representations of the predicted entity or temporal information in the quadruple (corresponding to the problem relation vectors in this application).
[0106] Step 305: Based on the question element vector and the question relationship vector, determine multiple candidate answer vectors from the temporal knowledge graph.
[0107] In the embodiments of this application, after obtaining the problem element vector and the problem relation vector, this application can obtain the problem from the time-series knowledge graph.
[0108] A candidate answer vector is an element vector (which can be an entity vector or a time vector) that is selected from a temporal knowledge graph and has a potential association with the question element vector and the question relation vector. It is a vector space representation of the candidate object that may be the answer to the question.
[0109] This application can utilize question element vectors (such as head entity and time vectors) and question relation vectors to retrieve tail entity vectors that satisfy the "head entity-relation-time" association in a time-series knowledge graph. For example, for the question "Which company did Zhang San work for in 2020?", it is necessary to filter out company entity vectors in the knowledge graph that are simultaneously associated with "Zhang San" (head entity vector), "2020" (time vector), and "worked for" (relation vector), and use these associated company entity vectors as candidate answer vectors.
[0110] Step 306: Using a scoring function, score the combination of elements in the question element vector, the question relationship vector, and each candidate answer vector to obtain the scoring result corresponding to each candidate answer vector.
[0111] In the embodiments of this application, the scoring function is a mathematical function used to measure the reasonableness of the association between question elements, question relationships and candidate answers (such as the norm calculation of "head entity vector + relationship vector ≈ tail entity conjugate vector" in step 203). The higher the output value, the closer the association.
[0112] Element combination refers to the combination of question element vector, question relation vector and candidate answer vector (such as "Zhang San (head entity vector) + employed in (relation vector) + 2020 (time vector) + Company A (candidate answer vector)"), which corresponds to the quadruple logic in the temporal knowledge graph.
[0113] This application can quantify the matching degree between questions and candidate answers through a scoring function, providing a basis for the final selection of answers.
[0114] Specifically, this application can combine the question element vector, the question relation vector, and each candidate answer vector to simulate the four-tuple structure of "head entity-relation-time-tail entity" in a temporal knowledge graph. For example, if the question asks "Which company did Zhang San work for in 2020?", the combination would be "Zhang San (head entity vector) + worked for (question relation vector) + 2020 (time vector) + candidate company (candidate answer vector)". Substituting the above combination into a preset scoring function (such as norm calculation based on complex vectors), the reasonableness of the combination is measured through vector operations. Taking the scoring function in step 203 as an example, the L1 / L2 norm of the conjugate of "head entity vector + question relation vector - candidate answer vector" is calculated. The larger the calculated score, the more the combination conforms to the factual logic in the temporal knowledge graph (i.e., the more reasonable the candidate answer).
[0115] Each candidate answer vector corresponds to a score result. The score directly reflects the degree of matching between the candidate answer and the question, providing a numerical basis for selecting the optimal answer.
[0116] Step 307: Based on the scoring results, obtain the target answer vector, and determine the question answer corresponding to the question statement according to the target answer vector.
[0117] In the embodiments of this application, the target answer vector refers to the vector with the highest score selected from the candidate answer vectors. It corresponds to the vector representation of the entity or time that best matches the semantics of the question in the temporal knowledge graph and is the direct basis for determining the final answer.
[0118] If entity or time information is missing in the question statement (e.g., "In which year did Zhang San work for Company A?" lacks time), the missing element is replaced with a virtual entity / time vector to make the "head entity-relationship-time-tail entity" quadruple structure complete, ensuring that the scoring function can score all possible candidate elements (such as all time vectors).
[0119] This application can score all possible elements in the entity vector set (E) or time vector set (T) (corresponding to the candidate answer vectors in this application) based on the TCR-TransD scoring function (e.g., if time is missing, the score is calculated for each time vector), and select the vector with the highest score as the target answer vector. For example, for "In which year did Zhang San work for Company A", the time vector corresponding to the highest score is the target answer vector by calculating the score of "Zhang San + worked for + candidate time + Company A".
[0120] Specifically, in one optional embodiment of this application, for each given question, in addition to the question itself, there is also a header entity that has been extracted from the question. Tail entity and time information If entity or time information is missing, virtual entities or time information are used as substitutes. This allows the model to employ a scoring function. and For all possible time information or entity Implement scoring. Here, E is the set of entity vectors obtained from TCR-TransD, and T is the set of time vectors.
[0121] For the calculation of the scoring function, the scoring function in the TCR-TransD method is adopted. ,Right now:
[0122]
[0123] Finally, this application can measure the difference between the predicted target answer vector and the true answer vector using the cross-entropy loss function, and use the gradient descent algorithm to iteratively update the parameters of the question answering model (such as entity vector, relation vector, weight matrix, etc.), so that the question answering model can continuously improve its ability to identify the correct answer during the training process, and finally output a more accurate target answer vector, thereby determining the final answer to the question.
[0124] In summary, this application leverages the advantages of graph convolutional neural networks and graph attention networks in feature extraction on graph structured data to enhance the reasoning ability of question answering models, thereby obtaining more accurate answers to question statements.
[0125] Furthermore, based on Figures 1 to 4 In an embodiment, this application provides a schematic diagram of a specific question-answering model, the structure of which is shown below: The temporal knowledge graph representation learning module is used to embed entities, relations, and temporal information into a vector space to obtain corresponding vector representations, so that the question-answering model can understand and utilize the semantic information in the temporal knowledge graph. For details, please refer to steps 101 to 103, which will not be repeated here.
[0126] The question representation module is used to convert natural language questions into vector representations that computers can understand, in order to obtain the answer to the question statement. For example... Figure 5 As shown in the diagram, this application provides a specific question representation module, which is the core of the question-answering model and is further divided into an encoding unit, a temporal feature unit, a relational semantic unit, and a gating unit. Among them, as... Figure 6The diagram illustrates a specific temporal feature unit, which consists of two layers. The first layer utilizes multi-head attention mechanisms, graph convolution, convolutional neural networks, and other networks to capture shallow temporal semantic information (corresponding to the shallow temporal feature vector of this application). The second layer utilizes multi-head attention mechanisms, graph attention, convolutional neural networks, and other networks to obtain a representation with deep temporal features (corresponding to the target temporal feature vector of this application). The specific implementation steps of each unit can be referred to in steps 104 and 301 to 307, and will not be repeated here.
[0127] Based on the question-and-answer model described above, such as Figure 7 As shown in the diagram, this application provides a specific question-answering system, the main functions of which are as follows: The question-answering system consists of three modules: question search, entity search, and a complete temporal knowledge graph.
[0128] Its specific details are as follows: (1) Question Search: After entering the question statement, click search. The system will display the question answer, answer type, and question obtained based on the question-answering model. For answer types that are entities, the system will also present the corresponding quadruple of the question statement in a visual way.
[0129] (2) Entity search: After entering the entity information, click search, and the system will present the time-series knowledge graph subgraph related to the entity.
[0130] (3) Overview of the temporal knowledge graph: Visualize all temporal knowledge graph subgraphs related to the question answer of the extracted question statement.
[0131] like Figure 8 As shown in the diagram, this application provides a specific schematic diagram for building a question-answering system. The main steps for building this question-answering system are divided into five parts: data processing, time-series knowledge graph construction, backend processing, frontend display, and question-answering model, as shown below: Data processing involves extracting the quadruples related to the answers to the question statements from the dataset and converting the IDs in the quadruples into corresponding names based on entity and relation dictionaries. For example, (Q318403, P166, Q1780561, 1995) can be converted into (Johann Olav Koss, award received, Peer Gynt Literary Award, 1995). The construction of a time-series knowledge graph involves using the Py2neo toolkit to import the processed quadruples into the Neo4j database, enabling storage and read / write operations to provide data support for the overall system. Data in Neo4j is visualized, allowing for a direct view of the time-series knowledge graph.
[0132] Front-end presentation involves using CSS, JavaScript, and HTML to create intuitive and responsive web pages. Additionally, the Echart plugin, developed using JavaScript, can be used to visualize data returned from the Neo4j database on the backend.
[0133] Question answering involves using the question answering model described above to return the corresponding answer to the given question statement. The temporal knowledge graph representation learning module of the question answering model uses the TCR-TransD method, as detailed in steps 101 to 103, which will not be elaborated here.
[0134] The backend processing involves using the Flask framework to respond to the frontend's HTTP requests. Flask then calls the Py2neo toolkit to query data matching the request from the Neo4j database. After that, Flask encapsulates this data and returns it to the frontend.
[0135] To implement the above embodiments, this application also provides a question-and-answer device. Figure 9 This is a schematic diagram of the structure of a question-and-answer device 900 provided in an embodiment of this application. Figure 9 As shown, the device includes: Initialization unit 910 is used to initialize multiple elements in the time-series knowledge graph in the real number space and the complex number space to obtain real number vectors and complex number vectors. The multiple elements include entities, relations and time. The real number vectors include entity real number vectors, relation real number vectors and time real number vectors. The complex number vectors include relation complex vectors and time complex vectors. The mapping unit 920 is used to map the entity real vector and the relation real vector according to the time real vector to construct a mapping matrix; The first determining unit 930 is used to determine the target vector of multiple elements in the time-series knowledge graph based on the mapping matrix, the relational complex vector and the time complex vector in the complex vector, wherein the target vector is a vector represented by a complex number; The second determining unit 940 is used to determine the answer to the question statement based on the target vector of the plurality of elements when the question statement is obtained.
[0136] In some embodiments, based on the time real vector, the mapping unit 920 is used to: determine the element-wise product of the entity real vector and the relation real vector; and multiply the time real vector by the element-wise product of the transpose to obtain a real mapping matrix.
[0137] In some embodiments, the target vector includes a target time vector, a target entity vector, and a target relation vector. The first determining unit 930 is configured to: determine the complex time vector as the target time vector corresponding to the time; convert the real entity vector in the mapping matrix into a complex entity vector in complex representation, and determine the complex entity vector as the target entity vector corresponding to the entity; and determine the target relation vector of the relation based on the complex relation vector and the complex time vector, wherein the target relation vector is associated with the complex time vector.
[0138] In some embodiments, the second determining unit 940 is configured to: acquire a question statement; determine the question elements in the question statement and the initial question representation vector corresponding to the question statement through a preset language model, wherein the initial question representation vector is the initial vector of each question element in the question statement; determine the question element vector corresponding to the question element based on the question element and the target vectors of multiple elements in the temporal knowledge graph; determine the question relation vector corresponding to the question statement based on a preset weight matrix and the initial question representation vector; determine multiple candidate answer vectors from the temporal knowledge graph based on the question element vector and the question relation vector; score the combination of elements of the question element vector, the question relation vector and each candidate answer vector using a scoring function to obtain a scoring result corresponding to each candidate answer vector; and obtain a target answer vector based on the scoring result to determine the question answer corresponding to the question statement according to the target answer vector.
[0139] In some embodiments, the second determining unit 940 is configured to: utilize a graph attention network and a graph convolutional neural network, combined with an initial question representation vector, to determine a target temporal semantic feature vector corresponding to a question statement; determine an initial relation vector corresponding to a question statement based on a question element vector and an initial question representation vector; fuse the target temporal semantic feature vector and the initial relation vector to obtain a target question representation vector; and determine a question relation vector corresponding to a question statement based on the target question representation vector and a preset weight matrix.
[0140] In some embodiments, the graph attention network includes a first graph attention network and a second graph attention network, and the graph convolutional neural network includes a first graph convolutional neural network and a second graph convolutional neural network. The second determining unit 940 is configured to: process the initial problem representation vector using the first graph attention network and the first graph convolutional neural network to obtain a shallow time feature vector corresponding to the problem statement; and process the shallow time feature vector using the second graph attention network and the second graph convolutional neural network to obtain a target time feature vector corresponding to the problem statement.
[0141] The methods and apparatus provided in the embodiments of this application have been described above. To implement the functions of the methods provided in the embodiments of this application, the electronic device may include a hardware structure and software modules, and may implement the above functions in the form of a hardware structure, software modules, or a hardware structure plus software modules. One of the above functions may be executed in the form of a hardware structure, software modules, or a hardware structure plus software modules.
[0142] Figure 10 This is a block diagram illustrating an electronic device 1000 for implementing the above-described question-and-answer method according to an exemplary embodiment. For example, the electronic device 1000 may be a mobile phone, computer, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.
[0143] Reference Figure 10 The electronic device 1000 may include a communication interface 1001, capable of interacting with other devices; a processor 1002, connected to the communication interface 1001 to enable interaction with other devices, used to execute the methods provided by one or more of the above-described technical solutions when running a computer program; and a memory 1003, on which the computer program is stored. Specifically, the specific processing procedure of the processor 1002 can refer to the question-and-answer method described in the above embodiments of this disclosure.
[0144] Of course, in practical applications, the various components in electronic device 1000 are coupled together through bus system 1004. It can be understood that bus system 1004 is used to realize the connection and communication between these components. In addition to a data bus, bus system 1004 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, in... Figure 10 The general labeled all buses as Bus System 1004.
[0145] The memory 1003 in this embodiment is used to store various types of data to support the operation of the electronic device 1000. Examples of such data include any computer program used to operate on the electronic device 1000.
[0146] The methods disclosed in the embodiments of this application can be applied to processor 1002, or implemented by processor 1002. Processor 1002 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in processor 1002 or by instructions in the form of software. The processor 1002 may be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 1002 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. A general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of this application can be directly manifested as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, which is located in memory 1003. Processor 1002 reads the information in memory 1003 and completes the steps of the aforementioned method in combination with its hardware.
[0147] In an exemplary embodiment, the electronic device 1000 may be implemented by one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers (MCUs), microprocessors, or other electronic components to perform the aforementioned method.
[0148] Embodiments of this disclosure also propose a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause a computer to execute the question-and-answer method described in the above embodiments of this disclosure.
[0149] Embodiments of this disclosure also provide a computer program product, including a computer program that is executed by a processor using the question-and-answer method described in the above embodiments of this disclosure.
[0150] Embodiments of this disclosure also propose a chip including one or more interface circuits and one or more processors; the interface circuits are used to receive signals from the memory of an electronic device and send signals to the processors, the signals including computer instructions stored in the memory, which, when executed by the processor, cause the electronic device to perform the question-and-answer method described in the above embodiments of this disclosure.
[0151] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0152] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "illustrative embodiment," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with an embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0153] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of the invention includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as will be understood by those skilled in the art to which embodiments of the invention pertain.
[0154] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processing module, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (control method), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic device, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which programs can be printed, because programs can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.
[0155] It should be understood that various parts of the embodiments of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0156] Those skilled in the art will understand that all or part of the steps of the methods described in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.
[0157] Furthermore, the functional units in the various embodiments of the present invention can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc.
[0158] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A question-and-answer method, characterized in that, include: Multiple elements in a time-series knowledge graph are initialized with vectors in real and complex space to obtain real vectors and complex vectors. The multiple elements include entities, relations, and time. The real vectors include entity real vectors, relation real vectors, and time real vectors. The complex vectors include relation complex vectors and time complex vectors. Based on the real time vector, the real entity vector and the real relation vector are mapped to construct a mapping matrix; Based on the mapping matrix, the relational complex vector and the temporal complex vector in the complex vector, the target vector of multiple elements in the time-series knowledge graph is determined, and the target vector is a vector represented by a complex number; When a question statement is obtained, the answer to the question statement is determined based on the target vector of the multiple elements.
2. The method according to claim 1, characterized in that, The step of mapping the entity real vector and the relation real vector based on the time real vector to construct a mapping matrix includes: Determine the element-wise product of the entity real vector and the relation real vector; Multiplying the real time vector by the element-wise product of its transpose yields the real number mapping matrix.
3. The method according to claim 1, characterized in that, The target vector includes a target time vector, a target entity vector, and a target relation vector. The step of determining the target vector of multiple elements in the time-series knowledge graph based on the mapping matrix, the relational complex vector and the time complex vector in the complex vector includes: The complex time vector is determined to be the target time vector corresponding to the time. The entity real vectors in the mapping matrix are converted into entity complex vectors in complex representation, and the entity complex vectors are determined as the target entity vectors corresponding to the entities. Based on the complex relation vector and the complex time vector, a target relation vector is determined, which is associated with the complex time vector.
4. The method according to claim 1, characterized in that, When a question statement is obtained, determining the answer to the question statement based on the target vector of the multiple elements includes: Obtain the question statement; By using a preset language model, the question elements in the question statement and the initial question representation vector corresponding to the question statement are determined. The initial question representation vector is the initial vector of each question element in the question statement. Based on the question element and the target vectors of multiple elements in the time-series knowledge graph, determine the question element vector corresponding to the question element; Based on the preset weight matrix and the initial question representation vector, the question relationship vector corresponding to the question statement is determined; Based on the question element vector and the question relationship vector, multiple candidate answer vectors are determined from the temporal knowledge graph; Using a scoring function, the combination of elements of the question element vector, the question relationship vector, and each candidate answer vector is scored to obtain the scoring result corresponding to each candidate answer vector; Based on the scoring results, a target answer vector is obtained, and the question answer corresponding to the question statement is determined according to the target answer vector.
5. The method according to claim 4, characterized in that, The process of determining the question relation vector corresponding to the question statement based on the preset weight matrix and the initial question representation vector includes: By using graph attention networks and graph convolutional neural networks, combined with the initial question representation vector, the target temporal semantic feature vector corresponding to the question statement is determined; Based on the question element vector and the initial question representation vector, determine the initial relation vector corresponding to the question statement; The target temporal semantic feature vector and the initial relation vector are fused to obtain the target problem representation vector; Based on the target question representation vector and the preset weight matrix, the question relationship vector corresponding to the question statement is determined.
6. The method according to claim 5, characterized in that, The graph attention network includes a first graph attention network and a second graph attention network, and the graph convolutional neural network includes a first graph convolutional neural network and a second graph convolutional neural network. The step of using graph attention networks and graph convolutional neural networks, combined with the initial question representation vector, to determine the target temporal semantic feature vector corresponding to the question statement includes: The initial question representation vector is processed using the first graph attention network and the first graph convolutional neural network to obtain the shallow time feature vector corresponding to the question statement; The shallow time feature vector is processed using the second graph attention network and the second graph convolutional neural network to obtain the target time feature vector corresponding to the question statement.
7. A question-and-answer device, characterized in that, The device includes: An initialization unit is used to initialize multiple elements in a time-series knowledge graph in real and complex space to obtain real vectors and complex vectors. The multiple elements include entities, relations, and time. The real vectors include entity real vectors, relation real vectors, and time real vectors. The complex vectors include relation complex vectors and time complex vectors. The mapping unit is used to map the entity real vector and the relation real vector according to the time real vector to construct a mapping matrix; The first determining unit is used to determine the target vector of multiple elements in the time-series knowledge graph based on the mapping matrix, the relational complex vector and the time complex vector in the complex vector, wherein the target vector is a vector represented by a complex number; The second determining unit is used to determine the answer to the question statement based on the target vector of the plurality of elements when the question statement is obtained.
8. An electronic device, characterized in that, include: The processor and the memory used to store computer programs that can run on the processor. When the processor is used to run the computer program, it performs the method according to any one of claims 1 to 6.
9. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to perform the method according to any one of claims 1 to 6.
10. A computer program product, characterized in that, It includes a computer program that, when executed by a processor, implements the method according to any one of claims 1 to 6.