<p>BERT is not trained to determine if one sentence follows another. That is just ONE of the <a href="https://openreview.net/pdf?id=rJ4km2R5t7" rel="noreferrer">GLUE tasks</a> and there are a myriad more. ALL of the GLUE tasks (and superglue) are getting knocked out of the park by ALBERT.</p>

<p>BERT (and Albert for that matter) is the absolute state of the art in Natural Language Understanding. Doc2Vec doesn't come close. BERT is not a bag-of-words method. It's a bi-directional attention based encoder built on the Transformer which is the incarnation of the Google Brain paper <a href="https://arxiv.org/abs/1706.03762" rel="noreferrer">Attention is All you Need</a>. Also see this <a href="http://jalammar.github.io/illustrated-transformer/" rel="noreferrer">Visual breakdown</a> of the Transformer model.</p>

<p>This is a fundamentally new way of looking at natural language which doesn't use RNN's or LSTMs or tf-idf or any of that stuff. We aren't turning words or docs into vectors anymore. <a href="https://nlp.stanford.edu/projects/glove/" rel="noreferrer">GloVes: Global Vectors for Word Representations</a> with LSTMs are old. Doc2Vec is old.</p>

<p>BERT is reeeeeallly powerful - like, pass the Turing test easily powerful. Take a look at </p>

<p>See <a href="https://w4ngatang.github.io/static/papers/superglue.pdf" rel="noreferrer">superGLUE</a> which just came out. Scroll to the bottom at look at how insane those tasks are. THAT is where NLP is at.</p>

<p>Okay so now that we have dispensed with the idea that tf-idf is state of the art - you want to take documents and look at their similarity? I would use ALBERT on Databricks in two layers:</p>

<ol>
<li><p>Perform either Extractive or Abstractive summarization: <a href="https://pypi.org/project/bert-extractive-summarizer/" rel="noreferrer">https://pypi.org/project/bert-extractive-summarizer/</a> (NOTICE HOW BIG THOSE DOCUMENTS OF TEXT ARE - and reduce your document down to a summary.</p></li>
<li><p>In a separate step, take each summary and do the STS-B task from Page 3 <a href="https://openreview.net/pdf?id=rJ4km2R5t7" rel="noreferrer">GLUE</a></p></li>
</ol>

<p>Now, we are talking about absolutely bleeding edge technology here (Albert came out in just the last few months). You will need to be extremely proficient to get through this but it CAN be done, and I believe in you!!</p>
Is it possible to use Google BERT to calculate similarity between two textual documents?
<p>Is it possible to use Google BERT for calculating similarity between two textual documents? As I understand BERT's input is supposed to be a limited size sentences. Some works use BERT for similarity calculation for sentences like:</p>

<p><a href="https://github.com/AndriyMulyar/semantic-text-similarity" rel="noreferrer">https://github.com/AndriyMulyar/semantic-text-similarity</a></p>

<p><a href="https://github.com/beekbin/bert-cosine-sim" rel="noreferrer">https://github.com/beekbin/bert-cosine-sim</a></p>

<p>Is there an implementation of BERT done to use it for large documents instead of sentences as inputs ( Documents with thousands of words)?</p>