Flask App with Sentence Transformers

in blog •  23 days ago 

I've spent sometime to refactor, add a pipeline and tests to https://github.com/DoctorLai/SimilarString

image.png

This repository contains a Flask application that uses the SentenceTransformer model to compute the similarity between two input sentences. The application is containerized using Docker and is configured to run in both development and production environments using gunicorn.

A Simple Server to Compute the score of similarity between two strings.

To build and run:

docker build -t mlserver .
docker run -p 5000:5000 -e FLASK_ENV=development mlserver

And sample curl:

curl -v -H "Content-type: application/json" --data '{"s1":"This is a Surface Studio Laptop","s2":"That is a car"}' http://127.0.0.1:5000

which returns:

{
    'status': 'success', 
    's1': 'This is a Surface Studio Laptop', 
    's2': 'That is a car', 
    'score': 0.08295086771249771
}

Steem to the Moon🚀!

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!