Information Retrieval and Web Search IR models: Vectorial Model Instructor: Rada Mihalcea Class web page: [Note: Some.

Slides:



Advertisements
Similar presentations
Text Categorization.
Advertisements

Boolean and Vector Space Retrieval Models
Chapter 5: Introduction to Information Retrieval
Modern information retrieval Modelling. Introduction IR systems usually adopt index terms to process queries IR systems usually adopt index terms to process.
Basic IR: Modeling Basic IR Task: Slightly more complex:
Intelligent Information Retrieval 1 Vector Space Model for IR: Implementation Notes CSC 575 Intelligent Information Retrieval These notes are based, in.
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:
Learning for Text Categorization
IR Models: Overview, Boolean, and Vector
1 Boolean and Vector Space Retrieval Models Many slides in this section are adapted from Prof Raymond Mooney (UTexas), Prof. Joydeep Ghosh (UT ECE) who.
Boolean, Vector Space, Probabilistic
IR Models: Structural Models
Ch 4: Information Retrieval and Text Mining
Modeling Modern Information Retrieval
CS276 Information Retrieval and Web Mining
IR Models: Latent Semantic Analysis. IR Model Taxonomy Non-Overlapping Lists Proximal Nodes Structured Models U s e r T a s k Set Theoretic Fuzzy Extended.
Boolean, Vector Space, Probabilistic
Vector Space Model CS 652 Information Extraction and Integration.
1 Basic Text Processing and Indexing. 2 Document Processing Steps Lexical analysis (tokenizing) Stopwords removal Stemming Selection of indexing terms.
Information Retrieval IR 6. Recap of the last lecture Parametric and field searches Zones in documents Scoring documents: zone weighting Index support.
Retrieval Models II Vector Space, Probabilistic.  Allan, Ballesteros, Croft, and/or Turtle Properties of Inner Product The inner product is unbounded.
IR Models: Review Vector Model and Probabilistic.
Other IR Models Non-Overlapping Lists Proximal Nodes Structured Models Retrieval: Adhoc Filtering Browsing U s e r T a s k Classic Models boolean vector.
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.
Information Retrieval and Web Search Text properties (Note: some of the slides in this set have been adapted from the course taught by Prof. James Allan.
PrasadL2IRModels1 Models for IR Adapted from Lectures by Berthier Ribeiro-Neto (Brazil), Prabhakar Raghavan (Yahoo and Stanford) and Christopher Manning.
Information Retrieval Chapter 2: Modeling 2.1, 2.2, 2.3, 2.4, 2.5.1, 2.5.2, Slides provided by the author, modified by L N Cassel September 2003.
Information Retrieval Models - 1 Boolean. Introduction IR systems usually adopt index terms to process queries Index terms:  A keyword or group of selected.
Information Retrieval Lecture 2 Introduction to Information Retrieval (Manning et al. 2007) Chapter 6 & 7 For the MSc Computer Science Programme Dell Zhang.
Introduction to Digital Libraries Searching
Advanced topics in Computer Science Jiaheng Lu Department of Computer Science Renmin University of China
IR Models J. H. Wang Mar. 11, The Retrieval Process User Interface Text Operations Query Operations Indexing Searching Ranking Index Text quer y.
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
Introduction to Digital Libraries hussein suleman uct cs honours 2003.
Ranking in Information Retrieval Systems Prepared by: Mariam John CSE /23/2006.
Information Retrieval Model Aj. Khuanlux MitsophonsiriCS.426 INFORMATION RETRIEVAL.
CSCE 5300 Information Retrieval and Web Search Introduction to IR models and methods Instructor: Rada Mihalcea Class web page:
Vector Space Models.
1 CS 391L: Machine Learning Text Categorization Raymond J. Mooney University of Texas at Austin.
Lecture 6: Scoring, Term Weighting and the Vector Space Model
C.Watterscsci64031 Classical IR Models. C.Watterscsci64032 Goal Hit set of relevant documents Ranked set Best match Answer.
Set Theoretic Models 1. IR Models Non-Overlapping Lists Proximal Nodes Structured Models Retrieval: Adhoc Filtering Browsing U s e r T a s k Classic Models.
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.
Introduction n IR systems usually adopt index terms to process queries n Index term: u a keyword or group of selected words u any word (more general) n.
Information Retrieval Models School of Informatics Dept. of Library and Information Studies Dr. Miguel E. Ruiz.
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.
1 Text Categorization  Assigning documents to a fixed set of categories  Applications:  Web pages  Recommending pages  Yahoo-like classification hierarchies.
The Vector Space Models (VSM)
Information Retrieval and Web Search
אחזור מידע, מנועי חיפוש וספריות
Information Retrieval and Web Search
Representation of documents and queries
6. Implementation of Vector-Space Retrieval
4. Boolean and Vector Space Retrieval Models
5. Vector Space and Probabilistic Retrieval Models
Boolean and Vector Space Retrieval Models
Recuperação de Informação B
Recuperação de Informação B
Advanced information retrieval
Term Frequency–Inverse Document Frequency
Presentation transcript:

Information Retrieval and Web Search IR models: Vectorial Model Instructor: Rada Mihalcea Class web page: [Note: Some slides in this set were adapted from an IR course taught by Ray Mooney at UT Austin, who in turn adapted them from Joydeep Ghosh, who in turn adapted them …]

Slide 1 Topics Vectorial model –TF/IDF Weighting –Similarity measure Inner product Euclidian cosine –Naïve implementation –Practical implementation –Weighting methods Need someone to present next time

Slide 2 IR Models Non-Overlapping Lists Proximal Nodes Structured Models Retrieval: Adhoc Filtering Browsing U s e r T a s k Classic Models boolean vector probabilistic Set Theoretic Fuzzy Extended Boolean Probabilistic Inference Network Belief Network Algebraic Generalized Vector Lat. Semantic Index Neural Networks Browsing Flat Structure Guided Hypertext

Slide 3 Vector-Space Model t distinct terms remain after preprocessing –Unique terms that form the VOCABULARY These “ orthogonal ” terms form a vector space. Dimension = t = |vocabulary| –2 terms  bi-dimensional; … ; n-terms  n-dimensional Each term, i, in a document or query j, is given a real- valued weight, w ij. Both documents and queries are expressed as t- dimensional vectors: d j = (w 1j, w 2j, …, w tj )

Slide 4 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. Vectorial model was developed in the SMART system (Salton, c. 1970) and standardly used by TREC participants and web IR systems

Slide 5 Graphic Representation Example: D 1 = 2T 1 + 3T 2 + 5T 3 D 2 = 3T 1 + 7T 2 + T 3 Q = 0T 1 + 0T 2 + 2T 3 T3T3 T1T1 T2T2 D 1 = 2T 1 + 3T 2 + 5T 3 D 2 = 3T 1 + 7T 2 + T 3 Q = 0T 1 + 0T 2 + 2T Is D 1 or D 2 more similar to Q? How to measure the degree of similarity? Distance? Angle? Projection?

Slide 6 Document Collection Representation A collection of n documents can be represented in the vector space model by a term-document matrix. An entry in the matrix corresponds to the “ weight ” of a term in the document; zero means the term has no significance in the document or it simply doesn ’ t exist in the document. T 1 T 2 …. T t D 1 w 11 w 21 … w t1 D 2 w 12 w 22 … w t2 : : : : D n w 1n w 2n … w tn

Slide 7 Term Weights: Term Frequency More frequent terms in a document are more important, i.e. more indicative of the topic. f ij = frequency of term i in document j May want to normalize term frequency (tf) across the entire corpus: tf ij = f ij / max{f ij }

Slide 8 Term Weights: Inverse Document Frequency Terms that appear in many different documents are less indicative of overall topic. df i = document frequency of term i = number of documents containing term i idf i = inverse document frequency of term i, = log 2 (N/ df i ) (N: total number of documents) An indication of a term ’ s discrimination power. Log used to dampen the effect relative to tf. Make the difference: –Document frequency VS. corpus frequency ?

Slide 9 TF-IDF Weighting A typical weighting is tf-idf weighting: w ij = tf ij idf i = tf ij log 2 (N/ df i ) A term occurring frequently in the document but rarely in the rest of the collection is given high weight. Experimentally, tf-idf has been found to work well. It was also theoretically proved to work well (Papineni, NAACL 2001) [more weighting schemes next time]

Slide 10 Computing TF-IDF: An Example Given a document containing terms with given frequencies: A(3), B(2), C(1) Assume collection contains 10,000 documents and document frequencies of these terms are: A(50), B(1300), C(250) Then: A: tf = 3/3; idf = log(10000/50) = 5.3; tf-idf = 5.3 B: tf = 2/3; idf = log(10000/1300) = 2.0; tf-idf = 1.3 C: tf = 1/3; idf = log(10000/250) = 3.7; tf-idf = 1.2

Slide 11 Query Vector Query vector is typically treated as a document and also tf-idf weighted. Alternative is for the user to supply weights for the given query terms.

Slide 12 Similarity Measure We now have vectors for all documents in the collection, a vector for the query, how to compute similarity? A similarity measure is a function that computes the degree of similarity between two vectors. Using a similarity measure between the query and each document: –It is possible to rank the retrieved documents in the order of presumed relevance. –It is possible to enforce a certain threshold so that the size of the retrieved set can be controlled.

Slide 13 Desiderata for proximity If d 1 is near d 2, then d 2 is near d 1. If d 1 near d 2, and d 2 near d 3, then d 1 is not far from d 3. No document is closer to d than d itself. –Sometimes it is a good idea to determine the maximum possible similarity as the “distance” between a document d and itself

Slide 14 First cut: Euclidean distance Distance between vectors d 1 and d 2 is the length of the vector |d 1 – d 2 |. –Euclidean distance Exercise: Determine the Euclidean distance between the vectors (0, 3, 2, 1, 10) and (2, 7, 1, 0, 0) 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

Slide 15 Second cut: Manhattan Distance Or “city block” measure –Based on the idea that generally in American cities you cannot follow a direct line between two points. Uses the formula: Exercise: Determine the Euclidean distance between the vectors (0, 3, 2, 1, 10) and (2, 7, 1, 0, 0) x y

Slide 16 Third cut: Inner Product Similarity between vectors for the document d i and query q can be computed as the vector inner product: sim(d j,q) = d j q = w ij · w iq where w ij is the weight of term i in document j and w iq is the weight of term i in the query For binary vectors, the inner product is the number of matched query terms in the document (size of intersection). For weighted term vectors, it is the sum of the products of the weights of the matched terms.

Slide 17 Properties of Inner Product Favors long documents with a large number of unique terms. –Again, the issue of normalization Measures how many terms matched but not how many terms are not matched.

Slide 18 Inner Product: Example 1 d1 d2 d3 d4d5 d6 d7 k1 k2 k3

Slide 19 d1 d2 d3 d4d5 d6 d7 k1 k2 k3 Inner Product: Exercise

Slide 20 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 t 1 d2d2 d1d1 t 3 t 2 θ

Slide 21 Cosine similarity Cosine of angle between two vectors The denominator involves the lengths of the vectors So the cosine measure is also known as the normalized inner product

Slide 22 Cosine similarity exercise Exercise: Rank the following by decreasing cosine similarity: –Two documents that have only frequent words (the, a, an, of) in common. –Two documents that have no words in common. –Two documents that have many rare words in common (wingspan, tailfin).

Slide 23 Example Documents: Austen's Sense and Sensibility, Pride and Prejudice; Bronte's Wuthering Heights cos(SAS, PAP) =.996 x x x 0.0 = cos(SAS, WH) =.996 x x x.254 = 0.929

Slide 24 Cosine Similarity vs. Inner Product Cosine similarity measures the cosine of the angle between two vectors. Inner product normalized by the vector lengths. D 1 = 2T 1 + 3T 2 + 5T 3 CosSim(D 1, Q) = 10 /  (4+9+25)(0+0+4) = 0.81 D 2 = 3T 1 + 7T 2 + 1T 3 CosSim(D 2, Q) = 2 /  (9+49+1)(0+0+4) = 0.13 Q = 0T 1 + 0T 2 + 2T 3  t3t3 t1t1 t2t2 D1D1 D2D2 Q  D 1 is 6 times better than D 2 using cosine similarity but only 5 times better using inner product. CosSim(d j, q) = InnerProduct(d j, q) =

Slide 25 Comments on Vector Space Models Simple, mathematically based approach. Considers both local (tf) and global (idf) word occurrence frequencies. Provides partial matching and ranked results. Tends to work quite well in practice despite obvious weaknesses. Allows efficient implementation for large document collections.

Slide 26 Problems with Vector Space Model Missing semantic information (e.g. word sense). Missing syntactic information (e.g. phrase structure, word order, proximity information). Assumption of term independence (e.g. ignores synonomy). Lacks the control of a Boolean model (e.g., requiring a term to appear in a document). –Given a two-term query “ A B ”, may prefer a document containing A frequently but not B, over a document that contains both A and B, but both less frequently.

Slide 27 Naïve Implementation Convert all documents in collection D to tf-idf weighted vectors, d j, for keyword vocabulary V. Convert query to a tf-idf-weighted vector q. For each d j in D do Compute score s j = cosSim(d j, q) Sort documents by decreasing score. Present top ranked documents to the user. Time complexity: O(|V|·|D|) Bad for large V & D ! |V| = 10,000; |D| = 100,000; |V|·|D| = 1,000,000,000

Slide 28 Practical Implementation Based on the observation that documents containing none of the query keywords do not affect the final ranking Try to identify only those documents that contain at least one query keyword Actual implementation of an inverted index

Slide 29 Step 1: Preprocessing Implement the preprocessing functions: –For tokenization –For stop word removal –For stemming Input: Documents that are read one by one from the collection Output: Tokens to be added to the index –No punctuation, no stop-words, stemmed

Slide 30 Step 2: Indexing Build an inverted index, with an entry for each word in the vocabulary Input: Tokens obtained from the preprocessing module Output: An inverted index for fast access

Slide 31 Step 2 (cont’d) Many data structures are appropriate for fast access –B-trees, skipped lists, hashtables We need: –One entry for each word in the vocabulary –For each such entry: Keep a list of all the documents where it appears together with the corresponding frequency  TF –For each such entry, keep the total number of occurrences in all documents:  IDF

Slide 32 Step 2 (cont’d) system computer database science D 2, 4 D 5, 2 D 1, 3 D 7, 4 Index terms df D j, tf j Index file lists     

Slide 33 Step 2 (cont’d) TF and IDF for each token can be computed in one pass Cosine similarity also required document lengths Need a second pass to compute document vector lengths –Remember that the length of a document vector is the square- root of sum of the squares of the weights of its tokens. –Remember the weight of a token is: TF * IDF –Therefore, must wait until IDF’s are known (and therefore until all documents are indexed) before document lengths can be determined. Do a second pass over all documents: keep a list or hashtable with all document id-s, and for each document determine its length.

Slide 34 Time Complexity of Indexing Complexity of creating vector and indexing a document of n tokens is O(n). So indexing m such documents is O(m n). Computing token IDFs can be done during the same first pass Computing vector lengths is also O(m n). Complete process is O(m n), which is also the complexity of just reading in the corpus.

Slide 35 Step 3: Retrieval Use inverted index (from step 2) to find the limited set of documents that contain at least one of the query words. Incrementally compute cosine similarity of each indexed document as query words are processed one by one. To accumulate a total score for each retrieved document, store retrieved documents in a hashtable, where the document id is the key, and the partial accumulated score is the value. Input: Query and Inverted Index (from Step 2) Output: Similarity values between query and documents

Slide 36 Step 4: Ranking Sort the hashtable including the retrieved documents based on the value of cosine similarity –sort {$retrieved{$b}  $retrieved{$a}} keys %retrieved Return the documents in descending order of their relevance Input: Similarity values between query and documents Output: Ranked list of documented in reversed order of their relevance

Slide 37 What weighting methods? Weights applied to both document terms and query terms Direct impact on the final ranking  Direct impact on the results  Direct impact on the quality of IR system

Slide 38 Standard Evaluation Measures wx yz n 2 = w + y n 1 = w + x N relevant not relevant retrievednot retrieved Starts with a CONTINGENCY table

Slide 39 Precision and Recall Recall: Precision: w w+y w+x w From all the documents that are relevant out there, how many did the IR system retrieve? From all the documents that are retrieved by the IR system, how many are relevant?