Word vector increment method, electronic device and computer storage medium
Through the word vector incremental method, local linear relationships are used to construct word vectors of new words in the target word vector space, which solves the limitations of cross-language word vector alignment based on linear orthogonal mapping methods and improves word vector alignment. and fusion effects.
Patent Information
- Application Number
- CN202111218455.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-20
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2041-10-20
AI Technical Summary
The linear orthogonal mapping method in the existing technology has limitations in aligning cross-language word vectors, resulting in poor word vector space alignment and large differences, which affects the alignment and fusion effects of word vectors.
Using the word vector increment method, by obtaining the intersection word set between the word vector space to be aligned and the target word vector space, the local linear relationship of the new words is obtained, and the local linear relationship is used to construct the new words in the target word vector space. Word vectors increase the number of words in the target word vector space and maintain local linear features to improve the limitations of linear assumptions.
It effectively improves the alignment and fusion quality of word vectors in different word vector spaces, avoids the problem of poor local linear feature representation, and improves alignment and fusion effects.
Smart Images

Figure CN113887216B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of natural language processing technology, and in particular to a word vector increment method, electronic device and computer storage medium. Background Art
[0002] In recent years, natural language processing technology has developed rapidly. Among them, word vectors, as an important cornerstone of natural language processing technology, play an important role in the field of natural language processing. In particular, due to differences in corpus, algorithms, model parameters, etc., it is usually necessary to align and fuse different word vector models.
[0003] In traditional technology, linear assumptions are usually used in cross-language word vectors to map word vectors in different vector spaces to the same word vector space through orthogonal mapping and other methods to solve the problem of inconsistent word vector spaces. However, the assumption based on linear orthogonal mapping usually has certain limitations, which makes the word vector space alignment effect poor, resulting in large differences in the word vectors of some words after mapping, resulting in poor alignment and fusion effects of word vectors. Summary of the invention
[0004] The main technical problem solved by this application is to provide a word vector increment method, electronic device and computer storage medium to improve the alignment and fusion quality of word vectors in different word vector spaces.
[0005] In order to solve the above technical problems, a technical solution adopted by the present application is to provide a word vector increment method. The word vector increment method includes: obtaining an intersection word set between a first word set in the word vector space to be aligned and a second word set in the target word vector space; obtaining new words in the first word set relative to the second word set; obtaining a local linear relationship of the new words in the word vector space to be aligned formed by the intersection words in the intersection word set; and constructing a word vector of the new words in the target word vector space using the local linear relationship.
[0006] In order to solve the above technical problems, a technical solution adopted in the present application is to provide an electronic device. The electronic device includes a memory and a processor coupled to each other, and the processor is used to execute program data stored in the memory to implement the above word vector increment method.
[0007] In order to solve the above technical problems, a technical solution adopted by the present application is: providing a computer storage medium having program data stored thereon, which can be executed to implement the above word vector increment method.
[0008] The beneficial effect of the embodiment of the present application is that the word vector increment method of the present application includes: obtaining the intersection word set between the first word set in the word vector space to be aligned and the second word set in the target word vector space; obtaining the newly added words of the first word set relative to the second word set; obtaining the local linear relationship of the newly added words in the word vector space to be aligned formed by the intersection words in the intersection word set; and constructing the word vector of the newly added words in the target word vector space using the local linear relationship formed by the intersection words in the word vector space to be aligned by means of local linear mapping, and the newly added words in the word vector space to be aligned can be incremented to the target word vector space, which can not only increase the number of words in the target word vector space and realize the expansion of the target word vector space, but also can keep the local linear features of the newly added words in the word vector space to be aligned in the target word vector space, realize local linear embedding, improve the limitation of linear assumption, and thus effectively improve the alignment and fusion quality of word vectors in different word vector spaces. Moreover, the present application limits the neighboring word set of the new word to the intersection word set between the first word set in the word vector space to be aligned and the second word set in the target word vector space. This can avoid the problem of poor local linear feature representation of the new word due to the non-existence of some neighboring words when the new word is subsequently constructed in the target word vector space using the neighboring words of the new word. Therefore, the word vector alignment and fusion effects in different word vector spaces can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0010] Figure 1 This is a flow chart of an embodiment of the word vector increment method of the present application;
[0011] Figure 2 yes Figure 1 A specific flow chart of step S13 in the embodiment;
[0012] Figure 3 yes Figure 2 Specific flow chart of step S21 in the embodiment;
[0013] Figure 4 yes Figure 1 A schematic diagram of a specific process of step S14 in the embodiment;
[0014] Figure 5This is a flow chart of an embodiment of the word vector increment method of the present application;
[0015] Figure 6 yes Figure 5 A schematic diagram of a specific flow chart of step S55 in the word vector increment method of the embodiment;
[0016] Figure 7 It is a flowchart of part of the process in an embodiment of the word vector increment method of the present application;
[0017] Figure 8 This is a schematic diagram of word vector distribution before the word vector increment method of this application is applied;
[0018] Fig. 9 This is a schematic diagram of the word vector distribution process and results of applying the word vector increment method of this application;
[0019] Fig.10 This is a comparison chart of the average cosine similarity before and after the word vector increment of this application;
[0020] Fig.11 This is a line graph of the average cosine similarity of intersection words under different K values for the word vector increment method of this application;
[0021] Fig.12 This is a line graph of the average cosine similarity of new words under different K values in the word vector increment method of this application;
[0022] Fig.13 It is a structural schematic diagram of an embodiment of the electronic device of the present application;
[0023] Fig.14 It is a structural diagram of an embodiment of the computer storage medium of the present application. DETAILED DESCRIPTION
[0024] The present application is further described in detail below in conjunction with the accompanying drawings and examples. It is particularly noted that the following examples are only used to illustrate the present application, but are not intended to limit the scope of the present application. Similarly, the following examples are only some embodiments of the present application rather than all embodiments, and all other embodiments obtained by those of ordinary skill in the art without making creative work are within the scope of protection of the present application.
[0025] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiments of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0026] In traditional technology, word vectors are usually obtained using word2vec, glove or other word vector generation technologies. However, word vectors trained with different languages, different corpora, different algorithms or even different parameters have spatial differences. Therefore, linear assumptions are usually used in cross-language word vectors to map different word vectors to the same vector space through regression, orthogonal mapping and other methods to solve the problem of inconsistent word vector space. The original intention of the orthogonal mapping method is to maintain the unitary invariance of word vector embedding. If the word vector can be perfectly embedded, the RPD value of the mapped word vector and the target word vector should be 0 (the RPD value was proposed by Xuhui Zhou et al. and is an evaluation indicator that can be used to measure the differences between different word vectors. The smaller the value, the smaller the difference between the word vectors. In particular, the RPD value of completely identical word vectors is 0). However, actual tests have found that the method based on linear orthogonal mapping maintains unitary invariance and cannot obtain completely consistent word vector space. This may be caused by differences in training corpora, algorithms and model parameters.
[0027] Therefore, the assumption based on linear orthogonal mapping usually has certain limitations. HaoZhou Wang (2021), Nakashole (2018) and others also pointed out the limitations of the linear assumption, especially for word vectors of languages with large differences (such as Chinese and English). The limitations of the linear assumption make the alignment between different word vector spaces poor, and make the word vectors of some words before and after mapping very different, which has a great impact on word alignment and word fusion in different word vector spaces.
[0028] This application incorporates the idea of local linear embedding into vector alignment and word increment to solve the limitations of the linear assumption and improve the effect of word vector alignment and fusion.
[0029] To this end, this application first proposes a word vector increment method, such as Figure 1 As shown, Figure 1This is a flow chart of an embodiment of the word vector increment method of the present application. The word vector increment method of this embodiment specifically includes the following steps:
[0030] Step S11: Obtain an intersection word set between a first word set in the word vector space to be aligned and a second word set in the target word vector space.
[0031] Before executing step S11, this embodiment further includes: using the corpus text to perform model training to obtain a word vector model to be aligned. The word vector space of the word vector model to be aligned is the word vector space to be aligned, and the corpus text includes newly added words (for example, proprietary words in a proprietary field) and intersection words (for example, common words between different fields).
[0032] Specifically, the corpus text is obtained, and word2vec, Glove or other word vector training methods (models) are used to train based on the corpus text to obtain the word vector model to be aligned. Specifically, after the corpus source text is obtained, the corpus text is cleaned and segmented, and the cleaned and segmented corpus text is trained using word2vec, etc. to obtain the word vector model to be aligned.
[0033] The target word vector space can be understood as the word vector space of the target word vector model; the target word vector model can adopt a pre-trained word vector model. In some embodiments, it is impossible to obtain the corpus for training the target word vector model, or it is impossible to obtain the training parameters for training the target word vector model. Therefore, the pre-trained target word vector model can be directly obtained to solve the problem that the target word vector model cannot be obtained through corpus training when the corpus for training the word vector cannot be obtained. Of course, in other embodiments, the target word vector model can also be trained based on the corpus text using word2vec, Glove or other word vector training methods.
[0034] For example, you can obtain an open source word vector library (target word vector space). For example, the open source word vector library contains a huge number of word vectors, which are obtained based on a very large amount of corpus using supercomputers and long-term model training; however, there are still a large number of new words (such as professional words) that are not included in the open source word vector library.
[0035] Because the open source word vector library only provides the word vector results, but does not provide the open source corpus and auxiliary information during the training process, it is impossible to continue training by adding professional corpus based on the open source word vector library to obtain a target word vector library (target word vector space) containing professional words / new words.
[0036] To this end, this embodiment can use the corpus training of professional words / newly added words to obtain a word vector library. For example, the corpus training of professional words / newly added words related to the products of enterprise A can be used to obtain the word vector library of enterprise A, that is, the word vector library to be aligned (word vector space to be aligned). There are intersection words between the word vector library to be aligned and the target word vector library, and the word vector library to be aligned includes intersection words and newly added words, that is, the first word set in the word vector space to be aligned includes the intersection words and newly added words with the second word set in the target word vector space.
[0037] The word vector alignment of this embodiment can map word vectors of one or more different word vector spaces to be aligned to the same target word vector space. In some embodiments, the alignment is for the alignment of corpora of the same language type rather than the alignment of corpora of different language types.
[0038] The intersection words in the intersection word set are words shared by the word vector space to be aligned and the target word vector space (such as common words), and the newly added words are words unique to the word vector space to be aligned.
[0039] For example, the newly added words in the word vector library of company A (the word vector space to be aligned) may include words specific to company A's products, such as "powerful wash" and "child lock"; the intersection words of the word vector library of company A and the word vector library of company B (the target word vector space) may include common words such as "beautiful" and "repair".
[0040] Step S12: Acquire new words in the first word set relative to the second word set.
[0041] The first word set and the second word set can be compared to obtain new words in the first word set relative to the second word set, where the new words are in the first word set but not in the second word set; the new word set of the new words in the word vector space to be aligned and the intersection word set constitute the first word set.
[0042] Step S13: obtaining the local linear relationship of the newly added word formed by the intersection words in the intersection word set in the word vector space to be aligned.
[0043] Optionally, the local linear relationship of the newly added word in this embodiment includes the neighboring words of the newly added word and the weight coefficients of the neighboring words to the newly added word. Figure 2 The method shown implements step S13. The method of this embodiment specifically includes step S21 and step S22.
[0044] Step S21: Obtaining a neighboring word set of the newly added word from the intersection word set.
[0045] This embodiment limits the neighboring word set of the new word to the intersection word set between the first word set in the word vector space to be aligned and the second word set in the target word vector space. This can avoid the problem of poor local linear feature representation of the new word due to the non-existence of some neighboring words when the new word is subsequently constructed in the target word vector space using the neighboring words of the new word. Therefore, the word vector alignment and fusion effects in different word vector spaces can be improved.
[0046] Each word in the word vector space can be linearly represented by its K neighboring words. The linear representation of the word by the K neighboring words reflects the local linear characteristics of the word in the word vector space.
[0047] Optionally, this embodiment may adopt Figure 3 The method shown implements step S21 , and the method of this embodiment includes step S31 and step S32 .
[0048] Step S31: Calculate the cosine distance between the newly added word in the word vector space to be aligned and other words in the intersection word set.
[0049] Calculate the cosine distance between the newly added word in the word vector space to be aligned and each other word in the intersection word set.
[0050] Step S32: Determine other words whose cosine distance is less than the preset distance as neighboring words of the newly added word.
[0051] The cosine distance is compared with a preset distance, and words corresponding to cosine distances smaller than the preset distance are taken as neighboring words of the newly added word, so as to obtain a neighboring word set of the newly added word.
[0052] This embodiment uses the nearest neighbor algorithm (K Near Neighbor, KNN) and other algorithms, that is, by measuring the cosine distance to obtain the neighboring word combination of the new word in the word vector space to be aligned, that is, the neighboring word set. Of course, in other embodiments, the neighboring words of the new word can also be obtained by using the Euclidean distance and the like.
[0053] The smaller the cosine distance between the neighboring word and the new word (the closer it is), the greater its contribution to the local linear features of the new word. Therefore, in this embodiment, the neighboring words of the new word can first be sorted in ascending order of cosine distance, that is, from small to large, to obtain a sequence, and then K (how to determine the optimal K will be introduced below) neighboring words (relatively the closest) corresponding to the cosine distance are obtained from the sequence in order from small to large as the neighboring word set of the new word.
[0054] For example, in the word vector space to be aligned, the newly added word "dishwasher" can be represented by its corresponding 5 (K=5) nearest neighbor word sets {"wash", "dishes and chopsticks", "washing machine", "detergent", "dishwashing salt"}.
[0055] Step S22: Obtain the weight coefficient of the adjacent words in the adjacent word set to the newly added word.
[0056] The magnitude of the weight coefficients reflects the distance between the neighboring words and the newly added words (in the target space to be aligned), and the value of the weight coefficient reflects the distance ratio between the neighboring words and the newly added words (to the unit distance, which can be preset).
[0057] In the word vector space, each word can be represented by a local linear relationship consisting of multiple (at least two) neighboring words in its neighboring word set and the corresponding weight coefficients, which reflects the local linear characteristics of the word; for example, dishwasher = 0.15 wash + 0.3 dishes + 0.1 washing machine + 0.2 detergent + 0.25 dishwashing salt. The weight coefficients {0.15, 0.3, 0.1, 0.2, 0.25} are the weight coefficients of the neighboring words {"wash", "dishwashing", "washing machine", "detergent", "dishwashing salt"} to the newly added word "dishwasher".
[0058] In this embodiment, a local linear embedding (LLE) algorithm may be used to calculate the weights corresponding to the newly added words.
[0059] Based on the LLE idea, we add the new word v i In the original high-dimensional neighborhood of k ), then suppose we add a new word v i It can be composed of K neighboring words (v1, v2…v k ) is linearly expressed as v i =w 1i *v 1+ w 2i *v 2… w ki *v k , where (w 1i 、w 2i …w ki ) is the weight coefficient. After LLE dimensionality reduction, the corresponding projection of the newly added word in the low-dimensional space and its neighboring words also approximately maintain the above linear relationship.
[0060] For the LLE algorithm, we must first determine the size of the neighborhood, that is, how many neighboring words are needed to linearly represent the new word, which is the K value mentioned above. The determination of the K value can be found below.
[0061] In the process of finding the optimal K value, the optimal weight coefficient needs to be found for each K value in order to determine the optimal linear relationship. In this embodiment, the mean square error can be used as the loss function to obtain the optimal weight coefficient (see below for details).
[0062] Step S14: construct a word vector for the newly added word in the target word vector space using the local linear relationship and the corresponding intersection words.
[0063] Optionally, this embodiment may adopt Figure 4 The method shown implements step S14. The method of this embodiment includes step S41 and step S42.
[0064] Step S41: Obtain neighboring word vectors of neighboring words corresponding to the local linear relationship in the target word vector space.
[0065] In the word vector space, the word vector corresponding to each word is composed of multiple components.
[0066] From the above analysis, it can be seen that the neighboring words of the newly added word are the intersection words of the word vector space to be aligned and the target word vector space. Therefore, all the neighboring words of the newly added word in the local linear relationship and the neighboring word vectors corresponding to these neighboring words can be obtained from the target word vector space.
[0067] Step S42: construct a word vector for the newly added word in the target word vector space using neighboring word vectors and weight coefficients.
[0068] In the target word vector space, the weighted word vector of the neighboring word vector based on the weight coefficient is obtained as the word vector of the newly added word in the target word vector space. Specifically, each component of each neighboring word vector is obtained; and the weighted value of each component in multiple neighboring word vectors based on the weight coefficient is calculated, and the weighted value is the component corresponding to the newly added word in the target word vector.
[0069] That is, each component of the new word in the target word vector space is composed of the local linear relationship x of the K neighboring word vectors i =w 1i *x 1+ w 2i *x2…w ki *x k Calculated; where x i is the component of the new word in the target word vector space, x1…x k are the components of the K neighboring words in the target word vector space.
[0070] This embodiment uses the local linear relationship formed by the intersection words in the word vector space to be aligned relative to the target word vector space to construct the word vector of the new word in the target word vector space, which can align the new word in the word vector space to the target word vector space, and realize the expansion of the target word vector space, and can keep the local linear features of the new word in the target word vector space to realize local linear embedding, which can improve the limitation of the linear assumption, and thus can effectively improve the alignment and fusion quality of word vectors in different word vector spaces; and this embodiment limits the neighboring word set of the new word to the intersection word set between the first word set in the word vector space to be aligned and the second word set in the target word vector space, which can avoid the problem that some neighboring words do not exist when the new word is constructed in the target word vector space in the subsequent use of the neighboring words of the new word, resulting in poor local linear feature representation of the new word, thereby improving the alignment and fusion effect of word vectors in different word vector spaces.
[0071] This application further proposes another embodiment of a word vector alignment method, such as Figure 5 As shown, Figure 5 This is a flow chart of an embodiment of the word vector increment method of the present application. The vector increment method of this embodiment specifically includes the following steps:
[0072] Step S51: Obtain an intersection word set between a first word set in the word vector space to be aligned and a second word set in the target word vector space.
[0073] Step S51 is similar to step S11 and will not be described in detail here.
[0074] Step S52: Acquire new words in the first word set relative to the second word set.
[0075] Step S52 is similar to step S12 and will not be described in detail here.
[0076] Step S53: Obtaining a neighboring word set of the newly added word from the intersection word set.
[0077] Step S53 is similar to step S21 and will not be described in detail here.
[0078] Step S54: determining multiple groups of neighboring words corresponding to the newly added words from the neighboring word set, each group of neighboring words including a different number of neighboring words.
[0079] The number of neighboring words in each obtained neighboring word group is different, that is, the above K value is different.
[0080] Specifically, the neighboring words in the neighboring word set of the new word can be arranged in ascending order of their cosine distance to obtain a sequence (the neighboring words with smaller cosine distances to the new word (the closer they are) contribute more to the local linear features of the new word; in this embodiment, the neighboring words of the new word can be first sorted in ascending order of cosine distance to obtain a sequence); then, multiple groups of neighboring word groups are obtained from the sequence in ascending order (multiple groups of neighboring word groups are obtained from the sequence in ascending order (cosine distance), and the number K of neighboring words in each neighboring word group is different. K can be 5, 10, etc.); then, the weight coefficient of each group of neighboring word groups to the new word in the word vector space to be aligned is obtained.
[0081] Step S55: For each group of neighboring words, determine the weight coefficient of each neighboring word in the neighboring word group relative to the newly added word, reconstruct the word vector in the target word vector space using the neighboring words and the weight coefficient, and obtain the test index parameters corresponding to the target word vector space after the reconstructed word vector.
[0082] Specifically, this embodiment can also adopt the following Figure 6 The method shown implements step S55, and the method of this embodiment includes steps S61 to S64.
[0083] Step S61: For each group of neighboring words, initial weight coefficients are configured for the neighboring words in the neighboring words.
[0084] Construct the local linear relationship between the K neighboring words of the new word and the new word, and for each new word v in the word vector space to be aligned i According to the above method, we can get the adjacent word group (v1,v2…v k ) and the weight coefficient w corresponding to each neighboring word ii , add the new word v i Represents the local linear relationship v of K neighboring words i =w 1i *v1+w 2i *v2…w ki *v k . And configure the initial weight coefficients of the K neighboring words in this local linear relationship.
[0085] Step S62: adjusting the initial weight coefficient based on the loss function to obtain the weight coefficient of each neighboring word in the neighboring word group relative to the newly added word.
[0086] In this embodiment, the mean square error can be used to construct a loss function of the local linear relationship, and the loss function can be solved to adjust the initial weight coefficient to obtain the weight coefficient of each neighboring word in the neighboring word group relative to the newly added word.
[0087] The local linear embedding algorithm and Lagrangian function can also be used to construct the loss function of the local linear relationship.
[0088] This embodiment can obtain the optimal weight coefficient based on the loss function.
[0089] Step S63: Reconstruct the word vector in the target word vector space using the neighboring word groups and weight coefficients.
[0090] Specifically, this embodiment first obtains the neighboring word vectors of each neighboring word in the neighboring word group of the newly added word in the target word vector space, wherein each neighboring word vector has multiple components; and then calculates the weighted value of each component in the multiple neighboring word vectors based on the weight coefficient, which is the component corresponding to the newly added word in the target word vector.
[0091] Each component of the new word in the target word vector space is composed of the local linear relationship x of its K neighboring word vectors i =w 1i *x 1+ w 2i *x2…w ki *x k Calculated; where x i is the component of the new word in the target word vector space, x1…x k They are the components of the word vectors of the K neighboring words in the target word vector space.
[0092] Step 64: Obtain test index parameters corresponding to the target word vector space after reconstructing the word vector.
[0093] The target word vector model corresponding to the target word vector space after the reconstructed word vector is tested and trained using the test corpus to obtain a test index parameter. The test index parameter can be an evaluation index such as RPD or cosine similarity.
[0094] Step S56: Based on the test index parameters corresponding to each group of neighboring phrases, the neighboring words in the neighboring phrases corresponding to the optimal test index parameters are used as the neighboring words of the newly added word, and the weight coefficients of the neighboring words are used as the weight coefficients of the newly added word.
[0095] Each group of neighboring phrases corresponds to a test index parameter. The optimal test index parameter is obtained from multiple test index parameters, and the neighboring words in the neighboring phrases corresponding to the optimal test index parameter are used as the neighboring words of the newly added words in the target word vector space, and the weight coefficient of the neighboring words is used as the weight coefficient of the newly added words in the target word vector space.
[0096] This embodiment obtains multiple groups of neighboring words from the neighboring word set of the newly added word (the number K of neighboring words in each group of neighboring words is different), and obtains the weight coefficient of each neighboring word in each group of neighboring words to the newly added word in the word vector space to be aligned, and reconstructs the word vector of the newly added word in the target word vector space based on the neighboring word vector of each neighboring word in each group of neighboring words in the target word vector space and the corresponding weight coefficient, that is, the word vector of the newly added word in the target word vector space is reconstructed multiple times using different numbers of neighboring word combinations; then the target word vector model after each reconstruction of the word vector of the newly added word is tested and trained using the data test corpus, and finally the reconstructed word vector (neighboring words and weight coefficient) corresponding to the optimal test index parameter is obtained as the word vector of the newly added word in the target word vector space.
[0097] For example, 5 neighboring words (K=5) and the weight coefficients of these 5 neighboring words to the new word are obtained from the neighboring word set of the new word, and the optimal weight coefficient when K=5 is obtained through continuous iteration of the loss function; then 10 neighboring words (K=10) are obtained from the neighboring word set of the new word and the weight coefficients of these 10 neighboring words to the new word, and then the optimal weight coefficient when K=10 is obtained through continuous iteration of the loss function; finally, the test index parameters of the target word vector model are solved when K=5 and 10, and the optimal K is obtained based on the optimal test index parameters; the word vector of the new word corresponding to the optimal K in the target word vector space is the final word vector of the new word in the target word vector space.
[0098] Through the above method, this embodiment can improve the accuracy of the target word vector model corresponding to the target word vector space, and thus can improve the accuracy of corpus processing.
[0099] Of course, the method of this embodiment can also be used in fields such as semantic recognition, without specific limitation.
[0100] The above method is used to realize the alignment increment of the newly added words to the target word vector space; and for the intersection words of the first word set in the word vector space to be aligned and the second word set in the target word vector space, the alignment increment can be realized by the following method.
[0101] like Figure 7 As shown, the method of this embodiment includes the following steps:
[0102] Step S71: Obtain the first intersection word vector of the intersection word in the intersection word set in the word vector space to be aligned and the second intersection word vector of the intersection word in the target word vector space.
[0103] Step S71 is similar to step S11 and will not be described in detail here.
[0104] Step S72: Calculate the weighted word vector of the first intersection word vector and the second intersection word vector to obtain the intersection word vector.
[0105] The weighted word vector can be obtained by calculating the average word vector of the first intersection word vector and the second intersection word vector. The average word vector can be the average of the first intersection word vector and the second intersection word vector; for example, the first intersection word vector (1, 1, 2) + the second intersection word vector (2, 3, 4) = the average word vector (1.5, 2, 3). It should be noted that when the weight corresponding to the first intersection word vector is zero, the weighted word vector can be the second intersection word vector, and when the weight corresponding to the second intersection word vector is zero, the weighted word vector can be the first intersection word vector.
[0106] Step S73: Update the second intersection word vector to the intersection word vector.
[0107] In this embodiment, the second intersection word vector of the intersection word in the target word vector space is updated to the average word vector of the first intersection word vector and the second intersection word vector of the intersection word in the word vector space to be aligned. This can maintain part of the vector information of the first intersection word vector and improve the accuracy of the target word vector model, especially for the corpus for training the word vectors to be aligned.
[0108] This application can solve the problem of spatial inconsistency of trained word vector models caused by different corpora, different algorithms and even different parameters; and solve the problem that some words cannot obtain good local linear embedding based on the local linear fusion method, so as to improve the overall effect of word vector alignment; and integrate the local linear embedding idea into vector alignment, which can solve the limitations of linear assumptions and improve the effects of word vector alignment and fusion.
[0109] In the process of word vector fusion, the original word vector information can be effectively utilized to reduce the training time and resource consumption, and achieve the purpose of incremental training. The final word vector can effectively improve the accuracy of various text downstream tasks (such as text classification, text clustering, etc.).
[0110] like Figures 8 to 12 As shown, Figure 8 This is a schematic diagram of word vector distribution before the word vector increment method of this application is applied; Fig. 9 This is a schematic diagram of the word vector distribution process and results of applying the word vector increment method of this application; Fig.10 This is a comparison chart of the average cosine similarity before and after the word vector increment of this application; Fig.11 This is a line graph of the average cosine similarity of intersection words under different K values for the word vector increment method of this application; Fig.12This is a line graph of the average cosine similarity of new words in this application's word vector increment method under different K values. It can be seen that this application can effectively solve the limitation problem of linear mapping and effectively improve the effect after fusion; the appropriate K value can be selected based on the average cosine similarity of the intersection word pairs and the new word pairs.
[0111] Among them, from Fig.10 The average cosine similarity before and after the word vector fusion is compared. The greater the similarity, the closer the mapped word vector is to the corresponding original word vector, which means the better the mapping effect.
[0112] from Figure 10-12 It can be seen that with the increase of K value, the cosine similarity shows a trend of first increasing and then decreasing. This is because if the K value is too small, there are too few local neighbors (neighboring words) and the local linear structure cannot be maintained; if the K value is too large, the reconstruction weight coefficients of the calculated sample points will be very close, which will cause the sample points to overlap when projected into the low-dimensional space, and the information of the original data will be lost.
[0113] The present application further proposes an electronic device, such as Fig.13 As shown, Fig.13 The electronic device 80 of this embodiment includes a processor 81 , a memory 82 , an input / output device 83 and a bus 84 .
[0114] The processor 81, memory 82, and input / output device 83 are respectively connected to a bus 84. The memory 82 stores program data, and the processor 81 is used to execute the program data to implement the word vector increment method of the above embodiment.
[0115] In this embodiment, the processor 81 may also be referred to as a CPU (Central Processing Unit). The processor 81 may be an integrated circuit chip having signal processing capabilities. The processor 81 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. A general-purpose processor may be a microprocessor or the processor 81 may also be any conventional processor, etc.
[0116] The present application further proposes a computer-readable storage medium, such as Fig.14 As shown, the computer-readable storage medium 160 of this embodiment is used to store the program data 161 of the above embodiment, and the program data 161 can be executed to implement the above word vector increment method. The program data 161 has been described in detail in the above method embodiment and will not be repeated here.
[0117] The computer-readable storage medium 160 of this embodiment may be, but is not limited to, a USB flash drive, an SD card, a PD optical drive, a mobile hard disk, a large-capacity floppy drive, a flash memory, a multimedia memory card, a server, and the like.
[0118] Different from the prior art, the word vector increment method of the present application includes: obtaining an intersection word set between a first word set in the word vector space to be aligned and a second word set in the target word vector space; obtaining new words in the first word set relative to the second word set; obtaining the local linear relationship of the new words in the word vector space to be aligned formed by the intersection words in the intersection word set; and constructing the word vector of the new words in the target word vector space using the local linear relationship. In this way, the present application utilizes the local linear relationship formed by the intersection words in the word vector space to be aligned relative to the target word vector space to construct the word vector of the new word in the target word vector space, and can align the new word increment to the target word vector space, and can maintain the local linear features of the new word in the target word vector space to achieve local linear embedding, which can improve the limitations of the linear assumption and effectively improve the alignment and fusion quality of the word vectors; and the present application limits the neighboring word set of the new word to the intersection word set between the first word set in the word vector space to be aligned and the second word set in the target word vector space, which can avoid the problem of poor local linear feature representation of the new word due to the non-existence of some neighboring words when the new word is subsequently constructed in the target word vector space using the neighboring words of the new word, thereby improving the word vector alignment and fusion effects in different word vector spaces.
[0119] In addition, if the above functions are implemented in the form of software functions and sold or used as independent products, they can be stored in a storage medium readable by a mobile terminal, that is, the present application also provides a storage device storing program data, the program data can be executed to implement the method of the above embodiment, and the storage device can be, for example, a USB flash drive, an optical disk, a server, etc. In other words, the present application can be embodied in the form of a software product, which includes a number of instructions for enabling a smart terminal to execute all or part of the steps of the method described in each embodiment.
[0120] In the description of the present application, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, mechanisms, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, mechanisms, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0121] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0122] Any process or method description in a flowchart or otherwise described herein may be understood to represent a mechanism, segment or portion of a code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0123] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing the logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (which can be a personal computer, server, network device or other system that can fetch instructions from the instruction execution system, device or apparatus and execute the instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0124] The above description is only an implementation method of the present application, and does not limit the patent scope of the present application. Any equivalent mechanism or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A word vector increment method, characterized in that: include: Obtain an intersection word set between a first word set in the word vector space to be aligned and a second word set in the target word vector space; Obtaining new words in the first word set relative to the second word set; Obtaining a local linear relationship of the newly added word formed by intersection words in the intersection word set in the to-be-aligned word vector space; Constructing a word vector of the newly added word in the target word vector space by using the local linear relationship; The local linear relationship includes neighboring words of the newly added word and weight coefficients of the neighboring words to the newly added word.
2. The word vector increment method according to claim 1, characterized in that: The step of obtaining the local linear relationship of the newly added word formed by the intersection words in the intersection word set in the word vector space to be aligned includes: Acquire a neighboring word set of the newly added word from the intersection word set; Obtain a weight coefficient of a neighboring word in the neighboring word set to the newly added word.
3. The word vector increment method according to claim 2, characterized in that: The constructing the word vector of the newly added word in the target word vector space by using the local linear relationship comprises: Obtaining a neighboring word vector of the neighboring word corresponding to the local linear relationship in the target word vector space; The word vector of the newly added word is constructed in the target word vector space using the neighboring word vectors and the weight coefficients.
4. The word vector increment method according to claim 2, characterized in that: The step of obtaining the weight coefficient of the adjacent words in the adjacent word set to the newly added word comprises: Determining a plurality of groups of neighboring words corresponding to the newly added words from the neighboring word set, each group of the neighboring words including a different number of neighboring words; For each group of the neighboring words, determine the weight coefficient of each neighboring word in the neighboring word group relative to the newly added word, reconstruct the word vector in the target word vector space using the neighboring words and the weight coefficient, and obtain the test index parameter corresponding to the target word vector space after the reconstructed word vector; Based on the test index parameters corresponding to each group of neighboring phrases, the neighboring words in the neighboring phrases corresponding to the optimal test index parameters are used as neighboring words of the newly added words, and the weight coefficients of the neighboring words are used as the weight coefficients of the newly added words.
5. The word vector increment method according to claim 4, characterized in that: For each group of the adjacent words, determining the weight coefficient of each adjacent word in the adjacent words relative to the newly added word comprises: For each group of the neighboring words, configuring initial weight coefficients for the neighboring words in the neighboring words; The initial weight coefficient is adjusted based on the loss function to obtain a weight coefficient of each of the neighboring words in the neighboring word group relative to the newly added word.
6. The word vector increment method according to claim 3, characterized in that: The constructing the word vector of the newly added word in the target word vector space by using the neighboring word vectors and the weight coefficients includes: In the target word vector space, a weighted word vector of the neighboring word vectors based on the weight coefficient is obtained as the word vector of the newly added word in the target word vector space.
7. The word vector increment method according to claim 1, characterized in that: Further including: Obtain a first intersection word vector of an intersection word in the intersection word set in the to-be-aligned word vector space and a second intersection word vector of the intersection word in the target word vector space; Calculate a weighted word vector of the first intersection word vector and the second intersection word vector to obtain an intersection word vector; Update the second intersection word vector to the intersection word vector.
8. The word vector increment method according to claim 4, characterized in that: The test index parameter includes RPD or cosine similarity.
9. An electronic device, characterized in that: It includes a memory and a processor coupled to each other, and the processor is used to execute program data stored in the memory to implement the word vector increment method described in any one of claims 1 to 8.
10. A computer storage medium, characterized in that: Program data is stored thereon, and the program data can be executed to implement the word vector increment method described in any one of claims 1 to 8.
