惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
Y
Y Combinator Blog
M
MIT News - Artificial intelligence
The Cloudflare Blog
WordPress大学
WordPress大学
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 司徒正美
小众软件
小众软件
Blog — PlanetScale
Blog — PlanetScale
雷峰网
雷峰网
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
J
Java Code Geeks
云风的 BLOG
云风的 BLOG
C
Check Point Blog
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
V
V2EX
F
Fortinet All Blogs
B
Blog
大猫的无限游戏
大猫的无限游戏
N
Netflix TechBlog - Medium
B
Blog RSS Feed
A
About on SuperTechFans
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

Redis

Real-Time Fraud Detection: Latency, Features & Scale Context window in AI: why every token is a budget decision Connecting to Redis Cloud with AWS PrivateLink vs. VPC peering | Redis Redis Data Integration in Redis Cloud is now GA in AWS | Redis Why AI Misses Business Context & How Teams Fix It AI Reasoning Explained: Why Context Matters Semantic Layer vs Context Layer: Key Differences Redis array data type: How it works and when to use it Context Graphs vs. Vector Search: When RAG Falls Short What’s new in two – May 2026 edition Redis 8.8 performance improvements: Faster string, hash, streams, SCAN & more Redis 8.8: New array data structure & open source features How Conflict-free Replicated Data Types power active-active database replication Context Orchestration: What It Is & How It Works Context Compaction for AI Agents: A Complete Guide Prompt Bloat: Causes, Costs & Fixes for LLM Apps Agentic Retrieval Techniques: A Complete Guide Single-shot reliable consumers with XREADGROUP CLAIM in Redis 8.4 | Redis Long-Horizon AI Agents: Memory & State Infrastructure What is a context engine? What Is a Context Layer? AI Agent Infrastructure Context Retrieval for AI Agents: What It Is & Why It Matters Context Poisoning: How Bad Data Breaks Agent Reasoning Context is all you need: Introducing Redis Iris | Redis Context Engineering for AI: What It Is & How to Build It Dynamic endpoints: Migrate databases without changing your endpoint | Redis AI Shopping Assistants: How They Work & What to Build Endless Aisle Retail: Infrastructure & Real-Time Data LLM Speed Benchmarks: Metrics & Infrastructure Guide Context Pruning: Cut LLM Tokens Without Losing Quality
Designing a semantic routing system: From static rules to...
Redis · 2026-04-03 · via Redis

A semantic routing pattern is a powerful technique used in intelligent systems to classify incoming requests based on their meaning and direct them to the most appropriate processing path. Unlike traditional rule-based approaches that rely on keywords or binary logic, semantic routing leverages embeddings and similarity matching to understand user intent. By comparing an input against predefined categories—such as FAQ, restricted topics, or complex queries—the system can efficiently determine how to handle each request. This enables use cases like routing simple questions to low-cost pipelines, blocking sensitive topics, or escalating complex queries to advanced models, all within milliseconds.

In a production environment, flexibility is critical. Rather than hardcoding routing rules, modern systems allow configurations to be defined and updated dynamically. In this approach, routing definitions are stored in Redis as a centralized source of truth. The application loads these configurations at runtime to build the router, while also exposing services that enable users to update or extend routing rules without requiring redeployment. This design ensures scalability, maintainability, and real-time adaptability.

To support semantic routing, this sample leverages RedisVL for Java, a library that simplifies working with vector embeddings and similarity search in Redis. RedisVL provides high-level abstractions for vector indexing, embedding storage, and similarity-based retrieval. In this setup, the stored example queries act as reference data that can be vectorized and used by the semantic router to match incoming user inputs based on meaning rather than exact keywords.

Find the source code here: https://github.com/Redislabs-Solution-Architects/semantic-router-with-redis

1. Define default routing config in Java and store in Redis

The first step is to establish a default routing configuration directly in the application code. This configuration maps each category—such as sports, technology, or business—to a set of representative example queries that define its semantic intent. When the loaddefaultRouterConfig() method is executed, it begins by clearing any existing routing data in Redis to prevent inconsistencies or stale entries. It then iterates through each category and stores the associated queries in Redis using a structured key format (e.g., router:sports). Each query is saved as a field in a Redis hash. By persisting this data in Redis, the system externalizes its routing knowledge, making it reusable, shareable, and independent of application memory.

Code snippet is as follows.

2. Build a service to update router settings dynamically

To support runtime flexibility, a service layer is introduced to allow users or external systems to modify routing configurations dynamically. The updateRouter() method serves this purpose by accepting a new set of categories and example queries. For each category, it replaces the existing Redis entry by deleting the old key and inserting the updated values. This ensures that updates are applied cleanly and consistently at the category level. In a real-world app, this functionality would typically be exposed via a REST API, letting users add new categories, refine example queries, or adjust routing behavior without redeploying the system. This approach transforms routing from a static configuration into a dynamic, user-driven capability.

Code snippet is as follows.

3. Build the semantic router dynamically from Redis

Once routing data is stored in Redis, the system can dynamically construct the semantic router at runtime. The build() method scans all Redis keys that match the routing pattern, retrieves their associated queries, and transforms each category into a Route object. Each route includes a name, a set of reference examples for semantic comparison, metadata such as category and priority, and a distance threshold that controls matching sensitivity. These routes are then aggregated into a router configuration, which defines how many matches to consider and how similarity scores are calculated. Finally, the SemanticRouter is instantiated using this configuration along with a vectorizer for embedding generation. Because the router is built entirely from Redis data, any updates made through the service layer are automatically reflected, resulting in a fully dynamic and data-driven routing system.

Code snippet is as follows.

Workflow

  1. Initialize → Load default categories and store them in Redis
  2. Update → Users modify routing rules via a service → Redis is updated
  3. Runtime → The router reads from Redis, builds routes, and processes queries

Frontend view to use the service

The frontend might appear as shown below.

1. The Semantic routing configuration is visible to the user.

Semantic routing settings

2. The user has the ability to submit queries for verification of the routing outcome.

Router for questions

3. User can submit new question list and assign a category like “health”

Submit question list

4. Load the router for questions can get the updated routing settings

Load the router for questions can get the updated routing settings

5. The user can then inquire about "Health" to retrieve results for a new question category.

The user can then inquire about "Health" to retrieve results for a new question category.

Flexible and scalable system architecture

This architecture cleanly separates routing data from routing logic, enabling a flexible and scalable system. By leveraging Redis as a dynamic configuration store and semantic similarity for intelligent classification, you create a routing mechanism that is both efficient and adaptable. As a result, your system can evolve over time—supporting new categories, refining intent recognition, and improving user experience—without requiring code changes or redeployments.