Building a RAG Pipeline
Add your knowledge base to LiyaEngine and tune retrieval for your use case.
LiyaEngine includes a built-in RAG (Retrieval-Augmented Generation) pipeline. When enabled, the engine retrieves relevant content from your tenant knowledge base before generating a response, grounding answers in your proprietary data.
Enable RAG
RAG is controlled by the enable_rag feature flag. Update it via PATCH /dashboard/account/config:
PATCH https://api.liyaengine.ai/dashboard/account/config
Authorization: Bearer <jwt>
Content-Type: application/json
{
"featureConfig": {
"enable_rag": true
}
}Once enabled, all intents in your enabled domains will query the knowledge base.
Knowledge sources
Knowledge is organised by domain and source type. The built-in hiring sample domain ships with system-managed labor-market source types (not tenant-uploaded — they're ingested from O*NET and BLS):
| Source type | Description |
|---|---|
onet_occupation_profile | Occupation Profile (O*NET) — skills, tasks, activities per role |
bls_wage_data | Wage Benchmarks (BLS) — median wages and percentiles by occupation |
bls_growth_projections | Growth Outlook (BLS) — projected demand per occupation |
For your own knowledge base, upload documents to a collection — a tenant-defined source type you create and attach to your custom domain(s). Upload and manage collections in the Knowledge section of the dashboard, or via the API (see Knowledge Sources).
RAG configuration
Retrieval behaviour isn't a single tenant-wide dial — it's configured at two levels: the domain (how far retrieval reaches) and the collection (how its documents are chunked, embedded, and weighted).
Domain-level: retrieval scope
Set how far a domain's intents are allowed to search via PATCH /dashboard/custom-domains/:domainKey:
PATCH https://api.liyaengine.ai/dashboard/custom-domains/hiring
Authorization: Bearer <jwt>
Content-Type: application/json
{
"retrievalScope": "domain_plus_global"
}retrievalScope value | Description |
|---|---|
domain_only | Retrieve only from collections attached to this domain — the default |
domain_plus_global | Also retrieve from tenant-wide (unfiled) knowledge |
global_only | Ignore domain-specific collections; retrieve tenant-wide knowledge only |
Collection-level: chunking, embedding, and ranking
Each knowledge collection has its own chunking and retrieval settings, configured via PATCH /dashboard/collections/:id:
{
"default_chunking_strategy": "sliding_window",
"default_chunk_size": 768,
"default_chunk_overlap": 128,
"default_embedding_model": "text-embedding-3-large",
"retrieval_config": {
"scope": "collection_plus_domain",
"boost_priority": 1.5,
"fallback_when_empty": "domain_fallback"
}
}Chunking strategies
| Strategy | Description |
|---|---|
fixed | Non-overlapping fixed-size chunks — the default |
semantic | Splits on sentence boundaries |
sliding_window | Fixed-size chunks with overlap — the only strategy where default_chunk_overlap has any effect |
Key parameters
| Parameter | Range / Default | Description |
|---|---|---|
default_chunk_size | 100–2000 chars, default 512 | Target characters per chunk |
default_chunk_overlap | 0 to chunk_size − 1 | Character overlap between adjacent chunks — only applies when default_chunking_strategy is sliding_window |
retrieval_config.scope | collection_only | collection_plus_domain | Whether retrieval for this collection also pulls from the domain's other collections |
retrieval_config.boost_priority | 0.5–3.0, default 1.0 | Score multiplier applied to this collection's chunks during ranking |
retrieval_config.fallback_when_empty | domain_fallback | no_results | What happens when this collection returns nothing above threshold |
Tuning retrieval quality
Boost your most authoritative collection
If one collection holds your most reliable content (e.g. official policy docs vs. community notes), raise its boost_priority so its chunks outrank the rest during retrieval:
{ "retrieval_config": { "boost_priority": 2.0 } }Avoid empty results with domain fallback
If a collection's coverage is thin and queries against it often come back empty, set fallback_when_empty to domain_fallback so retrieval falls back to the domain's other collections instead of returning nothing:
{ "retrieval_config": { "fallback_when_empty": "domain_fallback" } }Use sliding-window chunking for long documents
For documents like job descriptions or policy manuals, sliding-window chunking with overlap preserves context across chunk boundaries — semantic and fixed chunking do not use default_chunk_overlap at all:
{
"default_chunking_strategy": "sliding_window",
"default_chunk_size": 768,
"default_chunk_overlap": 128
}RAG per domain
RAG is scoped to the domain of each request. A hiring intent only retrieves from hiring knowledge sources — it never queries fintech or other domain sources. This prevents cross-domain contamination.
For custom domains, RAG requires enable_rag: true in the domain's feature config and at least one knowledge source uploaded. See Custom Domain Knowledge Sources.
Disabling RAG
enable_rag is a tenant-wide feature flag — there is no per-request override to bypass retrieval for a single call. To turn retrieval off entirely, set enable_rag: false via PATCH /dashboard/account/config as shown above. Intents that don't benefit from your knowledge base (e.g. general chat) simply won't get useful context injected, but retrieval still runs unless the flag is off.