Quick answer: An AI knowledge base is a curated, retrievable collection of documents that a language model or agent reads from to answer questions. It is not the model's training data and not a traditional database. It is a body of text (docs, policies, product info, research) that has been ingested, split into chunks, and indexed so the right passages can be pulled in at query time and handed to the model. It gives the model current, specific, private knowledge it never saw during training.
The confusion is understandable, because "knowledge base" already meant something in software before LLMs. Let me clear it up.
How It Differs From What You Already Know
| Traditional database | Docs site | AI knowledge base | |
|---|---|---|---|
| Stores | Structured rows and columns | Human-readable pages | Text chunks plus embeddings |
| Queried by | Exact keys, SQL | Humans clicking and reading | Semantic similarity to a question |
| Returns | Matching records | A page to read | Relevant passages for a model |
| Consumer | Applications | People | An LLM or agent |
| Optimized for | Precise lookups | Navigation | Retrieval by meaning |
A database answers "give me order 4471." A docs site answers "let a person find the refund policy." An AI knowledge base answers "what does our refund policy say?" by finding the relevant paragraphs and feeding them to a model that writes the answer. Same underlying content, different access pattern.
The key word is retrievable. Content sitting in a database or on a docs site is not automatically usable by an LLM. It has to be turned into something a model can search by meaning, which is what building a knowledge base actually is.
The Four Steps to Build One
Building an AI knowledge base is a pipeline: ingest, chunk, embed, retrieve. Each step has a clear job.
1. Ingest
Get the raw text out of wherever it lives (web pages, PDFs, docs) and into clean, plain form. For web content, that means fetching pages and converting them to markdown. Using link.sc, a page becomes clean text in one call. The contract: POST to api.link.sc/v1/fetch with an x-api-key header, body {"url": ..., "format": "markdown"}, response {"content": ...}.
import os
import requests
LINKSC = "https://api.link.sc/v1"
HEADERS = {
"x-api-key": os.environ["LINKSC_API_KEY"],
"content-type": "application/json",
}
def ingest(url: str) -> str:
r = requests.post(
f"{LINKSC}/fetch",
headers=HEADERS,
json={"url": url, "format": "markdown"},
)
r.raise_for_status()
return r.json()["content"]
Clean input matters more than any later step. If you ingest raw HTML full of navigation and ads, that noise gets embedded and retrieved right alongside your real content.
2. Chunk
Models retrieve passages, not whole documents. Split each document into overlapping chunks of a few hundred words. Overlap keeps a sentence that straddles a boundary from getting cut in half.
def chunk(text: str, size: int = 800, overlap: int = 100) -> list[str]:
words = text.split()
chunks = []
start = 0
while start < len(words):
chunks.append(" ".join(words[start:start + size]))
start += size - overlap
return chunks
3. Embed
Turn each chunk into a vector that captures its meaning, and store it. When a question comes in, embed the question the same way and find the chunks whose vectors are closest. This is what lets you retrieve by meaning instead of exact keywords, so "how do I get my money back" finds the refund policy even without the word "refund."
# pseudocode: use your embedding model and vector store of choice
vectors = [(embed(c), c) for c in all_chunks]
store.upsert(vectors)
4. Retrieve
At query time, embed the question, pull the top matching chunks, and pass them to the model as context. That is the retrieval step, and it is where the knowledge base earns its keep.
def retrieve(question: str, k: int = 5) -> list[str]:
q_vec = embed(question)
return store.search(q_vec, top_k=k)
The RAG Connection
If those four steps sound like retrieval-augmented generation, that is because they are. A knowledge base is the retrieval half of RAG. The model reading the retrieved chunks and writing an answer is the generation half. You cannot do RAG without a knowledge base to retrieve from, and a knowledge base with no model reading it is just a search index.
Put plainly: the knowledge base is the corpus and its index; RAG is the technique that uses it to answer questions. For the full picture of how the two fit together, see what is RAG (retrieval-augmented generation).
Keeping It Fresh From the Web
A knowledge base built once and never updated slowly rots. Prices change, docs get revised, policies update. If your source is the web, the fix is to re-ingest on a schedule: fetch the source pages again, re-chunk, and re-embed anything that changed.
from datetime import date
def refresh(urls: list[str]) -> None:
for url in urls:
text = ingest(url)
chunks = chunk(text)
store.upsert([(embed(c), c) for c in chunks], namespace=url)
# record when you last refreshed so you know how stale the KB is
store.set_meta("last_refresh", str(date.today()))
For a knowledge base that tracks a fast-moving source, you can even skip the persistent index for some queries and fetch live at question time, trading a bit of latency for perfect freshness.
Common Mistakes
- Treating the model as the knowledge base. The model's weights are not your corpus. It does not know your private docs, and it does not know what changed since training. The knowledge base is separate on purpose.
- Ingesting dirty text. Boilerplate and markup pollute retrieval. Clean at ingest time.
- Chunks too big or too small. Too big and you retrieve irrelevant filler; too small and you lose context. A few hundred words with overlap is a good default to tune from.
- Never refreshing. A stale knowledge base gives confidently outdated answers, which is worse than admitting it does not know.
Done right, an AI knowledge base is what turns a general-purpose model into something that actually knows your material. The single most valuable move is feeding it clean, current text, which is exactly what a fetch-to-markdown step gives you.
If your source is a documentation site, turning any docs site into an LLM knowledge base walks through the whole thing end to end. The link.sc docs cover the fetch endpoint in detail.
Build a knowledge base your AI can actually read. Start with link.sc for free.