An entity relation extraction method and system for financial field knowledge graph construction
By using pre-trained natural language processing models and dependency parsing techniques in the financial field, combined with multi-dimensional evaluation and deep learning models, the problem of low accuracy in entity relation extraction in the financial field is solved, and efficient and accurate entity relation extraction and knowledge graph construction are achieved.
Patent Information
- Application Number
- CN202411444299.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2044-10-16
Smart Images

Figure CN119378494B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The embodiment of the present application relates to the technical field of knowledge graph, and particularly relates to an entity relation extraction method and system for financial field knowledge graph construction. BACKGROUND
[0002] With the globalization of financial markets and the continuous improvement of informationization, 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, which is 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 faced by the financial industry. Therefore, an efficient and accurate entity relation extraction technology is needed to support the construction of financial knowledge graph.
[0003] Currently, in the process of constructing a financial field knowledge graph, common entity relation extraction methods mainly include rule-based methods, machine learning-based methods, and methods combining the two. Among them, the rule-based method relies on manually defined templates or regular expressions to match entities and relationships; the machine learning-based method automatically learns the representation of entities and relationships by training a model; and the hybrid method tries to combine the advantages of both, using rules to guide model learning. These methods, although to some extent, solve the problem, but still have deficiencies when faced with the complex and variable professional terms and context of the financial field.
[0004] Existing entity relation extraction methods often lack understanding of financial professional knowledge when applied to the financial field, resulting in low extraction accuracy, especially in dealing with long-tail entities and complex relationships. In addition, rule-based methods require a large amount of human cost to maintain the rule set, making it difficult to adapt to the rapidly changing financial market; while machine learning-based methods, although capable of automatic learning, have high annotation costs for training data and limited model generalization ability. Therefore, it is urgent to develop a more intelligent and efficient entity relation extraction method to meet the needs of financial field knowledge graph construction. SUMMARY
[0005] The embodiment of the present application provides an entity relation extraction method and system for financial field knowledge graph construction, to solve the problem of poor entity relation extraction accuracy in the prior art.
[0006] In a first aspect, the embodiment of the present application provides an entity relation extraction method for financial field knowledge graph construction, comprising:
[0007] Obtaining original text data in the financial field;
[0008] Preprocessing the original text data, including word segmentation, stop word removal, and part-of-speech tagging, to obtain preprocessed text;
[0009] Performing entity recognition on the preprocessed text using a pre-trained natural language processing model to determine entities and their entity types in the text;
[0010] Determining dependency relationships between the entities using dependency syntax analysis techniques;
[0011] Extracting potential relationships between entities based on 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 strength of relationships between entities in the relationship candidate set;
[0013] Adding relationships with scores higher than a preset threshold to a knowledge graph in the financial domain.
[0014] Optionally, the determination of dependency relationships between the entities using dependency syntax analysis techniques includes:
[0015] Applying a dependency syntax analysis algorithm to analyze the preprocessed text and obtain a dependency tree structure;
[0016] Determining connection paths between entities based on the dependency tree structure to extract direct or indirect relationships between entities.
[0017] Optionally, the scoring of each pair of entities and their relationships in the relationship candidate set to determine the strength of relationships between entities in the relationship candidate set includes:
[0018] Calculating the relationship frequency between each pair of entities, 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, d i represents the relationship instances in document i, δ(e1, e2, d i ) represents an indicator function that takes the value 1 when e1 and e2 appear in document d i , and 0 otherwise, and N represents the total number of documents;
[0021] Calculating the strength of relationships between entities based on the relationship frequency, defined as:
[0022]
[0023] S(e1, e2) = a * F(e1, e2) + b * F(e2, e1) + g * F(e1, e2) * F(e2, e1) + theta * S(e1, e2), wherein S(e1, e2) represents the relationship strength of the entity e1 and the entity e2 calculated according to the relationship frequency, a, b, g, theta are preset parameters, and F(e2, e1) represents the relationship frequency of the entity e2 and the entity e1.
[0024] Optionally, the method further comprises: performing semantic similarity evaluation on the entity relationships in the relationship candidate set to filter out low-quality relationships.
[0025] The semantic similarity evaluation comprises:
[0026] The semantic vector of each pair of entities is calculated.
[0027] The similarity between the semantic vectors is calculated using the cosine similarity, 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] The entity relationships in the relationship candidate set with a semantic similarity lower than a preset threshold are filtered out.
[0031] Optionally, the entity recognition on the preprocessed text using the pre-trained natural language processing model comprises:
[0032] The pre-trained natural language processing model is used for entity recognition.
[0033] The preprocessed text is input into the natural language processing model to obtain the boundary position of the entity in the text and the entity type thereof.
[0034] Optionally, the method further comprises:
[0035] The relationship candidate set is further screened using a deep learning model to improve the accuracy of relationship extraction.
[0036] The further screening of the relationship candidate set using the deep learning model comprises:
[0037] A bidirectional long short-term memory network model based on an attention mechanism is constructed.
[0038] Features of each pair of entities and their context are extracted using the bidirectional long short-term memory network model.
[0039] The extracted features are input into a fully connected layer, and an activation function is used to output the probability distribution of each entity pair belonging to different relationship categories.
[0040] The highest probability relation category is selected as the final prediction result.
[0041] Optionally, further comprising:
[0042] The set of relation candidates is verified using a rule-based logical inference system to further improve the accuracy of relation extraction.
[0043] The logical inference system comprises:
[0044] A set of inference rules R is defined according to the professional knowledge in the financial field;
[0045] For each pair of entities e1, e2, the logical consistency is verified using the set of inference rules R to determine a consistency score, wherein the consistency score is defined as:
[0046]
[0047] wherein C(e1, e2) represents the consistency score of a given entity pair (e1, e2), η r is the weight coefficient of rule r, wherein rule r belongs to a specific instance in the set of inference rules R, ζ(e1, e2, r) is the applicability index of rule r applied to entity pair e1, e2, with a value range of [0, 1], taking a value of 1 when rule r is applicable to entity pair e1, e2, and 0 otherwise.
[0048] Optionally, the scoring of each pair of entities and their relations in the set of relation candidates to determine the relation strength between entities in the set of relation candidates further comprises:
[0049] Each pair of entities and their relations in the set of relation candidates is evaluated in multiple dimensions, and the multiple-dimensional evaluation includes:
[0050] A multi-dimensional feature vector of the relation is defined, including relation frequency, semantic similarity, and consistency score.
[0051] The multi-dimensional feature vector is classified using a support vector machine to determine the relation strength between entities, defined as:
[0052]
[0053] wherein X(e1, e2) represents the multi-dimensional feature vector of each pair of entity relations, SVM(X(e1, e2)) represents the estimation of the relation strength of each pair of entities (e1, e2) by the support vector machine, m represents the number of training samples, 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 a kernel function, X i is a multi-dimensional feature vector of a training sample, and b is a bias term.
[0054] Optionally, the method further comprises 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 comprises:
[0056] defining a graph G(V, E), wherein V represents a set of entities, and E represents a set of relationships between entities;
[0057] for each pair of entities (e1, e2) in the graph G, calculating a 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, and λ3 are preset weight coefficients, S(e1, e2) represents a relationship strength of the entity e1 and the entity e2 calculated according to the relationship frequency, C(e1, e2) is a consistency score of the entity e1 and the entity e2, and SVM(X(e1, e2)) represents an estimation of the relationship strength of each pair of entities (e1, e2) by a support vector machine;
[0060] updating the weights of the entities using a graph-based algorithm to optimize the structure of the graph.
[0061] Optionally, the method further comprises:
[0062] performing uncertainty evaluation on each pair of entities and its relationship in the set of relationship candidates to determine an uncertainty evaluation value of each pair of entities, wherein the uncertainty evaluation value is defined as:
[0063]
[0064] wherein U(e1, e2) represents the uncertainty evaluation value of a given pair of entities (e1, e2), R i is the i-th relationship category, and p(R i |e1, e2) is a conditional probability of the relationship R i given the pair of entities e1, e2, p(R i ) is a prior probability of the relationship R i , and n is the number of relationship categories.
[0065] wherein the performing uncertainty evaluation on each pair of entities and its relationship in the set of relationship candidates further comprises:
[0066] The mutual information is used to measure the dependency between the entity pair and the relationship thereof, and the dependency is defined as:
[0067]
[0068] wherein, MI(e1, e2, R) represents the mutual information, and is used to measure the dependency between the entity pair (e1, e2) and the relationship R thereof, R represents a 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 a conditional probability of the relationship r given the entity pair e1, e2, and p(r) is a prior probability of the relationship r.
[0069] Optionally, the method further comprises:
[0070] The neural network model is used to jointly evaluate each entity pair and the relationship thereof in the relationship candidate set to determine a joint evaluation value, wherein the joint evaluation value is defined as:
[0071]
[0072] wherein, J(e1, e2) represents the joint evaluation value of the given entity pair (e1, e2), NN is the neural network model, and the output thereof is a relationship evaluation score of the entity pair e1, e2, SVM(X(e1, e2)) represents an estimation of the relationship strength of the given entity (e1, e2) by the support vector machine, C(e1, e2) represents a consistency score of the given entity pair (e1, e2), U(e1, e2) represents an uncertainty evaluation value of the given entity pair (e1, e2), and MI(e1, e2, R) represents the dependency between the given entity pair (e1, e2) and the relationship R thereof.
[0073] In a second aspect, the embodiments of the present application provide an entity relationship extraction system for constructing a knowledge graph in the financial field, comprising:
[0074] An acquisition module is configured to acquire original text data in the financial field;
[0075] A preprocessing module is configured 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 configured to perform entity recognition on the preprocessed text by using a pre-trained natural language processing model to determine entities and entity types thereof in the text, and determine dependency relationships between the entities by using dependency syntax analysis technology;
[0077] A construction module is configured to extract potential relationships between the entities according to the dependency relationships, and construct a relationship candidate set;
[0078] The determining module is further configured to score each pair of entities and their relationship in the relationship candidate set to determine the relationship strength between entities in the relationship candidate set.
[0079] The relationship with a score higher than a preset threshold is added to the knowledge graph in the financial field.
[0080] In a third aspect, an embodiment of the present application provides a device, including 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, and implement the entity relationship extraction method for constructing a knowledge graph in a financial field as described in the first aspect.
[0081] In a fourth aspect, an embodiment of the present application provides a computer storage medium, which stores a computer program; when the computer program is executed by a computer, the entity relationship extraction method for constructing a knowledge graph in a financial field as described in the first aspect is implemented.
[0082] In the embodiment of the present application, original text data in the financial field is acquired; the original text data is preprocessed, including word segmentation, stop word removal, and part-of-speech tagging, to obtain preprocessed text; a pre-trained natural language processing model is used to perform entity recognition on the preprocessed text to determine entities and entity types in the text; a dependency syntax analysis technique is used to determine the dependency relationship between the entities; potential relationships between the entities are extracted according to the dependency relationship, and a relationship candidate set is constructed; each pair of entities and their relationship in the relationship candidate set is scored to determine the relationship strength between entities in the relationship candidate 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 in the present application can improve the efficiency and accuracy of entity relationship extraction.
[0083] These aspects or other aspects of the present application will be more apparent in the following description of the embodiments. BRIEF DESCRIPTION OF DRAWINGS
[0084] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiment or prior art description. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without any creative effort.
[0085] Figure 1 A flowchart of an entity relationship extraction method for constructing a knowledge graph in a financial field provided by an embodiment of the present application;
[0086] Figure 2A structural schematic diagram of an entity relationship extraction method system for financial field knowledge graph construction provided by an embodiment of the present application is shown in the figure.
[0087] Figure 3 A structural schematic diagram of a computing device provided by an embodiment of the present application is shown in the figure. DETAILED DESCRIPTION
[0088] In order to enable personnel in the technical field to better understand the scheme of the present application, the technical scheme in the embodiments of the present application will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present application.
[0089] In some processes described in the specification and claims of the present application and the above-mentioned drawings, a plurality of operations appearing in a specific order are included, but it should be clearly understood that these operations can be executed or in parallel without the order in which they appear in the text, and the serial numbers of the operations such as 101, 102, etc. are only used to distinguish different operations, and the serial numbers themselves do not represent any execution order. In addition, these processes can include more or fewer operations, and the operations can be executed in sequence or in parallel. It should be noted that the "first", "second", etc. in the text are used to distinguish different messages, devices, modules, etc. and do not represent the order. Also, "first" and "second" are not different types.
[0090] The technical scheme in the embodiments of the present application will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0091] Figure 1 A flowchart of an entity relationship extraction method for financial field knowledge graph construction provided by an embodiment of the present application is shown in the figure, which comprises: Figure 1
[0092] 101, obtaining original text data in the financial field;
[0093] In this step, obtaining original text data in the financial field means collecting unstructured information related to finance from different sources. These information can include news reports, company financial reports, market analysis reports, social media posts, etc. Any form of written material. 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, let's assume 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 scraping: Use web crawling techniques to scrape the latest news articles from financial news websites such as Bloomberg, CNBC, etc. Techniques involved include HTTP request sending, HTML page parsing (BeautifulSoup tools), regular expression matching, etc.
[0096] Social media API: Use social media platforms such as Twitter API to obtain tweets related to specific stocks or financial markets through keyword search functionality. This requires registering a developer account and applying for access permissions.
[0097] Company financial report download: Download the quarterly and annual financial statements of listed companies from the SEC (Securities and Exchange Commission) EDGAR database. This can be achieved through automated scripts that periodically check for updates and download the latest files.
[0098] For example, if we decide to obtain data about "Apple Inc." stocks from Twitter, we can set up a Python script using the Tweepy library to connect to the Twitter API. The script will use the following code snippet:
[0099] import tweepy
[0100] # Set your API keys
[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] # Authenticate
[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 files
[0112] with open('apple_tweets.txt','w')as f:
[0113] for tweet in tweets:
[0114] f.write(tweet.text+'\n')
[0115] The script above connects to the Twitter API and searches for the 100 most recent English tweets containing "AAPL" (Apple's stock ticker). It then saves the content of these tweets to a text file named apple_tweets.txt. This gives us a portion of raw text data about Apple.
[0116] 102. Preprocess the original text data, including word segmentation, stop word removal, and part-of-speech tagging, to obtain the preprocessed text;
[0117] In this step, preprocessing the raw text data refers to a series of standardization operations performed on the text data to improve the performance of subsequent natural language processing tasks. These operations mainly include tokenization, stop word removal, and part-of-speech tagging.
[0118] Tokenization is the process of dividing continuous text into words or phrases, and it is one of the fundamental steps in natural language processing.
[0119] Removing stop words refers to removing those very common but not carrying actual meaning words from the text, such as "of", "is", "in", etc., because these words are not helpful in most cases to understand the content of the text.
[0120] Part-of-speech tagging is to assign a part-of-speech tag to each word, such as Noun (NN), Verb (VB), Adjective (JJ), etc., which is very useful for understanding the structure and semantics of the sentence.
[0121] In this example, we continue to use the tweet data about Apple company 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 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] ## Make sure 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] # 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 the result
[0141] print(tagged_tokens)
[0142] In this example, we first loaded the list of stop words for English. Then, we read the previously saved text data and tokenized it. Next, we created a new list, filtered_tokens, which contains all the words after removing stop words. Finally, we used the pos_tag function to perform part-of-speech tagging on the filtered words and printed the tagged result.
[0143] In this way, we obtained the preprocessed text data, which can be further used for natural language processing tasks such as sentiment analysis, topic modeling, etc.
[0144] The output result may 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'), ('following', 'VBG'), ('release', 'NN'), ('better-than-expected', 'JJ'), ('earnings', 'NNS'), ('results', 'NNS'), ('.', '.')]
[0147] This example shows how to perform basic tokenization, stopword removal, and part-of-speech tagging on an English text.
[0148] 103. performing entity recognition on the preprocessed text using a pre-trained natural language processing model to determine entities and their entity types in the text;
[0149] Optionally, the "performing entity recognition on the preprocessed text using a pre-trained natural language processing model" in step 103 includes: performing entity recognition using a pre-trained natural language processing model; inputting the preprocessed text into the natural language processing model to obtain the boundary positions of entities and their entity types in the text.
[0150] In this step, performing entity recognition on the preprocessed text using a pre-trained natural language processing model means using a well-trained model to automatically identify named entities and their types in the text. Named entity recognition (NER) is an information extraction technique that identifies named entities in text, such as names of people, places, organizations, times, currency values, etc., and classifies 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 positions of entities in the text, i.e. identify which text fragments constitute an entity; second, label these entities with corresponding labels to indicate their type. Pre-trained models are usually trained on large-scale corpora and can be well generalized to new data, thus improving the accuracy and efficiency of entity recognition.
[0152] In this example, we will continue to use the Python programming language and the Spacy library to demonstrate how to perform entity recognition on a pre-processed text. Spacy is a powerful natural language processing library that comes with multiple pre-trained models that can be used directly for entity recognition tasks.
[0153] import spacy
[0154] # Load the pre-trained Spacy model
[0155] # Here we choose the English model
[0156] nlp = spacy.load('en_core_web_sm')
[0157] # Example text
[0158] text = "Apple's stock price rose sharply today following the release of better-than-expected earnings results."
[0159] # Perform entity recognition on the 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 the Spacy 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 well. Then we define an example text and use the nlp object to process the text. After processing, we get all the recognized entities by iterating over the doc.ents attribute and print out their text content and entity types.
[0165] Assuming the model successfully recognizes the entities in the text, the output might look like:
[0166] Apple ORG
[0167] This means the model considers "Apple" as an organization name. Note that Spacy supports multiple entity types, such as:
[0168] PERSON: Person names
[0169] NORP: Nationalities or religious groups
[0170] FAC: Facilities, such as buildings, airports, etc.
[0171] ORG: Organizations, e.g. companies, agencies, branches, etc.
[0172] GPE: Geographic locations, e.g. countries, cities, etc.
[0173] LOC: Non-GPE locations, e.g. mountain ranges, famous landmarks, etc.
[0174] PRODUCT: Objects, e.g. products, cars, etc.
[0175] EVENT: Events, e.g. sports games, concerts, etc.
[0176] WORK_OF_ART: Works of art, e.g. books, movies, etc.
[0177] LAW: Laws, e.g. laws, regulations, etc.
[0178] LANGUAGE: Languages, e.g. English, Chinese, etc.
[0179] DATE: Dates, e.g. 2022-01-01, etc.
[0180] TIME: Times, e.g. 10:00, etc.
[0181] PERCENT: Percentages, e.g. 50%, etc.
[0182] MONEY: Amounts of money, e.g. $100, etc.
[0183] QUANTITY: Quantities, e.g. 100, etc.
[0184] ORDINAL: Ordinal numbers, e.g. first, second, etc.
[0185] CARDINAL: Cardinal numbers, e.g. one, two, etc.
[0186] The above examples demonstrate 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 text and provide a foundation for subsequent analysis or application.
[0187] 104. determining dependencies between the entities using dependency syntax analysis techniques;
[0188] Optionally, the step 104 of "determining dependencies between the entities using dependency syntax analysis techniques" includes: applying a dependency syntax analysis algorithm to analyze the pre-processed text to obtain a dependency tree structure; and determining a connection path between entities based on the dependency tree structure to extract direct or indirect relationships between entities.
[0189] In this step, determining the dependency relationships between entities using dependency parsing techniques means understanding the sentence structure and extracting relationships between entities by analyzing the dependencies between words in the sentence. Dependency parsing is a natural language processing technique that focuses on the direct dependencies between words rather than the overall structure of the sentence. The results of dependency parsing are usually represented in the form of a dependency tree, where each word is a node of the tree, and the edges represent the dependencies between words.
[0190] Dependency parsing algorithms can be divided into various types according to different models and methods, such as early graph models, transformation models, etc. The commonly used neural network model is now commonly used. Through dependency parsing, we can determine the "head word" of each word in the sentence and the relationship type between them, so as to better understand the semantic structure of the sentence.
[0191] In this application embodiment, we will continue to use the Python programming language and the Spacy library to demonstrate how to perform dependency parsing on a pre-processed text and determine the dependency relationships between entities.
[0192] import spacy
[0193] # Load the pre-trained Spacy model
[0194] nlp = spacy.load('en_core_web_sm')
[0195] # Example 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 parsing on the text
[0198] doc = nlp(text)
[0199] # Output the dependency relationships 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 dependency relations between entities
[0203] for ent in doc.ents:
[0204] # Find the head token of the entity
[0205] head_token = ent.root
[0206] # Get all children of the entity head token
[0207] children = list(head_token.children)
[0208] # Print the entity and its children
[0209] print(f"Entity: {ent.text}, Head: {head_token.text}, Children: {[child.text for child in children]}")
[0210] In this example, we first load the Spacy pre-trained model en_core_web_sm. Then, we define a sample text and use the nlp object to process the text. After processing, we output the dependency relation type (dep_), head token (head), and part of speech (pos_) of each word by iterating through each token in the doc object. This helps us understand the structure of the sentence.
[0211] Next, we look for the root token of each identified entity (ent) and get all the children of the root token. In this way, we can determine the direct or indirect relationship between the entity and its surrounding words.
[0212] Assuming the model successfully identifies the entities in the text and analyzes the dependency relations, the output might look like:
[0213]
[0214] In this output, we can see the dependency relations of each word and its head token, as well as the dependency relations of the entity "Apple". Through dependency relations, we can further analyze the relationship between the entity and other words, such as the relationship between "Apple" as the subject and its predicate verb "rose".
[0215] This example demonstrates how to use dependency syntax analysis techniques to determine the dependency relationships between entities in preprocessed text. Through this method, we can gain a deeper understanding of the semantic structure in the text.
[0216] 105、According to the dependency relationship, extract the potential relationship between entities and construct a relationship candidate set;
[0217] In this step, according to the dependency relationship, extracting the potential relationship between entities and constructing a relationship candidate set means extracting the relationship between entities from the dependency tree structure obtained by dependency syntax 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 build 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-predicate-object relationships), semantic roles, etc. The purpose of constructing a relationship candidate set is to provide candidates for subsequent automatic relationship classification or manual review.
[0219] In the embodiments of the present 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] # Example 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 get 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 a 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 relationships in the dependency tree structure
[0247] For the token in the document:
[0248] print(f"{token.text:<12}{token.dep_:<10}{token.head.text:<12}{token.head.pos_}")
[0249] # Output dependency relations 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 the set of relation candidates
[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 output the dependency relation type (dep_), head word (head), and the part-of-speech (pos_) of each word by iterating through each token in the doc object.
[0263] Next, we define a function `get_dependency_path` that takes two entities as input and attempts to find the dependency path between them. We use a depth-first search (DFS) approach to find the path and record each word pair along the path.
[0264] Then, we iterate through each entity pair (ent1 and ent2). If they are not the same entity, we call the get_dependency_path function to obtain the path between them. If a path exists, we store this path information in the relations list, forming a candidate relation set.
[0265] Finally, we output each pair of relations and its dependency path in the candidate relation set.
[0266] Assuming the model successfully identifies entities in the text and analyzes dependencies, the output might look something like this:
[0267]
[0268]
[0269] In this output, we can see the dependency relationships 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, providing a foundation for further relationship classification.
[0270] 106. Score each pair of entities and their relationship in the candidate relationship set to determine the strength of the relationship between entities in the candidate relationship set;
[0271] Optionally, step 106, "scoring each pair of entities and their relationship in the candidate relationship set to determine the relationship strength between entities in the candidate relationship set," includes:
[0272] Calculate the relation frequency between each pair of entities, whereby the relation frequency is defined as:
[0273]
[0274] Where F(e1,e2) represents the relation frequency between entities e2 and e1, e1 and e2 represent the first and second entities in each pair of entities, respectively, and d i δ(e1,e2,d) represents a relation instance in document i. i ) indicates an indicator function, when e1 and e2 are in document d i The value is 1 if it appears in the document, and 0 otherwise. N represents the total number of documents.
[0275] According to the relationship frequency, the relationship strength between entities is calculated, which is defined as:
[0276]
[0277] where 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) appears together in multiple documents.
[0280] The calculation formula is where δ(e1, e2, d i ) is an indicator function that returns 1 if e1 and e2 appear together in document d i , otherwise returns 0, and N represents the total number of all documents.
[0281] Relation Strength:
[0282] Relation Strength is a value calculated according to the relationship frequency, which quantifies the strength of the relationship between two entities.
[0283] The formula is where α, β, γ, θ are preset parameters used to adjust the calculation method of relationship strength.
[0284] In the embodiments of the present application, it is assumed that we have the following financial field text data set containing N = 1000 articles about financial markets. Our goal is to extract entity pairs and their relationships from these articles and calculate their relationship strength.
[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 together in the same document 50 times, while "interest rate" and "Bank A" appear together 45 times.
[0289] Therefore, F("Bank A", "interest rate") = 50F, F("interest rate", "Bank A") = 45F.
[0290] Relationship strength calculation:
[0291] The preset parameters are set as follows: α = 0.7, β = 0.3, γ = 1.5, θ = 10.
[0292] Calculate the relationship strength using the formula:
[0293]
[0294] Assume e -1.5×(50-10) If the value 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 frequency of the relationship between "Bank A" and "interest rate" is 50, and the strength of the relationship is 0.91. This means that the entities "Bank A" and "interest rate" appear relatively frequently in our text dataset, and the relationship between them is considered strong.
[0296] This is a specific example of how to assess the strength of relationships between entity pairs in the financial sector by calculating relationship frequency and strength. This process can be automated and applied to large amounts of data to help build more accurate knowledge graphs.
[0297] 107. Add relationships with scores higher than a preset threshold to the knowledge graph of the financial field.
[0298] In this step, adding relationships with scores above a preset threshold to the financial knowledge graph means incorporating entity pairs and their relationships, deemed to have strong connections, into a structured knowledge representation. A knowledge graph is a graphical representation of knowledge, using nodes to represent entities and edges to represent relationships between them. By adding high-scoring relationships to the knowledge graph, we can build a richer and more accurate financial knowledge base, supporting various advanced applications such as intelligent recommendation, risk assessment, and market prediction. The preset threshold is a pre-defined standard value; only when a relationship's score exceeds this threshold is it considered sufficiently reliable and added to the knowledge graph. This ensures the quality of the knowledge graph and avoids knowledge errors or redundancy caused by noisy data.
[0299] Assuming we have completed the previous steps and obtained a candidate set of relations and their scores, we will now add relations with scores above a preset threshold to a financial knowledge graph. The specific implementation steps are as follows:
[0300] Define a preset threshold: Set a reasonable threshold to filter relationships. For example, we set the threshold to 0.5.
[0301] Filter relationships: Select relationships 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.
[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 a preset threshold
[0307] threshold = 0.5
[0308] # Suppose we have the following set of relationship candidates and their 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 relationships with scores higher than a 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] #Visualized 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 define a preset threshold of 0.5. Then, we have a list `relationships` containing a set of candidate relationships and their scores. Next, we create an undirected graph `G` using the NetworkX library and add all entities as nodes to the graph. We filter out relationships with scores higher than the threshold and add them as edges to the graph. Finally, we visualize the knowledge graph using Matplotlib and output the relationships added to the knowledge graph.
[0337] The output result could be:
[0338] Relationships added to the knowledge graph:
[0339] ('Apple','stock')
[0340] ('earnings','release')
[0341] ('price','rise')
[0342] This indicates that we have successfully added relationships with scores higher than the preset threshold to the knowledge graph in the financial field. In this way, we can continuously accumulate and update the knowledge graph, making it an important tool in the financial field.
[0343] Optionally, it also includes: performing semantic similarity evaluation on the 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 of each pair of entities;
[0346] Calculate the similarity between the semantic vectors using cosine similarity, which is defined as:
[0347]
[0348] Where 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 the entity relationships in the relationship candidate set whose semantic similarity is lower than the preset threshold.
[0350] In this step, Semantic Vectors: Semantic vectors are numerical vectors that represent entities in text. These vectors capture the semantic relationships between entities. Common methods for generating semantic vectors include pre-trained models such as Word2Vec, GloVe, or BERT.
[0351] Cosine Similarity: Cosine similarity is a measure of the angle between two non-zero vectors, used to measure their similarity. The value of cosine similarity is usually between -1 and 1, and the closer the value is to 1, the more similar the two vectors are.
[0352] Predefined Threshold: The predefined threshold is a value used after cosine similarity calculation to filter out entity pairs with a similarity lower than this value. Only when the similarity of an entity pair is higher than this threshold, their relationship is considered high quality and thus retained.
[0353] In the embodiments of the present application, 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 background of the embodiments, it is assumed that we have a set of candidate entity pairs, such as "Bank A" and "interest rate", "Company B" and "stock price", "Person C" and "bond", etc.
[0355] We have generated semantic vectors for each entity using a pre-trained natural language processing model (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] Calculate the similarity of each pair of entities using the cosine similarity formula:
[0358]
[0359] Suppose we get 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] Suppose we set the predefined threshold to 0.6, i.e. only those entity pairs with a cosine similarity greater than or equal to 0.6 will be retained.
[0364] Filtering 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, this relationship will be retained.
[0367] For "Company B" and "Stock Price", since 0.55 < 0.6, the relationship is filtered out.
[0368] For "Person C" and "Bond", since 0.75 > 0.6, the relationship is kept.
[0369] After semantic similarity evaluation, we keep the relationships of "Bank A" and "Interest Rate" and "Person C" and "Bond", while the relationship of "Company B" and "Stock Price" is filtered out.
[0370] By calculating the semantic vectors of entity pairs and their cosine similarity, and setting a preset threshold (e.g. 0.6), we successfully filter out low-quality relationships and only keep those that are semantically more relevant and of higher quality. This step helps improve the accuracy and reliability of the knowledge graph.
[0371] Optionally, further comprising: using a deep learning model to perform secondary screening on the candidate relationship set to improve the accuracy of relationship extraction.
[0372] The secondary screening of the candidate relationship set using a deep learning model includes: 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 from each pair of entities and their context; 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; 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 secondary screening on the candidate relationship set to improve the accuracy of relationship extraction. This step is usually after the initial relationship extraction, and through a more complex model, the quality of the candidate relationships is verified and optimized.
[0374] Deep learning model: a machine learning method that simulates the working principle of human brain neurons, learning complex patterns in data through multiple layers of neural networks.
[0375] Attention mechanism: a technique that enables the model to focus on certain parts of the input sequence, enhancing the model's ability to handle long sequences.
[0376] Bidirectional Long Short-Term Memory Network (BiLSTM): an improved Recurrent Neural Network (RNN) that can remember long-term dependencies and consider past and future context information simultaneously through a bidirectional approach.
[0377] Feature extraction: The process of obtaining information from raw data that helps in classification or prediction.
[0378] Fully Connected Layer (FC): A layer in a neural network where each neuron is connected to all neurons in the previous layer.
[0379] Activation function: A function used to introduce non-linearity 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, the sum of all probabilities equals 1.
[0381] Relation class: Different types of relations that an entity pair in a relation candidate set may have, such as "works at", "located at", etc.
[0382] In this embodiment, we assume that we have obtained a relation candidate set containing multiple entity pairs and their possible relations. Now we want to use a BiLSTM model based on attention mechanism for secondary screening to improve the accuracy of final relation extraction.
[0383] Construct a bidirectional long short-term memory network model based on attention mechanism:
[0384] First, we need to define a neural network architecture that includes 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 context information around them. For example, for the entity pair "Zhang San" and "Beijing", we may get the sentence "Zhang San lives in Beijing". Then we input this sentence into the BiLSTM model, which outputs a hidden state vector for each word.
[0387] Next, the attention mechanism layer will perform weighted summation on these hidden state vectors to obtain a more focused vector representation that emphasizes the most useful parts for relation identification.
[0388] Input the extracted features into the fully connected layer, and output the probability distribution of each entity pair belonging to different relation classes through the activation function:
[0389] The feature vectors output from the attention mechanism layer are fed into one or more fully connected layers. After the fully connected layers, we usually add a softmax layer as the activation function, which can output a probability distribution for each entity pair belonging to different relation classes. For example, the output might be [0.2, 0.1, 0.6, 0.1], which means the model thinks that the entity pair is most likely to belong to the third relation class with a probability of 60%.
[0390] The relation class with the highest probability is chosen as the final prediction result:
[0391] According to the probability distribution output by the softmax layer, we choose the relation class 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 relation class.
[0392] In the example of the embodiment, let's assume we have a sentence: "Li Si works at Alibaba."
[0393] Entity pair: "Li Si" and "Alibaba"
[0394] Context: "works at"
[0395] Build the model:
[0396] Define the BiLSTM+Attention model using frameworks such as TensorFlow or PyTorch.
[0397] Feature extraction:
[0398] Input the sentence "Li Si works at Alibaba.", after the embedding layer and BiLSTM layer, 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 into the fully connected layer and passes through the softmax layer to get the probability distribution of the relation class. Suppose the output is [0.1, 0.8, 0.05, 0.05].
[0402] Final prediction:
[0403] The relation class corresponding to the highest probability is the second class, assuming the class list is ["friend", "works at", "located at", "owns"], the prediction result is "works at".
[0404] In this way, we 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, it also includes using a rule-based logical reasoning system to verify the candidate set of relations to further improve the accuracy of relation extraction.
[0406] The logical reasoning system includes defining a set of reasoning rules R based on professional knowledge in the financial field; for each pair of entities e1, e2, use the reasoning rule set R to verify its logical consistency to determine the consistency score, where the consistency score is defined as:
[0407]
[0408] Where C(e1,e2) represents the consistency score of the given entity pair (e1,e2), η r is the weight coefficient of rule r, where rule r belongs to a specific instance in the reasoning rule set R, ζ(e1,e2,r) is the applicability index of rule r applied to entity pair e1,e2, with a value range of [0,1], taking the value of 1 when the rule r is applicable to the entity pair e1,e2, otherwise 0.
[0409] Rule-Based Logical Reasoning System (Rule-Based Logical Reasoning System):
[0410] This is a system that verifies data consistency by applying a set of predefined rules. In this context, rules are used to ensure that the entity relations extracted from text conform to the logical structure and common sense of a specific field.
[0411] Rule Set R (Rule Set R):
[0412] The reasoning rule set is a collection of logical rules that define the logical conditions that entities should meet. For example, in the financial field, rules such as "If a company issues stocks, then the company must be a listed company" can be defined.
[0413] Consistency Score C(e1,e2) (Consistency Score): The consistency score is a quantitative measure of the logical consistency of entity pair 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 a rule r. Different rules can have different weights depending on their importance in the verification process.
[0415] Applicability Indicator ζ(e1, e2, r):
[0416] The applicability indicator is used to determine whether a rule r is applicable to a specific entity pair e1 and e2. If the rule is applicable, the indicator is 1, otherwise it is 0.
[0417] In the embodiments of the present application, we assume that we are building a knowledge graph in the financial field and want to verify the relationship candidate set extracted from the text through a logical reasoning system.
[0418] Define the set of reasoning rules R: Define some rules about the financial field. For example:
[0419] Rule R1: If an entity is a "stock issuer", it should also be a "listed company".
[0420] Rule R2: If an entity is a "bond issuer", it should also be an "enterprise" 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 applicability indicator ζ(e1, e2, r)
[0424] For each pair of entity relationships e1 and e2, check whether it satisfies each rule r. If it does, then
[0425] ζ(e1, e2, r) = 1, otherwise 0.
[0426] Calculate the consistency score Cc:
[0427] Calculate the consistency score of each entity pair using the defined consistency score formula:
[0428] C(e1, e2) = ∑ r∈R η r × ζ(e1, e2, r)
[0429] For example, assume the following situation:
[0430] The entity pair (e1, e2) is ("Company X", "stock issuer"), so ζ(e1, e2, r1) = 1 because Company X issues stocks, it should also be a public company.
[0431] The entity pair (e1, e2) is ("Company Y", "bond issuer"), so ζ(e1, e2, r2) can be 1 or 0, depending on whether Company Y is an "enterprise" or a "government agency".
[0432] In the example calculation, we assume we have two entity pairs (e1, e2) and (e3, e4), and two rules r1 and r2, with weights 0.8 and 0.5 respectively.
[0433] For (e1, e2) = ("Company X", "stock issuer"), assume ζ(e1, e2, r1) = 1 and ζ(e1, e2, r2) = 0, then C(e1, e2) = 0.8 * 1 + 0.5 * = 0.8.
[0434] For (e3, e4) = ("Company Y", "bond issuer"), assume ζ(e3, e4, r1) = 0 and ζ(e3, e4, r2) = 1, then C(e3, e4) 0.8 * 0 + 0.5 * 1 = 0.5.
[0435] By calculating the consistency score of each entity pair, we can better understand their logical consistency. A high score indicates that the entity pair is more consistent with our domain rules, and therefore is more likely to be the correct entity relationship.
[0436] By using a rule-based logical reasoning system, we can verify the relationship candidate set according to the professional knowledge of the financial field, and improve the accuracy of relationship extraction by calculating the consistency score. This method helps to reduce false relationships and enhance the quality of the knowledge graph.
[0437] Optionally, it also includes: optimizing the structure of the knowledge graph by using a graph-based algorithm;
[0438] The optimization of the structure of the knowledge graph by using a graph-based algorithm includes: defining a graph G(V, E), where V represents the set of entities and E represents the 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:
[0439] W(e1, e2) = λ1 × S(e1, e2) + λ2 × C(e1, e2) + λ3 × SVM(X(e1, e2))
[0440] where λ1, λ2, λ3 are predefined weight coefficients, S(e1, e2) represents the relation strength between entity e1 and entity e2 calculated based on the relation frequency, C(e1, e2) is the consistency score of entity e1 and entity e2, and SVM(X(e1, e2)) represents the estimation of the relation strength of each pair of entities (e1, e2) by the support vector machine.
[0441] The weights of entities are updated using a graph-based algorithm to optimize the structure of the graph.
[0442] Graph G(V, E):
[0443] Graph G is a mathematical structure consisting of a set of nodes V and a set of edges E, where nodes V represent a set of entities and edges E represent a set of relations between entities. In this context, graph G is used to represent a knowledge graph in the financial domain.
[0444] Edge weight W(e1, e2):
[0445] The weight is a numerical value assigned to each pair of entities (e1, e2) in the graph G, representing the strength of the relationship between the two entities. The calculation of the weight takes into account the relation strength, consistency score, and the estimation of the support vector machine.
[0446] Predefined weight coefficients λ1, λ2, λ3:
[0447] These coefficients are used to adjust the importance of each factor in calculating the weight. Different coefficient values will make some factors have a greater impact on the final weight.
[0448] Relation strength S(e1, e2):
[0449] The relation strength is calculated based on the relation frequency, reflecting the closeness of the relationship between the two entities.
[0450] Consistency score C(e1, e2):
[0451] The consistency score is calculated by a logical reasoning system, reflecting the logical consistency of the entity pair.
[0452] Support vector machine SVM(X(e1, e2)):
[0453] The support vector machine is a machine learning method used to estimate the relation strength of the entity pair. Here, the SVM estimates the relation strength between the entity pair.
[0454] In this example, we have already completed a series of preliminary work, including relationship strength scoring, semantic similarity evaluation and logical consistency verification. Now we want to use graph-based algorithms to optimize the structure of the knowledge graph.
[0455] Define graph G(V, E)
[0456] We define a graph G, where V is the set of entities and E is the set of relationships between entities. For example, V may contain entities "Bank A", "interest rate", "Company B", "stock price", "Person C" and "bond".
[0457] Calculate weight W(e1, e2)
[0458] We need to calculate the weight for each pair of entities (e1, e2) in the graph G. The formula for calculating the weight is:
[0459] W(e1, e2) = λ1 × S(e1, e2) + λ2 × C(e1, e2) + λ3 × SVM(X(e1, e2))
[0460] Suppose we have the following values:
[0461] λ1 = 0.5, λ2 = 0.3, λ3 = 0.2
[0462] S(e1, e2) = 0.91 (e.g., the relationship strength between "Bank A" and "interest rate")
[0463] C(e1, e2) = 0.8 (e.g., the consistency score of "Bank A" and "interest rate")
[0464] SVM(X(e1, e2)) = 0.75 (e.g., the SVM estimate of "Bank A" and "interest rate")
[0465] Calculate the weight:
[0466] 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
[0467] Graph-based algorithms can help us adjust the weights of edges in graph G, thereby optimizing the structure of the knowledge graph. Here we can use algorithms such as PageRank, random walk or other graph optimization algorithms to redistribute the weights.
[0468] For example, using the PageRank algorithm, we can recalculate the importance of each node according to its in-degree and out-degree, and adjust the weight of the edge accordingly.
[0469] Summary of the example
[0470] By defining the graph G and calculating the weight W(e1, e2) for each pair of entities, we can better understand the strength of the relationship between entities. Using graph-based algorithms to update the weights helps optimize the overall structure of the knowledge graph, making it more reasonable and accurate.
[0471] Suppose we have the following pairs of entities and their calculated results:
[0472] (e1, e2) = ("Bank A", "interest rate"), weight W(e1, e2) = 0.845
[0473] (e3, e4) = ("Company B", "stock price"), weight W(e3, e4) = 0.6
[0474] (e5, e6) = ("Person C", "bonds"), weight W(e5, e6) = 0.7
[0475] 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.
[0476] Optionally, it also includes: performing uncertainty evaluation on each pair of entities and their relationships in the relationship candidate set to determine the uncertainty evaluation value of each pair of entities, wherein the uncertainty evaluation value is defined as:
[0477]
[0478] where U(e1, e2) represents the uncertainty evaluation value of the given entity pair (e1, e2), R i is the i-th relationship category, p(R i |e1, e2) is the conditional probability of relationship R i given the entity pair e1, e2, p(R i ) is the prior probability of relationship R i , and n is the number of relationship categories.
[0479] wherein the uncertainty evaluation on each pair of entities and their relationships in the relationship candidate set further includes: using mutual information to measure the dependence between the entity pair and its relationship, and the dependence is defined as:
[0480]
[0481] where MI(e1, e2, R) represents mutual information, which measures the dependency between the entity pair (e1, e2) and its relationship R, R represents a 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 the relationship r given the entity pair e1, e2, and p(r) is the prior probability of the relationship r.
[0482] Uncertainty Evaluation:
[0483] Uncertainty Evaluation is used to measure the uncertainty of the relationship of a given entity pair (e1, e2). The higher this evaluation value is, the greater the uncertainty of the relationship is.
[0484] Uncertainty Evaluation Value U(e1, e2):
[0485] The uncertainty evaluation value is calculated according to the conditional probability distribution of a given entity pair (e1, e2) and the prior probability of the relationship category. The formula is:
[0486]
[0487] where R i represents the i-th relationship category, p(R i |e1, e2) is the conditional probability of the relationship R i given the entity pair (e1, e2), pR i is the prior probability of the relationship R i , and n is the number of relationship categories.
[0488] Mutual Information MI(e1, e2, R):
[0489] Mutual information is used to measure the dependency between the entity pair (e1, e2) and its relationship. The formula is:
[0490]
[0491] where r represents a specific relationship in the relationship category R, p(r|e1, e2) is the conditional probability of the relationship r given the entity pair e1, e2, and p(r) is the prior probability of the relationship r.
[0492] In the embodiments of the present application, it is assumed that we have completed the relationship strength scoring of the entity pair, the semantic similarity evaluation, and the logical consistency verification, and we want to further understand the reliability of the relationship through uncertainty evaluation.
[0493] Let's assume we have defined three relationship categories: Owning, Investing, Cooperating.
[0494] We need to compute the conditional probability p(r|e1, e2) for each entity pair (e1, e2) under different relationship categories.
[0495] We also need to compute the prior probability p(R i ) for each relationship category. This is usually based on the frequency of occurrence of each relationship category in the entire dataset.
[0496] Let's assume we have the following entity pairs and their conditional probabilities and prior probabilities:
[0497] Entity pair (e1, e2) = ("Bank A", "Interest Rate");
[0498] Conditional probability p(Owning|e1, e2) = 0.1;
[0499] Conditional probability p(Investing|e1, e2) = 0.8;
[0500] Conditional probability p(Cooperating|e1, e2) = 0.1;
[0501] Prior probability p(Owning) = 0.3;
[0502] Prior probability p(Investing) = 0.5;
[0503] Prior probability p(Cooperating) = 0.2;
[0504] Entity pair (e3, e4) = ("Company B", "Stock Price");
[0505] Conditional probability p(Owning|e3, e4) = 0.3;
[0506] Conditional probability p(Investing|e3, e4) = 0.5;
[0507] Conditional probability p(Cooperating|e3, e4) = 0.2;
[0508] Compute the uncertainty assessment value for each entity pair using the uncertainty assessment value formula:
[0509]
[0510] For entity pair (e1, e2) = ("Bank A", "Interest Rate"):
[0511]
[0512] For entity pair (e3, e4) = ("Company B", "stock price"):
[0513]
[0514] Calculate the mutual information of each entity pair using the mutual information formula:
[0515]
[0516] For entity pair (e1, e2) = ("Bank A", "interest rate"):
[0517]
[0518] MI(e1, e2, R) ≈ 0.1 × (-1.585) + 0.8 × 0.322 + 0.1 × (-1) ≈ -0.1585 + 0.2576 - 0.1 = -0.0009
[0519] For entity pair (e3, e4) = ("Company B", "stock price"):
[0520]
[0521] By calculating the uncertainty evaluation value and mutual information of each entity pair, we can better understand the reliability and dependence of each entity pair relationship. The lower the uncertainty evaluation value, the more certain the relationship; the higher the mutual information value, the higher the dependence between the entity pair and its relationship.
[0522] This step helps further filter and optimize the relationship candidate set, thereby improving the accuracy and reliability of the knowledge graph.
[0523] Optionally, it also 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:
[0524]
[0525] where 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 entity pair e1, e2, SVM(X(e1, e2)) represents the relationship strength estimate of the given entity (e1, e2) by the support vector machine, 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 dependence between the given entity pair (e1, e2) and its relationship R.
[0526] Joint Evaluation Value J(e1, e2):
[0527] The joint evaluation value is the result of a comprehensive evaluation of the relationship between a given entity pair (e1, e2). It integrates multiple evaluation metrics, including support vector machine estimation, consistency score, uncertainty evaluation value, and mutual information.
[0528] Neural Network Model (NN):
[0529] A neural network model is a machine learning model that can take multiple input features and output a comprehensive score. In this scenario, the neural network model takes four input features: support vector machine estimate, consistency score, uncertainty assessment value, and mutual information.
[0530] Support Vector Machine (SVM(X(e1, e2)))
[0531] Support Vector Machines (SVMs) are a type of supervised learning model used for classification and regression analysis. In this context, SVMs are used to estimate the relationship strength of a given pair of entities (e1, e2).
[0532] Consistency Score C(e1, e2):
[0533] The consistency score is calculated through a logical reasoning system and reflects the logical consistency of entity pairs.
[0534] Uncertainty Evaluation Value U(e1, e2):
[0535] The uncertainty assessment value is used to measure the uncertainty of the relationship between a given pair of entities (e1, e2). The higher the assessment value, the greater the uncertainty of the relationship.
[0536] Mutual Information MI(e1, e2, R):
[0537] Mutual information is used to measure the degree of dependency between an entity pair (e1, e2) and its relation.
[0538] In this embodiment, it is assumed that we have already completed entity pair relation strength scoring, semantic similarity evaluation, logical consistency verification, uncertainty evaluation, and mutual information calculation. Now we wish to use a neural network model to jointly evaluate each pair of entities and their relation in the relation candidate set.
[0539] We need to prepare four features for each entity pair:
[0540] SVM(X((e1, e2)): Support Vector Machine estimate
[0541] C(e1, e2): Consistency score
[0542] U(e1, e2): Uncertainty evaluation value
[0543] MI(e1, e2, R): Mutual information
[0544] Train a neural network model
[0545] Suppose we have trained a neural network model NN that can receive the above four features as input and output a comprehensive score.
[0546] Suppose there are the following entity pairs and their corresponding feature values:
[0547] Entity pair (e1, e2) = ("Bank A", "interest rate");
[0548] SVM(X(e1, e2)) = 0.75;
[0549] C(e1, e2) = 0.8;
[0550] U(e1, e2) = 0.1;
[0551] MI(e1, e2, R) = 0.2;
[0552] Entity pair (e3, e4) = ("Company B", "stock price");
[0553] SVM(X(e3, e4)) = 0.6;
[0554] C(e3, e4) = 0.7;
[0555] U(e3, e4) = 0.2;
[0556] MI(e3, e4, R) = 0.15;
[0557] Use the neural network model NN to jointly evaluate the features of each entity pair:
[0558] J(e1, e2) = NN(SVM(X(e1, e2)), C(e1, e2), U(e1, e2), MI(e1, e2, R))
[0559] Assume that the output of the neural network model NN is the relationship evaluation score of the entity pair (e1, e2).
[0560] Computing joint evaluation values
[0561] For entity pair (e1, e2) = ("Bank A", "interest rate"):
[0562] J(e1, e2) = NN(0.75, 0.8, 0.1, 0.2)
[0563] Assuming the output of the neural network model NN is 0.85.
[0564] For entity pair (e3, e4) = ("Company B", "stock price"):
[0565] J(e3, e4) = NN(0.6, 0.7, 0.2, 0.15)
[0566] Assuming the output of the neural network model NN is 0.7.
[0567] By using the neural network model NN to jointly evaluate the relationship of entity pairs, we can get a comprehensive score that integrates multiple evaluation indicators. This comprehensive evaluation helps to further improve the accuracy and reliability of relationship extraction.
[0568] Finally, we get the following joint evaluation values:
[0569] For entity pair (e1, e2) = ("Bank A", "interest rate"), the joint evaluation value is 0.85.
[0570] For entity pair (e3, e4) = ("Company B", "stock price"), the joint evaluation value is 0.7.
[0571] In this way, we can further filter and optimize the relationship candidate set to ensure that the relationships finally added to the knowledge graph are of high quality.
[0572] Figure 2 An entity relationship extraction system structure diagram for financial field knowledge graph construction is provided for the embodiments of the present application, as shown in Figure 2 The device comprises:
[0573] An acquisition module 21 is configured to acquire original text data in the financial field.
[0574] A preprocessing module 22 is configured to preprocess the original text data, including word segmentation, stop word removal, and part-of-speech tagging operations, to obtain preprocessed text.
[0575] A determination module 23 is configured to use a pre-trained natural language processing model to perform entity recognition on the preprocessed text to determine entities and their entity types in the text; and use dependency syntax analysis technology to determine the dependency relationships between the entities.
[0576] constructing a module 24 for extracting potential relationships between entities according to the dependency relationship and constructing a relationship candidate set;
[0577] The determining module 23 is further configured to score each pair of entities and their relationship in the relationship candidate set to determine the relationship strength between entities in the relationship candidate set.
[0578] The adding module 25 adds the relationship with a score higher than a preset threshold to the knowledge graph in the financial field.
[0579] Figure 2 The entity relationship extraction system for constructing the knowledge graph in the financial field can perform Figure 1 The implementation principle and technical effects of the entity relationship extraction system for constructing the knowledge graph in the financial field are not described again. The specific manner in which each module, unit in the entity relationship extraction system for constructing the knowledge graph in the financial field performs operations has been described in detail in the embodiments related to the method, and will not be described in detail here.
[0580] In one possible design, Figure 2 The entity relationship extraction system for constructing the knowledge graph in the financial field can be implemented as a computing device, such as Figure 3 As shown in the figure, the computing device can include a storage component 31 and a processing component 32.
[0581] 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.
[0582] The processing component 32 is configured to: obtain original text data in the financial field; perform preprocessing on the original text data, including word segmentation, stop word removal, and part-of-speech tagging operations, to obtain preprocessed text; perform entity recognition on the preprocessed text using a pre-trained natural language processing model to determine entities and entity types in the text; determine dependency relationships between the entities using dependency syntax analysis technology; extract potential relationships between entities according to the dependency relationships and construct a relationship candidate set; score each pair of entities and their relationship in the relationship candidate set to determine the relationship strength between entities in the relationship candidate set; and add the relationship with a score higher than a preset threshold to the knowledge graph in the financial field.
[0583] The processing component 32 can 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 can also be 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, micro-controllers, microprocessors or other electronic components, configured to perform the methods described above.
[0584] The storage component 31 is configured to store various types of data to support the operation of 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 storage, flash memory, magnetic disk or optical disk.
[0585] Of course, the computing device can also include other components, such as an input / output interface, a display component, a communication component, etc.
[0586] The input / output interface provides an interface between the processing component and the peripheral interface module, which can be an output device, an input device, etc.
[0587] The communication component is configured to facilitate wired or wireless communication between the computing device and other devices, etc.
[0588] The computing device can be a physical device or an elastic computing host provided by a cloud computing platform, and the computing device can be a cloud server, and the processing component, the storage component, etc. can be a basic server resource rented or purchased from the cloud computing platform.
[0589] The embodiment of the present application also provides a computer storage medium, which stores a computer program, and the computer program can implement the above Figure 1 An entity relationship extraction method for a financial field knowledge graph construction.
[0590] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described system, device and unit can refer to the corresponding process in the foregoing method embodiments, which will not be described here.
[0591] The device embodiments described above are merely illustrative, wherein the units described as separate components can or can not be physically separate, and the components displayed as units can or can not be physical units, i.e., can be located in one place, or can be distributed to multiple network units. Part or all of the modules can be selected to achieve the purposes of the embodiments according to actual needs. Those skilled in the art can understand and implement without creative labor.
[0592] Through the description of the above embodiments, those skilled in the art can clearly understand that the embodiments can be realized by means of software and necessary universal hardware platforms, and of course can also be realized by hardware. Based on such understanding, the above technical solutions can be embodied in the form of software products, and the computer software products can be stored in a computer readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and include a plurality of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in each embodiment or some parts of the embodiments.
[0593] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. An entity relationship extraction method for financial domain knowledge graph construction, characterized in that, The method comprises the following steps: obtaining original text data in the financial field; preprocessing the original text data, including word segmentation, stop word removal, and part-of-speech tagging, to obtain preprocessed text; performing entity recognition on the preprocessed text using a pre-trained natural language processing model to determine the entities and their entity types in the text; determining the dependency relationships between the entities using dependency syntax analysis technology; extracting potential relationships between the entities based on 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; adding relationships with scores higher than a preset threshold to a knowledge graph in the financial field; The scoring of 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 comprises: calculating the relationship frequency between each pair of entities, defined as: in, Representing entities Pointing to entity Relationship frequency, and They represent the first entity and the second entity in each pair of entities, This represents a relation instance in document i. Indicates a pointer function, in the document There are entities in Pointing to entity When specifying the dependency path, the value is 1; otherwise, it is 0. N represents the total number of documents. calculating the relationship strength between the entities based on the relationship frequency, defined as: ; wherein, represents the relationship strength of the entity and the entity calculated according to the relationship frequency, is a preset parameter, represents the relationship frequency of the entity to the entity .
2. The method of claim 1, wherein, The use of dependency syntax analysis technology to determine the dependency relationships between the entities comprises: applying a dependency syntax analysis algorithm to analyze the preprocessed text and obtain a dependency tree structure; determining the connection paths between the entities based on the dependency tree structure to extract direct or indirect relationships between the entities.
3. The method of claim 1, wherein, Further comprising: performing semantic similarity evaluation on the entity relationships in the relationship candidate set to filter out low-quality relationships; The semantic similarity evaluation comprises: calculating the semantic vectors of each pair of entities; calculating the similarity between the semantic vectors using cosine similarity, defined as: ; wherein, represents a similarity between the semantic vectors of the first and second entities, and respectively represent the semantic vectors of the first and second entities; filtering out the entity relationships in the relationship candidate set with a semantic similarity lower than a preset threshold.
4. The method of claim 1, wherein, The use of a pre-trained natural language processing model for entity recognition on the preprocessed text comprises: using a pre-trained natural language processing model for entity recognition; inputting the preprocessed text into the natural language processing model to obtain the boundary positions of the entities and their entity types.
5. The method according to any one of claims 1 to 4, characterized in that, Further comprising: using a deep learning model for secondary screening of the relationship candidate set to improve the accuracy of relationship extraction; The use of a deep learning model for secondary screening of the relationship candidate set comprises: constructing 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 context; 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; selecting the relationship category with the highest probability as the final prediction result.
6. The method of claim 5, wherein, Further comprising: 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: defining a set of reasoning rules R based on professional knowledge in the financial field; For each pair of entity relations , its logical consistency is verified using the set of inference rules R to determine a consistency score, wherein the consistency score is defined as: ; wherein, denotes the consistency score of a given entity pair , is the weight coefficient of rule r, where rule r belongs to a specific instance of the inference rule set R, is the applicability indicator of rule r applied to entity pair , taking values in the range 1 when rule is applicable to entity pair , otherwise 0. The scoring of 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 comprises: performing multi-dimension evaluation on each pair of entities and their relationship in the relationship candidate set, the multi-dimension evaluation comprising: defining a multi-dimension feature vector of the relationship, including relationship frequency, semantic similarity, consistency score; classifying the multi-dimension feature vector using a support vector machine to determine the relationship strength between entities, defined as: ; wherein, represents a multi-dimensional feature vector for each pair of entity relations, represents an estimate of the relation strength for each pair of entities (e1, e2) by the support vector machine, represents the number of training samples, is the relation class label for the i-th training sample, is the Lagrange multiplier corresponding to the i-th training sample, is the kernel function, is the multi-dimensional feature vector for the training sample, 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 comprises: 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 in the graph G , the weight of each pair of entities is computed , defined as: ; wherein, is a preset weight coefficient, S(e1, e2) denotes the relation strength of entities and calculated according to the relation frequency, is a consistency score of entities and , denotes the estimation of the relation strength of each pair of entities (e1, e2) by the support vector machine; updating the weight of an entity using a graph-based algorithm to optimize the graph structure; further comprising: performing uncertainty evaluation on each pair of entities and their relationship in the relationship candidate set to determine an uncertainty evaluation value of each pair of entities, wherein the uncertainty evaluation value is defined as: ; wherein, denotes the uncertainty assessment value for a given entity pair (e1, e2), is the i-th relation class, is the given entity pair the conditional probability of the relation when the relation is the prior probability of the relation n is the number of relation classes; wherein the performing uncertainty evaluation on each pair of entities and their relationship in the relationship candidate set further comprises: using mutual information to measure the degree of dependence between an entity pair and its relationship, the degree of dependence being defined as: ; wherein MI (e1, e2) represents mutual information, used to measure the degree of dependence between the entity pair (e1, e2) and its relationship R, R represents a set of relationship categories of the entity pair (e1, e2), and r represents a specific relationship in the relationship category R, P(r | e1, e2) represents the conditional probability of the relationship r when the given entity pair (e1, e2) is P(r) represents the prior probability of the relationship r. further comprising: performing joint evaluation on each pair of entities and their relationship in the relationship candidate set using a neural network model to determine a joint evaluation value, wherein the joint evaluation value is defined as: ; wherein, denotes the joint evaluation value for a given entity pair (e1, e2), NN is a neural network model whose output is a relation evaluation score for the entity pair , denotes the estimation of the relation strength for a given entity pair (e1, e2) by a support vector machine, denotes the consistency score for a given entity pair , denotes the uncertainty evaluation value for a given entity pair (e1, e2), MI( ) denotes the degree of dependence between a given entity pair (e1, e2) and its relation R.
7. An entity relation extraction system for financial domain knowledge graph construction, characterized in that, comprising: an acquisition module configured to acquire original text data in the financial field; a preprocessing module configured 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 pre-trained natural language processing model to determine entities and their entity types in the text; determine the dependency relationship between the entities using dependency syntax analysis technology; a construction module configured to extract potential relationships between entities according to the dependency relationship and construct a relationship candidate set; the determination module is further configured to score each pair of entities and their relationship in the relationship candidate set to determine the relationship strength between entities in the relationship candidate set; add relationships with a score higher than a preset threshold to the knowledge graph in the financial field; the scoring each pair of entities and their relationship in the relationship candidate set to determine the relationship strength between entities in the relationship candidate set comprises: calculating the relationship frequency between each pair of entities, the relationship frequency being defined as: ; in, Representing entities and entity Relationship frequency, and They represent the first entity and the second entity in each pair of entities, This represents a relation instance in document i. Indicates a pointer function, in the document There are entities in Pointing to entity When specifying the dependency path, the value is 1; otherwise, it is 0. N represents the total number of documents. calculating the relationship strength between entities according to the relationship frequency, the relationship strength being defined as: ; wherein S(e1, e2) represents the relationship strength between entities e1 and e2 calculated according to the relationship frequency and entities is a preset parameter, represents the relationship frequency between entities points to entities . 8. A computing device, comprising: comprise 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 realize the entity relationship extraction method for constructing a knowledge graph in the financial field according to any one of claims 1-6.
9. A computer storage medium, characterized in that a computer program is stored, and when the computer program is executed by a computer, the entity relationship extraction method for constructing a knowledge graph in the financial field according to any one of claims 1-6 is realized.
Citation Information
Patent Citations
Natural language semantic understanding method and device based on vertical domain knowledge graph
CN115033661A
Knowledge graph construction method based on course data
CN117787401A