from rasa_nlu.training_data import load_data
from rasa_nlu.model import Trainer
from rasa_nlu import config
training_data = load_data('data/examples/rasa/demo-rasa.json')
trainer = Trainer(config.load("sample_configs/config_pretrained_embeddings_spacy.yml"))
trainer.train(training_data)
model_directory = trainer.persist('./projects/default/') # Returns the directory the model is stored in
Now I have 2 issues.
my training data isn’t in json format it is in yml format like so
version: “2.0”
nlu:
intent: greet
examples: |
hey
hello
hi
hello there
good morning
good evening
moin
hey there
let’s go
hey dude
goodmorning
goodevening
good afternoon
How do I use yml file to load the training data. I get this error when I try to load a yaml file.
ValueError: Unknown data format for file
config.load("sample_configs/config_pretrained_embeddings_spacy.yml")
throws this error
I fear that you’re referring to a rather old 0.x version of Rasa that isn’t supported anymore. In modern versions of Rasa the training is triggered from the command line via;
rasa train
Is there a reason why you’re using such an old version?
Technically, they are trained seperately in 2.x. You can confirm by running:
rasa train --help
usage: rasa train [-h] [-v] [-vv] [--quiet] [--data DATA [DATA ...]]
[-c CONFIG] [-d DOMAIN] [--out OUT] [--dry-run]
[--augmentation AUGMENTATION] [--debug-plots]
[--num-threads NUM_THREADS]
[--fixed-model-name FIXED_MODEL_NAME] [--persist-nlu-data]
[--force] [--finetune [FINETUNE]]
[--epoch-fraction EPOCH_FRACTION]
{core,nlu} ...
positional arguments:
{core,nlu}
core Trains a Rasa Core model using your stories.
nlu Trains a Rasa NLU model using your NLU data.
That means that you can run:
rasa train nlu
To only run the NLU part of the pipeline. Or, if you only want the core policies:
Actually I want to write my own server using FastAPI, for that, I need the actual code. I do not want to start the Rasa server. So i think above commands will only work in I run the Rasa HTTPI API.
rasa run will open all the endpoints, my custom api will only have training endpoint that will train the models along with other custom endpoints. I have seen the blog post, it also train models using rasa train, which is not what i required.
What I am doing is, I have installed Rasa 2.8.8 and imported train from rasa.api and trying to train by giving paths. It did train for the first time but after that it is giving me this error
RuntimeError: This event loop is already running
Could you try running it in a normal python script? If memory serves, Jupyter is running in an async loop via Tornado which might be confusing the async code inside of Rasa.