---
title: "Ontologie juridique IA : comment un graphe de connaissances a réduit de 97% les coûts de l'IA juridique"
url: https://www.haqq.ai/fr/blog/legal-ontology-ai-cost-reduction
locale: fr
type: blog
description: "Une ontologie du droit du travail mexicain a remplacé 300 outils MCP par 7 et fait passer le coût par message de 0,60 à 0,02 $. Méthode, données de Stanford, plan."
category: "ai-legal-tech"
keywords: "legal ontology, legal ontology AI, reduce legal AI cost, legal AI cost per query, legal knowledge graph, ontology vs RAG legal, MCP tools legal AI, MCP tool count cost, Mexican labor law AI, Ley Federal del Trabajo AI, legal AI hallucination rate, Stanford legal RAG hallucination study, Arabic legal ontology, UAE labour law ontology, how to build a legal ontology"
published: 2026-04-01
updated: 2026-10-20
english_version: https://www.haqq.ai/blog/legal-ontology-ai-cost-reduction
source: src/data/blogPosts.ts
generator: scripts/generate-page-markdown.ts
---

# Ontologie juridique IA : comment un graphe de connaissances a réduit de 97% les coûts de l'IA juridique

Une ontologie du droit du travail mexicain a remplacé 300 outils MCP par 7 et fait passer le coût par message de 0,60 à 0,02 $. Méthode, données de Stanford, plan.

> **Note:** In short: a legal ontology built by Dynamic Interfaces for Mexican labour law replaced 300 MCP tools with 7, and its cost per message fell from $0.60 to $0.02, a 97% drop. The saving comes from about 88,000 fewer tool-description tokens per request plus a cheaper model the smaller tool set allowed.

> **Note:** **Method.** System examined: Dynamic Interfaces' legal ontology for Mexican federal labour law, which we explored through its MCP server in March 2026. Corpus: 4 federal laws, 1,689 articles, 11 entity types, 7 judicial precedents, 12 typed cross-reference kinds, 10 enum taxonomies. Tools exposed to the model: about 300 before (one per database operation), 7 after (one per legal operation). Tool descriptions in context: about 90,000 tokens before, about 2,100 after (roughly 300 tokens per tool). Cost per message: $0.60 before, $0.02 after, as measured and reported to us by Dynamic Interfaces; the $0.02 figure also reflects a move from a frontier model to a cheaper open-weight one. HAQQ did not re-run the cost measurement independently.

## Key facts

- Ontology cost result: 300 tools to 7, $0.60 to $0.02 per message (Dynamic Interfaces, reported to HAQQ, March 2026).
- Tool-count research: RAG-MCP, which passes the model only the tool descriptions it retrieves, raised tool-selection accuracy from 13.62% to 43.13% and cut prompt tokens by more than 50% (Gan and Sun, arXiv:2505.03275, May 2025).
- Legal RAG hallucinations: a preregistered Stanford RegLab and HAI study found that Lexis+ AI, Westlaw AI-Assisted Research and Ask Practical Law AI each hallucinated between 17% and 33% of the time, less often than GPT-4 (Magesh et al., Journal of Empirical Legal Studies 22:216, April 2025).
- Harvey was valued at $15.5 billion after a $550 million round announced on 9 September 2026 (Harvey blog; TechCrunch, 9 Sep 2026).
- Mexico 2026 reference values: general minimum wage MXN 315.04 a day; UMA MXN 117.31 a day, in force from 1 February 2026 (CONASAMI and INEGI figures, as reported Jan 2026).
- Target corpus for HAQQ: UAE Federal Decree-Law No. 33 of 2021 on the regulation of labour relations has 74 articles, in force since 2 February 2022 (UNEP LEAP legislation database, read 20 Oct 2026).

## How did we come across this system?

In March 2026 I joined a call with the CEO of Dynamic Interfaces to see a legal ontology they had built for Mexican labour law. They told us five Mexican government customers use it daily, and that court-appointed expert witnesses (peritos) query four federal statutes through it and get answers with article-level citations. The number that made me spend the next two weeks inside it was the cost: two cents per message.

For a sense of scale, the per-seat legal AI market is priced in hundreds of dollars a month, and its leader, Harvey, was valued at $15.5 billion in September 2026. A two-cent message changes who can afford legal AI. This post is what I found when I connected to their MCP server, read the data model and tested it against the legal reasoning I would expect from a careful labour lawyer.

