CN107423269B - Word vector processing method and device - Google Patents

Word vector processing method and device Download PDF

Info

Publication number
CN107423269B
CN107423269B CN201710383929.0A CN201710383929A CN107423269B CN 107423269 B CN107423269 B CN 107423269B CN 201710383929 A CN201710383929 A CN 201710383929A CN 107423269 B CN107423269 B CN 107423269B
Authority
CN
China
Prior art keywords
word
words
vector
corner code
code character
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
CN201710383929.0A
Other languages
Chinese (zh)
Other versions
CN107423269A (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
Advanced New Technologies Co 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 Advanced New Technologies Co Ltd filed Critical Advanced New Technologies Co Ltd
Priority to CN201710383929.0A priority Critical patent/CN107423269B/en
Publication of CN107423269A publication Critical patent/CN107423269A/en
Application granted granted Critical
Publication of CN107423269B publication Critical patent/CN107423269B/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/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/126Character encoding

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Machine Translation (AREA)

Abstract

The embodiment of the application discloses a word vector processing method and device. The method comprises the following steps: segmenting the corpus into words to obtain each word; determining each n-element four-corner code character corresponding to each word, wherein the n-element four-corner code characters represent continuous n four-corner code characters of the corresponding word; establishing and initializing word vectors of the words and four-corner code character vectors of the n-element four-corner code characters corresponding to the words; and training the word vector and the quadrangle code character vector according to the word vector, the quadrangle 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 four-corner code characters corresponding to the word, especially the stroke space orientation 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
Technical Field
The present application relates to the field of computer software technologies, and in particular, to a word vector processing method and apparatus.
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 and a word vector processing device, 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 word vectors of generated 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 four-corner code character corresponding to each word, wherein the n-element four-corner code characters represent continuous n four-corner code characters of the corresponding word;
establishing and initializing word vectors of the words and four-corner code character vectors of the n-element four-corner code characters corresponding to the words;
and training the word vector and the quadrangle code character vector according to the word vector, the quadrangle 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 four-corner code character corresponding to each word, and the n-element four-corner code characters represent continuous n four-corner code characters of the corresponding word;
the initialization module is used for establishing and initializing word vectors of all the words and four-corner code character vectors of all n-element four-corner code characters corresponding to all the words;
and the training module is used for training the word vectors and the quadrangle code character vectors according to the word vectors, the quadrangle code character vectors and the linguistic data 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 four-corner code character mapping table according to the vocabulary table, wherein the mapping table comprises the mapping relation between each word and the n-element four-corner code characters, and the n-element four-corner code characters represent continuous n four-corner code characters of the mapped words; skipping to step 3;
step 3, establishing and initializing word vectors of the words and four-corner code character vectors of the n-element four-corner code characters mapped by the words according to the n-element four-corner 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 BDA0001305835620000031
wherein, s (w) represents each n-ary four-corner code character set mapped by the current word w in the n-ary four-corner code character mapping table, q represents each n-ary four-corner code character in s (w), sim (w, c) represents the similarity between the current word w and the current context word c;
Figure BDA0001305835620000032
a vector dot product of the four corner 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 BDA0001305835620000033
where c' is a randomly drawn negative sample word, and Ec'∈p(V)[x]Means that randomly extracted negative sample words c' satisfy probability distributionp(V) the expected value, σ (-) of the expression x is the neural network excitation function, defined as
Figure BDA0001305835620000034
Calculating the corresponding loss function according to the calculated loss characteristic value l (w, c)According to the gradient, a character vector of a quadrangle code of q
Figure BDA0001305835620000035
And word vector for current context word c
Figure BDA0001305835620000036
And (6) updating.
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 four-corner code characters corresponding to the word, particularly the stroke space orientation characteristics of the word can be expressed, and further the accuracy of the word vector of the Chinese word is favorably 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.
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 stroke space orientation features, such as Korean and Japanese, and for non-Chinese, corresponding encoding is required according to encoding rules of four-corner 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 four-corner code character corresponding to each word, wherein the n-element four-corner code characters represent continuous n four-corner code characters of the corresponding word.
The four-corner code is a code of the Chinese character, the coding principle of the four-corner code is to divide the basic strokes of the Chinese character into 10 kinds, which are respectively represented by ten numbers of 0 and 1-9, and the numbers corresponding to the strokes of the four corners of the Chinese character are sequentially selected to form a character sequence as the four-corner code corresponding to the Chinese character, wherein each character in the character sequence is a number, the character sequence can be called as a four-corner code character sequence, and each character is called as a four-corner code character. Generally, the corresponding four-corner code of each Chinese character comprises 5 digits, and sometimes a one-digit complement code is added at the end.
For example, the four-corner code of the character "man" is "80000", and the four-corner code of the character "min" is "77747".
Further, a chinese word generally consists of a plurality of chinese characters, and the four-corner code character sequence corresponding to the chinese word can also be obtained by sequentially connecting the four-corner codes of the plurality of chinese characters, and then the n-ary four-corner code character corresponding to the word is: the word corresponds to n continuous quadrangle code characters in the quadrangle code character sequence.
Following the above example, for the word "people", the corresponding four-corner code character sequence is "8000077747", from which it can be known that: the corresponding 3-element four-corner code characters are as follows: 800 (1 to 3 four corner code characters), 000 (2 to 4 four corner code characters), 747 (8 to 10 four corner code characters), and the like; the corresponding 4-element four-corner code characters are as follows: 8000 (1-4 quadrangle code characters), 0000 (2-5 quadrangle code characters), 0007 (3-6 quadrangle code characters), and the like; the corresponding 5-element four-corner code characters are as follows: 80000 (1 st to 5 th quadrangle code characters), "00007" (2 nd to 6 th quadrangle code characters), "00077" (3 rd to 7 th quadrangle code characters), and the like.
In the embodiment of the present application, the value of n may be dynamically adjustable. For the same word, when determining each n-ary four-corner code character corresponding to the word, the value of n may be only 1 (for example, only each 3-ary four-corner code character corresponding to the word is determined), or may be multiple (for example, each 3-ary four-corner code character and each 4-ary four-corner code character corresponding to the word are determined). When the value of n is exactly the total number of the four-corner code characters contained in the four-corner code character sequence corresponding to the character or the word, the n-element four-corner code character is exactly the four-corner code character sequence.
In the embodiment of the present application, the n-ary four-character code may be represented by a designated code other than a numeral for the convenience of computer processing. For example, different quadrangle code characters can be represented by different codes other than a number, and the n-ary quadrangle code character can be represented as a non-numeric code string, wherein the codes have a mapping relation with numbers or number sequences.
S103: and establishing and initializing a word vector of each word and a four-corner code character vector of each n-element four-corner code character corresponding to each word.
In the embodiment of the present application, a quadrangle code character vector refers to a vector for representing an n-ary quadrangle code character. Each n-gram character may be represented by a vector of tetragonal characters, as if each word were represented by a vector of words.
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 quadrangle code character vector. For example, each word vector and each quadrangle code character vector cannot be initialized to the same vector; for another example, the vector elements in some word vectors or quadrangle code character vectors cannot all take values of 0; and so on.
In this embodiment of the present application, a random initialization mode or an initialization mode according to a specified probability distribution may be adopted to initialize the word vectors of the words and the four-corner code character vectors of the n-ary four-corner code characters corresponding to the words, where the four-corner code character vectors of the same n-ary four-corner code character 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 character vectors corresponding to some words have been trained based on other corpora before, then when the word vectors and character vectors corresponding to these words are trained based on the corpora in fig. 1, the word vectors and character vectors corresponding to these words may not be re-established and initialized, but rather, the word vectors and character vectors corresponding to these words may be trained based on the corpora in fig. 1 and the previous training results.
S104: and training the word vector and the quadrangle code character vector according to the word vector, the quadrangle 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-ary four-corner code characters corresponding to the word can be used for more finely representing the characteristics of the word, particularly representing the stroke space orientation 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 application, for step S102, the determining each n-ary four-corner 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:
and determining each n-element four-corner code character corresponding to the word, wherein the n-element four-corner code character corresponding to the word represents n continuous four-corner code characters of the word, 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-element four-corner code characters are also the same, so that for the steps in the previous section, the steps are executed respectively for each determined word which is different from each other, and for repeated words, the existing results 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 quadrangle code character vector according to the word vector, the quadrangle 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 four-corner code character vector of each n-element four-corner 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 four-corner code character vectors of the n-element four-corner 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 a previous way as an example, the updating, according to the similarity between the specified word and the previous and next words, the word vector of the previous and next words and the four corner code character vector of each n-ary four corner code character corresponding to the specified 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 four-corner code character vectors of the n-element four-corner code characters corresponding to the specified words 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 present application, the word vector and the quadrangle code character vector are updated to actually correct the degree of error. 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.
Then, updating the word vector of the specified word and the four-corner code character vector of each n-ary four-corner code character corresponding to the specified word according to the loss characterization value 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 four-corner code character vectors of the n-element four-corner code characters corresponding to the specified words according to the gradient.
In this embodiment of the present application, the training process for the word vector and the four-corner 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 four-corner 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 quadrangle code character vector according to the word vector, the quadrangle 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 upper and lower words according to the four-corner code character vector of each n-element four-corner code character corresponding to the word and the word vector of the upper and lower words;
and updating the word vector of the context word and the four-corner code character vector of each n-element four-corner 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 table one by one, extracting n-element four-corner code characters corresponding to each word, establishing an n-element four-corner code character table and a mapping table of the words and the corresponding n-element four-corner code characters; skipping to step 3;
step 3, establishing a word vector with the dimension of d for each word in the vocabulary table, establishing a four-corner code character vector with the dimension of d for each n-element four-corner code character in the n-element four-corner 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 four-corner code character corresponding to the current word w according to the word in the step 2 and the corresponding n-element four-corner code character mapping table, and calculating the similarity between the current word w and the context word c according to the formula (1):
Figure BDA0001305835620000111
wherein, S in the formula represents the n-ary quadrangle code character table established in step 2, S (w) represents the n-ary quadrangle code character set corresponding to the current word w in the mapping table in step 2, and q represents an element (i.e. a certain n-ary quadrangle 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 BDA0001305835620000112
expressing the vector dot product operation of the n-element four-corner 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 BDA0001305835620000113
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 BDA0001305835620000114
wherein if x is a real number, then σ (x) is also a real number; calculating gradient according to the value of l (w, c), and updating n-element quadrangle code character vector
Figure BDA0001305835620000115
And vectors of contextual words
Figure BDA0001305835620000116
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, and "governance" is selected as the context word c at this time, all n-element four-corner code characters s (w) mapped by the current word w are extracted, for example, the 5-element four-corner code characters of "haze" mapping include "10427", "04271", "42710", "27102", etc., and the 5-element four-corner code characters of "governance" mapping include "33160", "31601", "16016", "60161", etc. Then, the loss score l (w, c) is calculated according to the formula (1), the formula (2) and the formula (3), and then the gradient is calculated, so as to update the word vector of c and all the four-corner 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 four-corner code character mapping table according to the vocabulary table, wherein the mapping table comprises the mapping relation between each word and the n-element four-corner code characters, and the n-element four-corner code characters represent continuous n four-corner code characters of the mapped words; skipping to step 3;
step 3, establishing and initializing word vectors of the words and four-corner code character vectors of the n-element four-corner code characters mapped by the words according to the n-element four-corner 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 BDA0001305835620000131
wherein, s (w) represents each n-ary four-corner code character set mapped by the current word w in the n-ary four-corner code character mapping table, q represents each n-ary four-corner code character in s (w), sim (w, c) represents the similarity between the current word w and the current context word c;
Figure BDA0001305835620000132
a vector dot product of the four corner 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 BDA0001305835620000133
where c' is a randomly drawn negative sample word, and Ec'∈p(V)[x]Means that randomly extracted negative sample words c' satisfy probability distributionp(V) the expected value, σ (-) of the expression x is the neural network excitation function, defined as
Figure BDA0001305835620000134
Calculating the gradient corresponding to the loss function according to the calculated loss characterization value l (w, c), and according to the gradient, performing four-corner code character vector pair q
Figure BDA0001305835620000135
And word vector for current context word c
Figure BDA0001305835620000136
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 four-corner code, other characters or word codes that can express the stroke space orientation feature of the word are also applicable to the scheme of the present application, for example, five-stroke codes of chinese characters, etc., and the four-corner code in the above schemes may be replaced with 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 four-corner code character corresponding to each word, where the n-ary four-corner code character represents n consecutive four-corner code characters of the corresponding word;
the initialization module 503 is configured to establish and initialize a word vector of each word and a four-corner-code character vector of each n-ary four-corner-code character corresponding to each word;
the training module 504 trains the word vector and the quadrangle code character vector according to the word vector, the quadrangle code character vector, and the corpus after word segmentation.
Optionally, the determining module 502 determines each n-ary four-corner 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:
and determining each n-element four-corner code character corresponding to the word, wherein the n-element four-corner code character corresponding to the word represents n continuous four-corner code characters of the word, 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 four-corner code character vector of each n-ary four-corner code character corresponding to each word, and specifically includes:
the initialization module 503 initializes the word vectors of the words and the four-corner code character vectors of the n-ary four-corner code characters corresponding to the words in a random initialization manner or an initialization manner according to a designated probability distribution, wherein the four-corner code character vectors of the same n-ary four-corner code characters are also the same.
Optionally, the training module 504 trains the word vector and the quadrangle code character vector according to the word vector, the quadrangle code character vector, and the corpus after word segmentation, and 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 four-corner code character vector of each n-element four-corner 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 four-corner code character vectors of the n-element four-corner 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 next words, the word vector of the previous and next words and the four corner code character vector of each n-ary four corner 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 four-corner code character vectors of the n-element four-corner code characters corresponding to the specified words according to the loss characterization values.
Optionally, the training module 504 updates, according to the loss characterization value, the word vector of the context word and the four-corner-code character vector of each n-ary four-corner-code character corresponding to the specified word, specifically including:
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 four-corner code character vectors of the n-element four-corner code characters corresponding to the specified words 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 quadrangle code character vector according to the word vector, the quadrangle code character vector, and the corpus after word segmentation, and 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 upper and lower words according to the four-corner code character vector of each n-element four-corner code character corresponding to the word and the word vector of the upper and lower words;
and updating the word vector of the context word and the four-corner code character vector of each n-element four-corner 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 four-corner code character is a four-corner code character.
The device and the method provided by the embodiment of the application are in one-to-one correspondence, so the device also has the beneficial technical effects similar to the corresponding method, and the beneficial technical effects of the method are explained in detail above, so the beneficial technical effects of the corresponding device are not described again.
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 Hardware Description Language), traffic, pl (core universal Programming Language), HDCal (jhdware Description Language), lang, Lola, HDL, laspam, hardward Description Language (vhr Description Language), vhal (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 (21)

1. A method of word vector processing, comprising:
segmenting the corpus into words to obtain each word;
determining each n-element four-corner code character corresponding to each word, wherein the n-element four-corner code characters represent continuous n four-corner code characters of the corresponding word, and are used for expressing the stroke space orientation characteristics of the word;
establishing and initializing word vectors of the words and four-corner code character vectors of the n-element four-corner code characters corresponding to the words;
training the word vectors and the quadrangle code character vectors according to the word vectors, the quadrangle code character vectors and the linguistic data after word segmentation;
wherein, the determining of each n-ary four-corner 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:
and determining each n-element four-corner code character corresponding to the word, wherein the n-element four-corner code character corresponding to the word represents n continuous four-corner code characters of the word, and n is a positive integer or a plurality of different positive integers.
2. The method according to claim 1, 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.
3. The method according to claim 1, wherein the initializing the word vector of each word and the quadrangle code character vector of each n-ary quadrangle code character corresponding to each word specifically comprises:
and initializing the word vector of each word and the four-corner code character vector of each n-element four-corner code character corresponding to each word by adopting a random initialization mode or an initialization mode according to appointed probability distribution, wherein the four-corner code character vectors of the same n-element four-corner code character are also the same.
4. The method according to claim 1, wherein the training of the word vector and the quadcode character vector according to the word vector, the quadcode character vector, and the corpus after word segmentation 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 four-corner code character vector of each n-element four-corner 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 four-corner code character vectors of the n-element four-corner code characters corresponding to the specified words according to the similarity between the specified words and the context words.
5. The method according to claim 4, wherein the updating, according to the similarity between the specified word and the context word, the word vector of the context word and the four-corner-code-character vector of each n-ary four-corner-code character corresponding to the specified word 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 four-corner code character vectors of the n-element four-corner code characters corresponding to the specified words according to the loss characterization values.
6. The method according to claim 5, wherein the updating, according to the loss characterization value, the word vector of the context word and the quadrangle code character vector of each n-ary quadrangle 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 four-corner code character vectors of the n-element four-corner code characters corresponding to the specified words according to the gradient.
7. The method according to claim 5, 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.
8. The method according to claim 1, wherein the training of the word vector and the quadcode character vector according to the word vector, the quadcode character vector, and the corpus after word segmentation 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 upper and lower words according to the four-corner code character vector of each n-element four-corner code character corresponding to the word and the word vector of the upper and lower words;
and updating the word vector of the context word and the four-corner code character vector of each n-element four-corner code character corresponding to the word according to the similarity between the word and the context word.
9. The method according to claim 8, 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.
10. The method according to any one of claims 1 to 9, wherein the word is a chinese word, the word vector is a word vector of a chinese word, and the four-corner code characters are four-corner code characters.
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 four-corner code character corresponding to each word, wherein the n-element four-corner code characters represent continuous n four-corner code characters of the corresponding word, and the n-element four-corner code characters are used for expressing the stroke space orientation characteristics of the word;
the initialization module is used for establishing and initializing word vectors of all the words and four-corner code character vectors of all n-element four-corner code characters corresponding to all the words;
the training module is used for training the word vectors and the quadrangle code character vectors according to the word vectors, the quadrangle code character vectors and the linguistic data after word segmentation;
the determining module determines each n-ary four-corner code character corresponding to each word, and specifically includes:
the determining module determines 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:
and determining each n-element four-corner code character corresponding to the word, wherein the n-element four-corner code character corresponding to the word represents n continuous four-corner code characters of the word, and n is a positive integer or a plurality of different positive integers.
12. The apparatus according to claim 11, 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.
13. The apparatus according to claim 11, wherein the initializing module initializes the word vector of each word and the four-corner-code character vector of each n-ary four-corner-code character corresponding to each word, and specifically includes:
the initialization module initializes the word vector of each word and the four-corner code character vector of each n-element four-corner code character corresponding to each word in a random initialization mode or an initialization mode according to appointed probability distribution, wherein the four-corner code character vectors of the same n-element four-corner code character are also the same.
14. The apparatus according to claim 11, wherein the training module trains the word vector and the quadcode character vector according to the word vector, the quadcode 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 four-corner code character vector of each n-element four-corner 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 four-corner code character vectors of the n-element four-corner code characters corresponding to the specified words according to the similarity between the specified words and the context words.
15. The apparatus according to claim 14, wherein the training module updates, according to the similarity between the specified word and the context word, a word vector of the context word and a four-corner-code-character vector of each n-ary four-corner-code character corresponding to the specified 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 four-corner code character vectors of the n-element four-corner code characters corresponding to the specified words according to the loss characterization values.
16. The apparatus according to claim 15, wherein the training module updates, according to the loss characterization value, the word vector of the context word and the quadrangle code character vector of each n-ary quadrangle code character corresponding to the specified word, and specifically includes:
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 four-corner code character vectors of the n-element four-corner code characters corresponding to the specified words according to the gradient.
17. The apparatus according to claim 15, 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.
18. The apparatus according to claim 11, wherein the training module trains the word vector and the quadcode character vector according to the word vector, the quadcode 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 upper and lower words according to the four-corner code character vector of each n-element four-corner code character corresponding to the word and the word vector of the upper and lower words;
and updating the word vector of the context word and the four-corner code character vector of each n-element four-corner code character corresponding to the word according to the similarity between the word and the context word.
19. The apparatus according to claim 18, 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.
20. The apparatus of any one of claims 11 to 19, wherein the word is a chinese word, the word vector is a word vector of a chinese word, and the four corner code characters are four corner code characters.
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 four-corner code character mapping table according to the vocabulary table, wherein the mapping table comprises the mapping relation between each word and the n-element four-corner code characters, and the n-element four-corner code characters represent continuous n four-corner code characters of the mapped word, wherein the n-element four-corner code characters are used for expressing the stroke space orientation characteristics of the word; skipping to step 3;
step 3, establishing and initializing word vectors of the words and four-corner code character vectors of the n-element four-corner code characters mapped by the words according to the n-element four-corner 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 FDA0002745319200000061
wherein, s (w) represents each n-ary four-corner code character set mapped by the current word w in the n-ary four-corner code character mapping table, q represents each n-ary four-corner code character in s (w), sim (w, c) represents the similarity between the current word w and the current context word c;
Figure FDA0002745319200000075
a vector dot product of the four corner 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 FDA0002745319200000071
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 FDA0002745319200000072
Calculating the gradient corresponding to the loss function according to the calculated loss characterization value l (w, c), and according to the gradient, performing four-corner code character vector pair q
Figure FDA0002745319200000073
And word vector for current context word c
Figure FDA0002745319200000074
And (6) updating.
CN201710383929.0A 2017-05-26 2017-05-26 Word vector processing method and device Active CN107423269B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710383929.0A CN107423269B (en) 2017-05-26 2017-05-26 Word vector processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710383929.0A CN107423269B (en) 2017-05-26 2017-05-26 Word vector processing method and device

Publications (2)

Publication Number Publication Date
CN107423269A CN107423269A (en) 2017-12-01
CN107423269B true CN107423269B (en) 2020-12-18

Family

ID=60429134

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710383929.0A Active CN107423269B (en) 2017-05-26 2017-05-26 Word vector processing method and device

Country Status (1)

Country Link
CN (1) CN107423269B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110119507A (en) * 2018-02-05 2019-08-13 阿里巴巴集团控股有限公司 Term vector generation method, device and equipment
CN108595592A (en) * 2018-04-19 2018-09-28 成都睿码科技有限责任公司 A kind of text emotion analysis method based on five-stroke form code character level language model
CN111274793B (en) * 2018-11-19 2023-04-28 阿里巴巴集团控股有限公司 Text processing method and device and computing equipment
CN113220865B (en) * 2021-04-15 2022-06-24 山东师范大学 Text similar vocabulary retrieval method, system, medium and electronic equipment

Also Published As

Publication number Publication date
CN107423269A (en) 2017-12-01

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
CN107957989B (en) Cluster-based word vector processing method, device and equipment
WO2019084867A1 (en) Automatic answering method and apparatus, storage medium, and electronic device
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
CN111310441A (en) Text correction method, device, terminal and medium based on BERT (binary offset transcription) voice recognition
CN107402945B (en) Word stock generation method and device and short text detection method and device
CN107247704B (en) Word vector processing method and device and electronic equipment
CN112308113A (en) Target identification method, device and medium based on semi-supervision
CN112200132A (en) Data processing method, device and equipment based on privacy protection
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
CN116186272B (en) Combined training method and device, storage medium and electronic equipment
CN116340469B (en) Synonym mining method and device, storage medium and electronic equipment
CN114817469A (en) Text enhancement method, and training method and device of text enhancement model
CN115423485A (en) Data processing method, device and equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 1247338

Country of ref document: HK

TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20200923

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

Applicant after: Innovative advanced technology Co.,Ltd.

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

Applicant before: Advanced innovation technology Co.,Ltd.

Effective date of registration: 20200923

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

Applicant after: Advanced innovation technology Co.,Ltd.

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

Applicant before: Alibaba Group Holding Ltd.

GR01 Patent grant
GR01 Patent grant