CS255 Fundamentals of Information Retrieval
Lecture 6
Vector Space Model
Krishnendu Ghosh
Department of Computer Science & Engineering
Indian Institute of Information Technology Dharwad
Ranked Retrieval
Problem with Boolean Search: feast or famine
Ranked Retrieval Models
feast or famine: not a problem in Ranked Retrieval
Scoring as the basis of Ranked Retrieval
Query-Document Matching Scores
Jaccard Coefficient
Jaccard Coefficient: Scoring example
Issue with Jaccard coefficients
Recall: Binary Term-Document Incidence Matrix
Each document is represented by a binary vector ∈ {0,1}|V|
Term-Document Count Matrices
Bag of Words Model
Term Frequency tf
Log-Frequency Weighting
score
Rare terms are more informative
Collection vs. Document Frequency
Word | Collection Frequency | Document Frequency |
Insurance | 10440 | 3997 |
Try | 10422 | 8760 |
idf Weight
idf Weight, suppose N = 1 million
There is one idf value for each term t in a collection.
term | dft | idft |
calpurnia | 1 | 6 |
animal | 100 | 4 |
sunday | 1,000 | 3 |
fly | 10,000 | 2 |
under | 100,000 | 1 |
the | 1,000,000 | 0 |
Effect of idf on Ranking
tf-idf Weighting
Score for a Document given a Query
There are many variants
score(q.d)=
Binary → Count → Weight Matrix
Each document is now represented by a real-valued vector of tf-idf weights ∈ R|V|
Documents as Vectors
Queries as Vectors
Formalizing Vector Space Proximity
Why Distance is a Bad Idea
The Euclidean distance between q and d2 is large even though the distribution of terms in the query q and the distribution of terms in the document d2 are very similar.
Use Angle instead of Distance
from Angles to Cosines
Length Normalization
Cosine Similarity
Cosine Similarity Illustrated
Cosine Similarity amongst 3 Documents
How similar are the novels?
SaS: Sense and Sensibility
PaP: Pride and Prejudice
WH: Wuthering Heights?
term | SaS | PaP | WH |
affection | 115 | 58 | 20 |
jealous | 10 | 7 | 11 |
gossip | 2 | 0 | 6 |
wuthering | 0 | 0 | 38 |
Cosine Similarity amongst 3 Documents
Log frequency weighting
dot(SaS,PaP) ≈ 12.1
dot(SaS,WH) ≈ 13.4
dot(PaP,WH) ≈ 10.1
After length normalization
cos(SaS,PaP) ≈ 0.94
cos(SaS,WH) ≈ 0.79
cos(PaP,WH) ≈ 0.69
term | SaS | PaP | WH |
affection | 3.06 | 2.76 | 2.30 |
jealous | 2.00 | 1.85 | 2.04 |
gossip | 1.30 | 0 | 1.78 |
wuthering | 0 | 0 | 2.58 |
term | SaS | PaP | WH |
affection | 0.789 | 0.832 | 0.524 |
jealous | 0.515 | 0.555 | 0.465 |
gossip | 0.335 | 0 | 0.405 |
wuthering | 0 | 0 | 0.588 |
Computing Cosine Similarity
D1=(1,2,2)
D2=(2,1,2)
Cosine Similarity: Term-at-a-Time Algorithm
Computing Cosine Similarity
Algorithm can be adapted to scoring document-at-a-time (DAAT)
Storing wt,d in each posting could be expensive
…because we’d have to store a floating point number
For tf-idf scoring, it suffices to store tft,d in the posting and idft in the head of the postings list
Extracting the top K items can be done with a priority queue (e.g., a heap)
Variants of TF-IDF
Weighting in Queries vs Documents
Many search engines allow for different weightings for queries vs. documents
SMART Notation: denotes the combination in use in an engine, with the notation ddd.qqq, using the acronyms from the previous table
A very standard weighting scheme is: lnc.ltc
Document: logarithmic tf (l as first character), no idf and cosine normalization
Query: logarithmic tf (l in leftmost column), idf (t in second column), cosine normalization …
Calculating TF-IDF: lnc.ltc
Document: car insurance auto insurance
Query: best car insurance
Doc length =
Score = 0+0+0.27+0.53 = 0.8
Summary: Vector Space Ranking
Thank You