NLP Intent and Slot Recognition

General Description

This component provides natural language processing capabilities for intent detection and slot filling using BERT-based models. It processes text input to identify user intentions and extract structured information from the text, such as entities and their values. The system uses a fine-tuned BERT model with custom classifier heads for intent recognition and slot identification, served through a FastAPI interface. Training is performed on annotated data with Lightning, allowing for efficient model iteration and deployment in containerized environments.

Resource Link
Source code https://gitc.piap.lukasiewicz.gov.pl/ai-prism/wp4/ai-based-perception-modules/nlp-intent-and-slot
Demo Video

Contact

The following table includes contact information of the main developers in charge of the component:

Name Email Organisation
Dorin Clisu dorin.clisu@nttdata.com NTT Data Romania

License

Proprietary.

Technical Foundations

Integrated and Open Source Components

Overview

The NLP Intent and Slot Recognition component integrates several key open-source libraries to provide its functionality. It leverages Hugging Face's Transformers for pre-trained language models, PyTorch Lightning for training workflows, FastAPI for serving predictions, and Uvicorn for ASGI server implementation. These components work together to enable efficient natural language understanding in robotics applications.

Pre-existing Components

FastAPI

Source

FastAPI is a modern web framework for building APIs with Python. https://fastapi.tiangolo.com/

Description

FastAPI is a high-performance web framework for building APIs with Python 3.7+ based on standard Python type hints. It provides automatic Swagger UI documentation, data validation, and serialization.

Modifications

None.

Purpose in AI-PRISM

FastAPI is used to expose the NLP model's capabilities via a RESTful API, allowing other AI-PRISM components to make intent and slot recognition requests and receive structured JSON responses.

License

MIT License https://github.com/tiangolo/fastapi/blob/master/LICENSE

Lightning (PyTorch Lightning)

Source

PyTorch Lightning is a lightweight PyTorch wrapper for high-performance AI research. https://lightning.ai/

Description

Lightning is a framework that organizes PyTorch code to separate research code from engineering code, making deep learning projects more maintainable and scalable.

Modifications

None.

Purpose in AI-PRISM

Lightning is used to structure the training workflow for the BERT-based model, handling the training loop, validation, checkpointing, and logging in a standardized way.

License

Apache License 2.0 https://github.com/Lightning-AI/lightning/blob/master/LICENSE

PyTorch

Source

PyTorch is an open-source machine learning framework. https://pytorch.org/

Description

PyTorch is a deep learning framework that provides a seamless path from research prototyping to production deployment with GPU acceleration.

Modifications

None.

Purpose in AI-PRISM

PyTorch is the core machine learning framework used to define, train, and deploy the neural network models for intent recognition and slot filling.

License

BSD-3-Clause License https://github.com/pytorch/pytorch/blob/master/LICENSE

Transformers

Source

Transformers is a library of state-of-the-art pre-trained models for natural language processing. https://huggingface.co/transformers/

Description

Transformers provides thousands of pre-trained models for various NLP tasks, including BERT models used in this component for contextual word embeddings.

Modifications

None.

Purpose in AI-PRISM

Transformers is used to load pre-trained BERT models that provide powerful contextual embeddings for text understanding, which are then fine-tuned for the specific intent and slot recognition tasks.

License

Apache License 2.0 https://github.com/huggingface/transformers/blob/main/LICENSE

Uvicorn

Source

Uvicorn is an ASGI web server implementation for Python. https://www.uvicorn.org/

Description

Uvicorn is a lightning-fast ASGI server implementation, based on uvloop and httptools.

Modifications

None.

Purpose in AI-PRISM

Uvicorn serves as the production ASGI server that hosts the FastAPI application, handling HTTP requests and responses efficiently.

License

BSD-3-Clause License https://github.com/encode/uvicorn/blob/master/LICENSE.md

How to install

Every AI-PRISM component is installed using the Cluster management service. During the installation process, the user needs to configure a set of high-level parameters.

How to use

The NLP Intent and Slot Recognition component can be used by sending HTTP POST requests to the /recognize endpoint with text to be analyzed. The service returns structured JSON with detected intent and extracted slots.