SangramMCP
Posts: 57
Joined: Wed Jul 26, 2017 7:41 pm

Context Switching Issue

Fri May 18, 2018 4:05 pm

I have two dialogs
1.
public class TestDialog:Dialog
{


internal static class Cons
{
public const string YesNo = "confirm-detail";
public const string ShareDetail = "share-detail";
}


[Expression("@cab {late} for users")]
[Expression("need to {wait} for @cab")]
[Expression("we were {waiting} for @cab")]
[Expression("we were {waited} for @cab")]
[Entity("CabLateIssue")]
[Intent(Name = "issue_intent")]
public void CabLateIssue(Context context, Result result)
{
context.Add(Cons.YesNo);
result.SendResponse("Would you like to share more details?");
}

[Expression("@cab is not {ontime} today")]
[Entity("TurnUp")]
public void CabRefuseForTurnUp(Context context, Result result)
{


context.Add(Cons.YesNo);
result.SendResponse("Would you like to share more details?");

}

[Expression("@negative-context")]
[Context(Cons.YesNo)]
[Intent(Name = "no_intent")]
public void IntentThree(Context context, Result result)
{
context.Remove(Cons.YesNo);
result.SendResponse("As you wish. We have logged your message.");
}

[Expression("@positive-context")]
[Context(Cons.YesNo)]
[Intent(Name = "yes_intent")]
public void IntentTwo(Context context, Result result)
{
context.Remove(Cons.YesNo);
context.Add(Cons.ShareDetail);
result.SendResponse("Please go ahead type your concern in detail.");
}

[Expression("@sys.text")]
[Context(Cons.ShareDetail)]
[Intent(Name = "share_intent")]
public void ShareDetail(Context context, Result result)
{
context.Remove(Cons.ShareDetail);
var detail = result.Entities.OfType("sys.text");//Returns normalized value without punctuation marks.
result.SendResponse($"Your response: {result.Request.Text}");//Use Request to fetch original user message.
}



}

2.

[Expression("@cab did {not} {wait} for me")]
[Expression("@cab is {not} ready to come to {pick up} point")]
[Expression("@cab is {not} ready to come to {pick-up} point")]
[Expression("@cab is {not} ready to come to {pickup} point")]
[Expression("@cab {refuse} to come to {pick up} point")]
[Expression("@cab {refuse} to come to {pick-up} point")]
[Expression("@cab {refuse} to come to {pick up} point")]
[Expression("@cab {refuses} to come to {pickup} point")]
[Expression("@cab {refuses} to come to {pick up} point")]
[Expression("@cab {refuses} to come to {pick-up} point")]
[Expression("@cab {refused} to come to {pick up} point")]
[Expression("@cab {refused} to come to {pick-up} point")]
[Expression("@cab {refused} to come to {pickup} point")]
[Expression("@cab {refusing} to come to {pick up} point")]
[Expression("@cab {refusing} to come to {pick-up} point")]
[Expression("@cab {refusing} to come to {pickup} point")]
[Expression("@cab {hesitate} to come to {pick up} point")]
[Expression("@cab {hesitate} to come to {pick-up} point")]
[Expression("@cab {hesitate} to come to {pickup} point")]
[Expression("@cab {hesitates} to come to {pick up} point")]
[Expression("@cab {hesitates} to come to {pick-up} point")]
[Expression("@cab {hesitates} to come to {pickup} point")]
[Expression("@cab {hesitating} to come to {pick up} point")]
[Expression("@cab {hesitating} to come to {pick-up} point")]
[Expression("@cab {hesitating} to come to {pickup} point")]

[Entity("hesitate")]
[Entity("pickup")]
public void CabRefusePickup(Context context, Result result)
{


var response = new Response
{
Text = "Hey! I am in transport dialog",
Format = ResponseFormat.Html
};

result.SendResponse(response);


}

And the output:
Hi IBNE MASSUD, how can I help you today?
cab is late for the user
Would you like to share more details?
yes
Please go ahead type your concern in detail.
cab did not come to pickup point
Hey! I am in transport dialog

As per normal behavior: the response should be: "Your response: cab did not come to pickup point"
But it is out from the context. How to resolve this issue?

User avatar
Sreejith
Help & Support
Posts: 20
Joined: Sat Apr 06, 2013 6:16 pm

Re: Context Switching Issue [SOLVED]

Mon May 21, 2018 8:00 am

this is simple...after you are asking for detail from the user there are 2 intents that get confidence:

1. CabRefusePickup = 0.9745762 confidence
2. share_intent = 0.72 confidence

your dialog structure has Race-Condition (intents that are very similar to each other) intents...remember @sys.text entity has a default max confidence of 0.8

Solution 1:

please change your dialog structure so you dont have 2 intents that will have similar confidence for the same user input...this is what you should do for large projects.

Solution 2:


or increase isolated text entity confidence. OscovaBot.Configuration.Scoring.IsolatedTextEntityConfidence = 0.95;
If your experiment needs statistics, you ought to have done a better experiment - Ernest Rutherford

SangramMCP
Posts: 57
Joined: Wed Jul 26, 2017 7:41 pm

Re: Context Switching Issue

Mon May 21, 2018 10:46 am

If we are into any context, until and unless we clear the context, it should not out from the context.

I have tried with your second solution OscovaBot.Configuration.Scoring.IsolatedTextEntityConfidence = 0.95;.
But the issue is still persist.

I did not get properly the first solution.

Is it possible to set in the configuration, so that until and unless we clear the context in the code, the conversation continue with the added context?

I am using syn.bot 2.9.5.1 version.

User avatar
Leslie
Lead Software Architect
Posts: 377
Joined: Fri Sep 14, 2012 12:20 pm
Contact: Website

Re: Context Switching Issue

