Role perception-based map construction method and system, terminal and storage medium
By constructing the event map based on character perception methods, the problem of inadequate exponents in the existing technologies has been solved, and more accurate event relationship expression and information reservation are realized, which is suitable for prediction and analysis of complex events.
Patent Information
- Application Number
- CN202411301362.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-18
- Publication Date
- 2025-01-24
Smart Images

Figure CN119358647A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of knowledge graphs, and specifically relates to a graph construction method, system, terminal and storage medium based on role perception. Background Art
[0002] In the current era of the Internet and big data, with the development of technologies such as cloud computing, the Internet of Things, and artificial intelligence, data collection and acquisition have become more convenient, but at the same time, the explosive growth of information has made it increasingly difficult for people to effectively manage and understand this information. In particular, there is still a lot of room for knowledge mining of complex events, as well as the integration and analysis of complex events and other entity information. How to effectively develop and utilize multi-source heterogeneous data and build a multi-relational knowledge graph with rich and comprehensive information can provide important data support for urban governance, traffic monitoring, and safe production, and is also an important prerequisite for the transition from informatization to data intelligence.
[0003] At present, event graphs are generally constructed by introducing virtual entities to decompose them into multiple triples for representation. However, in the decomposition and transformation process, because traditional methods focus on the relationship between binary entities, the relationship between multiple entities is not fully represented, and a large amount of spatiotemporal information is lost. Therefore, it is necessary to find a model that can better express the multiple relationships between events. Summary of the invention
[0004] In view of the above-mentioned deficiencies in the prior art, the present invention provides a graph construction method, system, terminal and storage medium based on role perception to solve the above-mentioned technical problems.
[0005] In a first aspect, the present invention provides a method for constructing a graph based on role perception, comprising: Extract time, place and people from event data, and use the extracted time, place and people as roles to establish relationships between roles; The entities in the event data are constructed as roles, with roles as virtual entity nodes and multivariate relationships between roles as edges. The knowledge graph is constructed by constructing role vectors and pattern matrices. A scoring function and a loss function are constructed, and based on the scoring function and the loss function, the knowledge graph is trained according to a strategy of minimizing the loss function.
[0006] In an optional implementation, time, place, and person are extracted from event data, and the extracted time, place, and person are used as roles to establish relationships between roles, including: Crawl event data from a target web page and save the event data to a basic database; Use information extraction models to extract time, place, people and event types from event data; A temporal relationship is generated based on the extracted time, a positional relationship is generated based on the extracted location, and a causal relationship of the event type is generated based on the temporal relationship and the positional relationship.
[0007] In an optional implementation, entities in event data are constructed as roles, roles are used as virtual entity nodes, and multivariate relationships between roles are used as edges. A knowledge graph is constructed by constructing role vectors and pattern matrices, including: Constructing basis vectors for the character, and generating a character vector using the basis vectors and a weight matrix; Pre-generate an embedding vector of an event type, and determine an event embedding vector corresponding to the role entity based on the event type corresponding to the role entity; Based on the relationship types between role entities, determine the relationship embedding vectors of role entities; Decompose multi-relation events into multiple triples and sets of additional attribute values of triples by introducing role entities; Multiple triples of multi-relation events and sets of additional attribute values of triples are introduced into a pattern matrix to capture the compatibility of a role with all related entities. The rows and columns of the pattern matrix represent role entities of different multi-relation events, and the elements of the pattern matrix represent the relationships between role entities.
[0008] In an optional implementation, constructing a scoring function and a loss function, and training the knowledge graph based on the scoring function and the loss function according to a strategy of minimizing the loss function, includes: Construct a distance-based scoring function: ; Among them, Pr i[1,:]E1 represents the correlation between the i-th role and the first entity in the relation r; The loss function is defined as negative log-likelihood loss, maximizing the logarithm of the probability of the observed fact set appearing in the model, and adding a regularization term to the loss function to penalize the complexity of the embedding vector; Extract all multi-tuples that do not contain missing entities from the multi-tuple relational knowledge base as training samples, and construct the corresponding observation fact set; Use gradient descent to optimize the embedding vectors and other learnable parameters of the knowledge graph model to minimize the loss function; During the training process, the performance of the knowledge graph model is regularly evaluated on the validation set, and the knowledge graph model structure, learning rate, and regularization strength are adjusted as needed; For a multi-tuple with missing entities, use the trained knowledge graph model to calculate the estimated scores of all possible candidate entities filled in the multi-tuple, and select the entity with the highest estimated score as the prediction result; Design an iterative completion strategy to first complete a portion of the determined entities, and then make predictions again based on the updated knowledge graph until convergence is reached or a specific stopping condition is met; Reintegrate all completed multi-tuples into the knowledge graph.
[0009] In a second aspect, the present invention provides a graph construction system based on role perception, comprising: The information extraction module is used to extract time, place and people from event data, and use the extracted time, place and people as roles to establish relationships between roles; The graph construction module is used to construct entities in event data into roles, use roles as virtual entity nodes, and use multivariate relationships between roles as edges. It constructs a knowledge graph by constructing role vectors and pattern matrices. The iterative training module is used to construct a scoring function and a loss function, and based on the scoring function and the loss function, the knowledge graph is trained according to a strategy of minimizing the loss function.
[0010] In an optional implementation, the information extraction module includes: An event crawling unit, used to crawl event data from a target web page and save the event data to a basic database; An entity extraction unit, used to extract time, place, person and event type from event data using an information extraction model; The relationship generation unit is used to generate a temporal relationship based on the extracted time, generate a positional relationship based on the extracted location, and generate a causal relationship of an event type based on the temporal relationship and the positional relationship.
[0011] In an optional embodiment, the map construction module includes: A vector construction unit, used to construct a basis vector for the character, and generate a character vector using the basis vector and a weight matrix; A first embedding unit, configured to pre-generate an embedding vector of an event type, and determine an event embedding vector corresponding to the role entity based on the event type corresponding to the role entity; A second embedding unit, configured to determine a relation embedding vector of the role entity based on the relation type between the role entities; An event decomposition unit, used to decompose a multi-relation event into a plurality of triples and a set of additional attribute values of the triples by introducing role entities; A matrix introduction unit is used to introduce multiple triples of multi-relation events and sets of additional attribute values of triples into a pattern matrix to capture the compatibility of the role with all related entities. The rows and columns of the pattern matrix represent role entities of different multi-events, and the elements of the pattern matrix represent the relationships between role entities.
[0012] In an optional embodiment, the iterative training module includes: Function building block for building distance-based scoring functions: ; Among them, Pr i[1,:]E1 represents the correlation between the i-th role and the first entity in the relation r; The loss definition unit is used to define the loss function as negative log-likelihood loss, maximize the logarithm of the probability of occurrence of the observed fact set in the model, and add a regularization term to the loss function to penalize the complexity of the embedding vector; The basic training unit is used to extract all multi-tuples that do not contain missing entities from the multi-tuple relational knowledge base as training samples and construct the corresponding observation fact set; A learning optimization unit, which is used to optimize the embedding vectors and other learnable parameters of the knowledge graph model using the gradient descent method to minimize the loss function; The parameter adjustment unit is used to regularly evaluate the performance of the knowledge graph model on the validation set during the training process, and adjust the knowledge graph model structure, learning rate, and regularization strength as needed; The entity prediction unit is used to calculate the estimated scores of all possible candidate entity-filled tuples with missing entities using the trained knowledge graph model, and select the entity with the highest estimated score as the prediction result; The entity completion unit is used to design an iterative completion strategy, which first completes a part of the determined entities and then predicts again based on the updated knowledge graph until convergence is reached or a specific stopping condition is met; The graph update unit is used to reintegrate all completed multi-tuples into the knowledge graph.
[0013] In a third aspect, a terminal is provided, including: processor, memory, wherein: The memory is used to store computer programs. The processor is used to call and run the computer program from the memory, so that the terminal executes the above-mentioned terminal method.
[0014] According to a fourth aspect, a computer storage medium is provided, wherein the computer-readable storage medium stores instructions, and when the instructions are executed on a computer, the computer executes the methods described in the above aspects.
[0015] The beneficial effect of the present invention is that the graph construction method, system, terminal and storage medium based on role perception provided by the present invention abstractly construct the time, place, characters and the like in the multi-relationship event into roles as the specific virtual entity nodes of the event knowledge graph, and the multi-relationships between the roles as the edges constituting the graph, so as to better represent the characteristics of the event itself and the relationship between the timing, position and the like of the event elements, and facilitate the prediction of subsequent events. The present invention can better express the relationship within the multi-relationship event, reduce information loss, and at the same time abstract the time and place into roles, and conveniently add time and space factors to the model.
[0016] In addition, the invention has a reliable design principle, a simple structure and a very broad application prospect. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0018] Figure 1 is a schematic flow chart of a method according to an embodiment of the present invention.
[0019] Figure 2 It is a graphical schematic diagram of the event knowledge graph of the method according to an embodiment of the present invention.
[0020] Figure 3 is a schematic block diagram of a system according to an embodiment of the present invention.
[0021] Figure 4 A schematic diagram of the structure of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0022] In order to enable those skilled in the art to better understand the technical solutions in the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0023] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in the specification of the present invention herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention.
[0024] The role-awareness-based graph construction method provided in the embodiment of the present invention is executed by a computer device, and accordingly, the role-awareness-based graph construction system runs in the computer device.
[0025] Figure 1 is a schematic flow chart of a method according to an embodiment of the present invention. Figure 1 The execution subject can be a role-aware graph construction system. According to different requirements, the order of the steps in the flowchart can be changed, and some can be omitted.
[0026] like Figure 1 As shown, the method includes: Step 110, extracting time, place and person from the event data, and using the extracted time, place and person as roles, and establishing relationships between the roles; Step 120, constructing entities in the event data into roles, using roles as virtual entity nodes, using multivariate relationships between roles as edges, and constructing a knowledge graph by constructing role vectors and pattern matrices; Step 130, construct a scoring function and a loss function, and based on the scoring function and the loss function, train the knowledge graph according to the strategy of minimizing the loss function.
[0027] To facilitate understanding of the present invention, the role-awareness-based graph construction method provided by the present invention is further described below based on the principle of the role-awareness-based graph construction method of the present invention and in combination with the process of constructing the role-awareness-based graph in the embodiment.
[0028] Specifically, the graph construction method based on role perception includes: S1. Extract time, place and people from event data, and use the extracted time, place and people as roles to establish relationships between roles.
[0029] Crawl event data from the target web page and save the event data to the basic database; use the information extraction model to extract time, place, people and event type from the event data; generate a temporal relationship based on the extracted time, generate a location relationship based on the extracted place, and generate a causal relationship of the event type based on the temporal relationship and the location relationship.
[0030] The specific steps include: Determine the target web pages: First, identify the list of web page URLs that need to be crawled, which may be one or more websites.
[0031] Analyze the structure of the web page: Use browser developer tools (such as Chrome DevTools) to analyze the HTML structure of the web page, dynamic content rendered by JavaScript, and possible API interfaces.
[0032] Write a crawler: Choose a suitable programming language and library (such as Python's Scrapy, BeautifulSoup, Requests, or Selenium) to write a crawler based on the structure of the web page. Make sure to comply with the robots.txt file regulations of the target website to avoid placing too much burden on the website.
[0033] Data crawling: Execute crawler programs to crawl event data from web pages, which may include titles, descriptions, timestamps, locations, participants, etc.
[0034] Design database structure: Design a suitable database table structure based on the characteristics of event data, including fields such as event ID, title, description, time, location, and people.
[0035] Select a database system: Choose an appropriate database system (such as MySQL, MongoDB, PostgreSQL, etc.) based on the amount of data and access frequency.
[0036] Data storage: After the crawled data is cleaned, it is inserted into the database in batches or in real time.
[0037] Select or train a model: Select a suitable natural language processing (NLP) model or train a custom model to perform information extraction tasks. Common models include named entity recognition (NER), relation extraction, etc.
[0038] Data preprocessing: Perform text cleaning, word segmentation, part-of-speech tagging and other preprocessing tasks on the event descriptions in the database.
[0039] Perform information extraction: Use the trained model to extract time, place, person, and event type from the preprocessed text.
[0040] Time series relationship generation: Sort events according to the extracted time information and build a chronological relationship between events.
[0041] Position relationship generation: Use location information to analyze the relative position or movement trajectory of events in space and construct a position relationship diagram.
[0042] Causal relationship generation: Combining event types, temporal relationships, and location relationships, causal reasoning algorithms (such as causal graphs, causal chains, etc.) are used to analyze the causal relationships between events.
[0043] Relational databases, NoSQL databases, and time series databases are used to store the attributes of event entities and the relationships between event entities. Specifically, the event information database stores the basic information, role information, and relationship information between roles of event data entities. The basic information includes the entity's own attribute values such as name, classification, and characteristics. The role information includes important element classifications such as time, location, and person. The relationship information between roles includes temporal relationships, location management, and causal relationships.
[0044] In another embodiment of the present invention, event information is extracted through the currently common Span-based Entity and Relation Transformer model.
[0045] Taking the multi-relationship event "At 17:00 on January 1, 2024, a traffic accident occurred at Xizhimen Bridge in Beijing, resulting in severe congestion of about 3 kilometers from east to west on Xizhimen Street. The police have intervened and implemented traffic control" as an example, the information extraction results are as follows: Entity Recognition: Entity 1: Xizhimen Bridge, Beijing; Entity 2: Traffic accident; Entity 3: Xizhimen Street; Entity 4: Police.
[0046] Relation extraction: Xizhimen Bridge in Beijing is related to the location where the traffic accident occurred; The traffic accident was related to congestion on Xizhimen Avenue from east to west; The police are concerned with intervening and enforcing traffic control.
[0047] Event element extraction: Time: 17:00, January 1, 2024 (time of accident); Location: Xizhimen Bridge, Beijing (where the accident occurred); Consequences: Xizhimen Avenue was severely congested for about 3 kilometers from east to west (a direct consequence of the accident); Status: Currently (police have intervened and implemented traffic control).
[0048] Event classification: traffic accident.
[0049] The above event extraction results define the event as a traffic accident, but fail to fully identify the multiple relationships among accidents, congestion, and management, and only identify the spatiotemporal information related to the accident, resulting in serious information loss.
[0050] S2. Construct entities in event data into roles, use roles as virtual entity nodes, and use multivariate relationships between roles as edges. Construct a knowledge graph by constructing role vectors and pattern matrices.
[0051] Construct a basis vector for the role, and generate a role vector using the basis vector and a weight matrix; pre-generate an embedding vector of an event type, and determine the event embedding vector corresponding to the role entity based on the event type corresponding to the role entity; determine the relationship embedding vector of the role entity based on the relationship type between the role entities; decompose a multi-relation event into multiple triples and a set of additional attribute values of the triples by introducing role entities; introduce multiple triples of the multi-relation event and a set of additional attribute values of the triples into a pattern matrix to capture the compatibility of the role with all related entities, wherein the rows and columns of the pattern matrix represent the role entities of different multi-relation events, and the elements of the pattern matrix represent the relationships between the role entities.
[0052] The specific steps include: Define the character attributes: First, clarify the basic attributes of the character, such as name, occupation, skills, etc. These attributes will serve as the basis for building basis vectors.
[0053] Constructing a basis vector space: Based on the number of character attributes, a multi-dimensional basis vector space is constructed. Each dimension corresponds to a character attribute, and standardized values or one-hot encoding are used to indicate the presence or absence or strength of different attributes.
[0054] Generate weight matrix: Generate a weight matrix for each role based on the context or task requirements. This matrix determines the contribution of each element in the basis vector to the final role vector. The weights can be trained by machine learning algorithms or manually set based on expert knowledge.
[0055] Calculate the character vector: Multiply the basis vector by the weight matrix to get the final vector representation of each character. This vector contains all the key information of the character and can be used for subsequent calculations and analysis.
[0056] Define event types: Make it clear what types of events exist, such as battles, transactions, meetings, etc.
[0057] Generate event type embeddings: Generate a unique embedding vector for each event type. These vectors can be randomly initialized and trained through machine learning algorithms such as Word2Vec, GloVe, or specialized embedding learning models to capture the semantic relationships between event types.
[0058] Matching roles and event types: According to the event types that the role entity participates in, the corresponding event type embedding is assigned to the role entity.
[0059] Calculate event embedding vector (optional): If the role entity is associated with multiple event types, consider aggregating the embedding vectors of these event types (such as average, weighted sum, etc.) to form a comprehensive event embedding vector for the role entity.
[0060] Define relationship types: clarify the various types of relationships that may exist between role entities, such as friends, enemies, superiors and subordinates, etc.
[0061] Generate relation type embeddings: Generate a unique embedding vector for each relation type, similar to how we generated the event type embeddings.
[0062] Matching roles and relationship types: According to the actual relationship between role entities, the corresponding relationship type embeddings are assigned to the corresponding role entity pairs.
[0063] Compute relation embedding vectors: For each role entity, aggregate its relation type embeddings with all other related entities to form the relation embedding vector for that role.
[0064] Identify multi-relation events: In complex scenarios, an event may involve multiple role entities and multiple relationships.
[0065] Decompose into triples: Decompose multi-relation events into multiple basic triples, each of which contains two role entities and one relationship type.
[0066] Collect additional attribute values: In addition to the basic information of the triple, additional attribute values of each triple are collected, such as time, place, degree, etc. These values help to describe the event more comprehensively.
[0067] Design a pattern matrix: According to the complexity of multi-relationship events, design a suitable pattern matrix. The rows and columns of the matrix represent the role entities in different multi-relationship events, and the elements of the matrix represent the relationship or compatibility between the role entities.
[0068] Fill the pattern matrix: Map each triple and its additional attribute values to the corresponding position of the pattern matrix. For relationships or compatibilities, you can use numerical values or symbols to indicate their strength and type.
[0069] Compute compatibility: Using the information in the pattern matrix, calculate the compatibility or association between the role entities. This can be achieved through matrix operations (such as matrix multiplication, element addition, etc.), and can be combined with additional weights or thresholds to optimize the results.
[0070] In one embodiment of the present invention, still taking the event "At 17:00 on January 1, 2024, a traffic accident occurred at Xizhimen Bridge in Beijing, resulting in severe congestion of about 3 kilometers from east to west on Xizhimen Street. The police have intervened and implemented traffic control" as an example, the knowledge graph is graphically represented as follows: Figure 2 shown.
[0071] In this model, traffic accidents, traffic congestion, and traffic control are identified as three related events. The time, location, and people of each event are defined as roles, and the timing, location, and causal relationships between the roles are established.
[0072] (1) Designing character vectors In the event knowledge graph built based on the RAM model, roles are shared in n-ary relational facts, and the compatibility between roles and events determines the rationality of fact expression.
[0073] The present invention constructs a basis vector u for the character i , the embedding of each character is calculated based on the combination of basis vectors, and the character space of basis vectors is represented as follows: ; Among them, ur i is the i-th role of the r-th relationship, and ar i is the corresponding weight matrix.
[0074] ; For different role entities, a multi-embedding mechanism is designed to map an entity to m embeddings, each of which includes d dimensions.
[0075] (2) Designing a relationship model matrix The rows and columns of the matrix represent the role entities of different multi-events, and the elements in the matrix represent the relationship between the role entities, as shown in Table 1.
[0076] Table 1
[0077] The multi-relational facts are decomposed into multiple triples by introducing role entities and embedded into the relation matrix. An n-ary relational fact is decomposed into triples as follows: ; Among them, r, a1, a2…, a m Belongs to the relation set R, s, o, v1, v2…, v i belongs to the entity set ε. (s, r, o) is the main triple, {(a i ,v i ):i=1,2,…,m} is the additional attribute value description of the main triple.
[0078] Introducing the pattern matrix P, the calculation process of Pr i is as follows: ; Pri represents the pattern matrix of the i-th role of the r-th relation, and the j-th row Pri[j,:] represents the consistency of the j-th role entity in the fact with the role in the multi-embedding.
[0079] S3. Construct a scoring function and a loss function, and based on the scoring function and the loss function, train the knowledge graph according to the strategy of minimizing the loss function.
[0080] Construct a distance-based scoring function: ; Among them, Pr i[1,:]E1 represents the correlation between the i-th role and the first entity in the relation r.
[0081] The loss function is defined as negative log-likelihood loss to maximize the logarithm of the probability of occurrence of the observed fact set in the model, and a regularization term is added to the loss function to penalize the complexity of the embedding vector; all multi-tuples that do not contain missing entities are extracted from the multi-tuple relational knowledge base as training samples, and the corresponding observed fact set is constructed; the embedding vector and other learnable parameters of the knowledge graph model are optimized using the gradient descent method to minimize the loss function; during the training process, the performance of the knowledge graph model is regularly evaluated on the validation set, and the knowledge graph model structure, learning rate, and regularization strength are adjusted as needed; for multi-tuples with missing entities, the trained knowledge graph model is used to calculate the estimated score of the multi-tuple after all possible candidate entities are filled, and the entity with the highest estimated score is selected as the prediction result; an iterative completion strategy is designed to first complete a part of the determined entities, and then predict again based on the updated knowledge graph until convergence is reached or a specific stopping condition is met; all completed multi-tuples are reintegrated into the knowledge graph.
[0082] The final knowledge graph model can be applied to multiple fields such as finance, transportation, public opinion monitoring, etc., and can construct a knowledge graph based on current events. It can also further preview the evolution direction of events and predict future events, such as financial trend forecasts, traffic congestion warnings, etc.
[0083] Still taking the multi-relationship event "At 17:00 on January 1, 2024, a traffic accident occurred at Xizhimen Bridge in Beijing, resulting in severe congestion of about 3 kilometers from east to west on Xizhimen Street. The police have intervened and implemented traffic control" as an example, the information expressed by the event knowledge graph is as follows: Event Entity Recognition: Event 1: Traffic accident; Event 2: Traffic congestion; Event 3: Traffic control.
[0084] Role Identification: Role 1: Time; Role 2: Location; Role 3: Character.
[0085] Relation extraction: Traffic congestion occurs after a traffic accident; Traffic control occurs after traffic congestion; The location of the traffic jam is close to the location of the traffic accident; Traffic control occurs at the same location as the traffic jam; Traffic police assist perpetrators in dealing with traffic accidents and traffic jams.
[0086] Event element extraction: Time 1: 17:00, January 1, 2024 (time of accident); Time 2: 17:00, January 1, 2024 (congestion start time); Time 3: 18:00, January 1, 2024 (traffic control time, i.e. current time); Location 1: Xizhimen Bridge, Beijing (where the accident occurred); Location 2: Xizhimen Street, Beijing (where the congestion occurred); Location 3: Xizhimen Street, Beijing (traffic control location).
[0087] Event classification: traffic accident, traffic congestion, traffic control.
[0088] It can be clearly seen from the above examples that the knowledge graph built based on the RAM model can express the causal relationship and temporal relationship between multiple events more clearly.
[0089] In some embodiments, the role-aware graph construction system may include multiple functional modules composed of computer program segments. The computer programs of the various program segments in the role-aware graph construction system may be stored in a memory of a computer device and executed by at least one processor to perform (see Figure 1 Description) Capabilities built on role-aware graphs.
[0090] In this embodiment, the role-aware graph construction system can be divided into multiple functional modules according to the functions it performs, such as Figure 3As shown. The functional modules of the system 300 may include: an information extraction module 310, a graph construction module 320 and an iterative training module 330. The module referred to in the present invention refers to a series of computer program segments that can be executed by at least one processor and can complete fixed functions, which are stored in a memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.
[0091] The information extraction module is used to extract time, place and people from event data, and use the extracted time, place and people as roles to establish relationships between roles; The graph construction module is used to construct entities in event data into roles, use roles as virtual entity nodes, and use multivariate relationships between roles as edges. It constructs a knowledge graph by constructing role vectors and pattern matrices. The iterative training module is used to construct a scoring function and a loss function, and based on the scoring function and the loss function, the knowledge graph is trained according to a strategy of minimizing the loss function.
[0092] Optionally, as an embodiment of the present invention, the information extraction module includes: An event crawling unit, used to crawl event data from a target web page and save the event data to a basic database; An entity extraction unit, used to extract time, place, person and event type from event data using an information extraction model; The relationship generation unit is used to generate a temporal relationship based on the extracted time, generate a positional relationship based on the extracted location, and generate a causal relationship of an event type based on the temporal relationship and the positional relationship.
[0093] Optionally, as an embodiment of the present invention, the graph construction module includes: A vector construction unit, used to construct a basis vector for the character, and generate a character vector using the basis vector and a weight matrix; A first embedding unit, configured to pre-generate an embedding vector of an event type, and determine an event embedding vector corresponding to the role entity based on the event type corresponding to the role entity; A second embedding unit, configured to determine a relation embedding vector of the role entity based on the relation type between the role entities; An event decomposition unit, used to decompose a multi-relation event into a plurality of triples and a set of additional attribute values of the triples by introducing role entities; A matrix introduction unit is used to introduce multiple triples of multi-relation events and sets of additional attribute values of triples into a pattern matrix to capture the compatibility of the role with all related entities. The rows and columns of the pattern matrix represent role entities of different multi-events, and the elements of the pattern matrix represent the relationships between role entities.
[0094] Optionally, as an embodiment of the present invention, the iterative training module includes: Function building block for building distance-based scoring functions: ; Among them, Pr i[1,:]E1 represents the correlation between the i-th role and the first entity in the relation r; The loss definition unit is used to define the loss function as negative log-likelihood loss, maximize the logarithm of the probability of occurrence of the observed fact set in the model, and add a regularization term to the loss function to penalize the complexity of the embedding vector; The basic training unit is used to extract all multi-tuples that do not contain missing entities from the multi-tuple relational knowledge base as training samples and construct the corresponding observation fact set; A learning optimization unit, which is used to optimize the embedding vectors and other learnable parameters of the knowledge graph model using the gradient descent method to minimize the loss function; The parameter adjustment unit is used to regularly evaluate the performance of the knowledge graph model on the validation set during the training process, and adjust the knowledge graph model structure, learning rate, and regularization strength as needed; The entity prediction unit is used to calculate the estimated scores of all possible candidate entity-filled tuples with missing entities using the trained knowledge graph model, and select the entity with the highest estimated score as the prediction result; The entity completion unit is used to design an iterative completion strategy, which first completes a part of the determined entities and then predicts again based on the updated knowledge graph until convergence is reached or a specific stopping condition is met; The graph update unit is used to reintegrate all completed multi-tuples into the knowledge graph.
[0095] Figure 3 A schematic diagram of the structure of a terminal 400 provided in an embodiment of the present invention. The terminal 400 can be used to execute the role-awareness-based graph construction method provided in an embodiment of the present invention.
[0096] The terminal 400 may include: a processor 410, a memory 420 and a communication unit 430. These components communicate via one or more buses. Those skilled in the art will appreciate that the server structure shown in the figure does not limit the present invention, and it may be a bus structure or a star structure, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0097] The memory 420 can be used to store the execution instructions of the processor 410, and the memory 420 can be implemented by any type of volatile or non-volatile storage terminal or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. When the execution instructions in the memory 420 are executed by the processor 410, the terminal 400 can perform some or all of the steps in the following method embodiments.
[0098] The processor 410 is the control center of the storage terminal, and uses various interfaces and lines to connect various parts of the entire electronic terminal. It runs or executes software programs and / or modules stored in the memory 420, and calls data stored in the memory to perform various functions of the electronic terminal and / or process data. The processor can be composed of an integrated circuit (IC), for example, it can be composed of a single packaged IC, or it can be composed of multiple packaged ICs with the same or different functions. For example, the processor 410 can include only a central processing unit (CPU). In the embodiment of the present invention, the CPU can be a single computing core or multiple computing cores.
[0099] The communication unit 430 is used to establish a communication channel so that the storage terminal can communicate with other terminals, receive user data sent by other terminals or send user data to other terminals.
[0100] The present invention also provides a computer storage medium, wherein the computer storage medium may store a program, and when the program is executed, the program may include some or all of the steps in each embodiment provided by the present invention. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM).
[0101] Therefore, the present invention abstracts the time, place, and people in multi-relationship events into roles as specific virtual entity nodes of the event knowledge graph, and the multi-relationships between roles as the edges of the graph to better represent the characteristics of the event itself and the timing, position, and other relationships between event elements, so as to facilitate the prediction of subsequent events. The present invention can better express the internal relationships of multi-relationship events and reduce information loss. At the same time, it abstracts time and place into roles, and can conveniently add time and space factors to the model. The technical effects that can be achieved by this embodiment can be found in the description above, and will not be repeated here.
[0102] Those skilled in the art can clearly understand that the technology in the embodiments of the present invention can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solution in the embodiments of the present invention, in essence or in other words, the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, and other media that can store program codes, including several instructions for enabling a computer terminal (which can be a personal computer, a server, or a second terminal, a network terminal, etc.) to execute all or part of the steps of the methods described in each embodiment of the present invention.
[0103] In this specification, the same or similar parts between the various embodiments can be referred to each other. In particular, for the terminal embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description in the method embodiment.
[0104] In the several embodiments provided by the present invention, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of systems or modules, which can be electrical, mechanical or other forms.
[0105] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0106] In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.
[0107] Although the present invention has been described in detail with reference to the accompanying drawings and in combination with the preferred embodiments, the present invention is not limited thereto. Without departing from the spirit and essence of the present invention, a person of ordinary skill in the art may make various equivalent modifications or substitutions to the embodiments of the present invention, and these modifications or substitutions shall be within the scope of the present invention. Any person of ordinary skill in the art may easily think of changes or substitutions within the technical scope disclosed by the present invention, and these shall be within the scope of protection of the present invention.
Claims
1. A graph construction method based on role perception, characterized in that: include: Extract time, place and people from event data, and use the extracted time, place and people as roles to establish relationships between roles; The entities in the event data are constructed as roles, with roles as virtual entity nodes and multivariate relationships between roles as edges. The knowledge graph is constructed by constructing role vectors and pattern matrices. A scoring function and a loss function are constructed, and based on the scoring function and the loss function, the knowledge graph is trained according to a strategy of minimizing the loss function.
2. The method according to claim 1, characterized in that Extract time, place, and person from event data, and use the extracted time, place, and person as roles to establish relationships between roles, including: Crawl event data from a target web page and save the event data to a basic database; Use information extraction models to extract time, place, people and event types from event data; A temporal relationship is generated based on the extracted time, a positional relationship is generated based on the extracted location, and a causal relationship of the event type is generated based on the temporal relationship and the positional relationship.
3. The method according to claim 1, characterized in that The entities in the event data are constructed as roles, roles are used as virtual entity nodes, and the multivariate relationships between roles are used as edges. The knowledge graph is constructed by constructing role vectors and pattern matrices, including: Constructing basis vectors for the character, and generating a character vector using the basis vectors and a weight matrix; Pre-generate an embedding vector of an event type, and determine an event embedding vector corresponding to the role entity based on the event type corresponding to the role entity; Based on the relationship types between role entities, determine the relationship embedding vectors of role entities; Decompose multi-relation events into multiple triples and sets of additional attribute values of triples by introducing role entities; Multiple triples of multi-relation events and sets of additional attribute values of triples are introduced into a pattern matrix to capture the compatibility of a role with all related entities. The rows and columns of the pattern matrix represent role entities of different multi-relation events, and the elements of the pattern matrix represent the relationships between role entities.
4. The method according to claim 1, characterized in that Constructing a scoring function and a loss function, and training the knowledge graph based on the scoring function and the loss function according to a strategy of minimizing the loss function, including: Construct a distance-based scoring function: ; Among them, Pr i[1,:]E1 represents the correlation between the i-th role and the first entity in the relation r; The loss function is defined as negative log-likelihood loss, maximizing the logarithm of the probability of the observed fact set appearing in the model, and adding a regularization term to the loss function to penalize the complexity of the embedding vector; Extract all multi-tuples that do not contain missing entities from the multi-tuple relational knowledge base as training samples, and construct the corresponding observation fact set; Use gradient descent to optimize the embedding vectors and other learnable parameters of the knowledge graph model to minimize the loss function; During the training process, the performance of the knowledge graph model is regularly evaluated on the validation set, and the knowledge graph model structure, learning rate, and regularization strength are adjusted as needed; For a multi-tuple with missing entities, use the trained knowledge graph model to calculate the estimated scores of all possible candidate entities filled in the multi-tuple, and select the entity with the highest estimated score as the prediction result; Design an iterative completion strategy to first complete a portion of the determined entities, and then make predictions again based on the updated knowledge graph until convergence is reached or a specific stopping condition is met; Reintegrate all completed multi-tuples into the knowledge graph.
5. A graph construction system based on role perception, characterized in that: include: The information extraction module is used to extract time, place and people from event data, and use the extracted time, place and people as roles to establish relationships between roles; The graph construction module is used to construct entities in event data into roles, use roles as virtual entity nodes, and use multivariate relationships between roles as edges. It constructs a knowledge graph by constructing role vectors and pattern matrices. The iterative training module is used to construct a scoring function and a loss function, and based on the scoring function and the loss function, train the knowledge graph according to the strategy of minimizing the loss function.
6. The system according to claim 5, characterized in that The information extraction module comprises: An event crawling unit, used to crawl event data from a target web page and save the event data to a basic database; An entity extraction unit, used to extract time, place, person and event type from event data using an information extraction model; The relationship generation unit is used to generate a temporal relationship based on the extracted time, generate a positional relationship based on the extracted location, and generate a causal relationship of an event type based on the temporal relationship and the positional relationship.
7. The system according to claim 5, characterized in that The graph construction module includes: A vector construction unit, used to construct a basis vector for the character, and generate a character vector using the basis vector and a weight matrix; A first embedding unit, configured to pre-generate an embedding vector of an event type, and determine an event embedding vector corresponding to the role entity based on the event type corresponding to the role entity; A second embedding unit, configured to determine a relation embedding vector of the role entity based on the relation type between the role entities; An event decomposition unit, used to decompose a multi-relation event into a plurality of triples and a set of additional attribute values of the triples by introducing role entities; A matrix introduction unit is used to introduce multiple triples of multi-relation events and sets of additional attribute values of triples into a pattern matrix to capture the compatibility of the role with all related entities. The rows and columns of the pattern matrix represent role entities of different multi-events, and the elements of the pattern matrix represent the relationships between role entities.
8. The system according to claim 5, characterized in that The iterative training module includes: Function building block for building distance-based scoring functions: ; Among them, Pr i[1,:]E1 represents the correlation between the i-th role and the first entity in the relation r; The loss definition unit is used to define the loss function as negative log-likelihood loss, maximize the logarithm of the probability of occurrence of the observed fact set in the model, and add a regularization term to the loss function to penalize the complexity of the embedding vector; The basic training unit is used to extract all multi-tuples that do not contain missing entities from the multi-tuple relational knowledge base as training samples and construct the corresponding observation fact set; A learning optimization unit, which is used to optimize the embedding vectors and other learnable parameters of the knowledge graph model using the gradient descent method to minimize the loss function; The parameter adjustment unit is used to regularly evaluate the performance of the knowledge graph model on the validation set during the training process, and adjust the knowledge graph model structure, learning rate, and regularization strength as needed; The entity prediction unit is used to calculate the estimated scores of all possible candidate entity-filled tuples with missing entities using the trained knowledge graph model, and select the entity with the highest estimated score as the prediction result; The entity completion unit is used to design an iterative completion strategy, which first completes a part of the determined entities and then predicts again based on the updated knowledge graph until convergence is reached or a specific stopping condition is met; The graph update unit is used to reintegrate all completed multi-tuples into the knowledge graph.
9. A terminal, characterized in that: include: A memory, used for storing a graph construction program based on role perception; A processor, configured to implement the steps of the role-awareness-based graph construction method as described in any one of claims 1 to 4 when executing the role-awareness-based graph construction program.
10. A computer-readable storage medium storing a computer program, characterized in that: The readable storage medium stores a graph construction program based on role perception, and when the graph construction program based on role perception is executed by the processor, the steps of the graph construction method based on role perception as described in any one of claims 1-4 are implemented.
Citation Information
Cited By
Crowd flow prediction method and apparatus
WO2026184317A1