Sitemap
1 min readMar 5, 2025

Ng, I don't have code to point to, but the basic idea is really simple. You associate a query with documents from your click or conversion logs -- or, if you don't have those, you could just execute the query and use retrieved documents. You then compute the mean of the vectors for the documents associated with the query -- which means you have to have some way of computing those, like applying a pre-trained sentence transformer model to the document titles. You now have bag-of-document query vectors for all those queries. That covers what you can do offline. If you want to compute bag-of-document vectors for unseen queries online, that's a bit more work, since you have to train a model. HuggingFace has a tutorial for that process, but doing it right requires a bit more work. I am hoping to put together a repo with Aritra Mandal one of these days, but we haven't gotten around to it.

--