An Senegalese Legal Texts Structuration Using LLM-augmented Knowledge Graph

This study leverages large language models to extract and structure nearly 8,000 articles from Senegalese legal texts into a comprehensive knowledge graph, thereby enhancing access to judicial information and clarifying rights and responsibilities for citizens and legal professionals.

Oumar Kane, Mouhamad M. Allaya, Dame Samb, Mamadou Bousso

Published 2026-03-10
📖 4 min read☕ Coffee break read

Imagine the legal system of Senegal as a gigantic, ancient library. Inside this library, there are thousands of books (laws, decrees, and codes) written in French. These books are messy: some pages are torn, some are just scanned pictures, and the chapters are written in a confusing code that only a few experts can decipher. For an average citizen trying to find out their rights regarding land or taxes, walking into this library is like trying to find a specific needle in a haystack while wearing blindfolded.

This paper is about building a super-smart, AI-powered librarian and a digital map to help everyone navigate this library.

Here is a breakdown of what the researchers did, using simple analogies:

1. The Problem: The "Messy Attic"

The researchers started by looking at the Senegalese legal system. They found that while there are many laws, they are scattered and hard to connect.

  • The Analogy: Imagine your attic is full of boxes. One box says "Land Rules," another says "Tax Rules," but inside the "Land Rules" box, there are notes referencing the "Tax Rules" box. If you want to know how much rent you can charge, you have to dig through three different boxes to find the answer.
  • The Goal: They wanted to clean up this attic, organize every single rule, and draw a map showing how every rule connects to every other rule.

2. The Solution: The "Digital Twin" (Knowledge Graph)

The team didn't just scan the documents; they built a Knowledge Graph.

  • The Analogy: Think of a Knowledge Graph as a giant subway map or a social network for laws.
    • Nodes (The Stops): Each stop on the map is a piece of information (e.g., "Law 98-03," "Article 5," "President," "Minister").
    • Edges (The Tracks): The tracks connecting the stops show the relationships. For example, a track connects "Law 98-03" to "Article 5" with a label saying "contains." Another track connects "Article 5" to "Minister" with a label saying "signed by."
  • The Result: They successfully pulled 7,967 articles from 20 different legal documents and turned them into a map with 2,872 stops and 10,774 tracks. Now, instead of reading a whole book, a user can see exactly how one law leads to another.

3. The Engine: The "AI Brain" (LLMs)

To build this map, they couldn't just use a simple computer script because legal language is tricky. They used Large Language Models (LLMs) like GPT-4o and Mistral-Large.

  • The Analogy: Imagine you have a robot that has read every book in the world. You give it a messy legal paragraph and say, "Hey Robot, tell me: Who signed this? What law does it change? What other laws does it mention?"
  • The "Triples": The robot answers in a specific format called "Knowledge Triples" (Subject → Verb → Object).
    • Example: "Article 5" → "references" → "Law 2020."
  • The Experiment: They tested different "Robots" (AI models) to see which one was the best at reading these laws and building the map.
    • The Winner: GPT-4o was the smartest reader, getting the details right 86% of the time.
    • The Speedster: Mistral-Large was the fastest, finishing the job in record time while still doing a great job.

4. Why This Matters

Before this project, if a Senegalese farmer wanted to know their rights regarding public land, they might have to hire a lawyer or spend days in a dusty archive.

  • The New Reality: With this system, the farmer (or a lawyer) can ask the AI, "Show me all the rules about land rent in the Dakar region." The AI instantly looks at its "Subway Map," follows the tracks, and gives a clear, organized answer.

Summary

The researchers took a chaotic, hard-to-read pile of legal documents and used advanced AI to:

  1. Clean them up (extracting 7,967 rules).
  2. Connect the dots (building a graph database).
  3. Test the best AI brains to see which one understands the law best.

The Bottom Line: They are building a GPS for the law. Just as a GPS helps you navigate a confusing city without getting lost, this AI system helps citizens and lawyers navigate the complex world of Senegalese law, making justice more accessible and transparent for everyone.