Ludwig NLU Engine
Last updated
Last updated
The Ludwig NLU Engine is a robust Natural Language Understanding (NLU) solution built using Ludwig AI, a high-level, declarative machine learning framework. This engine simplifies the process of extracting intents, entities, and other language features by leveraging Ludwig’s intuitive design and powerful machine learning capabilities. It also enables you to use models deployed on HuggingFace or your own locally trained models for inference.
Install the Hexabot CLI running this command
Create your Hexabot project using this Ludwig custom template:
Navigate to your project directory and initialize it using the following commands. You can customize your project configuration in my-chatbot/docker/.env
file:
Kickstart your newly created chatbot by running:
This ensures that Hexabot uses the Ludwig based NLU engine for processing intents and language detection.
Navigate to “Settings” from the main menu.
Select the “Chatbot” tab.
Ensure that the “Default NLU Helper” is set to "ludwig-nlu-helper".
Navigate to “Settings” from the main menu.
Select the “Ludwig NLU Engine” tab.
Update NLU Engine Settings :
The Ludwig NLU engine is already pre-configured to connect with the Ludwig NLU API provided in the template. You only need to update the Ludwig NLU engine's endpoint and API token if you are not using the default setup.
A Probability Threshold is also available, it’s set by default to 0.1, this value is the minimum probability required for a prediction to be accepted. Be sure to adjust this threshold based on the specific model you are using and your desired balance of precision and recall.
While Hexabot simplifies the integration, understanding Ludwig's core concepts is beneficial if you want to build custom models. Ludwig is a declarative machine learning framework where you define your models and training through a configuration file using YAML or JSON. Ludwig handles the complexity and coding details of your configuration.
Here’s a brief overview of how you might use Ludwig in conjunction with Hexabot:
Defining a Model Architecture: Instead of coding a model from scratch, you define a model architecture using a high-level configuration. You might define different layers of a neural network, define a text encoder and other model specifications.
Training Models: Ludwig uses your training data and the configuration you provide to train the model, generating a model that you can then host and use for inference in Hexabot, locally or using a cloud based model.
HuggingFace Integration: You can also directly utilize models from HuggingFace by referencing their names in the Ludwig configuration. This makes using the state-of-the-art models very simple for experimentation.
For in-depth understanding on how to use Ludwig, please refer to its official documentation: https://ludwig.ai.
The Ludwig NLU Engine supports inference using both Hugging Face models and locally trained models. Each prediction logs a confidence score to provide insight into its reliability. The Ludwig NLU engine in the Hexabot starter template is pre-configured to use two Hugging Face models developed by the Hexabot team that demonstrates intent detection and language classification. These models serve as an example to help you get started. Keep in mind that for real use cases, you may need to define and train your own models based on your dataset to better suit your needs. For detailed instructions on training your own models and integrating them with the engine, refer to the README file in the original repository. You may also wish to try this dataset as a starting point for training your custom models.
Navigate to the "NLU" from the main menu and then select the "NLU Entities" tab to add some entities and/or intent values. Check the Manage NLU Entities section in the docs for more information on how to add and manage your NLU entities :
Use the NLU training tool to test out some text against the NLU intent you just added and see if predictions are good.
Finally, you can use NLU Entities when configuring triggers in the blocks within the Visual Editor. You can check the Regular Blocks section in the documentation to help understand how to trigger blocks using NLU intents.
The Ludwig NLU Engine offers a balance between easy configuration and powerful customization. By using pre-trained models from the default setup or training custom models, you have all the tools to build the required NLU logic for your use case. Remember to test and adjust your settings to leverage its capabilities to the fullest.