Ayinde v Haringey के बाद citation पर आधारित UK केस-लॉ retrieval

Ayinde v Haringey ने रातोंरात UK की legal AI का गणित बदल दिया। एक barrister ने एक LLM से बनाए गए पाँच नकली केस उद्धृत किए और उसे Bar Standards Board के पास भेज दिया गया। hallucinated citations के अब पेशेवर-आचरण संबंधी परिणाम होते हैं। यहाँ citation पर आधारित UK केस-लॉ retrieval बनाने की डेवलपर गाइड है — TNA Find Case Law, legislation.gov.uk, neutral-citation parsing, और इसे एक कार्यशील agent में कैसे जोड़ा जाए।
TL;DR
- •Ayinde v Haringey [2025] EWHC 1383 (Admin) ने hallucinated केस citations को सिर्फ़ गुणवत्ता की समस्या नहीं, बल्कि पेशेवर-आचरण का मुद्दा बना दिया।
- •BAILII की शर्तें बल्क programmatic access को सीमित करती हैं; इंग्लैंड और वेल्स के फ़ैसलों के लिए The National Archives की Find Case Law सेवा ही वैध API है।
- •legislation.gov.uk के पास point-in-time access वाली एक स्थिर Developer API है — compliance कार्य के लिए अनिवार्य, जहाँ '30 जून 2024 को प्रभावी' एक वास्तविक query है।
- •Stanford HAI के 'Hallucination-Free?' अध्ययन ने दिखाया कि Westlaw और Lexis+ AI अब भी 17–33% बार hallucinate करते हैं — citation grounding ही वास्तुशिल्प उत्तर है, कोई vendor का चयन नहीं।
- •API Pick UK Legal Search केस-लॉ और प्राथमिक विधान पर semantic retrieval को एक ही POST में समेटता है — प्रति कॉल 60 credits।
वह केस जिसने गणित बदल दिया
6 जून 2025 को King's Bench Division की Divisional Court ने एक ही निर्णय में दो फ़ैसले सुनाए — Ayinde v The London Borough of Haringey और Al-Haroun v Qatar National Bank QPSC, neutral citation [2025] EWHC 1383 (Admin)। दोनों में, वकील ने ऐसी सामग्री दाखिल की थी जिसमें ऐसी authorities उद्धृत थीं जो अस्तित्व में थीं ही नहीं; Ayinde में, पाँच गढ़े हुए केस। अदालत ने पेशेवर कर्तव्यों का उल्लंघन पाया और अधिवक्ताओं को क्रमशः BSB और SRA के पास भेजा।
48 घंटों के भीतर, UK के हर legal-tech roadmap के शीर्ष पर एक नया बिंदु आ गया: citation grounding। गुणवत्ता की सुविधा के रूप में नहीं, बल्कि एक नियामक आवश्यकता के रूप में। Stanford HAI के 'Hallucination-Free?' अध्ययन (Magesh et al., मई 2024) ने पहले ही दिखा दिया था कि अग्रणी vendor tools — Lexis+ AI, Westlaw AI — benchmark queries पर 17–33% बार citations hallucinate करते हैं। Ayinde ने उस अकादमिक निष्कर्ष को एक compliance समस्या में बदल दिया।
UK के legal उत्पादों में AI सुविधाएँ बनाने वाले डेवलपर्स के लिए, वास्तुशिल्प सीख स्पष्ट है: retrieval प्रामाणिक स्रोतों से आना चाहिए, citations स्रोत के विरुद्ध सत्यापन-योग्य होनी चाहिए, और जब system किसी उत्तर को ground न कर सके, तो उसे उत्तर देने से इनकार करना चाहिए। इसके अलावा कुछ भी एक नियामक के पास भेजे जाने का इंतज़ार है।
यहाँ इसे सही तरीके से करने की कार्यशील डेवलपर गाइड है: कौन-सी APIs का उपयोग करें, उनकी क्या ख़ामियाँ हैं, और उन्हें एक कार्यशील agent में कैसे जोड़ें।
प्रामाणिक स्रोत
1. National Archives Find Case Law
The National Archives (TNA) द्वारा संचालित। अप्रैल 2003 से High Court, Court of Appeal, UK Supreme Court, Privy Council और कई tribunals द्वारा सुनाए गए अदालती फ़ैसलों को कवर करता है। दस्तावेज़ Akoma Ntoso (LegalDocML) XML मानक में। caselaw.nationalarchives.gov.uk पर सार्वजनिक API; "computational analysis" उद्देश्यों के लिए आवेदन-आधारित bulk-data feed।
ताक़तें: इंग्लैंड और वेल्स के केस-लॉ के लिए प्रामाणिक स्रोत, संरचित XML फ़ैसले की संरचना संरक्षित रखता है (paragraph संख्याएँ, citations, headings), Open Government Licence की शर्तें attribution के साथ पुनः-उपयोग की अनुमति देती हैं। कमज़ोरियाँ: 2003 से पहले सीमित coverage, bulk feed के लिए आवेदन आवश्यक, यदि आपने कभी legal XML छुआ नहीं है तो LegalDocML को parse करना भारी है।
2. legislation.gov.uk Developer API
TNA द्वारा संचालित। UK प्राथमिक विधान (Acts of Parliament), statutory instruments, और Northern Ireland / Scottish / Welsh समकक्षों को कवर करता है। महत्वपूर्ण रूप से, point-in-time queries का समर्थन करता है: '1 अप्रैल 2018 को यह प्रावधान कैसा दिखता था'।
ताक़तें: स्थिर, अच्छी तरह से प्रलेखित, point-in-time access, OGL-licensed। कमज़ोरियाँ: schema (CLML) अपने आप में एक अलग चीज़ है; सभी संशोधन इतिहास में पीछे तक एकसमान रूप से ट्रैक नहीं किए जाते; in-force-date मॉडल आपको चौंका सकता है।
3. BAILII (मानव web के माध्यम से केवल-पढ़ने योग्य)
लंबे समय से चली आ रही विधिक सूचना aggregator। उन jurisdictions और दस्तावेज़ प्रकारों के लिए महत्वपूर्ण जिन्हें Find Case Law कवर नहीं करता (पुराने फ़ैसले, Scottish / NI सामग्री, कुछ tribunal निर्णय)। बल्क scraping BAILII की शर्तों द्वारा प्रतिबंधित है। इसे एक मानव-पठनीय बैकअप के रूप में मानें, API के रूप में नहीं।
4. API Pick UK Legal Search
एक ही POST endpoint में UK केस-लॉ और प्राथमिक विधान पर semantic search। JSON in / JSON out, प्रति कॉल 60 credits, केवल-सफलता पर बिलिंग। semantic प्रासंगिकता के अनुसार रैंक किए गए title, neutral citation, source URL, और snippet लौटाता है। AI-agent tool calling के लिए डिज़ाइन किया गया।
आमने-सामने
| Find Case Law | legislation.gov.uk | API Pick UK Legal Search | |
|---|---|---|---|
| Coverage | 2003 से E&W केस-लॉ | UK statutes + SIs, point-in-time | केस-लॉ + विधान, semantic |
| Format | Akoma Ntoso XML | CLML XML + JSON / Atom | JSON, snippet पहले से आकार में |
| Search | Keyword | Keyword + structural | Semantic |
| Auth | सार्वजनिक के लिए कोई नहीं; gated bulk feed | कोई नहीं | x-api-key |
| Licence | Open Government Licence | Open Government Licence | API Pick TOS |
| उपयुक्तता | compliance-स्तर का source-of-truth | statute lookup, point-in-time queries | AI-agent retrieval, RAG परत |
वह वास्तुकला जो Ayinde के बाद टिकती है
न्यूनतम व्यवहार्य citation-आधारित stack:
Question → [LLM agent]
↓ tool_use(uk_legal_search)
[API Pick UK Legal Search] → ranked authorities
↓ tool_use(extract_urls)
[API Pick URL Extract] → full judgment / statute body
↓ Agent reads, drafts answer
↓ Citation-required prompt rule
Answer with [Neutral Citation, Section/Paragraph]
↓ Final verification pass
Refuse if citation can't be matched in extracted textverification pass वही जगह है जहाँ अधिकांश टीमें विफल होती हैं। मॉडल से 'अपने स्रोत उद्धृत करो' कहना पर्याप्त नहीं है — आपको programmatically सत्यापित करना होगा कि हर उद्धृत authority extracted text में दिखाई देती है। यदि नहीं दिखती, तो उत्तर को अस्वीकार करें या मानव समीक्षा के लिए सामने लाएँ।
कार्यशील कोड
import re, requests
from anthropic import Anthropic
KEY = "pk_yourkey"
client = Anthropic()
def fetch_tool(path: str) -> dict:
return requests.get(f"https://www.apipick.com{path}/tool-schema").json()["claude"]
TOOLS = [
fetch_tool("/api/search/uk-legal"),
fetch_tool("/api/extract"),
]
SYSTEM = """You are a UK legal research assistant. You answer questions about
England & Wales case law and UK primary legislation using the tools available.
Rules — non-negotiable:
1. Use uk_legal_search to find authorities relevant to the question.
2. For authorities you intend to cite, use extract_urls to retrieve the
full text. Do not cite anything you have not extracted.
3. Cite every legal proposition with a neutral citation in standard form:
[YYYY] EWHC|EWCA|UKSC NNN (Court), §[paragraph] — for cases.
Section N(M) of the [Act Name] YYYY — for statutes, with point-in-time
noted if relevant.
4. If the search returned no relevant authority, or the relevant text was
not extracted, say so explicitly: "I could not retrieve a sufficient
authority for this question. Please escalate to qualified counsel."
Do not infer from training-data knowledge.
5. Distinguish ratio from obiter where it matters. Note when an authority
is first instance, appellate, or Supreme Court.
6. For legislation, default to the in-force version. State the date you used.
7. This output is informational retrieval, not legal advice."""
def call_tool(b):
paths = {"uk_legal_search": "/api/search/uk-legal", "extract_urls": "/api/extract"}
r = requests.post(
f"https://www.apipick.com{paths[b.name]}",
json=b.input,
headers={"x-api-key": KEY},
timeout=60,
)
return {"type": "tool_result", "tool_use_id": b.id,
"content": r.text, "is_error": r.status_code != 200}
NEUTRAL_CITATION = re.compile(r"\[(\d{4})\]\s+(EWHC|EWCA|UKSC)\s+\d+")
def verify_citations(answer: str, extracted_text: str) -> list[str]:
"""Return list of citations in the answer that don't appear in extracted text."""
cites = NEUTRAL_CITATION.findall(answer)
return [
f"[{year}] {court}" for year, court in cites
if f"[{year}] {court}" not in extracted_text
]
def legal_research(question: str) -> str:
msgs = [{"role": "user", "content": question}]
extracted_buffer = ""
while True:
r = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=4096,
system=SYSTEM,
tools=TOOLS,
messages=msgs,
)
msgs.append({"role": "assistant", "content": r.content})
if r.stop_reason == "end_turn":
answer = "\n".join(b.text for b in r.content if b.type == "text")
unverified = verify_citations(answer, extracted_buffer)
if unverified:
return (
"REFUSED: the answer cited authorities that were not retrieved. "
f"Unverified: {unverified}. Escalate to qualified counsel."
)
return answer
if r.stop_reason == "tool_use":
results = []
for b in r.content:
if b.type != "tool_use":
continue
tr = call_tool(b)
if b.name == "extract_urls":
extracted_buffer += tr["content"]
results.append(tr)
msgs.append({"role": "user", "content": results})
print(legal_research(
"What is the test for breach of duty by a public authority "
"post Roberts v Soldiers, Sailors, Airmen and Families Association?"
))तीन चीज़ें जो यह कोड करता है और आलसी implementations नहीं करतीं: (1) किसी authority पर निर्भर होने से पहले हर उद्धृत authority का पूरा text extract के ज़रिए खींचता है, (2) ऐसे उत्तरों को अस्वीकार करता है जिनकी neutral-citation strings वास्तव में किसी retrieved text में दिखाई नहीं देतीं, (3) system prompt में 'मैं पर्याप्त authority retrieve नहीं कर सका' इनकार को पका देता है ताकि retrieval विफल होने पर मॉडल के पास एक सुंदर निकास हो।
लागत की सीमा
एक सामान्य legal-research कॉल:
- 1 search कॉल — 60 credits (~$0.06)
- 2–4 authorities को कवर करने वाली 1 extract कॉल — 4–8 credits (~$0.004–$0.008)
- ~6,000 input + 1,500 output Claude tokens — ~$0.05
गोल आँकड़ा: citations के साथ प्रति शोधित उत्तर ~$0.12। एक छोटी in-house legal टीम के लिए 100 प्रश्न/दिन पर यह $12/दिन है — किसी भी commercial legal-tech subscription की लागत से कहीं नीचे, और audit trail आपके नियंत्रण में।
यह कहाँ सामान्यीकृत होता है
'citation grounding' का वास्तुशिल्प pattern केवल UK केस-लॉ पर ही लागू नहीं होता — यह वही pattern है जो निवेश due diligence के लिए SEC filings RAG को विश्वसनीय बनाता है और जो एक वैज्ञानिक साहित्य agent को hallucinated paper संदर्भों से बचने देता है। तीन नियम इन्हें एकजुट करते हैं:
- पहले retrieve करें, बाद में generate करें। मॉडल को कभी ऐसी citation न बनाने दें जो retrieved context में नहीं थी।
- निर्धारक रूप से सत्यापित करें। extracted text पर एक regex सस्ता है और अधिकांश गढ़ंत पकड़ लेता है।
- शालीनता से इनकार करें। मॉडल को मददगार बनने के लिए प्रशिक्षित करने से पहले system prompt को "मैं विश्वसनीय रूप से उत्तर नहीं दे सकता" कहने के लिए प्रशिक्षित करें।
Ayinde वह क्षण था जब ये नियम 'इंजीनियरिंग best practice' से बदलकर 'अपने उपयोगकर्ताओं को BSB के सामने खड़ा किए बिना UK legal AI ship करने का एकमात्र तरीका' बन गए। API Pick UK Legal Search search-परत का building block है; बाक़ी आपको जोड़ना है।
अक्सर पूछे जाने वाले प्रश्न
Ayinde v Haringey में असल में क्या हुआ था?
जून 2025 में High Court (Ritchie J) ने पाया कि वकील ने एक skeleton argument दाखिल किया था जिसमें एक LLM द्वारा बनाए गए पाँच अस्तित्वहीन केस उद्धृत थे, और इसके अलावा Al-Haroun v Qatar National Bank में एक अन्य अधिवक्ता द्वारा एक और गढ़ी हुई authority भी थी। फ़ैसले एक साथ Ayinde v Haringey & Al-Haroun v Qatar National Bank [2025] EWHC 1383 (Admin) के रूप में सुनाए गए। अदालत ने अधिवक्ताओं को Bar Standards Board और Solicitors Regulation Authority के पास भेजा। UK में जब भी 'विधिक अभ्यास में AI hallucination' का विषय उठता है, यही फ़ैसला अब मानक authority के रूप में उद्धृत किया जाता है।
क्या मैं BAILII को scrape कर सकता हूँ?
नहीं। BAILII की शर्तें बल्क programmatic access को सीमित करती हैं, और operator इस बारे में स्पष्ट रहा है — BAILII की स्थिति पर Transparency Project का दस्तावेज़ देखें। वैध मार्ग इंग्लैंड और वेल्स के फ़ैसलों के लिए The National Archives की Find Case Law सेवा है, जिसके पास एक सार्वजनिक API और एक अलग, आवेदन-आधारित bulk-data feed है।
Find Case Law और legislation.gov.uk में क्या अंतर है?
Find Case Law (caselaw.nationalarchives.gov.uk) अदालती फ़ैसलों को कवर करता है — EWHC, EWCA, UKSC और tribunal के निर्णय। legislation.gov.uk प्राथमिक और द्वितीयक विधान को कवर करता है: Acts of Parliament, statutory instruments, और (compliance कार्य के लिए महत्वपूर्ण) point-in-time ऐतिहासिक संस्करण। एक पूर्ण UK legal RAG stack को दोनों की आवश्यकता होती है।
point-in-time विधान AI agents के लिए क्यों मायने रखता है?
अधिकांश विधिक प्रश्न इस बारे में होते हैं कि किसी विशिष्ट तिथि पर कानून क्या था — कथित उल्लंघन के दिन, अनुबंध पर हस्ताक्षर की तिथि, जिस समय किसी एजेंसी ने निर्णय लिया। विधान का वर्तमान संस्करण लौटाना किसी भी ऐतिहासिक प्रश्न के लिए ग़लत उत्तर देता है। legislation.gov.uk के /data.feed?type=ukpga&prospective=true-शैली के endpoints इसका समाधान करते हैं। तिथियाँ hallucinate करने वाले अधिकांश AI legal tools इसलिए विफल होते हैं क्योंकि उन्होंने इसे जोड़ा नहीं।
क्या यह output विधिक सलाह मानी जाती है?
नहीं। किसी भी retrieval API (हमारी सहित) का output सूचनात्मक retrieval है, विधिक सलाह नहीं। इंग्लैंड और वेल्स में अभ्यास करने वाले solicitors और barristers SRA / BSB के आचरण नियमों से बँधे रहते हैं। यह पोस्ट जिस वास्तुकला का वर्णन करती है, वह योग्य विधिक समीक्षा को सहायता देने के लिए बनाई गई है — उसकी जगह लेने के लिए नहीं। Ayinde का precedent इस अंतर को non-negotiable बनाता है।
इस लेख में उपयोग की गई APIs
Sarah Choy, API Pick की CEO हैं। वे AI एजेंट्स और LLM वर्कफ़्लो के लिए प्रोडक्शन-रेडी APIs बनाने के बारे में लिखती हैं।