AI Development Guide

All 18 TypeSafe Cookbooks in 2026: Guardrails, RAG, Extraction and Ranking

The cookbooks are the fastest way into this product, because each one is a finished system on a real dataset rather than a description of a feature. Here is what all 18 do, grouped by the problem they solve.

Distk Editorial Sep 2026 13 min read

TypeSafe publishes 18 official cookbooks in 2026, grouped into self-consistency, batching, how-to, extraction and classification, and labelled beginner, intermediate or advanced. The highest-value group commercially is verification: the guardrails recipe screens every message into and out of an LLM app with one request, and the citation checking recipe catches hallucinated citations against the source. The reranking recipe reports top-1 accuracy rising from 5 percent to 18 percent and top-10 from 38 percent to 62 percent across 40 CLERC legal queries. Every extraction recipe has the model choose among candidates rather than produce a value, because bounded answer spaces suit a Choice. Only three recipes make a second request, each for a documented reason. Copy the structure, rewrite the questions for your domain, and re-derive every threshold against your own labelled data.

What Are the TypeSafe Cookbooks in 2026?

The cookbooks are end-to-end recipes showing TypeSafe applied to real problems, from a few questions to full pipelines. Each one is a worked example with a real dataset, the questions that decide something about it, and the code that turns those decisions into a working system. There are 18 of them in 2026, grouped into five categories and labelled beginner, intermediate or advanced.

TypeSafe's own framing is that you read one when you want to see how the primitives and patterns come together on a concrete problem, or copy one as the starting point for your own. The prerequisite it states is that you already know the primitives and understand how confidence works.

Explain It Like I Am Five: Why Recipes Beat Instructions

There are two ways to learn to cook.

Someone can hand you a list of ingredients and say "flour is for structure, eggs are for binding, sugar is for sweetness". All true. All useless when you are hungry and standing in a kitchen.

Or someone can hand you a recipe for a cake. Exact amounts. Exact order. Exact oven temperature. Somebody already burnt the first three cakes so you do not have to.

These cookbooks are the second kind. Each one is a whole finished dish. Here is the real data, here are the exact questions, here is the code, here is what came out.

And here is the nice thing about recipes. Once you have made a cake, you can make a slightly different cake. You can swap the fruit. The recipe taught you the shape, and the shape works for hundreds of other cakes.

So the best way to learn this is not to read every page of the manual. Find the recipe closest to your problem, cook that, and then change one ingredient at a time.

Which Cookbooks Cover Guardrails and Verifying Other AI?

This is the group with the clearest commercial logic in 2026, because it puts a cheap decision model around an expensive generative one. TypeSafe describes the category as universal verification: verifying the input prompt, extractions, reasoning traces, tool calls, or inputs of any other AI, detecting jailbreaks, citation errors, hallucinations and other error modes at a fraction of the cost of the model call itself.

CookbookWhat it doesPrimitivesLevel
Guardrails for LLMsScreens every message going into and out of an LLM app with one request, thresholding hazard probabilities and severity to pass, review, block, or routeSeveral Nouls plus one ScoreIntermediate
Double-checking citationsCatches wrong or hallucinated citations by checking against the source document, with one question deciding whether the quote's context supports the claimChoiceBeginner
Classifying RAG passagesScores each retrieved passage with one request, then decides in code which ones reach the answering modelScoreIntermediate

The guardrails recipe is worth reading closely even if you never use it verbatim, because its structure is reusable. One Noul per hazard, such as whether a message attempts a jailbreak, requests harm, gives a diagnosis or dosage, or raises self-harm, plus one Score for severity. Each hazard has an action threshold and a lower review threshold, so a message either triggers its configured action, goes to a human, or passes. The severity score has its own threshold and can turn a review into a block. TypeSafe notes you edit it in two places: the dictionary of hazard questions and the two named routing policies.

That two-places design is the lesson. Everything a reviewer needs to argue about lives in two constants, not scattered across a codebase.

Which Cookbooks Cover Search, Retrieval and Reranking?

Three, and they are the strongest evidence in the documentation that this is not just a classification tool. The reranking cookbook in particular publishes before and after numbers on a public dataset.

