Using BERT for search engine with an Elastic Database

I want to make Documents search engine where the user will type a query and top n relevant documents should be shown. I want to use BERT for the searching and the first question is can i use it with an Elastic Database ? Seconed question is which task should i use for the pretrained model 1) Question-Answer 2) Binary Classification as 1 relevant 2 not relevant ?

Topic elastic-net bert grid-search

Category Data Science


Train with relevant/non-relevant approach using sentence-transformers. When you train the model you can encode all documents and get their BERT embedding vectors.

Elastic search lets you put these vectors in properties of your corpus, so each document is saved along with its embedding vector.

For each query get the first 1000 candidates and their vectors using elastic search and rerank them in python using cosine similarity and return the results.

Don't be surprised if didnt perform well.

PS: the calculation of cosine similarity can be also done on the fly using Learning-2-Rank plugin of elastic search but I didnt use it myself.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.