Repository: RasaHQ/rasa
Pull request: Shorten the information in tqdm during training
**Proposed changes**:
- closes https://github.com/RasaHQ/rasa/issues/5855

**Status (please check what you already did)**:
- [ ] added some tests for the functionality
- [ ] updated the documentation
- [x] updated the changelog (please check [changelog](https://github.com/RasaHQ/rasa/tree/master/changelog) for instructions)
- [x] reformat files using `black` (please check [Readme](https://github.com/RasaHQ/rasa#code-style) for instructions)


Problem statement:
shorten the information in tqdm during training ML algorithms based on the log level
**Description of Problem**:
currently DIETClassifier output a lot of info in tqdm:
```
Epochs:  11%|▍   | 9/80 [03:58<30:47, 26.02s/it, t_loss=6.703, i_loss=0.451, entity_loss=0.044, role_loss=0.053, i_acc=0.961, entity_f1=0.883, role_f1=0.717]
```
which makes it unusable for small sized terminals.
we should consider removing some information like `loss` if log level is info
also consider shortening `entity_loss=0.044, role_loss=0.053` to `e_loss=0.044, r_loss=0.053`

**Overview of the Solution**:
<!-- What would a possible solution look like?
Describe, without going too low into technical details,
what changes need to happen during implementation of this feature. -->

**Examples** (if relevant):
<!-- List examples and/or link to relevant references. -->

**Blockers** (if relevant):
<!-- Is this feature blocked by anything or anyone?
Or might there be any potential blockers on the way? -->

**Definition of Done**:
<!-- What needs to be there to consider this feature as done?
- [ ] Tests are added
- [ ] Feature described the docs
- [ ] Feature mentioned in the changlog
- [ ] ... -->

Hints from issue discussion:

Commit message: add changelog

Patch to review:
diff --git a/changelog/5855.improvement.rst b/changelog/5855.improvement.rst
new file mode 100644
index 000000000000..083779d38b89
--- /dev/null
+++ b/changelog/5855.improvement.rst
@@ -0,0 +1,2 @@
+Shorten the information in tqdm during training ML algorithms based on the log level. If you train your model
+in debug mode, all available metrics will be shown during training, otherwise, the information is shorten.
diff --git a/rasa/nlu/classifiers/diet_classifier.py b/rasa/nlu/classifiers/diet_classifier.py
index a42ca6e1ddf1..c7da68d2f85f 100644
--- a/rasa/nlu/classifiers/diet_classifier.py
+++ b/rasa/nlu/classifiers/diet_classifier.py
@@ -1109,26 +1109,42 @@ def _create_metrics(self) -> None:
         # so create loss metrics first to output losses first
         self.mask_loss = tf.keras.metrics.Mean(name="m_loss")
         self.intent_loss = tf.keras.metrics.Mean(name="i_loss")
-        self.entity_loss = tf.keras.metrics.Mean(name="entity_loss")
-        self.entity_group_loss = tf.keras.metrics.Mean(name="group_loss")
-        self.entity_role_loss = tf.keras.metrics.Mean(name="role_loss")
+        self.entity_loss = tf.keras.metrics.Mean(name="e_loss")
+        self.entity_group_loss = tf.keras.metrics.Mean(name="g_loss")
+        self.entity_role_loss = tf.keras.metrics.Mean(name="r_loss")
         # create accuracy metrics second to output accuracies second
         self.mask_acc = tf.keras.metrics.Mean(name="m_acc")
         self.response_acc = tf.keras.metrics.Mean(name="i_acc")
-        self.entity_f1 = tf.keras.metrics.Mean(name="entity_f1")
-        self.entity_group_f1 = tf.keras.metrics.Mean(name="group_f1")
-        self.entity_role_f1 = tf.keras.metrics.Mean(name="role_f1")
+        self.entity_f1 = tf.keras.metrics.Mean(name="e_f1")
+        self.entity_group_f1 = tf.keras.metrics.Mean(name="g_f1")
+        self.entity_role_f1 = tf.keras.metrics.Mean(name="r_f1")
 
     def _update_metrics_to_log(self) -> None:
+        debug_log_level = logging.getLogger("rasa").level == logging.DEBUG
+
+        logger.debug("Following metrics will be logged during training: ")
+        logger.debug("  - t_loss (total loss)")
         if self.config[MASKED_LM]:
-            self.metrics_to_log += ["m_loss", "m_acc"]
+            self.metrics_to_log.append("m_acc")
+            logger.debug("  - m_acc (mask accuracy)")
+            if debug_log_level:
+                self.metrics_to_log.append("m_loss")
+                logger.debug("  - m_loss (mask loss)")
         if self.config[INTENT_CLASSIFICATION]:
-            self.metrics_to_log += ["i_loss", "i_acc"]
+            self.metrics_to_log.append("i_acc")
+            logger.debug("  - i_acc (intent accuracy)")
+            if debug_log_level:
+                self.metrics_to_log.append("i_loss")
+                logger.debug("  - i_loss (intent loss)")
         if self.config[ENTITY_RECOGNITION]:
             for tag_spec in self._entity_tag_specs:
                 if tag_spec.num_tags != 0:
                     name = tag_spec.tag_name
-                    self.metrics_to_log += [f"{name}_loss", f"{name}_f1"]
+                    self.metrics_to_log.append(f"{name[0]}_f1")
+                    logger.debug(f"  - {name[0]}_acc ({name} accuracy)")
+                    if debug_log_level:
+                        self.metrics_to_log.append(f"{name[0]}_loss")
+                        logger.debug(f"  - {name[0]}_loss ({name} loss)")
 
     def _prepare_layers(self) -> None:
         self.text_name = TEXT
diff --git a/rasa/nlu/selectors/response_selector.py b/rasa/nlu/selectors/response_selector.py
index 4d030cda4096..010a89df1f16 100644
--- a/rasa/nlu/selectors/response_selector.py
+++ b/rasa/nlu/selectors/response_selector.py
@@ -429,10 +429,22 @@ def _create_metrics(self) -> None:
         self.response_acc = tf.keras.metrics.Mean(name="r_acc")
 
     def _update_metrics_to_log(self) -> None:
-        if self.config[MASKED_LM]:
-            self.metrics_to_log += ["m_loss", "m_acc"]
+        debug_log_level = logging.getLogger("rasa").level == logging.DEBUG
 
-        self.metrics_to_log += ["r_loss", "r_acc"]
+        logger.debug("Following metrics will be logged during training: ")
+        logger.debug("  - t_loss (total loss)")
+        if self.config[MASKED_LM]:
+            self.metrics_to_log.append("m_acc")
+            logger.debug("  - m_acc (mask accuracy)")
+            if debug_log_level:
+                self.metrics_to_log.append("m_loss")
+                logger.debug("  - m_loss (mask loss)")
+
+        self.metrics_to_log.append("r_acc")
+        logger.debug("  - r_acc (response accuracy)")
+        if debug_log_level:
+            self.metrics_to_log.append("r_loss")
+            logger.debug("  - r_loss (response loss)")
 
     def _prepare_layers(self) -> None:
         self.text_name = TEXT


Code review comments:
diff_hunk: @@ -1109,26 +1109,42 @@ def _create_metrics(self) -> None:
         # so create loss metrics first to output losses first
         self.mask_loss = tf.keras.metrics.Mean(name="m_loss")
         self.intent_loss = tf.keras.metrics.Mean(name="i_loss")
-        self.entity_loss = tf.keras.metrics.Mean(name="entity_loss")
-        self.entity_group_loss = tf.keras.metrics.Mean(name="group_loss")
-        self.entity_role_loss = tf.keras.metrics.Mean(name="role_loss")
+        self.entity_loss = tf.keras.metrics.Mean(name="e_loss")
+        self.entity_group_loss = tf.keras.metrics.Mean(name="g_loss")
+        self.entity_role_loss = tf.keras.metrics.Mean(name="r_loss")
         # create accuracy metrics second to output accuracies second
         self.mask_acc = tf.keras.metrics.Mean(name="m_acc")
         self.response_acc = tf.keras.metrics.Mean(name="i_acc")
-        self.entity_f1 = tf.keras.metrics.Mean(name="entity_f1")
-        self.entity_group_f1 = tf.keras.metrics.Mean(name="group_f1")
-        self.entity_role_f1 = tf.keras.metrics.Mean(name="role_f1")
+        self.entity_f1 = tf.keras.metrics.Mean(name="e_f1")
+        self.entity_group_f1 = tf.keras.metrics.Mean(name="g_f1")
+        self.entity_role_f1 = tf.keras.metrics.Mean(name="r_f1")
 
     def _update_metrics_to_log(self) -> None:
+        debug_log_level = logging.getLogger("rasa").level == logging.DEBUG
+
+        logger.debug("Following metrics will be logged during training: ")
+        logger.debug("  - t_loss (total loss)")
         if self.config[MASKED_LM]:
-            self.metrics_to_log += ["m_loss", "m_acc"]
+            self.metrics_to_log.append("m_acc")
+            logger.debug("  - m_acc (mask accuracy)")
+            if debug_log_level:
+                self.metrics_to_log.append("m_loss")
+                logger.debug("  - m_loss (mask loss)")
path: rasa/nlu/classifiers/diet_classifier.py
text: @user1:
this seems to be roughly the same for all, let's create a helper method for it