Questions about Duckling

Hi, I understand that duckling uses a fixed pre-trained model and that the entire text input given by user will be given as input to duckling when duckling is mentioned in the pipeline. Now, does that mean whatever I get as output here for a given input will also be same in rasa?

Well, Rasa will provide all the information that comes out of duckling BUT this doesn’t mean slot filling will happen automatically for all dimensions

For example TIME is very tricky specially if there is a time range, those don’t get auto-filled. you would need some kind of wrapper to handle ranges.

edit: the website you mentioned is the older version of duckling. This is the latest repo reworked in Haskell

Okay, so in that website, I was able to get the desired output for inputs like tomorrow 6 am, from 20th Aug to 23th Sept etc. But when I tried out cases like - hey can you book a room tomorrow at 6 am, it failed. So I’m trying to understand if rasa does something before sending the user input to duckling for date extraction. Or should this be because it’s old now?

Also, what happens if duckling is not able to extract the date? Will it give an approximate date? Is there any documentation for duckling explaining in details about how it works? The README file doesn’t give a lot of information.

When you tried this, do you have a slot configured in Rasa? You can check the logs of what duckling returned to Rasa. Rasa does not do any pre processing before sending a message to duckling

Duckling is basically a regular expression on steroids. It does not do any approximation. If you are slightly familiar with Haskell, you can see how the bindings are created. It is indeed more advanced than a simple regular expression since you can create patterns for different variations of input.

About the time dimension. it is quite a tricky one. time ranges cannot be used for slot filling since there are no slot types in rasa that handles ranges and thus you would need to fill it in a custom action. ranges are not very well handled by duckling either specially when it comes to time.

1 Like

No. Sorry if I did not make it clear. I was only trying to see how outputs are when I give such inputs in the duckling try-it-out website.

It said “Duckling can’t answer”

pull the rasa/duckling:latest image from dockerhub

run the image on your machine - docker run -p 8000:8000 rasa/duckling

on another terminal run curl curl -XPOST http://0.0.0.0:8000/parse --data 'locale=en_GB&text=tomorrow at eight'

This should give you experimental results you are looking for from the latest duckling

1 Like

Thanks. I tried this and I got this output

[{"body":"tomorrow","start":0,"value":{"values":[{"value":"2021-12-02T00:00:00.000-08:00","grain":"day","type":"value"}],"value":"2021-12-02T00:00:00.000-08:00","grain":"day","type":"value"},"end":8,"dim":"time","latent":false}]curl: (6) Could not resolve host: at
curl: (6) Could not resolve host: eight

I tried with a different text = can you book a ticket for me tomorrow at 6 pm

[]curl: (6) Could not resolve host: you
curl: (6) Could not resolve host: book
curl: (6) Could not resolve host: a
curl: (6) Could not resolve host: ticket
curl: (6) Could not resolve host: for
curl: (6) Could not resolve host: me
curl: (6) Could not resolve host: tomorrow
curl: (6) Could not resolve host: at
curl: (6) Could not resolve host: 6
curl: (6) Could not resolve host: pm

can you share the command you ran? seems like there might be something missing in your request

curl -XPOST http://localhost:8000/parse --data text=tomorrow at eight

I did this because curl -XPOST http://localhost:8000/parse --data ‘locale=en_GB&text=tomorrow at eight’ threw an error

Need a 'text' parameter to parse'text' is not recognized as an internal or external command,
operable program or batch file.

please add the quotes and locale curl -XPOST http://0.0.0.0:8000/parse --data 'locale=en_GB&text=tomorrow at eight'

you have a character encoding issue in your terminal. type the quotes from your keyboard instead of copying from here. sometimes it can be an issue

Ohh okay yeah. the single quotes was the problem. Thanks a lot!

I tried for this text (especially because you pointed out that date ranges are going to be tricky) - can you check for ticket availabilty between 20-11-2020 and 21-02-2021

[{"body":"between 20-11-2020 and 21-02-2021","start":38,"value":{"values":[{"to":{"value":"2021-02-22T00:00:00.000-08:00","grain":"day"},"from":{"value":"2020-11-20T00:00:00.000-08:00","grain":"day"},"type":"interval"}],"to":{"value":"2021-02-22T00:00:00.000-08:00","grain":"day"},"from":{"value":"2020-11-20T00:00:00.000-08:00","grain":"day"},"type":"interval"},"end":71,"dim":"time","latent":false},{"body":"02-2021'","start":64,"value":{"to":{"value":2021,"unit":"foot"},"from":{"value":2,"unit":"foot"},"type":"interval"},"end":72,"dim":"distance","latent":false}]

Do you know why the to value is recognized as date+1 (22-02-2021 instead of 21-02-2021).

P.S: This was with en_IN

Duckling intervals are upper exclusive for the grain https://github.com/facebook/duckling/issues/29 - see the last comment here.

Ohh, so I have to handle this then, is it?

Yup. In Rasa you can handle this in custom action based on slot mappings.

Right. One last question -

About the time dimension. it is quite a tricky one. time ranges cannot be used for slot filling since there are no slot types in rasa that handles ranges and thus you would need to fill it in a custom action. ranges are not very well handled by duckling either specially when it comes to time.

So this means I have to

  1. Handle the to date (make it date - 1)
  2. Since there is no slot type to handle ranges, I should probably define two other slots and set those with the from and to values.

Or is there any better way of doing this?

Indeed. I don’t see another way for duckling.

For DIET trained entities you can use entity roles and groups but duckling, you would need two slots and fill them in as duckling provides in ranges.

be aware, ranges are extremely complicated in general and duckling often misses the mark.

Refer to this thread

1 Like

Thanks a lot! @souvikg10

how to change to indian time zone ?