CoolFace
Datasetpublic

ArthurSrz/open_codes

Open Codes Open dataset of French legal code articles with embeddings. Chunked articles from French legal codes sourced from Legifrance via the PISTE API, with 1024-dimensional embeddings generated by Mistral AI. Each row is a text chunk enriched with full article metadata from the parent legal code article. Legal codes included The list of legal codes is dynamic and managed in the LEX_codes_piste table. Adding a new code there (with actif=true) automatically… See the full description on the dataset page: https://huggingface.co/datasets/ArthurSrz/open_codes.

sourceHugging Faceetalab-2.0updated 3mo agoView on Hugging Face
0likes44downloads
Dataset Card

Open Codes

Open dataset of French legal code articles with embeddings.

Chunked articles from French legal codes sourced from Legifrance via the PISTE API, with 1024-dimensional embeddings generated by Mistral AI.

Each row is a text chunk enriched with full article metadata from the parent legal code article.

Dataset Description

  • Source: PISTE Legifrance API (official French government legal database)
  • License: Licence Ouverte / Etalab 2.0
  • Embeddings: Mistral AI mistral-embed (1024 dimensions)
  • Update frequency: Daily (nightly sync at 02:00 UTC, dataset push at 07:00 UTC)
  • Codes: Dynamically sourced from LEX_codes_piste (active codes only)
  • Quality: Dedup + stale-chunk filtering applied before every push

Legal codes included

The list of legal codes is dynamic and managed in the LEX_codes_piste table. Adding a new code there (with actif=true) automatically includes it in the next sync and export.

Schema

Chunk fields

ColumnTypeDescription
chunk_textstringText content of the chunk
embeddingfloat32[1024]Mistral AI embedding vector
id_legifrancestringLegifrance article identifier
code_namestringHuman-readable code name (e.g. "Code civil")
chunk_indexint32Chunk position within the article (0-indexed)
start_positionint32Character offset in original article text
end_positionint32End character offset in original article text
codestringLegal code identifier (e.g. LEGITEXT000006070721)
numstringArticle number (e.g. "L. 1234-5")
etatstringArticle status (VIGUEUR, ABROGE, etc.)
fullSectionsTitrestringFull hierarchy path in the code

Article metadata fields (prefixed article_)

Identifiers
ColumnTypeDescription
article_id_legifrancestringLegifrance article ID
article_codestringLegal code ID
article_numstringArticle number
article_cidstringConsolidated ID
article_idElistringELI (European Legislation Identifier)
article_idEliAliasstringELI alias
article_idTextestringText ID
article_cidTextestringConsolidated text ID
Content
ColumnTypeDescription
article_textestringFull article plain text
article_texteHtmlstringFull article HTML
article_notastringArticle notes (plain text)
article_notaHtmlstringArticle notes (HTML)
article_surtitrestringArticle subtitle
article_historiquestringArticle history
Dates & Status

Date format: article_dateDebut and article_dateFin are stored as Unix timestamps in milliseconds (string type). This is the raw format returned by the Legifrance PISTE API.

To convert to a human-readable date in Python:

python
from datetime import datetime, timezone

timestamp_ms = "1301529600000"
dt = datetime.fromtimestamp(int(timestamp_ms) / 1000, tz=timezone.utc)
print(dt)  # 2011-03-31 00:00:00+00:00

Special value: 32472144000000 (year 2999) means "no end date" — the article is in force indefinitely.

ColumnTypeDescription
article_dateDebutstringEffective start date (Unix ms)
article_dateFinstringEffective end date (Unix ms, 32472144000000 = indefinite)
article_dateDebutExtensionstringExtension start date (Unix ms)
article_dateFinExtensionstringExtension end date (Unix ms)
article_etatstringStatus: VIGUEUR (in force), ABROGE (repealed), etc.
article_type_articlestringArticle type
article_naturestringLegal nature
article_originestringOrigin (e.g. LEGI)
article_version_articlestringVersion identifier
article_versionPrecedentestringPrevious version ID
article_multipleVersionsboolHas multiple versions
Hierarchy
ColumnTypeDescription
article_sectionParentIdstringParent section ID
article_sectionParentCidstringParent section consolidated ID
article_sectionParentTitrestringParent section title
article_fullSectionsTitrestringFull hierarchy path
article_ordreint32Sort order within the code
article_partiestringPartie (e.g. "Partie legislative")
article_livrestringLivre
article_titrestringTitre
article_chapitrestringChapitre
article_sectionstringSection
article_sous_sectionstringSous-section
article_paragraphestringParagraphe
Extras
ColumnTypeDescription
article_infosComplementairesstringAdditional info (plain text)
article_infosComplementairesHtmlstringAdditional info (HTML)
article_conditionDifferestringDeferred condition
article_infosRestructurationBranchestringBranch restructuring info
article_infosRestructurationBrancheHtmlstringBranch restructuring (HTML)
article_renvoistringCross-references
article_comporteLiensSPboolContains SP links
article_idTechInjectionstringTechnical injection ID
article_refInjectionstringInjection reference
article_numeroBostringBO number
article_inapstringINAP code

Configs

ConfigDescriptionSource
defaultCode articles + chunks from Legifrance PISTE APIREF_codes_legifrance + REF_article_chunks
jurisprudenceCourt decisions from Judilibre APIREF_decisions_judilibre + REF_legal_chunks
circulairesGovernment circularsREF_circulaires + REF_legal_chunks
reponses_legisParliamentary written answersREF_reponses_ministerial + REF_legal_chunks

Usage

python
from datasets import load_dataset
from datetime import datetime, timezone

# Load default config (code articles)
ds = load_dataset("ArthurSrz/open_codes", split="train")

# Load jurisprudence config (court decisions)
juris = load_dataset("ArthurSrz/open_codes", "jurisprudence", split="train")

# Access a chunk with its embedding and article metadata
row = ds[0]
print(row["code_name"])                # e.g. "Code civil"
print(row["chunk_text"][:200])
print(len(row["embedding"]))           # 1024

# Convert dates from Unix ms to datetime
date_debut = datetime.fromtimestamp(int(row["article_dateDebut"]) / 1000, tz=timezone.utc)
print(date_debut)                      # e.g. 2011-03-31 00:00:00+00:00

# Filter by legal code
code_civil = ds.filter(lambda x: x["code_name"] == "Code civil")

# Filter active articles only
en_vigueur = ds.filter(lambda x: x["article_etat"] == "VIGUEUR")

# Use embeddings for semantic search
import numpy as np
query_emb = np.array(ds[0]["embedding"])

Provenance

Built by the marIAnne project. Sync pipeline fetches articles nightly from PISTE Legifrance, chunks them, and generates embeddings via Mistral AI.