Hi,
I am trying to train a conversational bot with the implementation of a custom component. The problem is that the training phase is stuck. It won’t finish and it will be always iteratively printing(“END”) as stated in askdata_component.py. My rasa version is 2.8.3 and python 3.8.
I am attaching my config and my component. Config:
language: "it" # your two-letter language code
pipeline:
- name: SpacyNLP
# language model to load
model: "it_core_news_md"
- name: SpacyTokenizer
- name: SpacyFeaturizer
# - name: RegexFeaturizer
- name: LexicalSyntacticFeaturizer
- name: CountVectorsFeaturizer
- name: CountVectorsFeaturizer
analyzer: "char_wb"
min_ngram: 1
max_ngram: 4
- name: DIETClassifier
epochs: 100
entity_recognition: False
constrain_similarities: True
model_confidence: linear_norm
- name: DucklingEntityExtractor
url: "http://localhost:8000"
locale: "it_IT"
#locale: "en_EN"
timezone: "Europe/Rome"
dimensions: ["time", "duration", "numeral"]
- name: EntitySynonymMapper
# solo se presenti retrieval intent / regole
- name: ResponseSelector
epochs: 100
retrieval_intent: faq
constrain_similarities: True
model_confidence: linear_norm
- name: "askdata_component.ApiAskdata"
slug_workspace: "***"
token: "***"
policies:
#- name: MemoizationPolicy
# max_history: 5
# solo se presenti retrieval intent / regole
- name: RulePolicy
# Confidence threshold for the `core_fallback_action_name` to apply.
# The action will apply if no other action was predicted with
# a confidence >= core_fallback_threshold
# core_fallback_threshold: 0.4
# core_fallback_action_name: "action_default_fallback"
# enable_fallback_prediction: True
- name: TEDPolicy
#max_history: 5
epochs: 20
constrain_similarities: True
model_confidence: linear_norm
askdata_component.py:
from rasa.nlu.components import Component
from rasa.nlu import utils
from rasa.nlu.model import Metadata
from askdata import *
import jsonpickle
#from askdata.askdata_client import *
import os
import typing
from typing import Any, Optional, Text, Dict
class ApiAskdata(Component):
# name = "askdata_compone"
# provides = ["entities"]
# defaults = {}
# language_list = ["it"]
defaults = {"slug_workspace":"try",
"token":2}
def __init__(self, component_config, language: Optional[Text] = None):
super(ApiAskdata, self).__init__(component_config)
self.slug_workspace = self.component_config["slug_workspace"]
self.token = self.component_config["token"]
def train(self, training_data, cfg, **kwargs):
"""Not needed, because the the model is pretrained"""
pass
def convert_to_rasa(self, value):
"""Convert model output into the Rasa NLU compatible output format."""
entity = {"sim_vendute": value}
return entity
def process(self, message, **kwargs):
"""Retrieve the text message, pass it to the classifier
and append the prediction results to the message class."""
#print("Askdata start")
token = self.token
askdata = Askdata(token = token)
agent = askdata.agent(self.slug_workspace)
data = agent.ask("***")
value = data["***"].item()
entity = self.convert_to_rasa(value)
message.set("entities", [entity], add_to_output=True)
print("END")
def persist(self, file_name, model_dir):
"""Pass because a pre-trained model is already persisted"""
#classifier_file = os.path.join(model_dir, file_name)
#jsonpickle(classifier_file, self)
pass
@classmethod
def load(
cls,
meta: Dict[Text, Any],
model_dir: Optional[Text] = None,
model_metadata: Optional["Metadata"] = None,
cached_component: Optional["ApiAskdata"] = None,
**kwargs: Any,
) -> "ApiAskdata":
"""Loads trained component (see parent class for full docstring)."""
if cached_component:
return cached_component
else:
return cls(meta)
traceback:
2021-08-23 17:35:04 INFO rasa.model - Data (core-config) for Core model section changed.
2021-08-23 17:35:04 INFO rasa.model - Data (nlu-config) for NLU model section changed.
Training NLU model...
2021-08-23 17:35:06 INFO rasa.nlu.utils.spacy_utils - Trying to load spacy model with name 'it_core_news_md'
2021-08-23 17:35:07 INFO rasa.nlu.components - Added 'SpacyNLP' to component cache. Key 'SpacyNLP-it_core_news_md'.
c:\users\canta\anaconda3\lib\site-packages\rasa\utils\train_utils.py:626: FutureWarning: model_confidence is set to `linear_norm`. We introduced this option in Rasa Open Source 2.3.0, but have identified multiple problems with it based on user feedback. Therefore, `model_confidence=linear_norm` is now deprecated and will be removed in Rasa Open Source `3.0.0`.Please use `model_confidence=softmax` instead.
rasa.shared.utils.io.raise_deprecation_warning(
2021-08-23 17:35:07 INFO rasa.shared.nlu.training_data.training_data - Training data stats:
2021-08-23 17:35:07 INFO rasa.shared.nlu.training_data.training_data - Number of intent examples: 27 (6 distinct intents)
2021-08-23 17:35:07 INFO rasa.shared.nlu.training_data.training_data - Found intents: 'prenotare_stanza', 'greet', 'prenota_orario', 'goodbye', 'affirm', 'deny'
2021-08-23 17:35:07 INFO rasa.shared.nlu.training_data.training_data - Number of response examples: 0 (0 distinct responses)
2021-08-23 17:35:07 INFO rasa.shared.nlu.training_data.training_data - Number of entity examples: 0 (0 distinct entities)
2021-08-23 17:35:07 INFO rasa.nlu.model - Starting to train component SpacyNLP
2021-08-23 17:35:08 INFO rasa.nlu.model - Finished training component.
2021-08-23 17:35:08 INFO rasa.nlu.model - Starting to train component SpacyTokenizer
2021-08-23 17:35:08 INFO rasa.nlu.model - Finished training component.
2021-08-23 17:35:08 INFO rasa.nlu.model - Starting to train component SpacyFeaturizer
2021-08-23 17:35:08 INFO rasa.nlu.model - Finished training component.
2021-08-23 17:35:08 INFO rasa.nlu.model - Starting to train component LexicalSyntacticFeaturizer
2021-08-23 17:35:08 INFO rasa.nlu.model - Finished training component.
2021-08-23 17:35:08 INFO rasa.nlu.model - Starting to train component CountVectorsFeaturizer
2021-08-23 17:35:08 INFO rasa.nlu.featurizers.sparse_featurizer.count_vectors_featurizer - 30 vocabulary items were created for text attribute.
2021-08-23 17:35:08 INFO rasa.nlu.model - Finished training component.
2021-08-23 17:35:08 INFO rasa.nlu.model - Starting to train component CountVectorsFeaturizer
2021-08-23 17:35:08 INFO rasa.nlu.featurizers.sparse_featurizer.count_vectors_featurizer - 420 vocabulary items were created for text attribute.
2021-08-23 17:35:08 INFO rasa.nlu.model - Finished training component.
2021-08-23 17:35:08 INFO rasa.nlu.model - Starting to train component DIETClassifier
Epochs: 100%|██████████████████████████████████████████████████| 100/100 [00:10<00:00, 9.64it/s, t_loss=0.81, i_acc=1]
2021-08-23 17:35:18 INFO rasa.nlu.model - Finished training component.
2021-08-23 17:35:18 INFO rasa.nlu.model - Starting to train component DucklingEntityExtractor
2021-08-23 17:35:18 INFO rasa.nlu.model - Finished training component.
2021-08-23 17:35:18 INFO rasa.nlu.model - Starting to train component EntitySynonymMapper
2021-08-23 17:35:18 INFO rasa.nlu.model - Finished training component.
2021-08-23 17:35:18 INFO rasa.nlu.model - Starting to train component ResponseSelector
2021-08-23 17:35:18 INFO rasa.nlu.model - Finished training component.
2021-08-23 17:35:18 INFO rasa.nlu.model - Starting to train component ApiAskdata
2021-08-23 17:35:18 INFO rasa.nlu.model - Finished training component.
2021-08-23 17:35:18 INFO rasa.nlu.model - Successfully saved model into 'C:\Users\canta\AppData\Local\Temp\tmpynor48z1\nlu'
NLU model training completed.
2021-08-23 17:35:20 INFO rasa.nlu.components - Added 'SpacyNLP' to component cache. Key 'SpacyNLP-it_core_news_md'.
Training Core model...
Processed story blocks: 100%|████████████████████████████████████████████| 3/3 [00:00<00:00, 3003.80it/s, # trackers=1]
Processed story blocks: 100%|████████████████████████████████████████████| 3/3 [00:00<00:00, 1499.93it/s, # trackers=3]
Processed story blocks: 100%|████████████████████████████████████████████| 3/3 [00:00<00:00, 300.00it/s, # trackers=12]
Processed story blocks: 100%|█████████████████████████████████████████████| 3/3 [00:00<00:00, 78.95it/s, # trackers=39]
c:\users\canta\anaconda3\lib\site-packages\rasa\shared\utils\io.py:97: UserWarning: Found a rule-based policy in your pipeline but no rule-based training data. Please add rule-based stories to your training data or remove the rule-based policy (`RulePolicy`) from your your pipeline.
More info at https://rasa.com/docs/rasa/rules
Processed trackers: 0it [00:00, ?it/s]
Processed trackers: 100%|██████████████████████████████████████████████████| 3/3 [00:00<00:00, 999.52it/s, # action=23]
Processed trackers: 0it [00:00, ?it/s]
Processed trackers: 100%|██████████████████████████████████████████████████████████████| 3/3 [00:00<00:00, 1500.29it/s]
Processed trackers: 100%|█████████████████████████████████████████████| 120/120 [00:00<00:00, 497.92it/s, # action=881]
END
.
.
.
.
Any help is appreciated. Thanks!