A simple RNN-based Question Answering API built using Pytorch + FastAPI and Docker.
The model is trained using a Recurrent Neural Network (RNN) and exposed through a REST API.
- Train model using
train.py - Model + vocab stored in
config/ - API loads model and serves prediction
rnn-qa/
│
├── config/ # model artifacts
├── data/ # sample dataset
│
├── .gitignore
├── .dockerignore
│
├── Dockerfile # container setup
│
├── inference.py # prediction logic
├── main.py # FastAPI app / entrypoint
├── model.py # RNN model architecture
│
├── requirements.txt
│
├── tokenizer.py # text processing
├── train.py # training script
└── utils.py # helper functions
# Start API
git clone https://github.com/ssnym/rnn-qa.git
cd rnn-qa
pip install -r requirements.txt
uvicorn main:app --reloadBase URL: http://127.0.0.1:8000
A prebuilt Docker image is available on Docker Hub with 650+ pulls.
Docker Hub: https://hub.docker.com/r/ssnym/rnn-qa
# Pull the image
docker pull ssnym/rnn-qa
# Run the container:
docker run -p 8000:8000 ssnym/rnn-qaThe API will be available at:
http://127.0.0.1:8000
curl --location 'http://127.0.0.1:8000/predict' \
--header 'Content-Type: application/json' \
--data '{
"question": "What is the capital of France"
}'{
"answer": "Paris",
"confidence": 0.85
}Tutorial Followed : FastAPI course by CampusX