Web search basics (Recap) The Web Web crawler Indexer Search User Indexes Query Engine 1.

Slides:



Advertisements
Similar presentations
Lecture 6: Scoring, Term Weighting and the Vector Space Model
Advertisements

Introduction to Information Retrieval Introduction to Information Retrieval Lecture 7: Scoring and results assembly.
Chapter 5: Introduction to Information Retrieval
Beyond Boolean Queries Ranked retrieval  Thus far, our queries have all been Boolean.  Documents either match or don’t.  Good for expert users with.
TEXT SIMILARITY David Kauchak CS159 Spring Quiz #2  Out of 30 points  High:  Ave: 23  Will drop lowest quiz  I do not grade based on.
Text Similarity David Kauchak CS457 Fall 2011.
| 1 › Gertjan van Noord2014 Zoekmachines Lecture 4.
Hinrich Schütze and Christina Lioma
Introducing ranked retrieval
Ranking models in IR Key idea: We wish to return in order the documents most likely to be useful to the searcher To do this, we want to know which documents.
Introduction to Information Retrieval (Manning, Raghavan, Schutze) Chapter 6 Scoring term weighting and the vector space model.
TF-IDF David Kauchak cs160 Fall 2009 adapted from:
Information Retrieval Ling573 NLP Systems and Applications April 26, 2011.
CpSc 881: Information Retrieval
Indexing The essential step in searching. Review a bit We have seen so far – Crawling In the abstract and as implemented Your own code and Nutch If you.
CS276 Information Retrieval and Web Mining
Hinrich Schütze and Christina Lioma
Information Retrieval IR 6. Recap of the last lecture Parametric and field searches Zones in documents Scoring documents: zone weighting Index support.
The Vector Space Model …and applications in Information Retrieval.
Retrieval Models II Vector Space, Probabilistic.  Allan, Ballesteros, Croft, and/or Turtle Properties of Inner Product The inner product is unbounded.
Vector Space Model : TF - IDF
CES 514 Data Mining March 11, 2010 Lecture 5: scoring, term weighting, vector space model (Ch 6)
Chapter 5: Information Retrieval and Web Search
CSCI 5417 Information Retrieval Systems Jim Martin Lecture 6 9/8/2011.
CS276A Text Information Retrieval, Mining, and Exploitation Lecture 4 15 Oct 2002.
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.
Web search basics (Recap) The Web Web crawler Indexer Search User Indexes Query Engine 1 Ad indexes.
Boolean and Vector Space Models
Automated Essay Grading Resources: Introduction to Information Retrieval, Manning, Raghavan, Schutze (Chapter 06 and 18) Automated Essay Scoring with e-rater.
Document ranking Paolo Ferragina Dipartimento di Informatica Università di Pisa.
Scoring, Term Weighting, and Vector Space Model Lecture 7: Scoring, Term Weighting and the Vector Space Model Web Search and Mining 1.
Information Retrieval continued Many slides in this presentation are from Christopher D. Manning, Prabhakar Raghavan and Hinrich Schütze, Introduction.
TF-IDF David Kauchak cs458 Fall 2012 adapted from:
Information Retrieval Lecture 2 Introduction to Information Retrieval (Manning et al. 2007) Chapter 6 & 7 For the MSc Computer Science Programme Dell Zhang.
Basic ranking Models Boolean and Vector Space Models.
Advanced topics in Computer Science Jiaheng Lu Department of Computer Science Renmin University of China
Information Retrieval and Data Mining (AT71. 07) Comp. Sc. and Inf
Term Frequency. Term frequency Two factors: – A term that appears just once in a document is probably not as significant as a term that appears a number.
Chapter 6: Information Retrieval and Web Search
Information Retrieval and Web Search IR models: Vectorial Model Instructor: Rada Mihalcea Class web page: [Note: Some.
Ranking in Information Retrieval Systems Prepared by: Mariam John CSE /23/2006.
Web search basics (Recap) The Web Web crawler Indexer Search User Indexes Query Engine 1.
Introduction to Information Retrieval Introduction to Information Retrieval COMP4210: Information Retrieval and Search Engines Lecture 5: Scoring, Term.
CSCI 5417 Information Retrieval Systems Jim Martin Lecture 5 9/6/2011.
Vector Space Models.
Introduction to Information Retrieval CSE 538 MRS BOOK – CHAPTER VI SCORING, TERM WEIGHTING AND THE VECTOR SPACE MODEL 1.
CIS 530 Lecture 2 From frequency to meaning: vector space models of semantics.
Lecture 6: Scoring, Term Weighting and the Vector Space Model
Information Retrieval Techniques MS(CS) Lecture 7 AIR UNIVERSITY MULTAN CAMPUS Most of the slides adapted from IIR book.
Information Retrieval and Web Search IR models: Vector Space Model Instructor: Rada Mihalcea [Note: Some slides in this set were adapted from an IR course.
Term weighting and Vector space retrieval
Introduction to Information Retrieval Introduction to Information Retrieval Lecture 9: Scoring, Term Weighting and the Vector Space Model.
Web Information Retrieval
Information Retrieval and Web Search IR models: Vector Space Model Term Weighting Approaches Instructor: Rada Mihalcea.
3: Search & retrieval: Structures. The dog stopped attacking the cat, that lived in U.S.A. collection corpus database web d1…..d n docs processed term-doc.
Introduction to Information Retrieval Introduction to Information Retrieval CS276: Information Retrieval and Web Search Pandu Nayak and Prabhakar Raghavan.
IR 6 Scoring, term weighting and the vector space model.
Introduction to Information Retrieval Information Retrieval and Data Mining (AT71.07) Comp. Sc. and Inf. Mgmt. Asian Institute of Technology Instructor:
The Vector Space Models (VSM)
Plan for Today’s Lecture(s)
7CCSMWAL Algorithmic Issues in the WWW
Ch 6 Term Weighting and Vector Space Model
Prof. Paolo Ferragina, Algoritmi per "Information Retrieval"
Information Retrieval and Web Search
Representation of documents and queries
From frequency to meaning: vector space models of semantics
CS276: Information Retrieval and Web Search
Term Frequency–Inverse Document Frequency
Presentation transcript:

Web search basics (Recap) The Web Web crawler Indexer Search User Indexes Query Engine 1

Process query Look-up the index Retrieve list of documents Order documents Content relevance Link analysis Popularity Prepare results page 2

Ranked retrieval Thus far, our queries have all been Boolean. Documents either match or don’t. Good for expert users with precise understanding of their needs and the collection. Also good for applications: Applications can easily consume 1000s of results. Not good for the majority of users. Most users incapable of writing Boolean queries (or they are, but they think it’s too much work). Most users don’t want to wade through 1000s of results.  This is particularly true of web search. Ch. 6

Problem with Boolean search: feast or famine Boolean queries often result in either too few (=0) or too many (1000s) results. Query 1: “standard user dlink 650” → 200,000 hits Query 2: “standard user dlink 650 no card found”: 0 hits It takes a lot of skill to come up with a query that produces a manageable number of hits. AND gives too few; OR gives too many Ch. 6

Ranked retrieval models Rather than a set of documents satisfying a query expression, in ranked retrieval, the system returns an ordering over the (top) documents in the collection for a query Free text queries: Rather than a query language of operators and expressions, the user’s query is just one or more words in a human language In principle, there are two separate choices here, but in practice, ranked retrieval has normally been associated with free text queries and vice versa 5

Feast or famine: not a problem in ranked retrieval When a system produces a ranked result set, large result sets are not an issue Indeed, the size of the result set is not an issue We just show the top k ( ≈ 10) results We don’t overwhelm the user Premise: the ranking algorithm works Ch. 6 Today’s question: Given a large list of documents that match a query, how to order them according to their relevance? Answer: Scoring the documents

Answer: Scoring Documents Given document d Given query q Calculate score(q,d) Rank documents in decreasing order of score(q,d) Generic Model: Documents = bag of [unordered] words (in set theory a bag is a multiset) A document is composed of terms A query is composed of terms score(q,d) will depend on terms 7

Scoring as the basis of ranked retrieval We wish to return in order the documents most likely to be useful to the searcher How can we rank-order the documents in the collection with respect to a query? Assign a score – say in [0, 1] – to each document This score measures how well document and query “match”. Ch. 6

Query-document matching scores We need a way of assigning a score to a query/document pair Let’s start with a one-term query If the query term does not occur in the document: score should be 0 The more frequent the query term in the document, the higher the score (should be) We will look at a number of alternatives for this. Ch. 6

10 Method 1: Jaccard Coefficient A commonly used measure of overlap of two sets Let A and B be two sets Jaccard coefficient: JACCARD (A, A) = 1 JACCARD (A, B) = 0 if A ∩ B = 0 A and B don’t have to be the same size Always assigns a number between 0 and 1

11 Jaccard Coefficient: Example What is the query-document match score that the Jaccard Coefficient computes for: Query: “ides of March” Document “Caesar died in March” JACCARD(q, d) = 1/6

Issues with Jaccard for scoring It doesn’t consider term frequency (how many times a term occurs in a document) Rare terms in a collection are more informative than frequent terms. Jaccard doesn’t consider this information We need a more sophisticated way of normalizing for length  Alternative instead of |A ∩ B|/|A ∪ B| (Jaccard) for length normalization. Ch. 6

Binary term-document incidence matrix Each document is represented by a binary vector ∈ {0,1} |V| Sec. 6.2

Term-document count matrices Consider the number of occurrences of a term in a document: Each document is a count vector in ℕ v : a column below Sec. 6.2

Bag of words model Vector representation doesn’t consider the ordering of words in a document John is quicker than Mary and Mary is quicker than John have the same vectors This is called the bag of words model.

Term frequency tf The term frequency tf t,d of term t in document d is defined as the number of times that t occurs in d. We want to use tf when computing query-document match scores. But how? Raw term frequency is not what we want: A document with 10 occurrences of the term is more relevant than a document with 1 occurrence of the term. But not 10 times more relevant. Relevance does not increase proportionally with term frequency.

Method 2: Assign weights to terms Assign to each term a weight tf t,d - term frequency (how often term t occurs in document d) query = ‘who wrote wild boys’ doc1 = ‘Duran Duran sang Wild Boys in 1984.’ doc2 = ‘Wild boys don’t remain forever wild.’ doc3 = ‘Who brought wild flowers?’ doc4 = ‘It was John Krakauer who wrote In to the wild.’ query = {boys: 1, who: 1, wild: 1, wrote: 1} doc1 = {1984: 1, boys: 1, duran: 2, in: 1, sang: 1, wild: 1} doc2 = {boys: 1, don’t: 1, forever: 1, remain: 1, wild: 2}… score(q, doc1) = = 2score(q, doc2) = = 3 score(q,doc3) = = 2score(q, doc4) = = 3 17

Why is tf not good? All terms have equal importance. Bigger documents have more terms, thus the score is larger. It ignores term order. Postulate: If a word appears in every document, probably it is not that important (it has no discriminatory power). 18

Introduction to Information Retrieval Log-frequency weighting  The log frequency weight of term t in d is  0 → 0, 1 → 1, 2 → 1.3, 10 → 2, 1000 → 4, etc.  Score for a document-query pair: sum over terms t in both q and d:  score  The score is 0 if none of the query terms is present in the document. Sec. 6.2

Document frequency Rare terms are more informative than frequent terms Recall stop words Consider a term in the query that is rare in the collection (e.g., arachnocentric) A document containing this term is very likely to be relevant to the query arachnocentric → We want a high weight for rare terms like arachnocentric. Sec

Document frequency, continued Frequent terms are less informative than rare terms Consider a query term that is frequent in the collection (e.g., high, increase, line) A document containing such a term is more likely to be relevant than a document that doesn’t But it’s not a sure indicator of relevance. → For frequent terms, we want high positive weights for words like high, increase, and line But lower weights than for rare terms. We will use document frequency (df) to capture this. Sec

idf weight df t is the document frequency of t: the number of documents that contain t df t is an inverse measure of the informativeness of t df t  N We define the idf (inverse document frequency) of t by We use log (N/df t ) instead of N/df t to “dampen” the effect of idf. Will turn out the base of the log is immaterial. Sec

idf example, suppose N = 1 million termdf t idf t calpurnia1 animal100 sunday1,000 fly10,000 under100,000 the1,000,000 There is one idf value for each term t in a collection. Sec

Method 3: New weights df t - document frequency for term t idf t - inverse document frequency for term t tf-idf td - a combined weight for term t in document d Increases with the number of occurrences within a doc Increases with the rarity of the term across the whole corpus N - total number of documents 24

Using new weights 25 Question: For which words does tf-idf td have a value of 0? Answer: stopwords, that is words that appear in every document.

Example: idf values 26 termsdfidf boys brought don’t duran flowers forever in it john termsdfidf krakauer remain sang the to was who wild40.0 wrote doc1 = ‘Duran Duran sang Wild Boys in 1984.’ doc2 = ‘Wild boys don’t remain forever wild.’ doc3 = ‘Who brought wild flowers?’ doc4 = ‘It was John Krakauer who wrote In to the wild.’

Example: calculating scores (1) documentsS: tf-idfS: tf duran duran sang wild boys in wild boys don't remain forever wild who brought wild flowers it was john krakauer who wrote in to the wild query = ‘who wrote wild boys’ documentsS: tf-idfS: tf duran duran sang wild boys in wild boys don't remain forever wild who brought wild flowers it was john krakauer who wrote in to the wild When df for ‘wild’ becomes 3, its idf = log10(4/3) = 0.125

Example: calculating scores (2) documentsS: tf-idfS: tf duran duran who sang wild boys in wild boys don't remain forever wild who brought wild flowers it was john krakauer who wrote in to the wild documentsS: tf-idfS: tf duran duran sang wrote wild boys in wild boys don't remain forever wild who brought wild flowers it was john krakauer who wrote in to the wild query = ‘who wrote wild boys’ 28 Question: Why when we introduce ‘wrote’ the score for ‘duran-duran’ is higher than when we introduce ‘who’? Answer: ‘who’ has a lower idf (log4/3) than ‘wrote’ (log4/2) Question: Why when we introduce ‘wrote’ the score for ‘duran-duran’ is higher than when we introduce ‘who’? Answer: ‘who’ has a lower idf (log4/3) than ‘wrote’ (log4/2)

The Vector Space Model Formalizing the “bag-of-words” model. Each term from the collection becomes a dimension in a n-dimensional space. A document is a vector in this space, where term weights serve as coordinates. It is important for: Scoring documents for answering queries Query by example Document classification Document clustering 29 Question: How big is the vector space? Answer: It will depend on the size of the vocabulary of the document collection. Question: How big is the vector space? Answer: It will depend on the size of the vocabulary of the document collection.

Term-document matrix (revision) 30 Anthony & Cleopatra Julius CaesarHamletOthello Anthony Brutus Caesar Calphurnia01000 Cleopatra48000 The counts in each column represent term frequency (tf).

Documents as vectors 31 … combat … courage… enemy … fierce … peace … war HenryVI HenryVI HenryVI Othello Rom.&Jul Taming … Calculation example: N = 44 (works in the Shakespeare collection) wardf = 21, idf = log(44/21) = HenryVI-1tf-idf war = tf war * idf war = 12 * = HenryVI-3 = 50 * =

Why turn docs into vectors? 32 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.

Some geometry 33 t1 t2 d1 d2 d1 cosine can be used as a measure of similarity between two vectors Given two vectors and

Cosine Similarity 34 where is a weight, e.g., tf-idf We can regard a query q as a document d q and use the same formula: For any two given documents d j and d k, their similarity is:

Example 35 Given the Shakespeare play “Hamlet”, find most similar plays to it. 1.Taming of the shrew 2.Winter’s tale 3.Richard III horhaue tftf-idftftf-idf Hamlet Taming of the Shrew The word ‘hor’ appears only in these two plays. It is an abbreviation (‘Hor.’) for the names Horatio and Hortentio. The product of the tf-idf values for this word amounts to 82% of the similarity value between the two documents.

Documents as vectors So we have a |V|-dimensional vector space Terms are axes of the space Documents are points or vectors in this space Very high-dimensional: tens of millions of dimensions when you apply this to a web search engine These are very sparse vectors - most entries are zero. Sec. 6.3

Queries as vectors Key idea 1: Do the same for queries: represent them as vectors in the space Key idea 2: Rank documents according to their proximity to the query in this space proximity = similarity of vectors proximity ≈ inverse of distance Recall: We do this because we want to get away from the you’re-either-in-or-out Boolean model. Instead: rank more relevant documents higher than less relevant documents Sec. 6.3

Formalizing vector space proximity First cut: distance between two points ( = distance between the end points of the two vectors) Euclidean distance? Euclidean distance is a bad idea because Euclidean distance is large for vectors of different lengths. Sec. 6.3

Why distance is a bad idea The Euclidean distance between q and d 2 is large even though the distribution of terms in the query q and the distribution of terms in the document d 2 are very similar. Sec. 6.3

Use angle instead of distance Thought experiment: take a document d and append it to itself. Call this document d′. “Semantically” d and d′ have the same content The Euclidean distance between the two documents can be quite large The angle between the two documents is 0, corresponding to maximal similarity. Key idea: Rank documents according to angle with query. Sec. 6.3

From angles to cosines The following two notions are equivalent. Rank documents in decreasing order of the angle between query and document Rank documents in increasing order of cosine(query,document) Cosine is a monotonically decreasing function for the interval [0 o, 180 o ] Sec. 6.3

From angles to cosines But how – and why – should we be computing cosines? Sec. 6.3

Length normalization A vector can be (length-) normalized by dividing each of its components by its length – for this we use the L 2 norm: Dividing a vector by its L 2 norm makes it a unit (length) vector (on surface of unit hypersphere) Effect on the two documents d and d′ (d appended to itself) from earlier slide: they have identical vectors after length-normalization. Long and short documents now have comparable weights Sec. 6.3

cosine(query,document) Dot product Unit vectors q i is the tf-idf weight of term i in the query d i is the tf-idf weight of term i in the document cos(q,d) is the cosine similarity of q and d … or, equivalently, the cosine of the angle between q and d. Sec. 6.3

Cosine for length-normalized vectors For length-normalized vectors, cosine similarity is simply the dot product (or scalar product): for q, d length-normalized. 45

Cosine similarity illustrated 46

Cosine similarity amongst 3 documents termSaSPaPWH affection jealous10711 gossip206 wuthering0038 How similar are the novels SaS: Sense and Sensibility PaP: Pride and Prejudice, and WH: Wuthering Heights? Term frequencies (counts) Sec. 6.3 Note: To simplify this example, we don’t do idf weighting.

3 documents example contd. Log frequency weighting termSaSPaPWH affection jealous gossip wuthering After length normalization termSaSPaPWH affection jealous gossip wuthering cos(SaS,PaP) ≈ × × × × 0.0 ≈ 0.94 cos(SaS,WH) ≈ 0.79 cos(PaP,WH) ≈ 0.69 Why do we have cos(SaS,PaP) > cos(SaS,WH)? Sec. 6.3

Computing cosine scores Sec. 6.3

tf-idf weighting has many variants Columns headed ‘n’ are acronyms for weight schemes. Why is the base of the log in idf immaterial? Sec. 6.4

Weighting may differ 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), no normalization … A bad idea? Sec. 6.4

Digression: spamming indices 52 This method was 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.

Issues to consider 53 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