Entity relation extraction method and system for music field
By automatically extracting entity relationships from music text using the BERT-BIGRU-ATTENTION model, the problem of the huge cost of manual annotation in the music field is solved, and efficient and accurate entity relationship extraction and knowledge graph construction are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANDONG NORMAL UNIV
- Filing Date
- 2023-03-14
- Publication Date
- 2026-06-05
AI Technical Summary
Existing technologies lack automatic and accurate methods for extracting entity relationships in the music field, resulting in huge consumption of human, material, and financial resources, and traditional methods are difficult to effectively construct music knowledge graphs.
The BERT-BIGRU-ATTENTION model is used for music text processing. Data is obtained through web crawling, entity types and relationship categories are predefined, and a deep learning model is used to automatically extract entity relationships from the music text and construct a knowledge graph.
This approach improves the accuracy and efficiency of music entity relation extraction while reducing human intervention, enriches the entity attributes of the knowledge graph, and reduces the difficulty of information acquisition.
Smart Images

Figure CN116257616B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of text entity relation extraction technology, and in particular to a method and system for entity relation extraction in the music field. Background Technology
[0002] The statements in this section merely refer to the background art related to this invention and do not necessarily constitute prior art.
[0003] With the explosive growth of information, it's difficult for people to find the information they truly need from the vast amount of data. Search engines emerged to address this need. However, because HTML web pages lack semantics and are difficult for computers to understand, they have significant shortcomings in search accuracy. Furthermore, as society shifts from an information-based to a knowledge-based model, computer applications rely heavily on subject-specific knowledge, and this is also true in the field of music. Therefore, how to quickly and accurately obtain the desired content from the massive amount of music information online is a topic worthy of research.
[0004] Music is an art form that uses organized sounds to create auditory imagery, expressing people's thoughts, feelings, and social realities. Knowledge graphs for the music field are widely used in music retrieval, personalized music recommendations, and intelligent question-answering systems in the music domain. Currently, with the continuous and vigorous development of the music industry, a large amount of music text data has been accumulated. This data contains a vast amount of music-related knowledge that is structurally complex and semantically rich. How to acquire and organize this knowledge, and how to provide intelligent information services based on this knowledge, are the problems that this invention aims to solve.
[0005] In the Chinese research environment, authoritative knowledge graphs for entity linking, ontology for music resource organization, and tools for music knowledge extraction and entity alignment are relatively lacking. There is still insufficient attention paid to the processing and fusion technologies of music domain data, especially music content data, and digital infrastructure support is inadequate, hindering effective research and practice in constructing music knowledge graphs. Furthermore, traditional relation extraction processes require expert annotation of raw text data, consuming significant human, material, and financial resources. The accuracy of text annotation directly affects the effectiveness of subsequent entity relation extraction. Manually extracting a certain type of binary relation from large amounts of natural text is extremely time-consuming and laborious, and manually extracting many different types of binary relations is impossible. Therefore, there is an urgent need to find a method that can automate relation extraction tasks to a large extent and accurately, and that can construct multi-relationships using binary relations. This is of great significance in helping people quickly and accurately obtain relations, thus saving time. Summary of the Invention
[0006] To address the shortcomings of existing technologies, this invention provides a method and system for entity relation extraction in the music domain. This invention primarily focuses on building a system for entity relation extraction in the open music domain. It acquires music text information through data mining, uses natural language processing to organize the information contained in the text, extracts relationships between entities in a music text through relation extraction, and constructs a music-oriented knowledge graph with entities as nodes and relationships as edges. This knowledge graph aggregates information and links from data resources into knowledge, making information resources easier to compute, understand, and evaluate, thereby providing open service capabilities.
[0007] In a first aspect, the present invention provides a method for entity relation extraction in the music field;
[0008] Entity relation extraction methods for the music domain include:
[0009] Get the text to be processed;
[0010] The text to be processed is filtered by sentence to obtain candidate sentences; the candidate sentences include at least two named music entities;
[0011] Noise reduction processing is performed on the candidate sentences;
[0012] The denoised candidate sentences are input into the trained entity relation extraction model, which outputs the music entity relations contained in the candidate sentences; wherein, the trained entity relation extraction model is trained using music text with labeled entity relations.
[0013] Secondly, this invention provides an entity relationship extraction system for the music field;
[0014] An entity relation extraction system for the music industry, including:
[0015] The acquisition module is configured to acquire the text to be processed.
[0016] The filtering module is configured to perform sentence filtering on the text to be processed to obtain candidate sentences; the candidate sentences include at least two music named entities.
[0017] The noise reduction module is configured to perform noise reduction processing on candidate sentences;
[0018] The output module is configured to: input the denoised candidate sentences into the trained entity relation extraction model, and output the music entity relations contained in the candidate sentences; wherein, the trained entity relation extraction model is trained using music text with labeled entity relations.
[0019] Thirdly, the present invention also provides an electronic device, comprising:
[0020] Memory, used for non-transitory storage of computer-readable instructions; and
[0021] Processor, for executing the computer-readable instructions,
[0022] When the computer-readable instructions are executed by the processor, they perform the method described in the first aspect above.
[0023] Fourthly, the present invention also provides a storage medium for non-transitory storage of computer-readable instructions, wherein, when the non-transitory computer-readable instructions are executed by a computer, the instructions for executing the method described in the first aspect are executed.
[0024] Fifthly, the present invention also provides a computer program product, including a computer program that, when run on one or more processors, is used to implement the method described in the first aspect above.
[0025] Compared with the prior art, the beneficial effects of the present invention are:
[0026] This invention proposes a relation extraction system for entities in the open music domain, which can be well used for knowledge graph construction. The music entity relation extraction is based on the BERT-BIGRU-ATTENTION model. Since most current relation extraction research is based on existing publicly available datasets, this invention requires the construction of a music-specific dataset. Relevant music data is collected through web scraping and manual collection, processed, and stored in a specific format to become the dataset used for training the subsequent relation extraction model. This invention predefines the relation categories between music entities for subsequent music entity relation prediction. After relation extraction, this invention can obtain the relationships between entity pairs involved in a piece of music text, storing them in the Neo4j graph database in the form of nodes and edges. Nodes represent entities involved in the music text, and edge values represent the relationships between entities, thus completing the construction of a music knowledge graph.
[0027] The proposed music entity relation extraction model in this invention is BERT-BIGRU-ATTENTION. It uses BERT (Bidirectional Encoder Representation from Transformers), the most popular pre-trained model in the field of Natural Language Processing (NLP) in recent years, instead of the previously commonly used word2vec. Applying BERT to the model's embedding layer generates dynamic word vectors that better express the semantics of the text. Simultaneously, GRU (Gated Recurrent Unit) is used instead of LSTM (Long Short-Term Memory) to extract temporal features from the music text, shortening the model training time and improving experimental results. This allows for better identification of the music entities involved in a text and the relationships between them, obtaining the triples required by this invention.
[0028] When predefining music entity types, this invention defines eight entities, covering most entities in the music domain, and also defines 13 relation categories, roughly encompassing the relation categories involved in music entities. Therefore, it can greatly enrich the attributes of entities in the knowledge graph, making it more suitable for practical applications.
[0029] The proposed deep learning-based automatic relation extraction system can automatically extract relations from text while minimizing human intervention. It involves human intervention to create accurate and effective ontologies, label a small amount of data, and train a deep learning model using data augmentation techniques. The model then processes both labeled and unlabeled data. Finally, manual verification is performed, minimizing human intervention while ensuring labeling accuracy. Experimental results show that the method significantly reduces human intervention in information acquisition while improving the accuracy of the acquired information. Attached Figure Description
[0030] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.
[0031] Figure 1 A flowchart for constructing the music knowledge graph in Implementation Example 1;
[0032] Figure 2 This is a framework diagram of the entity relationship extraction model in Example 1;
[0033] Figure 3 This is a flowchart of the music entity relationship extraction process in Example 1;
[0034] Figure 4 This is a schematic diagram of candidate sentences for Example 1;
[0035] Figure 5 This is a schematic diagram illustrating the changes in the dimension of the model training vectors in Example 1;
[0036] Figure 6 The musical entity relationship is shown in Example 1;
[0037] Figure 7 This is a partial display of the music knowledge graph from Example 1. Detailed Implementation
[0038] It should be noted that the following detailed descriptions are exemplary and intended to provide further illustration of the invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.
[0039] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments of the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. Furthermore, it should be understood that the terms “comprising” and “having”, and any variations thereof, are intended to cover non-exclusive inclusion, for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0040] Where there is no conflict, the embodiments and features in the embodiments of the present invention can be combined with each other.
[0041] All data acquisition in this embodiment is carried out in accordance with laws and regulations and with user consent, and the data is used legally.
[0042] To address the aforementioned problems, information extraction (IE) technology has emerged. This technology extracts specific types of entity, relationship, and event information from natural language text and outputs it as structured data. In the music field, information extraction technology identifies entities and relationships within the music industry from a news report. For example, in a news report about a singer releasing an album, this invention needs to identify possible entities such as the singer, album, release date, and songs. After identifying these entities, it then extracts possible relationships between them, such as lyricist, composer, and release date. Information extraction is also a crucial step in knowledge graph construction, refining and processing entities existing in data (numbers, text, images, etc.) that reflect the objective world, establishing connections between these entities to form knowledge.
[0043] Information extraction mainly comprises three subtasks: named entity recognition, relation extraction, and event extraction. Named entity recognition is used to identify entities in text; relation extraction identifies relationships between entities in text; and event extraction identifies and extracts event information from text describing events and presents it in a structured form, including the time, place, participating roles, and related actions or state changes.
[0044] This invention focuses on extracting relationships between musical entities. It involves inputting predefined entities and then classifying the relationships between them.
[0045] The development of relation extraction has gone through three stages.
[0046] The first stage is the pattern extraction model, which uses text analysis tools to analyze the corpus and then automatically constructs pattern rules. These rules can then be used to extract new relationships from new corpora.
[0047] Errors are inevitable in the process of automating the construction of patterns, thus requiring correction by human experts, which is expensive. This is the main limitation of pattern matching-based methods.
[0048] The second stage: Statistical Relation Extraction Models. Statistical methods offer wider coverage and require less human intervention, making Statistical Relation Extraction (SRE) extremely popular. It primarily utilizes traditional machine learning methods, such as SVM and Bayesian algorithms; additionally, there are graph methods that represent the dependencies between entities, text, and relationships using graphs to obtain accurate inter-entity relationships.
[0049] Traditional machine learning methods also rely on experts to annotate large-scale data. In addition, traditional natural language processing models also rely on the important features and feature combinations required for manually designing the model, which requires a huge amount of manpower and time.
[0050] The third stage: Neural Relation Extraction Models. Benefiting from the rapid development of deep learning in recent years, it offers a possible solution to the aforementioned problems, effectively promoting the development of natural language processing. Deep learning uses a multi-layered, non-linear neural network structure to abstract and learn data representations.
[0051] Neural network-based models can capture more semantic information from text, thus possessing stronger extraction capabilities. Different research on NRE mainly focuses on designing and using different network architectures to extract semantic information from text, such as RNNs, CNNs, GNNs, and attention-based neural networks. In recent years, SRE based on Transformers and pre-trained models has achieved even better results.
[0052] For most applications, simply identifying entities within a text is insufficient; this invention also requires extracting the relationships between them. For example, in the text "Silence is Golden is a Cantonese song composed by Leslie Cheung and with lyrics by Sam Hui," this invention identifies the entities as the song "Silence is Golden," and the individuals Leslie Cheung and Sam Hui. Furthermore, "Silence is Golden" and Leslie Cheung form a compositional relationship, while "Silence is Golden" and Sam Hui form a lyricist relationship.
[0053] The relationships between entities extracted in this invention can be used to construct music knowledge graphs, vertical domain search engines, etc. By building a relationship extraction system oriented towards the music domain, the difficulty for people to quickly obtain music information can be reduced.
[0054] Example 1
[0055] This embodiment provides a method for entity relation extraction in the music field;
[0056] like Figure 1 As shown, the entity relation extraction method for the music domain includes:
[0057] S101: Obtain the text to be processed;
[0058] S102: Filter the text to be processed by sentence to obtain candidate sentences; the candidate sentences include at least two music named entities;
[0059] S103: Perform noise reduction processing on the candidate sentences;
[0060] S104: Input the denoised candidate sentences into the trained entity relation extraction model and output the music entity relations contained in the candidate sentences; wherein, the trained entity relation extraction model is trained using music text with labeled entity relations.
[0061] Further, in step S101: the text to be processed is obtained by using a web crawler.
[0062] For example, web crawlers are used to obtain music corpora. The sources of these corpora include artist profiles from music software such as QQ Music and NetEase Cloud Music, unstructured text containing information about artists, music, and albums from Baidu Encyclopedia pages, and music news from music channels on news websites such as Sohu and Sina. This invention obtains raw music corpora by crawling relevant pages and simultaneously collecting them manually.
[0063] Furthermore, such as Figure 4 As shown, step S102: filtering the text to be processed to obtain candidate sentences specifically includes:
[0064] S102-1: Perform sentence segmentation, word segmentation, and part-of-speech tagging on the text to be processed;
[0065] S102-2: Filter the obtained sentences, retain sentences containing at least two music named entities, and delete the remaining sentences.
[0066] Further, step S103: Noise reduction processing is performed on the candidate sentences, specifically including:
[0067] For candidate sentences, remove stop words, special symbols, and spaces.
[0068] Furthermore, such as Figure 2 As shown, step S104: The denoised candidate sentences are input into the trained entity relation extraction model, and the music entity relations contained in the candidate sentences are output. The entity relation extraction model includes:
[0069] The layers are connected in sequence: word embedding layer, neural network layer, attention mechanism layer, and output layer.
[0070] Furthermore, such as Figure 3 As shown, step S104 involves inputting the denoised candidate sentences into the trained entity relation extraction model and outputting the music entity relations contained in the candidate sentences. The trained entity relation extraction model's operation includes:
[0071] The denoised candidate sentences are input into the BERT model with word embedding layer, which encodes the input candidate sentences to generate word vectors.
[0072] The BiGRU model with neural network layers processes word vectors to obtain text representations with temporal information;
[0073] The attention mechanism layer calculates the correlation between the text representation and the relation category in the sequence through key-value pairs to obtain the attention weight. The attention weight is then used to perform a weighted summation on the text representation with temporal information to obtain the sentence-level text representation.
[0074] The output layer classifies the sentence-level text representations using a classifier, and outputs the final music entity relationship categories.
[0075] For example, the candidate sentence after noise reduction is a piece of music text containing entity pairs.
[0076] For example, the word embedding layer uses a BERT pre-trained model to encode the input text to generate dynamic word vectors, fully utilizing the positional information of entity pairs to improve the understanding of vocabulary and text semantics. Compared to other models, the BERT model can more fully mine the semantic information in the text, consider contextual relationships, and effectively solve the problem of polysemy.
[0077] For example, the neural network layer chooses to use a bidirectional GRU model to generate text representations with temporal information.
[0078] For example, the attention mechanism layer calculates the relevance between words and relation categories in the sequence using key-value pairs and uses this relevance as attention weights. The hidden states generated by the network layer are then weighted and summed using these attention weights to obtain a sentence-level text representation.
[0079] For example, the output layer is a softmax classifier connected to a fully connected layer, which performs multi-classification using the softmax function.
[0080] For example, BERT, a pre-trained language representation model proposed by Google in 2018, revolutionized NLP. It emphasizes a departure from traditional unidirectional language models or shallow concatenation of two unidirectional language models for pre-training; instead, it employs a novel masked language model (MLM) to generate deep, bidirectional language representations. After using BERT pre-trained models, NLP tasks achieved new state-of-the-art results.
[0081] Training a standalone BERT model would be extremely time-consuming and resource-intensive; therefore, this invention uses an open-source BERT model in its experiments. This invention replaces the previously released Google model with the open-source Chinese-based BERT-WWM-EXT model from the Harbin Institute of Technology-iFlytek Lab, improving the experimental results. WWM stands for Whole Word Masking, and WWM-EXT increases the training set size and training steps compared to WWM. The improvement over BERT-Base-Chinese is that it replaces a complete word with a masked label instead of a single character. Unlike English, where the smallest token is a word, in Chinese, the smallest token is a character. A word is composed of one or more characters, and there are no clear divisions between words; words contain more information. Therefore, whole-word masking involves masking the entire word.
[0082] Table 1. Example of WWM description
[0083]
[0084] BERT employs a deep transformer architecture, which can train the context of all layers of the model together, allowing word vectors to be dynamically adjusted according to the text context. Therefore, the same word has different word embeddings in different contexts, which can solve the problem of polysemy. It can adapt to most natural language processing tasks with only minor adjustments.
[0085] The original input to the BERT model is a text segment s = [w1, w2, ..., w m The output is e = [x1, x2, ... x]. n ], w t x represents the t-th word in the input text. t The word embedding representation of the t-th word has a dimension of 128*768 for the text output vector.
[0086] For example, after obtaining the word vector representation of the text, the word vector matrix is used to obtain the temporal features of the text through a BiGRU neural network.
[0087] The GRU gated recurrent unit is a highly effective variant of LSTM that combines the forget gate and output gate in LSTM into a single update gate, which mixes the cell state and the hidden state.
[0088] Both LSTM and GRU use various gate functions to preserve important features of text sequences, ensuring that important information is not lost when processing long text sequences. Compared with LSTM, GRU has a simpler structure.
[0089] xt represents the input at time t, h t-1 This represents the state of the hidden layer at time t-1, which contains information about the previous nodes.
[0090] `zt` and `rt` represent the update gate and reset gate, respectively. The update gate controls the extent to which information from the previous state is incorporated into the current state; a larger update gate value indicates that more information from the previous state is incorporated. The reset gate controls how much information from the previous state is written into the current candidate set. The smaller the reset gate, the less information from the previous state is written.
[0091] r t =σ(W r ·[h t-1 ,x t (1)
[0092] z t =σ(W z ·[h t-1 ,x t (2)
[0093]
[0094]
[0095] σ is the sigmoid activation function, which can transform data into values in the range of 0-1, thus acting as a gating signal. The tanh function transforms data into values from -1 to 1.
[0096] Similarly, this invention uses BiGRU to process the sequence in both sequential and reverse order in the time dimension, and concatenates the output of GRU at each time step into the final output, thus ensuring that the context information of future moments is not ignored.
[0097] After BiGRU encoding, this invention obtains the feature matrix G = [h1, h2, ... h t ], where h t Let t be the hidden state of the t-th word.
[0098] For example, regarding the attention mechanism layer, the attention mechanism in deep learning is inspired by the attention mechanism of human vision. That is, human vision quickly scans the global image to obtain the target area that needs to be focused on, and then devotes more attention resources to this area to obtain more detailed information about the target that needs to be focused on, while suppressing other useless information.
[0099] This invention defines an attention mechanism layer that assigns weights to information in the text in order to increase the relevance of keywords in the text.
[0100] It mainly consists of four steps:
[0101] (1) Initialize the weight matrix w, then perform dot product and normalization on G and W to obtain the matrix. It represents the weight corresponding to each word, and the weight ratio represents the degree of relevance contributed to the extraction of text relations;
[0102] (2) Define a learnable function f to score the words of the input text function (similarity calculation);
[0103] (3) Normalize the scoring results to obtain the weight of each word;
[0104] (4) Perform a weighted summation on each word to obtain the final sentence feature representation r.
[0105] e t =f(h) t (5)
[0106]
[0107]
[0108] For example, regarding the output layer, the final sentence representation *r* obtained in this invention is passed through a fully connected layer, and the softmax function is used to extract relations. Because the experiment involves classifying multiple relations, this invention uses the CCE (Categorical Cross Entropy) loss function.
[0109] A predefined set of relations, s, contains 13 relation types. For predefined relationship labels.
[0110] The input is the final sentence representation r output by the attention mechanism layer, and the output is the relation category γ with the highest probability distribution. t .
[0111]
[0112]
[0113] Among them, w c ,b c These are the weights and biases, which are continuously learned during model training.
[0114] To obtain the best experimental results, this invention conducted multiple experiments, comparing the results obtained with different parameter values, and determined the final experimental parameters, as shown in Table 2.
[0115] Table 2 Experimental parameter settings
[0116] Epoch 30 Batch_size 16 Dropout 0.2 Learning__rate 3e-5 Word Embedding_dimension 768
[0117] Furthermore, the features extracted by the model include entity pairs, entity location sequence representations, text, and relation categories.
[0118] Further, in S104: the denoised candidate sentences are input into the trained entity relation extraction model, and the music entity relations contained in the candidate sentences are output. The training process of the trained entity relation extraction model includes:
[0119] S104-1: Construct the dataset and divide it into training and test sets according to a set ratio;
[0120] S104-2: Input the training set into the temporal relation extraction model and train the model. When the loss function value of the model no longer decreases, or when the number of training iterations exceeds the set number, stop training and obtain the preliminary trained entity relation extraction model.
[0121] S104-3: The entity relationship extraction model after initial training is then tested using a test set. If the accuracy of the test exceeds the set threshold, the trained entity relationship extraction model is obtained. If the accuracy of the test is lower than the set threshold, the training set is changed and the model is trained again.
[0122] Furthermore, the construction of the dataset specifically includes:
[0123] S104-11: Perform sentence segmentation, word segmentation, and part-of-speech tagging on the corpus; filter the obtained sentences, retain sentences containing at least two music named entities as candidate sentences, and delete the remaining sentences; perform noise reduction on the candidate sentences;
[0124] S104-12: Define the types of music entities and the categories of music entity relationships, and generate label index numbers for music entity relationship categories;
[0125] S104-13: Create a dataset in the music field.
[0126] Furthermore, the noise reduction process for the candidate sentences includes: removing stop words, deleting useless tags, removing special symbols and spaces.
[0127] Exemplarily, the noise reduction processing of the candidate sentences includes: removing stop words that have no practical meaning in the text; deleting useless tags in the sentences; removing special symbols and extra spaces that appear in the text; the extraction of entity relationships is limited within a single sentence, and relationships beyond the sentence scope are not processed; entity relationships that appear in the sentence need to be explicitly or directly expressed; merging words with referential relationships.
[0128] The beneficial effects of the above technical solution are: for the sentences obtained after clause separation, not all sentences can meet the requirements of the experiments of the present invention. Therefore, the present invention needs to filter the obtained sentences and only retain those sentences that may contain music entity relationships, and these sentences are called candidate sentences. The method for obtaining candidate sentences is based on the definition of entity relationships in the present invention. A candidate sentence needs to contain at least two music named entities that may have relationships with each other.
[0129] The beneficial effects of the above technical solution also include: the original music corpus obtained through web crawlers usually contains noise and has non-standard text expressions. Therefore, the present invention needs to process the original music text to reduce the noise contained therein and reduce the experimental errors accumulated due to the accuracy of the data set.
[0130] Further, S104-12: Define the types of music entities and the categories of music entity relationships. Among them, the types of music entities include: person, music, album, film and television, institution, time, game, and alias.
[0131] The person includes: singer, group, band, lyricist, composer, arranger; the music refers to Chinese songs; the album refers to music albums; the film and television refers to movies, TV dramas, and animations; the institution refers to record companies; the time refers to the release time of songs or albums; the game refers to mobile games or online games; the alias refers to the nicknames, aliases, and English names of people.
[0132] Exemplarily, usually there may be more than one or two entity types in a piece of text, and there may be three or more different entities. For example, the text: "My Heart Is an Open Book" is written and composed by Li Zongsheng, sung by Jackie Chan and Chen Shuhua, and included in Jackie Chan's album "The First Time" in 1993. The entity types involved in the text include people, music, and albums.
[0133] Further, S104-12: Define the types of music entities and the categories of music entity relationships. Among them, the categories of music entity relationships include:
[0134] Alternative title, lyrics, composition, arrangement, artist-song, artist-album, song-album, incidental music, record company, collaboration, other information, album-release date, song-release date;
[0135] Here, "alias" refers to a singer's nickname or alias; "lyricist" refers to a lyricist who writes lyrics for a song; "composer" refers to a composer who composes music for a song; "artist-song" indicates that a song belongs to a particular singer or group; "artist-album" indicates that an album belongs to a particular singer or group; and "song-album" indicates that the current song is a song from an album.
[0136] The term "interlude" refers to a song that is the theme song, ending song, or interlude of a film or television work; "record company" refers to a record company to which a singer or group is signed; "collaboration" refers to two people jointly creating or singing a song, or participating in the same film or television work; "other situations" refers to situations where the relationship between the two entities involved in the text is unknown or does not exist; "album-release time" refers to the release time of a certain album; "song-release time" refers to the release time of a certain song.
[0137] It should be understood that the same relationship may have multiple expressions. For example, the common expressions for the lyric-writing relationship include lyric writing, lyric filling, writing down, and lyricist, etc. As long as it can express the predefined relationship type, it can be used as related relationship text.
[0138] Further, S104-12: generating tag index numbers for music entity relationship categories, specifically including:
[0139] The relationship category tag index number is as follows: Artist-Song Relationship Category Tag Index Number 0, Lyricist Relationship Category Tag Index Number 1, Composer Relationship Category Tag Index Number 2, Arranger Relationship Category Tag Index Number 3, Song-Album Relationship Category Tag Index Number 4, Artist-Album Relationship Category Tag Index Number 5, Collaboration Relationship Category Tag Index Number 6, Interlude Relationship Category Tag Index Number 7, Other Relationship Category Tag Index Number 8, Alias Relationship Category Tag Index Number 9, Album Release Date Relationship Category Tag Index Number 10, Song Release Date Relationship Category Tag Index Number 11, Record Company Relationship Category Tag Index Number 12.
[0140] For example, a corresponding number of tag indexes are generated based on the predefined number of relationships, corresponding index IDs are generated based on the relationship types involved in the text, categorical variables are generated, and stored in a JSON file.
[0141] Furthermore, S104-13: forming a dataset in the music domain, specifically includes:
[0142] S104-131: Set the maximum value for text length. Text lengths below the maximum value are filled with zeros to ensure consistent text length. For text lengths above the maximum value, the excess parts are removed to ensure consistent text length.
[0143] S104-132: Store according to a set format, wherein the set format includes: sentence number, entity pair, entity pair relationship category, and text containing entity pairs;
[0144] For example, S104-13: forming a dataset in the music domain, specifically includes:
[0145] The maximum text length is set to 128. For text shorter than 128 characters, zero padding is used to ensure consistent length; for text longer than 128 characters, the excess portion is truncated. This ensures consistency in the text dimension of the input model.
[0146] The data is stored in a specific format, which consists of the input sentence number, entity pairs, relation categories, and text containing entity pairs.
[0147] When multiple pairs of entities and relationships appear in a text, this invention classifies each pair of entities and relationships to minimize experimental error.
[0148] Furthermore, in S104-2: before inputting the training set into the temporal relation extraction model, the music entity pairs and the original text are combined, the entity pairs are connected by $, and the entities involved in the original text are replaced with the special character #.
[0149] For example, Jay Chou's "Rice Fragrance" healed the hearts of countless people that summer.
[0150] During the model testing phase, the experimental results obtained from the predictions will be stored in neo4j as edges in the form of triples, making it convenient for users to query the relationship between two entities.
[0151] During the testing phase of the model, the present invention takes a text containing music entity pairs as input, and after being processed by the softmax function, outputs the relation category with the highest probability in the predefined relation set.
[0152] For example, given the entity pair "All the Way North" is Jay Chou's most successful pop love song with a Britpop style, and it's an insert song from Initial D, the model will output the relationship category "Artist-Song" for the input entity pair "All the Way North Initial D," and will output "Insert Song" for the input entity pair "All the Way North Initial D." This invention stores the obtained music triples in neo4j to complete the construction of a music knowledge graph.
[0153] Furthermore, after the music entity relation contained in the output candidate sentence, it also includes:
[0154] Construct a music knowledge graph based on music entity relationships;
[0155] This system utilizes a music knowledge graph to provide music knowledge Q&A and music search result recommendations.
[0156] Relation extraction (RE), a subtask of information extraction (IE), is primarily responsible for identifying entities from text and extracting semantic relationships between them. Relation extraction typically takes the form of triples: <entity, relation, entity>. Relation extraction can support downstream tasks such as automatic knowledge graph construction, search engines, and question answering. Its applications are also very broad, encompassing finance, biomedicine, risk control, social networking, and more. This invention applies it to the construction of a music knowledge graph.
[0157] Regarding the choice of programming language, this invention uses Python, the mainstream language for deep learning, and proposes a deep learning model based on BERT-BIGRU-ATTENTION.
[0158] Table 3 Model Module Description
[0159]
[0160]
[0161] To evaluate the quality of a model, this invention typically uses certain metrics. Since the model proposed in this invention is a deep learning model, the evaluation metrics chosen are the traditional Accuracy, Precision, Recall, and F1 score.
[0162] For multi-class classification problems, this invention typically transforms them into multiple binary classification problems, and then comprehensively examines the evaluation indicators on n binary confusion matrices. In the experiment, this invention selects the macro-averaging as the experimental result, that is, first statistically calculating the indicator value for each class, and then calculating the arithmetic mean for all classes.
[0163]
[0164]
[0165]
[0166]
[0167]
[0168] Where i represents the type of relation, L represents the number of relation types, and TP i For positive samples where relation category i is predicted to be positive, FP i For negative samples where relation category i is predicted to be positive, FN i For positive samples where relation category i is predicted to be negative, Precision i Recall i Let $\mathbf$ be the precision and recall of relation class $i$, and $\mathbf$ be the macro average of the precision, recall and F1 value of relation class $i$, respectively.
[0169] Using macro-average values as experimental results can reduce some errors caused by uneven dataset size and the uneven distribution of relation categories. Table 7 shows the P, R, and F1 scores obtained for each relation category during model testing.
[0170] Table 7 Experimental Results of Model Testing Relationship Categories
[0171]
[0172]
[0173] The input entities and the relation categories obtained through the relation extraction system are stored in the Neo4j database as nodes and edges. At the same time, the Cypher language is used to add, delete, query, and modify the nodes and relations in the knowledge graph. Figure 5 This is a schematic diagram illustrating the changes in the dimension of the model training vectors in Example 1; Figure 6 The musical entity relationship is shown in Example 1; Figure 7 This is a partial display of the music knowledge graph from Example 1.
[0174] The music entity relation extraction system based on deep learning proposed in this invention starts with music knowledge data, obtains raw data, processes the data to generate a dataset used for model training, and then proposes its own scheme for training. By inputting entity pairs and music text, it obtains the relations between entities and finally generates knowledge triples.
[0175] The model, centered on BERT-BIGRU-ATTENTION, improves the efficiency of extracting musical entities and relationships between entities from text corpora. First, the BERT model is used to transform the musical text into word vectors that computers can understand, extracting features contained in the text. BIGRU is used to extract temporal features of the text, obtaining the hidden states. The ATTENTION mechanism enhances the influence of keywords in the text, and finally, the relationships are output.
[0176] The automatic music entity relationship extraction system proposed in this invention lowers the barrier to music knowledge graph construction to a certain extent, helping people quickly obtain the relationships between entity pairs in music text. For the ever-increasing amount of music news information online, it performs in-depth mining on a large amount of semi-structured and unstructured text in the music field, extracting valuable information and transforming it into structured data. This provides users with accurate and comprehensive music search results, allowing them to have a more precise understanding of the content they are interested in.
[0177] Example 2
[0178] This embodiment provides an entity relationship extraction system for the music industry;
[0179] An entity relation extraction system for the music industry, including:
[0180] The acquisition module is configured to acquire the text to be processed.
[0181] The filtering module is configured to perform sentence filtering on the text to be processed to obtain candidate sentences; the candidate sentences include at least two music named entities.
[0182] The noise reduction module is configured to perform noise reduction processing on candidate sentences;
[0183] The output module is configured to: input the denoised candidate sentences into the trained entity relation extraction model, and output the music entity relations contained in the candidate sentences; wherein, the trained entity relation extraction model is trained using music text with labeled entity relations.
[0184] It should be noted that the acquisition module, filtering module, noise reduction module, and output module described above correspond to steps S101 to S104 in Embodiment 1. The examples and application scenarios implemented by these modules and their corresponding steps are the same, but they are not limited to the content disclosed in Embodiment 1. It should also be noted that these modules, as part of the system, can be executed in a computer system, such as a set of computer-executable instructions.
[0185] The descriptions of each embodiment in the above embodiments have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0186] The proposed system can be implemented in other ways. For example, the system embodiments described above are merely illustrative, and the division of modules described above is only a logical functional division. In actual implementation, there may be other division methods. For example, multiple modules may be combined or integrated into another system, or some features may be ignored or not executed.
[0187] Example 3 This example also provides an electronic device, including: one or more processors, one or more memories, and one or more computer programs; wherein, the processor is connected to the memory, and the one or more computer programs are stored in the memory. When the electronic device is running, the processor executes the one or more computer programs stored in the memory to cause the electronic device to perform the method described in Example 1.
[0188] Example 4 This example also provides a computer-readable storage medium for storing computer instructions, which, when executed by a processor, complete the method described in Example 1.
[0189] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for entity relation extraction in the music domain, characterized by: include: Get the text to be processed; The text to be processed is filtered by sentences to obtain candidate sentences; The candidate sentences include at least two named music entities; Noise reduction processing is performed on the candidate sentences; The denoised candidate sentences are input into the trained entity relation extraction model, which outputs the music entity relations contained in the candidate sentences. The entity relation extraction model includes: a word embedding layer, a neural network layer, an attention mechanism layer, and an output layer connected in sequence. The trained entity relation extraction model is obtained by training on music text with labeled entity relations, and its operation includes: The denoised candidate sentences are input into the BERT model with word embedding layer, which encodes the input candidate sentences to generate word vectors. The BiGRU model with neural network layers processes word vectors to obtain text representations with temporal information; The attention mechanism layer calculates the correlation between the text representation and the relation category in the sequence through key-value pairs to obtain the attention weight. The attention weight is then used to perform a weighted summation on the text representation with temporal information to obtain the sentence-level text representation. Define an attention mechanism layer to assign weights to information in the text, thereby increasing the relevance of keywords in the text. This involves four steps: Initialize the weight matrix Then to and Perform dot product and normalization to obtain the matrix. It represents the weight corresponding to each word, and the weight ratio represents the degree of relevance contributed to the extraction of text relations. Define a learnable function This is used to score the words in the input text function, using similarity calculation; The scoring results are normalized to obtain the weight of each word; The final sentence feature representation is obtained by weighted summation of each word. ; ; After BiGRU encoding, the feature matrix is obtained. ;in, For the first The hidden state of each word; The output layer classifies the sentence-level text representations using a classifier, and outputs the final music entity relationship categories.
2. The entity relation extraction method for the music domain as described in claim 1, characterized in that, The text to be processed is filtered into sentences to obtain candidate sentences. Specifically, this includes: segmenting the text into sentences, words, and parts-of-speech tagging; filtering the obtained sentences, retaining sentences containing at least two music named entities, and deleting the remaining sentences; and performing noise reduction on the candidate sentences, specifically including: removing stop words, deleting special symbols, and removing spaces from the candidate sentences.
3. The entity relation extraction method for the music domain as described in claim 1, characterized in that, The denoised candidate sentences are input into the trained entity relation extraction model, which outputs the music entity relations contained in the candidate sentences. The training process of the trained entity relation extraction model includes: Build a dataset and divide it into a training set and a test set according to a set ratio; The training set is input into the temporal relation extraction model to train the model. When the loss function value of the model no longer decreases, or when the number of training iterations exceeds the set number, the training is stopped, and the preliminary trained entity relation extraction model is obtained. The initial trained entity relation extraction model is then tested using a test set. If the accuracy of the test exceeds a set threshold, the trained entity relation extraction model is obtained. If the accuracy of the test is lower than the set threshold, the training set is changed, and the model is trained again.
4. The entity relation extraction method for the music domain as described in claim 3, characterized in that, The construction of the dataset specifically includes: The corpus is processed by sentence segmentation, word segmentation, and part-of-speech tagging; the obtained sentences are filtered, and sentences containing at least two music named entities are retained as candidate sentences, while the remaining sentences are deleted; the candidate sentences are then subjected to noise reduction processing. Define the types of music entities and the categories of music entity relationships, and generate label index numbers for music entity relationship categories; To create a dataset in the field of music.
5. The entity relation extraction method for the music domain as described in claim 4, characterized in that, Define the types of music entities and the categories of music entity relationships, wherein the types of music entities include: people, music, albums, films, organizations, time, games, and aliases; The individuals mentioned include: singers, groups, bands, lyricists, composers, and arrangers; the music mentioned refers to Chinese songs; the album mentioned refers to music albums; the film and television mentioned refers to movies, TV series, and animations; the organization mentioned refers to record companies; the time mentioned refers to the release date of the song or album; the game mentioned refers to mobile games or online games; the alias mentioned refers to the individual's nickname, alias, and English name. Define the types of music entities and the categories of music entity relationships, wherein the categories of music entity relationships include: Alternative title, lyrics, composition, arrangement, artist-song, artist-album, song-album, incidental music, record company, collaboration, other information, album-release date, song-release date; Here, "alias" refers to a singer's nickname or alias; "lyricist" refers to a lyricist who writes lyrics for a song; "composer" refers to a composer who composes music for a song; "artist-song" indicates that a song belongs to a particular singer or group; "artist-album" indicates that an album belongs to a particular singer or group; and "song-album" indicates that the current song is a song from an album. The term "interlude" refers to a song that is the theme song, ending song, or interlude of a film or television work; "record company" refers to a record company to which a singer or group is signed; "collaboration" refers to two people jointly creating or singing a song, or participating in the same film or television work; "other situations" refers to situations where the relationship between the two entities mentioned in the text is unknown or does not exist; "album-release date" refers to the release date of a certain album; "song-release date" refers to the release date of a certain song. Generate tag index numbers for music entity relationship categories, specifically including: The relationship category tag index number is as follows: Artist-Song Relationship Category Tag Index Number 0, Lyricist Relationship Category Tag Index Number 1, Composer Relationship Category Tag Index Number 2, Arranger Relationship Category Tag Index Number 3, Song-Album Relationship Category Tag Index Number 4, Artist-Album Relationship Category Tag Index Number 5, Collaboration Relationship Category Tag Index Number 6, Interlude Relationship Category Tag Index Number 7, Other Relationship Category Tag Index Number 8, Alias Relationship Category Tag Index Number 9, Album Release Date Relationship Category Tag Index Number 10, Song Release Date Relationship Category Tag Index Number 11, and Record Company Relationship Category Tag Index Number 12. Following the music entity relationships contained in the output candidate sentences, the process also includes: constructing a music knowledge graph based on the music entity relationships; and implementing music knowledge question answering and music search result recommendation based on the music knowledge graph.
6. An entity relation extraction system for the music domain, characterized by: include: The acquisition module is configured to acquire the text to be processed. The filtering module is configured to perform sentence filtering on the text to be processed to obtain candidate sentences; the candidate sentences include at least two music named entities. The noise reduction module is configured to perform noise reduction processing on candidate sentences; The output module is configured to: input the denoised candidate sentences into the trained entity relation extraction model, and output the music entity relations contained in the candidate sentences. The entity relation extraction model includes: a word embedding layer, a neural network layer, an attention mechanism layer, and an output layer connected in sequence. The trained entity relation extraction model is obtained by training on music text with labeled entity relations, and its operation includes: The denoised candidate sentences are input into the BERT model with word embedding layer, which encodes the input candidate sentences to generate word vectors. The BiGRU model with neural network layers processes word vectors to obtain text representations with temporal information; The attention mechanism layer calculates the correlation between the text representation and the relation category in the sequence through key-value pairs to obtain the attention weight. The attention weight is then used to perform a weighted summation on the text representation with temporal information to obtain the sentence-level text representation. Define an attention mechanism layer to assign weights to information in the text, thereby increasing the relevance of keywords in the text. This involves four steps: Initialize the weight matrix Then to and Perform dot product and normalization to obtain the matrix. It represents the weight corresponding to each word, and the weight ratio represents the degree of relevance contributed to the extraction of text relations. Define a learnable function This is used to score the words in the input text function, using similarity calculation; The scoring results are normalized to obtain the weight of each word; The final sentence feature representation is obtained by weighted summation of each word. ; ; After BiGRU encoding, the feature matrix is obtained. ;in, For the first The hidden state of each word; The output layer classifies the sentence-level text representations using a classifier, and outputs the final music entity relationship categories.
7. An electronic device, characterized in that it comprises: Memory is used to store computer-readable instructions in a non-transitory manner. as well as Processor, for executing the computer-readable instructions, When the computer-readable instructions are executed by the processor, they perform the method described in any one of claims 1-5.
8. A storage medium, characterized in that, The computer-readable instructions are stored non-transitory, wherein when the non-transitory computer-readable instructions are executed by a computer, the instructions of the method according to any one of claims 1-5 are executed.