0
$\begingroup$

I have a corpora of queries and answers where the queries are the title of different documents and the answers are a short description of them. E.g:

Title: African Civilian Deaths

Description: How many civilian non-combatants have been killed in the various civil wars in Africa?

I have tried to build a DSSM model to compute the cosine similarity between a given title and the queries so I could print out the one with bigger similarity expecting to be the right one. For instance, when writing "African Civilian Deaths" I was expecting to get the description between the top 10 answers, which didn't get to happen being in the 45th place.

As I didn't succeed doing this I was wondering how could I do it using tf-idf. I know how to compute the relevance of each word in my documents and so on but I don't really know how to make the comparison... Or how to say that this description corresponds to the title. Therefore, my question is how could I use tf-idf for comparing a query and an answer to see how close they are. I want the real question to be at least in the top 10 of most similar answers.

$\endgroup$

2 Answers 2

1
$\begingroup$

With tf-idf, each of your queries and answers is a vector (whose size is the number of words in your corpora) in the tf-idf word-document matrix.

Then, you can do exactly what you did previously and use cosine similarities to determine proximity between your titles and your descriptions.

Tf-idf is just a way to transform a document (seen as a bag of words) into a numerical vector. It creates a tf-idf word-document matrix. Each line of this matrix "represents" a word and each column a document.

$\endgroup$
1
  • $\begingroup$ I was think of another approach as the one with cosine similarity didn't give me good results. Something like compare the tf-idf value of the words in the documents with those in the queries or so as I am not interested in using DSSM now. $\endgroup$
    – Marisa
    Apr 13, 2018 at 12:39
0
$\begingroup$

If it is not the case that you have to implement everything from the scratch, perhaps of a research reason, you can use one of many information retrieval platforms whereby you can run popular retrieval methods like tf-idf, BM25, SDM, and so on. These are some that I have used:

$\endgroup$
1
  • $\begingroup$ I have to implement it from zero... $\endgroup$
    – Marisa
    Apr 13, 2018 at 12:41

Your Answer

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

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