CN107247704B - Word vector processing method and device and electronic equipment - Google Patents

Word vector processing method and device and electronic equipment Download PDF

Info

Publication number
CN107247704B
CN107247704B CN201710430490.2A CN201710430490A CN107247704B CN 107247704 B CN107247704 B CN 107247704B CN 201710430490 A CN201710430490 A CN 201710430490A CN 107247704 B CN107247704 B CN 107247704B
Authority
CN
China
Prior art keywords
word
words
code character
vector
cangjie
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710430490.2A
Other languages
Chinese (zh)
Other versions
CN107247704A (en
Inventor
曹绍升
周俊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Advanced New Technologies Co Ltd
Advantageous New Technologies Co Ltd
Original Assignee
Alibaba Group Holding Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201710430490.2A priority Critical patent/CN107247704B/en
Publication of CN107247704A publication Critical patent/CN107247704A/en
Application granted granted Critical
Publication of CN107247704B publication Critical patent/CN107247704B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/284Lexical analysis, e.g. tokenisation or collocates

Abstract

The embodiment of the application discloses a word vector processing method and device and electronic equipment. The method comprises the following steps: segmenting the corpus into words to obtain each word; determining each n-element Cangjie code character corresponding to each word, wherein the n-element Cangjie code characters represent continuous n Cangjie code characters of the corresponding word; establishing and initializing word vectors of the words and Cangjie code character vectors of the n-element Cangjie code characters corresponding to the words; and training the word vector and the Cangjie code character vector according to the word vector, the Cangjie code character vector and the corpus after word segmentation. By utilizing the embodiment of the application, the characteristics of the word can be more finely represented through the n-element cang jie code character corresponding to the word, particularly the font form characteristics of the word can be represented, the accuracy of the word vector of the Chinese word can be improved, and the practical effect is better.

Description

Word vector processing method and device and electronic equipment
Technical Field
The present application relates to the field of computer software technologies, and in particular, to a word vector processing method and apparatus, and an electronic device.
Background
Most of the current natural language processing solutions adopt neural network-based architectures, and the next important basic technology in such architectures is word vectors. A word vector is a vector that maps a word to a fixed dimension, the vector characterizing the semantic information of the word.
In the prior art, common algorithms for generating word vectors are specifically designed for english. Such as google's word vector algorithm, microsoft's deep neural network algorithm, etc.
However, these algorithms of the prior art are either not applicable to chinese or, although applicable to chinese, the word vectors of the generated chinese words are less practical.
Disclosure of Invention
The embodiment of the application provides a word vector processing method, a word vector processing device and electronic equipment, which are used for solving the problem that an algorithm for generating word vectors in the prior art cannot be used for Chinese, or can be used for Chinese, but the practical effect of the generated word vectors of Chinese words is poor.
In order to solve the above technical problem, the embodiment of the present application is implemented as follows:
the word vector processing method provided by the embodiment of the application comprises the following steps:
segmenting the corpus into words to obtain each word;
determining each n-element Cangjie code character corresponding to each word, wherein the n-element Cangjie code characters represent continuous n Cangjie code characters of the corresponding word;
establishing and initializing word vectors of the words and Cangjie code character vectors of the n-element Cangjie code characters corresponding to the words;
and training the word vector and the Cangjie code character vector according to the word vector, the Cangjie code character vector and the corpus after word segmentation.
The word vector processing apparatus provided in the embodiment of the present application includes:
the word segmentation module is used for segmenting words of the speech to obtain each word;
the determining module is used for determining each n-element Cangjie code character corresponding to each word, and the n-element Cangjie code characters represent continuous n Cangjie code characters of the corresponding word;
the initialization module is used for establishing and initializing word vectors of all the words and Cangjie code character vectors of all the n-element Cangjie code characters corresponding to all the words;
and the training module is used for training the word vector and the Cangjie code character vector according to the word vector, the Cangjie code character vector and the corpus after word segmentation.
Another word vector processing method provided in the embodiment of the present application includes:
step 1, segmenting words of a corpus, and establishing a vocabulary list formed by all words obtained through segmenting the words, wherein all the words do not comprise the words with the occurrence frequency less than the set frequency in the corpus; skipping to the step 2;
step 2, establishing an n-element Cangjie code character mapping table according to the vocabulary table, wherein the mapping table comprises the mapping relation between each word and the n-element Cangjie code characters, and the n-element Cangjie code characters represent continuous n Cangjie code characters of the mapped words; skipping to step 3;
step 3, establishing and initializing word vectors of all the words and cang-jie code character vectors of all the n-yuan cang-jie code characters mapped by all the words according to the n-yuan cang-jie code character mapping table; skipping to the step 4;
step 4, traversing the corpus after word segmentation, respectively taking each traversed word as a current word w, and executing step 5 on the current word w, if the traversal is finished, ending, otherwise, continuing the traversal;
step 5, taking the current word w as a center, respectively sliding at most k words to two sides to establish windows, traversing all words except the current word w in the windows, respectively taking each traversed word as a current contextual word c of the current word w, and executing step 6 on the current contextual word c, if the traversal is completed, continuing the execution of step 4, otherwise, continuing the traversal;
step 6, calculating the similarity between the current word w and the current contextual word c according to the following formula:
Figure BDA0001317253400000031
wherein, s (w) represents each n-member Cangjie code character set mapped by the current word w in the n-member Cangjie code character mapping table, q represents each n-member Cangjie code character in s (w), and sim (w, c) represents the similarity between the current word w and the current context word c;
Figure BDA0001317253400000032
a vector dot product of the Cangjie code character vector representing q and the word vector of the current context word c; skipping to step 7;
and 7, randomly extracting lambda words as negative sample words, and calculating corresponding loss characteristic values l (w, c) according to the following loss functions:
Figure BDA0001317253400000033
where c' is a randomly drawn negative sample word, and Ec'∈p(V)[x]The expected value of the expression x is the neural network excitation function defined as the expected value of the expression x when the randomly extracted negative sample word c' satisfies the probability distribution p (V)
Figure BDA0001317253400000034
Calculating the gradient corresponding to the loss function according to the calculated loss characterization value l (w, c), and performing Chinese character conversion on the long-distance channel of q according to the gradient
Figure BDA0001317253400000035
And word vector for current context word c
Figure BDA0001317253400000036
And (6) updating.
An electronic device provided in an embodiment of the present application includes:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to:
segmenting the corpus into words to obtain each word;
determining each n-element Cangjie code character corresponding to each word, wherein the n-element Cangjie code characters represent continuous n Cangjie code characters of the corresponding word;
establishing and initializing word vectors of the words and Cangjie code character vectors of the n-element Cangjie code characters corresponding to the words;
and training the word vector and the Cangjie code character vector according to the word vector, the Cangjie code character vector and the corpus after word segmentation.
The embodiment of the application adopts at least one technical scheme which can achieve the following beneficial effects: the method can realize that the characteristics of the word can be more finely expressed through the n-element cang-jie code character corresponding to the word, particularly the font form characteristics of the word can be expressed, and further the accuracy of the word vector of the Chinese word can be improved, the practical effect is better, and therefore the problems in the prior art can be partially or completely solved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only some embodiments described in the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without any creative effort.
Fig. 1 is a schematic flowchart of a word vector processing method according to an embodiment of the present application;
fig. 2 is a schematic flow chart of a specific implementation of the word vector processing method in an actual application scenario provided in an embodiment of the present application;
FIG. 3 is a diagram illustrating operations of a related process of a part of corpora used in the process of FIG. 2 according to an embodiment of the present application;
fig. 4 is a schematic flowchart of another word vector processing method according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of a word vector processing apparatus corresponding to fig. 1 according to an embodiment of the present application.
Detailed Description
The embodiment of the application provides a word vector processing method and device and electronic equipment.
In order to make those skilled in the art better understand the technical solutions in the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The scheme of the application is suitable for word vectors of Chinese words and word vectors of words of some other languages similar to Chinese, such as word vectors of words of languages with obvious font morphological characteristics, such as Korean and Japanese, and for non-Chinese, the words need to be correspondingly coded according to the coding rule of Cangjie codes.
For convenience of description, the following embodiments mainly aim at scenes of Chinese words to explain the scheme of the application.
Fig. 1 is a flowchart illustrating a word vector processing method according to an embodiment of the present application. From a program perspective, the execution subject of the flow may be a program or the like having a word vector generation function and/or a training function; from the perspective of the device, the executing body of the process may include, but is not limited to, at least one of the following devices on which the program may be loaded: personal computers, large and medium-sized computers, computer clusters, mobile phones, tablet computers, intelligent wearable equipment, vehicle machines and the like.
The process in fig. 1 may include the following steps:
s101: and segmenting the corpus to obtain each word.
In the embodiment of the present application, the words may specifically be: at least some of the words in the corpus that have occurred at least once. For convenience of subsequent processing, each word can be stored in the vocabulary, and the word can be read from the vocabulary when the word needs to be used.
S102: and determining each n-element Cangjie code character corresponding to each word, wherein the n-element Cangjie code characters represent continuous n Cangjie code characters of the corresponding word.
The Bijia code is a code (also a coding mode) of Chinese characters, which reflects the fine characteristics of Chinese characters according to the visual identification principle, almost all different font styles or variant characters have different Bijia codes, and the coincident code rate is a lower one of the current various Chinese character coding modes. Essentially, the Cangjie code encodes the font form information of the Chinese character, and it needs to be emphasized that the Cangjie code is split according to the structural complexity of the Chinese character, the number of split areas is uncertain, and the dynamic splitting principle makes the Cangjie code become a Chinese character encoding mode with lower encoding quantity.
The Chinese character of the Bijiajie code generally has 25 or 26 types, any Chinese character is divided into font structures by the principles of 'from top to bottom, from left to right, from outside to inside', and the like, and then a character sequence is formed by the corresponding characters to be used as the Bijiajie code corresponding to the Chinese character, wherein the character sequence can be called as a Bijiajie code character sequence, and each character in the Bijiajie code character sequence is called as a Bijiajie code character.
For example, the "eating" word Cangjie code is "RON", contains 3 Cangjie code characters, and the "rice" word Cangjie code is "NVHE", contains 4 Cangjie code characters.
Further, the chinese word generally consists of a plurality of chinese characters, and the chinese word corresponding n-member chinese code character is obtained by connecting the chinese word's chinese code ' cang jie ' in sequence: and n consecutive Cangjie code characters in the Cangjie code character sequence corresponding to the word.
Following the above example, for the word "eat", the corresponding cang jie code character sequence is "ronnhve", from which: the corresponding 3-membered Cangjie code character is: "RON" (1 to 3 Bijiangjie code characters), "ONN" (2 to 4 Bijiajie code characters), "VHE" (5 to 7 Bijiajie code characters), etc.; the corresponding 4-membered Cangjie code character is: "RONN" (1 to 4 Bijiangjie code characters), "ONNV" (2 to 5 Bijiajie code characters), "NNVH" (3 to 6 Bijiajie code characters), etc.; the corresponding 5-membered Cangjie code character is: "RONNV" (1 to 5 Bijiangjie codewords), "ONNVH" (2 to 6 Bijiangjie codewords), "NNVHE" (3 to 7 Bijiangjie codewords).
In the embodiment of the present application, the value of n may be dynamically adjustable. For the same word, when determining each n-ary cang-jie code character corresponding to the word, the value of n may be only 1 (for example, only each 3-ary cang-jie code character corresponding to the word is determined), or may be multiple (for example, each 3-ary cang-jie code character and each 4-ary cang-jie code character corresponding to the word are determined). When the value of n is exactly the total number of Cangjie code characters contained in the Cangjie code character sequence corresponding to the character or word, the n-element Cangjie code character is exactly the Cangjie code character sequence.
In the embodiment of the application, for the convenience of computer processing, the n-member Cangjie code characters can also be represented by numbers. For example, different Cangjie code characters can be represented by one number respectively, and the n-member Cangjie code character can be correspondingly represented as a number string, wherein the number has a mapping relation with the number string or the Cangjie code character.
S103: and establishing and initializing word vectors of the words and Cangjie code character vectors of the n-element Cangjie code characters corresponding to the words.
In the embodiment of the present application, the Cangjie codeword vector refers to a vector for representing an n-ary Cangjie codeword. Each n-member Cangjie code character can be represented by a Cangjie code character vector, as if each word can be represented by a word vector.
In the embodiment of the present application, in order to ensure the effect of the scheme, there may be some restrictions when initializing the word vector and the Cangjie code character vector. For example, the word vectors and the Cangjie code character vectors cannot be initialized to the same vector; for another example, the values of vector elements in some word vectors or Cangjie code character vectors cannot be all 0; and so on.
In the embodiment of the application, a random initialization mode or an initialization mode according to a designated probability distribution can be adopted to initialize the word vectors of the words and the Cangjie code character vectors of the n-element Cangjie code characters corresponding to the words, wherein the Cangjie code character vectors of the same n-element Cangjie code characters are also the same. For example, the specified probability distribution may be a 0-1 distribution, and the like.
In addition, if word vectors and cang jie code character vectors corresponding to some words have been trained previously based on other corpora, then when training word vectors and cang jie code character vectors corresponding to these words based on the corpora in fig. 1, it is possible to do training again based on the corpora in fig. 1 and the previous training results instead of re-establishing and initializing word vectors and cang jie code character vectors corresponding to these words.
S104: and training the word vector and the Cangjie code character vector according to the word vector, the Cangjie code character vector and the corpus after word segmentation.
In the embodiment of the present application, the training may be implemented by a neural network, and the neural network may be a shallow neural network or a deep neural network, etc. The application does not limit the specific structure of the neural network used.
Through the method of fig. 1, the n-member cang-jie code characters corresponding to the word can be used for more finely representing the characteristics of the word, particularly the font form characteristics of the word, so that the accuracy of the word vector of the Chinese word can be improved, the practical effect is good, and the problems in the prior art can be partially or completely solved.
Based on the method of fig. 1, the examples of the present application also provide some specific embodiments of the method, and further embodiments, which are described below.
In this embodiment of the present application, for step S102, the determining each n-yuan Cangjie code character corresponding to each word specifically includes: determining words appearing in the corpus according to the result of word segmentation of the corpus;
respectively executing, for each of the determined mutually different words:
determining each n-yuan Cangjie code character corresponding to the word, and characterizing the n-yuan Cangjie code character corresponding to the word
The word is continuous n Cangjie code characters, and n is a positive integer or a plurality of different positive integers.
In the embodiment of the application, for the same word, the corresponding n-member cang jie code characters are also the same, so that for the step in the previous paragraph, the step is executed respectively for each determined word which is different from each other, and for the repeated word, the existing result can be directly used without repeated execution, thereby saving resources.
Further, considering that if the number of times a word appears in a corpus is too small, the training samples and training times corresponding to the training based on the corpus are also small, which may adversely affect the reliability of the training result, so that such words may be filtered out and not trained for the time being. Training may be subsequently performed in other corpora.
Based on such a concept, the determining, according to the result of segmenting the corpus, the word appearing in the corpus may specifically include: and determining words which appear in the corpus and the occurrence frequency of which is not less than the set frequency according to the result of word segmentation of the corpus. The specific number of times of setting can be determined according to actual conditions.
In the embodiment of the present application, for step S104, there may be a plurality of specific training manners, such as a training manner based on a context word, a training manner based on a designated synonym or synonym, and for convenience of understanding, the foregoing manner is taken as an example and is described in detail.
The training of the word vector and the Cangjie code character vector according to the word vector, the Cangjie code character vector and the corpus after word segmentation may specifically include: determining a designated word in the corpus after word segmentation and one or more context words of the designated word in the corpus after word segmentation; determining the similarity between the designated word and the context word according to the Cangjie code character vector of each n-element Cangjie code character corresponding to the designated word and the word vector of the context word; and updating the word vectors of the context words and the Cangjie code character vectors of the n-element Cangjie code characters corresponding to the specified words according to the similarity between the specified words and the context words.
The specific manner of determining the similarity is not limited in this application. For example, the similarity may be calculated based on an angle cosine operation of the vectors, the similarity may be calculated based on a sum of squares operation of the vectors, and so on.
The designated word may be plural, the designated word may be repeated and may have a different position in the corpus, and the processing action in the previous paragraph may be performed for each designated word. Preferably, each word included in the corpus after word segmentation can be taken as a designated word.
In the embodiment of the present application, the training in step S104 may be such that: the similarity between a given word and a context word is relatively high (here, the similarity may reflect the degree of association, the degree of association between the word and the context word is relatively high, and the context words corresponding to the words having the same or similar meanings are often the same or similar), while the similarity between the given word and a non-context word is relatively low, and the non-context word may be used as a negative example word described below, and the context word may be used as a positive example word relatively.
It can be seen that some negative examples need to be determined as a contrast during the training process. One or more words can be randomly selected from the corpus after word segmentation as the negative sample words, and non-context words can also be strictly selected as the negative sample words. Taking the former way as an example, the updating the word vector of the contextual word and the Cangjie code character vector of each n-yuan Cangjie code character corresponding to the specified word according to the similarity between the specified word and the contextual word may specifically include: selecting one or more words from the words as negative sample words; determining the similarity between the specified word and each negative sample word; determining a loss characteristic value corresponding to the designated word according to the designated loss function, the similarity between the designated word and the upper and lower words and the similarity between the designated word and each negative sample word; and updating the word vectors of the context words and the Cangjie code character vectors of each n-element Cangjie code character corresponding to the specified word according to the loss characterization values.
Wherein, the loss characterization value is used for measuring the error degree between the current vector value and the training target. The parameters of the loss function may use the above-mentioned similarities as parameters, and the specific loss function expression is not limited in this application, and will be exemplified in detail later.
In the embodiment of the application, the word vector and the Cangjie code character vector are updated to actually correct the error degree. When the solution of the present application is implemented using a neural network, such a correction can be implemented based on back propagation and gradient descent methods. In this case, the gradient is the gradient corresponding to the loss function.
Updating the word vector of the specified word and the Cangjie code character vector of each n-yuan Cangjie code character corresponding to the specified word according to the loss characterization value, which may specifically include: determining a gradient corresponding to the loss function according to the loss characterization value; and updating the word vectors of the upper and lower words and the Cangjie code character vectors of each n-element Cangjie code character corresponding to the specified word according to the gradient.
In this embodiment of the present application, the training process for the word vector and the Cangjie code character vector may be performed iteratively based on at least part of words in the corpus after word segmentation, so that the word vector and the Cangjie code character vector may gradually converge until the training is completed.
Take training based on all words in the corpus after word segmentation as an example. For step S104, the training of the word vector and the cang jie code character vector according to the word vector, the cang jie code character vector, and the corpus after word segmentation may specifically include:
traversing the corpus after word segmentation, and respectively executing each word in the corpus after word segmentation:
determining one or more context words of the word in the corpus after word segmentation;
respectively executing the following steps according to each context word:
determining the similarity between the word and the context word according to the Cangjie code character vector of each n-element Cangjie code character corresponding to the word and the word vector of the context word;
and updating the word vector of the context word and the Cangjie code character vector of each n-element Cangjie code character corresponding to the word according to the similarity between the word and the context word.
The above description of how to update the data is described in detail, and is not repeated.
Further, to facilitate computer processing, the above traversal process may be implemented on a window basis.
For example, the determining one or more context words in the corpus after the word segmentation may specifically include: in the corpus after word segmentation, establishing a window by sliding the distance of a specified number of words leftwards and/or rightwards by taking the word as a center; and determining the words except the word in the window as the contextual words of the word.
Of course, a window with a set length may also be established with the first word of the corpus after word segmentation as the starting position, and the window includes the first word and a subsequent continuous set number of words; and after processing each word in the window, sliding the window backwards to process the next batch of words in the corpus until traversing the corpus.
The word vector processing method provided in the embodiment of the present application is explained above. For convenience of understanding, based on the above description, the embodiment of the present application further provides a flowchart of a specific implementation of the word vector processing method in an actual application scenario, as shown in fig. 2.
The process in fig. 2 mainly comprises the following steps:
step 1, using a word segmentation tool to segment Chinese linguistic data, scanning the segmented Chinese linguistic data, counting all the appeared words to establish a vocabulary table, and deleting the words with the appearance frequency less than b times (namely, the set frequency); skipping to the step 2;
step 2, scanning the vocabulary tables one by one, extracting n-yuan Cangjie code characters corresponding to each word, establishing an n-yuan Cangjie code character table and a mapping table of the words and the corresponding n-yuan Cangjie code characters; skipping to step 3;
step 3, establishing a word vector with dimension d for each word in the vocabulary table, establishing a Cangjie code character vector with dimension d for each n-element Cangjie code character in the n-element Cangjie code character table, and randomly initializing all established vectors; skipping to the step 4;
step 4, sliding one by one from the first word in the Chinese corpus in which word segmentation is completed, selecting one word each time as a current word w (namely, the designated word), and ending if w traverses all words in the whole corpus; otherwise, skipping to step 5;
step 5, taking the current word w as a center, sliding k words to two sides to establish a window, selecting one word as a context word c from the first word to the last word (except the current word w) in the window every time, and jumping to the step 4 if c traverses all words in the window; otherwise, jumping to step 6;
and 6, for the current word w, finding each n-element Cangjie code character corresponding to the current word w according to the word in the step 2 and the corresponding n-element Cangjie code character mapping table, and calculating the similarity between the current word w and the context word c according to the formula (1):
Figure BDA0001317253400000111
wherein, S in the formula represents the n-ary Cangjie code character table established in step 2, S (w) represents the n-ary Cangjie code character set corresponding to the current word w in the mapping table in step 2, and q represents the element (i.e. a certain n-ary Cangjie code character) in the set S (w). sim (w, c) represents the similarity score of the current word w and the context word c;
Figure BDA0001317253400000121
representing the vector dot product operation of the n-element cang jie code character q and the context word c; skipping to step 7;
step 7, randomly extracting λ words as negative sample words, and calculating a loss score l (w, c) according to formula (2) (i.e., the loss function), where the loss score can be used as the loss characterization value:
Figure BDA0001317253400000122
where log is a logarithmic function, c' is a randomly drawn negative sample term, and Ec'∈p(V)[x]The expectation value of the expression x is shown in the case that the randomly extracted negative sample word c' satisfies the probability distribution p (v), and σ (·) is a neural network excitation function, which is shown in detail in formula (3):
Figure BDA0001317253400000123
wherein if x is a real number, then σ (x) is also a real number; calculating gradient according to l (w, c) value, and updating n-element Bijiangcode character vector
Figure BDA0001317253400000124
And vectors of contextual words
Figure BDA0001317253400000125
And skipping to step 5.
In the steps 1 to 7, the step 6 and the step 7 are more critical steps. For ease of understanding, this is illustrated in connection with fig. 3.
Fig. 3 is a schematic diagram of related processing actions of a part of corpora used in the process of fig. 2 according to an embodiment of the present application.
As shown in fig. 3, it is assumed that there is a sentence "governing haze and cannot be relaxed" in the corpus, and the word segmentation obtains three words "governing", "haze" and "curving and cannot be relaxed" in the sentence.
Assuming that "haze" is selected as the current word w at this time, and "governing" is selected as the context word c, all n-element cang jie code characters s (w) mapped by the current word w are extracted, for example, the 5-element cang jie code characters mapped by "haze" include "MBHES", "BHESM", "hemsm", "ESMBB", and the like, and the 5-element cang jie code characters mapped by "governing" include "EIRMG", "IRMGW", "RMGWG". And then, calculating loss scores l (w, c) according to a formula (1), a formula (2) and a formula (3), and further calculating gradients so as to update the word vectors of c and all the Cangjie code character vectors corresponding to w.
Based on the same inventive idea as fig. 1 and the embodiment in fig. 2, the present application provides another word vector processing method.
Fig. 4 is a flowchart illustrating another word vector processing method according to an embodiment of the present application.
The flow in fig. 4 may include the following steps:
step 1, segmenting words of a corpus, and establishing a vocabulary list formed by all words obtained through segmenting the words, wherein all the words do not comprise the words with the occurrence frequency less than the set frequency in the corpus; skipping to the step 2;
step 2, establishing an n-element Cangjie code character mapping table according to the vocabulary table, wherein the mapping table comprises the mapping relation between each word and the n-element Cangjie code characters, and the n-element Cangjie code characters represent continuous n Cangjie code characters of the mapped words; skipping to step 3;
step 3, establishing and initializing word vectors of all the words and cang-jie code character vectors of all the n-yuan cang-jie code characters mapped by all the words according to the n-yuan cang-jie code character mapping table; skipping to the step 4;
step 4, traversing the corpus after word segmentation, respectively taking each traversed word as a current word w, and executing step 5 on the current word w, if the traversal is finished, ending, otherwise, continuing the traversal;
step 5, taking the current word w as a center, respectively sliding at most k words to two sides to establish windows, traversing all words except the current word w in the windows, respectively taking each traversed word as a current contextual word c of the current word w, and executing step 6 on the current contextual word c, if the traversal is completed, continuing the execution of step 4, otherwise, continuing the traversal;
step 6, calculating the similarity between the current word w and the current contextual word c according to the following formula:
Figure BDA0001317253400000131
wherein, s (w) represents each n-member Cangjie code character set mapped by the current word w in the n-member Cangjie code character mapping table, q represents each n-member Cangjie code character in s (w), and sim (w, c) represents the similarity between the current word w and the current context word c;
Figure BDA0001317253400000132
a vector dot product of the Cangjie code character vector representing q and the word vector of the current context word c; skipping to step 7;
and 7, randomly extracting lambda words as negative sample words, and calculating corresponding loss characteristic values l (w, c) according to the following loss functions:
Figure BDA0001317253400000141
where c' is a randomly drawn negative sample word, and Ec'∈p(V)[x]The expected value of the expression x is the neural network excitation function defined as the expected value of the expression x when the randomly extracted negative sample word c' satisfies the probability distribution p (V)
Figure BDA0001317253400000142
Calculating the gradient corresponding to the loss function according to the calculated loss characterization value l (w, c), and performing Chinese character conversion on the long-distance channel of q according to the gradient
Figure BDA0001317253400000143
And word vector for current context word c
Figure BDA0001317253400000144
And (6) updating.
The steps in the another word vector processing method may be executed by the same module or different modules, and this application is not limited in this respect.
It should be noted that, besides the Chai code, other characters or word codes that can represent the morphological characteristics of the word are also applicable to the scheme of the present application, for example, the zheng code of chinese character, etc., and the Chai code in each of the above schemes can be replaced by the code.
Based on the same inventive concept, the word vector processing method provided in the embodiment of the present application further provides a corresponding apparatus, as shown in fig. 5.
Fig. 5 is a schematic structural diagram of a word vector processing apparatus corresponding to fig. 1 according to an embodiment of the present application, where the apparatus may be located in an execution body of the process in fig. 1, and includes:
a word segmentation module 501 for segmenting words of the speech to obtain words;
a determining module 502, configured to determine each n-ary cang jie code character corresponding to each word, where the n-ary cang jie code character represents n consecutive cang jie code characters of the corresponding word;
the initialization module 503 is configured to establish and initialize word vectors of the words and Cangjie code character vectors of the n-yuan Cangjie code characters corresponding to the words;
the training module 504 trains the word vector and the Cangjie code character vector according to the word vector, the Cangjie code character vector and the corpus after word segmentation.
Optionally, the determining module 502 determines each n-member changjie code character corresponding to each word, which specifically includes:
the determining module 502 determines the words appearing in the corpus according to the result of segmenting the corpus;
performing, separately for each word of the determination:
determining each n-yuan Cangjie code character corresponding to the word, and characterizing the n-yuan Cangjie code character corresponding to the word
The word is continuous n Cangjie code characters, and n is a positive integer or a plurality of different positive integers.
Optionally, the determining module 502 determines, according to the result of segmenting the corpus, the word appearing in the corpus, which specifically includes:
the determining module 502 determines words that appear in the corpus and the occurrence frequency is not less than the set frequency according to the result of segmenting the corpus.
Optionally, the initializing module 503 initializes the word vector of each word and the Cangjie code character vector of each n-member Cangjie code character corresponding to each word, and specifically includes:
the initialization module 503 initializes the word vectors of the words and the Cangjie code character vectors of the n-ary Cangjie code characters corresponding to the words in a random initialization manner or an initialization manner according to a designated probability distribution, wherein the Cangjie code character vectors of the same n-ary Cangjie code character are also the same.
Optionally, the training module 504 trains the word vector and the cang jie code character vector according to the word vector, the cang jie code character vector, and the corpus after word segmentation, which specifically includes:
the training module 504 determines a specified word in the corpus after word segmentation and one or more context words in the corpus after word segmentation of the specified word;
determining the similarity between the designated word and the context word according to the Cangjie code character vector of each n-element Cangjie code character corresponding to the designated word and the word vector of the context word;
and updating the word vectors of the context words and the Cangjie code character vectors of the n-element Cangjie code characters corresponding to the specified words according to the similarity between the specified words and the context words.
Optionally, the training module 504 updates, according to the similarity between the specified word and the previous and following words, the word vector of the previous and following words and the Cangjie code character vector of each n-yuan Cangjie code character corresponding to the specified word, specifically including:
the training module 504 selects one or more words from the words as negative sample words;
determining the similarity between the specified word and each negative sample word;
determining a loss characteristic value corresponding to the designated word according to the designated loss function, the similarity between the designated word and the upper and lower words and the similarity between the designated word and each negative sample word;
and updating the word vectors of the context words and the Cangjie code character vectors of each n-element Cangjie code character corresponding to the specified word according to the loss characterization values.
Optionally, the training module 504 updates, according to the loss characterization value, the word vector of the contextual word and the Cangjie code character vector of each n-member Cangjie code character corresponding to the specified word, which specifically includes:
the training module 504 determines a gradient corresponding to the loss function according to the loss characterization value;
and updating the word vectors of the upper and lower words and the Cangjie code character vectors of each n-element Cangjie code character corresponding to the specified word according to the gradient.
Optionally, the training module 504 selects one or more words from the words as negative sample words, which specifically includes:
the training module 504 randomly selects one or more words from the words as negative sample words.
Optionally, the training module 504 trains the word vector and the cang jie code character vector according to the word vector, the cang jie code character vector, and the corpus after word segmentation, which specifically includes:
the training module 504 traverses the corpus after word segmentation, and executes the following steps for each word in the corpus after word segmentation:
determining one or more context words of the word in the corpus after word segmentation;
respectively executing the following steps according to each context word:
determining the similarity between the word and the context word according to the Cangjie code character vector of each n-element Cangjie code character corresponding to the word and the word vector of the context word;
and updating the word vector of the context word and the Cangjie code character vector of each n-element Cangjie code character corresponding to the word according to the similarity between the word and the context word.
Optionally, the training module 504 determines one or more context words in the corpus after the word is segmented, specifically including:
the training module 504 establishes a window by sliding the distance of a specified number of words left and/or right with the word as a center in the corpus after word segmentation;
and determining the words except the word in the window as the contextual words of the word.
Optionally, the word is a chinese word, the word vector is a word vector of a chinese word, and the long gap code character is a long gap code character.
Based on the same inventive concept, the embodiment of the present application further provides a corresponding electronic device, including:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to:
segmenting the corpus into words to obtain each word;
determining each n-element Cangjie code character corresponding to each word, wherein the n-element Cangjie code characters represent continuous n Cangjie code characters of the corresponding word;
establishing and initializing word vectors of the words and Cangjie code character vectors of the n-element Cangjie code characters corresponding to the words;
and training the word vector and the Cangjie code character vector according to the word vector, the Cangjie code character vector and the corpus after word segmentation.
Based on the same inventive concept, embodiments of the present application further provide a corresponding non-volatile computer storage medium, in which computer-executable instructions are stored, where the computer-executable instructions are configured to:
segmenting the corpus into words to obtain each word;
determining each n-element Cangjie code character corresponding to each word, wherein the n-element Cangjie code characters represent continuous n Cangjie code characters of the corresponding word;
establishing and initializing word vectors of the words and Cangjie code character vectors of the n-element Cangjie code characters corresponding to the words;
and training the word vector and the Cangjie code character vector according to the word vector, the Cangjie code character vector and the corpus after word segmentation.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the embodiments of the apparatus, the electronic device, and the nonvolatile computer storage medium, since they are substantially similar to the embodiments of the method, the description is simple, and the relevant points can be referred to the partial description of the embodiments of the method.
The apparatus, the electronic device, the nonvolatile computer storage medium and the method provided in the embodiment of the present application correspond to each other, and therefore, the apparatus, the electronic device, and the nonvolatile computer storage medium also have similar advantageous technical effects to the corresponding method.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose Logic functions are determined by programming the Device by a user. A digital system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Furthermore, nowadays, instead of manually making an integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development and writing, but the original code before compiling is also written by a specific Programming Language, which is called Hardware Description Language (HDL), and HDL is not only one but many, such as abel (advanced Boolean Expression Language), ahdl (alternate Language Description Language), traffic, pl (core unified Programming Language), HDCal, JHDL (Java Hardware Description Language), langue, Lola, HDL, laspam, hardsradware (Hardware Description Language), vhjhd (Hardware Description Language), and vhigh-Language, which are currently used in most common. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic for the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller as pure computer readable program code, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may thus be considered a hardware component, and the means included therein for performing the various functions may also be considered as a structure within the hardware component. Or even means for performing the functions may be regarded as being both a software module for performing the method and a structure within a hardware component.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functionality of the units may be implemented in one or more software and/or hardware when implementing the present application.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (22)

1. A method of word vector processing, comprising:
segmenting the corpus into words to obtain each word;
determining each n-element Cangjie code character corresponding to each word, wherein the n-element Cangjie code characters represent continuous n Cangjie code characters of the corresponding word;
establishing and initializing word vectors of the words and Cangjie code character vectors of the n-element Cangjie code characters corresponding to the words;
training the word vector and the Cangjie code character vector according to the word vector, the Cangjie code character vector and the corpus after word segmentation;
the words are Chinese words, and the word vectors are word vectors of the Chinese words.
2. The method of claim 1, wherein said determining each n-member changjie code character corresponding to said each word specifically comprises:
determining words appearing in the corpus according to the result of word segmentation of the corpus;
respectively aiming at each determined word different from each other, executing:
determining each n-element Cangjie code character corresponding to the word, wherein the n-element Cangjie code character corresponding to the word represents n continuous Cangjie code characters of the word, and n is a positive integer or a plurality of different positive integers.
3. The method according to claim 2, wherein said determining the words appearing in said corpus according to the result of said corpus participling specifically comprises:
and determining words which appear in the corpus and the occurrence frequency of which is not less than the set frequency according to the result of word segmentation of the corpus.
4. The method according to claim 1, wherein the initializing the word vector of each word and the Cangjie code character vector of each n-member Cangjie code character corresponding to each word specifically comprises:
initializing the word vector of each word and the Cangjie code character vector of each n-element Cangjie code character corresponding to each word by adopting a random initialization mode or a specified probability distribution initialization mode, wherein the Cangjie code character vectors of the same n-element Cangjie code character are also the same.
5. The method according to claim 1, wherein the training of the word vector and the Cangjie code character vector according to the word vector, the Cangjie code character vector, and the corpus after word segmentation specifically comprises:
determining a designated word in the corpus after word segmentation and one or more context words of the designated word in the corpus after word segmentation;
determining the similarity between the designated word and the context word according to the Cangjie code character vector of each n-element Cangjie code character corresponding to the designated word and the word vector of the context word;
and updating the word vectors of the context words and the Cangjie code character vectors of the n-element Cangjie code characters corresponding to the specified words according to the similarity between the specified words and the context words.
6. The method according to claim 5, wherein the updating, according to the similarity between the specified word and the context word, the word vector of the context word and the cang jie code character vector of each n-ary cang jie code character corresponding to the specified word specifically includes:
selecting one or more words from the words as negative sample words;
determining the similarity between the specified word and each negative sample word;
determining a loss characteristic value corresponding to the designated word according to the designated loss function, the similarity between the designated word and the upper and lower words and the similarity between the designated word and each negative sample word;
and updating the word vectors of the context words and the Cangjie code character vectors of each n-element Cangjie code character corresponding to the specified word according to the loss characterization values.
7. The method according to claim 6, wherein the updating, according to the loss characterization value, the word vector of the context word and the Cangjie code character vector of each n-member Cangjie code character corresponding to the specified word includes:
determining a gradient corresponding to the loss function according to the loss characterization value;
and updating the word vectors of the upper and lower words and the Cangjie code character vectors of each n-element Cangjie code character corresponding to the specified word according to the gradient.
8. The method according to claim 6, wherein the selecting one or more words from the words as negative sample words specifically comprises:
and randomly selecting one or more words from the words to serve as negative sample words.
9. The method according to claim 1, wherein the training of the word vector and the Cangjie code character vector according to the word vector, the Cangjie code character vector, and the corpus after word segmentation specifically comprises:
traversing the corpus after word segmentation, and respectively executing each word in the corpus after word segmentation:
determining one or more context words of the word in the corpus after word segmentation;
respectively executing the following steps according to each context word:
determining the similarity between the word and the context word according to the Cangjie code character vector of each n-element Cangjie code character corresponding to the word and the word vector of the context word;
and updating the word vector of the context word and the Cangjie code character vector of each n-element Cangjie code character corresponding to the word according to the similarity between the word and the context word.
10. The method according to claim 9, wherein said determining one or more contextual words in said corpus after word segmentation of said word specifically comprises:
in the corpus after word segmentation, establishing a window by sliding the distance of a specified number of words leftwards and/or rightwards by taking the word as a center;
and determining the words except the word in the window as the contextual words of the word.
11. A word vector processing apparatus comprising:
the word segmentation module is used for segmenting words of the speech to obtain each word;
the determining module is used for determining each n-element Cangjie code character corresponding to each word, and the n-element Cangjie code characters represent continuous n Cangjie code characters of the corresponding word;
the initialization module is used for establishing and initializing word vectors of all the words and Cangjie code character vectors of all the n-element Cangjie code characters corresponding to all the words;
the training module is used for training the word vector and the Cangjie code character vector according to the word vector, the Cangjie code character vector and the corpus after word segmentation;
the words are Chinese words, and the word vectors are word vectors of the Chinese words.
12. The apparatus according to claim 11, wherein the determining module determines each n-member jejun code character corresponding to each word, specifically comprising:
the determining module determines words appearing in the corpus according to the result of word segmentation of the corpus;
respectively aiming at each determined word different from each other, executing:
determining each n-element Cangjie code character corresponding to the word, wherein the n-element Cangjie code character corresponding to the word represents n continuous Cangjie code characters of the word, and n is a positive integer or a plurality of different positive integers.
13. The apparatus according to claim 12, wherein the determining module determines the word appearing in the corpus according to the result of segmenting the corpus, specifically comprising:
and the determining module determines words which appear in the corpus and the occurrence frequency of which is not less than the set frequency according to the result of segmenting the corpus.
14. The apparatus according to claim 11, wherein the initialization module initializes the word vector of each word and the Cangjie code character vector of each n-ary Cangjie code character corresponding to each word, specifically includes:
the initialization module initializes the word vectors of the words and the Cangjie code character vectors of the n-element Cangjie code characters corresponding to the words in a random initialization mode or an initialization mode according to the appointed probability distribution, wherein the Cangjie code character vectors of the same n-element Cangjie code characters are also the same.
15. The apparatus according to claim 11, wherein the training module trains the word vector and the Cangjie code character vector according to the word vector, the Cangjie code character vector, and the corpus after word segmentation, and specifically includes:
the training module determines a specified word in the corpus after word segmentation and one or more context words of the specified word in the corpus after word segmentation;
determining the similarity between the designated word and the context word according to the Cangjie code character vector of each n-element Cangjie code character corresponding to the designated word and the word vector of the context word;
and updating the word vectors of the context words and the Cangjie code character vectors of the n-element Cangjie code characters corresponding to the specified words according to the similarity between the specified words and the context words.
16. The apparatus according to claim 15, wherein the training module updates the word vector of the context word and the Cangjie code character vector of each n-member Cangjie code character corresponding to the specified word according to the similarity between the specified word and the context word, specifically including:
the training module selects one or more words from the words as negative sample words;
determining the similarity between the specified word and each negative sample word;
determining a loss characteristic value corresponding to the designated word according to the designated loss function, the similarity between the designated word and the upper and lower words and the similarity between the designated word and each negative sample word;
and updating the word vectors of the context words and the Cangjie code character vectors of each n-element Cangjie code character corresponding to the specified word according to the loss characterization values.
17. The apparatus according to claim 16, wherein the training module updates, according to the loss characterization value, the word vector of the contextual word and the cang-chang-code character vector of each n-ary cang-chang-code character corresponding to the specified word, specifically including:
the training module determines a gradient corresponding to the loss function according to the loss characterization value;
and updating the word vectors of the upper and lower words and the Cangjie code character vectors of each n-element Cangjie code character corresponding to the specified word according to the gradient.
18. The apparatus according to claim 16, wherein the training module selects one or more words from the words as negative sample words, and specifically includes:
and the training module randomly selects one or more words from the words to serve as negative sample words.
19. The apparatus according to claim 11, wherein the training module trains the word vector and the Cangjie code character vector according to the word vector, the Cangjie code character vector, and the corpus after word segmentation, and specifically includes:
the training module traverses the corpus after word segmentation, and executes the following steps for each word in the corpus after word segmentation respectively:
determining one or more context words of the word in the corpus after word segmentation;
respectively executing the following steps according to each context word:
determining the similarity between the word and the context word according to the Cangjie code character vector of each n-element Cangjie code character corresponding to the word and the word vector of the context word;
and updating the word vector of the context word and the Cangjie code character vector of each n-element Cangjie code character corresponding to the word according to the similarity between the word and the context word.
20. The apparatus according to claim 19, wherein the training module determines one or more context words in the corpus after the word segmentation, and specifically includes:
the training module establishes a window by sliding the distance of a specified number of words leftwards and/or rightwards by taking the word as a center in the corpus after word segmentation;
and determining the words except the word in the window as the contextual words of the word.
21. A method of word vector processing, comprising:
step 1, segmenting words of a corpus, and establishing a vocabulary list formed by all words obtained through segmenting the words, wherein all the words do not comprise the words with the occurrence frequency less than the set frequency in the corpus; skipping to the step 2;
step 2, establishing an n-element Cangjie code character mapping table according to the vocabulary table, wherein the mapping table comprises the mapping relation between each word and the n-element Cangjie code characters, and the n-element Cangjie code characters represent continuous n Cangjie code characters of the mapped words; skipping to step 3;
step 3, establishing and initializing word vectors of all the words and cang-jie code character vectors of all the n-yuan cang-jie code characters mapped by all the words according to the n-yuan cang-jie code character mapping table; skipping to the step 4;
step 4, traversing the corpus after word segmentation, respectively taking each traversed word as a current word w, and executing step 5 on the current word w, if the traversal is finished, ending, otherwise, continuing the traversal;
step 5, taking the current word w as a center, respectively sliding at most k words to two sides to establish windows, traversing all words except the current word w in the windows, respectively taking each traversed word as a current contextual word c of the current word w, and executing step 6 on the current contextual word c, if the traversal is completed, continuing the execution of step 4, otherwise, continuing the traversal;
step 6, calculating the similarity between the current word w and the current contextual word c according to the following formula:
Figure FDA0002596396220000061
wherein, s (w) represents each n-member Cangjie code character set mapped by the current word w in the n-member Cangjie code character mapping table, q represents each n-member Cangjie code character in s (w), and sim (w, c) represents the similarity between the current word w and the current context word c;
Figure FDA0002596396220000071
a vector dot product of the Cangjie code character vector representing q and the word vector of the current context word c; skipping to step 7;
and 7, randomly extracting lambda words as negative sample words, and calculating corresponding loss characteristic values l (w, c) according to the following loss functions:
Figure FDA0002596396220000072
where c' is a randomly drawn negative sample word, and Ec'∈p(V)[x]The expected value of the expression x is the neural network excitation function defined as the expected value of the expression x when the randomly extracted negative sample word c' satisfies the probability distribution p (V)
Figure FDA0002596396220000073
Calculating the gradient corresponding to the loss function according to the calculated loss characterization value l (w, c), and performing Chinese character conversion on the long-distance channel of q according to the gradient
Figure FDA0002596396220000074
And word vector for current context word c
Figure FDA0002596396220000075
And (6) updating.
22. An electronic device, comprising:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to:
segmenting the corpus into words to obtain each word;
determining each n-element Cangjie code character corresponding to each word, wherein the n-element Cangjie code characters represent continuous n Cangjie code characters of the corresponding word;
establishing and initializing word vectors of the words and Cangjie code character vectors of the n-element Cangjie code characters corresponding to the words;
training the word vector and the Cangjie code character vector according to the word vector, the Cangjie code character vector and the corpus after word segmentation;
the words are Chinese words, and the word vectors are word vectors of the Chinese words.
CN201710430490.2A 2017-06-09 2017-06-09 Word vector processing method and device and electronic equipment Active CN107247704B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710430490.2A CN107247704B (en) 2017-06-09 2017-06-09 Word vector processing method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710430490.2A CN107247704B (en) 2017-06-09 2017-06-09 Word vector processing method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN107247704A CN107247704A (en) 2017-10-13
CN107247704B true CN107247704B (en) 2020-09-08

Family

ID=60018874

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710430490.2A Active CN107247704B (en) 2017-06-09 2017-06-09 Word vector processing method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN107247704B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107957989B9 (en) * 2017-10-23 2021-01-12 创新先进技术有限公司 Cluster-based word vector processing method, device and equipment
CN111226223B (en) * 2017-10-26 2023-10-20 三菱电机株式会社 Word semantic relation estimation device and word semantic relation estimation method
CN108170663A (en) 2017-11-14 2018-06-15 阿里巴巴集团控股有限公司 Term vector processing method, device and equipment based on cluster

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW446901B (en) * 1999-06-17 2001-07-21 Inventec Corp Teaching method for breakdown input of Chinese characters and system thereof
CN101916159A (en) * 2010-07-30 2010-12-15 凌阳科技股份有限公司 Virtual input system utilizing remote controller
US8788508B2 (en) * 2011-03-28 2014-07-22 Microth, Inc. Object access system based upon hierarchical extraction tree and related methods
CN104778158A (en) * 2015-03-04 2015-07-15 新浪网技术(中国)有限公司 Method and device for representing text
WO2016008512A1 (en) * 2014-07-15 2016-01-21 Ibeezi Sprl Input of characters of a symbol-based written language
CN105631468A (en) * 2015-12-18 2016-06-01 华南理工大学 RNN-based automatic picture description generation method
CN106569998A (en) * 2016-10-27 2017-04-19 浙江大学 Text named entity recognition method based on Bi-LSTM, CNN and CRF

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW446901B (en) * 1999-06-17 2001-07-21 Inventec Corp Teaching method for breakdown input of Chinese characters and system thereof
CN101916159A (en) * 2010-07-30 2010-12-15 凌阳科技股份有限公司 Virtual input system utilizing remote controller
US8788508B2 (en) * 2011-03-28 2014-07-22 Microth, Inc. Object access system based upon hierarchical extraction tree and related methods
WO2016008512A1 (en) * 2014-07-15 2016-01-21 Ibeezi Sprl Input of characters of a symbol-based written language
CN104778158A (en) * 2015-03-04 2015-07-15 新浪网技术(中国)有限公司 Method and device for representing text
CN105631468A (en) * 2015-12-18 2016-06-01 华南理工大学 RNN-based automatic picture description generation method
CN106569998A (en) * 2016-10-27 2017-04-19 浙江大学 Text named entity recognition method based on Bi-LSTM, CNN and CRF

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
Chinese word spelling correction based on n-gram ranked inverted index list;Yeh Jui-Feng 等;《Proceedings of the Seventh SIGHAN Workshop on Chinese Language Processing》;20131031;43-48 *
Faster Segmentation-Free Handwritten Chinese Text Recognition with Character Decompositions;Bluche T 等;《2016 15th International Conference on Frontiers in Handwriting Recognition(ICFHR)》;20161026;正文第531页A章节、533页A章节及图1 *
基于云计算的嵌入式系统输入法研究与设计;杨露;《中国优秀硕士学位论文全文数据库 信息科技辑》;20150515(第05期);I137-79 *
问答系统中问题模式分类与相似度计算方法;周建政 等;《计算机工程与应用》;20140101(第01期);116-120 *

Also Published As

Publication number Publication date
CN107247704A (en) 2017-10-13

Similar Documents

Publication Publication Date Title
CN108345580B (en) Word vector processing method and device
CN108874765B (en) Word vector processing method and device
CN108170667B (en) Word vector processing method, device and equipment
WO2019084867A1 (en) Automatic answering method and apparatus, storage medium, and electronic device
CN107957989B (en) Cluster-based word vector processing method, device and equipment
CN107423269B (en) Word vector processing method and device
US11030411B2 (en) Methods, apparatuses, and devices for generating word vectors
TWI686713B (en) Word vector generating method, device and equipment
CN107247704B (en) Word vector processing method and device and electronic equipment
CN112528637B (en) Text processing model training method, device, computer equipment and storage medium
CN109960815A (en) A kind of creation method and system of nerve machine translation NMT model
CN112308113A (en) Target identification method, device and medium based on semi-supervision
CN108664141B (en) Input method with document context self-learning function
CN107577658B (en) Word vector processing method and device and electronic equipment
CN107562715B (en) Word vector processing method and device and electronic equipment
CN111091001B (en) Method, device and equipment for generating word vector of word
CN107844472B (en) Word vector processing method and device and electronic equipment
CN108681490B (en) Vector processing method, device and equipment for RPC information
CN115130621B (en) Model training method and device, storage medium and electronic equipment
CN110321433B (en) Method and device for determining text category
CN111539520A (en) Method and device for enhancing robustness of deep learning model
CN113343716B (en) Multilingual translation method, device, storage medium and equipment
CN115712734B (en) Sparse knowledge graph embedding method and device based on meta learning
CN112466278B (en) Voice recognition method and device and electronic equipment
CN107391489B (en) Text analysis method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20200925

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee after: Innovative advanced technology Co.,Ltd.

Address before: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee before: Advanced innovation technology Co.,Ltd.

Effective date of registration: 20200925

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee after: Advanced innovation technology Co.,Ltd.

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Patentee before: Alibaba Group Holding Ltd.

TR01 Transfer of patent right