Feat: Replace TF-IDF with NLP Semantic Search Embeddings (#1181)#1198
Merged
komalharshita merged 3 commits intoJul 19, 2026
Merged
Conversation
…ta#1181) - Added sentence-transformers to requirements.txt - Removed legacy TF-IDF keyword matching from utils/recommender.py - Implemented lazy-loaded all-MiniLM-L6-v2 model for semantic vector similarity - Added module-level and LRU caching for project and user query embeddings - Updated test_basic.py to match new function signature
|
Someone is attempting to deploy a commit to the komalsony234-1530's projects Team on Vercel. A member of the Team first needs to authorize it. |
komalharshita
requested changes
Jul 18, 2026
komalharshita
left a comment
Owner
There was a problem hiding this comment.
Thanks for the contribution! This is an interesting enhancement, but I think it needs a few changes before it can be merged.
- Please resolve the current merge conflicts with the latest
mainbranch. - Since this replaces the recommendation engine with sentence embeddings, please document the deployment impact (model download, startup time, memory usage, and any additional runtime requirements).
- Please include benchmark results or comparison examples showing how the new semantic search performs relative to the previous TF-IDF implementation.
- Clarify the fallback behavior if the NLP model fails to load. It should be clear whether recommendations continue to work or gracefully degrade.
- Consider adding tests for semantic matching and model initialization/failure scenarios to ensure the new behavior remains reliable.
Once these points are addressed, I'd be happy to review the PR again.
Author
|
@komalharshita done mam |
Owner
|
Thank you for your contribution to DevPath! Great work, and I'm happy to approve this PR. Keep contributing! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR resolves #1181 by completely replacing the legacy custom TF-IDF keyword-matching algorithm with a state-of-the-art NLP Semantic Search. By leveraging
sentence-transformersand the lightweightall-MiniLM-L6-v2model, the recommendation engine can now correctly pair synonymous and contextually related inputs (e.g., matching "Frontend" with "UI") that previously would have scored 0.Related Issue
Closes #1181
Type of Change
data/projects.jsonWhat Was Changed
requirements.txtsentence-transformers==3.0.1.src/utils/recommender.py_tf,_idf,_tfidf_vector,_cosine_similarity, and_tokenize. Integratedget_nlp_model()to lazily load theall-MiniLM-L6-v2model. Rewroteml_similarity_score()to compute continuous vector cosine similarity. Introduced LRU caching for user query encoding and dictionary caching for project encodings to prevent redundant processing.tests/test_basic.pytest_ml_similarity_score_returns_floatto match the newml_similarity_scoresignature since it no longer requires the fullall_projectspayload for IDF computation.How to Test This PR
git checkout feat/issue-1181-nlp-embeddingspip install -r requirements.txt. (Note: This will install PyTorch and download the model weights on the first execution).python src/app.py.Test Results
Self-Review Checklist
feat/,fix/,docs/,data/,style/,test/pytest tests/test_basic.pyand all tests passflake8 .locally and there are no errorsprint()orconsole.log()debug statements