intent_classifier_configuration#

class besser.bot.nlp.intent_classifier.intent_classifier_configuration.IntentClassifierConfiguration[source]#

Bases: ABC

The Intent Classifier Configuration abstract class.

This configuration is assigned to a state, allowing the customization of its intent classifier.

This class serves as a template to implement intent classifier configurations for the different Intent Classifiers.

_abc_impl = <_abc._abc_data object>#
class besser.bot.nlp.intent_classifier.intent_classifier_configuration.LLMIntentClassifierConfiguration(llm_suite, parameters={}, use_intent_descriptions=False, use_training_sentences=False, use_entity_descriptions=False, use_entity_synonyms=False)[source]#

Bases: IntentClassifierConfiguration

The LLM Intent Classifier Configuration class.

It allows the customization of a LLMIntentClassifier.

intent_classifier_configuration_library contains predefined configurations for the different LLM suites, that can be directly imported and used in a bot.

Parameters:
  • llm_suite (str) – the service provider from which we will load/access the LLM (openai, huggingface, huggingface-inference-api, replicate)

  • parameters (dict) – the LLM parameters (this will vary depending on the suite and the LLM)

  • use_intent_descriptions (bool) – whether to include the intent descriptions in the LLM prompt

  • use_training_sentences (bool) – whether to include the intent training sentences in the LLM prompt

  • use_entity_descriptions (bool) – whether to include the entity descriptions in the LLM prompt

  • use_entity_synonyms (bool) – whether to include the entity value’s synonyms in the LLM prompt

llm_suite#

the service provider from which we will load/access the LLM (openai, huggingface, huggingface-inference-api, replicate)

Type:

str

parameters#

the LLM parameters (this will vary depending on the suite and the LLM)

Type:

dict

use_intent_descriptions#

whether to include the intent descriptions in the LLM prompt

Type:

bool

use_training_sentences#

whether to include the intent training sentences in the LLM prompt

Type:

bool

use_entity_descriptions#

whether to include the entity descriptions in the LLM prompt

Type:

bool

use_entity_synonyms#

whether to include the entity value’s synonyms in the LLM prompt

Type:

bool

HUGGINGFACE_INFERENCE_API_LLM_SUITE = 'huggingface-inference-api'#
HUGGINGFACE_LLM_SUITE = 'huggingface'#
OPENAI_LLM_SUITE = 'openai'#
REPLICATE_LLM_SUITE = 'replicate'#
_abc_impl = <_abc._abc_data object>#
suites = ['openai', 'huggingface', 'huggingface-inference-api', 'replicate']#
class besser.bot.nlp.intent_classifier.intent_classifier_configuration.SimpleIntentClassifierConfiguration(num_words=1000, lower=True, oov_token='<OOV>', num_epochs=300, embedding_dim=128, input_max_num_tokens=15, discard_oov_sentences=True, check_exact_prediction_match=True, activation_last_layer='sigmoid', activation_hidden_layers='tanh', lr=0.001)[source]#

Bases: IntentClassifierConfiguration

The Simple Intent Classifier Configuration class.

It allows the customization of a SimpleIntentClassifier.

Parameters:
  • num_words (int) – Max num of words to keep in the index of words

  • lower (bool) – whether to transform the sentences to lowercase or not

  • oov_token (str) – Token for the out of vocabulary words

  • num_epochs (int) – Number of epochs to be run during training

  • embedding_dim (int) – Number of embedding dimensions to be used when embedding the words

  • input_max_num_tokens (int) – Max length for the vector representing a sentence

  • discard_oov_sentences (bool) – whether to automatically assign zero probabilities to sentences with all tokens being oov ones or not

  • check_exact_prediction_match (bool) – Whether to check for exact match between the sentence to predict and one of the training sentences or not

  • activation_last_layer (str) – The activation function of the last layer

  • activation_hidden_layers (str) – The activation function of the hidden layers

  • lr (float) – Learning rate for the optimizer

num_words#

Max num of words to keep in the index of words

Type:

int

lower#

whether to transform the sentences to lowercase or not

Type:

bool

oov_token#

Token for the out of vocabulary words

Type:

str

num_epochs#

Number of epochs to be run during training

Type:

int

embedding_dim#

Number of embedding dimensions to be used when embedding the words

Type:

int

input_max_num_tokens#

Max length for the vector representing a sentence

Type:

int

discard_oov_sentences#

whether to automatically assign zero probabilities to sentences with all tokens being oov ones or not

Type:

bool

check_exact_prediction_match#

Whether to check for exact match between the sentence to predict and one of the training sentences or not

Type:

bool

activation_last_layer#

The activation function of the last layer

Type:

str

activation_hidden_layers#

The activation function of the hidden layers

Type:

str

lr#

Learning rate for the optimizer

Type:

float

_abc_impl = <_abc._abc_data object>#