# Item-Item similarity based on text

We're build an item-item recommender based on the text descriptions of the items. Our initial approach was to calculate the TF-IDF vectors for each item. We used a hashing tf with 5000 possible hashes for the words. Then approximate all-pairs using a sampling technique (DIMSUM).

We have an mxn matrix where m is the number of words, n is the number of items. The naive approach of calculating all column cosine similarities won't work here since we have n=10^7 m=10^4.

Our first attempt was using DIMSUM http://stanford.edu/~rezab/papers/dimsum.pdf which is an all-pairs sampling technique. The problem with DIMSUM is it works for data where m >> n. Our matrix is short and wide n>m.

My Question: What is a good approach for estimating all-pairs similarity of items based on words. Where number of items is 10^7, number of words is 10^4. We only want items pairs above a certain threshold of similarity.

We don't have to do it this way, our task is to recommend a small set of items given one item, we have ways of doing this using collaborative filtering, but we want to also handle new items that we have no user data for so we're trying to find a way to use tf-idf vectors for that case.

• Are you planning on using distributed computation? If so, have you considered Apache Spark...it's much faster in many cases than map reduce. – user9424 Jul 31 '15 at 2:07
• I'm using spark. columnSimilarity is implemented in scala for spark, I'm using python so I implemented it myself in the python bindings. Either way, doing all pairs similarity brute force is infeasible even on huge spark clusters. DIMSUM offers a smart trick for sampling only column similarities that have a high probability of being over a certain threshold, the issue is that DIMSUM works only when you have more rows than columns. I have many more columns than rows. see the linked paper for details – Brandon Hamric Jul 31 '15 at 20:44
• Have you considered dimension reduction ? PCA is a good candidate for this kind of problem, specially involving the TFIDF vector model. Once you perform the dimension reduction, you can then apply a simple KMeans to cluster your items. – eliasah Oct 17 '15 at 9:42