LLM — Domain-Trained Legal AI
The reason XS Lawyer exists. Off-the-shelf chatbots hallucinate when asked about Egyptian Civil Code or Personal Status Law — we built an NLP pipeline trained on Egyptian Constitution, Civil Code, Commercial Law and case precedents, with citation enforcement to cut hallucinations and a document-analysis layer that turns uploaded contracts into plain-language explanations in Arabic or English.
Every section, explained.
5 working sections inside LLM — Domain-Trained Legal AI — each one a screen we designed, built and tested in the live system.
Egyptian Legal Corpus
A curated and cleaned knowledge base spanning the Egyptian Constitution, Civil Code, Commercial Law, Criminal Law, Family / Personal Status Law and Labor Law — each source indexed by article, paragraph and amendment date so the model can cite back to a specific statutory anchor.
- Constitution, Civil, Commercial, Criminal, Family, Labor
- Indexed by article + paragraph + amendment date
- Bilingual EN / AR source pairs where available
- Versioned corpus with audit trail per source
Citation Enforcement Pipeline
The hallucination-cut layer. Every model answer is post-processed against the corpus: if the citation can't be matched to an article in the knowledge base, the answer is downgraded to "uncited reasoning" and flagged in the UI — so a user can always tell what's grounded and what isn't.
- Post-generation citation match against the corpus
- Uncited answers downgraded and flagged in the UI
- Citation schema baked into the response format
- Prompt-eval suite over ~200 real legal questions
Document Analysis — Contracts & PDFs
Users drop a contract PDF into the chat and the system extracts clauses, flags risk language (auto-renewal, exclusive jurisdiction, unilateral amendments), and explains them in plain Arabic or English — with quota metering tied to each plan's file allowance.
- PDF parsing + clause extraction
- Risk-language flagging (renewal, jurisdiction, etc.)
- Plain-language explanations in EN or AR
- Per-plan file quota enforced at upload
Multilingual EN / AR Chat
The conversational surface — streaming responses, mid-thread language switching (a user can ask in Arabic and request the answer in English on the same turn), and a citation panel that renders the cited articles inline next to each answer.
- Streaming responses with token-level rendering
- Mid-thread EN ↔ AR language switching
- Inline citation panel beside every answer
- Conversation history persists per subscription
Credit-Based Usage Metering
Every chat message decrements a credit and every file upload counts against the file quota — metered at the chat layer, enforced against the Features (entitlements) module in the admin, and surfaced live on the conversation header so the user always knows where they stand.
- Per-message credit decrement at the chat layer
- Per-upload file quota enforced against Features module
- Live credit + file counters pinned to the header
- Soft-block + upgrade CTA when a quota runs out
Jump to another chapter
Need a llm — domain-trained legal ai like this?
If your product is a model wrapped in a Notion doc, that's exactly the gap we close — billing, admin, multilingual, security, and all. Let's talk.