Is it possible to use DIETClassifier with Duckling?

Hi! I’m new to Rasa. I have been tinkering with it for the past two weeks or so. I’m trying to build a more general bot. For now I want it to recognize some entities like artist and genre, just some custom ones to start, and the entities provided by Duckling. I also want it to recognize spaCy’s default entities if possible.

For now, I’ve put the custom entities and the Duckling entities in the domain, put some intents related to the custom entities and some responses related to the stories. It recognizes perfectly my custom entities on a newly trained model. But, if I create an interpreter and throw in some phrases with numbers, hours, dates for Duckling to pick up, nothing aside from DIETCassifier predictions show. It predicts the hours as artists and things like that.

I took the default config file and added:

  • name: “DucklingHTTPExtractor”

    url: “http://duckling:8000

    dimensions: [“time”, “number”, “amount-of-money”, “distance”] locale: “en_US”

    timezone: “America/New_York”

    timeout : 15

duckling in the url is the rasa/duckling container.

First before DIETClassifier, but I tried adding after too. I don’t know if it makes a difference (does it?).

So, do they work together? What approach should I take?

Thanks in advance :slight_smile:

Hi @ogabrielluiz! Yep, you can use spacy, diet, and Duckling side by side. but you shouldn’t annotate spacy or duckling entities in your training data – the annotation is only for the entity extractors that will learn on your training data (like DIET), not for rule-based or pre-trained ones (spacy and duckling).

But, if I create an interpreter and throw in some phrases with numbers, hours, dates for Duckling to pick up, nothing aside from DIETCassifier predictions show. It predicts the hours as artists and things like that.

Can you show your training data and the output of some of those phrases on rasa shell nlu?

Thanks for answering =) Here’s what you asked.

Today I want to listen to rock
    {
      "intent": {
        "name": "play_artist",
        "confidence": 0.9851589798927307
      },
      "entities": [
        {
          "entity": "artist",
          "start": 26,
          "end": 30,
          "extractor": "DIETClassifier",
          "value": "rock"
        }
      ],
      "intent_ranking": [
        {
          "name": "play_artist",
          "confidence": 0.9851589798927307
        },
        {
          "name": "play_genre",
          "confidence": 0.013811860233545303
        },
        {
          "name": "question",
          "confidence": 0.0010291538201272488
        }
      ],
      "text": "Today I want to listen to rock"

My data looks something like this:

## intent:play_genre
-  [boy band](genre)
-  [ragga jungle](genre)
-  [hard rock](genre)
-  [french pop](genre)
- play some [piano blues](genre)
- i want to listen to [alternative metal](genre)

## intent:play_artist
- play [tv on the radio](artist)
- i want to hear some [discipline](artist)
- play some [16 horsepower](artist)
- play some [elend](artist)
- i want to listen to [masterplan](artist)
- i want to hear some [david cross](artist)
- i want to listen to [busta rhymes](artist)
## intent:question
- what is [dressy bessy](artist)
- what is [meshuggah](artist)
- who started [sezen aksu](artist)
- who started [van halen](artist)

I just found out about EntityExtractor which I was able make it work with DIETClassifier. I think the problem in my model is due to it not being able to connect to my duckling container.

got it. yeah that training data looks good and so does the response!

How are you running the duckling container?

docker run -it --name duckling --rm rasa/duckling

When I tried the curl parse test it said connection refused. Maybe it has something to do with it.

Are you running rasa in a container or locally? If in a container, do you run it in the same network as the duckling container?

Rasa is locally, Duckling is in a container. Rasa version 1.9.3

Got it, thanks. In order for your local machine to be able to hit duckling, you’ll have to map the port to a local machine port. E.g. how I run it (same setup, local rasa, duckling in a container)

docker run -p 8000:8000 -d rasa/duckling 

and then I access it on http://localhost:8000

Can you try it that way?

Well… it worked!

quack!

I’m having trouble with asyncio when trying to run interactive mode so, if I want to run rasa in a container (just so I can have it in a more standardized way) would any of that change?

Thanks for the help @erohmensing !

If you’re running rasa in a container, you should either run both containers together in Docker Compose, or make sure they’re on the same docker network. In that case, since you’re using the internal references instead of mapping to your host machine, it would be http://duckling:8000 like you had before!

1 Like