Summary of the invention
In view of this, this specification provides a kind of implementation method of public sentiment early warning, comprising:
Public sentiment data to be determined is obtained from public feelings information source;
By the task model after public sentiment data to be determined input training, determined whether according to the output of task model after training
Issue early warning;The task model is disaggregated model, and input is text, and output includes to whether the prediction of public sentiment occurring;Institute
It states task model to be initialized according to the language model for completing pre-training, be instructed using markd sample public sentiment data
Practice;The language model and the task model structure having the same in addition to Softmax layers of normalization, output is to input text
This prediction hereafter;The language model carries out pre-training using unmarked text data.
This specification additionally provides a kind of realization device of public sentiment early warning, comprising:
Data capture unit to be determined, for obtaining public sentiment data to be determined from public feelings information source;
Task model uses unit, for the task model after training public sentiment data to be determined input, after training
The output of task model determines whether to issue early warning;The task model is disaggregated model, and input is text, and output includes pair
Whether the prediction of public sentiment is occurred;The task model is initialized according to the language model for completing pre-training, using there is label
Sample public sentiment data be trained;The language model and task model are having the same in addition to Softmax layers of normalization
Structure, output are the prediction hereafter to input text;The language model carries out pre-training using unmarked text data.
A kind of content distributing network CDN node that this specification provides, comprising: memory and processor;The memory
On be stored with can by processor run computer program;When the processor runs the computer program, above-mentioned answer is executed
Step described in implementation method with the web access in CDN node.
A kind of computer equipment that this specification provides, comprising: memory and processor;Being stored on the memory can
The computer program run by processor;When the processor runs the computer program, above-mentioned web access realization side is executed
Step described in method.
This specification additionally provides a kind of terminal, comprising: memory and processor;Being stored on the memory can be by
Manage the computer program of device operation;When the processor runs the computer program, the web of above-mentioned application at the terminal is executed
Step described in the implementation method of access.
A kind of computer readable storage medium that this specification provides, is stored thereon with computer program, the computer
When program is run by processor, step described in the implementation method that the above-mentioned web applied in CDN node is accessed is executed.
This specification additionally provides a kind of computer readable storage medium, is stored thereon with computer program, the calculating
When machine program is run by processor, step described in the implementation method of the web access of above-mentioned application at the terminal is executed.
By above technical scheme as it can be seen that in the embodiment of this specification, building is to input, except Softmax layer with text
The identical language model of external structure and task model, the output of language model are the prediction to input text hereafter, task model
Output include to whether the prediction of public sentiment occurring, after carrying out pre-training to language model using unmarked text data,
To complete the language model initialization task model of pre-training, then using markd sample public sentiment data come training mission mould
Type using the task model that training is completed determines whether that public sentiment occurs, so as to limited in markd sample data
In the case of improve public sentiment early warning accuracy, saved a large amount of manual work.
Specific embodiment
The embodiment of this specification proposes a kind of implementation method of new public sentiment early warning, and building is the language inputted with text
Model and task model, language model and the task model structure having the same in addition to Softmax layers, language model
Softmax layers are matched with the prediction to input text hereafter, and the Softmax layer of task model is matched with the pre- of public sentiment whether occurs
It surveys;With unmarked text data pre-training language model, the language model that pre-training is completed is moved in addition to Softmax layers
On task model, then with markd sample public sentiment data training mission model, so that limited in marked sample public sentiment data
In the case where, carrying out public sentiment early warning using task model has higher order of accuarcy, greatly reduces marker samples data
Manual work.
The embodiment of this specification may operate in any equipment with calculating and storage capacity, such as mobile phone, plate
The equipment such as computer, PC (Personal Computer, PC), notebook, server;Can also by operate in two or
The logical node of more than two equipment realizes the various functions in this specification embodiment.
In the embodiment of this specification, language model and task model are with text be input disaggregated model.Language mould
Type and task model use identical algorithm, have except Softmax (normalization) layer in addition to identical structure (language model with times
The input layer of business model is identical with middle layer).Wherein, the output of language model is the prediction hereafter to input text,
Using being matched with the Softmax hereafter predicted layer;The output of task model includes to whether the prediction of public sentiment occurring, using matching
In the Softmax layer of public sentiment prediction.
In one example, the input of language model and task model is several continuous words in a word, language mould
Which word the Softmax layer output of type follows for most probable after these words, and the output of task model then can be when one
When occurring these continuous words in word, whether the words is public feelings information;As input " today ", " weather ", " good " this
Word sequence, the output of task model can be " bad ", " ", indicate hereafter being likely to of " It's lovely day " " bad " or
" ";And the output of task model can be "No", indicate that " It's lovely day " is not public feelings information, there is no public sentiments.
The output of task model is except in addition to whether the prediction of public sentiment occurring, can also including other classification to input text
Prediction is not limited such as the event class degree etc. that event type (accident, swindle, start a rumour), the input text of public sentiment are reflected
It is fixed.
Since language model is used to predict input text hereafter, can be trained using unmarked training sample;
And task model is used to predict whether that public sentiment occurs, and is typically employed to markd training sample and is trained.This specification
In embodiment, pre-training is first carried out to language model using unmarked text data, it is initial with the language model that pre-training is completed
Change task model, then the task model after initialization is trained using markd sample public sentiment data.Training is completed
Task model can be utilized for public sentiment early warning.
Specifically, before training before task model, since language model and task model are complete in addition to Softmax layers
It is identical, can by task model in addition to Softmax layers other each layers each parameter value, be set as and complete pre-training
Language model is identical, and the initialization to task model can be realized.In this way, can be using a large amount of unmarked corpus to language mould
Type carries out pre-training, keeps language model study semantic and regular to the inherence of natural language, the language mould completed using pre-training
Type initialization task model can inherit the semanteme learnt and rule to task model, be trained to task model
When, as long as thering is label corpus to be finely adjusted on the basis of this to model using a small amount of, so that it may reach good accuracy rate.
The pre-training of language model can be carried out using general corpus, can also be carried out, not limited using public sentiment corpus
It is fixed, wherein general corpus includes the unrestricted text data of various contents, and public sentiment corpus is then that content is limited to public sentiment
Text data.
In one implementation, it may include two stages to the pre-training of language model: in the first stage, first using
General corpus carries out general pre-training to language model, after the completion of general pre-training, into second stage, using public sentiment corpus
Target pre-training is carried out to the language model after the completion of general pre-training.After completing second stage, language model is only completion
Pre-training.Due to general corpus representation and public sentiment corpus representation may it is different, general corpus into
Row pre-training and then with public sentiment corpus continue pre-training, can make language model study to public sentiment data inherent law.Two
The pre-training in a stage can be improved the ability that language model understands and handle non-public sentiment text data and public sentiment text data, from
And further increase the accuracy that task model determines whether to occur public sentiment.
The training of task model is trained using markd sample public sentiment data, sample public sentiment data includes content
It also include the text data that content is non-public sentiment for the text data of public sentiment.To sample public sentiment data according to the defeated of task model
The classification carried out needed for out marks.
It can refer to the prior art to the training of task model to carry out.In one example, in training mission model, by sample
Public sentiment data incoming task model calculates the value of loss function according to the label of the output of task model and sample public sentiment data,
According still further to the parameter value in the value adjustment task model of loss function.
Language model and task model can use arbitrary sorting algorithm, without limitation.For example, task model and language
Model can be LSTM model (Long Short-Term Memory, shot and long term memory network), to utilize LSTM model in language
The advantage of speech processing aspect reaches better early warning effect.It is a kind of such as to be schemed using the language model of LSTM or the structure of task model
Shown in 1.
In the embodiment of this specification, the process of the implementation method of public sentiment early warning is as shown in Figure 2.
Step 210, public sentiment data to be determined is obtained from public feelings information source.
In the origin and route of transmission of the event that may cause public sentiment, any one can learn that event occurs and causes
The information source of concern, all can serve as public feelings information source.For example, the message of professional media publication, it is public microblogging, wechat,
Know publication and video, the message of forwarding etc. on the equal network medias.
Urtext data can be obtained automatically from public feelings information source using technologies such as speech recognition, web crawlers, in conjunction with
The technologies such as word segmentation processing, semantic analysis, search engine retrieved from urtext data may be public sentiment related text number
According to, and according to the specific implementation of task model, by related text data processing for be matched with task model input form wait sentence
Determine public sentiment data.
For example, when the input of task model is whole section of text, it can be by related text data directly as carriage to be determined
Feelings data;When the input of task model is several continuous words in word sequence, after first related text data can be segmented
Word sequence is obtained, then using word sequence as public sentiment data to be determined.
It specifically can refer to prior art realization, repeat no more.
Step 220, by the task model after public sentiment data to be determined input training, according to the output of task model after training
Determine whether to issue early warning.
Task model after training is completed into public sentiment data to be determined input, output category is predicted to tie by task model
Fruit, including to whether the prediction of public sentiment occurring.
The specific implementation that can be exported according to task model is not done to determine to issue public sentiment early warning under what kind of situation
It limits.For example, if the output of task model be to whether the judgement conclusion of early warning, can be directly in the output of task model
Public sentiment early warning is carried out when early warning;If the output of task model be occur public sentiment probability, can reach in the probability of output or
More than some and progress public sentiment early warning under conditions of threshold value;If the output of task model is also wrapped in addition to the probability that public sentiment occurs
Include the prediction of the classification to public sentiment data to be determined (event type of such as public sentiment, event class degree), then it can be for difference
Event type, different event class degree be arranged different threshold values as issue early warning condition, in task model
Output carries out public sentiment early warning when meeting the condition of setting.
As it can be seen that building input is text, the identical language of external structure for removing Softmax layer in the embodiment of this specification
Model and task model, the Softmax layer of language model are matched with the prediction to input text hereafter, task model
Softmax layers are matched with the prediction that public sentiment whether occurs;Pre-training is being carried out to language model using unmarked text data
Afterwards, to complete the language model initialization task model of pre-training, then using markd sample public sentiment data come training mission
Model;In the limited situation of marked sample public sentiment data, carrying out public sentiment early warning using task model realizes higher standard
True degree has saved a large amount of manpower markers work.
It is above-mentioned that this specification specific embodiment is described.Other embodiments are in the scope of the appended claims
It is interior.In some cases, the movement recorded in detail in the claims or step can be come according to the sequence being different from embodiment
It executes and desired result still may be implemented.In addition, process depicted in the drawing not necessarily require show it is specific suitable
Sequence or consecutive order are just able to achieve desired result.In some embodiments, multitasking and parallel processing be also can
With or may be advantageous.
In an application example of this specification, the public sentiment early warning system of certain Internet Service Provider can supervise in real time
Survey the information of the publications such as news client, forum, wechat public platform, immediate communication platform, the sensitive information of discovery user's concern
And be analyzed and processed automatically, public sentiment early warning is issued the user in time.
The Internet Service Provider constructs two disaggregated models: language using bidirectional multi-layer Recognition with Recurrent Neural Network LSTM algorithm
Say model L-LSTM and task model T-LSTM.L-LSTM is identical with structure of the T-LSTM in addition to Softmax layers.L-
The input of LSTM and T-LSTM is a word of continuous N (N is greater than 1 integer) in word sequence.The output of L-LSTM is N number of to this
Most probably which K (K is integer) a word is followed after N number of continuous word in the prediction hereafter of word;The output of T-LSTM
Whether to carry out public sentiment early warning;The Softmax layer of L-LSTM and T-LSTM is matched with respective output.
Firstly, carrying out pre-training to language model L-LSTM, process is as shown in Figure 3.First with the text on wikipedia
General pre-training is carried out to L-LSTM as general corpus, completing the language model obtained after general pre-training is L-LSTM-G;
Target pre-training is carried out to L-LSTM-G using the history public sentiment text data of the Internet Service Provider as public sentiment corpus again,
Completing the language model obtained after target pre-training is L-LSTM-Y.
The specific method of general pre-training or target pre-training is: after general corpus or public sentiment corpus are carried out word segmentation processing
Obtain continuous input of several words as language model in word sequence, using these words in word sequence subsequent word as language mould
The output sample of type, carrys out train language model.
Secondly, being trained using public sentiment sample data to task model, process is as shown in Figure 4: public sentiment sample data
Be marked with whether should early warning label.Using L-LSTM-Y initialization task model T-LSTM, it may be assumed that remove T-LSTM
Except Softmax layers, the parameter initialization of other each layers is the value of the same parameter in L-LSTM-Y;By public sentiment sample data
It is input in T-LSTM for continuous several times in word sequence, obtains the prediction label of yes/no;Comparison prediction label and public sentiment sample
Whether the sample label of the label of data is consistent, according to whether unanimously generating feedback signal, and adjusts T- according to feedback signal
The parameter of each layer in LSTM;After repeating above-mentioned adjustment process to all public sentiment sample datas, the task mould of training completion is obtained
Type T-LSTM-F.
After carrying out pre-training to L-LSTM using unmarked general corpus and public sentiment corpus, L-LSTM-Y study has been arrived certainly
The inherent law and expression way of right language and public sentiment data, and learning outcome is passed into task model T-LSTM, as long as adopting
T-LSTM is finely adjusted with a small amount of markd public sentiment sample data, so that it may reach very high accuracy.Since multilayer is followed
Ring neural network have very strong modeling ability, by it is above-mentioned train up three times after, T-LSTM-F model can be good at catching
The important information in public sentiment data is caught, accurate early warning is made.
When using T-LSTM-F model, word sequence is obtained after the message grabbed from network is segmented as wait sentence
Determine public sentiment data, public sentiment data to be determined be input in T-LSTM-F model, if the output of T-LSTM-F model be it is yes,
Carry out public sentiment early warning;If the output of T-LSTM-F model is no, not early warning.
Corresponding with the realization of above-mentioned process, the embodiment of this specification additionally provides a kind of realization device of public sentiment early warning.It should
Device can also be realized by software realization by way of hardware or software and hardware combining.Taking software implementation as an example, make
It for the device on logical meaning, will be corresponded to by the CPU (Central Process Unit, central processing unit) of place equipment
Computer program instructions be read into memory operation formed.For hardware view, in addition to CPU shown in fig. 5, memory with
And except memory, the equipment where the realization device of public sentiment early warning also typically includes the chip for carrying out wireless signal transmitting-receiving
Deng other hardware, and/or for realizing other hardware such as board of network communicating function.
Fig. 6 show a kind of realization device of public sentiment early warning of this specification embodiment offer, including data to be determined obtain
Unit and task model is taken to use unit, in which: data capture unit to be determined is used to obtain carriage to be determined from public feelings information source
Feelings data;Task model is used to inputting public sentiment data to be determined into the task model after training using unit, according to training successor
The output of business model determines whether to issue early warning;The task model is disaggregated model, and input is text, and output includes to being
The no prediction that public sentiment occurs;The task model is initialized according to the language model for completing pre-training, and use is markd
Sample public sentiment data is trained;The language model and the task model knot having the same in addition to Softmax layers of normalization
Structure, output are the prediction hereafter to input text;The language model carries out pre-training using unmarked text data.
Optionally, the task model is initialized according to the language model for completing pre-training, comprising: in training mission
Before model, by task model in addition to Softmax layers other each layers each parameter value, be set as with complete pre-training language
Say that model is identical.
Optionally, the language model carries out pre-training using unmarked text data, comprising: the language model is first adopted
General pre-training is carried out with general corpus, then pre- to the language model progress target after the completion of general pre-training using public sentiment corpus
Training.
Optionally, the task model is trained using markd sample public sentiment data, comprising: by sample public sentiment number
According to incoming task model, the value of loss function is calculated according to the label of the output of task model and sample public sentiment data, according to damage
Lose the parameter value in the value adjustment task model of function.
Optionally, the task model and language model are as follows: shot and long term memory network LSTM model.
Optionally, the input of the task model are as follows: several continuous words;The public sentiment data to be determined include: by
The word sequence that text sentence obtains after being segmented.
The embodiment of this specification provides a kind of computer equipment, which includes memory and processor.
Wherein, the computer program that can be run by processor is stored on memory;Computer program of the processor in operation storage
When, execute each step of the implementation method of public sentiment early warning in this specification embodiment.To each of the implementation method of public sentiment early warning
The detailed description of a step refer to before content, be not repeated.
The embodiment of this specification provides a kind of computer readable storage medium, is stored with computer on the storage medium
Program, these computer programs execute the implementation method of public sentiment early warning in this specification embodiment when being run by processor
Each step.Content before referring to the detailed description of each step of the implementation method of public sentiment early warning, is not repeated.
The foregoing is merely the preferred embodiments of this specification, all the application's not to limit the application
Within spirit and principle, any modification, equivalent substitution, improvement and etc. done be should be included within the scope of the application protection.
In a typical configuration, calculating equipment includes one or more processors (CPU), input/output interface, net
Network interface and memory.
Memory may include the non-volatile memory in computer-readable medium, random access memory (RAM) and/or
The forms such as Nonvolatile memory, such as read-only memory (ROM) or flash memory (flash RAM).Memory is computer-readable medium
Example.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method
Or technology come realize information store.Information can be computer readable instructions, data structure, the module of program or other data.
The example of the storage medium of computer includes, but are not limited to phase change memory (PRAM), static random access memory (SRAM), moves
State random access memory (DRAM), other kinds of random access memory (RAM), read-only memory (ROM), electric erasable
Programmable read only memory (EEPROM), flash memory or other memory techniques, read-only disc read only memory (CD-ROM) (CD-ROM),
Digital versatile disc (DVD) or other optical storage, magnetic cassettes, tape magnetic disk storage or other magnetic storage devices
Or any other non-transmission medium, can be used for storage can be accessed by a computing device information.As defined in this article, it calculates
Machine readable medium does not include temporary computer readable media (transitory media), such as the data-signal and carrier wave of modulation.
It should also be noted that, the terms "include", "comprise" or its any other variant are intended to nonexcludability
It include so that the process, method, commodity or the equipment that include a series of elements not only include those elements, but also to wrap
Include other elements that are not explicitly listed, or further include for this process, method, commodity or equipment intrinsic want
Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including described want
There is also other identical elements in the process, method of element, commodity or equipment.
It will be understood by those skilled in the art that the embodiment of this specification can provide as the production of method, system or computer program
Product.Therefore, the embodiment of this specification can be used complete hardware embodiment, complete software embodiment or combine software and hardware side
The form of the embodiment in face.Moreover, it wherein includes that computer is available that the embodiment of this specification, which can be used in one or more,
It is real in the computer-usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.) of program code
The form for the computer program product applied.