Giter Site home page Giter Site logo

ezzaldin97 / tiny-semantic-caching Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 154 KB

using Ollama and Duckdb Vector Search Extension to build in Memory Semantic Caching Database

License: MIT License

Python 95.69% Dockerfile 4.31%
caching duckdb in-memory-caching llm ollama semantic-search

tiny-semantic-caching's Introduction

Tiny Semantic Caching

Description:

Semantic Caching is an In-Memory Database that support Semantic Search (Vector Search), it can be used in many different applications like RAG (Retrieval Augmented Generation), Database Assistant, and many more.. Designing a high performance applications that uses LLMs requires handling alot of issues like Time-Complexity, and avoidance of repeatable calls. Semantic Caching can help and save time and computational resources when designing applications like this. Tiny Semantic Caching is a project that uses Ollama and Vector Search in Duckdb to create complete semantic caching cycle.

Prerequisities:

  • Python (>=3.10)
  • Poetry
  • Ollama
  • Docker
  • Basic Understanding of Vector Indexing & Vector Search.

Project Setup:

  • Install all Prerequisities Softwares required for this project.
  • install requirements
poetry install
  • copy all containt of .env.example to .env file / rename .env.example to .env .
  • get an embedding model from Ollama like nomic-embed-text
ollama pull nomic-embed-text

make sure to update model name/embedding size in .env file if you used other embedding model.

  • to test the project locally
## use this directly
poetry run uvicorn main:app --reload

## or use this to activate the environment first
poetry shell
## then test the API
uvicorn main:app --reload

use the following URL to test the functionalities http:localhost:8000/docs

  • if no issues locally, use the docker-compose file to build the containers
### build the images
docker-compose build
## run the docker-compose file
docker-compose up -d

How it Works?

There are 4 different Functionalities:

  1. vectorize (GET): convert Passed Text to Vector Using the Embedding Model

  1. insertion (POST): insert data and its embeddings to caching database.

  2. search (POST): search for similar/identical text based on passed text. here text is vectorized then search in caching database, last thing it to insert it.

  1. refresh (DELETE): refreshing database to clear all records from it.

Usage:

  • feel free to update the scripts based on your needs and run the docker compose file.
  • use the direct image without any update by
## go to scripts directory
cd scripts
## run the docker compose file
docker-compose up -d

tiny-semantic-caching's People

Contributors

ezzaldin97 avatar

Stargazers

Beckett avatar Alexandru Rosianu avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.