AI Research Project

Rosemary.

A Reference Architecture for Domain-Specific AI Chatbots

Rosemary is a research-driven RAG chatbot architecture designed as a practical reference for building reliable domain-specific conversational AI systems using semantic retrieval, metadata-aware filtering, smart reranking, and LLM-powered response generation.

Project Overview Watch on YouTube ↗

System Overview

Rosemary Pipeline

Research Flow
01
User Query Natural-language input
02
Query Validation Domain and scope check
03
Intent Router Selects the right retrieval path
Menu Retriever FAISS Index
Promo Retriever FAISS Index
04
Metadata Filter Price, category, temperature, spice level
05
Smart Reranker FAISS candidates + CrossEncoder
06
LLM Generation Controlled answer formatting
07
Reliable Answer Grounded, concise, domain-aware
Why Rosemary?

Reliable AI requires more than a language model.

In focused domains, a chatbot must do more than generate fluent answers. It must retrieve the right information, apply structured rules, and know when it should not answer.

! The Core Problem

Fluent answers are not always reliable answers.

A domain chatbot can sound convincing while returning the wrong menu, ignoring constraints, or inventing information that does not exist in its underlying data.

Rosemary is designed to make responses more grounded, structured, and domain-aware before the language model generates the final answer.

01

Search needs structure

Semantic similarity alone cannot reliably enforce filters such as price, category, spice level, or availability.

02

Queries need different paths

Questions about promotions, prices, recommendations, and menu details should not be processed by one generic flow.

03

Generation needs guardrails

Retrieval alone is not enough; final answers still need validation, constrained formatting, and factual boundaries.

Project Goals & Core Concepts

Designed for answers that are useful, grounded, and controllable.

Rosemary is not designed to make a chatbot sound smarter. It is designed to make domain-specific responses more dependable through structured retrieval, explicit routing, and controlled generation.

01

Project Goals

What Rosemary is built to improve

01

Reduce hallucination

Ground answers in retrieved menu and promotion data instead of relying on unconstrained generation.

02

Respect domain rules

Handle structured conditions such as category, price, temperature, spice level, and active promotions.

03

Improve answer consistency

Route different question types through the right path and return concise, predictable output.

02

Core Concepts

Four building blocks of the architecture

Retrieve

Semantic Retrieval

Finds relevant candidates from menu or promotion knowledge using vector similarity search.

Filter

Metadata-Aware Logic

Applies structured constraints such as price, category, spice, temperature, and availability.

Route

Intent-Aware Paths

Distinguishes menu, promo, price, description, recommendation, and out-of-scope questions.

Generate

Reranking & Guardrails

Refines candidate relevance and keeps final answers factual, concise, and consistently formatted.

Architecture Deep Dive

From a user query to a grounded restaurant answer.

Rosemary does not send every question directly to the language model. It validates, routes, retrieves, filters, ranks, and formats the result through purpose-built stages.

Select a pipeline stage

Tap to explore each stage of the Rosemary architecture.

01
Query Validation

Keep the assistant inside its intended domain.

Rosemary first determines whether the question belongs to the restaurant and promotion domain before any retrieval or generation begins.

Input

A raw natural-language question from the user.

Mechanism

Domain keywords are checked first. If no keyword matches, the query is compared semantically against in-scope examples using embeddings.

Decision

Accepted queries continue through the pipeline; out-of-scope questions receive a controlled refusal response.

Why this matters

It prevents unrelated questions from reaching the retriever and reduces the chance of confident but irrelevant answers.

Engineering Decisions & Research Value

Designed with purpose, not complexity for its own sake.

Rosemary combines retrieval, rule-based control, and generation through decisions intended to improve reliability in a focused domain.

01

Why the architecture works this way.

Select a decision

Tap to inspect the rationale and trade-offs behind each decision.

Decision 01

Keep menu and promotion knowledge in separate retrieval spaces.

Rosemary creates independent FAISS indexes for menu documents and promotion documents, then routes the query to the appropriate one.

Rationale

Menu data uses attributes such as category, price, warm, spicy, and soup status. Promo data uses date ranges, active status, and requirements.

Trade-off

The system needs explicit routing and maintains two indexes instead of one unified knowledge store.

Outcome

Retrieval is more focused, and time-sensitive promotion checks can be handled without contaminating menu results.

02

What this architecture demonstrates.

  • 01

    A hybrid control layer combining vector retrieval, deterministic metadata filtering, and constrained generation.

  • 02

    Query-aware routing that treats price, descriptions, promos, recommendations, and out-of-scope questions differently.

  • 03

    A practical reliability pattern for narrow-domain chatbots built from accessible open-source components.

03

Components behind Rosemary.

Language & Interface
Python Gradio
Models
Qwen 2.5 multilingual-e5-small MiniLM CrossEncoder
Retrieval & Orchestration
FAISS LangChain Hugging Face RapidFuzz
Live Examples

One architecture, different paths for different questions.

These examples show how Rosemary changes its handling based on query type: factual lookups take fast paths, constraints trigger metadata filters, promotion requests use a dedicated index, and unrelated questions stop at validation.

Choose an example

Tap to see how Rosemary handles each query type.

Example 01 · Price Lookup
User Query

“Berapa harga [Nama Menu]?”

Rosemary Response

“Harga [Nama Menu] adalah [harga] rupiah.”

Output follows the controlled price-answer format defined in the generation logic.

System Trace
01
Query Validation Restaurant-related request accepted
02
Menu Retrieval Find relevant menu candidate
03
Price Fast Path Read explicit price from metadata
What this demonstrates

A factual price question does not need a full reranking or free-form generation workflow when the answer exists directly in menu metadata.