llm_huggingface_api#
- class besser.bot.nlp.llm.llm_huggingface_api.LLMHuggingFaceAPI(bot, name, parameters, num_previous_messages=1)[source]#
Bases:
LLMA HuggingFace LLM wrapper for HuggingFace’s Inference API.
Normally, we consider an LLM in HuggingFace those models under the tasks
text-generationortext2text-generationtasks (more info), but there could be exceptions for other tasks (which have not been tested in this class).- Parameters:
- _nlp_engine#
the NLPEngine that handles the NLP processes of the bot the LLM belongs to
- Type:
- num_previous_messages#
for the chat functionality, the number of previous messages of the conversation to add to the prompt context (must be > 0)
- Type:
- _abc_impl = <_abc._abc_data object>#
- intent_classification(intent_classifier, message, parameters=None)[source]#
Predict the intent of a given message.
Instead of returning only the intent with the highest likelihood, return all predictions. Predictions include not only the intent scores but other information extracted from the message.
- Parameters:
intent_classifier (LLMIntentClassifier) – the intent classifier that is running the intent classification process
message (str) – the message to predict the intent
parameters (dict) – the LLM parameters. If none is provided, the RAG’s default value will be used
- Returns:
the list of predictions made by the LLM.
- Return type:
- predict(message, parameters=None)[source]#
Make a prediction, i.e., generate an output.
Runs the Text Generation Inference API task