WO2020082561A1 - 文本输入的预测方法、装置、计算机设备和存储介质 - Google Patents
文本输入的预测方法、装置、计算机设备和存储介质 Download PDFInfo
- Publication number
- WO2020082561A1 WO2020082561A1 PCT/CN2018/122814 CN2018122814W WO2020082561A1 WO 2020082561 A1 WO2020082561 A1 WO 2020082561A1 CN 2018122814 W CN2018122814 W CN 2018122814W WO 2020082561 A1 WO2020082561 A1 WO 2020082561A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- word vector
- predicted
- sample
- text
- loss function
- 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.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/279—Recognition of textual entities
- G06F40/289—Phrasal analysis, e.g. finite state techniques or chunking
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/274—Converting codes to words; Guess-ahead of partial word inputs
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
- G06N3/084—Backpropagation, e.g. using gradient descent
Definitions
- This application relates to the field of computer technology, and in particular to a text input prediction method, device, computer equipment, and storage medium.
- the recurrent neural network model is used to predict the text that the user may enter based on the text that the customer has entered.
- the Gaussian process fitting function is used in the training phase of the cyclic neural network model, but the Gaussian process requires a large amount of calculation and requires a kernel function set in advance to achieve the Gaussian process, resulting in the calculation efficiency of the text input prediction tool 3. Limited training efficiency.
- the main purpose of the present application is to provide a text input prediction method, device, computer equipment, and storage medium, aiming to solve the technical problem of low calculation efficiency of the traditional recurrent neural network model used for text input prediction.
- this application provides a text input prediction method, including:
- the target word vector is input into the prediction function in the neural process model to obtain predicted words.
- the step of selecting M word vectors from the sample word vectors into the neural process model to obtain the corresponding predicted word vectors includes:
- the neural process model is:
- x i is the input sample word vector
- y i is the predicted word vector output according to the input sample word vector x i
- p (z) is a multivariate normal distribution
- z is the global latent variable
- ⁇ 2 is random noise.
- the step of constructing a loss function according to the difference between the predicted word vector and the M + 1th sample word vector in the sample word vector sequence includes:
- the loss function is constructed according to the mean square error.
- the step of adjusting the parameters in the neural process model according to the loss function until the loss function satisfies a preset end condition, and the step of obtaining a prediction function includes:
- the loss function is greater than the preset threshold, perform a convex function optimization on the loss function
- the neural process model with adjusted parameters is used to recalculate the predicted word vector until the loss function constructed by the difference between the predicted word vector and the M + 1th sample word vector in the sample word vector sequence is less than or equal to Set the threshold.
- the step of obtaining training text and converting N words in the training text into corresponding N sample word vectors according to a preset dictionary to obtain a sample word vector sequence includes:
- the N words in the training text are converted into corresponding N sample word vectors according to a preset dictionary to obtain a sample word vector sequence.
- the step of inputting the target word vector into the prediction function to obtain a predicted word includes:
- the predicted word is set as the word corresponding to the standard word vector.
- the present application also provides a text processing device, which includes a model trainer and a text processor, and the model trainer includes:
- the first vectorization module is configured to obtain training text, and convert N words in the training text into corresponding N sample word vectors according to a preset dictionary to obtain a sample word vector sequence;
- the first input module is configured to select M sample word vectors from the sample word vector sequence to input a neural process model
- a first output module configured to output predicted word vectors corresponding to the M sample word vectors through the neural process model
- a difference judgment module configured to construct a loss function according to the difference between the predicted word vector and the M + 1th sample word vector in the sample word vector sequence
- An adjustment module configured to adjust parameters in the neural process model according to the loss function until the loss function meets a preset end condition
- the text processor includes:
- the second vectorization module is set to obtain target text and convert the target text into a corresponding target word vector according to a preset dictionary
- the second calculation module is configured to input the target word vector into the prediction function in the neural process model to obtain predicted words.
- the present application also provides a computer device, the computer device includes a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program is When the processor executes, the steps of the above method are implemented.
- the present application further provides a storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by the processor, the steps of the foregoing method are implemented.
- the text input prediction method, device, computer equipment, and storage medium proposed in the embodiments of the present application adopt the neural process model to train the training text, so that the process of setting the kernel function can be omitted to overcome other neural network Limitations on function design; at the same time, the efficient computing power of the neural process model is used to reduce the training time of the model.
- the prediction function obtained through the neural process model can predict the text to be input according to the target text, thereby improving the efficiency of text input by the user.
- FIG. 1 is a schematic structural diagram of a computer device in a hardware operating environment involved in an embodiment of the present application
- FIG. 2 is a schematic flowchart of a first embodiment of a text input prediction method of the application
- FIG. 3 is a schematic flowchart of a second embodiment of a text input prediction method of this application.
- FIG. 4 is a schematic flowchart of a third embodiment of a text input prediction method of this application.
- FIG. 5 is a schematic flowchart of a fourth embodiment of a text input prediction method of this application.
- FIG. 6 is a schematic flowchart of a fifth embodiment of a text input prediction method of this application.
- FIG. 7 is a schematic flowchart of a sixth embodiment of a text input prediction method of the present application.
- FIG. 1 is a schematic structural diagram of a computer device in a hardware operating environment involved in an embodiment of the present application.
- the computer device in the embodiment of the present application may specifically be a server, or may be a computer device with a data processing function such as a smart phone, tablet computer, or portable computer.
- the computer device may include a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005.
- the communication bus 1002 is configured to implement connection communication between these components.
- the user interface 1003 may include a display (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface.
- the network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface).
- the memory 1005 may be a high-speed RAM memory or a non-volatile memory (non-volatile memory), such as a disk memory.
- the memory 1005 may optionally be a storage device independent of the foregoing processor 1001.
- the computer device may also include an audio circuit, a WiFi module, a touch screen, etc., which will not be repeated here.
- the computer device can obtain the text data that needs to be processed by the user through the input unit through the input unit, and uses the acquired text data as the target text or training text.
- the computer device can also receive the text data that needs to be processed and sent by other devices through the network interface. , Use the received text data as the target text or training text; the computer device can also obtain the text data displayed on the display screen selected by the user through the input unit, and use the acquired text data as the training text.
- FIG. 1 does not constitute a limitation on the computer device, and may include more or less components than those illustrated, or combine certain components, or arrange different components.
- FIG. 2 is a schematic flowchart of a first embodiment of a text input prediction method of the present application.
- the text input prediction method includes:
- Step S100 obtaining training text, and converting N words in the training text into corresponding N sample word vectors according to a preset dictionary to obtain a sample word vector sequence;
- the training text is text data composed of multiple words according to language logic.
- Text data is a character string composed of more than one character in order.
- Target text such as "the weather is good today” or "my name is Wang Ping Pong”.
- the training text can be segmented first to obtain the words that constitute the training text, and then each word can be vectorized separately to obtain the word vector corresponding to each word, and then the sample word vectors can be combined in order to obtain the sample word vector sequence .
- the sample word vector sequence includes each sample word vector obtained by vectorizing each word in text form. The order of each sample word vector is consistent with the order in which the corresponding words appear in the target text. It can be understood that the sample word vector corresponding to the first word in the target text has the highest order in the sample word vector sequence.
- Word vectors are data used to express words in text form in mathematical form. For example, the text "simple" is expressed as the mathematical form "[00010000000 ...]", at this time, "[00010000000 ...
- 1" is the word vector of "weather"
- the text is not limited here What kind of word vector can be converted into a word in form, as long as the word in text form can be expressed mathematically. For example, if the target text is "My name is Wang Ping Pong", and the word segmentation is "I / ⁇ / ⁇ / ⁇ / ⁇ ⁇ ", then the word vector of the word " ⁇ ” is V1, and the word vector of " ⁇ " is V2 , The word vector of "Name” is V3, the word vector of "Yes” is V4, and the word vector of "Wang Ping Pong” is V5, then the word vectors included in the sample word vector sequence are V1, V2, V3, V4, V5 in sequence.
- step S200 M sample word vectors are selected from the sample word vector sequence and input into the neural process model to obtain corresponding predicted word vectors, where M ⁇ N;
- Neural Processes is one of the neural network models. Neural process models are machine learning models that need to be trained. Specifically, they can be learned through the logic of the order of the words in the sample text. The ability of input text to predict the next word to be input. That is, the neural process model can perform linear or nonlinear transformation on the input data through a series of parameters and operation logic to obtain the operation result. Parameters and operation logic can reflect the corresponding relationship between input and output.
- the neural process model is similar to the Gaussian process. It represents an infinite number of different functions at unobserved positions. Based on a certain amount of observations, the neural process model can capture the uncertainty of prediction, thereby achieving function approximation and obtaining predictions. The rule is to obtain the prediction function. Compared with the Gaussian process, the neural process model has high calculation efficiency. By learning the implicit kernel directly from the data to overcome the limitations of many function designs, that is, the neural process model can be set without setting the kernel function, thereby speeding up The efficiency of text prediction.
- the selection of the M sample word vectors is random. Each time step S200 is performed, the value of M is not necessarily the same, and the ranking positions of the words corresponding to the M sample word vectors in the sample text are not necessarily.
- Step S300 construct a loss function according to the difference between the predicted word vector and the M + 1th sample word vector in the sample word vector sequence;
- the predicted word vector is predicted by a neural network model, and the M + 1th sample word vector in the sample word vector sequence is actually present in the training text, that is, the M + 1th sample word vector is The true value of the relative predicted word vector.
- the computer device can construct a loss function according to the difference between the predicted word vector and the true value, and adjust the parameters in the neural network model according to the direction of minimizing the loss function, so that the output of the adjusted neural network model more meets the needs.
- Step S400 Adjust the parameters in the neural process model according to the loss function until the loss function meets a preset end condition
- the training process of the model needs to be repeated many times.
- the sample word vector sequence is input into the neural process model after adjustment of the parameters to calculate and predict Word vectors, that is, repeat steps S200 and S300 until the loss function meets the preset end condition and stop training.
- the loss function can reflect the accuracy of the prediction result output by the model. The smaller the loss function, the higher the accuracy of the prediction.
- Those skilled in the art can set a preset threshold corresponding to the loss function. When the loss function is less than the preset threshold, Stop training.
- a preset threshold corresponding to the number of times of repeating steps S200 and S300 may also be set, that is, a preset threshold corresponding to the number of iterations of the neural process model. When the number of iterations is greater than the preset threshold, the training is stopped.
- Step S500 Acquire target text, and convert the target text into a corresponding target word vector according to a preset dictionary
- Step S600 Input the target word vector into the prediction function in the neural process model to obtain predicted words.
- the target text is text data to be predicted.
- the user can input the target text through the input unit of the computer device to obtain the target text.
- the target text is vectorized according to the preset dictionary to form the target word vector, and then the predicted word vector is calculated by the prediction function, thereby obtaining the predicted word.
- Steps S100 to S500 can be run in the same computer device.
- steps S100 to S400 can be executed in one computer device, and step S500 can be executed in another computer device.
- steps S100 to S400 are run in the server to obtain the prediction function, and the server sends the prediction function to the mobile terminal used by the user.
- the mobile terminal used by the user receives the prediction function, and executes step S500 to obtain the predicted word.
- the training text is trained by using a neural process model, so that the process of setting the kernel function can be omitted to overcome the limitations of many neural network models in function design; while using the neural process model to efficiently Computing power to reduce the training time of the model.
- the prediction function obtained through the neural process model can predict the text to be input according to the target text, thereby improving the efficiency of text input by the user.
- FIG. 3 is a schematic flowchart of a second embodiment of a text input prediction method of the present application. Based on the foregoing embodiment, the step S200 includes:
- Step S210 obtaining a global latent variable according to the input sample word vector
- Global latent variables are latent variables that can be referenced by all objects or functions in the neural process model.
- Latent variables are observable variables. They are variables that cannot be directly observed, but can be inferred from other variables observed. Since the sample word vector x and the predicted word vector y corresponding to the sample word vector x cannot be directly derived to obtain the corresponding prediction function, a global latent variable z is introduced into the neural process model to derive the prediction function.
- Step S220 Obtain the corresponding predicted word vector according to the sample word vector and the global latent variable.
- step S210 since step S210 is performed, assuming that the word vector after the Mth sample word vector is unknown, the predicted word vector y is output by inputting the neural process model, that is, the sample word vector corresponding to the M + 1 item Make predictions, that is, assume that the sample word vector corresponding to the M + 1 item is unknown. It can be understood that, in step S210, the input sample word vector is to obtain the global latent variable z, and then the predicted word vector y will be obtained according to the global latent variable z.
- neural process model is:
- x i is the input sample word vector
- y i is the predicted word vector output according to the input sample word vector x i
- p (z) is a multivariate normal distribution
- z is the global latent variable
- ⁇ 2 is random noise.
- this logical process can be embodied by a function.
- the predicted word vector y can be obtained by.
- the function can be set, then the prediction function is obtained when obtained.
- FIG. 4 is a schematic flowchart of a third embodiment of a text input prediction method of the present application. Based on the foregoing embodiment, the step S300 includes:
- Step S310 calculating the mean square error of the M + 1th sample word vector in the predicted word vector and the sample word vector sequence
- y 1 is the predicted word vector output by the neural process model
- y 2 is the actual value, that is, the M + 1 item word vector.
- Step S320 construct the loss function according to the mean square error.
- the loss function (loss function) is used to estimate the degree of inconsistency between the model's predicted value f (x) and the true value y. It is a non-negative real value function, which is usually expressed by L (a, f (x)) The smaller the function, the better the accuracy of the model.
- the specific type of loss function used is not limited in this application.
- the loss function is constructed by comparing the difference between the predicted word vector and the true value, and the parameters in the neural process model are further modified by the loss function, so that the prediction function can achieve the purpose of fitting the distribution .
- FIG. 5 is a schematic flowchart of a fourth embodiment of a text input prediction method of the present application. Based on the foregoing embodiment, the step S400 includes:
- Step S410 Determine whether the loss function is greater than the preset threshold
- the preset threshold is a value set by a person skilled in the art according to actual needs.
- Step S420 if the loss function is greater than the preset threshold, perform a convex function optimization on the loss function
- step S500 is performed; if the mean square error is less than or equal to the preset threshold, it indicates the neural process model The difference between the output preset value and the real value meets the requirements, and the adjustment of the neural network model can be stopped.
- Convex function refers to a class of functions defined in real linear space. Convex function optimization is to minimize the loss function. The specific type of convex function optimization used is not limited in this application. In one embodiment, Adaptive Time Estimation (ADAM) is used for optimization. Compared with other adaptive learning rate algorithms, the ADAM optimization method converges faster and the learning effect is more effective. Problems in the optimization technology, such as the disappearance of the learning rate, the slow convergence, or the parameter update with high variance lead to large fluctuations in the loss function.
- ADAM Adaptive Time Estimation
- Step S430 Adjust the parameters in the neural process model according to the loss function optimized by the convex function
- the neural process model is:
- g (x i , z), ⁇ 2 ), g (x i in the neural process model can be adjusted according to the loss function optimized by the convex function , z), so that the fitted distribution is reached.
- step S440 the neural process model with adjusted parameters is used to recalculate the predicted word vector until the loss function constructed by the difference between the predicted word vector and the M + 1th sample word vector in the sequence of sample word vectors is less than or equal to The preset threshold.
- the parameter-adjusted neural process model is used to recalculate the predicted word vector, that is, the parameter-adjusted neural process model is used to repeat steps S200 and S300.
- FIG. 6 is a schematic flowchart of a fifth embodiment of a text input prediction method of the present application. Based on the foregoing embodiment, the step S100 includes:
- Step S110 obtaining training text
- Step S120 segment the training text according to part of speech and word length to obtain a word group
- word segmentation is the process of cutting a continuous character sequence into multiple individual characters or character sequences.
- Part of speech is data reflecting the type of content of the word.
- Part of speech includes part of speech such as adjective, preposition, predicate and noun.
- Word length is the number of characters contained in a word, part of speech and word length will greatly affect the corresponding meaning of the word, thereby affecting the prediction of the next word.
- the computer device may use a preset word segmentation method to perform word segmentation processing on the training text to obtain multiple characters or character sequences, and these characters or character sequences form word groups in the order in which they appear in the text.
- the computer device determines the corresponding part of speech of each word in the word sequence according to the preset vocabulary, and counts the corresponding word length of each word.
- the preset word segmentation method may be a character segmentation method based on character matching, semantic understanding, punctuation, or statistics.
- the computer device may set the word length threshold of the word obtained by the word segmentation, so that the word length of each word obtained by the word segmentation does not exceed the word length threshold.
- Step S130 Convert N words in the training text into corresponding N sample word vectors according to a preset dictionary to obtain a sample word vector sequence.
- the preset dictionary is a database or function pre-trained by a person skilled in the art to convert words into corresponding word vectors according to the preset dictionary.
- the corresponding word vectors of words with the same semantic meaning are also similar.
- the computer device vectorizes the word according to the content, part-of-speech and word length of each word to obtain the corresponding word vector of the word, thereby obtaining a sample word vector sequence composed of the sample word vector.
- the computer device can use the neural network model to convert words into word vectors.
- the type of neural network model that converts words into word vectors is not limited.
- FIG. 7 is a schematic flowchart of a sixth embodiment of a text input prediction method of the present application. Based on the foregoing embodiment, the step S600 includes:
- Step S610 according to the order of words corresponding to each target word vector in the target text, sequentially input the target word vector into the prediction function to obtain a predicted word vector;
- step S610 the user inputs character data into the computer device through the input unit, converts the words in the target text into corresponding target word vectors according to a preset dictionary, and the steps for obtaining the target word vector sequence can be referred to the embodiment Five steps S120 to S130.
- the prediction function is a distribution function that has been successfully trained and can reveal the logic of the context. Therefore, after inputting the target word vector, the predicted word vector corresponding to the target word vector can be calculated, that is, the word vector with the highest occurrence probability after the target word vector.
- Step S620 calculating the distance between the predicted word vector and each standard word vector in the preset dictionary
- the word vector itself is a high-dimensional vector, generally in dimensions ranging from tens of thousands to hundreds of thousands.
- the distance between word vectors can be calculated by cosine similarity or Euclidean distance. The closer the distance is, the higher the acquaintance. In this embodiment, the distance between word vectors is calculated using Euclidean distance.
- Euclidean distance refers to the arithmetic square root of the sum of squares of the difference between two word vectors in various dimensions.
- Step S630 Determine the standard word vector corresponding to the minimum value in the distance
- Step S640 Set the predicted word to the word corresponding to the standard word vector.
- the word corresponding to the predicted word vector can be obtained by predicting the word vector.
- the word is a predicted word that will be input after predicting the target text after analyzing the target text.
- an embodiment of the present application further proposes a text processing apparatus, including a model trainer and a text processor, and the model trainer includes:
- the first vectorization module 11 is configured to obtain training text, and convert N words in the training text into corresponding N sample word vectors according to a preset dictionary to obtain a sample word vector sequence;
- the first input module 12 is configured to select M sample word vectors from the sample word vector sequence to input a neural process model
- the first output module 13 is set to output the predicted word vector corresponding to the M sample word vectors by the neural process model
- the building module 14 is set to construct a loss function according to the difference between the predicted word vector and the M + 1th sample word vector in the sample word vector sequence;
- the adjustment module 15 is set to adjust the parameters in the neural process model according to the loss function until the loss function meets a preset end condition;
- the text processor includes:
- the second vectorization module 21 is set to obtain target text, and convert the target text into a corresponding target word vector according to a preset dictionary;
- the second calculation module 22 is configured to input the target word vector into the prediction function in the neural process model to obtain predicted words.
- the model trainer further includes a first calculation module 16, the first calculation module 16 is configured to obtain a global latent variable according to the input sample word vector;
- the first output module 13 is configured to obtain the corresponding predicted word vector according to the sample word vector and the global latent variable.
- the first calculation module 16 is further configured to calculate the mean square error of the M + 1th term vector in the predicted word vector and the sample word vector sequence;
- the construction module 14 is configured to construct the loss function
- the model trainer further includes a judgment module 17 set to judge whether the loss function is greater than the preset threshold;
- the construction module 14 is further configured to adjust the parameters in the neural process model according to the loss function if the loss function is greater than the preset threshold until the loss function meets the preset end condition, Obtain the prediction function. .
- the adjustment module 15 is further configured to perform convex function optimization on the loss function
- the adjustment module 15 is further configured to adjust parameters in the neural process model according to the loss function optimized by the convex function.
- the first vectorization module 11 is further configured to obtain training text
- the N words in the training text are converted into corresponding N sample word vectors according to a preset dictionary to obtain a sample word vector sequence.
- the second vectorization module 21 is further configured to obtain target text, and convert words in the target text into corresponding target word vectors according to a preset dictionary to obtain a target word vector sequence;
- the text processor also includes:
- the second input module 23 is configured to sequentially input the target word vectors into the prediction function according to the order of the words corresponding to the target word vectors in the target text;
- the second output module 24 is configured to obtain a predicted word vector according to the prediction function and the target word vector;
- the second calculation module 22 is further configured to calculate the distance between the predicted word vector and each standard word vector in the preset dictionary
- the synthesis module 25 is further configured to set the predicted word as the word corresponding to the standard word vector.
- an embodiment of the present application also provides a computer device including a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being processed by the computer program When the device is executed, the steps of the method described above are realized.
- the embodiments of the present application also provide a storage medium on which a computer program is stored, and when the computer program is executed by the processor, the operations of the embodiments in the method described above are implemented.
- the methods in the above embodiments can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware, but in many cases the former is better Implementation.
- the technical solution of the present application can be embodied in the form of a software product in essence or part that contributes to the existing technology, and the computer software product is stored in a storage medium (such as ROM / RAM) as described above , Magnetic disks, optical disks), including several instructions to enable a computer equipment (may be a mobile phone, computer, server, air conditioner, or network equipment, etc.) to perform the methods described in the embodiments of the present application.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Health & Medical Sciences (AREA)
- Artificial Intelligence (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Life Sciences & Earth Sciences (AREA)
- Biomedical Technology (AREA)
- Biophysics (AREA)
- Data Mining & Analysis (AREA)
- Evolutionary Computation (AREA)
- Molecular Biology (AREA)
- Computing Systems (AREA)
- Mathematical Physics (AREA)
- Software Systems (AREA)
- Machine Translation (AREA)
Abstract
本申请公开了一种文本输入的预测方法、装置、计算机设备和存储介质,该方法包括:获取训练文本,并根据预设词典将训练文本中N个词语转换为对应的N个样本词向量,得到样本词向量序列;选择M个样本词向量输入神经过程模型,得到对应的预测词向量,其中M<N;根据预测词向量和样本词向量序列中第M+1项样本词向量的差异构建损失函数;根据损失函数调整神经过程模型中的参数,直至损失函数满足预设结束条件;获取目标文本,并根据预设词典将目标文本转换为对应的目标词向量;将目标词向量输入预测函数,得到预测词语。
Description
本申请要求于2018年10月25日提交中国专利局、申请号为201811256223.9、发明名称为“文本输入的预测方法、装置、计算机设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在申请中。
本申请涉及计算机技术领域,尤其涉及文本输入的预测方法、装置、计算机设备和存储介质。
为了加快用户输入文本的速度,采用循环神经网络模型根据客户已输入文本,预测用户随后可能输入的文本。现有技术中,在循环神经网络模型训练阶段采用高斯过程拟合函数,但是高斯过程所需计算量较大,并且需要事先设定的核函数以实现高斯过程,导致文本输入预测工具的计算效率、训练效率受限。
发明内容
本申请的主要目的在于提供一种文本输入的预测方法、装置、计算机设备和存储介质,旨在解决传统循环神经网络模型用于文本输入预测的计算效率低的技术问题。
为实现上述目的,本申请提供一种文本输入的预测方法,包括:
获取训练文本,并根据预设词典将所述训练文本中N个词语转换为对应的N个样本词向量,得到样本词向量序列;
在所述样本词向量序列中选择M个样本词向量输入神经过程模型,得到对应的预测词向量,其中M<N;
根据所述预测词向量和所述样本词向量序列中第M+1项样本词向量的差异构建损失函数;
根据所述损失函数调整所述神经过程模型中的参数,直至所述损失函数满足预设结束条件;
获取目标文本,并根据预设词典将所述目标文本转换为对应的目标词向量;
将所述目标词向量输入所述神经过程模型中的预测函数,得到预测词语。
可选地,所述在所述样本词向量中选择M个词向量输入神经过程模型,得到对应的预测词向量的步骤,包括:
根据输入的所述样本词向量,获得全局潜变量;
根据所述样本词向量和所述全局潜变量获得对应的所述预测词向量。
可选地,所述神经过程模型为:
其中,x
i为输入的样本词向量,y
i为根据输入的样本词向量x
i输出的预测词向量,p(z)为多元正态分布,z为全局潜变量,g(x
i,z)为预测函数,σ
2为随机噪声。
可选地,所述根据所述预测词向量和所述样本词向量序列中第M+1项样本词向量的差异构建损失函数的步骤,包括:
计算所述预测词向量和所述样本词向量序列中第M+1项样本词向量的均方误差;
根据所述均方误差构建所述损失函数。
可选地,所述根据所述损失函数调整所述神经过程模型中的参数,直至所述损失函数满足预设结束条件,获得预测函数的步骤,包括:
判断所述损失函数是否大于所述预设阈值;
若所述损失函数大于所述预设阈值,则对所述损失函数进行凸函数优化;
根据经过凸函数优化的所述损失函数调整所述神经过程模型中的参数;
采用调整参数后的神经过程模型进行重新计算预测词向量,直至 由所述预测词向量和所述样本词向量序列中第M+1项样本词向量的差异构建的损失函数小于或等于所述预设阈值。
可选地,所述获取训练文本,并根据预设词典将所述训练文本中N个词语转换为对应的N个样本词向量,得到样本词向量序列的步骤,包括:
获取训练文本;
根据词性和词长对所述训练文本进行分词得到词语组;
根据预设词典将所述训练文本中N个词语转换为对应的N个样本词向量,得到样本词向量序列。
可选地,所述将所述目标词向量输入所述预测函数,得到预测词语的步骤包括:
按照所述目标文本中各目标词向量对应词语的先后顺序,依次将所述目标词向量输入到所述预测函数中,得到预测词向量;
计算所述预测词向量与所述预设词典中各标准词向量的距离;
确定所述距离中最小值对应的所述标准词向量;
将所述预测词语设置为所述标准词向量对应的词语。
此外,为实现上述目的,本申请还提供一种文本处理装置,其中,包括模型训练器和文本处理器,所述模型训练器包括:
第一向量化模块,设置为获取训练文本,并根据预设词典将所述训练文本中N个词语转换为对应的N个样本词向量,得到样本词向量序列;
第一输入模块,设置为在所述样本词向量序列中选择M个样本词向量输入神经过程模型;
第一输出模块,设置为通过所述神经过程模型输出所述M个样本词向量对应的预测词向量;
差异判断模块,设置为根据所述预测词向量和所述样本词向量序列中第M+1项样本词向量的差异构建损失函数;
调整模块,设置为根据所述损失函数调整所述神经过程模型中的参数,直至所述损失函数满足预设结束条件;
所述文本处理器包括:
第二向量化模块,设置为获取目标文本,并根据预设词典将所述目标文本转换为对应的目标词向量;
第二计算模块,设置为将所述目标词向量输入所述神经过程模型中的预测函数,得到预测词语。
此外,为实现上述目的,本申请还提供一种计算机设备,所述计算机设备包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行时实现如上述方法的步骤。
此外,为实现上述目的,本申请还提供一种存储介质,其中,所述存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如上述方法的步骤。
本申请实施例提出的一种文本输入的预测方法、装置、计算机设备和存储介质,通过采用神经过程模型对训练文本进行训练,从而可省去设置内核函数的过程,以克服其它神经网络模型在函数设计上的限制;同时利用神经过程模型高效的计算能力,减小模型的训练时间。通过神经过程模型得到的预测函数可根据目标文本进行待输入文本的预测,从而提高了用户进行文本输入的效率。
图1是本申请实施例方案涉及的硬件运行环境的计算机设备结构示意图;
图2为本申请文本输入预测方法第一实施例的流程示意图;
图3为本申请文本输入预测方法第二实施例的流程示意图;
图4为本申请文本输入预测方法第三实施例的流程示意图;
图5为本申请文本输入预测方法第四实施例的流程示意图;
图6为本申请文本输入预测方法第五实施例的流程示意图;
图7为本申请文本输入预测方法第六实施例的流程示意图。
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
如图1所示,图1是本申请实施例方案涉及的硬件运行环境的计算机设备结构示意图。
本申请实施例计算机设备具体可以是服务器,也可以是智能手机、平板电脑、便携计算机等具有数据处理功能的计算机设备。
如图1所示,该计算机设备可以包括:处理器1001,例如CPU,通信总线1002,用户接口1003,网络接口1004,存储器1005。其中,通信总线1002设置为实现这些组件之间的连接通信。用户接口1003可以包括显示屏(Display)、输入单元比如键盘(Keyboard),可选的用户接口1003还可以包括标准的有线接口、无线接口。网络接口1004可选的可以包括标准的有线接口、无线接口(如WI-FI接口)。存储器1005可以是高速RAM存储器,也可以是稳定的存储器(non-volatile memory),例如磁盘存储器。存储器1005可选的还可以是独立于前述处理器1001的存储装置。
可选地,计算机设备还可以包括音频电路、WiFi模块、触控屏等等,在此不再赘述。计算机设备可通过输入单元获取用户通过输入单元输入的需要进行处理的文本数据,将获取的文本数据作为目标文本或训练文本,计算机设备也可通过网络接口接收其他设备发送的需要进行处理的文本数据,将接收到的文本数据作为目标文本或训练文本;计算机设备还可以获取用户通过输入单元选择的显示屏中展示的文本数据,将获取的文本数据作为训练文本。
本领域技术人员可以理解,图1中示出的计算机设备结构并不构成对计算机设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
参照图2,图2为本申请文本输入预测方法第一实施例的流程示意图,所述文本输入预测方法包括:
步骤S100,获取训练文本,并根据预设词典将所述训练文本中N 个词语转换为对应的N个样本词向量,得到样本词向量序列;
其中,训练文本是包含多个词语按照语言逻辑组成的文本数据。文本数据是多于一个的字符按照顺序构成的字符串。目标文本比如“今天天气好”或者“我的名字是王乒乓”等。
具体地,可先对训练文本进行分词,得到组成训练文本的各词语,再将各词语分别向量化,得到各词语对应的词向量,再将各样本词向量按顺序组合起来得到样本词向量序列。样本词向量序列包括文本形式的各词向量化得到的各样本词向量。各样本词向量的先后顺序与相应的词在目标文本中出现的先后顺序一致。可以理解,目标文本中最开始的词所对应的样本词向量在样本词向量序列中的顺序最靠前。词向量是用于将文本形式的词以数学形式表达的数据。比如,文本形式的“话简”表示为数学形式“[00010000000...]”,此时,"[00010000000...1"即为“天气”的词向量,可以理解,这里不限定将文本形式的词转换为何种表示的词向量,只要能够将文本形式的词进行数学化表示即可。例如,目标文本为“我的名字是王乒乓”,将其分词得到“我/的/名字/是/王乒乓”,那么词“我”的词向量为V1,“的”的词向量为V2,“名字”的词向量为V3,"是”的词向量为V4,"王乒乓”的词向量为V5,则样本词向量序列包括的词向量依次为V1、V2、V3、V4、V5。
步骤S200,在所述样本词向量序列中选择M个样本词向量输入神经过程模型,得到对应的预测词向量,其中M<N;
神经过程模型(Neural Processes)为神经网络模型中的一种,神经过程模型是需要经过训练的机器学习模型,具体可通过对样本文本中词语的排列顺序逻辑进行学习,学习训练完成后具有根据当前输入文本预测下一待输入词语的能力。即神经过程模型可通过一系列的参数和运算逻辑将输入的数据进行线性或者非线性变换,得到运算结果。参数和运算逻辑能够反映输入和输出的对应关系。
神经过程模型与高斯过程相似,在未观察到的位置表示无限多不同的函数,在给定一定的观察结果的基础上,神经过程模型能捕获预测的不确定性,从而实现函数逼近,获得预测规律,即获得预测函数。相较于高斯过程,神经过程模型计算效率高,通过直接从数据中学习 隐式内核(implicit kernel)来克服许多函数设计上的限制,即神经过程模型设置时,可不用设置内核函数,从而加快文本预测的效率。
M个样本词向量的选择是随机的,每一次进行步骤S200时,M的取值是不一定的,同时M个样本词向量对应的词语在样本文本中的排序位置也是不一定的。
步骤S300,根据所述预测词向量和所述样本词向量序列中第M+1项样本词向量的差异构建损失函数;
所述预测词向量为经过神经网络模型预测得到的,所述样本词向量序列中第M+1项样本词向量为训练文本中真实存在的,也就是说,第M+1项样本词向量为相对预测词向量的真实值。计算机设备可根据预测词向量与真实值之间的的差异,构建损失函数,按照最小化损失函数的方向调整神经网络模型中的参数,以使得调整后的神经网络模型的输出更符合需求。
步骤S400,根据所述损失函数调整所述神经过程模型中的参数,直至所述损失函数满足预设结束条件;
事实上,模型的训练过程是需要多次重复的,根据所述损失函数调整所述神经过程模型中的参数后,再将样本词向量序列输入至调整参数后的所述神经过程模型中计算预测词向量,即重复步骤S200、S300,直至所述损失函数满足预设结束条件,停止训练。
损失函数可体现模型输出的预测结果的准确性,损失函数越小即预测的准确性越高,本领域技术人员可自行设置一个对应损失函数的预设阈值,当损失函数小于该预设阈值,停止训练。也可以设置对应重复步骤S200、S300的次数的预设阈值,即对应神经过程模型的迭代次数的预设阈值,当迭代次数大于预设阈值,停止训练。
步骤S500,获取目标文本,并根据预设词典将所述目标文本转换为对应的目标词向量;
步骤S600,将所述目标词向量输入所述神经过程模型中的预测函数,得到预测词语。
其中,目标文本是待进行预测的文本数据。用户可通过计算机设备的输入单元进行输入目标文本,从而获取目标文本。根据所述预设 词典将目标文本向量化,形成目标词向量,再通过预测函数计算预测词向量,从而得到预测词语。
步骤S100至步骤S500可在同一台计算机设备中进行运行。在另一实施例中,步骤S100至步骤S400可在一台计算机设备中进行运行,步骤S500可在另一台计算机设备中进行运行。例如:步骤S100至步骤S400在服务器中运行,获得预测函数,服务器将该预测函数发送至用户使用的移动终端中,用户使用的移动终端接收该预测函数,并执行步骤S500得到预测词语。
在本申请的文本输入预测方法中,通过采用神经过程模型对训练文本进行训练,从而可省去设置内核函数的过程,以克服许多神经网络模型在函数设计上的限制;同时利用神经过程模型高效的计算能力,减小模型的训练时间。通过神经过程模型得到的预测函数可根据目标文本进行待输入文本的预测,从而提高了用户进行文本输入的效率。
进一步的,参照图3,图3为本申请文本输入预测方法第二实施例的流程示意图,基于上述实施例,所述步骤S200,包括:
步骤S210,根据输入的所述样本词向量,获得全局潜变量;
全局潜变量为可被神经过程模型中所有对象或函数引用的潜变量。潜变量与可观察变量相对,是不能被直接观察,但能通过观察到的其他变量推断的变量。由于无法直接通过样本词向量x和样本词向量x对应的预测词向量y,推导得到对应的预测函数,所以在神经过程模型中引入全局潜变量z以推导得到该预测函数。
步骤S220,根据所述样本词向量和所述全局潜变量获得对应的所述预测词向量。
具体地,由于进行步骤S210时,假设第M项样本词向量之后的词向量为未知,通过输入神经过程模型中,以得到输出的预测词向量y,即对M+1项对应的样本词向量进行预测,即假设M+1项对应的样本词向量是未知的。可以理解的,在步骤S210中,输入的样本词向量为获得全局潜变量z,再将根据全局潜变量z与得到所述预测词向量y。
进一步地,所述神经过程模型为:
其中,x
i为输入的样本词向量,y
i为根据输入的样本词向量x
i输出的预测词向量,p(z)为多元正态分布,z为全局潜变量,g(x
i,z)为预测函数,σ
2为随机噪声。
假设根据训练文本中的M个词向量预测第M+1个词向量是有限维度的边际分布,即可通过一个函数来体现这一逻辑过程。对有限个词向量序列x
1:n,可通过得到预测词向量y。由于全局潜变量z的引入,可设置函数=,那么获得即获得预测函数。
进一步的,参照图4,图4为本申请文本输入预测方法第三实施例的流程示意图,基于上述实施例,所述步骤S300,包括:
步骤S310,计算所述预测词向量和所述样本词向量序列中第M+1项样本词向量的均方误差;
均方误差的计算公式如下:
J=(y
1-y
2)
2,
其中,y
1为神经过程模型输出的预测词向量,y
2为实际真实值,即第M+1项词向量。
步骤S320,根据所述均方误差构建所述损失函数。
损失函数(loss function)是用来估量模型的预测值f(x)与真实值y的不一致程度,它是一个非负实值函数,通常使用L(a,f(x))来表示,损失函数越小,模型的准确性就越好。具体采用何种类型的损失函数,在本申请中不做限制。
在本实施例中,通过比较预测词向量和真实值之间的差异,从而构建得到损失函数,通过损失函数进一步对神经过程模型中的参数进行修改,从而使得预测函数可达到拟合分布的目的。
进一步的,参照图5,图5为本申请文本输入预测方法第四实施例的流程示意图,基于上述实施例,所述步骤S400,包括:
步骤S410,判断所述损失函数是否大于所述预设阈值;
预设阈值为本领域技术人员根据实际需要设置的数值。
步骤S420,若所述损失函数大于所述预设阈值,则对所述损失 函数进行凸函数优化;
若所述损失函数小于或等于所述预设阈值,则获得所述神经过程模型中的预测函数,执行步骤S500;若所述均方误差小于或等于所述预设阈值,则表示神经过程模型输出的预设值与真实值的差异度满足要求,可停止对神经网络模型进行调整。
凸函数是指一类定义在实线性空间上的函数。凸函数优化即是损失函数最小化。具体采用何种类型的凸函数优化,在本申请中不做限制。在一实施例中,采用自适应时刻估计方法(Adaptive Moment Estimation,ADAM)进行优化,与其他自适应学习率算法相比,ADAM优化方法收敛速度更快,学习效果更为有效,而且可以纠正其他优化技术中存在的问题,如学习率消失、收敛过慢或是高方差的参数更新导致损失函数波动较大等问题。
步骤S430,根据经过凸函数优化的所述损失函数调整所述神经过程模型中的参数;
具体地,由于神经过程模型为:
具体可根据经过凸函数优化的所述损失函数,调整所述神经过程模型中的参数z、p(z)、N(y
i|g(x
i,z),σ
2)、g(x
i,z),使得达到拟合分布。
步骤S440,采用调整参数后的神经过程模型进行重新计算预测词向量,直至由所述预测词向量和所述样本词向量序列中第M+1项样本词向量的差异构建的损失函数小于或等于所述预设阈值。
采用调整参数后的神经过程模型进行重新计算预测词向量,即采用调整参数后的神经过程模型重复步骤S200和S300。
进一步的,参照图6,图6为本申请文本输入预测方法第五实施例的流程示意图,基于上述实施例,所述步骤S100,包括:
步骤S110,获取训练文本;
步骤S120,根据词性和词长对所述训练文本进行分词得到词语组;
其中,分词是将一个连续的字符序列切分成多个单独的字符或者字符序列的过程。词性(POS,Part of speech)是反映词的内容所属类型的数据。词性包括形容词、介词、谓词和名词等词性。词长是词所包含的字符的数量,词性和词长会很大程度上影响词语对应的意思,从而影响下一词语的预测。
具体地,计算机设备可采用预设的分词方式对训练文本进行分词处理,得到多个字符或者字符序列,这些字符或者字符序列按照各自在文本中出现的先后顺序形成词语组。计算机设备根据预设词汇表确定词序列中各词相应的词性,并统计各词语相应的词长。其中,预设的分词方式可以是基于字符匹配、基于语义理解、标点符号划分或者基于统计的分词方式。计算机设备可设置分词得到的词的词长阀值,使得分词得到的各词的词长均不超过词长阀值。
步骤S130,根据预设词典将所述训练文本中N个词语转换为对应的N个样本词向量,得到样本词向量序列。
预设词典为本领域技术人员预先训练的数据库或函数,以根据预设词典能将词语转换为对应的词向量。一般地,语义相同的词语所相对应的词向量也相近。
计算机设备根据各词的内容、词性与词长,将该词向量化,得到该词相应的词向量,从而得到样本词向量组成的样本词向量序列。其中,计算机设备可以利用神经网络模型将词转化为词向量,在本实施例中,不限制将词转化为词向量的神经网络模型类型。
进一步的,参照图7,图7为本申请文本输入预测方法第六实施例的流程示意图,基于上述实施例,所述步骤S600,包括:
步骤S610,按照所述目标文本中各目标词向量对应的词语的先后顺序,依次将目标词向量输入到所述预测函数中,得到预测词向量;
在步骤S610之前,用户通过输入单元将字符数据输入至计算机设备中,根据预设词典将所述目标文本中的词语转换为对应的目标词向量,得到目标词向量序列的步骤具体可参照实施例五中步骤S120至步骤S130。
由于预测函数为已训练成功的可揭示上下文逻辑规律的分布函 数。所以输入目标词向量后,可计算得到目标词向量对应的预测词向量,即目标词向量后出现概率最大的词向量。
步骤S620,计算所述预测词向量与所述预设词典中各标准词向量的距离;
词向量本身是个高维度的向量,一般在几万到几十万不等的维度。可以通过余弦相似度或欧式距离计算词向量两两之间的距离,距离越近即相识度越高。在本实施例中,采用欧式距离计算词向量间的距离。欧氏距离是指两词向量在各维度上差值的平方和的算术平方根。
步骤S630,确定所述距离中最小值对应的所述标准词向量;
步骤S640,将所述预测词语设置为所述标准词向量对应的词语。
由于预设词典中设置有词语和词向量的对应关系,通过预测词向量即可得到与预测词向量对应的词语,该词语为对目标文本进行分析后,预测目标文本后即将输入的预测词语。
此外,本申请实施例还提出一种文本处理装置,包括模型训练器和文本处理器,所述模型训练器包括:
第一向量化模块11,设置为获取训练文本,并根据预设词典将所述训练文本中N个词语转换为对应的N个样本词向量,得到样本词向量序列;
第一输入模块12,设置为在所述样本词向量序列中选择M个样本词向量输入神经过程模型;
第一输出模块13,设置为所述神经过程模型输出M个样本词向量对应的预测词向量;
构建模块14,设置为根据所述预测词向量和所述样本词向量序列中第M+1项样本词向量的差异构建损失函数;
调整模块15,设置为根据所述损失函数调整所述神经过程模型中的参数,直至所述损失函数满足预设结束条件;
所述文本处理器包括:
第二向量化模块21,设置为获取目标文本,并根据预设词典将所述目标文本转换为对应的目标词向量;
第二计算模块22,设置为将所述目标词向量输入所述神经过程模型中的预测函数,得到预测词语。
进一步地,在又一实施例中,所述模型训练器还包括第一计算模块16,所述第一计算模块16设置为根据输入的所述样本词向量,获得全局潜变量;
第一输出模块13设置为根据所述样本词向量和所述全局潜变量获得对应的所述预测词向量。
进一步地,在又一实施例中,所述第一计算模块16还设置为计算所述预测词向量和所述样本词向量序列中第M+1项词向量的均方误差;
所述构建模块14设置为构建所述损失函数;
所述模型训练器还包括判断模块17,设置为判断所述损失函数是否大于所述预设阈值;
所述构建模块14还设置为若所述损失函数大于所述预设阈值,则调整模块15根据所述损失函数调整所述神经过程模型中的参数,直至所述损失函数满足预设结束条件,获得预测函数。。
进一步地,在又一实施例中,所述调整模块15还设置为对所述损失函数进行凸函数优化;
所述调整模块15还设置为根据经过凸函数优化的所述损失函数调整所述神经过程模型中的参数。
进一步地,在又一实施例中,第一向量化模块11还设置为获取训练文本;
对所述训练文本进行分词得到词语组;
根据词性和词长对所述训练文本进行分词得到词语组;
根据预设词典将所述训练文本中N个词语转换为对应的N个样本词向量,得到样本词向量序列。
进一步地,在又一实施例中,第二向量化模块21还设置为获取目标文本,并根据预设词典将所述目标文本中的词语转换为对应的目标词向量,得到目标词向量序列;
所述文本处理器还包括:
第二输入模块23,设置为按照所述目标文本中各目标词向量对应的词语的先后顺序,依次将目标词向量输入到所述预测函数中;
第二输出模块24,设置为根据所述预测函数和所述目标词向量得到预测词向量;
所述第二计算模块22还设置为计算所述预测词向量与所述预设词典中各标准词向量的距离;
确定所述距离中最小值对应的所述标准词向量;
所述合成模块25还设置为将所述预测词语设置为所述标准词向量对应的词语。
此外,本申请实施例还提出一种计算机设备,所述计算机设备包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行时实现如上所述方法的步骤。
本申请计算机设备的具体实施例与上述文本输入预测方法各实施例基本相同,在此不作赘述。
此外,本申请实施例还提出一种存储介质,所述存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如上所述方法中各实施例的操作。
本申请计算机可读存储介质的具体实施例与上述文本输入预测方法各实施例基本相同,在此不作赘述。
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者系统不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者系统所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者系统中还存在另外的相同要素。
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在如上所述的一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台计算机设备设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。
Claims (20)
- 一种文本输入预测方法,其中,包括以下步骤:获取训练文本,并根据预设词典将所述训练文本中N个词语转换为对应的N个样本词向量,得到样本词向量序列;在所述样本词向量序列中选择M个样本词向量输入神经过程模型,得到对应的预测词向量,其中M<N;根据所述预测词向量和所述样本词向量序列中第M+1项样本词向量的差异构建损失函数;根据所述损失函数调整所述神经过程模型中的参数,直至所述损失函数满足预设结束条件;获取目标文本,并根据预设词典将所述目标文本转换为对应的目标词向量;将所述目标词向量输入所述神经过程模型中的预测函数,得到预测词语。
- 如权利要求1所述的文本输入预测方法,其中,所述在所述样本词向量中选择M个词向量输入神经过程模型,得到对应的预测词向量的步骤,包括:根据输入的所述样本词向量,获得全局潜变量;根据所述样本词向量和所述全局潜变量获得对应的所述预测词向量。
- 如权利要求1所述的文本输入预测方法,其中,所述根据所述预测词向量和所述样本词向量序列中第M+1项样本词向量的差异 构建损失函数的步骤,包括:计算所述预测词向量和所述样本词向量序列中第M+1项样本词向量的均方误差;根据所述均方误差构建所述损失函数。
- 如权利要求4所述的文本输入预测方法,其中,所述根据所述损失函数调整所述神经过程模型中的参数,直至所述损失函数满足预设结束条件,获得预测函数的步骤,包括:判断所述损失函数是否大于所述预设阈值;若所述损失函数大于所述预设阈值,则对所述损失函数进行凸函数优化;根据经过凸函数优化的所述损失函数调整所述神经过程模型中的参数;采用调整参数后的神经过程模型进行重新计算预测词向量,直至由所述预测词向量和所述样本词向量序列中第M+1项样本词向量的差异构建的损失函数小于或等于所述预设阈值。
- 如权利要求1所述的文本输入预测方法,其中,所述获取训练文本,并根据预设词典将所述训练文本中N个词语转换为对应的N个样本词向量,得到样本词向量序列的步骤,包括:获取训练文本;根据词性和词长对所述训练文本进行分词得到词语组;根据预设词典将所述训练文本中N个词语转换为对应的N个样本词向量,得到样本词向量序列。
- 如权利要求1所述的文本输入的预测方法,其中,所述将所述目标词向量输入所述预测函数,得到预测词语的步骤包括:按照所述目标文本中各目标词向量对应的词语的先后顺序,依次将目标词向量输入到所述预测函数中,得到预测词向量;计算所述预测词向量与所述预设词典中各标准词向量的距离;确定所述距离中最小值对应的所述标准词向量;将所述预测词语设置为所述标准词向量对应的词语。
- 一种文本处理装置,其中,包括模型训练器和文本处理器, 所述模型训练器包括:第一向量化模块,设置为获取训练文本,并根据预设词典将所述训练文本中N个词语转换为对应的N个样本词向量,得到样本词向量序列;第一输入模块,设置为在所述样本词向量序列中选择M个样本词向量输入神经过程模型;第一输出模块,设置为通过所述神经过程模型输出所述M个样本词向量对应的预测词向量;差异判断模块,设置为根据所述预测词向量和所述样本词向量序列中第M+1项样本词向量的差异构建损失函数;调整模块,设置为根据所述损失函数调整所述神经过程模型中的参数,直至所述损失函数满足预设结束条件;所述文本处理器包括:第二向量化模块,设置为获取目标文本,并根据预设词典将所述目标文本转换为对应的目标词向量;第二计算模块,设置为将所述目标词向量输入所述神经过程模型中的预测函数,得到预测词语。
- 一种计算机设备,其中,所述计算机设备包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行时实现以下步骤:获取训练文本,并根据预设词典将所述训练文本中N个词语转换为对应的N个样本词向量,得到样本词向量序列;在所述样本词向量序列中选择M个样本词向量输入神经过程模型,得到对应的预测词向量,其中M<N;根据所述预测词向量和所述样本词向量序列中第M+1项样本词向量的差异构建损失函数;根据所述损失函数调整所述神经过程模型中的参数,直至所述损失函数满足预设结束条件;获取目标文本,并根据预设词典将所述目标文本转换为对应的目标词向量;将所述目标词向量输入所述神经过程模型中的预测函数,得到预测词语。
- 根据权利要求9所述的计算机设备,其中,所述计算机程序被所述处理器执行时还实现以下步骤:根据输入的所述样本词向量,获得全局潜变量;根据所述样本词向量和所述全局潜变量获得对应的所述预测词向量。
- 根据权利要求9所述的计算机设备,其中,所述计算机程序被所述处理器执行时还实现以下步骤:计算所述预测词向量和所述样本词向量序列中第M+1项样本词向量的均方误差;根据所述均方误差构建所述损失函数。
- 根据权利要求12所述的计算机设备,其中,所述计算机程序被所述处理器执行时还实现以下步骤:判断所述损失函数是否大于所述预设阈值;若所述损失函数大于所述预设阈值,则对所述损失函数进行凸函数优化;根据经过凸函数优化的所述损失函数调整所述神经过程模型中的参数;采用调整参数后的神经过程模型进行重新计算预测词向量,直至由所述预测词向量和所述样本词向量序列中第M+1项样本词向量的差异构建的损失函数小于或等于所述预设阈值。
- 根据权利要求9所述的计算机设备,其中,所述计算机程序 被所述处理器执行时还实现以下步骤:获取训练文本;根据词性和词长对所述训练文本进行分词得到词语组;根据预设词典将所述训练文本中N个词语转换为对应的N个样本词向量,得到样本词向量序列。
- 根据权利要求9所述的计算机设备,其中,所述计算机程序被所述处理器执行时还实现以下步骤:按照所述目标文本中各目标词向量对应的词语的先后顺序,依次将目标词向量输入到所述预测函数中,得到预测词向量;计算所述预测词向量与所述预设词典中各标准词向量的距离;确定所述距离中最小值对应的所述标准词向量;将所述预测词语设置为所述标准词向量对应的词语。
- 一种存储介质,其中,所述存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如下步骤:获取训练文本,并根据预设词典将所述训练文本中N个词语转换为对应的N个样本词向量,得到样本词向量序列;在所述样本词向量序列中选择M个样本词向量输入神经过程模型,得到对应的预测词向量,其中M<N;根据所述预测词向量和所述样本词向量序列中第M+1项样本词向量的差异构建损失函数;根据所述损失函数调整所述神经过程模型中的参数,直至所述损失函数满足预设结束条件;获取目标文本,并根据预设词典将所述目标文本转换为对应的目标词向量;将所述目标词向量输入所述神经过程模型中的预测函数,得到预测词语。
- 根据权利要求16所述的存储介质,其中,所述计算机程序被所述处理器执行时还实现以下步骤:根据输入的所述样本词向量,获得全局潜变量;根据所述样本词向量和所述全局潜变量获得对应的所述预测词 向量。
- 根据权利要求16所述的存储介质,其中,所述计算机程序被所述处理器执行时还实现以下步骤:计算所述预测词向量和所述样本词向量序列中第M+1项样本词向量的均方误差;根据所述均方误差构建所述损失函数。
- 根据权利要求19所述的存储介质,其中,所述计算机程序被所述处理器执行时还实现以下步骤:判断所述损失函数是否大于所述预设阈值;若所述损失函数大于所述预设阈值,则对所述损失函数进行凸函数优化;根据经过凸函数优化的所述损失函数调整所述神经过程模型中的参数;采用调整参数后的神经过程模型进行重新计算预测词向量,直至由所述预测词向量和所述样本词向量序列中第M+1项样本词向量的差异构建的损失函数小于或等于所述预设阈值。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201811256223.9A CN109635274B (zh) | 2018-10-25 | 2018-10-25 | 文本输入的预测方法、装置、计算机设备和存储介质 |
| CN201811256223.9 | 2018-10-25 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020082561A1 true WO2020082561A1 (zh) | 2020-04-30 |
Family
ID=66066742
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2018/122814 Ceased WO2020082561A1 (zh) | 2018-10-25 | 2018-12-21 | 文本输入的预测方法、装置、计算机设备和存储介质 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN109635274B (zh) |
| WO (1) | WO2020082561A1 (zh) |
Cited By (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112883185A (zh) * | 2021-03-30 | 2021-06-01 | 中国工商银行股份有限公司 | 基于机器学习的问题推荐方法及装置 |
| CN113779241A (zh) * | 2021-03-11 | 2021-12-10 | 北京沃东天骏信息技术有限公司 | 信息获取方法及装置、计算机可读存储介质、电子设备 |
| CN114089841A (zh) * | 2021-11-23 | 2022-02-25 | 北京百度网讯科技有限公司 | 文本的生成方法、装置、电子设备以及存储介质 |
| CN114218352A (zh) * | 2021-11-29 | 2022-03-22 | 华能(浙江)能源开发有限公司清洁能源分公司 | 发电设备异常监测方法、装置、存储介质及电子设备 |
| CN114565085A (zh) * | 2022-03-03 | 2022-05-31 | 上海艾瑞德生物科技有限公司 | 浓度检测模型的训练方法、浓度检测方法、装置、电子设备及存储介质 |
| CN114880990A (zh) * | 2022-05-16 | 2022-08-09 | 马上消费金融股份有限公司 | 标点符号预测模型训练方法、标点符号预测方法及装置 |
| CN117932280A (zh) * | 2024-03-25 | 2024-04-26 | 之江实验室 | 长序列数据预测方法、装置、计算机设备、介质和产品 |
Families Citing this family (13)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112015859B (zh) * | 2019-05-31 | 2023-08-18 | 百度在线网络技术(北京)有限公司 | 文本的知识层次抽取方法及装置、计算机设备及可读介质 |
| CN110188360B (zh) * | 2019-06-06 | 2023-04-25 | 北京百度网讯科技有限公司 | 模型训练方法和装置 |
| CN110362742A (zh) * | 2019-06-18 | 2019-10-22 | 平安普惠企业管理有限公司 | 课程信息匹配方法、装置、计算机设备及存储介质 |
| CN110415022B (zh) * | 2019-07-05 | 2023-08-18 | 创新先进技术有限公司 | 处理用户行为序列的方法及装置 |
| CN110955789B (zh) * | 2019-12-31 | 2024-04-12 | 腾讯科技(深圳)有限公司 | 一种多媒体数据处理方法以及设备 |
| CN110795935A (zh) * | 2020-01-06 | 2020-02-14 | 广东博智林机器人有限公司 | 文字词向量模型的训练方法、装置、终端及存储介质 |
| US12073819B2 (en) | 2020-06-05 | 2024-08-27 | Google Llc | Training speech synthesis neural networks using energy scores |
| CN114201576A (zh) * | 2020-09-17 | 2022-03-18 | 广东博智林机器人有限公司 | 神经网络语言模型及文字信息的预测方法和装置 |
| CN113112007B (zh) * | 2021-06-11 | 2021-10-15 | 平安科技(深圳)有限公司 | 神经网络中序列长度选择方法、装置、设备及存储介质 |
| CN113539246B (zh) * | 2021-08-20 | 2022-10-18 | 贝壳找房(北京)科技有限公司 | 语音识别方法和装置 |
| CN115270125A (zh) * | 2022-08-11 | 2022-11-01 | 江苏安超云软件有限公司 | Ids日志分类预测方法、装置、设备及存储介质 |
| CN115600114B (zh) * | 2022-09-30 | 2026-02-13 | 成都卫士通信息产业股份有限公司 | 模型训练方法、相似度计算方法、装置、设备及介质 |
| CN119539122B (zh) * | 2024-11-12 | 2025-11-18 | 北京沃东天骏信息技术有限公司 | 交易数据处理模型的训练方法及装置、介质、电子设备 |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20150228272A1 (en) * | 2014-02-08 | 2015-08-13 | Honda Motor Co., Ltd. | Method and system for the correction-centric detection of critical speech recognition errors in spoken short messages |
| CN107247702A (zh) * | 2017-05-05 | 2017-10-13 | 桂林电子科技大学 | 一种文本情感分析处理方法和系统 |
| CN107705784A (zh) * | 2017-09-28 | 2018-02-16 | 百度在线网络技术(北京)有限公司 | 文本正则化模型训练方法和装置、文本正则化方法和装置 |
| CN108108428A (zh) * | 2017-12-18 | 2018-06-01 | 苏州思必驰信息科技有限公司 | 一种构建语言模型的方法、输入法及系统 |
Family Cites Families (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2001273293A (ja) * | 2000-03-23 | 2001-10-05 | Nippon Telegr & Teleph Corp <Ntt> | 単語推定方法及び装置及び単語推定プログラムを格納した記録媒体 |
| CN107944014A (zh) * | 2017-12-11 | 2018-04-20 | 河海大学 | 一种基于深度学习的中文文本情感分析方法 |
| CN108334497A (zh) * | 2018-02-06 | 2018-07-27 | 北京航空航天大学 | 自动生成文本的方法和装置 |
-
2018
- 2018-10-25 CN CN201811256223.9A patent/CN109635274B/zh active Active
- 2018-12-21 WO PCT/CN2018/122814 patent/WO2020082561A1/zh not_active Ceased
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20150228272A1 (en) * | 2014-02-08 | 2015-08-13 | Honda Motor Co., Ltd. | Method and system for the correction-centric detection of critical speech recognition errors in spoken short messages |
| CN107247702A (zh) * | 2017-05-05 | 2017-10-13 | 桂林电子科技大学 | 一种文本情感分析处理方法和系统 |
| CN107705784A (zh) * | 2017-09-28 | 2018-02-16 | 百度在线网络技术(北京)有限公司 | 文本正则化模型训练方法和装置、文本正则化方法和装置 |
| CN108108428A (zh) * | 2017-12-18 | 2018-06-01 | 苏州思必驰信息科技有限公司 | 一种构建语言模型的方法、输入法及系统 |
Cited By (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113779241A (zh) * | 2021-03-11 | 2021-12-10 | 北京沃东天骏信息技术有限公司 | 信息获取方法及装置、计算机可读存储介质、电子设备 |
| CN112883185A (zh) * | 2021-03-30 | 2021-06-01 | 中国工商银行股份有限公司 | 基于机器学习的问题推荐方法及装置 |
| CN114089841A (zh) * | 2021-11-23 | 2022-02-25 | 北京百度网讯科技有限公司 | 文本的生成方法、装置、电子设备以及存储介质 |
| CN114218352A (zh) * | 2021-11-29 | 2022-03-22 | 华能(浙江)能源开发有限公司清洁能源分公司 | 发电设备异常监测方法、装置、存储介质及电子设备 |
| CN114565085A (zh) * | 2022-03-03 | 2022-05-31 | 上海艾瑞德生物科技有限公司 | 浓度检测模型的训练方法、浓度检测方法、装置、电子设备及存储介质 |
| CN114880990A (zh) * | 2022-05-16 | 2022-08-09 | 马上消费金融股份有限公司 | 标点符号预测模型训练方法、标点符号预测方法及装置 |
| CN117932280A (zh) * | 2024-03-25 | 2024-04-26 | 之江实验室 | 长序列数据预测方法、装置、计算机设备、介质和产品 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN109635274A (zh) | 2019-04-16 |
| CN109635274B (zh) | 2023-10-27 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2020082561A1 (zh) | 文本输入的预测方法、装置、计算机设备和存储介质 | |
| US11803731B2 (en) | Neural architecture search with weight sharing | |
| US10936949B2 (en) | Training machine learning models using task selection policies to increase learning progress | |
| US11928601B2 (en) | Neural network compression | |
| CN109947919B (zh) | 用于生成文本匹配模型的方法和装置 | |
| US11756094B2 (en) | Method and device for evaluating comment quality, and computer readable storage medium | |
| US9807473B2 (en) | Jointly modeling embedding and translation to bridge video and language | |
| CN109584865B (zh) | 一种应用程序控制方法、装置、可读存储介质及终端设备 | |
| WO2020082560A1 (zh) | 文本关键词提取方法、装置、设备及计算机可读存储介质 | |
| CN107273349B (zh) | 一种基于多种语言的实体关系抽取方法及服务器 | |
| CN107526725A (zh) | 基于人工智能的用于生成文本的方法和装置 | |
| CN109002186B (zh) | 一种输入预测方法及装置 | |
| CN113987154A (zh) | 基于UniLM与对比学习的相似句生成模型训练方法及相关设备 | |
| CN108595629A (zh) | 用于答案选择系统的数据处理方法及应用 | |
| CN112084769A (zh) | 依存句法模型优化方法、装置、设备及可读存储介质 | |
| WO2025091924A1 (zh) | 人机交互方法、装置、电子设备以及存储介质 | |
| CN110858226A (zh) | 对话管理方法和装置 | |
| US20210383222A1 (en) | Neural network optimization using curvature estimates based on recent gradients | |
| WO2021139076A1 (zh) | 智能化文本对话生成方法、装置及计算机可读存储介质 | |
| CN109948140B (zh) | 一种词向量嵌入方法及装置 | |
| CN111178082A (zh) | 一种句向量生成方法、装置及电子设备 | |
| WO2018171499A1 (zh) | 一种信息检测方法、设备及存储介质 | |
| KR20180024582A (ko) | 토픽 모형에 대한 온라인 및 다이내믹 학습 방법 | |
| CN112286900A (zh) | 一种数据处理方法、装置、设备及存储介质 | |
| CN113761145B (zh) | 语言模型训练方法、语言处理方法和电子设备 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 18938003 Country of ref document: EP Kind code of ref document: A1 |





