Skip to content

AkashKhamkar/Sentence-Similarity-Flask-API-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Sentence-Similarity-Flask-API-

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:

1. sentence_similarity.py file

  • 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.

2. query.py file

  • This file contains and example query with 2 sentences.
  • Below is the output obtained when executing the query.py file

Query with 2 sentences:

image

OUTPUT:

(image

  • 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.

About

Enter 2 sentences as query and get their similarity score

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages