2

我正在尝试构建一个与 LUIS 模型对话的机器人。该机器人将有 35 个场景,每个场景对应一个 LUIS 意图。目前,LUIS 最多支持 20 个意图。如何在我的代码中扩展它?我想知道是否最好有一个 LUIS 模型层次结构,父模型调用特定的子模型。或者我应该在我的数据库中维护一个关键字列表并基于它调用一个特定的模型。我需要帮助来评估这两种方法的优缺点。谢谢!

4

1 回答 1

2

我建议您尝试使用 BestMatchDialog 替换尽可能多的场景(至少 15 个)。

您仍将使用 LuisDialog 作为您的根对话框。这是一个例子:

 [Serializable]
public class GreetingsDialog: BestMatchDialog<bool>
{
    [BestMatch(new string[] { "Hi", "Hi There", "Hello there", "Hey", "Hello",
        "Hey there", "Greetings", "Good morning", "Good afternoon", "Good evening", "Good day" },
       threshold: 0.5, ignoreCase: true, ignoreNonAlphaNumericCharacters: true)]
    public async Task WelcomeGreeting(IDialogContext context, string messageText)
    {
        await context.PostAsync("Hello there. How can I help you?");
        context.Done(true);
    }

    [BestMatch(new string[] { "bye", "bye bye", "got to go",
        "see you later", "laters", "adios" })]
    public async Task FarewellGreeting(IDialogContext context, string messageText)
    {
        await context.PostAsync("Bye. Have a good day.");
        context.Done(true);
    }

    public override async Task NoMatchHandler(IDialogContext context, string messageText)
    {
        context.Done(false);
    }
}

从你的 LuisDialog 你可以这样称呼它

 [LuisIntent("None")]
    [LuisIntent("")]
    public async Task None(IDialogContext context, IAwaitable<IMessageActivity> message, LuisResult result)
    {
        var cts = new CancellationTokenSource();
        await context.Forward(new GreetingsDialog(), GreetingDialogDone, await message, cts.Token);
    }

上面的代码是从Ankitbko 的 MeBot repo借来的。

于 2016-11-24T17:57:39.917 回答