RASA(一)
layout: post
title: rasa_chatbot
subtitle:
date: 2020-7-24
author: RJ
header-img:
catalog: true
tags:
- NLP
環境配置
pip install -n rasa python==3.7
pip3 install rasa==2.0.0rc1
conda install pytorch==1.5.1 torchvision==0.6.1 cudatoolkit=10.1 -c pytorch
pip install "rasa[transformers]"
三種model
Chinese_models_for_SpaCy models
pip install https://github.com/explosion/spacy-models/releases//tag/zh_core_web_lg-2.3.1/zh_core_web_lg-2.3.1.tar.gz
[MITIE]
[HFTransformer] pip install “rasa[transformers]”
智慧客服機器人
[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片儲存下來直接上傳(img-btiiabny-1601180411302)(https://raw.githubusercontent.com/rejae/rejae.github.io/master/img/15964501511980.png)]
Rasa研究使用
- Create a New Project
- View Your NLU Training Data
- Define Your Model Configuration
- Write Your First Stories
- Define a Domain
- Train a Model
- Test Your Assistant
- Talk to Your Assistant
rasa init --no-prompt (1. Create a New Project, if you use --no-prompt you will get a default project, or you could use rasa train latter)
cat data/nlu.md (nlu.md is your train data)
cat config.yml
cat data/stories.md
cat domain.yml
rasa train
rasa test
rasa shell
Core
Stories
Domains
Responses
Actions
Reminders and External Events
Policies
Slots
Forms
Retrieval Actions
Interactive Learning
Fallback Actions
Knowledge Base Actions
Stories.md and nlu.md
- data/nlu.md ‘*’ your NLU training data
- data/stories.md ‘*’ your stories
1、Stories
Rasa stories are a form of training data used to train the Rasa’s dialogue management models.
A story is a representation of a conversation between a user and an AI assistant, converted into a specific format where user inputs are expressed as corresponding intents (and entities where necessary) while the responses of an assistant are expressed as corresponding action names.
## story 標題
>> checkpoint
* intent
- action
- xxx_form
- form{"name":"xxx_form"}
## story_happy
>> activate restaurant form
- ...
* request_restaurant
- restaurant_form
- form{"name": "restaurant_form"}
把以上內容儲存到 stories.md檔案中
呼叫執行:
rasa train core -d domain.yml -s data/stories.md --out models -c config.yml
2、 訓練資料 nlu.md
[training-data-format](https://rasa.com/docs/rasa/nlu/training-data-format/)
The training data for Rasa NLU is structured into different parts:
- common examples (required)
- synonyms
(Synonyms will map extracted entities to the same name, for example mapping “my savings account” to simply “savings”. However, this only happens after the entities have been extracted, so you need to provide examples with the synonyms present so that Rasa can learn to pick them up)
- regex features
(Regex features are a tool to help the classifier detect entities or intents and improve the performance.)
- lookup tables
(Lookup tables may be specified as plain text files containing newline-separated words or phrases. Upon loading the training data, these files are used to generate case-insensitive regex patterns that are added to the regex features.)
synonyms: use the new format [savings account]{"entity": "source_account", "value": "savings"}
Domain.yml
domain可以理解為機器的知識庫,其中定義了意圖,動作,以及對應動作所反饋的內容。
其中槽位和實體重合度較高
intents 意圖
actions 動作
templates 回答模板
entities 實體
slots 詞槽
config.yml
language: zh
pipeline:
- name: HFTransformersNLP
model_name: "bert"
model_weights: "bert-base-chinese"
cache_dir: "D:\\model_files"
- name: LanguageModelTokenizer
- name: LanguageModelFeaturizer
- name: LexicalSyntacticFeaturizer
- name: CRFEntityExtractor
- name: EntitySynonymMapper
- name: DIETClassifier
epochs: 200
policies:
- name: "rasa.core.policies.ted_policy.TEDPolicy"
epochs: 120
featurizer:
- name: MaxHistoryTrackerFeaturizer
max_history: 5
state_featurizer:
- name: BinarySingleStateFeaturizer
- name: "rasa.core.policies.memoization.MemoizationPolicy"
max_history: 5
- name: "rasa.core.policies.form_policy.FormPolicy"
- name: "rasa.core.policies.mapping_policy.MappingPolicy"
- name: "rasa.core.policies.fallback.FallbackPolicy"
nlu_threshold: 0.4
core_threshold: 0.3
ambiguity_threshold: 0.05
fallback_action_name: 'action_fallback'
# Configuration for Rasa NLU.
# https://rasa.com/docs/rasa/nlu/components/
language: zh
pipeline:
- name: MitieNLP
model: data/total_word_feature_extractor_zh.dat
- name: JiebaTokenizer
dictionary_path: D:/rasa_workspace/.rasa_p2/data/dict/user_dict.txt
- name: MitieEntityExtractor
- name: EntitySynonymMapper
- name: RegexFeaturizer
- name: MitieFeaturizer
- name: SklearnIntentClassifier
policies:
- name: MemoizationPolicy
- name: TEDPolicy
max_history: 5
epochs: 100
- name: MappingPolicy
reference
基於RASA的task-orient對話系統解析(二)——對話管理核心模組
基於RASA的task-orient對話系統解析(三)——基於rasa的會議室預定對話系統例項
參考
git clone https://github.com/mit-nlp/MITIE.git
cd MITIE
python setup.py install
相關文章
- rasa 如何寫一個故事
- Rasa 聊天機器人專欄(下)機器人
- Rasa 聊天機器人專欄(上)機器人
- Rasa init報錯:AttributeError: type object 'Callable' has no attribute '_abc_registry'ErrorObject
- Rasa中使用lookup table時針對中文對RegexEntityExtractor進行修改
- rasa form的中斷形式 自然機器語言學習 人工智慧ORM人工智慧
- 每日一練(一)
- 一筆一劃教你寫一簽名
- 一次一密
- 一條唯一索引索引
- 一步一步實現一個PromisePromise
- Mysql 一主一從配置MySql
- 一、JVM專欄之一JVM
- 一比一還原axios原始碼(一)—— 發起第一個請求iOS原始碼
- MyBatis 使用resultMap 以及 一對一和一對多MyBatis
- 一杯茶,一支菸,一行程式碼寫一天 !行程
- 一對一直播原始碼助力一對一教育,進入直播3.0時代!原始碼
- L1-030 一幫一
- 一、一加9刷入LineageOS
- 弘一法師語錄一
- 一步一步來
- 一對一聊天ajax實現
- promise原理—一步一步實現一個promisePromise
- 自由職業一時爽,一直自由一直爽
- 一步一步帶你掌握webpack(一)——入門Web
- 一天一個設計模式(一) - 總體概述設計模式
- 為什麼反向關聯 一對一和一對多都是同一個方法
- JPA(3) 表關聯關係(多對一、一對多、多對多、一對一)
- 什麼是一對一直播原始碼?一對一直播為何產生?原始碼
- excel表格複製貼上格式怎麼能一模一樣 表格怎麼複製一個一模一樣的Excel
- 華為雲FusionInsight MRS:助力企業構建“一企一湖,一城一湖”
- gorm 關係一對一,一對多,多對多查詢GoORM
- 一顆燈 一束光 一片葉 很寧靜
- PHP產生一個唯一IDPHP
- Golang一日一庫之logrusGolang
- Golang一日一庫之gjsonGolangJSON
- 第一梯隊,增速第一
- 一步一步上手MyBatisPlusMyBatis