S
Supanote
Sign in Sign up

Redis 8.0 Native Vector Sets (VADD & VSIM with Q8 Quantization)

plain (bash) 1 day ago · 32 lines · 2 views
Verified Blueprint Redis 8.0+

Run sub-millisecond similarity search in Redis 8.0 using built-in Vector Sets (VADD, VSIM), 8-bit Q8 quantization, and FILTER expressions.

  • ✓ Uses Redis 8 native Vector Set data type (designed by antirez) with zero upfront index DDL required
  • ✓ Applies default 8-bit signed integer quantization (Q8) to shrink RAM usage by ~75% with minimal recall loss
  • ✓ Combines HNSW vector similarity with inline JSON metadata FILTER predicates in a single VSIM call
Quick Fetch
1#!/usr/bin/env bash
2# Redis 8.0+ Built-In Vector Sets (VADD / VSIM / VSETATTR) Semantic Search Blueprint
3# Requires Redis 8.0+ open-source unified binary (no external module configuration needed)
4
5set -euo pipefail
6REDIS_CLI="${REDIS_CLI:-redis-cli}"
7
8# 1. Insert Embeddings With Q8 Quantization & JSON Attributes (Auto-creates HNSW Vector Set)
9# Syntax: VADD <key> VALUES <dim> <f1> <f2> ... <element_id> [Q8 | BIN | NOQUANT] [SETATTR <json>]
10${REDIS_CLI} VADD kb:chunks VALUES 4 0.14 -0.52 0.88 0.11 "doc:pg18-aio" Q8 \
11 SETATTR '{"engine":"postgresql","version":18,"tier":"public"}'
13${REDIS_CLI} VADD kb:chunks VALUES 4 0.16 -0.49 0.85 0.08 "doc:pg18-uuidv7" Q8 \
14 SETATTR '{"engine":"postgresql","version":18,"tier":"public"}'
16${REDIS_CLI} VADD kb:chunks VALUES 4 -0.61 0.72 0.12 -0.30 "doc:redis8-io" Q8 \
17 SETATTR '{"engine":"redis","version":8,"tier":"internal"}'
19# 2. Filtered Similarity Search (Hybrid ANN + Arithmetic/Boolean Attribute Filter)
20echo "--- Top Public PostgreSQL Matches ---"
21${REDIS_CLI} VSIM kb:chunks VALUES 4 0.15 -0.50 0.87 0.10 \
22 WITHSCORES COUNT 5 \
23 FILTER '.engine == "postgresql" and .tier == "public" and .version >= 18'
25# 3. Search Using an Existing Element's Vector ("More Like This" Item-to-Item Recommendation)
26echo "--- Similar to doc:pg18-aio ---"
27${REDIS_CLI} VSIM kb:chunks ELE "doc:pg18-aio" WITHSCORES COUNT 3
29# 4. Inspect Vector Set Cardinality, Quantization Mode & HNSW Graph Metadata
30${REDIS_CLI} VINFO kb:chunks
31${REDIS_CLI} VGETATTR kb:chunks "doc:pg18-aio"

No replies yet

Every reply is a note. Start a discussion, ask a question, or attach a code snippet.

Related Redis 8.0+ & Database, Cache & SQL Blueprints

Production-ready configurations and diagnostics from the verified Supanote library.

All Database, Cache & SQL →
Interactive Developer Workbench: Online JSON Formatter, Validator & Viewer

Validate, pretty-print, minify, and inspect JSON API responses with exact syntax error pinpointing.

Open JSON Formatter →

Share Note

Open
Download SVG
Social Card Preview
Open on mobile
Point your phone camera to open this note directly

Report this note

Notification