自己的笔记,只是写给自己偶尔复习一下rasa的。只有我自己能看懂这篇含糊其辞语焉不详的文章。
如何安装rasa?
参考官方文档:rasa安装
如何初始化一个rasa项目?
rasa init
"Creates a new project with example training data, actions, and config files."——by rasa document
需要自己编写哪些文件?
domain.yml
更多信息请参考官方文档:Domain
The domain defines the universe in which your assistant operates. It specifies the intents, entities, slots, responses, forms, and actions your bot should know about. It also defines a configuration for conversation sessions.
示例:
version: "2.0"
intents:
- affirm
- deny
- greet
- thankyou
- goodbye
- search_concerts
- search_venues
- compare_reviews
- bot_challenge
- nlu_fallback
- how_to_get_started
entities:
- name
slots:
concerts:
type: list
influence_conversation: false
venues:
type: list
influence_conversation: false
likes_music:
type: bool
influence_conversation: true
responses:
utter_greet:
- text: "Hey there!"
utter_goodbye:
- text: "Goodbye :("
utter_default:
- text: "Sorry, I didn't get that, can you rephrase?"
utter_youarewelcome:
- text: "You're very welcome."
utter_iamabot:
- text: "I am a bot, powered by Rasa."
utter_get_started:
- text: "I can help you find concerts and venues. Do you like music?"
utter_awesome:
- text: "Awesome! You can ask me things like \"Find me some concerts\" or \"What's a good venue\""
actions:
- action_search_concerts
- action_search_venues
- action_show_concert_reviews
- action_show_venue_reviews
- action_set_music_preference
session_config:
session_expiration_time: 60 # value in minutes
carry_over_slots_to_new_session: true
- intent
In a given user message, the thing that a user is trying to convey or accomplish (e,g., greeting, specifying a location).
示例:
intents:
- greet:
use_entities:
- name
- first_name
ignore_entities:
- location
- age
- entity
Keywords that can be extracted from a user message. For example: a telephone number, a person's name, a location, the name of a product
示例:
entities:
- PERSON
- time
- city:
roles:
- from
- to
- topping:
groups:
- 1
- 2
- slot
A key-value store that Rasa uses to track information over the course of a conversation.
类型:
- text
- bool
- categorical
- float
- list
- any
- Custom Slot Types
- response
A message that an assistant sends to a user. This can include text, buttons, images, and other content.
- form
A type of custom action that asks the user for multiple pieces of information.
示例:
forms:
restaurant_form:
required_slots:
cuisine:
- type: from_entity
entity: cuisine
num_people:
- type: from_entity
entity: number
- action
After each user message, the model will predict an action that the assistant should perform next. This page gives you an overview of the different types of actions you can use.
actions.py
更多信息请参考官方文档:Custom Actions
A custom action can run any code you want, including API calls, database queries etc. They can turn on the lights, add an event to a calendar, check a user's bank balance, or anything else you can imagine.
stories.yml
更多信息请参考官方文档:Stories
Stories are a type of training data used to train your assistant's dialogue management model. Stories can be used to train models that are able to generalize to unseen conversation paths.
rules.yml
更多信息请参考官方文档:Rules
Rules are a type of training data used to train your assistant's dialogue management model. Rules describe short pieces of conversations that should always follow the same path.
nlu.yml
更多信息请参考官方文档:NLU Training Data
NLU training data stores structured information about user messages.
config.yml
更多信息请参考官方文档:Model Configuration
The configuration file defines the components and policies that your model will use to make predictions based on user input.
如何训练?
rasa train
“Trains a model using your NLU data and stories, saves trained model in ./models.”——by rasa document