HitmanDark
Posts: 10
Joined: Fri Feb 21, 2020 1:14 am

SIML Document is too big, how do I compress/reduce size?

Wed Apr 22, 2020 12:04 am

I've written up a pretty extensive SIML project and exported it as an SIML Modern Document, its size is 2.5MB. Whenever I export and implement it into my C# application it starts running very slow. I've tested my app with a 14KB SIML file and it wasn't as slow at all, which proves that the size of the file is slowing it down.
Please please, is there any way to reduce the size of the SIML Modern file significantly whiles keeping its contents?

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

Re: SIML Document is too big, how do I compress/reduce size?

Wed Apr 22, 2020 8:09 am

SIML file size to my knowledge does not affect the performance of your bot unless it hinders with the normalization or pre-processing of user input. We've worked with even 15 MB to 100 MB SIML modern projects.

Your SIML contents are converted into normal C# classes during the parsing process. Only the response part is kept for evaluation after an expression is matched.

If you've got the SIML file in some open repository you can share the link privately and we can have a look and let you know what's actually causing a performance hit.

HitmanDark
Posts: 10
Joined: Fri Feb 21, 2020 1:14 am

Re: SIML Document is too big, how do I compress/reduce size?

Wed Apr 22, 2020 7:05 pm

I have both the project in question and the SIML document in repositorys, how do I contact you privately?

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

Re: SIML Document is too big, how do I compress/reduce size?

Wed Apr 22, 2020 9:07 pm

Click the chat bubble icon on the right below my avatar to send a private message.

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

Re: SIML Document is too big, how do I compress/reduce size?

Thu Apr 23, 2020 9:50 am

Firstly, your SIML code is very well written. You've used most of the concepts of the SIML Modern specifications in the right places.

We checked your code base by exporting your project to a Single SIML Document and loading it into Oscova. You've got over 12,000 Intents and the average processing time is 0.3 seconds. Which seems to be fine at the moment. Nothing seems to be halting the intent generation process.

A lot of the intents are related to small talks. I recommend that you remove them and create a separate based for like:
  • Greetings.siml (hi, hello, how are you)
  • Praise.simll (thank you, you are great, that was helpful)
  • Close.siml (bye, take care, see you)
The rest seems fine to us at the moment.

CSharp Code

using System;
using System.Diagnostics;
using System.Xml.Linq;
using Syn.Bot.Oscova;

namespace SimlBotProject
{
    class Program
    {
        static void Main(string[] args)
        {
            var bot = new OscovaBot();
            bot.Import(XDocument.Load("fleming-bot.siml"));
            bot.Trainer.StartTraining();

            var stopWatch = Stopwatch.StartNew();

            Console.WriteLine($"Total number of Intents: {bot.Stats.IntentCount}");

            bot.MainUser.ResponseReceived += (sender, eventArgs) =>
            {
                Console.WriteLine($"{eventArgs.Response.Text}:[{stopWatch.ElapsedMilliseconds}]");
            };

            while (true)
            {
                var request = Console.ReadLine();

                stopWatch.Restart();
                var evaluationResult = bot.Evaluate(request);
                evaluationResult.Invoke();
            }
        }
    }
}


HitmanDark
Posts: 10
Joined: Fri Feb 21, 2020 1:14 am

Re: SIML Document is too big, how do I compress/reduce size?

Fri Apr 24, 2020 5:39 am

So instead of having files with a lot of small talk intents I should rather make all of them individual .siml files?

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

Re: SIML Document is too big, how do I compress/reduce size?

Sun Apr 26, 2020 12:35 pm

Actually what I meant is that you could remove unnecessary small-talk intents. Remember the rule of thumb is to help the user find the right information and avoid chit chatting about things that aren't informative. The bot should just greet the user and drive the conversation into the right direction.

HitmanDark
Posts: 10
Joined: Fri Feb 21, 2020 1:14 am

Re: SIML Document is too big, how do I compress/reduce size?

Thu Apr 30, 2020 6:23 am

Leslie wrote:
Sun Apr 26, 2020 12:35 pm
Actually what I meant is that you could remove unnecessary small-talk intents. Remember the rule of thumb is to help the user find the right information and avoid chit chatting about things that aren't informative. The bot should just greet the user and drive the conversation into the right direction.
It seems as if the problem is persisting. Is there any other way to implement the Oscova bot like using SIML Package or .west file? Or can I send you my project source code to see if there's something wrong with how I'm doing things?

User avatar
Fantom
Help & Support
Posts: 312
Joined: Fri Oct 25, 2013 9:20 pm

Re: SIML Document is too big, how do I compress/reduce size?

Fri May 01, 2020 2:53 pm

Can you tell us what is the actually issue? is it the performance? how slow is the bot compared to the above metrics.

HitmanDark
Posts: 10
Joined: Fri Feb 21, 2020 1:14 am

Re: SIML Document is too big, how do I compress/reduce size?

Sun May 03, 2020 7:09 am

Fantom wrote:
Fri May 01, 2020 2:53 pm
Can you tell us what is the actually issue? is it the performance? how slow is the bot compared to the above metrics.
https://imgur.com/DoQzmBC
This is my chatbot app in action. The first part is the 14kb SIML and it works perfectly, being able to send a message instantly. The second part is the 2mb SIML and you realize that it basically freezes the app i.e. the Textbox freezes, the tap effect on the send button freezes and it takes approximately 10 seconds for the message to be sent.

Now, I am developing my app with Xamarin Forms and the chatbot is being in one out of four of the pages, so it is a full-fledged app with other features and many components.
This is the code that I'm using to integrate Oscova and get the chatbot to work in the ViewModel, idk, maybe I'm doing something wrong?:

CSharp Code

public ChatbotPageViewModel()
        {
            SendCommand = new RelayCommand(Send);
            BackArrowCommand = new RelayCommand(Back);

            chatbot = new OscovaBot();
            var assembly = IntrospectionExtensions.GetTypeInfo(typeof(MainPage)).Assembly;
            Stream stream = assembly.GetManifestResourceStream("BluePillApp.Helpers.new3.siml");

            chatbot.Import(XDocument.Load(stream));
            chatbot.Trainer.StartTraining();

            //This gets the chatbots response for each message
            chatbot.MainUser.ResponseReceived += (sender, args) =>
            {
                //await Task.Delay(1000);
                Messages.Add(new ChatMessageModel() { Text = args.Response.Text, User = App.ChatBot });
            };
        }

/// <summary>
        /// This function sends a message
        /// </summary>
        public void Send()
        {
            if (!string.IsNullOrEmpty(TextToSend))
            {
                var msgModel = new ChatMessageModel() { Text = TextToSend, User = App.User };

                //This adds a new message to the messages collection
                Messages.Add(msgModel);
                
                var result = chatbot.Evaluate(TextToSend);
                result.Invoke();

                //Removes the text in the Entry after message is sent
                TextToSend = string.Empty;
            }
        }

Return to “Report Bugs and Issues”

Who is online

Users browsing this forum: No registered users and 4 guests