CookbookWhat it doesReported resultLevel
Re-rankingBuilds 30-passage keyword shortlists for 40 CLERC legal queries, then uses one question per query-candidate pairTop-1 accuracy from 5 percent to 18 percent; top-10 from 38 percent to 62 percentBeginner
Line-by-line searchSemantic search over GitHub's Terms of Service, scoring 218 line IDs against a plain-language query in one requestAlso uses a Noul to check whether the document contains an answer at allBeginner
Knowledge graph entity alignmentDecides which of 450 candidate pairs from two beer catalogues describe the same productOne Score plus three companion Nouls that surface which fields disagreeBeginner

Two design details generalise beyond these recipes. The line-by-line search recipe asks a separate Noul about whether the document contains an answer at all, which is the difference between a search system that returns the least-bad line and one that can say there is nothing here. And the entity alignment recipe pairs a Score with Nouls that explain which fields disagree, so a human reviewing a near-match sees why rather than just a number.

Which Cookbooks Cover Extraction?

Three, and all of them share a principle that is easy to miss: do not ask the model to produce the value, ask it to choose the value. TypeSafe states this directly in its jaggedness notes, recommending that when the answer space is bounded you turn extraction into a Choice over options rather than asking for the value itself, and that for data extraction it is better to find candidates with a regular expression or a generative model and let Jev pick the correct one.

CookbookWhat it doesLevel
Date extractionExtracts absolute and relative dates by asking for the parts named in a document, then resolving and validating them in code with confidence-based reviewBeginner
Pre-parsed value extractionUses regular expressions to find candidate emails, phone numbers and amounts, then has TypeSafe select the requested span so code can normalise a verbatim valueBeginner
SDE cascadeA two-stage structured data extraction cascade, mini then verify then reasoning, to get most of the quality of a big reasoning model at a fraction of the costIntermediate

The date recipe is the clearest illustration of the principle. Every part of a date is a small closed set: twelve months, thirty-one possible days, a bounded range of years. That turns extraction into a Choice over enumerated options rather than free-form parsing, and it gives you somewhere to put an explicit "not stated" option so a missing part is reported rather than guessed. Code then assembles the parts into a real date and owns everything after that, including ordering, duration and weekday, because Jev reads dates as text rather than as ordered quantities.

The pre-parsed recipe inverts the usual division of labour in a way worth stealing: the regular expression does the finding, which it is perfect at, and the model does the choosing, which it is good at and the regex cannot do. Normalisation then happens in code on a verbatim span, so nothing is invented anywhere in the chain.

Which Cookbooks Cover Classification?

Three, covering a flat taxonomy with confidence, a deep hierarchy, and a machine learning feature loop.

CookbookWhat it doesLevel
Classification using confidenceClassifies SEC annual reports into 75 industry groups with one Choice each, then reads the answer's own confidence to decide whether to report that group or the broader division above itBeginner
Hierarchical classificationClassifies documents through deep patent, retail product, biomedical and source-code hierarchies using parallel beam search over Choice probabilitiesIntermediate
Autoresearch feature discoveryRuns a loop that proposes questions, converts free text into numeric features, and uses model errors to improve a supervised CatBoost regressorAdvanced

The confidence-based classification recipe deserves particular attention because the idea is elegant and transfers everywhere. When the model is confident, report the specific industry group. When it is not, report the broader division above it. Instead of a wrong specific answer or no answer at all, you return a correct less-specific answer. Any taxonomy with levels can do this, and it turns uncertainty into useful precision rather than a failure.

The hierarchical recipe is the one for large taxonomies. Rather than committing to a single greedy path down the tree, it runs a beam search over Choice probabilities, keeping the best K candidate paths at each level. TypeSafe's Choice documentation recommends this approach whenever you are classifying through a deep hierarchy or a large taxonomy.

The autoresearch recipe is the most ambitious and the only one labelled advanced. It uses Jev's probabilities as features for a classical machine learning model, proposing questions, turning text into numbers, and using the downstream model's errors to improve the feature set. That is also the documented answer to "can I customise Jev", since there is no fine-tuning: you train something else on its outputs.

Which Cookbooks Cover Tool Use, Formatting and Self-Consistency?

CookbookWhat it doesLevel
Function callingTurns natural-language trading requests into calls to ordinary typed functions by mapping function names and closed-set arguments to confidence-aware questionsIntermediate
Skill suggestionPicks at most one skill for an agent turn out of the 182 in Nous Research's Hermes catalogue, using two requests to rank and re-check the top candidatesIntermediate
Structure recoveryReconstructs Markdown from plain text that lost its formatting, in two requests: one stitches hard-wrapped lines back together, one classifies every block as heading, list, code or calloutBeginner
Parallel questionsRuns a 13-question regulatory briefing over the GDPR Wikipedia article to measure the cost and speed of batchingBeginner
Self-consistency: noulsRoutes uncertain probabilities to human review while keeping the underlying noul values visibleBeginner
Self-consistency: choicesAdds an uncertain outcome to moderation decisions and compares label agreement with the share of automatic actionsBeginner

