faq(frequency asked question), 常问问题,这类FAQ问题机器人,经过收集常见问题,以交互式方式实现人机问答。git
rasa应用中涉及的文件有:config.yml, nlu.md, stories.md, domain.yml。新增常见问题回答文件reponses.mdgithub
1. config.ymlsession
实现faq, 要有ResponseSelector, 它是一个监督式的检索模型,当用户的意图识别为faq意图后,经过responseSelector从预先定义的回复文本中检索生成回复,回复发送给respond_faq. app
# Configuration for Rasa NLU. # https://rasa.com/docs/rasa/nlu/components/ language: en pipeline: - name: WhitespaceTokenizer - name: RegexFeaturizer - name: LexicalSyntacticFeaturizer - name: CountVectorsFeaturizer - name: CountVectorsFeaturizer analyzer: "char_wb" min_ngram: 1 max_ngram: 4 - name: DIETClassifier epochs: 100 - name: EntitySynonymMapper - name: ResponseSelector epochs: 100 # Configuration for Rasa Core. # https://rasa.com/docs/rasa/core/policies/ policies: - name: MemoizationPolicy - name: TEDPolicy max_history: 5 epochs: 100 - name: MappingPolicy
2. nlu.mddom
在greet和goodbye意图基础上,添加faq意图,也可只保留faqui
## intent:greet - hey - hello - hi - good morning - good evening - hey there ## intent:goodbye - bye - goodbye - see you around - see you later ## intent:faq/ask_channels - what channels of communication does rasa support? - what channel do you support - what chat channels does rasa uses ## intent:faq/ask_languages - what language does rasa support? - which language do you support - which language supports rasa - languages supported
3. stories.mdspa
增长faqcode
## happy path * greet - utter_greet ## say goodbye * goodbye - utter_goodbye ## some questions from faq * faq - respond_faq
4. domain.ymlcomponent
intents, actions中需添加faqip
intents: - greet - goodbye - faq actions: - respond_faq responses: utter_greet: - text: "Hey! How are you?" utter_goodbye: - text: "bye" session_config: session_expiration_time: 60 carry_over_slots_to_new_session: true
5. responses.md
实现channel和language的回答
## ask channels * faq/ask_channels - we have a comprehensive from ask_channels ## ask languages * faq/ask_languages - you can use rasa to build assistants from ask_language
完整代码请走:https://github.com/hugLiu/rasa-faq/tree/main