Rasa NLU
Rasa NLU
In this exercise, you'll use Rasa NLU to create an interpreter, which parses incoming user messages and returns a set of entities. Your job is to train an interpreter using the MITIE entity recognition model in Rasa NLU.
- Create a dictionary called
argswith a single key"pipeline"with value"spacy_sklearn". - Create a
configby callingRasaNLUConfig()with the single argumentcmdline_argswith valueargs. - Create a
trainerby callingTrainer()using the configuration as the argument. - Create a
interpreterby callingtrainer.train()with thetraining_data.
================================================================
# Import necessary modules
from rasa_nlu.converters import load_data
from rasa_nlu.config import RasaNLUConfig
from rasa_nlu.model import Trainer
# Create args dictionary
args = {"pipeline": "spacy_sklearn"}
# Create a configuration and trainer
config = RasaNLUConfig(cmdline_args = args)
trainer = Trainer(config)
# Load the training data
training_data = load_data("./training_data.json")
# Create an interpreter by training the model
interpreter = trainer.train(training_data)
# Try it out
print(interpreter.parse("I'm looking for a Mexican restaurant in the North of town"))
Last modified: Thursday, 6 April 2023, 11:34 AM