PGDCA, BCA, B-Tech, MCA, M-Tech, B.Sc computer science राजस्थान सूचना सहायक व कंप्यूटर शिक्षक विशेष नोट्स: इस अध्याय में हम Text Vectorization: Bag of Words (BoW) and TF-IDF Metrics (टेक्स्ट वेक्टरइजेशन: बैग ऑफ वर्ड्स (BoW) और TF-IDF की गणना) की संपूर्ण थ्योरी, मुख्य तकनीकी बिंदु, तुलनात्मक तालिका और विगत परीक्षाओं के पैटर्न पर आधारित 20 अति-महत्वपूर्ण बहुविकल्पीय प्रश्न (MCQs) विस्तृत हिंदी व अंग्रेजी व्याख्या सहित पढ़ेंगे।
Overview: Text vectorization converts variable-length text documents into fixed-dimensional numerical feature vectors suitable for machine learning algorithms. Bag of Words (BoW) counts token occurrences over a corpus vocabulary, while TF-IDF weights each term by its local frequency scaled by its inverse corpus rarity.
अध्याय सार: टेक्स्ट वेक्टरइजेशन परिवर्तनीय लंबाई वाले दस्तावेज़ों को मशीन लर्निंग एल्गोरिद्म के अनुकूल निश्चित-आयाम के संख्यात्मक वेक्टर में बदलता है। बैग ऑफ वर्ड्स (BoW) शब्दकोश में शब्दों की गिनती करता है, जबकि TF-IDF स्थानीय शब्द आवृत्ति को पूरे कॉर्पस में उस शब्द की दुर्लभता के व्युत्क्रमानुपाती भार से गुणा करता है।
Text Vectorization: Bag of Words (BoW) and TF-IDF Metrics: Detailed Notes & Architecture (टेक्स्ट वेक्टरइजेशन: बैग ऑफ वर्ड्स (BoW) और TF-IDF की गणना)
1. Bag of Words (BoW) Model and Vocabulary Sparsity (बैग ऑफ वर्ड्स (BoW) मॉडल और वोकैबुलरी स्पार्सिटी)
[EN] The Bag of Words model constructs an ordered global vocabulary V of all |V| unique terms across a corpus and represents every document as a |V|-dimensional vector of raw counts (CountVectorizer) or binary 0/1 flags. Because a single document uses only a tiny fraction of V (often 50-200 words out of 50,000), BoW creates huge, ultra-sparse document-term matrices stored efficiently in CSR (Compressed Sparse Row) format. Its central flaw is ignoring word order and syntax entirely: 'Dog bites man' and 'Man bites dog' produce the exact same unigram BoW vector. Adding N-grams (bigrams/trigrams) captures short local word order such as 'not good', at the cost of exploding vocabulary size.
[HI] बैग ऑफ वर्ड्स (BoW) मॉडल पूरे कॉर्पस के सभी |V| अद्वितीय शब्दों का एक शब्दकोश बनाता है और प्रत्येक दस्तावेज़ को शब्दों की आवृत्ति वाले |V|-आयामी वेक्टर में बदलता है। चूंकि एक दस्तावेज़ में कुल शब्दकोश के बहुत कम शब्द होते हैं, इसलिए BoW एक विशाल स्पार्स (अधिकांशतः शून्य) मैट्रिक्स बनाता है। इसकी प्रमुख कमी शब्दों के क्रम और व्याकरण को पूरी तरह अनदेखा करना है—'Dog bites man' और 'Man bites dog' का यूनिग्राम BoW वेक्टर बिल्कुल समान होगा। बाइग्राम या ट्राइग्राम (N-grams) जोड़ने से 'not good' जैसा स्थानीय क्रम पकड़ा जा सकता है, पर शब्दकोश का आकार बहुत बढ़ जाता है।
2. Term Frequency (TF) Normalization Variants (टर्म फ्रीक्वेंसी (TF) और लंबाई सामान्यीकरण)
[EN] Using raw word counts unfairly inflates feature magnitudes for long documents compared to short tweets containing the same topic. Relative Term Frequency normalizes by document length: TF(t, d) = count(t in d) / total_tokens(d), ensuring values sum to 1 per document. Alternative damping formulas include sublinear log-scaling (1 + log(count(t, d)) for count > 0) to dampen repeated keyword stuffing, and Boolean TF (1 if present else 0). Normalized TF keeps short and long articles on a comparable numerical scale.
[HI] कच्ची शब्द गणना (raw count) छोटे दस्तावेज़ों की तुलना में लंबे दस्तावेज़ों के वेक्टर मानों को अनुचित रूप से बढ़ा देती है। रिलेटिव टर्म फ्रीक्वेंसी इसे दस्तावेज़ की कुल शब्द संख्या से भाग देकर संतुलित करती है: TF(t, d) = count(t in d) / total_tokens(d)। कीवर्ड की अत्यधिक पुनरावृत्ति का प्रभाव कम करने के लिए सब-लीनियर लॉग स्केलिंग (1 + log(count)) या बाइनरी TF (0 या 1) का भी उपयोग किया जाता है। सामान्यीकृत TF छोटे और बड़े लेखों को समान तुलनात्मक पैमाने पर लाता है।
3. Inverse Document Frequency (IDF) and TF-IDF Calculation (इनवर्स डॉक्यूमेंट फ्रीक्वेंसी (IDF) और TF-IDF गणना)
[EN] Term Frequency alone still over-values common words like 'report', 'system', or 'data' if they appear repeatedly in every document. Inverse Document Frequency measures how rare and informative term t is across N total documents: standard IDF(t) = log(N / df_t), where df_t is the count of documents containing t at least once. If t appears in every document (df_t = N), then IDF(t) = log(1) = 0, automatically zeroing non-discriminative filler words; to avoid division by zero or complete zeroing, scikit-learn uses smoothed IDF = ln((1 + N) / (1 + df_t)) + 1. Multiplying TF-IDF(t, d) = TF(t, d) * IDF(t) yields high weights ONLY for words frequent inside document d yet rare across the rest of the corpus.
[HI] केवल TF से उन शब्दों को भी अधिक महत्व मिल जाता है जो लगभग हर दस्तावेज़ में बार-बार आते हैं (जैसे 'system' या 'report')। इनवर्स डॉक्यूमेंट फ्रीक्वेंसी पूरे N दस्तावेज़ों में शब्द की दुर्लभता मापती है: IDF(t) = log(N / df_t), जहाँ df_t उन दस्तावेज़ों की संख्या है जिनमें t मौजूद है। यदि कोई शब्द सभी दस्तावेज़ों में आता है (df_t = N), तो IDF = log(1) = 0 होकर उसका भार शून्य कर देता है; शून्य विभाजन से बचने हेतु scikit-learn स्मूथ्ड सूत्र ln((1+N)/(1+df_t)) + 1 अपनाता है। अंततः TF-IDF = TF * IDF केवल उन्हीं शब्दों को उच्च स्कोर देता है जो किसी विशेष दस्तावेज़ में अधिक पर पूरे कॉर्पस में दुर्लभ हैं।
4. Cosine Similarity and Limits vs Dense Neural Embeddings (कोसाइन समानता और डेंस एम्बेडिंग्स की तुलना में सीमाएं)
[EN] Because BoW and TF-IDF vectors occupy very high-dimensional sparse spaces where Euclidean distance grows misleadingly with vector length/zero count, document similarity relies on Cosine Similarity: cos(theta) = (A dot B) / (||A|| * ||B||). Since TF-IDF weights are non-negative, Cosine Similarity lies in [0, 1] (0 = orthogonal/no shared terms, 1 = identical term direction), remaining completely invariant to document length. However, statistical count models suffer semantic blindness: synonyms like 'car' and 'automobile' sit along orthogonal axes with zero cosine overlap, and polysemous words like 'bank' merge unrelated senses. Dense semantic embeddings (Word2Vec, GloVe, BERT) overcome this by encoding meaning into compact 100- to 768-dimensional vectors.
[HI] BoW और TF-IDF के उच्च-आयामी स्पार्स वेक्टर पर यूक्लिडियन दूरी दस्तावेज़ की लंबाई से भ्रमित हो सकती है, इसलिए समानता मापने हेतु कोसाइन समानता cos(theta) = (A dot B)/(||A||*||B||) प्रयुक्त होती है। गैर-ऋणात्मक मानों के कारण इसका मान [0, 1] के बीच रहता है और यह दस्तावेज़ की लंबाई से स्वतंत्र होती है। परंतु इन सांख्यिकीय मॉडलों में शब्दार्थ की समझ नहीं होती—'car' और 'automobile' जैसे पर्यायवाची शब्दों के बीच शून्य समानता दिखती है। इसी सीमा को दूर करने के लिए Word2Vec, GloVe और BERT जैसे डेंस सिमैंटिक एम्बेडिंग्स विकसित किए गए।
Syntax, Formula & Technical Example (Text Vectorization: Bag of Words (BoW) and TF-IDF Metrics)
# Pure Python TF-IDF Calculation Across 3 Documents
import math
docs = [['ai', 'learns', 'data'], ['ai', 'uses', 'math'], ['data', 'science', 'ai']]
N = len(docs) # N = 3
vocab = sorted({w for d in docs for w in d})
df = {w: sum(1 for d in docs if w in d) for w in vocab}
# df['ai']=3 -> idf=log(3/3)=0.0; df['math']=1 -> idf=log(3/1)=1.0986
idf = {w: round(math.log(N / df[w]), 4) for w in vocab}
tf_doc1 = {w: round(docs[1].count(w)/len(docs[1]), 4) for w in vocab}
tfidf_doc1 = {w: round(tf_doc1[w] * idf[w], 4) for w in docs[1]}
# tfidf_doc1 -> {'ai': 0.0, 'uses': 0.3662, 'math': 0.3662}
Text Vectorization: Bag of Words (BoW) and TF-IDF Metrics Quick Reference & Comparison Table
| Vectorization Concept | Formula / Mechanism | Key Exam Fact |
|---|---|---|
| Bag of Words (BoW) | Sparse vector of word counts over vocabulary V | Completely ignores word order & grammar |
| Term Frequency (TF) | count(t, d) / total_terms(d) | Normalizes counts for document length |
| Inverse Doc Frequency (IDF) | log(N / df_t) across N documents | Drops to 0 when term appears in all docs |
| Cosine Similarity | dot(A, B) / (||A|| * ||B||) | Length-invariant metric in [0, 1] for TF-IDF |
Text Vectorization: Bag of Words (BoW) and TF-IDF Metrics Top 20 Bilingual MCQs with Answers
Q1. Why do the sentences 'Python beats Java' and 'Java beats Python' produce identical unigram Bag of Words vectors?
('Python beats Java' और 'Java beats Python' वाक्यों का यूनिग्राम बैग ऑफ वर्ड्स (BoW) वेक्टर बिल्कुल एक जैसा क्यों बनता है?)
(A) BoW keeps only the last word of each document
(B) BoW hashes every sentence to a single scalar
(C) Unigram BoW only tracks token counts and discards word order and syntactic position
(D) BoW converts both 'Python' and 'Java' into stopwords
Correct Answer: (C)
[EN] Standard BoW treats a document as an unordered multiset ('bag') of words, losing word sequence.
[HI] मानक BoW दस्तावेज़ को शब्दों के एक क्रम-रहित समूह (bag) के रूप में गिनता है और शब्द-क्रम को छोड़ देता है।
Q2. In a corpus of N = 1,000 documents, if the word 'computer' appears in all 1,000 documents, what is its standard unsmoothed IDF = log10(N / df)?
(N = 1,000 दस्तावेज़ों के कॉर्पस में यदि शब्द 'computer' सभी 1,000 दस्तावेज़ों में आता है, तो इसका मानक अनस्मूथ्ड IDF = log10(N / df) क्या होगा?)
(A) 3.0
(B) 1.0
(C) 1000.0
(D) 0.0
Correct Answer: (D)
[EN] IDF = log10(1000 / 1000) = log10(1) = 0.0, indicating the term provides zero cross-document discrimination.
[HI] IDF = log10(1000 / 1000) = log10(1) = 0.0 होता है, अर्थात् यह शब्द दस्तावेज़ों में अंतर करने में उपयोगी नहीं है।
Q3. Calculate TF-IDF (using log base 10) for term 'neural' appearing 3 times in a 15-word document, given N = 500 total documents and df('neural') = 5.
(15 शब्दों के दस्तावेज़ में 'neural' 3 बार आता है; कुल N = 500 दस्तावेज़ों में से df = 5 होने पर (log आधार 10 के साथ) TF-IDF मान क्या होगा?)
(A) 0.20
(B) 0.40
(C) 0.60
(D) 2.00
Correct Answer: (B)
[EN] TF = 3 / 15 = 0.2; IDF = log10(500 / 5) = log10(100) = 2.0; TF-IDF = 0.2 * 2.0 = 0.40.
[HI] TF = 3/15 = 0.2; IDF = log10(500/5) = log10(100) = 2.0; अतः TF-IDF = 0.2 * 2.0 = 0.40.
Q4. Which word receives the HIGHEST TF-IDF score in a specific document d?
(किसी विशेष दस्तावेज़ d में किस प्रकार के शब्द को सर्वाधिक TF-IDF स्कोर प्राप्त होता है?)
(A) A stopword occurring once in every single document
(B) A word absent from document d completely
(C) A typo appearing 100 times in every document
(D) A word that occurs frequently inside document d but rarely across the other documents in the corpus
Correct Answer: (D)
[EN] High local TF multiplied by high global IDF highlights characteristic keywords unique to that document.
[HI] स्थानीय रूप से अधिक बार (उच्च TF) लेकिन बाकी कॉर्पस में दुर्लभ (उच्च IDF) आने वाले शब्द को सर्वाधिक स्कोर मिलता है।
Q5. What is the dimension (length) of every document vector produced by a Bag of Words CountVectorizer on a corpus with 12,500 unique tokens?
(12,500 अद्वितीय टोकनों वाले कॉर्पस पर बैग ऑफ वर्ड्स CountVectorizer द्वारा बनाए गए प्रत्येक दस्तावेज़ वेक्टर का आयाम क्या होगा?)
(A) 12,500
(B) Number of documents N in the corpus
(C) Number of words in that single document
(D) log2(12,500)
Correct Answer: (A)
[EN] Each index corresponds to one unique vocabulary entry, so every vector has fixed length |V| = 12,500.
[HI] वेक्टर का प्रत्येक स्थान शब्दकोश के एक अद्वितीय शब्द को दर्शाता है, इसलिए प्रत्येक वेक्टर का आकार |V| = 12,500 होगा।
Q6. Why does scikit-learn's TfidfVectorizer apply smoothed IDF formula ln((1 + N) / (1 + df)) + 1 by default?
(scikit-learn का TfidfVectorizer डिफ़ॉल्ट रूप से स्मूथ्ड IDF सूत्र ln((1 + N) / (1 + df)) + 1 क्यों उपयोग करता है?)
(A) To replace Cosine Similarity with Manhattan distance
(B) To reduce vocabulary size to 10 words
(C) To avoid zero division and prevent words appearing in all documents (df = N) from being completely multiplied by zero
(D) To force negative weights on every keyword
Correct Answer: (C)
[EN] Adding 1 inside and outside the log prevents division by zero and guarantees minimum IDF = 1 instead of wiping out frequent terms completely.
[HI] लॉग में 1 जोड़ने से शून्य विभाजन टलता है और df = N होने पर भी IDF 0 के बजाय 1 रहता है जिससे शब्द पूरी तरह गायब नहीं होता।
Q7. How can Bag of Words partially preserve local word phrases like 'artificial intelligence' or 'not bad'?
(बैग ऑफ वर्ड्स 'artificial intelligence' या 'not bad' जैसे स्थानीय शब्द-समूहों के क्रम को आंशिक रूप से कैसे सुरक्षित रख सकता है?)
(A) By removing all nouns during preprocessing
(B) By including Bigrams or Trigrams (ngram_range=(1, 2)) in the vocabulary
(C) By switching from TF to binary presence
(D) By sorting all words alphabetically inside each document
Correct Answer: (B)
[EN] Extracting consecutive n-grams treats 'not_bad' as a distinct token feature alongside single unigrams.
[HI] बाइग्राम या ट्राइग्राम (N-grams) जोड़ने से 'not bad' एक साथ एक अलग फीचर के रूप में दर्ज हो जाता है।
Q8. What is the valid range of Cosine Similarity between any two non-zero TF-IDF document vectors?
(किन्हीं दो गैर-शून्य TF-IDF दस्तावेज़ वेक्टरों के बीच कोसाइन समानता का वैध रेंज क्या होता है?)
(A) (-infinity, 0]
(B) [-1, +1]
(C) [0, infinity)
(D) [0, 1]
Correct Answer: (D)
[EN] Because TF and IDF weights in standard document vectors are >= 0, vectors lie in the first orthant, keeping cos(theta) in [0, 1].
[HI] चूंकि TF और IDF दोनों गैर-ऋणात्मक (>= 0) होते हैं, इसलिए दो वेक्टरों के बीच कोसाइन समानता [0, 1] के बीच रहती है।
Q9. Why is Cosine Similarity preferred over Euclidean Distance when comparing TF-IDF vectors of short tweets vs long research papers?
(छोटे ट्वीट्स और लंबे शोध-पत्रों के TF-IDF वेक्टरों की तुलना में यूक्लिडियन दूरी की तुलना में कोसाइन समानता को प्राथमिकता क्यों दी जाती है?)
(A) Euclidean distance is undefined for sparse vectors
(B) Euclidean distance runs slower than O(N^3)
(C) Cosine similarity always ignores shared keywords
(D) Cosine Similarity measures the angle (topic direction) regardless of vector magnitude/document length
Correct Answer: (D)
[EN] Two documents on the same topic of vastly different lengths share a small angle (high cosine) despite huge Euclidean norm differences.
[HI] कोसाइन समानता लंबाई/परिमाण के बजाय दो वेक्टरों के बीच के कोण (विषय की दिशा) को मापती है, अतः यह दस्तावेज़ के आकार से अप्रभावित रहती है।
Q10. Compute the Cosine Similarity between document vector A = [3, 4, 0] and B = [0, 0, 5]:
(दस्तावेज़ वेक्टर A = [3, 4, 0] और B = [0, 0, 5] के बीच कोसाइन समानता की गणना करें:)
(A) 0.5
(B) 1.0
(C) 0.0
(D) 0.8
Correct Answer: (C)
[EN] Dot product A.B = 3*0 + 4*0 + 0*5 = 0, so cos(theta) = 0 / (5 * 5) = 0.0 (completely disjoint vocabularies).
[HI] डॉट प्रोडक्ट A.B = 0 होने के कारण कोसाइन समानता = 0.0 है (कोई भी साझा शब्द नहीं है)।
Q11. What major semantic limitation affects both Bag of Words and TF-IDF representations?
(बैग ऑफ वर्ड्स और TF-IDF दोनों निरूपणों को कौन-सी प्रमुख अर्थगत (semantic) सीमा प्रभावित करती है?)
(A) They require labeled GPUs for training
(B) They enforce strict left-to-right syntactic parsing
(C) They cannot represent integer counts
(D) Synonymy and polysemy are ignored ('car' and 'automobile' have zero similarity despite identical meaning)
Correct Answer: (D)
[EN] Distinct tokens occupy orthogonal basis dimensions, so BoW/TF-IDF cannot recognize semantic relatedness between synonyms.
[HI] प्रत्येक शब्द एक अलग अक्ष पर होने के कारण BoW/TF-IDF 'car' और 'automobile' जैसे पर्यायवाची शब्दों के बीच समानता नहीं पहचान पाते।
Q12. What does Zipf's Law imply for Bag of Words vocabularies in large natural language corpora?
(बड़े प्राकृतिक भाषा कॉर्पस में बैग ऑफ वर्ड्स शब्दकोश के लिए ज़िप का नियम (Zipf's Law) क्या दर्शाता है?)
(A) Every word in English appears the exact same number of times
(B) Stopwords never appear more than once
(C) A small set of words occurs very frequently while a huge long tail of rare words occurs once or twice, creating high sparsity
(D) Vocabulary size stays constant at 100 words regardless of corpus size
Correct Answer: (C)
[EN] Zipf's power-law distribution produces massive long-tail vocabularies, typically pruned with min_df or max_features.
[HI] ज़िप के नियम के अनुसार कुछ शब्द बहुत बार आते हैं जबकि अधिकांश शब्द विरले ही आते हैं, जिससे अत्यधिक स्पार्सिटी बढ़ती है।
Q13. How do dense Word Embeddings (like Word2Vec or BERT) fundamentally differ from TF-IDF vectors?
(Word2Vec या BERT जैसे डेंस वर्ड एम्बेडिंग्स TF-IDF वेक्टरों से मौलिक रूप से कैसे भिन्न हैं?)
(A) Embeddings store only binary 0/1 flags
(B) Embeddings encode distributed semantic similarity into low-dimensional dense vectors (e.g., 300d) instead of sparse |V|-dim counts
(C) Embeddings discard semantic relationships between synonyms
(D) Embeddings use higher dimensions (> 1 million) than BoW
Correct Answer: (B)
[EN] Dense vectors place semantically similar words ('king', 'queen') close together in continuous latent space.
[HI] डेंस एम्बेडिंग्स स्पार्स गिनती के बजाय कम आयाम (जैसे 300d) वाले सतत वेक्टरों में शब्दों के अर्थ और समानता को संजोते हैं।
Q14. In scikit-learn, what parameter in TfidfVectorizer or CountVectorizer drops rare typos appearing in fewer than 3 documents?
(scikit-learn में TfidfVectorizer या CountVectorizer का कौन-सा पैरामीटर 3 से कम दस्तावेज़ों में आने वाली दुर्लभ वर्तनी त्रुटियों को हटाता है?)
(A) min_df=3
(B) max_df=0.1
(C) ngram_range=(3, 3)
(D) norm='l1'
Correct Answer: (A)
[EN] Setting min_df=3 ignores terms whose document frequency is strictly below 3 documents.
[HI] min_df=3 सेट करने पर वे शब्द बाहर हो जाते हैं जो 3 से कम दस्तावेज़ों में आते हैं।
Q15. In the Python TF-IDF trace over 3 documents, why did 'ai' receive a TF-IDF score of 0.0 in doc1?
(3 दस्तावेज़ों वाले पायथन TF-IDF कोड में doc1 में शब्द 'ai' का TF-IDF स्कोर 0.0 क्यों आया?)
(A) Because 'ai' appeared in all 3 documents (df=3), making idf = log(3/3) = 0.0
(B) Because Python rounded 100 down to 0
(C) Because 'ai' did not appear in doc1
(D) Because 'ai' had negative term frequency
Correct Answer: (A)
[EN] A word present in every single document has zero distinguishing power under unsmoothed log(N/df).
[HI] तीनों दस्तावेज़ों में मौजूद होने से df=3 और idf = log(3/3) = 0.0 हो गया, जिससे TF-IDF शून्य मिला।
Q16. Which statement is NOT true about Bag of Words and TF-IDF?
(बैग ऑफ वर्ड्स और TF-IDF के संबंध में निम्न में से कौन-सा कथन सत्य नहीं है?)
(A) Adding N-grams increases the feature vocabulary size
(B) BoW matrices are typically stored in sparse matrix format to save RAM
(C) TF-IDF natively captures long-range semantic coreference and synonym similarity across sentences
(D) TF-IDF combines local term importance with global document rarity
Correct Answer: (C)
[EN] TF-IDF treats distinct surface words as independent features and has no native awareness of synonyms or coreference.
[HI] TF-IDF अलग-अलग शब्दों को स्वतंत्र मानता है; इसमें पर्यायवाची शब्दों या वाक्यों के बीच गहरे संदर्भ की समझ नहीं होती।
Q17. Within Text Vectorization: Bag of Words (BoW) and TF-IDF Metrics, which vectorization concept directly maps to: "Sparse vector of word counts over vocabulary V"?
(Text Vectorization: Bag of Words (BoW) and TF-IDF Metrics में कौन सा Vectorization Concept सीधे "Sparse vector of word counts over vocabulary V" से संबंधित है?)
(A) Cosine Similarity
(B) Inverse Doc Frequency (IDF)
(C) Bag of Words (BoW)
(D) Term Frequency (TF)
Correct Answer: (C)
[EN] In Text Vectorization: Bag of Words (BoW) and TF-IDF Metrics, 'Bag of Words (BoW)' handles 'Sparse vector of word counts over vocabulary V' (Completely ignores word order & grammar).
[HI] Text Vectorization: Bag of Words (BoW) and TF-IDF Metrics में 'Bag of Words (BoW)' का कार्य/विवरण 'Sparse vector of word counts over vocabulary V' (Completely ignores word order & grammar) है।
Q18. Which option accurately describes 'Term Frequency (TF)' in Text Vectorization: Bag of Words (BoW) and TF-IDF Metrics?
(Text Vectorization: Bag of Words (BoW) and TF-IDF Metrics के संदर्भ में 'Term Frequency (TF)' की सही विशेषता कौन सी है?)
(A) Sparse vector of word counts over vocabulary V
(B) log(N / df_t) across N documents
(C) count(t, d) / total_terms(d)
(D) dot(A, B) / (||A|| * ||B||)
Correct Answer: (C)
[EN] 'Term Frequency (TF)' provides 'count(t, d) / total_terms(d)' — key point: Normalizes counts for document length.
[HI] 'Term Frequency (TF)' का मुख्य विवरण 'count(t, d) / total_terms(d)' है (Normalizes counts for document length)।
Q19. In Text Vectorization: Bag of Words (BoW) and TF-IDF Metrics, identify the correct parameter for the specification: "log(N / df_t) across N documents".
(Text Vectorization: Bag of Words (BoW) and TF-IDF Metrics में "log(N / df_t) across N documents" विवरण किस विकल्प के लिए सही है?)
(A) Inverse Doc Frequency (IDF)
(B) Cosine Similarity
(C) Term Frequency (TF)
(D) Bag of Words (BoW)
Correct Answer: (A)
[EN] 'Inverse Doc Frequency (IDF)' corresponds to 'log(N / df_t) across N documents' (Drops to 0 when term appears in all docs).
[HI] 'Inverse Doc Frequency (IDF)' का संबंध 'log(N / df_t) across N documents' (Drops to 0 when term appears in all docs) से है।
Q20. Considering Text Vectorization: Bag of Words (BoW) and TF-IDF Metrics, what key behavior defines 'Cosine Similarity'?
(Text Vectorization: Bag of Words (BoW) and TF-IDF Metrics में 'Cosine Similarity' की मुख्य भूमिका या मान क्या है?)
(A) Sparse vector of word counts over vocabulary V
(B) count(t, d) / total_terms(d)
(C) log(N / df_t) across N documents
(D) dot(A, B) / (||A|| * ||B||)
Correct Answer: (D)
[EN] 'Cosine Similarity' represents 'dot(A, B) / (||A|| * ||B||)' (Length-invariant metric in [0, 1] for TF-IDF).
[HI] 'Cosine Similarity' का अर्थ/मान 'dot(A, B) / (||A|| * ||B||)' है (Length-invariant metric in [0, 1] for TF-IDF)।
Text Vectorization: Bag of Words (BoW) and TF-IDF Metrics — Exam FAQs
Q1: Why does TF-IDF work better than raw Bag of Words for Search Engines and Text Classification?
सर्च इंजन और टेक्स्ट वर्गीकरण में कच्चे बैग ऑफ वर्ड्स की तुलना में TF-IDF बेहतर क्यों काम करता है?
[EN] Raw BoW gives huge weights to frequent filler terms and favors long documents, whereas TF-IDF normalizes document length and suppresses ubiquitous words across the corpus while boosting rare topic-specific keywords.
[HI] कच्चा BoW सामान्य शब्दों व लंबे दस्तावेज़ों को अनुचित भार देता है, जबकि TF-IDF लंबाई को संतुलित कर आम शब्दों का भार घटाता है और विषय-विशेष कीवर्ड्स को उभारता है।
Q2: What happens to TF-IDF vector size as the training corpus grows, and how is it controlled?
प्रशिक्षण कॉर्पस बढ़ने पर TF-IDF वेक्टर के आकार पर क्या प्रभाव पड़ता है और इसे कैसे नियंत्रित किया जाता है?
[EN] The vocabulary size |V| grows rapidly with corpus size; practitioners cap it using stopword filtering, lemmatization, min_df (dropping rare typos), max_df (dropping near-universal terms), max_features, or hashing vectorizers.
[HI] कॉर्पस बढ़ने पर वोकैबुलरी आकार |V| तेज़ी से बढ़ता है; इसे स्टॉपवर्ड हटाने, min_df, max_df, max_features या हैशिंग वेक्टरइज़र से नियंत्रित किया जाता है।
Q3: When should someone still use TF-IDF instead of a large Transformer model?
बड़े ट्रांसफॉर्मर मॉडल के बजाय आज भी TF-IDF का उपयोग कब करना चाहिए?
[EN] TF-IDF paired with Logistic Regression or Linear SVM is ideal for low-latency CPU inference, limited labeled datasets, full interpretability of keyword weights, and hybrid sparse+dense retrieval (BM25 + embeddings) in RAG.
[HI] कम लेटेंसी वाले CPU सिस्टम, छोटे डेटासेट, स्पष्ट कीवर्ड व्याख्या और RAG सिस्टम में हाइब्रिड सर्च (BM25 + एम्बेडिंग्स) के लिए TF-IDF आज भी अत्यंत उपयोगी है।
Post a Comment
Post a Comment