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