LEX — AI Legal Platform for Law Firms

AI-powered legal analysis platform for law firms and corporate counsel.

Features

Resources

Blog Articles

Technology

Built on AWS (EC2, Bedrock Claude AI, ALB, WAF, S3, ACM, KMS). PostgreSQL, Redis, Qdrant vector database. TypeScript, React, Node.js.

Start free — 50 credits on registration. Sign up

TECH 22 min

Experimental AI Court: Simulating Legal Proceedings Across All Instances

Three separate models — judge, prosecutor, advocate — with information isolation reproduce adversarial proceedings. Instance specialization, result trees, and adversarial training on GCP.

Experimental AI Court: Simulating Legal Proceedings to Predict Outcomes


Introduction

A lawyer preparing a case for trial always tries to predict the outcome. They read case law, analyze the opponent's position, and assess the strengths and weaknesses of their own arguments. But this prediction is limited by human capacity: no lawyer can physically read all 50 million decisions in the USRCD (Unified State Register of Court Decisions), compare their case against every analogous one, and account for the tendencies of each court instance.

Lex AI LLC is designing a system that addresses this problem in a fundamentally different way. Instead of statistical analysis of "similar cases," we are building a full-scale simulation of court proceedings — an experimental AI court in which specialized models play the roles of judge, prosecutor, and advocate. Each model is trained on a corresponding data corpus, holds its own "procedural position," and argues accordingly. The result is not a number ("73% probability") but a complete simulated proceeding with arguments, counterarguments, and a reasoned decision.

An important caveat that runs throughout this article: the experimental court is a tool for prediction and preparation, not a replacement for real justice. In line with the principles described in our earlier articles on constitutional RLHF and model safety, the system does not hand down "verdicts" or "resolve cases" — it models possible scenarios to help lawyers prepare more effectively.


1. Architecture: Three Models, One Proceeding

Why Three Separate Models Instead of One

The temptation to use a single powerful model that "pretends" to be the judge, then the advocate, is understandable — it is simpler to implement. But this approach has a fundamental flaw: a single model inevitably "knows" it is arguing both sides and cannot be truly adversarial. It is like playing chess against yourself — you subconsciously favor one side.

Three separate models solve this problem through information isolation. The advocate model does not know what strategy the prosecutor model will choose. The judge model cannot see the parties' "internal notes." Each model optimizes its position independently, creating genuine adversarial dynamics — the foundation of fair adjudication enshrined in Article 129 of the Constitution of Ukraine.

The Advocate Model (LEX Advocate)

LEX Advocate is trained on a corpus of successful defense positions from the USRCD. During fine-tuning on GCP, special emphasis is placed on cases where the defense achieved a positive outcome: acquittals, case dismissals, sentence reductions, and claims granted.

The key characteristic of this model is presumptive reasoning. LEX Advocate defaults to searching for arguments in the client's favor. It is not "objective" — and that is by design, because a real advocate is not objective either. Their constitutional function (Article 59) is to ensure the most effective protection of the client's rights.

The LEX Advocate reward function evaluates the completeness of defense strategy utilization. The model receives a high reward when it identifies procedural violations a human lawyer might have missed, when it finds contradictions in the prosecution's position, or when it proposes an alternative legal qualification of the acts. A penalty is applied for missing obvious defense arguments or for arguments that contradict the client's interests.

The model operates across several strategic patterns. It may choose full denial of the case facts, acknowledgment of facts while challenging the legal qualification, procedural defense by identifying violations in evidence collection, or a soft strategy emphasizing mitigating circumstances. The choice of strategy is determined by the specific circumstances of the case and the court instance hearing it.

The Prosecutor Model (LEX Prosecutor)

LEX Prosecutor is trained on indictments upheld in court, charges sustained at trial, and claims granted by courts. Its task is to build the most persuasive prosecution or plaintiff position possible.

This model has a significant constraint built into its architecture: it operates exclusively on the evidence provided. LEX Prosecutor does not fabricate circumstances, add "probable" facts, or build arguments on assumptions. Article 62 of the Constitution directly prohibits accusations based on assumptions, and this prohibition is hardcoded into the reward model.

The LEX Prosecutor reward function evaluates the logical coherence of the prosecution's position. The model receives a high reward for a clear "fact → legal norm → conclusion" structure, for complete coverage of qualifying elements of the offense, and for anticipating defense counterarguments with prepared responses. Penalties apply for logical gaps, the use of emotional arguments instead of legal ones, or references to evidence not present in the case file.

The Judge Model (LEX Judge)

LEX Judge is the most complex of the three models. It is trained on the complete USRCD corpus with emphasis on the reasoning sections — where the judge explains why they adopted a particular position, which evidence they found persuasive, and which they rejected.

The defining feature of LEX Judge is instance specialization. In reality, it is not a single model but a family of LoRA adapters, each reflecting decision-making patterns at a specific court level.

