File size: 3,328 Bytes
1d5ed4a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
---

license: cc-by-4.0
language:
- en
tags:
- eu-law
- legal
- gdpr
- ai-act
- rag
- retrieval
- instruction-tuning
task_categories:
- text-generation
- text-retrieval
configs:
- config_name: chunks
  data_files: chunks/train.jsonl
- config_name: finetuning
  data_files: finetuning/train.jsonl
---


# EuropeGram: EU Legal Text -- RAG Chunks & Instruction Data

Structured, chunked, and instruction-formatted text derived from official EU
legislation, built for retrieval-augmented generation (RAG) and LoRA
fine-tuning experiments comparing Base / RAG / Fine-tuned / Fine-tuned+RAG
LLM strategies over EU documents. Produced by the EuropeGram project's
extraction -> chunking -> fine-tuning-export pipeline.

## Source documents

| Document | CELEX ID | Source | Chunks | Instruction pairs |
|---|---|---|---|---|
| Regulation (EU) 2024/1689 (Artificial Intelligence Act) | `32024R1689` | [EUR-Lex](https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX:32024R1689) | 316 | 126 |
| Regulation (EU) 2016/679 (General Data Protection Regulation) | `32016R0679` | [EUR-Lex](https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX:32016R0679) | 187 | 99 |

**Attribution & authenticity notice.** The underlying legal texts are
reproduced from the official PDF renditions published on EUR-Lex. Reuse of
EU legislation is permitted free of charge under [Decision
2011/833/EU](https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX:32011D0833),
provided the source is acknowledged and the meaning or message of the
original is not distorted. **Only the versions published in the Official

Journal of the European Union are authentic and legally binding** -- this
dataset is a derived, machine-processed artifact for ML research and must
not be treated as an authoritative legal source.

## Configs

### `chunks`

One row per RAG chunk (structure-aware: packed by article/annex paragraph,
capped at `max_chars` with `overlap_chars` overlap for long ones -- see
`europegram.rag.chunker`). Fields:

- `id`: chunk id, e.g. `article-4-chunk-0`
- `text`: chunk text (first chunk of an article/annex is prefixed with its heading)
- `document_id`, `celex_id`: which source document
- `ref_type`: `"article"` or `"annex"`
- `ref_id`: e.g. `"article-4"`, `"annex-viii"`
- `title`: article/annex title
- `chapter_number`, `chapter_title`: containing chapter, when applicable (nullable)
- `page_start`, `page_end`: page span in the source PDF
- `chunk_index`: position of this chunk within its article/annex (0-based)

### `finetuning`

One Alpaca-style instruction/output pair per article/annex, for LoRA
fine-tuning (see `europegram.finetuning.dataset_builder` and
`colab/finetune_lora.ipynb`). Fields:

- `instruction`: natural-language question about one article/annex
- `input`: always empty (kept for Alpaca-format compatibility)
- `output`: the article/annex's full text -- the target completion
- `document_id`, `celex_id`, `ref_id`: provenance, so any model output can be traced back to a specific legal reference

## Loading

```python

from datasets import load_dataset



chunks = load_dataset("<your-username>/<dataset-name>", "chunks", split="train")

finetuning = load_dataset("<your-username>/<dataset-name>", "finetuning", split="train")

```