Mon May 21, 2018 4:06 pm

I have checked the second solution by Sreejith and it seems to be working just fine within a test dialog.

CSharp Code

using Syn.Bot.Oscova;
using Syn.Bot.Oscova.Attributes;

namespace TestConsole
{
    public class TestDialog : Dialog
    {
        internal static class Cons
        {
            public const string YesNo = "confirm-detail";
            public const string ShareDetail = "share-detail";
        }

        [Expression("@cab {late} for users")]
        [Expression("need to {wait} for @cab")]
        [Expression("we were {waiting} for @cab")]
        [Expression("we were {waited} for @cab")]
        [Entity("CabLateIssue")]
        [Intent(Name = "issue_intent")]
        public void CabLateIssue(Context context, Result result)
        {
            context.Add(Cons.YesNo);
            result.SendResponse("Would you like to share more details?");
        }

        [Expression("@cab is not {ontime} today")]
        [Entity("TurnUp")]
        public void CabRefuseForTurnUp(Context context, Result result)
        {
            context.Add(Cons.YesNo);
            result.SendResponse("Would you like to share more details?");
        }

        [Expression("@sys.negative")]
        [Context(Cons.YesNo)]
        [Intent(Name = "no_intent")]
        public void IntentThree(Context context, Result result)
        {
            context.Remove(Cons.YesNo);
            result.SendResponse("As you wish. We have logged your message.");
        }

        [Expression("@sys.positive")]
        [Context(Cons.YesNo)]
        [Intent(Name = "yes_intent")]
        public void IntentTwo(Context context, Result result)
        {
            context.Remove(Cons.YesNo);
            context.Add(Cons.ShareDetail);
            result.SendResponse("Please go ahead type your concern in detail.");
        }

        [Expression("@sys.text")]
        [Context(Cons.ShareDetail)]
        [Intent(Name = "share_intent")]
        public void ShareDetail(Context context, Result result)
        {
            context.Remove(Cons.ShareDetail);
            var detail = result.Entities.OfType("sys.text");
            result.SendResponse($"Your response: {result.Request.Text}");
        }

        [Expression("@cab did {not} {wait} for me")]
        [Expression("@cab is {not} ready to come to {pick up} point")]
        [Expression("@cab is {not} ready to come to {pick-up} point")]
        [Expression("@cab is {not} ready to come to {pickup} point")]
        [Expression("@cab {refuse} to come to {pick up} point")]
        [Expression("@cab {refuse} to come to {pick-up} point")]
        [Expression("@cab {refuse} to come to {pick up} point")]
        [Expression("@cab {refuses} to come to {pickup} point")]
        [Expression("@cab {refuses} to come to {pick up} point")]
        [Expression("@cab {refuses} to come to {pick-up} point")]
        [Expression("@cab {refused} to come to {pick up} point")]
        [Expression("@cab {refused} to come to {pick-up} point")]
        [Expression("@cab {refused} to come to {pickup} point")]
        [Expression("@cab {refusing} to come to {pick up} point")]
        [Expression("@cab {refusing} to come to {pick-up} point")]
        [Expression("@cab {refusing} to come to {pickup} point")]
        [Expression("@cab {hesitate} to come to {pick up} point")]
        [Expression("@cab {hesitate} to come to {pick-up} point")]
        [Expression("@cab {hesitate} to come to {pickup} point")]
        [Expression("@cab {hesitates} to come to {pick up} point")]
        [Expression("@cab {hesitates} to come to {pick-up} point")]
        [Expression("@cab {hesitates} to come to {pickup} point")]
        [Expression("@cab {hesitating} to come to {pick up} point")]
        [Expression("@cab {hesitating} to come to {pick-up} point")]
        [Expression("@cab {hesitating} to come to {pickup} point")]
        [Entity("hesitate")]
        [Entity("pickup")]
        public void CabRefusePickup(Context context, Result result)
        {
            var response = new Response
            {
                Text = "Hey! I am in transport dialog",
                Format = ResponseFormat.Html
            };
            result.SendResponse(response);
        }
    }
}

Actually there's a lot involved than simply selecting an intent with the same context when certain contexts are active. Oscova does prioritize intents with contexts but sometimes active contexts do not mean that certain intents should always receive higher scores.

Imagine 3 intents with 3 similar contexts but with different entity signatures. Which one would the engine choose? This is where the calibration process comes into play. The following list of expressions from 3 different intents should give you an idea as to how calibration works when the user says Yes.

[Expression("@sys.positive")] + Context
[Expression("@sys.negative")] + Context
[Expression("@sys.text")] + Context


Having seen your code, it is evident that the ShareDetail intent will receive less @sys.text confidence as the engine can never be fully confident if the value for @sys.text is a perfect match and although ShareDetail intent is still in the EvaluationResult collection its receiving somewhere around 5 % lesser score than CabRefusePickup intent. This sheds light on the statement that a engine should never come out of context unless the context is cleared.

You must change the logic here. Instead of creating an intent for every cab issue, you must instead create one intent that takes all issues. For this, firstly remove the CabRefusePickup intent as it directly competes with ShareDetail intent and secondly increase the confidence value of OscovaBot.Configuration.Scoring.IsolatedTextEntityConfidence to 0.9 as the default value is 0.8. Lastly, if your are running in Deep processing mode change it to Standard.

The logic should be:
  • Let the user specify an issue - Merge the expressions of CabRefuseIntent and CabLateIssue intents into a new CabIssue intent.
  • Give the user a list of options to choose from (cab was late, cab didn't arrive, cab driver refused pickup). Or give names to expressions using the Name attribute to check which expression was triggered within an intent body.
  • Let the user select an option
  • Later ask the user to elaborate.

Return to “Report Bugs and Issues”

Who is online

Users browsing this forum: No registered users and 1 guest