当前位置:   article > 正文

搭建 rasa 框架流程_error initializing graph component for node run_la

error initializing graph component for node run_languagemodelfeaturizer1.
  1. 先初始化一个空工程,添加 compents、pre_models 路径
    在这里插入图片描述
  2. 在 config.yml 中增加 pipeline:定义 tokenizer 和 featurizer 和 classifier 等
language: en
pipeline:
  - name: WhitespaceTokenizer
    intent_tokenization_flag: True
  - name: LanguageModelFeaturizer
  - name: RegexFeaturizer
  - name: LexicalSyntacticFeaturizer
  - name: CountVectorsFeaturizer
  - name: CountVectorsFeaturizer
    analyzer: char_wb
    min_ngram: 1
    max_ngram: 4
  - name: DIETClassifier
    epochs: 200
policies:
- name: TEDPolicy
  epochs: 200

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
# Configuration for Rasa NLU.
# https://rasa.com/docs/rasa/nlu/components/
language: zh

pipeline:
  # # No configuration for the NLU pipeline was provided. The following default pipeline was used to train your model.
  # # If you'd like to customize it, uncomment and adjust the pipeline.
  # # See https://rasa.com/docs/rasa/tuning-your-model for more information.
  - name: compoments.nlu.tokenizers.bert_tokenizer.CustomBertTokenizer
    cache_dir: ./tmp
    model_weights: pre_models
  - name: LanguageModelFeaturizer
    cache_dir: ./tmp
    model_name: bert
    model_weights: pre_models
  - name: DIETClassifier
    epochs: 100
  - name: RegexEntityExtractor
  - name: EntitySynonymMapper
  - name: ResponseSelector
    epochs: 100
    retrieval_intent: rasa_faq
  - name: FallbackClassifier
    threshold: 0.3
    ambiguity_threshold: 0.1

# Configuration for Rasa Core.
# https://rasa.com/docs/rasa/core/policies/
policies:
# # No configuration for policies was provided. The following default policies were used to train your model.
# # If you'd like to customize them, uncomment and adjust the policies.
# # See https://rasa.com/docs/rasa/policies for more information.
   - name: AugmentedMemoizationPolicy
   - name: TEDPolicy
     max_history: 5
     epochs: 100
   - name: compoments.polices.ask_again_policy.AskAgainRulePolicy
     core_fallback_threshold: 0.5
     ask_again_intent: "再问一次"
     need_ask_again_intents:
      - "查询天气"

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  1. 定义 domain.yml 文件:这里主要需要定义 intents、responses、slots、entities、(forms)、actions 等
version: "2.0"

intents:
  - greet
  - goodbye
  - affirm
  - deny
  - mood_great
  - mood_unhappy
  - bot_challenge

responses:
  utter_greet:
  - text: "Hey! How are you?"
    buttons:
    - title: "great"
      payload: "/mood_great"
    - title: "super sad"
      payload: "/mood_unhappy"

  utter_cheer_up:
  - text: "Here is something to cheer you up:"
    image: "https://i.imgur.com/nGF1K8f.jpg"

  utter_did_that_help:
  - text: "Did that help you?"

  utter_happy:
  - text: "Great, carry on!"

  utter_goodbye:
  - text: "Bye"

  utter_iamabot:
  - text: "I am a bot, powered by Rasa."

session_config:
  session_expiration_time: 60  # value in minutes
  carry_over_slots_to_new_session: true

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
version: "2.0"

actions:
 - utter_greet
 - utter_suggest_cuisine
 - utter_search_restaurants

intents:
 - greet
 - affirm
 - deny
 - search_restaurant

responses:
  utter_greet:
  - text: "hi!"
  utter_suggest_cuisine:
  - text: "how about greek food?"
  - text: "how about chinese food?"
  - text: "how about italian food?"
  - text: "how about sushi?"
  utter_search_restaurants:
  - text: "great! here's what I found ..."

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  1. 定义 data 里的 yml 文件(默认 train 的路径是 data,这些 yml 文件就是训练数据)其中 nlu.yml 是 nlu 模型的训练数据,stories.yml、 rules.yml是 core 模型的训练数据
version: "2.0"

nlu:
  - intent: greet
    examples: |
      - 你好
      -- 您好
      - 早上好
      - 下午好
      - 晚上好
      --- intent: goodbye
    examples: |
      - good afternoon
      - cu
      - good by
      - cee you later
      - good night
      - bye
      - goodbye
      - have a nice day
      - see you around
      - bye bye
      - see you later
      - 明天见
      - 下次再见
      - 有缘再见
      - 江湖再见

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
version: "2.0"

stories:

- story: happy path
  steps:
  - intent: greet
  - action: utter_greet
  - intent: mood_great
  - action: utter_happy

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  1. 以上定义完成后就可以训练 rasa train nlu 模型了,会自动保存在 model 文件夹下,命名是时间戳 + .tar.gz
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/343652
推荐阅读
相关标签
  

闽ICP备14008679号