AI Pattern Library

A searchable, interactive catalog of proven AI engineering patterns — with explanations, architecture diagrams, runnable code, and real-world gotchas.

11 Patterns
8 Categories
Runnable Code
reasoning beginner

Chain-of-Thought Prompting

Improve LLM reasoning by instructing the model to break down complex problems into intermediate steps before giving a final answer.

chain-of-thoughtcotreasoningprompting
memory intermediate

Conversational Memory

Maintain context across multi-turn conversations by managing short-term, long-term, and summary memory for AI assistants.

memoryconversationcontext-windowsummarization
retrieval advanced

Hybrid Search for RAG

Combine vector similarity search with keyword-based (BM25) search to get the best of both retrieval worlds for RAG pipelines.

hybrid-searchbm25vector-searchretrieval
evaluation intermediate

LLM-as-Judge Evaluation

Use one LLM to evaluate the outputs of another, enabling scalable automated quality assessment for AI systems.

evaluationllm-judgequalitytesting
safety intermediate

Output Guardrails & Validation

Validate and filter LLM outputs to ensure safety, correctness, and compliance before they reach end users.

guardrailssafetyvalidationfiltering
orchestration intermediate

Prompt Routing & Orchestration

Route user requests to specialized prompts, models, or pipelines based on intent classification or content analysis.

routingorchestrationintentpipeline
agents advanced

ReAct Agent

Combine Reasoning and Acting in an interleaved loop where the LLM thinks about what to do, takes an action, observes the result, and repeats.

reactagentreasoningacting
retrieval intermediate

Retrieval-Augmented Generation (RAG)

Ground LLM responses in external knowledge by retrieving relevant documents and injecting them into the prompt context.

ragembeddingsvector-searchknowledge-base
reasoning intermediate

Self-Consistency

Improve reasoning accuracy by sampling multiple chain-of-thought paths and taking a majority vote on the final answer.

self-consistencyvotingsamplingreasoning
tool-use intermediate

Tool Use / Function Calling

Extend LLM capabilities by giving it access to external tools and functions it can invoke to take actions or fetch real-time data.

function-callingtoolsapiactions
reasoning advanced

Tree-of-Thought

Explore multiple reasoning branches in a tree structure, enabling the LLM to evaluate and backtrack on different solution paths.

tree-of-thoughttotreasoningsearch