This repository contains the solution for an assignment on the course of Practical Machine Learning and Deep Learning (PMLDL). The task involves deploying a machine learning model and creating a simple automated MLOps pipeline. The main task is to deploy a model in an API and create a web application that interacts with the API. The model API accepts requests from the web application and sends back responses.
For this solution, I use the distil-bert model from HuggingFace for Named Entity Recognition (NER). NER is a personally interesting field of research. I chose it for this assignment to get more practice for the course project. The possible entity types are:
- MISC: Miscellaneous entity
- PER: Person’s name
- ORG: Organization
- LOC: Location
PMLDL-1/
├── services/
│ ├── backend/
│ │ ├── src/
│ │ │ └── main.py
│ │ ├── Dockerfile
│ │ ├── pyproject.toml
│ │ └── oetry.lock
│ ├── frontend/
│ │ ├── src/
│ │ │ └── main.py
│ │ ├── Dockerfile
│ │ ├── pyproject.toml
│ │ └── poetry.lock
├── docker-compose.yml
├── .dockerignore
├── .gitignore
└── README.md
- Docker
- Docker Compose
- Poetry (for dependency management)
-
Clone the repository:
git clone https://github.com/your-username/PMLDL-1.git cd PMLDL-1 -
Build and run the Docker containers:
docker-compose up --build
-
Access the web application:
Open your web browser and navigate to
http://localhost:8501to access the Streamlit frontend.
The backend is built using FastAPI and runs the distil-bert model for NER. It includes:
- Model Caching: To improve performance by caching the model.
- Optimized Docker Configuration: To ensure efficient resource usage.
- Health Checks: To monitor the status of the API.
The frontend is built using Streamlit and includes:
- Input Fields: For users to input text.
- Prediction Area: To display the annotated entities.
For color annotation, I used the st-annotated-text library.
- Docker: For containerization.
- FastAPI: For building the backend API.
- Streamlit: For building the frontend web application.
- HuggingFace Transformers: For the
distil-bertmodel. - st-annotated-text: For color annotation in the frontend.
- Poetry: For dependency management.
- Thanks to the creators of the
st-annotated-textlibrary for providing a simple way to annotate text in Streamlit. - Thanks to the HuggingFace team for the
distil-bertmodel and the Transformers library.