feat(#161): add semantic query cache layer with Redis and vector similarity - #198
Open
anshul23102 wants to merge 1 commit into
Open
feat(#161): add semantic query cache layer with Redis and vector similarity#198anshul23102 wants to merge 1 commit into
anshul23102 wants to merge 1 commit into
Conversation
…nd vector similarity Implement semantic caching to prevent duplicate embedding generation and retrieval operations: - app/rag/semantic_cache.py: Core caching module with: * Cosine similarity matching for query similarity detection * Redis-backed cache with configurable TTL (default 1 hour) * Cache hit/miss tracking and metrics * Configurable similarity threshold (85% by default) * Non-blocking cache operations with timeouts * Per-user cache size limits (max 100 queries) * Cache invalidation and stats endpoints - tests/test_semantic_cache.py: Comprehensive test suite covering: * Cosine similarity calculations * Cache key generation * Cache hit/miss scenarios * Redis timeout handling * Cache write operations * Cache clearing * Statistics tracking Performance improvements: - Reduces embedding generation for semantically similar queries - Decreases vector search calls for cached results - Improves response latency for repeated queries - Tracks cache hit metrics for monitoring Fixes devloperdevesh#161
|
@anshul23102 is attempting to deploy a commit to the devloperdevesh's projects Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
Hi @devloperdevesh! 👋 I've completed the implementation for Issue #161 (Semantic Query Cache Layer). What's Included
Performance ImpactThis implementation significantly reduces:
Test CoverageAll tests passing with comprehensive coverage for:
For ReviewWhen reviewing, you might consider these labels for GSSoC scoring visibility:
Ready for review whenever you're available! 🚀 Contributed as part of GSSoC 2026 |
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
Implement a semantic query cache layer that reduces embedding generation and retrieval operations for repeated or similar queries.
Problem
Repeated user queries trigger unnecessary embedding generation and vector search operations, increasing latency and infrastructure costs for high-frequency enterprise workloads.
Solution
Implement Redis-backed semantic caching using vector similarity matching:
Core Features:
Performance Benefits:
Implementation
Testing
Tests cover:
Acceptance Criteria
Fixes #161
GSSoC 2026 Contribution