<p>A promising approach would be metric embedding. In this paper: <a href="https://arxiv.org/pdf/2001.11692.pdf" rel="nofollow noreferrer">Convolutional Embedding for Edit Distance</a> the researchers state that the algorithm can accelerate the searching by orders of magnitude. After doing the training metric embedding you can apply the <a href="https://github.com/google-research/google-research/tree/master/scann" rel="nofollow noreferrer">approximate nearest neighbor</a> algorithms to find the k text with the shortest distance.</p>
<p>HTH.</p>
Efficient edit distance
<p>I have a big corpus and I'm trying to find the most similar n-grams in the corpus. For that case, I'm using <a href="https://kite.com/python/docs/difflib.get_close_matches" rel="nofollow noreferrer"><code>get_close matches</code></a>.</p>

<p>The problem is that this procedure takes a lot of time. A friend suggests me to convert the n-grams to MD5 and then calculate the distance. I suspect that it will work. Is hashing invariant to hashing? Is distance calculation efficiently running on MD5 that strings?</p>

<p>Post scriptum, what is the most efficient way to calculate the distance between strings (like n-grams) in a large corpus?</p>