Lesson 28.4 · 4 of 7 · 5 min read · Reviewed 24 Nov 2026
When to use an open model next to a hosted one
By the end, you can
- Design systems that use an open model next to Claude.
- Choose which work goes where.
Common hybrid patterns
| Pattern | Open model does | Claude does |
|---|---|---|
| Privacy filter | Detects and masks personal data locally | Answers using the masked text |
| Cheap triage | Classifies or routes high-volume requests | Handles the hard ones |
| Embeddings | Embeds documents on your own servers | Answers from retrieved chunks (Part 4) |
| On-device | Runs offline features on a phone or laptop | Handles online, heavier requests (30.5) |
| Draft and check | Drafts simple outputs | Reviews or escalates uncertain cases |
Design rules
- Decide by data class first. Mark which data may leave your environment, and route on that.
- Then by difficulty. Easy and high-volume to the small model; hard to Claude (71.2).
- Keep a fallback. If the local model is unsure or down, send the safe version to Claude, or to a person.
- Log the route each request took, so you can debug and measure (chapter 67).
Evaluate the whole chain
A redactionRedaction: Removing or masking sensitive data, such as PII or secrets, before it is stored, logged or sent. step that misses names is a privacy bug, however good the final answer looks. Test each stage on its own (recall of the redactor, accuracy of the triage) and test the end-to-end result.
Costs you take on
Running your own model means GPUs, scaling, patching and monitoring. Count that operational cost against any per-token savings (chapter 71).
Key points
- Open models and Claude often work together: each handles the work it suits best.
- Common splits: a small local model for redaction, classification or embeddings; Claude for reasoning, writing and agents.
- Routing by data sensitivity keeps private data local while sending safe, hard tasks to Claude.
- Evaluate each part separately and watch the handoffs between them.
Route requests by data class
Build a small router that masks personal data locally, sends safe hard tasks to an API model, and falls back to a person when unsure.
You will have: A router function plus a log line per request showing the route it took and the text that left your network.
Steps
- Write a redactor that masks emails and phone numbers with simple regular expressions.
- Write a router: simple requests go to the local model; hard ones go to the API model after redaction.
- If the local model's confidence is below a threshold, route to a person.
- Log each request's route and the exact text sent outside.
- Check that no email address appears in any text sent outside.
Done when
- Every request prints one route= line.
- No outgoing text contains an @ sign.
- The low-confidence request is routed to a person.
Open in the Playground No API key needed.
Starter code (Python)
import re
REQUESTS = [
{"text": "Where is my order? Email me at jo.lee@example.com", "hard": False, "local_conf": 0.92},
{"text": "I was charged twice and my bank says call 0700 900 123. Please explain what happened.", "hard": True, "local_conf": 0.88},
{"text": "Something odd with my account, jo.lee@example.com", "hard": False, "local_conf": 0.41},
]
def redact(text):
# TODO: mask emails as [EMAIL] and phone numbers (digits and spaces, 9+ digits) as [PHONE]
return text
def route(req):
# TODO: return (route_name, text_sent_outside or None)
return "unknown", None
for r in REQUESTS:
name, sent = route(r)
print(f"route={name:6} sent_outside={sent!r}")
Show a solution
import re
REQUESTS = [
{"text": "Where is my order? Email me at jo.lee@example.com", "hard": False, "local_conf": 0.92},
{"text": "I was charged twice and my bank says call 0700 900 123. Please explain what happened.", "hard": True, "local_conf": 0.88},
{"text": "Something odd with my account, jo.lee@example.com", "hard": False, "local_conf": 0.41},
]
EMAIL = re.compile(r"[\w.+-]+@[\w-]+\.[\w.]+")
PHONE = re.compile(r"\b\d[\d ]{7,}\d\b")
def redact(text):
return PHONE.sub("[PHONE]", EMAIL.sub("[EMAIL]", text))
def route(req):
if req["local_conf"] < 0.6:
return "person", None
if not req["hard"]:
return "local", None
return "api", redact(req["text"])
outside = []
for r in REQUESTS:
name, sent = route(r)
if sent:
outside.append(sent)
print(f"route={name:6} sent_outside={sent!r}")
print("emails sent outside:", sum("@" in s for s in outside))