> **Note:** **Disclosure.** HAQQ sells legal AI, and at the time of writing we were exploring an integration with Dynamic Interfaces. Their cost figures are their own measurements; we report them with that label.

## What does the Stanford study say about legal AI hallucinations?

Magesh, Surani, Dahl, Suzgun, Manning and Ho, at Stanford's RegLab and the Stanford Institute for Human-Centered AI, ran what they describe as the first preregistered evaluation of AI legal research tools. Published in the Journal of Empirical Legal Studies in April 2025, it found that the RAG-based tools from LexisNexis and Thomson Reuters each hallucinated between 17% and 33% of the time. Retrieval reduced hallucinations compared with GPT-4, and the tools differed a lot: Lexis+ AI answered 65% of queries accurately, Westlaw AI-Assisted Research 42%.

The study tested three products on US law in 2024. It does not show that every RAG system hallucinates at that rate, and it does not test ontologies. What it does show is that retrieval over text, on its own, left a measurable error rate in tools sold as reliable. That is the gap a structured model of the law tries to close. For court cases where fabricated citations reached a judge, see our [hallucination audit](https://www.haqq.ai/blog/ai-legal-hallucination-audit).

## Why does RAG struggle with statutes?

Most legal AI products retrieve passages: they chunk documents, embed them and fetch the chunks closest to the question. That works for many questions. On statute-heavy work it fails in three predictable ways.

### Versions over time

A chunk of an article carries no date. Mexico's "Vacaciones Dignas" reform, published in the Diario Oficial de la Federación on 27 December 2022, amended Articles 76 and 78 of the Ley Federal del Trabajo and raised the first-year vacation entitlement from 6 to 12 days from 2023. A perito valuing a dismissal that spans the change needs both versions and the date each applied. Plain retrieval has no field for that.

### Hierarchy

Law is layered: constitution, federal law, regulations, then titles, chapters, articles and fractions inside each law. Chunking flattens it. When one article applies "in the terms of" another, a retriever can return the first without the second.

### Cross-references

Article 162 of the Ley Federal del Trabajo (seniority premium of 12 days' wages per year of service) takes its salary base from Articles 485 and 486, which cap it at twice the minimum wage. Getting the number right means following that chain. Similarity search returns fragments; a graph walks the links.

## What is a legal ontology?

A legal ontology is a machine-readable model of a body of law: its entities (laws, articles, courts, precedents, computed values such as wage caps), the hierarchy between them, the dates each version applied, and typed links between provisions. A model answering a question queries that structure instead of searching loose text.

In the Dynamic Interfaces system each cross-reference has a type: remite_a (refers to), complementa (complements), modifica (amends), excepciona (creates an exception), define_termino (defines a term), establece_formula (sets a formula) and establece_procedimiento (sets a procedure). The exception type matters most to me. Article 5 of the LFT sets general rights, and special work regimes carve out exceptions. A system that does not record exceptions will apply the general rule where the special one governs.

## How much does a legal ontology reduce AI costs?

Per Dynamic Interfaces' measurement, from $0.60 to $0.02 per message. Two things produce the drop, and it helps to keep them apart.

### Fewer tool descriptions in every request

The usual way to build an agent is to expose each database operation as a tool. Across 11 entity types that reaches about 300 tools, and every tool description is sent to the model with every request: at roughly 300 tokens each, about 90,000 tokens before the user has asked anything. The ontology replaces them with 7 legal operations: query_legal_knowledge, calculate_settlement, find_jurisprudencia, get_cross_references, get_wage_data, get_vacation_table and generate_dictamen. That is about 2,100 tokens of descriptions, a saving of roughly 87,900 tokens per request.

This matches published research. In the RAG-MCP paper, showing the model only the relevant tools instead of all of them more than tripled tool-selection accuracy (13.62% to 43.13%) and cut prompt tokens by more than half.

### A cheaper model can do the job

With 7 clear tools, the model's task is smaller: understand the question, pick one to three tools, and write up structured results. The ontology does the structural work. That let Dynamic Interfaces move from a frontier model to a cheaper open-weight one, which accounts for much of the remaining saving.

### What the saving means for a perito

Take a perito laboral in Mexico City earning roughly MXN 15,000 to 30,000 a month (the range we were given), handling 50 cases a month at 20 messages each. At $0.60 a message, that is $600 a month, about MXN 10,800 at 18 pesos to the dollar, or 36% to 72% of income. At $0.02 it is $20, about 1.2% to 2.4%. The lower price opens a market that the higher one rules out.

## Which reference unit applies: UMA or minimum wage?

Since the constitutional reform of January 2016, Mexico has two reference units: the UMA (Unidad de Medida y Actualización) and the minimum wage. In 2026 the general minimum wage is MXN 315.04 a day and the UMA MXN 117.31, a ratio of about 2.69. For the seniority-premium cap under Articles 162, 485 and 486, twice the minimum wage gives MXN 630.08 a day and twice the UMA gives MXN 234.62, 62.8% less.

Calculators and commentators in Mexico do not all apply the same unit to this cap, so this is a choice a lawyer has to make and defend. A retrieval system leaves that choice to the model on every query. An ontology records which unit the firm applies to which concept, and the authority for it, so the choice is visible and the same every time.

## Can a legal ontology work in other jurisdictions?

The building blocks recur everywhere: hierarchical legislation, subject tags, cross-reference graphs, versions over time and computed values. Civil-law systems with codified statutes (France, Brazil, Saudi Arabia, the UAE) map most directly. Hudson de Martim's SAT-Graph RAG paper applies a similar structural and temporal model to the Brazilian Constitution. Common-law systems need case law treated as a first-class entity beside statutes.

## What is HAQQ building with this?

We are building a UAE labour-law ontology, starting with Federal Decree-Law No. 33 of 2021 (74 articles) and its implementing regulation. Saudi Arabia's Labor Law, issued by Royal Decree No. M/51 of 1426H, is about 245 articles. Corpora of that size can be modelled and checked by lawyers in weeks. Because the ontology hands the model structured data, the model synthesises in Arabic or English instead of extracting rules from Arabic text, which is the harder task. The ontology will feed HAQQ's [legal research](https://www.haqq.ai/product/legal-research) on UAE labour questions.

Governments are moving the same way. The EU's European Legislation Identifier (ELI), agreed by the Council in 2012, gives legislation stable machine-readable identifiers, and New Zealand's Better Rules work drafts policy as plain language, rules and code together.

## How do you build a legal ontology?

For one country's labour law, our working estimate is 4 to 8 weeks. These are the steps we follow:

- Identify the 3 to 5 primary statutes and their official sources, and check how machine-readable each is.
- Design the entity model. Start from a general template (Law, StructuralUnit, Article, CaseLaw, CrossReference, ComputedValue) and add what the jurisdiction needs.
- Define the taxonomies: 15 to 25 subject tags, the cross-reference types and the computed-value types.
- Parse the laws, keep the hierarchy and version dates, tag articles by subject (a model can draft tags; a lawyer approves them) and load them into a database.
- Build the cross-reference graph: explicit references first, then references between laws, with every edge typed and reviewed.
- Expose a small set of tools over MCP, for example search articles, get article, get cross-references, get case law, compute value, get timeline and compare jurisdictions.
- Measure before and after: tool tokens per request, cost per message, and accuracy on a test set of questions with lawyer-approved answers.

## References

- [Magesh et al., Hallucination-Free? Assessing the Reliability of Leading AI Legal Research Tools, Journal of Empirical Legal Studies 22:216 to 242 (2025)](https://doi.org/10.1111/jels.12413)
- [Gan and Sun, RAG-MCP: Mitigating Prompt Bloat in LLM Tool Selection via Retrieval-Augmented Generation, arXiv:2505.03275](https://arxiv.org/abs/2505.03275)
- [de Martim, An Ontology-Driven Graph RAG for Legal Norms, arXiv:2505.00039](https://arxiv.org/abs/2505.00039)
- [Harvey raises $550M at a $15.5B valuation (Harvey blog, 9 Sep 2026)](https://www.harvey.ai/blog/harvey-raises-dollar550m-at-a-dollar155b-valuation-to-help-legal-teams-own-their-intelligence)
- [Harvey hits $15.5B valuation months after reaching $11B (TechCrunch, 9 Sep 2026)](https://techcrunch.com/2026/09/09/harvey-hits-15-5b-valuation-months-after-reaching-11b/)
- [Anthropic: donating the Model Context Protocol to the Agentic AI Foundation (9 Dec 2025)](https://www.anthropic.com/news/donating-the-model-context-protocol-and-establishing-of-the-agentic-ai-foundation)
- [UAE employment laws and regulations in the private sector (u.ae), incl. Federal Decree-Law No. 33 of 2021](https://u.ae/en/information-and-services/jobs/employment-in-the-private-sector/employment-laws-and-regulations-in-the-private-sector)
- [Federal Decree-Law No. 33 of 2021 (UNEP LEAP legislation database)](https://leap.unep.org/en/countries/ae/national-legislation/federal-decree-law-no33-2021-regarding-regulation-employment)
- [Ley Federal del Trabajo (Cámara de Diputados)](https://www.diputados.gob.mx/LeyesBiblio/pdf/LFT.pdf)

## Related reading

- [where AI hallucinations have reached a court](https://www.haqq.ai/blog/ai-legal-hallucination-audit)
- [why Arabic legal AI struggles with retrieval](https://www.haqq.ai/blog/arabic-legal-ai)
- [our frontier-model legal benchmark, updated October 2026](https://www.haqq.ai/blog/best-ai-for-legal-work-benchmark)
- [legal engineering and the TIRO pattern](https://www.haqq.ai/blog/legal-engineering-ai-powered-legal-workflows-guide)

## Questions fréquentes

### Qu'est-ce qu'une ontologie juridique ?

Une ontologie juridique est un modèle lisible par machine d'un corpus de droit : ses entités (lois, articles, précédents, valeurs calculées comme les plafonds de salaire), la hiérarchie qui les relie, les dates d'application de chaque version, et des liens typés entre dispositions, comme « renvoie à », « modifie » ou « crée une exception ». Un modèle d'IA interroge cette structure au lieu de chercher dans du texte non structuré.

### Dans quelle mesure une ontologie juridique peut-elle réduire les coûts de l'IA juridique ?

Dans le système de droit du travail mexicain que nous avons examiné, le coût par message est passé de 0,60 $ à 0,02 $, soit une baisse de 97 %, selon les mesures de son concepteur, Dynamic Interfaces. Remplacer environ 300 outils MCP par 7 a retiré environ 88 000 tokens de descriptions d'outils de chaque requête, et cet ensemble d'outils réduit leur a permis de passer à un modèle open-weight moins coûteux.

### En quoi une ontologie juridique diffère-t-elle du RAG ?

Le RAG récupère des fragments de texte qui ressemblent à la question. Une ontologie stocke la structure du droit : hiérarchie, dates de version et renvois typés. Cela permet à un système de suivre une chaîne comme celle qui mène de l'article 162 de la Ley Federal del Trabajo du Mexique au plafond de salaire des articles 485 et 486, et d'appliquer la version d'un article en vigueur à une date donnée.

### À quelle fréquence les outils de RAG juridique hallucinent-ils ?

Une étude préenregistrée du Stanford RegLab et du HAI (Magesh et al., Journal of Empirical Legal Studies, 2025) a constaté que Lexis+ AI, Westlaw AI-Assisted Research et Ask Practical Law AI hallucinaient chacun dans 17 % à 33 % des cas sur ses requêtes de test, moins que GPT-4. Lexis+ AI a répondu avec exactitude à 65 % des requêtes et Westlaw à 42 %.

### Pourquoi moins d'outils MCP rendent-ils l'IA juridique moins chère et plus précise ?

Chaque description d'outil est envoyée au modèle à chaque requête, donc 300 outils d'environ 300 tokens chacun ajoutent environ 90 000 tokens avant même la question. L'article RAG-MCP (arXiv:2505.03275) a constaté que ne transmettre que les outils pertinents faisait passer la précision de sélection des outils de 13,62 % à 43,13 % et réduisait de plus de moitié les tokens du prompt.

### Combien de temps faut-il pour construire une ontologie juridique ?

Notre estimation de travail pour le droit du travail d'un pays est de 4 à 8 semaines : identifier les textes, concevoir le modèle d'entités, analyser et étiqueter les articles avec la relecture d'un avocat, construire le graphe de renvois typés, exposer un petit ensemble d'outils MCP, et mesurer le coût et la précision sur un jeu de tests approuvé par un avocat. Le décret-loi fédéral n° 33 de 2021 des Émirats arabes unis compte 74 articles.

---

Canonical page: https://www.haqq.ai/fr/blog/legal-ontology-ai-cost-reduction
Whole-site context for agents: https://www.haqq.ai/llms.txt · https://www.haqq.ai/agents.md

Generated at build time from the site's own content data. Do not edit by hand.
