Skip to content

Commit

Permalink
Merge 8ca8344 into ba0d890
Browse files Browse the repository at this point in the history
  • Loading branch information
tabergma authored Sep 4, 2020
2 parents ba0d890 + 8ca8344 commit 73f5d12
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
3 changes: 3 additions & 0 deletions changelog/6555.improvement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Do not set the output dimension of the `sparse-to-dense` layers to the same dimension as the dense features.

Update default value of `dense_dimension` for `DIETClassifier` and `ResponseSelctor` to 128.
2 changes: 1 addition & 1 deletion docs/docs/components/intent-classifiers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ Intent classifiers assign one of the intents defined in the domain file to incom
+---------------------------------+------------------+--------------------------------------------------------------+
| embedding_dimension | 20 | Dimension size of embedding vectors. |
+---------------------------------+------------------+--------------------------------------------------------------+
| dense_dimension | text: 512 | Dense dimension for sparse features to use if no dense |
| dense_dimension | text: 128 | Dense dimension for sparse features to use if no dense |
| | label: 20 | features are present. |
+---------------------------------+------------------+--------------------------------------------------------------+
| concat_dimension | text: 512 | Concat dimension for sequence and sentence features. |
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/components/selectors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ Selectors predict a bot response from a set of candidate responses.
+---------------------------------+-------------------+--------------------------------------------------------------+
| embedding_dimension | 20 | Dimension size of embedding vectors. |
+---------------------------------+-------------------+--------------------------------------------------------------+
| dense_dimension | text: 512 | Dense dimension for sparse features to use if no dense |
| | label: 512 | features are present. |
+---------------------------------+-------------------+--------------------------------------------------------------+
| dense_dimension | text: 128 | Dense dimension for sparse features to use if no dense |
| | label: 128 | features are present. |
+---------------------------------+------------------+--------------------------------------------------------------+
| concat_dimension | text: 512 | Concat dimension for sequence and sentence features. |
| | label: 512 | |
+---------------------------------+-------------------+--------------------------------------------------------------+
Expand Down
10 changes: 4 additions & 6 deletions rasa/nlu/classifiers/diet_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
EPOCHS,
RANDOM_SEED,
LEARNING_RATE,
DENSE_DIMENSION,
RANKING_LENGTH,
LOSS_TYPE,
SIMILARITY_TYPE,
Expand Down Expand Up @@ -87,6 +86,7 @@
TENSORBOARD_LOG_LEVEL,
CONCAT_DIMENSION,
FEATURIZERS,
DENSE_DIMENSION,
)


Expand Down Expand Up @@ -174,9 +174,9 @@ def required_components(cls) -> List[Type[Component]]:
# Dimension size of embedding vectors
EMBEDDING_DIMENSION: 20,
# Default dense dimension to use if no dense features are present.
DENSE_DIMENSION: {TEXT: 512, LABEL: 20},
DENSE_DIMENSION: {TEXT: 256, LABEL: 20},
# Default dimension to use for concatenating sequence and sentence features.
CONCAT_DIMENSION: {TEXT: 512, LABEL: 20},
CONCAT_DIMENSION: {TEXT: 256, LABEL: 20},
# The number of incorrect labels. The algorithm will minimize
# their similarity to the user input during training.
NUM_NEG: 20,
Expand Down Expand Up @@ -1340,14 +1340,12 @@ def _prepare_sparse_dense_layers(
) -> None:
sparse = False
dense = False

for is_sparse, feature_dimension in feature_signatures:
if is_sparse:
sparse = True
else:
dense = True
# if dense features are present
# use the feature dimension of the dense features
dense_dim = feature_dimension

if sparse:
self._tf_layers[f"sparse_to_dense.{name}"] = layers.DenseForSparse(
Expand Down
6 changes: 3 additions & 3 deletions rasa/nlu/selectors/response_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
EPOCHS,
RANDOM_SEED,
LEARNING_RATE,
DENSE_DIMENSION,
RANKING_LENGTH,
LOSS_TYPE,
SIMILARITY_TYPE,
Expand Down Expand Up @@ -72,6 +71,7 @@
TENSORBOARD_LOG_LEVEL,
CONCAT_DIMENSION,
FEATURIZERS,
DENSE_DIMENSION,
)
from rasa.nlu.constants import (
RESPONSE,
Expand Down Expand Up @@ -157,9 +157,9 @@ def required_components(cls) -> List[Type[Component]]:
# Dimension size of embedding vectors
EMBEDDING_DIMENSION: 20,
# Default dense dimension to use if no dense features are present.
DENSE_DIMENSION: {TEXT: 512, LABEL: 512},
DENSE_DIMENSION: {TEXT: 256, LABEL: 20},
# Default dimension to use for concatenating sequence and sentence features.
CONCAT_DIMENSION: {TEXT: 512, LABEL: 512},
CONCAT_DIMENSION: {TEXT: 256, LABEL: 256},
# The number of incorrect labels. The algorithm will minimize
# their similarity to the user input during training.
NUM_NEG: 20,
Expand Down

0 comments on commit 73f5d12

Please sign in to comment.