{"id":23858778,"url":"https://github.com/tthebc01/redis-ollama-rag","last_synced_at":"2026-05-02T17:39:02.418Z","repository":{"id":267376298,"uuid":"899343899","full_name":"TtheBC01/redis-ollama-RAG","owner":"TtheBC01","description":"Docker stack for using Redis as a vector store and job queue with Ollama for embeddings","archived":false,"fork":false,"pushed_at":"2024-12-11T21:49:58.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-22T10:38:48.332Z","etag":null,"topics":["docker-compose","fastapi","ollama","python-rq","redisvl"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TtheBC01.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-06T04:32:39.000Z","updated_at":"2024-12-12T03:58:36.000Z","dependencies_parsed_at":"2024-12-10T01:30:04.544Z","dependency_job_id":"4094f25a-f6ca-48e7-85bb-a891a4cbfbbb","html_url":"https://github.com/TtheBC01/redis-ollama-RAG","commit_stats":null,"previous_names":["tthebc01/redis-vector-db","tthebc01/redis-ollama-rag"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TtheBC01%2Fredis-ollama-RAG","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TtheBC01%2Fredis-ollama-RAG/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TtheBC01%2Fredis-ollama-RAG/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TtheBC01%2Fredis-ollama-RAG/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TtheBC01","download_url":"https://codeload.github.com/TtheBC01/redis-ollama-RAG/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240163511,"owners_count":19758023,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker-compose","fastapi","ollama","python-rq","redisvl"],"created_at":"2025-01-03T03:19:16.836Z","updated_at":"2026-05-02T17:39:02.390Z","avatar_url":"https://github.com/TtheBC01.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RedisVL + Ollama stack\n\nThis repo spins up a minimal docker stack that leverages [Redis](https://redis.io/) + [RedisVL](https://redis.io/docs/latest/integrate/redisvl/) as a vector database for calculating semantic similarity between \"documents\" (text strings) embedded via the [Ollama](https://ollama.com/) inference engine.\n\nThe stack defined in `docker-compose.yaml` creates an instance for Redis (for storing vector embeddings and jobs), Ollama (for creating embeddings), and [FastAPI](https://fastapi.tiangolo.com/) (as a simple \"business logic\" gateway) as well as an [RQ](https://python-rq.org/) worker service for embedding documents asynchronously. \n\n**NOTE** Using job queues can offload long-running, computationally intensive processes to other containers keeping server load to a minimum. Embedding jobs are processed in FIFO order so you are in less danger of DDOSing your RAG system by leveraging an asynchronous job queue architecture.\n\n## 1. Buid the FastAPI gateway\n\nFirst you'll need to build the FastAPI server application in the `/src` directory:\n\n```sh\ngit clone https://github.com/TtheBC01/redis-vector-db.git\ncd redis-vector-db\ndocker build -t vector-gateway ./src\n```\n\n## 2. Run the stack\n\nOnce you've successfully build the server application and tagged it as `vector-gateway`, bring the stack up:\n\n```sh\ndocker compose up -d\n```\n\nYou should have 4 services up: `fastapi`, `rq-worker`, `redis-server`, and `ollama-service`. If you visit `http://localhost:8000`, you should get \n\n```sh\n{\"message\":\"Redis vector demo is up!\"}\n```\n\n## 3. Pull an embedding model \n\nYou'll need to download an embedding model in order to build a queryable vector store. Run the following command to pull [Nomic's](https://www.nomic.ai/) open source embedding model:\n\n```sh\ncurl -X GET \"http://localhost:8000/load-model/?model=nomic-embed-text\"\n```\n\nThis model embeds text strings into a 768-dimensional vector field. There are other embedding models offered by Ollama too. Check the models you have cached by running:\n\n```sh\ncurl -X GET http://localhost:8000/available-models/\n```\n\n## 4. Embed some text\n\nTry embedding some text and storing it in your Redis instance like this:\n\n```sh\ncurl -X POST http://localhost:8000/embed/ -H \"Content-Type: application/json\" -d '{\"payload\": [\"Paris is the capital of France.\", \"The dog ran after the cat.\", \"Mark Twain was not his real name.\"]}'\n```\n\nYou can embed many many \"documents\" at once, but if your text blob is longer than the context size of your embedding model, any text over the limit will be ignored by the model. If this is your situation, you'll need to \"chunk\" you documents appropriately. For reference, the [`nomic-embed-text`](https://ollama.com/library/nomic-embed-text) model has a context size of 8192 tokens. \n\n```mermaid\nsequenceDiagram\n    User-\u003e\u003e+FastAPI: Document(s)\n    FastAPI-\u003e\u003e+RQ: Embedding Job\n    FastAPI-\u003e\u003e-User: Job ID\n    RQ-\u003e\u003e+Ollama: Embed w/ Parameters\n    Ollama-\u003e\u003e-RQ: Return Vectors\n    RQ-\u003e\u003e+RedisVL: Store Docs+Vectors(+tags)\n```\n\n## 5. Check similarity\n\nNow that your Redis instance has some vectors loaded, try to query it:\n\n```sh\ncurl -X GET http://localhost:8000/search/ -H \"Content-Type: application/json\" -d '{\"payload\": \"Where is Paris?\"}'\n```\n\nYou'll get the top 3 documents that match your query string in order of relevance as well as their vector distance (computed using cosine similarity).\n\n```mermaid\nsequenceDiagram\n    User-\u003e\u003e+FastAPI: User Query String\n    FastAPI-\u003e\u003e+Ollama: Embed query\n    Ollama-\u003e\u003e-FastAPI: Query vector\n    FastAPI-\u003e\u003e+RedisVL: Submit query vector with filters\n    RedisVL-\u003e\u003e-FastAPI: k nearest neighbor docs (cosine similarity)\n    FastAPI-\u003e\u003e-User: Top results related to query\n```\n\n## Speed up Embeddings with a GPU\n\nYou can greatly increase the speed of embeddings by mounting a local gpu to the Ollama service defined in the `docker-compose.yml` file. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftthebc01%2Fredis-ollama-rag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftthebc01%2Fredis-ollama-rag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftthebc01%2Fredis-ollama-rag/lists"}