Presentation is loading. Please wait.

Presentation is loading. Please wait.

Documents as vectors Each doc j can be viewed as a vector of tf.idf values, one component for each term So we have a vector space terms are axes docs live.

Similar presentations


Presentation on theme: "Documents as vectors Each doc j can be viewed as a vector of tf.idf values, one component for each term So we have a vector space terms are axes docs live."— Presentation transcript:

1 Documents as vectors Each doc j can be viewed as a vector of tf.idf values, one component for each term So we have a vector space terms are axes docs live in this space even with stemming, may have 20,000+ dimensions The corpus of documents gives us a matrix, which we could also view as a vector space in which words live – transposable data

2 Why turn docs into vectors? Query-by-example Given a doc D, find others “like” it. Now that D is a vector, => Given a doc, find vectors (docs) “near” it. Intuition: t1t1 d2d2 d1d1 d3d3 d4d4 d5d5 t3t3 t2t2 θ φ Postulate: Documents that are “close together” in vector space talk about the same things.

3 The vector space model Query as vector: We regard query as short document We return the documents ranked by the closeness of their vectors to the query, also represented as a vector. Developed in the SMART system (Salton, c. 1970) Standard used by TREC participants and web IR systems t1t1 d2d2 d1d1 d3d3 d4d4 d5d5 t3t3 t2t2 θ φ

4 Desiderata for Proximity Symmetry: If d 1 is near d 2, then d 2 is near d 1. Triangular inequality: If d 1 near d 2, and d 2 near d 3, then d 1 is not far from d 3. Identity: No doc is closer to d than d itself. t1t1 d2d2 d1d1 d3d3 d4d4 d5d5 t3t3 t2t2 θ φ

5 First cut Distance between d 1 and d 2 is the length of the vector |d 1 – d 2 |. Euclidean distance Why is this not a great idea? We still haven’t dealt with the issue of length normalization Long documents would be more similar to each other by virtue of length, not topic However, we can implicitly normalize by looking at angles instead

6 Cosine similarity Distance between vectors d 1 and d 2 captured by the cosine of the angle x between them. Note – this is similarity, not distance You do not have triangular inequality, but good enough t 1 d 2 d 1 t 3 t 2 θ

7 Cosine similarity A vector can be normalized (given a length of 1) by dividing each of its components by its length – here we use the L 2 norm This maps vectors onto the unit sphere: Then, Longer documents don’t get more weight

8 Cosine similarity Cosine of angle between two vectors The denominator involves the lengths of the vectors. Normalization

9 Normalized vectors For normalized vectors, the cosine is simply the dot product:

10 Example Docs: Austen's Sense and Sensibility, Pride and Prejudice; Bronte's Wuthering Heights. tf weights cos(SAS, PAP) =.996 x.993 +.087 x.120 +.017 x 0.0 = 0.999 cos(SAS, WH) =.996 x.847 +.087 x.466 +.017 x.254 = 0.889

11 Cosine similarity exercises Rank the following by decreasing cosine similarity: Two docs that have only frequent words (the, a, an, of) in common. Two docs that have no words in common. Two docs that have many rare words in common (wingspan, tailfin).

12 Queries in the vector space model Central idea: the query as a vector: We regard the query as short document We return the documents ranked by the closeness of their vectors to the query, also represented as a vector. Note that d q is very sparse!

13 Summary What’s the real point of using vector spaces?: A user’s query can be viewed as a (very) short document. Query becomes a vector in the same space as the docs. Can measure each doc’s proximity to it. Natural measure of scores/ranking – no longer Boolean. Is it the only thing that people use? No; if you know that some words have special meaning in your own corpus, not justified by tf.idf, then manual editing of weights may take place E.g., “benefits” might be re-weighted by hand in the corpus of an HR department

14 Digression: spamming indices This was all invented before the days when people were in the business of spamming web search engines. Consider: Indexing a sensible passive document collection vs. An active document collection, where people (and indeed, service companies) are shaping documents in order to maximize scores Vector space similarity may not be as useful in this context.

15 Issues to consider How would you augment the inverted index to support cosine ranking computations? Walk through the steps of serving a query. The math of the vector space model is quite straightforward, but being able to do cosine ranking efficiently at runtime is nontrivial


Download ppt "Documents as vectors Each doc j can be viewed as a vector of tf.idf values, one component for each term So we have a vector space terms are axes docs live."

Similar presentations


Ads by Google