lmaf / README.md
Lexai
refactor: rename LegalIntern to LMAF (Legal Multi-Agent Framework) (#1)
3bd9d04 unverified
|
Raw
History Blame
6.4 kB
metadata
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

  1. No agent carries conversation history -- each call starts from a fresh context with the current ConsultationState rendered as text. This prevents context contamination and allows any agent to be swapped or retried independently.

  2. Structured state -- ConsultationState tracks hypotheses, evidence, critiques, and their relationships. Agents mutate state via typed operations, not free-form text.

  3. Git-versioned workspace -- every iteration creates a commit, making the full research process reproducible and auditable.

  4. 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

Related Papers

License

Apache-2.0