The sentence_similarity.py file contains the flask app and the query.py file contains an example query and below is an example output obtained:
- I have used pretrained "all-MiniLM-L6-v2" model from the Hugging Face library which is trained on more than 1 billion sentence pairs.
- This model basically maps the sentences & paragraphs to a 384 dimensional dense vector space.
- This file contains the code for the flask app and api and the model loading and tokenizing as well as generating the output.
- This file contains and example query with 2 sentences.
- Below is the output obtained when executing the query.py file
- Here I have used ngrok library as the project was done in gogle collab.
- As local hosting can't be done in google collab I have used ngrok_flask library.
- ngrok basically allows you to host the flask app on ngrok domain instead of local hosting.
- Also this flask app is easily deployable anywhere with or without the ngrok library and the api works perfectly.