Entity relationship extraction method and system for construction of knowledge graph in financial field
Through the application of entity recognition and accommodation analysis technologies in the financial field, combining the frequency and semantic similarity scores, the problem of low accuracy of physical relations in the financial field of knowledge maps is solved, and more efficient and accurate effect extraction results are achieved.
Patent Information
- Application Number
- CN202411444299.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-10-16
AI Technical Summary
The prior art has low accuracy in the construction of knowledge graphs in the financial field, especially in poor performance when dealing with complex professional terms and contexts, and has high cost of rules-based methods and limited generalization capabilities of machine learning-based methods.
Adopt a method of drawing method for physical relations in the financial field. By acquiring and processing financial text data, using the pre -trained natural language processing model for physical identification, combining the analysis of technologies to extract the relationship between entity in combination Similar scores build a knowledge map.
It improves the accuracy and efficiency of physical relations, can more accurately handle complex financial professional terms and context, reduce the cost of artificial maintenance rules, and improve the generalization of models.
Smart Images

Figure CN119378494A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of knowledge graph technology, and in particular, to an entity relationship extraction method and system for constructing a knowledge graph in the financial field. Background Art
[0002] With the increasing globalization and informatization of financial markets, a large amount of unstructured text data has been generated in the financial field, such as news reports, research reports, regulatory documents, etc. These data contain rich information and are of great value for market trend analysis, risk management, compliance monitoring, etc. However, how to efficiently extract useful information from massive text data and structure it for further analysis and application has become a major challenge facing the financial industry. Therefore, an efficient and accurate entity relationship extraction technology is needed to support the construction of financial knowledge graphs.
[0003] At present, in the process of building knowledge graphs in the financial field, common entity relationship extraction methods mainly include rule-based methods, machine learning-based methods, and methods that combine the two. Among them, rule-based methods rely on manually defined templates or regular expressions to match entities and relationships; machine learning-based methods automatically learn the representation of entities and relationships through training models; and hybrid methods attempt to combine the advantages of both and use rules to guide model learning. Although these methods have solved the problem to a certain extent, they still have shortcomings when facing the complex and ever-changing professional terms and contexts in the financial field.
[0004] When applied to the financial field, existing entity relationship extraction methods often have low extraction accuracy due to a lack of understanding of financial expertise, especially in dealing with long-tail entities and complex relationships. In addition, rule-based methods require a lot of manpower to maintain the rule set, making it difficult to adapt to the rapidly changing financial market; while machine learning-based methods can learn automatically, the annotation cost of training data is high and the model generalization ability is limited. Therefore, it is urgent to develop a more intelligent and efficient entity relationship extraction method to meet the needs of knowledge graph construction in the financial field. Summary of the invention
[0005] The embodiments of the present application provide an entity relationship extraction method and system for constructing a knowledge graph in the financial field, so as to solve the problem of poor accuracy of entity relationship extraction in the prior art.
[0006] In a first aspect, the present application embodiment provides an entity relationship extraction method for constructing a knowledge graph in the financial field, including:
[0007] Obtaining raw text data in the financial field;
[0008] Preprocessing the original text data, including word segmentation, stop word removal, and part-of-speech tagging operations, to obtain preprocessed text;
[0009] Performing entity recognition on the preprocessed text using a pretrained natural language processing model to determine entities and their entity types in the text;
[0010] Determining dependency relationships between the entities using dependency parsing techniques;
[0011] Extracting potential relationships between entities according to the dependency relationships and constructing a relationship candidate set;
[0012] Scoring each pair of entities and their relationships in the relationship candidate set to determine the relationship strength between the entities in the relationship candidate set;
[0013] Relations with scores higher than a preset threshold are added to the knowledge graph in the financial field.
[0014] Optionally, the using dependency syntactic analysis technology to determine the dependency relationship between the entities includes:
[0015] Applying a dependency syntactic analysis algorithm to analyze the preprocessed text to obtain a dependency tree structure;
[0016] A connection path between entities is determined based on the dependency tree structure to extract direct or indirect relationships between entities.
[0017] Optionally, scoring each pair of entities and their relationships in the relationship candidate set to determine the relationship strength between the entities in the relationship candidate set includes:
[0018] The relationship frequency between each pair of entities is calculated, and the relationship frequency is defined as:
[0019]
[0020] Where F(e1, e2) represents the relationship frequency between entity e2 and entity e1, e1 and e2 represent the first entity and the second entity between each pair of entities, respectively. i represents the relation instance in document i, δ(e1, e2, d i ) represents the indicator function. When e1 and e2 are in document d i When it appears in, the value is 1, otherwise it is 0, and N represents the total number of documents;
[0021] The relationship strength between entities is calculated based on the relationship frequency, and the relationship strength is defined as:
[0022]
[0023] Among them, S(e1, e2) represents the relationship strength between entity e1 and entity e2 calculated according to the relationship frequency, α, β, γ, θ are preset parameters, and F(e2, e1) represents the relationship frequency between entity e2 and entity e1.
[0024] Optionally, the method further includes: performing semantic similarity evaluation on entity relationships in the relationship candidate set to filter out low-quality relationships;
[0025] Wherein, the semantic similarity evaluation includes:
[0026] Calculate the semantic vector for each pair of entities;
[0027] The cosine similarity is used to calculate the similarity between the semantic vectors, and the similarity is defined as:
[0028]
[0029] Wherein, sim(v1, v2) represents the similarity between the semantic vectors of the first entity and the second entity, and V1 and v2 represent the semantic vectors of the first entity and the second entity respectively;
[0030] Filter out entity relations in the relation candidate set whose semantic similarity is lower than a preset threshold.
[0031] Optionally, the performing entity recognition on the preprocessed text using a pretrained natural language processing model includes:
[0032] Use pre-trained natural language processing models for entity recognition;
[0033] The preprocessed text is input into the natural language processing model to obtain the boundary positions of entities in the text and their entity types.
[0034] Optionally, it also includes:
[0035] A deep learning model is used to perform secondary screening on the relationship candidate set to improve the accuracy of relationship extraction.
[0036] The secondary screening of the relationship candidate set by using the deep learning model includes:
[0037] Construct a bidirectional long short-term memory network model based on attention mechanism;
[0038] Using the bidirectional long short-term memory network model to extract features from each pair of entities and their contexts;
[0039] The extracted features are input into the fully connected layer, and the probability distribution of each entity pair belonging to different relationship categories is output through the activation function;
[0040] The relationship category with the highest probability is selected as the final prediction result.
[0041] Optionally, it also includes:
[0042] Using a rule-based logical reasoning system to verify the relationship candidate set to further improve the accuracy of relationship extraction;
[0043] The logical reasoning system comprises:
[0044] Define a set of inference rules R based on professional knowledge in the financial field;
[0045] For each pair of entity relationships e1, e2, the inference rule set R is used to verify their logical consistency to determine the consistency score, where the consistency score is defined as:
[0046]
[0047] Where C(e1, e2) represents the consistency score of a given entity pair (e1, e2), η r is the weight coefficient of rule r, where rule r belongs to a specific instance in the inference rule set R, ζ(e1, e2, r) is the applicability index of rule r applied to entity pair e1, e2, and its value range is [0,1]. It takes the value of 1 when rule r is applicable to entity pair e1, e2, otherwise it takes the value of 0.
[0048] Optionally, the step of scoring each pair of entities and their relationships in the relationship candidate set to determine the relationship strength between the entities in the relationship candidate set further includes:
[0049] A multi-dimensional evaluation is performed on each pair of entities and their relationship in the relationship candidate set, wherein the multi-dimensional evaluation includes:
[0050] A multi-dimensional feature vector that defines the relationship, including relationship frequency, semantic similarity, and consistency score;
[0051] The multi-dimensional feature vector is classified using a support vector machine to determine the strength of the relationship between entities, which is defined as:
[0052]
[0053] Among them, X(e1, e2) represents the multi-dimensional feature vector of each pair of entity relationships, SVM(X(e1, e2)) represents the support vector machine's estimation of the relationship strength of each pair of entities (e1, e2), m represents the number of training samples, and y i is the label of the i-th training sample, α i is the Lagrange multiplier corresponding to the i-th training sample, K(X(e1, e2), X i) is the kernel function, X i is the multi-dimensional feature vector of the training sample, and b is the bias term.
[0054] Optionally, the method further includes: optimizing the structure of the knowledge graph using a graph-based algorithm;
[0055] The optimizing the structure of the knowledge graph using a graph-based algorithm includes:
[0056] Define a graph G(V, E), where V represents a set of entities and E represents a set of relationships between entities;
[0057] For each pair of entities (e1, e2) ∈ E in the graph G, calculate the weight W(e1, e2) of each pair of entities, defined as:
[0058] W(e1, e2)=λ1×S(e1, e2)+λ2×C(e1, e2)+λ3×SVM(X(e1, e2))
[0059] Wherein, λ1, λ2, λ3 are preset weight coefficients, S(e1, e2) represents the relationship strength between entity e1 and entity e2 calculated according to the relationship frequency, C(e1, e2) is the consistency score between entity e1 and entity e2, and SVM(X(e1, e2)) represents the estimation of the relationship strength of each pair of entities (e1, e2) by the support vector machine;
[0060] Use graph-based algorithms to update the weights of entities to optimize the graph structure.
[0061] Optionally, it also includes:
[0062] An uncertainty evaluation is performed on each pair of entities and their relationships in the relationship candidate set to determine an uncertainty evaluation value of each pair of entities, wherein the uncertainty evaluation value is defined as:
[0063]
[0064] Among them, U(e1, e2) represents the uncertainty evaluation value of a given entity pair (e1, e2), R i is the i-th relationship category, p(R i |e1, e2) is the relationship R for a given entity pair e1, e2 i The conditional probability, p(R i ) is the relationship R i The prior probability of , n is the number of relationship categories;
[0065] The step of performing uncertainty assessment on each pair of entities and their relationship in the candidate relationship set further includes:
[0066] Mutual information is used to measure the degree of dependence between entity pairs and their relations, which is defined as:
[0067]
[0068] Among them, MI(e1, e2, R) represents mutual information, which is used to measure the degree of dependence between the entity pair (e1, e2) and its relationship R, R represents the set of relationship categories of the entity pair (e1, e2), r represents a specific relationship in the relationship category R, p(r|e1, e2) is the conditional probability of relationship r given the entity pair e1, e2, and p(r) is the prior probability of relationship r.
[0069] Optionally, it also includes:
[0070] A neural network model is used to jointly evaluate each pair of entities and their relationships in the relationship candidate set to determine a joint evaluation value, wherein the joint evaluation value is defined as:
[0071]
[0072] Among them, J(e1, e2) represents the joint evaluation value of the given entity pair (e1, e2), NN is a neural network model, and its output is the relationship evaluation score of the entity pair e1, e2, SVM(X(e1, e2)) represents the support vector machine’s estimation of the relationship strength of the given entity (e1, e2), C(e1, e2) represents the consistency score of the given entity pair (e1, e2), U(e1, e2) represents the uncertainty evaluation value of the given entity pair (e1, e2), and MI(e1, e2, R) represents the degree of dependence between the given entity pair (e1, e2) and its relationship R.
[0073] In the second aspect, the embodiment of the present application provides an entity relationship extraction system for building a knowledge graph in the financial field, including:
[0074] The acquisition module is used to obtain the original text data in the financial field;
[0075] A preprocessing module is used to preprocess the original text data, including word segmentation, stop word removal, and part-of-speech tagging operations, to obtain preprocessed text;
[0076] A determination module is used to perform entity recognition on the preprocessed text using a pretrained natural language processing model to determine entities and their entity types in the text; and to determine dependency relationships between the entities using dependency syntactic analysis technology;
[0077] A construction module, used to extract potential relationships between entities according to the dependency relationship and construct a relationship candidate set;
[0078] The determination module is further used to score each pair of entities and their relationship in the relationship candidate set to determine the relationship strength between the entities in the relationship candidate set;
[0079] Relations with scores higher than a preset threshold are added to the knowledge graph in the financial field.
[0080] In a third aspect, an embodiment of the present application provides a method comprising a processing component and a storage component; the storage component stores one or more computer instructions; the one or more computer instructions are used to be called and executed by the processing component to implement an entity relationship extraction method for constructing a knowledge graph in the financial field as described in the first aspect above.
[0081] In a fourth aspect, an embodiment of the present application provides a computer storage medium storing a computer program. When the computer program is executed by a computer, it implements an entity relationship extraction method for constructing a knowledge graph in the financial field as described in the first aspect above.
[0082] In the embodiment of the present application, original text data in the financial field is obtained; the original text data is preprocessed, including word segmentation, stop word removal, and part-of-speech tagging operations to obtain preprocessed text; the preprocessed text is subjected to entity recognition using a pretrained natural language processing model to determine the entities and their entity types in the text; the dependency relationship between the entities is determined using dependency syntactic analysis technology; the potential relationship between the entities is extracted based on the dependency relationship, and a candidate relationship set is constructed; each pair of entities and their relationships in the candidate relationship set is scored to determine the strength of the relationship between the entities in the candidate relationship set; and the relationship with a score higher than a preset threshold is added to the knowledge graph in the financial field. The technical solution provided by the present application can improve the efficiency and accuracy of entity relationship extraction.
[0083] These and other aspects of the present application will become more clearly understood in the description of the following embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0084] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0085] Figure 1 A flowchart of an entity relationship extraction method for constructing a knowledge graph in the financial field provided in an embodiment of the present application;
[0086] Figure 2A schematic diagram of the structure of a method and system for extracting entity relationships for building a knowledge graph in the financial field provided in an embodiment of the present application;
[0087] Figure 3 A schematic diagram of the structure of a computing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0088] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0089] In some of the processes described in the specification and claims of this application and the above-mentioned figures, multiple operations that appear in a specific order are included, but it should be clearly understood that these operations may not be executed in the order in which they appear in this article or executed in parallel. The serial numbers of the operations, such as 101, 102, etc., are only used to distinguish between different operations, and the serial numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this article are used to distinguish different messages, devices, modules, etc., do not represent the order of precedence, and do not limit the "first" and "second" to be different types.
[0090] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0091] Figure 1 A flowchart of an entity relationship extraction method for constructing a knowledge graph in the financial field is provided for the embodiment of the present application, such as Figure 1 As shown, the method includes:
[0092] 101. Obtain original text data in the financial field;
[0093] In this step, obtaining raw text data in the financial field refers to collecting unstructured information related to finance from different sources. This information can include any form of text materials such as news reports, company financial reports, market analysis reports, social media posts, etc. These text data usually contain a lot of information about financial activities and market dynamics, which is of great significance for understanding market sentiment, predicting trends or conducting financial research.
[0094] In this application example, suppose we want to build a stock market sentiment analysis system. First, we need to collect a large amount of text data as input. We can obtain this data from the following aspects:
[0095] News website crawling: Use web crawling technology to crawl the latest news articles from financial news websites (such as Bloomberg, CNBC, etc.). The technologies involved here include HTTP request sending, HTML page parsing (BeautifulSoup and other tools), regular expression matching, etc.
[0096] Social Media API: Use the Application Programming Interface (API) provided by social media platforms such as the Twitter API to obtain tweets about specific stocks or financial markets through keyword search functions. This requires registering a developer account and applying for access rights.
[0097] Download company financial reports: Download the quarterly and annual financial statements of listed companies from the SEC's EDGAR database. This can be achieved through automated scripts that regularly check for updates and download the latest files.
[0098] For example, if we decide to get data from Twitter about the stock of "Apple Inc.", we can set up a Python script that connects to the Twitter API using the Tweepy library. The script would use a code snippet like this:
[0099] import tweepy
[0100] #Set your API key
[0101] consumer_key='your_consumer_key'
[0102] consumer_secret='your_consumer_secret'
[0103] access_token='your_access_token'
[0104] access_token_secret='your_access_token_secret'
[0105] #Authentication
[0106] auth=tweepy.OAuthHandler(consumer_key,consumer_secret)
[0107] auth.set_access_token(access_token,access_token_secret)
[0108] api = tweepy.API(auth)
[0109] #Search keywords
[0110] tweets=api.search(q='AAPL',lang='en',count=100)
[0111] #Save tweets to file
[0112] with open('apple_tweets.txt','w')as f:
[0113] for tweet in tweets:
[0114] f.write(tweet.text+'\n')
[0115] The above script will connect to the Twitter API and search for the last 100 English tweets containing "AAPL" (Apple's stock code), and then save the content of these tweets to a text file called apple_tweets.txt. In this way, we have obtained some raw text data about Apple.
[0116] 102. Preprocessing the original text data, including word segmentation, stop word removal, and part-of-speech tagging operations, to obtain preprocessed text;
[0117] In this step, preprocessing the original text data refers to a series of standardized operations performed on the text data in order to improve the effect of subsequent natural language processing tasks. These operations mainly include tokenization, stop words removal, and part-of-speech tagging.
[0118] Tokenization is the process of dividing continuous text into words or phrases, which is one of the basic steps in natural language processing.
[0119] Removing stop words means removing those very common but meaningless words from the text, such as "的", "是", "在", etc., because these words are not very helpful for understanding the text content in most cases.
[0120] Part-of-speech tagging is to assign a part-of-speech tag to each word, such as noun (Noun, NN), verb (Verb, VB), adjective (Adjective, JJ), etc., which is very useful for understanding the sentence structure and semantics.
[0121] In the embodiments of this application, we continue to use the tweet data about Apple Inc. obtained in the previous example for preprocessing. The following is a complete Python code example showing how to use the NLTK (Natural Language Toolkit) library to complete the tasks of word tokenization, stop word removal, and part-of-speech tagging:
[0122] import nltk
[0123] from nltk.corpus import stopwords
[0124] from nltk.tokenize import word_tokenize
[0125] from nltk import pos_tag
[0126] ## Ensure that the necessary NLTK resources have been downloaded
[0127] nltk.download('punkt')
[0128] nltk.download('stopwords')9nltk.download('averaged_perceptron_tagger')
[0129] # Load the stop word list
[0130] stop_words = set(stopwords.words('english'))
[0131] # Read the tweet data
[0132] with open('apple_tweets.txt', 'r') as file:
[0133] text = file.read()
[0134] # Word tokenization
[0135] tokens = word_tokenize(text)
[0136] #Remove stop words
[0137] filtered_tokens=[word for word in tokens if not word.lower()in stop_words]
[0138] #Part-of-speech tagging
[0139] tagged_tokens=pos_tag(filtered_tokens)
[0140] #Print results
[0141] print(tagged_tokens)
[0142] In this example, we first load the English stop word list. Next, we read the previously saved text data and tokenize it. Then, we create a new list filtered_tokens, which contains all the words after removing the stop words. Finally, we use the pos_tag function to tag the filtered words and print the tagged results.
[0143] In this way, we get preprocessed text data which can be further used for natural language processing tasks such as sentiment analysis, topic modeling, etc.
[0144] The output might look like this:
[0145] Filtered Tokens:['Apple','stock','price','rose','sharply','today','following','release','better-than-expected','earnings','results','.']
[0146] TaggedTokens:[('Apple','NNP'),('stock','NN'),('price','NN'),('rose','VBD'),('sharply','RB'),('today','NN'),('f ollowing','VBG'),('release','NN'),('better-than-expected','JJ'),('earnings','NNS'),('results','NNS'),('.','.')]
[0147] This example shows the basic process of how to tokenize a piece of English text, remove stop words, and perform part-of-speech tagging.
[0148] 103. Perform entity recognition on the preprocessed text using a pretrained natural language processing model to determine entities and entity types in the text;
[0149] Optionally, in step 103, "using a pre-trained natural language processing model to perform entity recognition on the pre-processed text" includes: using a pre-trained natural language processing model to perform entity recognition; inputting the pre-processed text into the natural language processing model to obtain the boundary position of the entity in the text and its entity type.
[0150] In this step, using a pre-trained natural language processing model to perform entity recognition on the pre-processed text refers to using a trained model to automatically identify named entities and their types in the text. Named Entity Recognition (NER) is an information extraction technology used to identify named entities in text, such as names of people, places, names of organizations, time, currency values, etc., and classify them into predefined categories. Entity recognition is an important task in natural language processing and is crucial for text understanding and information extraction.
[0151] The process of entity recognition usually includes two steps: first, determine the boundary position of the entity in the text, that is, identify which text segments constitute an entity; second, label these entities accordingly to indicate which type of entity they belong to. Pre-trained models are usually trained on large-scale corpora and can be better generalized to new data, thereby improving the accuracy and efficiency of entity recognition.
[0152] In the examples of this application, we will continue to use Python programming language and Spacy library to demonstrate how to perform entity recognition on a preprocessed text. Spacy is a powerful natural language processing library with built-in multiple pre-trained models that can be directly used for entity recognition tasks.
[0153] import spacy
[0154] #Load the pre-trained Spacy model
[0155] #The English model is selected here
[0156] nlp=spacy.load('en_core_web_sm')
[0157] #Sample text
[0158] text="Apple's stock price rose sharply today following the release of better-than-expected earnings results."
[0159] #Perform entity recognition on text
[0160] doc=nlp(text)
[0161] # Output the recognized entities and their types
[0162] for ent in doc.ents:
[0163] print(ent.text,ent.label_)
[0164] In this example, we first load Spacy's pre-trained model en_core_web_sm. This model has been trained on a large amount of English text and can recognize common named entity types very well. Next, we define a sample text and use the nlp object to process this text. After processing, we get all the recognized entities by traversing the doc.ents attribute and print out their text content and entity type.
[0165] Assuming the model successfully identifies entities in the text, the output might look something like this:
[0166] Apple ORG
[0167] This means that the model thinks that "Apple" is an organization name. Note that SpaCy supports multiple entity types, such as:
[0168] PERSON: Name
[0169] NORP: national / religious etc. groups
[0170] FAC: buildings, airports and other facilities
[0171] ORG:Organization
[0172] GPE: Geopolitical entities such as governments and cities
[0173] LOC: Non-GPE geographical location
[0174] PRODUCT: Item, such as a product or company
[0175] EVENT: Event
[0176] WORK_OF_ART: Work of Art
[0177] LAW:Law
[0178] LANGUAGE: Language
[0179] DATE: Date
[0180] TIME: time
[0181] PERCENT: Percent
[0182] MONEY: amount
[0183] QUANTITY: quantity
[0184] ORDINAL: Ordinal
[0185] CARDINAL: Cardinality
[0186] The above examples show how to use a pre-trained natural language processing model to perform entity recognition on pre-processed text. In this way, we can automatically extract meaningful information from the text and provide a basis for subsequent analysis or application.
[0187] 104. Determine the dependency relationship between the entities using dependency parsing technology;
[0188] Optionally, the "using dependency syntactic analysis technology to determine the dependency relationship between the entities" in step 104 includes: applying a dependency syntactic analysis algorithm to analyze the preprocessed text to obtain a dependency tree structure; determining the connection path between entities based on the dependency tree structure to extract the direct or indirect relationship between the entities.
[0189] In this step, using dependency parsing technology to determine the dependency relationship between the entities means understanding the sentence structure and extracting the relationship between entities by analyzing the dependency relationship between words in the sentence. Dependency parsing is a natural language processing technology that focuses on the direct dependency relationship between words rather than the overall structure of the sentence. The result of dependency parsing is usually represented in the form of a dependency tree, where each word is a node of the tree and the edges represent the dependency relationship between words.
[0190] Dependency parsing algorithms can be divided into many types according to different models and methods, such as early graph models, conversion models, etc., and now commonly used neural network models. Through dependency syntactic analysis, we can determine the "head word" of each word in a sentence and the type of relationship between them, so as to better understand the semantic structure of the sentence.
[0191] In the embodiments of this application, we will continue to use the Python programming language and the Spacy library to demonstrate how to perform dependency syntactic analysis on a preprocessed text and determine the dependency relationship between entities.
[0192] import spacy
[0193] #Load the pre-trained Spacy model
[0194] nlp=spacy.load('en_core_web_sm')
[0195] #Sample text
[0196] text="Apple's stock price rose sharply today following the release of better-than-expected earnings results."
[0197] #Perform entity recognition and dependency syntax analysis on the text
[0198] doc=nlp(text)
[0199] # Output the dependency relationship in the dependency tree structure
[0200] for token in doc:
[0201] print(f"{token.text:<12}{token.dep_:<10}{token.head.text:<12}{token.head.pos_}")
[0202] # Output dependencies between entities
[0203] for ent in doc.ents:
[0204] #Find the head word of the entity
[0205] head_token = ent.root
[0206] #Get all child nodes of the entity head word
[0207] children=list(head_token.children)
[0208] #Print the relationship between the entity and its child nodes
[0209] print(f"Entity:{ent.text},Head:{head_token.text},Children:{[child.text for child in children]}")
[0210] In this example, we first loaded the pre-trained model en_core_web_sm from Spacy. Then, we defined a sample text and used the nlp object to process the text. After processing, we traversed each word (token) in the doc object and output the dependency type (dep_), head word (head), and part of speech (pos_) of each word. This helps us understand the structure of the sentence.
[0211] Next, for each identified entity (ent), we find the root word (root) of the entity and get all the children nodes (children) of the root word. In this way, we can determine the direct or indirect relationship between the entity and its surrounding words.
[0212] Assuming the model successfully identified entities in the text and analyzed dependencies, the output might look something like this:
[0213]
[0214] In this output, we can see the dependencies of each word and its head word, as well as the dependencies of the entity "Apple". Through the dependency relationship, we can further analyze the relationship between the entity and other words, such as the relationship between "Apple" as a subject and its predicate verb "rose".
[0215] This example shows how to use dependency parsing techniques to determine the dependency relationships between entities in preprocessed text. In this way, we can gain a deeper understanding of the semantic structure in the text.
[0216] 105. Extracting potential relationships between entities according to the dependency relationship, and constructing a relationship candidate set;
[0217] In this step, extracting potential relationships between entities based on the dependency relationships and constructing a set of relationship candidates means extracting the relationships between entities from the dependency tree structure obtained by dependency syntactic analysis and forming a candidate relationship set. This process involves identifying direct or indirect connections between entities from dependency relationships and converting these connections into relationship candidates that can be further analyzed. These relationship candidates can be used to construct knowledge graphs, perform relationship classification, or other natural language processing tasks.
[0218] The relationship between entities can be extracted from multiple perspectives, such as dependency paths, syntactic roles (such as subject-verb-object relationships), semantic roles, etc. The purpose of constructing a set of relationship candidates is to provide candidates for subsequent automatic relationship classification or manual review.
[0219] In the embodiments of this application, we will continue to use the Python programming language and the Spacy library to demonstrate how to extract potential relationships between entities from dependency relationships and construct a relationship candidate set.
[0220] import spacy
[0221] #Load the pre-trained Spacy model
[0222] nlp=spacy.load('en_core_web_sm')
[0223] #Sample text
[0224] text="Apple's stock price rose sharply today following the release of better-than-expected earnings results."
[0225] #Perform entity recognition and dependency syntax analysis on the text
[0226] doc=nlp(text)
[0227] #Define a function to obtain the dependency path between entities
[0228] def get_dependency_path(entity1,entity2):
[0229] path=[]
[0230] visited=set()
[0231] def find_path(token,target):
[0232] if token==target:
[0233] return True
[0234] visited.add(token)
[0235] for child in token.children:
[0236] if child not in visited and find_path(child,target):
[0237] path.append((token,child))
[0238] return True
[0239] return False
[0240] #Find the path between two entities
[0241] for token in entity1:
[0242] for target in entity2:
[0243] if find_path(token,target):
[0244] break
[0245] return path
[0246] # Output the dependency relationship in the dependency tree structure
[0247] for token in doc:
[0248] print(f"{token.text:<12}{token.dep_:<10}{token.head.text:<12}{token.head.pos_}")
[0249] # Output dependencies between entities
[0250] relations = []
[0251] for ent1 in doc.ents:
[0252] for ent2 in doc.ents:
[0253] if ent1 !=ent2:
[0254] path=get_dependency_path([ent1.root],[ent2.root])
[0255] if path:
[0256] relations.append((ent1.text,ent2.text,path))
[0257] #Output relationship candidate set
[0258] for relation in relations:
[0259] print(f"Relation between'{relation[0]}'and'{relation[1]}':")
[0260] for token_pair in relation[2]:
[0261] print(f"{token_pair[0].text}->{token_pair[1].text}")
[0262] In this example, we first loaded the pre-trained model en_core_web_sm from Spacy. Then, we defined a sample text and used the nlp object to process the text. After processing, we traversed each word (token) in the doc object and output the dependency type (dep_), head word (head), and part of speech (pos_) of each word.
[0263] Next, we define a function get_dependency_path that takes two entities and tries to find a dependency path between them. We use a depth-first search (DFS) method to find the path and record each word pair on the path.
[0264] Then, we traverse each entity pair (ent1 and ent2), and if they are not the same entity, we call the get_dependency_path function to get the path between them. If a path exists, we store the path information in the relations list to form a relationship candidate set.
[0265] Finally, we output each pair of relations and their dependency paths in the relation candidate set.
[0266] Assuming the model successfully identified entities in the text and analyzed dependencies, the output might look something like this:
[0267]
[0268]
[0269] In this output, we can see the dependencies of each word and its head word, as well as the dependency paths between entities. Through these paths, we can construct a candidate set of relationships between entities and provide a basis for further relationship classification.
[0270] 106. Score each pair of entities and their relationships in the relationship candidate set to determine the relationship strength between the entities in the relationship candidate set;
[0271] Optionally, the step 106 of “scoring each pair of entities and their relationships in the relationship candidate set to determine the relationship strength between entities in the relationship candidate set” includes:
[0272] The relationship frequency between each pair of entities is calculated, and the relationship frequency is defined as:
[0273]
[0274] Where F(e1,e2) represents the relationship frequency between entity e2 and entity e1, e1 and e2 represent the first entity and the second entity between each pair of entities, respectively. i represents the relation instance in document i, δ(e1,e2,d i ) represents the indicator function. When e1 and e2 are in document d i When it appears in, the value is 1, otherwise it is 0, and N represents the total number of documents;
[0275] The relationship strength between entities is calculated based on the relationship frequency, and the relationship strength is defined as:
[0276]
[0277] Wherein, S(e1, e2) represents the relationship strength between entity e1 and entity e2 calculated according to the relationship frequency, α, β, γ, θ are preset parameters, and F(e2, e1) represents the relationship frequency between entity e2 and entity e1.
[0278] Relation Frequency:
[0279] Relation frequency refers to the number of times a pair of entities (e2, e1) co-occurs in multiple documents.
[0280] The calculation formula is where δ(e1,e2,d i ) is an indicator function that if e1 and e2 are in document d i If both appear in , the function returns 1, otherwise it returns 0, and N represents the total number of all documents.
[0281] Relation Strength:
[0282] Relationship strength is a value calculated based on relationship frequency, which is used to quantify the strength of the relationship between two entities.
[0283] The formula is Among them, α, β, γ, and θ are preset parameters used to adjust the calculation method of relationship strength.
[0284] In the embodiment of this application, it is assumed that we have the following text dataset in the financial field, which contains N=1000 articles about financial markets. Our goal is to extract entity pairs and their relationships from these articles and calculate their relationship strengths.
[0285] Entity pair selection:
[0286] We have obtained some candidate entity pairs through the previous steps, such as "Bank A" and "interest rate".
[0287] Relation frequency calculation:
[0288] Suppose we find that "Bank A" and "interest rate" appear 50 times in the same document, while "interest rate" and "Bank A" appear 45 times.
[0289] Therefore, F("Bank A","interest rate")=50F, F("interest rate","Bank A")=45F.
[0290] Tie strength calculation:
[0291] The preset parameters are set as: α = 0.7, β = 0.3, γ = 1.5, θ = 10
[0292] The relationship strength is calculated according to the formula:
[0293]
[0294] Assume e -1.5×(50-10) If the value of is a very small positive number, then the relationship strength S("Bank A", "interest rate") will be close to 0.7×(1+0.3)=0.91.
[0295] In this example, the relationship frequency between "Bank A" and "interest rate" is 50, and the relationship strength is 0.91. This means that in our text dataset, the entity pair "Bank A" and "interest rate" appear relatively frequently, and the relationship between them is considered to be strong.
[0296] The above is a specific example of how to evaluate the strength of relationships between entities in the financial field by calculating relationship frequency and relationship strength. This process can be automatically applied to large amounts of data to help build a more accurate knowledge graph.
[0297] 107. Add relations whose scores are higher than the preset threshold to the knowledge graph in the financial field.
[0298] In this step, adding relationships with a score higher than a preset threshold to the knowledge graph in the financial field means adding entity pairs and their relationships that are considered to have a strong relationship strength to a structured knowledge representation. Knowledge graph is a way to represent knowledge in a graphical structure, which uses nodes to represent entities and edges to represent the relationship between entities. By adding relationships with higher scores to the knowledge graph, we can build a richer and more accurate knowledge base in the financial field, which in turn supports various advanced applications such as intelligent recommendation, risk assessment, market forecasting, etc. The preset threshold refers to a standard value set in advance. Only when the score result of a relationship exceeds this threshold, the relationship will be considered reliable enough and added to the knowledge graph. This is done to ensure the quality of the knowledge graph and avoid knowledge errors or redundancy caused by noise data.
[0299] Assume that we have completed the previous steps and obtained a set of relationship candidates and their scoring results. Now, we will add the relationships whose scoring results are higher than the preset threshold to a knowledge graph in the financial field. The following are the specific implementation steps:
[0300] Define preset threshold: Set a reasonable threshold to filter relations. For example, we set the threshold to 0.5.
[0301] Filter relations: Select relations with scores higher than the threshold from the scoring results.
[0302] Build a knowledge graph: Use appropriate tools or libraries (such as Neo4j, GraphDB, etc.) to build a knowledge graph and add the filtered relationships into it.
[0303] Here is an example of building a simple knowledge graph using Python and the NetworkX library:
[0304] import networkx as nx
[0305] import matplotlib.pyplot as plt
[0306] #Define the preset threshold
[0307] threshold=0.5
[0308] #Suppose we have the following relationship candidate set and its scoring results
[0309] relationships=[
[0310] ("Apple","stock",0.9),
[0311] ("earnings","release",0.8),
[0312] ("price","rise",0.6),
[0313] ("today","sharp",0.3), ]
[0315] # Create an undirected graph
[0316] G = nx.Graph()
[0317] #Add nodes
[0318] nodes=set()
[0319] for rel in relationships:
[0320] nodes.add(rel[0])
[0321] nodes.add(rel[1])
[0322] G.add_nodes_from(nodes)
[0323] #Filter out the relationships with scores higher than the threshold and add them to the graph
[0324] edges=[(rel[0],rel[1])for rel in relationships if rel[2]>threshold]
[0325] G.add_edges_from(edges)
[0326] #Visualize the knowledge graph
[0327] plt.figure(figsize=(8,6))
[0328] pos = nx.spring_layout(G)
[0329] nx.draw_networkx(G,pos,with_labels=True,node_size=1500,node_color="skyblue",font_size=16)
[0330] plt.title("Financial Knowledge Graph")
[0331] plt.show()
[0332] # Output relationship
[0333] print("Relationships added to the knowledge graph:")
[0334] for edge in edges:
[0335] print(edge)
[0336] In this example, we first defined a preset threshold threshold=0.5. Then, we have a list relationships containing a set of relationship candidates and their scoring results. Next, we created an undirected graph G using the NetworkX library and added all entities as nodes to the graph. We filtered out relationships with scores higher than the threshold and added them as edges to the graph. Finally, we visualized the knowledge graph using Matplotlib and output the relationships added to the knowledge graph.
[0337] The output may be:
[0338] Relationships added to the knowledge graph:
[0339] ('Apple','stock')
[0340] ('earnings','release')
[0341] ('price','rise')
[0342] This shows that we have successfully added relationships with scores above the preset threshold to the knowledge graph in the financial field. In this way, we can continue to accumulate and update the knowledge graph, making it an important tool in the financial field.
[0343] Optionally, the method further includes: performing semantic similarity evaluation on entity relationships in the relationship candidate set to filter out low-quality relationships;
[0344] Wherein, the semantic similarity evaluation includes:
[0345] Calculate the semantic vector for each pair of entities;
[0346] The cosine similarity is used to calculate the similarity between the semantic vectors, and the similarity is defined as:
[0347]
[0348] Wherein, sim(v1,v2) represents the similarity between the semantic vectors of the first entity and the second entity, and v1 and v2 represent the semantic vectors of the first entity and the second entity respectively;
[0349] Filter out entity relations in the relation candidate set whose semantic similarity is lower than a preset threshold.
[0350] In this step, semantic vectors: semantic vectors refer to the conversion of entities in the text into numerical vectors, which can capture the semantic relationship between entities. Common methods for generating semantic vectors include pre-trained models such as Word2Vec, GloVe or BERT.
[0351] Cosine Similarity: Cosine similarity is used to measure the cosine value of the angle between two non-zero vectors to measure the similarity between them. The value range of cosine similarity is usually between -1 and 1. The closer the value is to 1, the more similar the two vectors are.
[0352] Predefined Threshold: The preset threshold is used to filter out entity pairs with similarity lower than this value after the cosine similarity calculation. Only when the similarity of the entity pairs is higher than this threshold, the relationship between them is considered to be of high quality and thus retained.
[0353] In the present embodiment, it is assumed that we have completed the relationship strength scoring of entity pairs and want to further filter out low-quality relationships through semantic similarity evaluation. The following are the specific implementation steps:
[0354] In the context of the embodiment, assume that we have a set of candidate entity pairs, for example: "Bank A" and "interest rate", "Company B" and "stock price", "Individual C" and "bond", etc.
[0355] We have generated semantic vectors for each entity using pre-trained natural language processing models such as BERT.
[0356] Using the pre-trained BERT model, we can obtain the semantic vector of each entity. For example, the vector of "Bank A" may be v1 = [0.1, 0.2, 0.3, ...], and the vector of "interest rate" may be v2 = [0.2, 0.3, 0.4, ...].
[0357] Use the cosine similarity formula to calculate the similarity of each pair of entities:
[0358]
[0359] Suppose we calculate the following results:
[0360] For the entity pair “Bank A” and “interest rate”, the cosine similarity is 0.85.
[0361] For the entity pair “Company B” and “Stock Price”, the cosine similarity is 0.55.
[0362] For the entity pair “person C” and “bond”, the cosine similarity is 0.75.
[0363] Assume that we set the preset threshold to 0.6, that is, only those entity pairs whose cosine similarity is greater than or equal to 0.6 will be retained.
[0364] Filter out low-quality relationships
[0365] Check if the cosine similarity of each entity pair is greater than or equal to 0.6.
[0366] For "Bank A" and "Interest Rate", since 0.85>0.6, the relationship will be retained.
[0367] For "Company B" and "Stock Price", since 0.55<0.6, this relationship will be filtered out.
[0368] For "Individual C" and "Bond", since 0.75>0.6, the relationship will be retained.
[0369] After semantic similarity evaluation, we retain the relationships between “Bank A” and “Interest Rate” and between “Individual C” and “Bond”, while the relationship between “Company B” and “Stock Price” is filtered out.
[0370] By calculating the semantic vectors and their cosine similarity of entity pairs and setting a preset threshold (e.g. 0.6), we successfully filtered out low-quality relationships and retained only those relationships that are semantically relevant and high-quality. This step helps improve the accuracy and reliability of the knowledge graph.
[0371] Optionally, the method further includes: performing secondary screening on the relationship candidate set using a deep learning model to improve the accuracy of relationship extraction.
[0372] The method uses a deep learning model to perform secondary screening on the relationship candidate set, including: constructing a bidirectional long short-term memory network model based on an attention mechanism; using the bidirectional long short-term memory network model to extract features for each pair of entities and their contexts; inputting the extracted features into a fully connected layer, and outputting the probability distribution of each entity pair belonging to different relationship categories through an activation function; and selecting the relationship category with the highest probability as the final prediction result.
[0373] In this step, we use a deep learning model to perform a secondary screening of the relationship candidate set in order to improve the accuracy of relationship extraction. This step is usually performed after the initial relationship extraction, using a more complex model to verify and optimize the quality of the candidate relationships.
[0374] Deep learning model: A machine learning method that simulates the working principles of human brain neurons and learns complex patterns in data through multi-layer neural networks.
[0375] Attention mechanism: A technique that enables the model to focus on certain specific parts of the input sequence, thereby enhancing the model's ability to process long sequences.
[0376] Bidirectional Long Short-Term Memory Network (BiLSTM): An improved Recurrent Neural Network (RNN) that can remember long-term dependency information and consider both past and future contextual information in a bidirectional manner.
[0377] Feature extraction: The process of obtaining information from raw data that can aid in classification or prediction.
[0378] Fully Connected Layer (FC): A layer in a neural network in which each neuron is connected to all neurons in the previous layer.
[0379] Activation function: A function used to introduce nonlinear factors into a neural network. Common ones include ReLU, sigmoid, tanh, etc.
[0380] Probability distribution: A set of numerical values that describe the likelihood of an event occurring, where the sum of the probabilities of all events equals 1.
[0381] Relationship categories: different types of relationships that may exist between entity pairs in the relationship candidate set, such as "works at", "is located in", etc.
[0382] In the embodiment of this application, it is assumed that we have obtained a set of relation candidates containing multiple entity pairs and their possible relations. Now we want to use a BiLSTM model based on the attention mechanism for secondary screening to improve the accuracy of the final relation extraction.
[0383] Build a bidirectional long short-term memory network model based on the attention mechanism:
[0384] First, we need to define a neural network architecture that contains a BiLSTM layer and an attention mechanism layer. The BiLSTM layer is responsible for capturing the temporal dependencies of sequence data, while the attention mechanism layer helps the model focus on the most relevant information in the input.
[0385] Use the bidirectional long short-term memory network model to extract features for each pair of entities and their context:
[0386] For each entity pair, we extract the contextual information around them. For example, for the entity pair "Zhang San" and "Beijing", we might get the sentence "Zhang San lives in Beijing". Then, we input this sentence into the BiLSTM model, and the model outputs the hidden state vector of each word.
[0387] Next, the attention mechanism layer performs a weighted summation of these hidden state vectors to obtain a more focused vector representation that emphasizes the parts that are most useful for relationship recognition.
[0388] The extracted features are input into the fully connected layer, and the probability distribution of each entity pair belonging to different relationship categories is output through the activation function:
[0389] The feature vector output from the attention mechanism layer is fed into one or more fully connected layers. After the fully connected layer, we usually add a softmax layer as an activation function, which can output the probability distribution of each entity pair belonging to different relation categories. For example, the output may be [0.2, 0.1, 0.6, 0.1], which means that the model believes that the entity pair is most likely to belong to the third relation category with a probability of 60%.
[0390] Select the relationship category with the highest probability as the final prediction result:
[0391] According to the probability distribution output by the softmax layer, we select the relationship category with the highest probability as the final prediction result. If the output probability distribution is [0.2, 0.1, 0.6, 0.1], the prediction result is the third relationship category.
[0392] In the example of the embodiment, suppose we have a sentence: "Li Si works at Alibaba."
[0393] Entity pair: "Li Si" and "Alibaba"
[0394] Context: "Working at..."
[0395] Build the model:
[0396] Define the BiLSTM+Attention model using a framework such as TensorFlow or PyTorch.
[0397] Feature extraction:
[0398] Input the sentence "Li Si works at Alibaba." After passing through the embedding layer and the BiLSTM layer, we get the hidden state vector of each word.
[0399] The attention mechanism layer generates a weighted context vector based on these vectors.
[0400] Output probability distribution:
[0401] The context vector is input to the fully connected layer and passes through the softmax layer to obtain the probability distribution of the relationship category. Assume that the output is [0.1, 0.8, 0.05, 0.05].
[0402] Final prediction:
[0403] The relationship category corresponding to the highest probability is the second category. Assuming the category list is ["friend", "work at", "located at", "has"], the prediction result is "work at".
[0404] In this way, we can not only filter out low-quality relations from the candidate set, but also further improve the accuracy of relation extraction through deep learning models.
[0405] Optionally, the method further includes: verifying the relationship candidate set using a rule-based logical reasoning system to further improve the accuracy of relationship extraction;
[0406] The logic reasoning system includes: defining a set of reasoning rule sets R according to professional knowledge in the financial field; for each pair of entity relationships e1, e2, using the reasoning rule set R to verify its logical consistency to determine a consistency score, wherein the consistency score is defined as:
[0407]
[0408] Among them, C(e1,e2) represents the consistency score of a given entity pair (e1,e2), η r is the weight coefficient of rule r, where rule r belongs to a specific instance in the inference rule set R, ζ(e1,e2,r) is the applicability index of rule r applied to entity pair e1,e2, and its value range is [0,1]. It takes the value of 1 when rule r is applicable to entity pair e1,e2, otherwise it takes the value of 0.
[0409] Rule-Based Logical Reasoning System:
[0410] This is a system that verifies data consistency by applying a set of predefined rules. In this context, the rules are to ensure that the entity relationships extracted from the text conform to the logical structure and common sense of the specific domain.
[0411] Inference rule set R(Rule Set R):
[0412] An inference rule set is a collection of logical rules that define logical conditions that should be satisfied between entities. For example, in the financial field, you can define rules such as "if a company issues shares, then the company must be a listed company."
[0413] Consistency Score C(e1,e2) (Consistency Score): The consistency score quantifies the degree of logical consistency between entity pairs e1 and e2. It is calculated by considering all applicable rules r and combining the weight coefficient of each rule.
[0414] Weight coefficient η r(Weight Coefficient): The weight coefficient is a measure of the importance of rule r. Different rules may have different weights depending on their importance in the verification process.
[0415] Applicability Indicator ζ(e1,e2,r):
[0416] The applicability index is used to determine whether the rule r is applicable to a specific pair of entities e1 and e2. If the rule is applicable, the index is 1, otherwise it is 0.
[0417] In the embodiment of the present application, it is assumed that we are building a knowledge graph in the financial field and hope to verify the set of relationship candidates extracted from the text through a logical reasoning system.
[0418] Define the inference rule set R: define some rules about the financial field. For example:
[0419] Rule R1: If an entity is a “stock issuer” then it should also be a “public company”.
[0420] Rule R2: If an entity is a “bond issuer” then it should also be a “corporate” or a “government agency”.
[0421] Set the weight coefficient η r :
[0422] Assign a weight coefficient to each rule. For example, if R1 is considered more critical than R2, we can set η R1 =0.8,η R2 =0.5.
[0423] Calculate the suitability index ζ(e1,e2,r)
[0424] For each pair of entity relations e1 and e2, check whether it satisfies each rule r. If it does, then
[0425] ζ(e1,e2,r)=1, otherwise it is 0.
[0426] Calculate the consistency score Cc:
[0427] The consistency score for each entity pair is calculated using the defined consistency score formula:
[0428] C(e1,e2)=∑ r∈R η r ×ζ(e1,e2,r)
[0429] For example, suppose the following situation:
[0430] The entity pair (e1, e2) is ("Company X", "Stock Issuer"), then ζ(e1, e2, r1) = 1. Since Company X has issued stocks, it should also be a listed company.
[0431] The entity pair (e1, e2) is ("Company Y", "Bond Issuer"), then ζ(e1, e2, r2) may be 1 or 0, depending on whether Company Y is a "corporate" or a "government agency".
[0432] In the calculation of the embodiment, it is assumed that we have two entity pairs (e1, e2) and (e3, e4), and two rules r1 and r2, with weights of 0.8 and 0.5 respectively.
[0433] For (e1, e2) = ("Company X", "Stock Issuer"), assuming ζ(e1, e2, r1) = 1, ζ(e1, e2, r2) = 0, then C(e1, e2) = 0.8*1+0.5* = 0.8.
[0434] For (e3, e4) = ("Company Y", "Bond Issuer"), assuming ζ(e3, e4, r1) = 0, ζ(e3, e4, r2) = 1, then C(e3, e4)0.8*0+0.5*1 = 0.5.
[0435] By calculating a consistency score for each entity pair, we can better understand how logically consistent they are. A high score indicates that the entity pair is more consistent with our domain rules and is therefore more likely to be a correct entity relationship.
[0436] By using a rule-based logical reasoning system, we are able to verify the set of relation candidates based on financial domain expertise and improve the accuracy of relation extraction by calculating consistency scores. This approach helps reduce incorrect relations and enhances the quality of the knowledge graph.
[0438] Optionally, the method further includes: optimizing the structure of the knowledge graph using a graph-based algorithm;
[0439] The method of optimizing the structure of the knowledge graph using a graph-based algorithm includes: defining a graph G(V, E), where V represents a set of entities and E represents a set of relationships between entities; for each pair of entities (e1, e2)∈E in the graph G, calculating the weight W(e1, e2) of each pair of entities, which is defined as:
[0440] W(e1, e2)=λ1×S(e1, e2)+λ2×C(e1, e2)+λ3×SVM(X(e1, e2))
[0441] Wherein, λ1, λ2, λ3 are preset weight coefficients, S(e1, e2) represents the relationship strength between entity e1 and entity e2 calculated according to the relationship frequency, C(e1, e2) is the consistency score between entity e1 and entity e2, and SVM(X(e1, e2)) represents the estimation of the relationship strength of each pair of entities (e1, e2) by the support vector machine;
[0442] Use graph-based algorithms to update the weights of entities to optimize the graph structure.
[0443] Graph G(V,E)(Graph G(V,E)):
[0444] A graph G is a mathematical structure consisting of a node set V and an edge set E, where the nodes V represent a set of entities and the edges E represent a set of relationships between entities. In this context, the graph G is used to represent the knowledge graph in the financial field.
[0445] Weight W(e1, e2) (Edge Weight):
[0446] The weight is a numerical value assigned to each pair of entities (e1, e2) in the graph G, which is used to represent the strength of the relationship between the two entities. The calculation of the weight takes into account the relationship strength, consistency score and support vector machine estimation.
[0447] Predefined Weight Coefficients:
[0448] These coefficients are used to adjust the importance of each factor when calculating the weight. Different coefficient values will make some factors have a greater impact on the final weight.
[0449] Relation Strength S(e1, e2)
[0450] Relationship strength is calculated based on relationship frequency and reflects the closeness of the relationship between two entities.
[0451] Consistency Score C(e1, e2)
[0452] The consistency score is calculated through a logical reasoning system and reflects the logical consistency of the entity pair.
[0453] Support Vector Machine SVM(X(e1, e2))
[0454] Support vector machine is a machine learning method used to estimate the strength of the relationship between entity pairs. Here, SVM estimates the strength of the relationship between entity pairs.
[0455] In the embodiment of this application, it is assumed that we have completed a series of preliminary work, including relationship strength scoring, semantic similarity evaluation and logical consistency verification. Now we hope to use a graph-based algorithm to optimize the structure of the knowledge graph.
[0456] Define graph G(V, E)
[0457] We define a graph G, where V is a set of entities and E is a set of relationships between entities. For example, V may contain entities "Bank A", "Interest Rate", "Company B", "Stock Price", "Individual C", and "Bond".
[0458] Calculate the weight W(e1, e2)
[0459] We need to calculate the weight for each pair of entities (e1, e2) in the graph G. The weight calculation formula is:
[0460] W(e1, e2)=λ1×S(e1, e2)+λ2×C(e1, e2)+λ3×SVM(X(e1, e2))
[0461] Suppose we have the following values:
[0462] λ1=0.5, λ20.3, λ3=0.2
[0463] S(e1, e2) = 0.91 (e.g., the strength of the relationship between "Bank A" and "interest rate")
[0464] C(e1, e2) = 0.8 (e.g., consistency score of “Bank A” and “interest rate”)
[0465] SVM(X(e1, e2)) = 0.75 (e.g., SVM estimates for “Bank A” and “Interest Rate”)
[0466] Calculate weights:
[0467] W("Bank A", "interest rate") = 0.5 × 0.91 + 0.3 × 0.8 + 0.2 × 0.75 = 0.455 + 0.24 + 0.15 = 0.845
[0468] Graph-based algorithms can help us adjust the weights of edges in the graph G, thereby optimizing the structure of the knowledge graph. Here, we can use algorithms such as PageRank, random walks, or other graph optimization algorithms to redistribute weights.
[0469] For example, using the PageRank algorithm, we can recalculate the importance of each node based on its in-degree and out-degree, and adjust the edge weights accordingly.
[0470] Summary of Examples
[0471] By defining the graph G and calculating the weight W(e1, e2) of each pair of entities, we can better understand the strength of the relationship between entities. Using a graph-based algorithm to update the weights helps optimize the overall structure of the knowledge graph, making it more reasonable and accurate.
[0472] Suppose we have the following pairs of entities and their computation results:
[0473] (e1, e2) = ("Bank A", "interest rate"), weight W (e1, e2) = 0.845
[0474] (e3, e4) = ("Company B", "Stock Price"), weight W (e3, e4) = 0.6
[0475] (e5, e6) = ("Personal C", "Bond"), weight W (e5, e6) = 0.7
[0476] Through such weight calculation, we can identify which relationships are more important and give them higher weights in the knowledge graph, thereby optimizing the graph structure.
[0477] Optionally, the method further includes: performing uncertainty evaluation on each pair of entities and their relationships in the relationship candidate set to determine an uncertainty evaluation value of each pair of entities, wherein the uncertainty evaluation value is defined as:
[0478]
[0479] Among them, U(e1, e2) represents the uncertainty evaluation value of a given entity pair (e1, e2), R i is the i-th relationship category, p(R i |e1, e2) is the relationship R for a given entity pair e1, e2 i The conditional probability, p(R i ) is the relationship R i The prior probability of , n is the number of relationship categories;
[0480] The uncertainty assessment of each pair of entities and their relationship in the candidate relationship set further includes: using mutual information to measure the degree of dependence between the entity pair and its relationship, where the degree of dependence is defined as:
[0481]
[0482] Among them, MI(e1, e2, R) represents mutual information, which is used to measure the degree of dependence between the entity pair (e1, e2) and its relationship R, R represents the set of relationship categories of the entity pair (e1, e2), r represents a specific relationship in the relationship category R, p(r|e1, e2) is the conditional probability of relationship r given the entity pair e1, e2, and p(r) is the prior probability of relationship r.
[0483] Uncertainty Evaluation:
[0484] The uncertainty assessment is used to measure the uncertainty of the relationship for a given entity pair (e1, e2). The higher the assessment value, the greater the uncertainty of the relationship.
[0485] Uncertainty Evaluation Value U(e1, e2):
[0486] The uncertainty assessment value is calculated based on the conditional probability distribution of the given entity pair (e1, e2) and the prior probability of the relationship category. The formula is:
[0487]
[0488] Among them, R i represents the i-th relationship category, p(R i |e1, e2) is the relation R given the entity pair (e1, e2) i The conditional probability, pR i is the relationship R i The prior probability of , n is the number of relationship categories.
[0489] Mutual Information MI(e1, e2, R)
[0490] Mutual information is used to measure the degree of dependence between an entity pair (e1, e2) and its relationship. The formula is:
[0491]
[0492] Among them, r represents a specific relation in the relation category R, p(r|e1, e2) is the conditional probability of relation r given the entity pair (e1, e2), and p(r) is the prior probability of relation r.
[0493] In the embodiment of the present application, it is assumed that we have completed the relationship strength scoring, semantic similarity evaluation, and logical consistency verification of entity pairs, and we hope to further understand the reliability of the relationship through uncertainty evaluation.
[0494] Suppose we define three relationship categories: Owning, Investing, and Cooperating.
[0495] We need to calculate the conditional probability p(r|e1, e2) of each entity pair (e1, e2) under different relationship categories.
[0496] We also need to calculate the prior probability p(R i ). This is usually based on the frequency of occurrence of each relationship category in the entire dataset.
[0497] Suppose we have the following entity pairs and their conditional and prior probabilities:
[0498] Entity pair (e1, e2) = ("Bank A", "interest rate");
[0499] Conditional probability p(Owning|e1, e2) = 0.1;
[0500] Conditional probability p(Investing|e1, e2) = 0.8;
[0501] Conditional probability p(Cooperating|e1, e2) = 0.1;
[0502] Prior probability p(Owning) = 0.3;
[0503] Prior probability p(Investing) = 0.5;
[0504] Prior probability p(Cooperating) = 0.2;
[0505] Entity pair (e3, e4) = ("Company B", "Stock Price");
[0506] Conditional probability (pOwning|e3, e4) = 0.3;
[0507] Conditional probability p(Investing|e3, e4) = 0.5;
[0508] Conditional probability p(Cooperating|e3, e4) = 0.2;
[0509] The uncertainty estimate is calculated for each entity pair using the uncertainty estimate formula:
[0510]
[0511] For entity pair (e1, e2) = ("Bank A", "interest rate"):
[0512]
[0513] For entity pair (e3, e4) = ("Company B", "Stock Price"):
[0514]
[0515] The mutual information formula is used to calculate the mutual information of each entity pair:
[0516]
[0517] For entity pair (e1, e2) = ("Bank A", "interest rate"):
[0518]
[0519] MI(e1, e2, R)≈0.1×(-1.585)+0.8×0.322+0.1×(-1)≈-0.1585+0.2576-0.1=-0.0009
[0520] For entity pair (e3, e4) = ("Company B", "Stock Price"):
[0521]
[0522] By calculating the uncertainty evaluation value and mutual information for each entity pair, we can gain a deeper understanding of the reliability and dependence of each entity pair relationship. The lower the uncertainty evaluation value, the more certain the relationship is; the higher the mutual information value, the higher the dependence between the entity pair and its relationship.
[0523] This step helps to further screen and optimize the set of relationship candidates, thereby improving the accuracy and reliability of the knowledge graph.
[0524] Optionally, the method further includes: using a neural network model to jointly evaluate each pair of entities and their relationships in the relationship candidate set to determine a joint evaluation value, wherein the joint evaluation value is defined as:
[0525]
[0526] Among them, J(e1, e2) represents the joint evaluation value of the given entity pair (e1, e2), NN is a neural network model, and its output is the relationship evaluation score of the entity pair e1, e2, SVM(X(e1, e2)) represents the support vector machine’s estimation of the relationship strength of the given entity (e1, e2), C(e1, e2) represents the consistency score of the given entity pair (e1, e2), U(e1, e2) represents the uncertainty evaluation value of the given entity pair (e1, e2), and MI(e1, e2, R) represents the degree of dependence between the given entity pair (e1, e2) and its relationship R.
[0527] Joint Evaluation Value J(e1, e2)
[0528] The joint evaluation value is the result of a comprehensive evaluation of the relationship of a given entity pair (e1, e2), which combines multiple evaluation indicators, including support vector machine estimation, consistency score, uncertainty evaluation value and mutual information.
[0529] Neural Network Model NN (Neural Network Model):
[0530] A neural network model is a machine learning model that can take in multiple input features and output a composite score. In this scenario, the neural network model takes in four input features: support vector machine estimates, consistency scores, uncertainty estimates, and mutual information.
[0531] Support Vector Machine SVM(X(e1, e2)) (Support Vector Machine):
[0532] Support vector machine is a supervised learning model used for classification and regression analysis. In this context, SVM is used to estimate the strength of the relationship given an entity pair (e1, e2).
[0533] Consistency Score C(e1, e2)
[0534] The consistency score is calculated through a logical reasoning system and reflects the logical consistency of the entity pair.
[0535] Uncertainty Evaluation Value U(e1, e2):
[0536] The uncertainty evaluation value is used to measure the uncertainty of the relationship of a given entity pair (e1, e2). The higher the evaluation value, the greater the uncertainty of the relationship.
[0537] Mutual Information MI(e1, e2, R)
[0538] Mutual information is used to measure the degree of dependence between an entity pair (e1, e2) and its relationship.
[0539] In the present embodiment, it is assumed that we have completed the relationship strength scoring, semantic similarity evaluation, logical consistency verification, uncertainty evaluation and mutual information calculation of entity pairs. Now we want to use the neural network model to jointly evaluate each pair of entities and their relationships in the relationship candidate set.
[0540] We need to prepare four features for each entity pair:
[0541] SVM(X((e1, e2)) : Support Vector Machine Estimation
[0542] C(e1, e2): consistency score
[0543] U(e1, e2): uncertainty assessment value
[0544] MI(e1, e2, R): Mutual Information
[0545] Training the neural network model
[0546] Assume that we have trained a neural network model NN that can receive the above four features as input and output a comprehensive score.
[0547] Suppose there are the following pairs of entities and their corresponding eigenvalues:
[0548] Entity pair (e1, e2) = ("Bank A", "interest rate");
[0549] SVM(X(e1, e2))=0.75;
[0550] C(e1, e2) = 0.8;
[0551] U(e1, e2) = 0.1;
[0552] MI(e1, e2, R) = 0.2;
[0553] Entity pair (e3, e4) = ("Company B", "Stock Price");
[0554] SVM(X(e3, e4))=0.6;
[0555] C(e3, e4) = 0.7;
[0556] U(e3, e4) = 0.2;
[0557] MI(e3, e4, R) = 0.15;
[0558] The neural network model NN is used to jointly evaluate the features of each entity pair:
[0559] J(e1, e2)=NN(SVM(X(e1, e2)), C(e1, e2), U(e1, e2), MI(e1, e2, R))
[0560] Assume that the output of the neural network model NN is the relationship evaluation score of the entity pair (e1, e2).
[0561] Calculate the joint evaluation value
[0562] For entity pair (e1, e2) = ("Bank A", "interest rate"):
[0563] J(e1,e2)=NN(0.75,0.8,0.1,0.2)
[0564] Assume that the output of the neural network model NN is 0.85.
[0565] For entity pair (e3, e4) = ("Company B", "Stock Price"):
[0566] J(e3, e4)=NN(0.6, 0.7, 0.2, 0.15)
[0567] Assume that the output of the neural network model NN is 0.7.
[0568] By using the neural network model NN to jointly evaluate the relationship between entity pairs, we can get a comprehensive score that combines multiple evaluation indicators. This comprehensive evaluation helps to further improve the accuracy and reliability of relationship extraction.
[0569] Finally, we get the following joint evaluation value:
[0570] For the entity pair (e1, e2) = ("Bank A", "Interest Rate"), the joint evaluation value is 0.85.
[0571] For the entity pair (e3, e4) = ("Company B", "Stock Price"), the joint evaluation value is 0.7.
[0572] In this way, we can further screen and optimize the set of relationship candidates to ensure that the relationships finally added to the knowledge graph are of high quality.
[0573] Figure 2 A schematic diagram of the structure of an entity relationship extraction system for building a knowledge graph in the financial field is provided for the embodiment of the present application. Figure 2 As shown, the device comprises:
[0574] An acquisition module 21 is used to acquire original text data in the financial field;
[0575] A preprocessing module 22 is used to preprocess the original text data, including word segmentation, stop word removal, and part-of-speech tagging operations to obtain preprocessed text;
[0576] A determination module 23 is used to perform entity recognition on the preprocessed text using a pretrained natural language processing model to determine entities and their entity types in the text; and to determine dependency relationships between the entities using dependency syntactic analysis technology;
[0577] A construction module 24, configured to extract potential relationships between entities according to the dependency relationship and construct a relationship candidate set;
[0578] The determination module 23 is also used to score each pair of entities and their relationship in the relationship candidate set to determine the relationship strength between the entities in the relationship candidate set;
[0579] Adding module 25, adding the relationship whose scoring result is higher than the preset threshold to the knowledge graph in the financial field.
[0580] Figure 2 The entity relationship extraction system for building a knowledge graph in the financial field can be executed Figure 1 The implementation principle and technical effect of the entity relationship extraction system method for building a knowledge graph in the financial field described in the embodiment shown will not be repeated. The specific way in which each module and unit performs operations in the entity relationship extraction system for building a knowledge graph in the financial field in the above embodiment has been described in detail in the embodiment of the method, and will not be elaborated here.
[0581] In one possible design, Figure 2 The entity relationship extraction system for constructing a knowledge graph in the financial field according to the embodiment shown can be implemented as a computing device, such as Figure 3 As shown, the computing device may include a storage component 31 and a processing component 32;
[0582] The storage component 31 stores one or more computer instructions, wherein the one or more computer instructions are called and executed by the processing component 32 .
[0583] The processing component 32 is used to: obtain original text data in the financial field; preprocess the original text data, including word segmentation, stop word removal, and part-of-speech tagging operations to obtain preprocessed text; use a pre-trained natural language processing model to perform entity recognition on the preprocessed text to determine the entities and their entity types in the text; use dependency syntactic analysis technology to determine the dependency relationships between the entities; extract potential relationships between entities based on the dependency relationships, and construct a relationship candidate set; score each pair of entities and their relationships in the relationship candidate set to determine the relationship strength between the entities in the relationship candidate set; add relationships whose scoring results are higher than a preset threshold to the knowledge graph in the financial field.
[0584] The processing component 32 may include one or more processors to execute computer instructions to complete all or part of the steps in the above method. Of course, the processing component may also be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above method.
[0585] The storage component 31 is configured to store various types of data to support operations at the terminal. The storage component can be implemented by any type of volatile or non-volatile storage device 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.
[0586] Of course, the computing device may also include other components, such as input / output interfaces, display components, communication components, etc.
[0587] The input / output interface provides an interface between the processing component and the peripheral interface module, which may be an output device, an input device, etc.
[0588] The communication component is configured to facilitate, among other things, wired or wireless communications between the computing device and other devices.
[0589] Among them, the computing device can be a physical device or an elastic computing host provided by a cloud computing platform, etc. In this case, the computing device can refer to a cloud server, and the above-mentioned processing components, storage components, etc. can be basic server resources rented or purchased from the cloud computing platform.
[0590] The present application also provides a computer storage medium storing a computer program, wherein the computer program can achieve the above-mentioned Figure 1 The illustrated embodiment is an entity relationship extraction method for constructing a knowledge graph in the financial field.
[0591] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0592] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0593] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0594] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. An entity relationship extraction method for constructing a knowledge graph in the financial field, characterized in that: include: Obtaining raw text data in the financial field; Preprocessing the original text data, including word segmentation, stop word removal, and part-of-speech tagging operations, to obtain preprocessed text; Performing entity recognition on the preprocessed text using a pretrained natural language processing model to determine entities and their entity types in the text; Determining dependency relationships between the entities using dependency parsing techniques; Extracting potential relationships between entities according to the dependency relationships and constructing a relationship candidate set; Scoring each pair of entities and their relationships in the relationship candidate set to determine the relationship strength between the entities in the relationship candidate set; Relations with scores higher than a preset threshold are added to the knowledge graph in the financial field.
2. The method according to claim 1, characterized in that The using dependency syntactic analysis technology to determine the dependency relationship between the entities includes: Applying a dependency syntactic analysis algorithm to analyze the preprocessed text to obtain a dependency tree structure; A connection path between entities is determined based on the dependency tree structure to extract direct or indirect relationships between entities.
3. The method according to claim 1, characterized in that Scoring each pair of entities and their relationships in the relationship candidate set to determine the relationship strength between the entities in the relationship candidate set includes: The relationship frequency between each pair of entities is calculated, and the relationship frequency is defined as: Among them, F(e1,e2) represents the relationship frequency between entity e2 and entity e1, e1 and e2 represent the first entity and the second entity between each pair of entities, respectively. i represents the relation instance in document i, δ(e1,e2,d i ) represents the indicator function. When e1 and e2 are in document d i When it appears in, the value is 1, otherwise it is 0, and N represents the total number of documents; The relationship strength between entities is calculated based on the relationship frequency, and the relationship strength is defined as: Wherein, S(e1, e2) represents the relationship strength between entity e1 and entity e2 calculated according to the relationship frequency, α, β, γ, θ are preset parameters, and F(e2, e1) represents the relationship frequency between entity e2 and entity e1.
4. The method according to claim 1, characterized in that Also includes: Performing semantic similarity evaluation on entity relations in the relation candidate set to filter out low-quality relations; Wherein, the semantic similarity evaluation includes: Calculate the semantic vector for each pair of entities; The cosine similarity is used to calculate the similarity between the semantic vectors, and the similarity is defined as: Wherein, sim(v1,v2) represents the similarity between the semantic vectors of the first entity and the second entity, and v1 and v2 represent the semantic vectors of the first entity and the second entity respectively; Filter out entity relations in the relation candidate set whose semantic similarity is lower than a preset threshold.
5. The method according to claim 1, characterized in that The using a pre-trained natural language processing model to perform entity recognition on the pre-processed text includes: Use pre-trained natural language processing models for entity recognition; The preprocessed text is input into the natural language processing model to obtain the boundary positions of entities in the text and their entity types.
6. The method according to any one of claims 1 to 5, characterized in that: Also includes: Using a deep learning model to perform secondary screening on the relationship candidate set to improve the accuracy of relationship extraction; The secondary screening of the relationship candidate set by using the deep learning model includes: Construct a bidirectional long short-term memory network model based on attention mechanism; Using the bidirectional long short-term memory network model to extract features from each pair of entities and their contexts; The extracted features are input into the fully connected layer, and the probability distribution of each entity pair belonging to different relationship categories is output through the activation function; The relationship category with the highest probability is selected as the final prediction result.
7. The method according to claim 6, characterized in that Also includes: Using a rule-based logical reasoning system to verify the relationship candidate set to further improve the accuracy of relationship extraction; The logical reasoning system comprises: Define a set of inference rules R based on professional knowledge in the financial field; For each pair of entity relationships e1, e2, the inference rule set R is used to verify its logical consistency to determine the consistency score, where the consistency score is defined as: Among them, C(e1,e2) represents the consistency score of a given entity pair (e1,e2), η r is the weight coefficient of rule r, where rule r belongs to a specific instance of the inference rule set R, ζ(e1,e2,r) is the applicability index of rule r to entity pair e1,e2, and its value range is [0,1]. It takes the value of 1 when rule r is applicable to entity pair e1,e2, otherwise it takes the value of 0; The step of scoring each pair of entities and their relationships in the relationship candidate set to determine the relationship strength between the entities in the relationship candidate set further includes: A multi-dimensional evaluation is performed on each pair of entities and their relationship in the relationship candidate set, wherein the multi-dimensional evaluation includes: A multi-dimensional feature vector that defines the relationship, including relationship frequency, semantic similarity, and consistency score; The multi-dimensional feature vector is classified using a support vector machine to determine the strength of the relationship between entities, which is defined as: Among them, X(e1, e2) represents the multi-dimensional feature vector of each pair of entity relationships, SVM(X(e1, e2)) represents the support vector machine's estimation of the relationship strength of each pair of entities (e1, e2), m represents the number of training samples, and y i is the label of the i-th training sample, α i is the Lagrange multiplier corresponding to the i-th training sample, K(X(e1,e2),X i ) is the kernel function, X i is the multi-dimensional feature vector of the training sample, and b is the bias term; Optimizing the structure of the knowledge graph using a graph-based algorithm; The optimizing the structure of the knowledge graph using a graph-based algorithm includes: Define a graph G(V,E), where V represents a set of entities and E represents a set of relationships between entities; For each pair of entities (e1, e2) ∈ E in the graph G, calculate the weight W(e1, e2) of each pair of entities, defined as: W(e1,e2)=λ1×S(e1,e2)+λ2×C(e1,e2)+λ3×SVM(X(e1,e2)) Wherein, λ1, λ2, λ3 are preset weight coefficients, S(e1, e2) represents the relationship strength between entity e1 and entity e2 calculated according to the relationship frequency, C(e1, e2) is the consistency score between entity e1 and entity e2, and SVM(X(e1, e2)) represents the estimation of the relationship strength of each pair of entities (e1, e2) by the support vector machine; Use graph-based algorithms to update entity weights to optimize the graph structure; Also includes: An uncertainty evaluation is performed on each pair of entities and their relationships in the relationship candidate set to determine an uncertainty evaluation value of each pair of entities, wherein the uncertainty evaluation value is defined as: Among them, U(e1,e2) represents the uncertainty evaluation value of a given entity pair (e1,e2), R i is the i-th relationship category, p(R i |e1,e2) is the relationship R for a given entity pair e1,e2 i The conditional probability, p(R i ) is the relationship R i The prior probability of , n is the number of relationship categories; The step of performing uncertainty assessment on each pair of entities and their relationship in the candidate relationship set further includes: Mutual information is used to measure the degree of dependence between entity pairs and their relations, which is defined as: Among them, MI(e1,e2,R) represents mutual information, which is used to measure the degree of dependence between the entity pair (e1,e2) and its relationship R. R represents the set of relationship categories of the entity pair (e1,e2), r represents a specific relationship in the relationship category R, p(r|e1,e2) is the conditional probability of relationship r given the entity pair e1,e2, and p(r) is the prior probability of relationship r. Also includes: A neural network model is used to jointly evaluate each pair of entities and their relationships in the relationship candidate set to determine a joint evaluation value, wherein the joint evaluation value is defined as: Among them, J(e1,e2) represents the joint evaluation value of the given entity pair (e1,e2), NN is a neural network model whose output is the relationship evaluation score of the entity pair e1,e2, SVM(X(e1,e2)) represents the support vector machine’s estimation of the relationship strength of the given entity (e1,e2), C(e1,e2) represents the consistency score of the given entity pair (e1,e2), U(e1,e2) represents the uncertainty evaluation value of the given entity pair (e1,e2), and MI(e1,e2,R) represents the degree of dependence between the given entity pair (e1,e2) and its relationship R.
8. An entity relationship extraction system for building a knowledge graph in the financial field, characterized in that: include: The acquisition module is used to obtain the original text data in the financial field; A preprocessing module is used to preprocess the original text data, including word segmentation, stop word removal, and part-of-speech tagging operations, to obtain preprocessed text; A determination module, configured to perform entity recognition on the preprocessed text using a pretrained natural language processing model to determine entities and entity types in the text; Determining dependency relationships between the entities using dependency parsing techniques; A construction module, used to extract potential relationships between entities according to the dependency relationship and construct a relationship candidate set; The determination module is further used to score each pair of entities and their relationship in the relationship candidate set to determine the relationship strength between the entities in the relationship candidate set; Relations with scores higher than a preset threshold are added to the knowledge graph in the financial field.
9. A computing device, characterized in that It comprises a processing component and a storage component; the storage component stores one or more computer instructions; the one or more computer instructions are used to be called and executed by the processing component to implement an entity relationship extraction method for constructing a knowledge graph in the financial field as described in any one of claims 1 to 7.
10. A computer storage medium, characterized in that: A computer program is stored, and when the computer program is executed by a computer, an entity relationship extraction method for constructing a knowledge graph in the financial field as described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Relation extraction method and system based on knowledge map
CN108073711A
Entity relationship extraction method, device and equipment and storage medium thereof
CN111709240A
Analysis method and device for intimacy between entities, electronic equipment and storage medium
CN111930957A
Knowledge graph relation extraction method and system based on entity co-occurrence matrix
CN112487214A
Electric power knowledge graph construction method and device
CN112632287A
Cited By
Data traceability analysis system and method based on big data
CN119722337A
Knowledge construction method and system based on large model and RAG technology
CN120296111A