:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(ml_inference): retire kev's date facts from the serving package (#106234)
Robbie13ca332b57d1
diff --git a/products/ml_inference/packages/kev-vllm/README.md b/products/ml_inference/packages/kev-vllm/README.mdindex 206600d4bd26..2572790d3607 100644--- a/products/ml_inference/packages/kev-vllm/README.md+++ b/products/ml_inference/packages/kev-vllm/README.md@@ -42,6 +42,8 @@ curl -s localhost:8000/pooling -H 'content-type: application/json' -d '{"model":The answer is under `data.answers`, in Kev's format for either model, with `data.probabilities_raw` alongside for parity checks. JevK5 takes at most 16 options per question and 16,384 tokens per prompt, and refuses more.+The AI gateway states the day counts between the dates in a state when a request sets `date_facts` (PostHog/ai-gateway#505), before any host sees it, so this plugin does no date preprocessing of its own.+Prefix caching is off for both models: vLLM does not enable it for pooling models on hybrid backbones, so every row recomputes its state. Batching across rows and requests still applies.## Container imagediff --git a/products/ml_inference/packages/kev-vllm/kev_vllm/kev_compat.py b/products/ml_inference/packages/kev-vllm/kev_vllm/kev_compat.pyindex 91e130eccf94..8bc0c0e22b4d 100644--- a/products/ml_inference/packages/kev-vllm/kev_vllm/kev_compat.py+++ b/products/ml_inference/packages/kev-vllm/kev_vllm/kev_compat.py@@ -12,7 +12,6 @@ stays trivial.import jsonimport re-from datetime import datetimefrom typing import Any, Literal, Unionfrom pydantic import BaseModel, Field, model_validator@@ -145,40 +144,6 @@ def option_text(name: str, desc: JSONContent) -> str:return name if desc is None or desc == "" else f"{name}: {render(desc)}"-MONTHS = "January|February|March|April|May|June|July|August|September|October|November|December"---_DATE = re.compile(rf"\b(?:{MONTHS}) \d{{1,2}}, \d{{4}}\b|\b\d{{4}}-\d{{2}}-\d{{2}}\b")---def date_facts(text: str) -> str:- """Deterministic date arithmetic for the model: every pair of absolute dates found in `text`, as one sentence each- ("August 3, 2026 is 12 days after July 22, 2026."). The model cannot subtract dates reliably (issue #8); it can use a- stated day count. Returns "" when fewer than two dates are found. Dates are listed in order of first appearance."""- found = []- for m in _DATE.finditer(text):- raw = m.group(0)- try: d = datetime.strptime(raw, "%B %d, %Y") if "," in raw else datetime.strptime(raw, "%Y-%m-%d")- except ValueError: continue- if raw not in [r for r, _ in found]: found.append((raw, d))- facts = []- for i in range(len(found)):- for j in range(i + 1, len(found)):- n = (found[j][1] - found[i][1]).days- facts.append(f"{found[j][0]} is {abs(n)} day{'s' if abs(n) != 1 else ''} {'after' if n > 0 else 'before'} {found[i][0]}." if n else f"{found[j][0]} is the same day as {found[i][0]}.")- return " ".join(facts)---def with_date_facts(state):- """State with a `date_facts` field (object states) or an appended paragraph (string states) when two or more absolute- dates appear. Opt-in preprocessing (KEV_DATE_FACTS=1 in kev.serve, --date_facts in kev.benchmark)."""- facts = date_facts(render(state))- if not facts: return state- if isinstance(state, dict): return {**state, "date_facts": facts}- if isinstance(state, list): return state + [{"date_facts": facts}]- return f"{state}\n\ndate_facts: {facts}"--def question_keys(qtype: str, criteria) -> list[str]:"""The keys a question's probabilities are reported under, in option order: the criteria names (choice),["false", "true"] (noul), the level indices as strings (score). Labels, targets and anchors use the same keys."""