← Back to work
xAI · 2025

Agentic legal assistant

Sensitive entities masked before the model ever sees them, with answers grounded in domain documents.

  • LangChain
  • NER masking
  • RAG
  • FastAPI
  • React
  • TypeScript
Problem

Legal documents are exactly the place an LLM shouldn't guess, but they're also full of names, dates, and case-specific detail that can't be sent to a model carelessly, and multi-step legal reasoning breaks down fast if the system loses track of what it's already established.

The interaction decision

Mask sensitive entities before anything reaches the model, so privacy isn't a policy promise, it's structurally true of the pipeline. Ground every claim in retrieved source documents rather than model memory, so a user can trace an answer back to the passage it came from instead of taking it on faith.

Architecture

LangChain-orchestrated multi-step reasoning, NER-based masking as a pre-processing stage ahead of any model call, and retrieval-augmented generation over a domain document corpus. Python and FastAPI backend; a React and TypeScript interface built to surface the multi-step reasoning and citations rather than hide them behind a single chat bubble.

What shipped

A production conversational assistant for legal workflows that reasons across multiple steps while keeping sensitive data out of the model path entirely.