Various NLP tasks using Huggingface and Flask. Right now, the app supports only three tasks:
-
Sentiment Analysis: Identify if the sentence's sentiment is Positive or Negative.
-
Extractive Question Answering: For a given Context paragraph ask a Question. You should get an Answer from the paragraph.
-
Text Generation: Provide a Context (start of a sentence) and let the AI complete your story.
Plan is to include more tasks in future. Hugginface's transformers
library makes these things very easy to do.
Contributions are most welcome.
-
Clone the repo:
git clone https://github.com/mldev-ai/NLP-Tasks.git
-
Navigate into the downloaded repo:
cd NLP-Tasks
-
Install the required dependencies:
pip install -r requirements.txt
-
Run the flask-app:
-
Windows Powershell:
$env:FLASK_APP="app.py"
flask run
-
Linux:
export FLASK_APP=app.py
flask run
- If getting
command not found: flask
error, try this:
python3 -m flask run
- If getting
-
-
The app is tested on Windows only. If you're using other OS and encounter any problem, please raise an issue.
-
I tried deploying the app to Heroku in two ways, got problem in both:
-
Using Docker: dependecy issues with
transformers
library. -
Direct Flask with git: size limit increased because of the
transformers
library's requirements, which are, some pre-trained models and fullPyTorch
library.
-
Right now, the most important contribution that can be made to this repo are:
-
Reduce the inference time, currently its too high (around 10 seconds for question answering task).
-
Deploy the app to any hosting site such as heroku, AWS, or Azure.
-
Add more NLP tasks to the app.
-
BTW, if someone can make nice UI using CSS or JS. That would be a huge plus. :)
Huggingface's transformers library has revolutionised the way state-of-the-art NLP models are being used in real-world. Without, this library, the app made here would have taken tremendous amount of time (compared to what it took now).