The court of first instance assigns the greatest weight to factual circumstances and evidence. This adapter is trained on decisions of local courts and reflects their tendency toward detailed examination of evidence, witness questioning, and appointment of expert examinations. These courts work directly with the "live" facts of the case.

The appellate instance focuses on whether the court of first instance correctly applied legal norms and fully examined the evidence. This adapter is trained on appellate court decisions and reflects their approach: they rarely reassess evidence independently but carefully verify whether the first instance correctly qualified the legal relationships and whether it overlooked significant circumstances.

The cassation instance — the Supreme Court — focuses exclusively on questions of law. This adapter is trained on Supreme Court rulings and reflects their attention to consistency of judicial practice, correctness of norm interpretation, and conformity of decisions with the Supreme Court's legal positions. The cassation adapter has virtually no interest in factual circumstances — it evaluates the purity of legal logic.

The LEX Judge reward function is the most complex of the three. It evaluates the completeness of examination of both parties' arguments (the judge cannot ignore any argument), logical consistency of reasoning (each conclusion must follow from the preceding one), conformity of the decision with established practice of the relevant instance, and correct application of procedural norms. The judge receives a penalty for selectively citing parties' arguments, for conclusions that do not follow from the stated arguments, and for ignoring the Supreme Court's legal positions.


2. The Simulation Process: How the AI Court Works

Case Initialization

The user uploads case materials: a statement of claim or indictment, available evidence, and procedural documents. The system classifies the case by category (civil, criminal, administrative, commercial), determines jurisdiction, and identifies the applicable legislation.

A critically important step occurs during initialization — input data validation. The system checks the completeness of the materials provided and warns the user if essential documents are missing. Simulation on incomplete data may yield misleading results, and the system honestly reports this rather than "filling in" missing facts.

First Round: Parties' Positions

LEX Prosecutor (or the plaintiff, depending on the case type) receives the case materials and formulates its position. The model builds its arguments, cites specific legal provisions, references relevant case law, and formulates its demands.

Simultaneously and independently, LEX Advocate receives the same materials and builds a defense position. The model searches for weak points in the opponent's arguments, identifies procedural violations, selects counterarguments, and finds alternative case law.

Information isolation at this stage is absolute. The models run in separate containers on GCP, have no access to each other's intermediate outputs, and generate their positions completely independently.

Second Round: Adversarial Phase

After the initial positions are formed, the adversarial phase begins. LEX Prosecutor receives LEX Advocate's position and prepares a response to the defense's counterarguments. LEX Advocate, in turn, receives the prosecution's position and supplements its arguments.

This exchange may continue for several rounds — two to three are usually sufficient to identify the key points of contention. The system automatically detects the moment of "convergence" — when the parties begin repeating their arguments without substantial new additions. This is a natural analog of courtroom debate, when the presiding judge stops parties who have begun going in circles.

It is at this stage that the most valuable output for the user emerges: the system identifies vulnerability points in each position. If LEX Advocate cannot find a counterargument to a particular prosecution argument, that signals a weak part of the position. If LEX Prosecutor cannot refute a defense argument, that signals the argument should be reinforced.

Third Round: The Court Decision

LEX Judge receives the complete record of the adversarial phase: the parties' positions, argument exchange rounds, and the list of evidence. The model analyzes each argument, cross-references it with legal norms and case law, and formulates its decision.

