Knowledge Base

Practical guides on AI, the African Stack, web fundamentals, Kenyan tech careers, and common developer errors. Written for developers building in and for Africa.

What Is RAG? Retrieval Augmented Generation Explained With a Kenyan SACCO Chatbot Example

RAG connects an LLM to your own data so it answers from facts, not guesses. This guide explains retrieval augmented generation with a Kenyan SACCO chatbot example, complete code, and practical tradeoffs.

AI and LLMs

What Are Embeddings? How Text Becomes Numbers

Embeddings turn text into arrays of numbers that capture meaning. This guide explains how they work with a plain-language walkthrough, a worked code example, and practical use cases for developers.

AI and LLMs

What Is a Vector Database? When Postgres With pgvector Is Enough

Vector databases store embedding vectors and search by similarity instead of exact match. This guide explains how they work, compares pgvector to dedicated options like Pinecone, and helps you pick the right one.

AI and LLMs

RAG vs Fine-Tuning: How to Choose for Your App

RAG retrieves your data at query time. Fine-tuning bakes knowledge into the model. This guide gives you a clear decision framework with three real scenarios to help you choose the right approach.

AI and LLMs

What Is Prompt Engineering? Techniques That Survive Model Updates

Prompt engineering is the practice of structuring LLM inputs to get reliable outputs. This guide covers durable techniques, not model-specific tricks, with before-and-after examples you can use today.

AI and LLMs

How Do Large Language Models Work? A Plain-Language Explanation

LLMs predict the next token based on everything before it. This guide explains how that works without equations, covering training, inference, and why LLMs sometimes make things up.

AI and LLMs

Tokens and Context Windows Explained: Why They Set Your API Bill

LLM APIs charge by the token. This guide explains what tokens are, how context windows limit what the model can read, and how both directly affect your costs and application design.

AI and LLMs

What Is Function Calling in LLM APIs? Tool Use With Code Examples

Function calling lets an LLM request specific actions, like checking weather or querying an M-Pesa balance, instead of guessing. This guide explains the pattern with runnable TypeScript examples.

AI and LLMs

What Are AI Agents? Loops, Tools, and Guardrails

An AI agent is a loop: observe, decide, act, repeat. This guide cuts through the hype to explain what agents actually are, how the loop works, and what guardrails prevent them from going off the rails.

AI and LLMs

What Is MCP? Model Context Protocol for Developers

MCP (Model Context Protocol) is an open standard for connecting LLMs to external tools and data sources. This guide explains the protocol, its architecture, and how to build your first MCP server.

AI and LLMs

LLM Hallucinations: Why They Happen and How Production Apps Reduce Them

LLM hallucinations happen because models generate probable text, not verified facts. This guide explains why they occur and covers five practical techniques to reduce them in production applications.

AI and LLMs

Temperature, Top-p, and Sampling Settings Explained

Temperature and top-p control how random an LLM's output is. This guide explains what each setting does, shows side-by-side output examples, and gives you practical defaults for common tasks.

AI and LLMs

System Prompts vs User Prompts: Structure That Improves Output

System prompts set the model's role and rules. User prompts carry the specific request. This guide shows the difference with a before-and-after example for a Kenyan business scenario.

AI and LLMs

Streaming LLM Responses in Next.js: Complete Setup

Stream LLM responses token by token in Next.js App Router. This guide walks through the full setup: a server-side route handler that streams from the OpenAI API, and a React component that renders the stream in real time.

AI and LLMs

What Are AI Evals? Testing LLM Features Before You Ship

AI evals are test suites for LLM-powered features. They verify that your system gives correct, safe, well-formatted answers. This guide explains how to build a practical eval suite with a TypeScript example.

AI and LLMs

Chunking Strategies for RAG: Sizes, Overlap, and Structure

How you split documents into chunks affects RAG retrieval quality. This guide covers practical chunking strategies, recommended sizes, overlap settings, and when to use structural chunking.

AI and LLMs

Semantic Search vs Keyword Search: What Changes With Embeddings

Keyword search matches exact terms. Semantic search matches meaning. This guide shows the same query run both ways, explains when each is better, and shows you how to implement hybrid search.

AI and LLMs

Cosine Similarity Explained for Developers

Cosine similarity measures how similar two vectors are by the angle between them. This guide explains the concept with a worked example in Python and TypeScript, so you understand what powers vector search.

AI and LLMs

M-Pesa Daraja API Integration: The Complete Walkthrough for Developers

A step-by-step guide to integrating M-Pesa Daraja API. Covers authentication, STK Push, callbacks, and going live with runnable Node.js and Python code.

African Stack

STK Push Explained: How Lipa na M-Pesa Online Works End to End

Understand the full STK Push lifecycle from request to callback. Covers the sequence of events, what happens at each stage, timeout behavior, and common failure codes.

African Stack