by refibrillator · 2y ago · 0 comments
In my experience there are two paths forward, the one I recommend is to train an MLP classifier on the embeddings to produce a binary classification (ie similar or not). The advantage is that you no longer need to set a numeric threshold on a distance metric, however you will need labeled training data to define what is “similar” in the context of your use case.
The other path is to calculate the statistics of pair-wise distances for every record in some unlabeled dataset you have, and use the resulting distribution to inform choice of threshold. This will at least give you an estimate of what % of records will be classified as similar for a given threshold value.
In our cases, < 100 labels on modern models (per task) goes far. We can do better, but more useful problems to solve. Impressive how far these have come!
We have 2 binary datasets in there [1], but of course, those results are not separately presented - you see the averages. The choice of datasets here is based on what other papers report, to have comparable results. In our experience with real data, AL doesn't fare any better on average - our pipelines use different representations (not just BERT based, includes some legacy ones like n-grams+tf-idf) and classifiers.
We do see some strong peformance with RoBERTa (Fig 6) and the margin strategy, which is an uncertainty based strategy like least confidence (Fig 7) - these probably correspond to your observations (to an extent).
It is a little hard to comment on differences without looking closely (I'd be happy to go through any document/tech. report you might be able to share) but in our experience, we have seen inconsistencies arise from:
* Not performing model selection at each iteration.
* Not calibrating the selected model at each iteration.
In these cases, a non-random query strategy sometimes just makes up for the lack of proper model selection, making it seem like the query strategy is stronger than it really is. Another point of difference is the seed data size - that can have a significant effect on "priming" the query strategy.
On a related note, specifically wrt uncertainty-based strategies, sampling bias is a known problem [2].
[1] On the Fragility of Active Learning, https://arxiv.org/abs/2403.15744
[2] Section 1.2 in Two faces of active learning, https://cseweb.ucsd.edu/~dasgupta/papers/twoface.pdf
However, if you use a "two towers" approach and have several additional MLP layers on top of each embedding separately, and then a dense MLP on the concatenations of each tower, the individual tower MLP layers are an embedding transformation, and will improve retrieval.
Like this:
Final MLP
/ \
QP MLP DP MLP
| |
QE DE
Now, you can apply the document preprocessor ("DP MLP") to your document embeddings ("DE") before storing them in the vector database, and apply the query preprocessor ("QP MLP") to your query embeddings ("QE") before querying your vector database.This should improve the precision and recall of your vector retrieval step beyond using e.g. raw LLM embeddings. Even better is for the final layer to just be cosine similarity, maximum inner product, or L2 distance, rather than having an MLP so you can just use a raw threshold (it's at least worth trying).
The finetuning here is specific to optimizing for retrieval, which may be different than just matching documents, which can be an advantage.
You may want to force the query and document finetunings to be the same, which makes a lot of sense, but the advantage in them differing can be that query strings are often rather short, and in a different sort of language structure than documents, so the differing query and document tunings can in some sense "normalize" queries and documents to be in the same space, when it works well.
If you train a binary classifier on the embeddings, have you found that the resulting probabilities are also good for ranking? Or do you stick with a distance measure for that?
Any paper or other source about this approach?