Spaces:
Sleeping
title: LMAF
emoji: ⚖️
colorFrom: blue
colorTo: indigo
sdk: gradio
sdk_version: 5.31.0
app_file: app.py
pinned: true
license: apache-2.0
tags:
- legal-nlp
- multi-agent
- ukraine
- court-decisions
- legal-consultation
LMAF -- Legal Multi-Agent Framework
A multi-agent framework for complex legal consultations over Ukrainian court decisions and legislation.
Built for the legal domain with access to 100M+ Ukrainian court decisions via SecondLayer.
Architecture
Nine specialised LLM agents work in a loop, each starting from a fresh context (no conversation history). All state lives in a structured ConsultationState object. The workspace is git-versioned for full reproducibility.
┌─────────────┐
│ Client │
│ Question │
└──────┬──────┘
│
┌──────▼──────┐
│ Surveyor │ Maps legal landscape (once)
└──────┬──────┘
│
┌──────▼──────┐
│ Planner │ Research strategy
└──────┬──────┘
│
┌────────────▼────────────┐
│ Orchestrator │ Dispatches tasks
└───┬─────────────────┬───┘
│ │
┌──────▼──────┐ ┌──────▼──────┐
│ Researcher │ │ Analyst │
│ (case law, │ │ (deadlines, │
│ legislation)│ │ penalties) │
└──────┬──────┘ └──────┬──────┘
│ │
┌───▼─────────────────▼───┐
│ Reviewer │ Adversarial verification
└────────────┬────────────┘
│
┌────────────▼────────────┐
│ Critic (periodic) │ Strategy audit
└──────┬──────────┬───────┘
│ │
┌──────▼──┐ ┌────▼────────┐
│ Planner │ │ Adjudicator │ Resolve disputes
│(revise) │ └─────────────┘
└─────────┘
│
┌────────────▼────────────┐
│ Formatter │ Final consultation
└─────────────────────────┘
Agent Roles
| Agent | Role | secondlayer-core Equivalent |
|---|---|---|
| Surveyor | Maps legal landscape, identifies relevant areas of law | IntentClassifier + QueryPlanner |
| Planner | Produces/revises research strategy | ExecutionPlan generation |
| Orchestrator | Dispatches tasks, formulates hypotheses | ChatService agentic loop |
| Researcher | Finds case law, legislation, doctrine via SecondLayer MCP | Tool calls (search, legislation) |
| Analyst | Computes deadlines, penalties, procedural checks | Calculation tool calls |
| Reviewer | Adversarial verification of evidence | CitationValidator + HallucinationGuard |
| Critic | Periodic strategy and coherence audit | New capability |
| Adjudicator | Resolves inter-agent disagreements | New capability |
| Formatter | Produces structured legal consultation | Response synthesis |
Key Design Decisions
No agent carries conversation history -- each call starts from a fresh context with the current
ConsultationStaterendered as text. This prevents context contamination and allows any agent to be swapped or retried independently.Structured state --
ConsultationStatetracks hypotheses, evidence, critiques, and their relationships. Agents mutate state via typed operations, not free-form text.Git-versioned workspace -- every iteration creates a commit, making the full research process reproducible and auditable.
SecondLayer MCP bridge -- agents access 100M+ court decisions, legislation, and Supreme Court positions through the SecondLayer API.
Quick Start
# Install
pip install -e .
# Set API keys
export ANTHROPIC_API_KEY=sk-...
export SECONDLAYER_API_KEY=...
# Run a consultation
lmaf "Чи може продавець стягнути пеню за прострочення оплати товару?"
# Run from a problem file
lmaf problems/consumer_penalty.yaml
Example Problems
| Problem | Difficulty | Description |
|---|---|---|
consumer_penalty.yaml |
Medium | Penalty and interest calculation for late payment |
labor_dismissal.yaml |
Hard | Challenging unlawful dismissal during martial law |
property_dispute.yaml |
Hard | Property rights in unregistered partnership |
Data Sources
- EDRSR -- 100M+ Ukrainian court decisions
- Verkhovna Rada -- Ukrainian legislation
- overthelex/ua-case-outcome-6m -- 6.7M court decisions dataset
- overthelex/ukrainian-court-decisions -- 428K balanced benchmark
Related Papers
- Temporal Decay of Co-Citation Predictability
- A Citation Graph from 100M Court Decisions
- Tokenizer Fertility and Zero-Shot Performance on Ukrainian Legal Text
License
Apache-2.0