RAG (Retrieval-Augmented Generation) retrieves relevant information from an external knowledge base and includes it in the prompt during LLM response generation. It is a core pattern in Azure AI Foundry. Compared to fine-tuning, RAG offers lower cost, easier data updates, source citation, and reduced hallucination — making it the most important topic on the AI-103 exam. This article comprehensively covers the 5-step pipeline, chunking strategies, Azure AI Search, and hallucination reduction.
Standalone LLMs (Closed-book) can only answer based on "general knowledge up to their training cutoff." RAG (Open-book) enables responses grounded in organization-specific data and current news.
| Step | Action | Key Service |
|---|---|---|
| 1. Document Ingestion | Ingest PDFs, Word, SharePoint, web | Azure AI Document Intelligence |
| 2. Chunking | Split into 200-1,000 token units | LangChain / Custom |
| 3. Embedding | Vectorization | Azure OpenAI text-embedding-3-large |
| 4. Indexing | Store in vector store | Azure AI Search Vector |
| 5. Retrieval | Top-K search | Azure AI Search Vector + Hybrid |
| 6. Generation | Response generation + source citation | GPT-4o |
Azure AI Search is the most recommended Azure-native vector store for RAG.
| Tier | Use Case | Monthly Cost (approx.) |
|---|---|---|
| Basic | Development | ~15,000 yen |
| Standard S1 | Standard production | 30,000-100,000 yen |
| Standard S2/S3 | Large-scale production | Hundreds of thousands of yen |
| Storage Optimized | Large volume | Hundreds of thousands of yen |
Chunking is the most important design decision affecting RAG quality.
| Strategy | Characteristics | Use Case |
|---|---|---|
| Fixed-size Chunking | Fixed 200, 500, 1,000 tokens | Simplest |
| Sentence Splitter | Split by sentence | Natural breaks |
| Paragraph Splitter | By paragraph | Most natural |
| Recursive Character Splitter | Hierarchical split Paragraph → Sentence → Word | Recommended (LangChain) |
| Semantic Chunking | Semantic grouping via embedding similarity | Highest quality, expensive |
| Document-structure-aware | Preserves heading, table, list structure | Structured PDFs |
Overlap (50-100 token overlap) prevents context loss. In production, A/B test multiple strategies for optimization.
| Model | Dimensions | Accuracy | Cost | Use Case |
|---|---|---|---|---|
| text-embedding-3-large | 3,072 | Highest | Medium | High-accuracy requirements |
| text-embedding-3-small | 1,536 | Standard | Low (~1/5 of 3-large) | Large document volumes |
| text-embedding-ada-002 | 1,536 | Legacy | Standard | Backward compatibility only |
Dimension reduction (e.g., 3-large from 3,072 → 1,024 dimensions) can reduce cost at a slight accuracy penalty. For multilingual requirements, consider multilingual-specialized models (multilingual-e5-large). Changing the embedding model mid-production requires regenerating all vectors, so initial selection is critical.
Techniques to reduce hallucination (the phenomenon where LLMs confidently generate factually incorrect responses):
| Service | Characteristics | Use Case |
|---|---|---|
| Azure AI Search Vector | Full features, Hybrid Search, Semantic Ranker | Production standard (recommended) |
| Azure Cosmos DB for NoSQL Vector | Integrated NoSQL data and vectors | NoSQL-based apps |
| Azure Database for PostgreSQL pgvector | PostgreSQL extension | Existing PostgreSQL environments |
| Azure Cache for Redis Vector | Low-latency cache | Session-ephemeral vectors |
from openai import AzureOpenAI
from azure.search.documents import SearchClient
from azure.identity import DefaultAzureCredential
# Azure OpenAI client (Managed Identity)
client = AzureOpenAI(
azure_endpoint='https://your-openai.openai.azure.com',
azure_ad_token_provider=DefaultAzureCredential()
)
# Azure AI Search client
search_client = SearchClient(
endpoint='https://your-search.search.windows.net',
index_name='documents',
credential=DefaultAzureCredential()
)
def rag_query(user_query: str) -> str:
# 1. Embedding generation
embedding = client.embeddings.create(
input=user_query,
model='text-embedding-3-large'
).data[0].embedding
# 2. Vector search (Hybrid)
results = search_client.search(
search_text=user_query,
vector_queries=[{
'vector': embedding,
'k_nearest_neighbors': 5,
'fields': 'content_vector'
}],
select=['content', 'source'],
query_type='semantic',
semantic_configuration_name='default'
)
# 3. Context construction
context = '\n\n'.join([f"[{r['source']}] {r['content']}" for r in results])
# 4. Generation with grounding
response = client.chat.completions.create(
model='gpt-4o',
messages=[
{'role': 'system', 'content': '''You are a helpful assistant.
Answer ONLY based on the provided context. If the answer is not in the context, say "I do not know".
Always cite sources using [source_id].'''},
{'role': 'user', 'content': f'Context:\n{context}\n\nQuestion: {user_query}'}
],
temperature=0
)
return response.choices[0].message.contentWhat is RAG (Retrieval-Augmented Generation)?
RAG retrieves relevant information from external knowledge bases (organization-specific data, latest information) and includes it in the prompt to generate responses. Standalone LLMs (Closed-book) can only answer based on general knowledge up to their training cutoff, while RAG (Open-book) enables responses grounded in organization-specific data and current news. Representative use cases: 1) Internal Q&A bots (referencing internal documents and policies), 2) Customer Support (FAQ and product manuals), 3) Legal Research (case law and contracts), 4) Medical Q&A (papers and guidelines), 5) E-commerce product recommendations (product catalog). RAG benefits: 1) lower cost and faster than fine-tuning, 2) easy data updates (just re-index), 3) source citation for accountability, 4) reduced hallucination. This is the most important topic in AI-103 Domain 2 (Generative AI).
What are the 5 steps of a RAG pipeline?
Standard RAG pipeline: 1) Document Ingestion (ingest PDFs, Word, SharePoint, web pages; structured extraction via Azure AI Document Intelligence), 2) Chunking (split documents into 200-1,000 token units; Sentence / Paragraph / Recursive Character Splitter), 3) Embedding (vectorize with Azure OpenAI text-embedding-3-large; 3,072 dimensions; batch processing recommended), 4) Indexing (store in Azure AI Search Vector Index; Vector Field + Filterable Metadata Field), 5) Retrieval (user query -> embed -> top-K search via cosine similarity; Hybrid Search = Vector + Full-text + BM25 for higher accuracy), 6) Generation (include retrieved chunks in prompt; generate response with GPT-4o; include source citations). Production deployments require continuous improvement at every step. Chunking strategy, retrieval accuracy, and prompt design especially drive response quality.
How do you leverage Vector Search in Azure AI Search?
Azure AI Search is the most recommended Azure-native vector store for RAG. Key features: 1) Vector Search (fast ANN search via HNSW Algorithm; supports up to hundreds of millions of vectors), 2) Hybrid Search (Vector + Full-text + BM25 for higher recall), 3) Semantic Ranking (re-ranking via Microsoft's proprietary BERT model), 4) Filter (filter by metadata fields), 5) Faceted Navigation (category aggregation), 6) Integrated Vectorization (auto-generate embeddings during document ingestion; Azure OpenAI integration), 7) Index Replicas + Partitions (high availability + scale). Pricing tiers: Basic (dev), Standard S1/S2/S3 (production), Storage Optimized (large volume). For production RAG, Standard S1 + 2 Replicas + 2 Partitions is the standard configuration, starting at tens of thousands of yen per month. Cosmos DB Vector and PostgreSQL pgvector are alternatives, but Azure AI Search leads on features and integration.
How do you design a chunking strategy?
Chunking is the most important design decision affecting RAG quality. Common strategies: 1) Fixed-size Chunking (fixed 200, 500, 1,000 tokens; simplest; downside: token boundaries cut mid-sentence), 2) Sentence Splitter (split by sentence; natural breaks; uneven chunk sizes), 3) Paragraph Splitter (by paragraph; most natural; depends on PDF structure), 4) Recursive Character Splitter (provided by LangChain; hierarchical split Paragraph -> Sentence -> Word; recommended), 5) Semantic Chunking (group semantically by embedding similarity; highest quality; expensive), 6) Document-structure-aware Chunking (preserves heading, table, list structure; integrated with Microsoft AI Document Intelligence). Overlap (50-100 token overlap) prevents context loss. Typical designs: general document -> 500 tokens + 100 overlap + Recursive Character; long-form articles -> 1,000 tokens + 200 overlap; structured PDFs -> Document-structure-aware Chunking. Production deployments standardly A/B test multiple strategies for optimization.
How do you choose an embedding model?
Azure OpenAI embedding models: 1) text-embedding-3-large (3,072 dimensions; highest accuracy; medium cost), 2) text-embedding-3-small (1,536 dimensions; fast; low cost; about 1/5 the price of 3-large), 3) text-embedding-ada-002 (1,536 dimensions; legacy; backward compatibility only). Decision: high-accuracy requirements (legal, medical, precise search) -> text-embedding-3-large; high-speed/low-cost requirements (internal FAQ, large document volumes) -> text-embedding-3-small. Dimension reduction (e.g., 3-large from 3,072 -> 1,024 dimensions) can reduce cost at a slight accuracy penalty (API parameter). Microsoft / OSS alternatives: BAAI/bge-large-en, E5 series; for multilingual requirements, multilingual-specialized models like multilingual-e5-large. Changing the embedding model mid-production requires regenerating all vectors, so initial selection is critical. Comparing multiple models in a pilot is recommended.
What techniques improve retrieval accuracy?
Accuracy improvement techniques: 1) Hybrid Search (combined score via Reciprocal Rank Fusion of Vector + Full-text + BM25; 10-30% better accuracy than vector alone), 2) Semantic Ranking (retrieve top 50 -> re-rank with Microsoft Semantic Ranker -> top 5 -> LLM; balances recall and precision), 3) Query Rewriting (user query -> LLM generates multiple variants -> parallel search -> result fusion; Hypothetical Document Embeddings (HyDE) pattern), 4) Multi-step Retrieval (first search -> generate additional queries from results -> second search; agent pattern), 5) Filter (narrow domain by metadata field; date range, author, etc.), 6) Re-ranker (Cohere Rerank API, cross-encoder models), 7) Chunk Enhancement (add heading, summary, questions to chunks to diversify embeddings). Production deployments require measuring each technique's effectiveness via evaluation and optimizing combinations. Continuous improvement via Azure AI Foundry's Prompt Flow + Evaluation is standard.
What techniques reduce hallucination?
Hallucination (the phenomenon where LLMs confidently generate factually incorrect responses) reduction: 1) Grounding (instruct in prompt: 'answer only based on the provided context; respond with "I do not know" if not in context'), 2) Source Citation (instruct in prompt: 'cite source IDs in responses' so users can verify), 3) Confidence Score (have LLM output response confidence; treat low confidence as uncertain), 4) Groundedness Detection (Azure AI Foundry's built-in metric; automatically verify generated content conforms to context; regenerate below threshold), 5) Multi-step Reasoning (Chain of Thought makes reasoning process explicit; easier to spot bad reasoning), 6) RAG result verification (after generation, have LLM self-check: 'is this response based solely on the provided context?'), 7) lower temperature toward 0 (deterministic responses suppress creative fabrication). Production deployments require combining multiple techniques + continuous evaluation. Microsoft's Groundedness Detection is a standard component of production RAG.
What are the related certification exams?
AI-103 (Developing AI Apps and Agents on Azure; GA 2026-06) Domain 2 (Generative AI 30-35%) deeply tests RAG patterns and is the flagship certification for this area. AI-901 (AI Fundamentals; GA 2026-06) covers RAG basics; AZ-204 (Developer Associate; retiring 2026-07, beware) covers RAG implementation from a developer perspective; SC-100 (Cybersecurity Architect Expert) covers RAG security and Responsible AI; DP-700 (Fabric Data Engineer) covers data preparation pipelines for RAG; DP-420 (Cosmos DB Specialty) covers RAG with Cosmos DB Vector. Understanding RAG is essential for Azure AI engineers and is the most important AI-103 study topic.
Related Articles and Deep Dives
Azure AI エンジニア キャリアロードマップ|AI-901 → AI-103 → 生成 AI アーキテクトへの道【2026 年版】
Azure AI エンジニアになるための認定取得ロードマップ完全版。AI-901 (2026-06 GA、AI-900 後継) → AI-103 (2026-06 GA、AI-102 後継) の最新ルート、Azure AI Foundry / Agent Service / OpenAI 中心の生成 AI 時代の構成、Databricks GenAI / OpenAI Direct との二刀流戦略、年収レンジまで日本語で網羅。
AI-103 完全ガイド|Developing AI Apps and Agents on Azure【2026 年 6 月 GA・AI-102 後継】
Microsoft Certified: Developing AI Apps and Agents on Azure (AI-103) の完全ガイド。AI-102 の後継として 2026 年 6 月 30 日 GA。Azure AI Foundry / Agent Service / OpenAI / AI Search を中心に、RAG パターン・Agent オーケストレーション・Responsible AI・Semantic Kernel SDK の実装スキル、3-4 ヶ月の合格ロードマップを日本語で網羅。
Azure データエンジニア キャリアロードマップ|DP-900 → DP-700 → AI-103 シニアデータエンジニアへの道【2026 年版】
Azure データエンジニアになるための認定取得ロードマップ完全版。DP-900 → DP-700 → DP-600 / DP-300 の Fabric 時代の王道ルート、Databricks 認定との二刀流、AI-103 統合戦略、DP-203 リタイア後の選択、12-18 ヶ月の学習プラン、年収レンジまで日本語で網羅。
Azure 認定資格ロードマップ 2026 完全版|全 26 試験の体系と大型再編 (AI-901/AI-103/SC-500)
Microsoft Azure 認定資格 全 26 試験 (現行 23 + 退役 3) の 2026 年版ロードマップ。Fundamentals/Associate/Expert/Specialty の階層、2026 年 6-9 月の大型再編 (AI-900→AI-901、AI-102→AI-103、AZ-500→SC-500)、役割別ルート (Admin/Developer/Architect/DevOps/Security/Data/AI) を日本語で整理。
The technical information in this article is based on the Azure AI Search RAG Documentation and the Azure AI Foundry Documentation. This article is not an official Microsoft Corporation product and has no affiliation or sponsorship relationship. Microsoft, Azure, Azure OpenAI, and Azure AI Search are trademarks of the Microsoft group of companies. OpenAI is a trademark of OpenAI, Inc. Information is based on official public materials as of May 24, 2026. Always check official pages for the latest information.
Practice with certification-focused question sets
View Azure exam prep pageNicheeLab Editorial Team
NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.
AZ-900 Azure Fundamentals: Complete Exam Guide (2026)
Pass AZ-900 — cloud concepts, Azure architecture, management...
Azure Certification Roadmap: Which Cert to Take Next (2026)
Choose your Azure certification path — Fundamentals, Associa...
AI-901 Azure AI Fundamentals (Beta): Complete Guide (2026)
Pass AI-901 — Microsoft Foundry, generative AI, responsible ...
Microsoft Entra ID Fundamentals for Azure Certs (2026)
Entra ID basics every cert candidate needs — tenants, identi...
DP-900 Azure Data Fundamentals: Complete Guide (2026)
Pass DP-900 — relational, non-relational, analytics, Power B...