zoukankan      html  css  js  c++  java
  • Syn Bot /OSCOVA bot的设置(14)

    Bot Configuration

    In V1 we have added the most essential configuration options to the BotConfiguration class. Developers use these settings to tune their Bot. The following are some of the most common configurations that are mostly changed to suite different bot projects.

    RequiredRecognizersOnly

    Gets or sets a value indicating if the Bot should only load required parsers based on the entity types used in declared Expressions.

    Default: false

    MinimumScore

    The absolute minimum score an intent must have to be added to the EvaluationResult.

    Default: 0.05

    MaxIntentCount

    The maximum number of high scoring intents to collect during request evaluation. Increasing or decreasing the value has no impact on the number of expressions evaluated by the Bot.

    Default: 5

    RuleScoreDependency

    When deep machine learning is enabled the Bot uses the value of this variable to determine how much of the Rule based score (in percentage) is to be taken into consideration during score calibration.

    Default: 0.6 (i.e. 60 percent)

    ContextLifespan

    The default lifespan of any context item that gets added to the user's context during a user session.

    *Default: ** *5

    MachineLearningRate

    The machine learning rate to use when the Bot is being trained in RuleAndML match mode. Lower value increase the time to train the Bot but may lead to better results.

    Default: 0.25

    ShowIntentInterpretation

    During serialization of evaluation result the Bot uses the value of this variable to determine if intent interpretation value is to be included.

    Default: false

    UseFullIntentName

    The value of this property indicates if the name of an intent must be a combination of the name of dialog class and the intent method name.

    For example if you have an intent WeatherByLocation in a dialog named WeatherDialog the name of the intent becaomes WeatherDialog.WeatherByLocation.

    It is recommended that the value of this property is set to true to avoid conflicts between similar intent names in different dialogs.

    Default: true

    ProcessingMode

    The mode to use for matching expressions to user input.

    Default: ProcessingMode.Unified

    Machine Learning in Oscova is powered by advanced neural network system the core architecture of which is designed to train faster and build intelligent models by extracting relevant features from expressions declared within Dialogs.

    Oscova Neural Network Trainer Diagram

    Selecting Modes

    There are 2 expression processing modes in Oscova.

    • Unified
    • DeepOnly

    Unified: This is the default mode and uses in-built model for processing user messages. This processing mode is best suited for all types of projects and takes the least amount of time to train. Unified processing automatically adjust to the current Bot environment whenever new elements like lexical database or word vector models are loaded.

    DeepOnly: This mode forces Oscova to reconstruct a new neural network model from ground up. This mode is mainly used in projects that have unique and precise expression values that are carefully stacked over intents.

    NOTE

    Named Expressions in DeepOnly processing mode must have unique entity and context signatures. Similar expressions with different names are invalid in DeepOnly processing mode.

    Example

    var bot = new OscovaBot();
    bot.Configuration.ProcessingMode = ProcessingMode.DeepOnly;
    bot.Dialogs.Add(new PizzaDialog());
    bot.Trainer.StartTraining(); May take several minutes to complete.
    

    When DeepOnly mode is enabled, Oscova automatically generates positive and negative training samples from expressions and feeds them to a newly constructed neural network model during the training process.

    Once the neural network training has completed, Oscova calibrates the score received by the neural network and the Natural Language Processing (NLP) engine.

    TIP

    Enabling DeepOnly mode in smaller projects may yield lower improvements in intent scoring.

    Saving Trained Model

    If you are not using Syn Bot Studio, you can save the Trained Model by handling the TrainingFinished event.

    NOTE

    Saving a trained model is possible only when a new neural network model is generated by Oscova in DeepOnly mode. It is not required to save a model in Unified mode.

    Example

    var bot = new OscovaBot();
    bot.Configuration.ProcessingMode = ProcessingMode.DeepOnly;
    bot.Dialogs.Add(new SomeDialog());
    
    //When the training has finished, the model is saved within Trained_Model.osml file.
    bot.TrainingFinished += (sender, args) =>
    {
        args.TrainedModel.Save("Trained_Model.xml");
    };
    
    bot.Trainer.StartTraining();
    

    Loading trained model

    Once the training is successful, the trained model will be saved in the same directory where the training data is placed. You may load the trained model into Oscova using the overloaded StartTraining() method.

    Example

    var bot = new OscovaBot();
    bot.Configuration.ProcessingMode = ProcessingMode.DeepOnly;
    bot.Dialogs.Add(new SomeDialog());
    bot.Trainer.StartTraining(XDocument.Load("Trained_Model.xml"));
    

    Training via Syn Bot Studio

    To train Oscova's Neural Network via Syn Bot Studio you will first need to extract the TrainingDatafrom Oscova Bot. You can retrieve the training data as an XML Document by calling the GetTrainingData() method on the Trainer property.

    IMPORTANT

    Training via Syn Bot Studio is version dependent. If you are using a higher version of Syn.Botframework you may follow the steps above to train Oscova in DeepOnly processing mode.

    Example

    var bot = new OscovaBot();
    bot.Configuration.ProcessingMode = ProcessingMode.DeepOnly;
    bot.Dialogs.Add(new PizzaDialog());
    var trainingDocument = bot.Trainer.GetTrainingData();
    trainingDocument.Save("TrainingData.xml"); //Saves the training data to an XML file.
    

    After the training data is saved follow the steps below to generate a trained neural network model.

    • Launch Syn Bot Studio, click on Tools select Oscova and then choose Neural Network Trainer
    • In Neural Network Trainer window, click on Browse... and select the TrainingData.xmlfile.
    • To begin training, click on Start Training.

    Oscova Neural Network Trainer

    Selecting minimum Loss

    The lower the Loss of the Neural Network the better trained is the model. After clicking on Start Training the Loss-Step chart will display the current Loss of the network.

    If the Loss is way above the specified Minimum Loss value and there is no significant change in the value for long, restart the training by clicking on Stop Training and then clicking on Start Training back again.

    If the Loss value is close to the specified Minimum Loss value and there is no significant change in the value for long, stop the training and you will be presented with the Minimum Loss Achievedvalue. Using this value as reference adjust the Minimum Loss and press Start Training again.

    NOTE

    It may take several minutes for the Neural Network to be trained depending on the number of internal samples generated for each expression.

  • 相关阅读:
    工具
    选择排序
    c#中queue的用法
    c#加密
    话谈c#拷贝
    const与readonly的区别
    WinForm中使MessageBox实现可以自动关闭功能
    c#winform关闭窗口时触发的事件
    委托
    C# STA和MTA线程设置
  • 原文地址:https://www.cnblogs.com/mrtiny/p/9082842.html
Copyright © 2011-2022 走看看