NLU in docker "can't find model 'nl'"

Hi there!

I’m a student currently working on my master’s degree at KULeuven, developing a chatbot application for an internship partner.

I’ve tried to get my NLU+Core running in Docker and finally have it up and running and answering to requests, however… I am running into quite some error due to me using Dutch language in SpaCy and I am unable to solve it.

I am using this docker compose file: version: ‘3.0’

services:
 rasa_core:
  image: rasa/rasa_core:latest
  ports:
   - 5005:5005
  volumes:
   - ./models/dialogue:/app/models
   - ./config:/app/config
  command:
   - start
   - --core
   - models
   - -c
   - rest
   - --endpoints
   - config/endpoints.yml
   - --nlu
   - current/
   
   
 rasa_nlu:
  image: rasa/rasa_nlu:latest-spacy
  volumes:
   - ./models:/app/models
  command:
   - start
   - --path
   - models

Everything is working, except when I post ANY request to my running agent through postman:

The Docker CLI returns this error: CLI

It appears to be that it cannot find my model ‘nl’ which is the SpaCy ‘nl’ pipeline I use to train the NLU model.

Also: when utilizing:

command:
   - download
   - spacy nl
   - start
   - --path
   - models

in the command section of the NLU service, the CLI returns next notification after docker-compose up: CLI_NL

Question is: Is there any way to actually get it to correctly parse my Dutch requests? How can I solve the problem that it cannot parse text through the ‘nl’ pipeline?

Thanks in advance.

One of the ways would be to mount another volume in your docker-compose of rasa_nlu like ./language_models:/app/language_models

download the spacy nl model from here: Release nl_core_news_sm-2.1.0 · explosion/spacy-models · GitHub

unzip and save it in the folder(./language_models/nl) - make sure that the root folder contains vectors/parser and taggers and they are placed right after the nl folder.

in your rasa_nlu config file - instead of the language code(nl/fr/de) use the path - language_models/nl yeah you will need to map your config file for nlu instead of relying on defaults your config could look like this:

language: "language_models/nl"

pipeline:

# all components will use their default values

- name: "ner_duckling_http"
  locale: "nl_Nothing"
  url: "http://duckling:8000"
- name: "intent_featurizer_count_vectors"
- name: "intent_classifier_tensorflow_embedding"

Hi souvikg10,

Thank you for the fast reply, I’ve implemented your solution and have tried running everything again. I quickly noticed I had to rerun the NLU training command, which I do like this: Elmer@Elmer-HP MINGW64 ~/Documents/KULeuven/Masterproef_Project/project

$ docker run -v $(pwd):/app/project -v $(pwd)/models/:/app/models -v $(pwd)/lan
    guage_models:/app/language_models rasa/rasa_nlu:latest-spacy run /app/project/i
    nitprobeersel.sh

The contents of the initprobeersel.sh file are as follows:

#python -m spacy download nl_core_news_sm
#python -m spacy link nl_core_news_sm nl
python -m rasa_nlu.train -c /app/project/nlu_config.yml -d /app/project/nlu.md -o models --project current

The nlu_config.yml now looks like this as you advised:

language: "language_models/nl"
pipeline: spacy_sklearn

And lastly, a screenshot indicating my current folder structure: image

The train command returns this error: image

I am operating completely outside my education expertise so any and all followup advice is more than welcomed. Thanks again.

in my solution, you have to download the model manually and then place it in the folder mentioned instead. if you download the model as above, like you have mentioned, you are downloading it as a module which would save the model in site-packages in pypi. you don’t need to do that

for the error, it seems there is an error with loading the model with correct shape which could be linked to the compatibility of the model with the correct version of spaCy. can you check which version of spaCy you are running?

Hello again.

My apologies, I forgot to mention the above lines you quoted are commented, hence they are not being run. I’ve followed the lines you recommended and left out the spacy download lines in the init file. It only contains the line: python -m rasa_nlu.train -c /app/project/nlu_config.yml -d /app/project/nlu.md -o models --project current

The spacy archive has been downloaded and manually located as I mentioned in my previous answer.

The SpaCy version I am running is 2.1.3: image

Hi @Heindrich,

I was wondering if you had any success with the implementation suggested by @souvikg10 ?

I am working on a similar configuration (I want to use French spacy) and I am facing some issues.

Thanks in advance.

Nevermind,

I think I found the solution to my issue. I will post it here in case someone need it.

I created a new image from the rasa:1.1.4 :

Here is my Dockerfile content :

FROM rasa/rasa:1.1.4-spacy-en

RUN python -m spacy download fr_core_news_md

RUN python -m spacy link fr_core_news_md fr

COPY requirements.txt requirements.txt

RUN pip install -r requirements.txt

with requirements.txt coming from rasa:1.1.4 where i added my custom dependencies.

And then followed the tutorial Rasa with Docker.