06 · Methodology
TF-IDF alone was never enough. The question was always how to represent meaning.
This project didn't start from a banking brief. It started from a 2021 undergraduate thesis that ran into the exact same problem: raw word counts don't capture what a sentence means.
2021 thesis: the LSA insight.
In my thesis, I was building a question classifier for a university chatbot using KNN. The first approach — KNN on raw TF-IDF vectors — had a structural problem. A sparse vector treats "lost card" and "card stolen" as completely unrelated: they share zero terms, so their distance is maximal even though they mean the same thing. KNN on sparse, high-dimensional vectors is both slow to compute and semantically blind.
LSA fixed this via SVD: decompose the TF-IDF matrix, keep the top-k singular values, and project every question into a lower-dimensional latent space. In that space, words that appear in similar contexts cluster together — "lost" and "stolen" both appear near "card" in the corpus, so they end up geometrically close. Accuracy improved from 92.1% to 93.2%, compute time dropped 35%. The lesson: co-occurrence implies meaning, and you need a dense space to exploit it.
2025: SBERT solves the same problem at a different scale.
SBERT (Sentence-BERT) does exactly what LSA did — but instead of decomposing a matrix built from 1,410 local questions, a transformer learns dense representations from pre-training on over a billion sentence pairs. The 384-dimensional output vector encodes meaning through attention weights, not co-occurrence statistics.
"Lost my card" and "card stolen" map to nearby points in the SBERT embedding space not because they appeared in the same documents in a small corpus, but because the model learned their shared semantic role across billions of examples. The classifier (LinearSVC) then operates in that already-meaningful space — and confidence in that space becomes a reliable routing signal.
|
LSA · 2021 thesis |
SBERT · this project |
| Semantic knowledge |
Co-occurrence in 1,410 questions |
Pre-trained on 1B+ sentence pairs |
| How meaning is found |
SVD on TF-IDF matrix (k = 661 dims) |
Transformer attention → 384-dim vector |
| Synonym handling |
Partial — only if both appear in corpus |
Yes — learned from pre-training |
| Downstream classifier |
KNN (Manhattan distance) |
LinearSVC + calibrated probabilities |
| Core mechanism |
Co-occurrence → matrix decomposition |
Context → attention → embedding |
"The insight was the same in 2021 and 2025: counting words isn't enough. You need to represent meaning. LSA used matrix algebra to find it in a small corpus. SBERT learned it from pre-training at scale."
— the thread connecting thesis to production
Full breakdown of the 2021 LSA implementation: NLP KNN LSA & Chatbot — thesis case study →