semantic-cache  by upstash

Semantic cache for natural language tasks

created 1 year ago
281 stars

Top 93.7% on sourcepulse

GitHubView on GitHub
Project Summary

This project provides a semantic cache for natural language queries, ideal for applications involving AI responses or text classification. It enables caching based on meaning rather than exact string matches, improving efficiency and reducing latency for similar but not identical queries. The target audience includes developers working with LLMs, chatbots, and natural language processing tasks.

How It Works

The cache leverages semantic similarity by storing cache entries based on their meaning, using an underlying Upstash Vector database. When a query is made, it's converted into a vector embedding and compared against existing cache entries. A configurable proximity threshold determines if a cache hit occurs, allowing for flexible matching of synonyms and paraphrased queries. This approach allows for effective caching of natural language inputs that traditional lexical caches would miss.

Quick Start & Requirements

  • Install via npm: npm install @upstash/semantic-cache @upstash/vector
  • Requires an Upstash Vector database.
  • Needs Upstash Vector URL and Token credentials (set via .env file).
  • Supports Node.js applications.
  • Official docs: https://github.com/upstash/semantic-cache

Highlighted Details

  • Caches based on semantic similarity, not just exact matches.
  • Handles synonyms and multi-language queries (if embedding model supports it).
  • Customizable proximity threshold for cache hit sensitivity.
  • Supports namespacing for data partitioning.

Maintenance & Community

The project is maintained by Upstash. Further community or contribution details are not explicitly detailed in the README.

Licensing & Compatibility

  • MIT License.
  • Permissive license suitable for commercial use and integration into closed-source applications.

Limitations & Caveats

A 1-second delay is noted as necessary after setting data to allow the vector index to update, which might impact real-time cache population in certain scenarios. The effectiveness of multilingual support is dependent on the chosen embedding model.

Health Check
Last commit

8 months ago

Responsiveness

1 week

Pull Requests (30d)
0
Issues (30d)
0
Star History
8 stars in the last 90 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems).

super-rag by superagent-ai

0.3%
380
RAG pipeline for AI apps
created 1 year ago
updated 1 year ago
Feedback? Help us improve.