I've developed a tool that retrieve the closest expressions from a database based on what the user typed. (using word embedding - a comparison is made between each expression from the database and the user input)

n-result are retrieved but the closest expressions are not necessarily the most relevant one.

For example, by typing : hospital machine

The top results will be "dialysis machine", "medical machine", ... but I'll also find expressions like "building machine", "office machine"

A user will most likely choose medicine related machine.

Is there a way to optimize my ranking system based on the user input while keeping this similarity between vectors of the expression ?

  • $\begingroup$ Are you asking about improving your tool online (updating with every addition of new data)? It seems like you want to track clicks to build a belief about what's relevant, no? $\endgroup$
    – Alex L
    Mar 14, 2019 at 3:34
  • $\begingroup$ Yes, using clicks, for example, i'd like to reinforce the relevance of the result. If my current system ranks Expression A as the best, but the second best result Expression B is always selected before (or more often) than Expression A, then Expression B must become the first result. However, I'd like to keep the similarity between the vectors of the expression to do the ranking. The click / relevance by user will be an improvement of the current system. Not sure if I made myself understandable, I'm kinda new in the domain $\endgroup$
    – Martin
    Mar 14, 2019 at 15:25

1 Answer 1


Understanding similarity between two phrases has two aspects

  1. How similar are the unique tokens in the phrases ?
  2. How much should the individual tokens contribute to the overall phrase similarity?

To answer 1, you can use vector similarity which can give you high similarity for tokens similar in meaning. To answer 2, you should look at giving importance/weights to the tokens. You can use a measure like tf-idf. While comparing hospital machine and building machine, machine being a frequent word in your corpus should get a lower score and hence would contribute lesser to the overall similarity. Most of the similarity would be then determined by the similarity between hospital and building which would solve your issue.

  • $\begingroup$ Okay, thank you! I'll have a look on these measure (tf-idf) for answer 2. I also want user input (it can be through click or order selection or a mark) to influence the result. The ranking should offer the most similar expression but also the most "selected". I wonder if it's possible to do so ? $\endgroup$
    – Martin
    Mar 14, 2019 at 15:36
  • $\begingroup$ The weights given by td-if can be one measure, user imput would provide another factor. But I would argue that TD-if would probably not be valuable if each phrase is only a few words. $\endgroup$
    – MichaelD
    Aug 13, 2019 at 1:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.