How To Create An Opensource NLU API With Rasa

You Have Access To An Exceptional Natural Language Understanding Tool

Introduction

Image for post
Image for post
Rasa NLU API called from Postman

NLU & Core

Image for post
Image for post
Rasa chatbot architecture with NLU portion marked.

NLU Data Format

Image for post
Image for post
The NLU.md file within the Rasa file structure

Intents & Entities

Simple Examples

## intent:check_balance
- How much money is on my account?
- what's my balance?
- what's my current balance?
- What's left on that account?
- How much do I have on that account?
- what's my [credit](account_type) account balance?
Image for post
Image for post
The intent is check_balance and the entity is account_type of credit.

Regular Expressions

## regex:accountNumber
- [0-9]{9}
## intent:inform_accountNumber
- my account number is [123454434](accountNumber)
- my account number is [334564343](accountNumber)
- my account number is [940564343](accountNumber)
Image for post
Image for post
The intent is marked and the entity of accountNumber is extracted.

Normalize Data

{"text":"Pay off my [credit card]{"entity": "account_type", "value": "credit"}, please"}
Image for post
Image for post
The input of creditcard accout is normalized to credit in the account_type entity.

Models

Image for post
Image for post
Different trained models can be invoked when running the API

Creating The API

conda activate rasa2
rasa run --enable-api -m models/nlu-20200917-225530.tar.gz
http://localhost:5005/model/parse
Image for post
Image for post
Sending a JSON query string to the Rasa API

Conclusion

Written by

NLP/NLU, Chatbots, Voice, Conversational UI/UX, CX Designer, Developer, Ubiquitous User Interfaces. www.cobusgreyling.me

Get the Medium app