The function calling recipe is the interesting one conceptually, because it treats tool selection as classification rather than generation. Function names become Choice options, closed-set arguments become their own questions, and confidence gates whether the call fires. That removes the failure mode where a generative model invents a function that does not exist or an argument the schema does not accept.

The skill suggestion recipe is one of only three in the whole documentation set that legitimately makes two requests. It ranks 182 skills in the first request, then fetches the full text of the top three and judges them again against that better evidence. It also uses a Choice and Nouls together on the same shortlist, the Choice to pick a skill and the Nouls to decide whether to suggest one at all, which is exactly the distinction TypeSafe draws between a relative and an absolute question.

The parallel questions recipe is the cheapest 10 minutes in the documentation. One batched call at 0.000497 US dollars and 0.27 seconds against 13 separate calls at 0.006090 US dollars and 2.71 seconds: 12.2 times cheaper and 10.0 times faster with no change in answers.

Which Cookbook Should You Start With in 2026?

Match the recipe to the problem you already have rather than to the one that sounds most impressive. The mapping below is by job rather than by category.

If your problem is...Start withWhy
An LLM product that sometimes says something it should notGuardrails for LLMsOne request screens input and output; thresholds live in two constants
RAG answers citing the wrong passageDouble-checking citations, then classifying RAG passagesOne verifies the output, the other improves the input
Search that returns nearly-right resultsRe-rankingPublished before and after numbers on a public dataset
A large category tree nobody can classify into reliablyClassification using confidence, then hierarchical classificationStart flat with a fallback to the parent, then go deep with beam search
Fragile regex or parsing code for dates and fieldsDate extraction and pre-parsed value extractionRegex finds candidates, the model chooses, code normalises
An agent choosing the wrong toolFunction calling, then skill suggestionTool choice as classification with a confidence gate
Moderation with too much or too little automationSelf-consistency: choicesCompares label agreement against the share of automatic actions
A cost or latency problem you cannot explainParallel questionsIt is almost always the number of calls, not the model

What Are the Common Mistakes When Copying a Cookbook in 2026?

Key Takeaways for 2026

Distk adapts these recipes to commercial workflows, which mostly means rewriting the questions for the client's domain and re-deriving every threshold against their own labelled data rather than inheriting the cookbook's.

Sources

TypeSafe Cookbooks in 2026: FAQs

How many TypeSafe cookbooks are there?

Eighteen in 2026, grouped into five categories: self-consistency, batching, how-to, extraction and classification. Each is labelled beginner, intermediate or advanced, and each is a complete worked example with a real dataset and code.

Which cookbook should I read first?

Match it to a problem you already have. For an LLM product that occasionally misbehaves, start with Guardrails for LLMs. For search that returns nearly-right results, start with Re-ranking. For an unexplained cost problem, read Parallel questions.

What does the LLM guardrails cookbook do?

Screens every message going into and out of an LLM app with one request, using a Noul per hazard plus a Score for severity. Each hazard has an action threshold and a lower review threshold, so messages pass, go to review, get blocked, or route to support.

Does TypeSafe publish accuracy results for reranking?

Yes. The reranking cookbook builds 30-passage keyword shortlists for 40 CLERC legal queries, then asks one question per query-candidate pair, and reports top-1 accuracy rising from 5 percent to 18 percent and top-10 accuracy from 38 percent to 62 percent.

How do the extraction cookbooks avoid asking the model to generate text?

They turn extraction into selection. Regular expressions or enumerated options produce candidates, and the model chooses the correct one. The date recipe treats months, days and years as small closed sets with an explicit not stated option, then assembles the date in code.

Can I copy a cookbook's thresholds?

No. Every threshold in every recipe was chosen against that recipe's dataset. Copy the structure and re-derive thresholds from your own labelled sample, because the confidence distribution on your material will differ.

Recipes are a starting point, not a deployment

Distk adapts these patterns to commercial workflows: rewriting the questions for your domain, re-deriving every threshold against your own labelled data, and deciding where a human stays in the loop.

Start the conversation →