The decision is generated in a format as close as possible to a real court decision: an introductory section (parties, subject of dispute), a descriptive section (chronology, parties' positions), a reasoning section (analysis of each argument with references to norms and case law), and a dispositive section (the actual decision).

The key difference from a real decision is that the reasoning section is significantly more detailed. LEX Judge explains not only why it accepted a particular position but also why it rejected the alternative. For each argument, the model indicates precisely which circumstances or legal norms were decisive. This makes the decision maximally useful for a lawyer preparing a real case.


3. Simulation Across Court Instances

Why Simulate Appeal and Cassation

A real court case rarely ends at the first instance. Approximately 20% of local court decisions are appealed, and a significant share of appellate decisions reach cassation. A lawyer preparing a case must think not only about winning at first instance but also about whether that victory will withstand challenge.

The experimental AI court models this process sequentially. After LEX Judge (first instance) renders its decision, the losing party automatically prepares an appeal. LEX Advocate or LEX Prosecutor (depending on who lost) analyzes the first-instance decision, identifies grounds for reversal, and formulates appeal arguments.

LEX Judge with the appellate adapter reviews the case differently. It does not repeat the examination of evidence but checks whether the first-instance court assessed it correctly. It focuses on whether the first instance correctly applied substantive and procedural law. The outcome may be upholding the decision, reversing it with a new decision, or remanding the case for retrial.

An analogous process occurs for the cassation instance, where LEX Judge with the cassation adapter evaluates the case exclusively through the lens of correct application of legal norms and consistency of judicial practice.

The Result Tree

The output of a full simulation is not a single verdict but a tree of possible outcomes across all instances. The user sees something like:

First instance: partially granted (70% of claims)
├── Plaintiff's appeal: decision modified, fully granted
│   └── Defendant's cassation: appellate ruling upheld
├── Defendant's appeal: decision reversed, claim denied
│   └── Plaintiff's cassation: appellate ruling reversed,
│       case remanded for new appellate review
└── No appeal: decision becomes final after 30 days

Each branch of the tree is accompanied by detailed reasoning: why exactly this outcome, which arguments proved decisive, which legal norms were applied. The lawyer can "drill down" into any branch and see the full simulation record.

Decision Stability Assessment

Based on the result tree, the system generates a decision stability index — a comprehensive assessment of how well the first-instance decision would withstand challenge. The index accounts for the number of potential grounds for reversal, the existence of conflicting Supreme Court practice on analogous issues, and typical reversal statistics for this case category.

Importantly, the stability index is not a "probability of winning." It is an assessment of the legal position's quality that helps the lawyer understand where their arguments are strongest and where they need reinforcement. The difference between "you have a 65% chance" and "your position on the statute of limitations is weak because the Supreme Court took the opposite stance in its ruling of 12 March 2024" is the difference between wasteful pseudo-precision and useful analysis.


4. Training on GCP: Technical Implementation

Infrastructure

The three models are trained on separate clusters in GCP europe-west4, ensuring both information isolation during training and compliance with data localization requirements.

LEX Advocate and LEX Prosecutor are trained on A3 instances with H100 GPUs. The base model is a fine-tuned version of LEX AI, described in our earlier articles, with further specialization through RLHF using role-specific reward models. LEX Judge requires greater computational resources due to instance specialization — three LoRA adapters are trained in parallel with regular cross-validation.

The total training cycle for the three models is estimated at 6 months. The first two months cover base training of each model on its respective corpus. The next two months involve RLHF with role-specific reward models and the start of adversarial training, where the models learn to argue against each other. The final two months focus on calibration, red teaming, and validation against real cases with known outcomes.

Adversarial Training

The most interesting training phase is when the models begin "playing" against each other. This is not simply generating individual arguments but full rounds of adversarial proceedings, the results of which are used to improve each model.

LEX Advocate and LEX Prosecutor conduct thousands of simulated cases. After each round, the system analyzes which arguments proved strongest, which defense strategies were most effective, and where the prosecution had gaps. This data becomes training examples for the next iteration.

LEX Judge is trained on the results of these contests, comparing its decisions with real court rulings in analogous cases. If the judge model systematically makes decisions that contradict established practice, that is a signal to correct the reward model.

This process has an elegant self-reinforcing property: the better LEX Advocate argues, the better LEX Prosecutor becomes (because it trains against a stronger opponent), and vice versa. LEX Judge, in turn, becomes more accurate because it works with argumentation of increasing quality.

Validation on Real Cases

Final validation is performed on a corpus of real cases with known outcomes at all instances. The system simulates the entire process "blind" (without knowledge of the actual result) and compares its prediction with what actually happened.

We do not expect or aim for 100% agreement. Real justice depends on countless factors that cannot be formalized: the personality of a specific judge, the quality of a lawyer's oral presentation, the emotional impact of case circumstances on the court. The goal is not predicting a specific outcome but identifying the strengths and weaknesses of a legal position — a preparation tool, not a prophecy.


5. Ethical Constraints and Constitutional Boundaries

This Is Not a Court

The most important ethical constraint of the system is embedded in its very name — "experimental." Article 124 of the Constitution of Ukraine is unambiguous: "Justice in Ukraine is administered exclusively by courts." No AI system, regardless of its accuracy, can render legally binding decisions. The experimental AI court is a simulation tool, much like a flight simulator models flight — it helps you prepare but does not replace the real aircraft.

This constraint is built into the interface: every simulation result is accompanied by a clear disclaimer that it has no legal force and cannot be used as evidence or grounds for legal conclusions.

The Risk of Self-Fulfilling Prophecy

There is a serious risk that AI court predictions could influence real justice. If a lawyer sees that the simulation predicts a loss, they might advise the client to settle rather than fight. If a prosecutor sees weakness in their position, they might drop charges. In each case, the prediction becomes self-fulfilling — not because it was accurate, but because people changed their behavior based on it.

To minimize this risk, the system always presents results as a range of possibilities, not a single verdict. The result tree shows that different instances may reach different decisions and that the outcome depends on the quality of the parties' arguments. This encourages the lawyer not to give up on an unfavorable prediction but to work on strengthening the weak points of their position.

Equal Access

If the AI court becomes a powerful prediction tool, the question of equitable access arises. A party with access to the simulation gains a substantial advantage over a party without it. This potentially violates the constitutional principle of equality of parties in court proceedings (Article 129).

Lex AI LLC addresses this problem through a pricing model that ensures a baseline level of access for everyone. Simple first-instance simulation is available at minimal cost or free for recipients of legal aid. Full three-instance simulation is a premium feature, but its results do not confer a "magic advantage" — they only help with better preparation, which a qualified lawyer can achieve without AI as well.

Prohibition Against Use for Coercion

The system includes a strict prohibition on using simulation results for extrajudicial pressure. A message like "the AI court predicts you will lose, so you had better pay now" constitutes a form of intimidation that violates Article 28 of the Constitution (prohibition of degrading treatment) and Article 55 (right to judicial protection).

The LEX Judge reward model is trained to recognize queries aimed at generating an "intimidating" prediction for use in negotiations. The model refuses formulations like "your chances are minimal" or "the court will undoubtedly rule against you," even when the statistics are genuinely unfavorable. Instead, it presents an analysis of the position's strengths and weaknesses, leaving the user to make their own decision.


6. Specifics of Ukrainian Justice in the Simulation

Judicial Reform and Its Impact

The Ukrainian judicial system has undergone several waves of reform: the creation of the High Anti-Corruption Court (2019), the reorganization of cassation courts within the Supreme Court, and changes to the judicial selection system. Each reform alters decision-making patterns, and the model must account for this.

LEX Judge has a "time window" mechanism: when generating a decision, the model weighs practice from recent years significantly more than practice from a decade ago. This is especially important for categories where practice has changed dramatically — for example, land disputes after the opening of the land market, or corporate disputes after the 2018 reform.

Martial Law

The martial law introduced on 24 February 2022 has significantly affected court proceedings. Changes to hearing timelines, specifics of cases involving military personnel, the peculiarities of claims for damages caused by armed aggression — the models must account for all of this.

LEX Judge has a dedicated adapter for "wartime" cases, trained on decisions rendered after 24 February 2022. This adapter is activated automatically when the case circumstances relate to the consequences of armed aggression, and it accounts for both legislative changes and trends in wartime judicial practice.

Regional Variations

Although the law is uniform across all of Ukraine, judicial practice has regional variability. Courts in different appellate circuits may interpret the same norms differently until the Supreme Court establishes a unified legal position. The simulation accounts for this variability — the user specifies the jurisdiction, and LEX Judge uses the practice of the corresponding appellate circuit for first- and second-instance decisions.

This is not bias — it is reality. A lawyer filing a claim in the Kyiv District Administrative Court needs to know the practice of that specific court and the Sixth Administrative Court of Appeal, not the national average.


7. Future Development

Integration with a Human Lawyer

The experimental AI court is designed as a tool for lawyers, not instead of lawyers. Future versions plan a mode where the lawyer can "intervene" in the simulation: replace LEX Advocate's arguments with their own and see how LEX Prosecutor and LEX Judge respond. This transforms the system from a prediction tool into an interactive training simulator — the lawyer can practice their arguments before the actual hearing.

Mediation and Alternative Dispute Resolution

Not every case should go to court. Based on the analysis of both parties' positions, the system can propose settlement options — compromises that both sides might accept. LEX Judge in a mediator role uses a different adapter, trained on successful settlement agreements and mediation practices. If both parties risk losing in court, a settlement may be the best outcome for everyone.

Simulating Constitutional Proceedings

The most ambitious direction is simulating petitions to the Constitutional Court. LEX Judge with a constitutional adapter can assess the prospects of a constitutional petition or complaint, analyze whether the challenged norm conforms to the Constitution, and predict the Constitutional Court's position based on its prior decisions. This is an extraordinarily complex task given the limited number of Constitutional Court decisions (a few hundred per year) and their qualitative difference from decisions of courts of general jurisdiction.


Conclusion

The experimental AI court is not an attempt to replace judges with robots. It is a recognition that lawyers deserve better preparation tools. A pilot does not become worse by training on a simulator — they become better. A lawyer who "lost" a simulation and saw the weak points in their position before the actual hearing has the opportunity to fix them.

Three separate models with information isolation reproduce adversarial dynamics — the foundation of fair adjudication. LEX Judge's instance specialization reflects the real hierarchy of the judicial system. The result tree shows not one "correct answer" but a spectrum of possibilities that depend on the quality of argumentation.

Article 129 of the Constitution establishes the principle of adversarial proceedings. Article 124 reserves justice exclusively for the courts. Article 59 guarantees the right to legal assistance. Lex AI LLC's experimental AI court exists at the intersection of these three principles: it implements adversarial dynamics through simulation, respects the courts' monopoly on justice, and expands access to quality legal assistance.

Justice cannot be automated. But preparation for the fight for justice — can be.


Lex AI LLC, 2026.