☁ Cloud frameworks — what you get free
LangChain and LlamaIndex provide 7+ chunking strategies with automatic selection. RecursiveCharacterTextSplitter, MarkdownNodeParser, SemanticSplitter — pick one, done.
LangChain / LlamaIndex
RecursiveCharacterTextSplitter(
chunk_size=512
)
# no LLM call needed
↗ Chunking Techniques with LangChain & LlamaIndex — lancedb.com, 2024
⚡ SLM · Superbrain — what we built
Ask llama3.1:8b to pick the strategy. Closed action space — 3 valid values. Every call has a fallback if JSON is malformed.
# closed action space
"""Output JSON only:
{"strategy": "semantic"|"recursive"|"fixed"}
Article (first 2000 chars): ..."""
try:
strategy = json.loads(resp)["strategy"]
assert strategy in {"semantic","recursive","fixed"}
except:
strategy = "fixed" # deterministic fallback
The principle
Design for failure. Every LLM call needs a fallback. The pipeline never blocks on a bad model response.