Semantic Cache Query Matching With Per-Query Distance Thresholds
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Fuzzy matching in semantic caches for question answering systems using generative AI models leads to incorrect responses and cache misses due to the rigidity and arbitrariness of similarity threshold choices, which are not optimized for precision and recall.
Innovation Solution
Generate a distance-dependent F1-optimized similarity threshold based on semantically preserving synthetic variations of queries, using embeddings and training separate thresholds for each query in a semantic cache to improve accuracy.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If a fixed similarity threshold is used for fuzzy matching in semantic cache, then the system can operate with simple structure and fast processing, but it leads to incorrect responses and cache misses due to rigidity and arbitrariness of threshold choice
Solution Approach 1:
The patent transforms the static, fixed similarity threshold into a dynamic, adaptive threshold that automatically adjusts based on the specific query and cache contents. The system computes an optimal threshold for each query using training data and performance metrics (precision, recall, F1 score), making the threshold flexible rather than rigid. This resolves the contradiction by maintaining fast processing (inheriting from simple structure) while improving accuracy through adaptive threshold selection.
Solution Approach 2:
The patent changes the parameter of the similarity threshold from a fixed constant to a variable that can take different values based on query characteristics and performance optimization. By computing customized thresholds for different queries based on training data analysis, the system optimizes the threshold parameter dynamically, thereby improving cache matching accuracy without sacrificing processing speed.
2Productivity
If a lower similarity threshold is used to increase cache hit rate, then more queries can be served from cache, but it increases the risk of incorrect responses due to overly permissive matching
Solution Approach 1:
The patent optimizes the similarity threshold parameter based on performance metrics including precision and recall. By analyzing training data and computing the F1 score for different threshold values, the system selects thresholds that balance cache hit rate with matching precision. This prevents both overly strict thresholds (low hit rate) and overly permissive thresholds (high false positives), achieving an optimal balance point.
Solution Approach 2:
The patent implements a feedback mechanism where the system evaluates cache matching performance using precision, recall, and F1 score metrics on training data. This feedback is used to iteratively optimize and select the best threshold value, ensuring that the threshold achieves the desired balance between cache hit rate and response accuracy. The feedback loop continuously refines the threshold based on actual performance.
3Reliability
If a higher similarity threshold is used to ensure response accuracy, then fewer incorrect responses occur, but it increases cache misses and requires more API calls to LLM
Solution Approach 1:
The patent dynamically adjusts the similarity threshold parameter to optimize the balance between precision and cache hit rate. Rather than using a uniformly high threshold that would cause excessive cache misses, the system computes customized thresholds for different queries based on training data analysis. This allows the system to maintain high precision where needed while being more permissive in cases where cache hits are more likely, thereby maximizing overall cache effectiveness.
Solution Approach 2:
The patent applies different similarity threshold values to different queries based on their specific characteristics and the distribution of distances in the training data. Instead of using a single global threshold, the system tailors the threshold locally for each query context, optimizing the precision-hit rate tradeoff for each individual case. This local optimization approach maximizes overall system performance.
4Reliability
If custom distance thresholds are computed for each query using training data and F1 optimization, then cache matching accuracy is improved, but the system complexity and computation time increase
Solution Approach 1:
The patent performs threshold optimization in advance during a training phase, where the system pre-computes optimal thresholds based on historical query data and performance metrics. This preliminary action creates a ready-to-use threshold configuration that can be applied during actual query processing without requiring complex real-time computations. The heavy computational work is done beforehand, simplifying the online system while maintaining high accuracy.
Data Source
AI summary
A method, computer program product, and computing system for processing a dataset of query-answer pairs. Synthetic variations of queries are generated and each of the synthetic variations of queries are mapped to a corresponding answer from the dataset. An embedding dataset is generated by transforming the synthetic variations into synthetic query embeddings and the queries into query embeddings. A first set of embeddings is defined for storage in a semantic cache and a second set of embeddings are defined and are not stored in the semantic cache. A separate distance threshold is assigned to each embedding of the first set of embeddings and a pairwise distance between each query and the synthetic variations is determined. Distance thresholds for respective pairwise distances between a query and synthetic variations of the query are generated. Subsequent queries are processed using the semantic cache and the distance thresholds.


