embed-eulaw-multi v1.0.0: cross-lingual EU law retriever, +122.0% recall@1 on a document-isolated split
Browse files- README.md +138 -0
- adapter.json +51 -0
- adapter.pt +3 -0
README.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: intfloat/multilingual-e5-small
|
| 4 |
+
library_name: multilingual-embedding
|
| 5 |
+
pipeline_tag: sentence-similarity
|
| 6 |
+
tags:
|
| 7 |
+
- retrieval
|
| 8 |
+
- cross-lingual
|
| 9 |
+
- legal
|
| 10 |
+
- eu-law
|
| 11 |
+
- eurlex
|
| 12 |
+
- lora
|
| 13 |
+
language:
|
| 14 |
+
- de
|
| 15 |
+
- en
|
| 16 |
+
- es
|
| 17 |
+
- fr
|
| 18 |
+
- it
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
# embed-eulaw-multi
|
| 22 |
+
|
| 23 |
+
A cross-lingual retriever for European Union law. It is a LoRA adapter over
|
| 24 |
+
`intfloat/multilingual-e5-small` that finds the same provision of EU law across five
|
| 25 |
+
languages: German, English, Spanish, French and Italian.
|
| 26 |
+
|
| 27 |
+
Give it a provision in one language and it retrieves the matching provision in another. It is
|
| 28 |
+
a retriever, not a reranker, and not a question-answering model.
|
| 29 |
+
|
| 30 |
+
## The number
|
| 31 |
+
|
| 32 |
+
Measured on a document-isolated held out split, 5,509 queries against a 5,509-passage pool:
|
| 33 |
+
|
| 34 |
+
| | recall@1 | 95% CI | hits |
|
| 35 |
+
|---|---|---|---|
|
| 36 |
+
| base `intfloat/multilingual-e5-small` | 0.2919 | [0.2800, 0.3040] | 1,608 / 5,509 |
|
| 37 |
+
| **+ this adapter** | **0.6480** | [0.6353, 0.6605] | 3,570 / 5,509 |
|
| 38 |
+
| delta | **+0.3561** | | **+122.0%** |
|
| 39 |
+
|
| 40 |
+
The two intervals do not overlap.
|
| 41 |
+
|
| 42 |
+
Per language after adaptation: de 0.6534, en 0.6480, es 0.6400, fr 0.6480, it 0.6510. The
|
| 43 |
+
spread is flat, so no single language is carrying the average. The largest gain is German,
|
| 44 |
+
which starts weakest on the base at 0.1352.
|
| 45 |
+
|
| 46 |
+
## What this number does and does not establish
|
| 47 |
+
|
| 48 |
+
**It is in distribution.** The adapter was trained and scored on the same corpus and the same
|
| 49 |
+
task. It measures how much adaptation helps where it was trained. It is not evidence of
|
| 50 |
+
transfer to other legal text, other domains, or other languages, and we have not measured
|
| 51 |
+
that. A sibling model of ours gained substantially in distribution and then transferred flat
|
| 52 |
+
out of origin, so please do not assume this one will not do the same.
|
| 53 |
+
|
| 54 |
+
**It is one training run.** We report the draw count, which is one. The training loop is only
|
| 55 |
+
partly seeded: the data shuffle and dropout draw from a configured seed, but the LoRA down
|
| 56 |
+
projection is initialised at attach time, before that seed is set. A re-run would start from a
|
| 57 |
+
different adapter and we cannot promise it lands on the same number. That is not a claim it
|
| 58 |
+
would move. We have not measured this adapter's run to run spread.
|
| 59 |
+
|
| 60 |
+
**Passages were scored under a 256 token cap.** We have not measured how often a relevant
|
| 61 |
+
passage was truncated at that cap. The number above is the number under that setting.
|
| 62 |
+
|
| 63 |
+
**Two earlier figures are retracted.** Development runs reported +126.3% and +128.79% on a
|
| 64 |
+
split that held out texts rather than whole documents. Those measured a different quantity and
|
| 65 |
+
are withdrawn. They are not larger versions of +122.0%, the training volumes are not matched,
|
| 66 |
+
and no difference between them may be read as the cost of anything.
|
| 67 |
+
|
| 68 |
+
## Using it
|
| 69 |
+
|
| 70 |
+
```python
|
| 71 |
+
from multilingual_embedding.embedding.neural.adapter import load_adapter
|
| 72 |
+
|
| 73 |
+
encoder = load_adapter("quanfire-ai/embed-eulaw-multi")
|
| 74 |
+
vectors = encoder.encode(["Article 5 of Regulation (EU) 2016/679 ..."])
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
Install with `pip install multilingual-embedding`.
|
| 78 |
+
|
| 79 |
+
### Base revision
|
| 80 |
+
|
| 81 |
+
This adapter's manifest predates our base pinning convention, so it reads back as unpinned.
|
| 82 |
+
The base revision it was built against is
|
| 83 |
+
`614241f622f53c4eeff9890bdc4f31cfecc418b3`, which we establish from the training host's model
|
| 84 |
+
cache rather than from a field the run recorded: that snapshot is the only one present and it
|
| 85 |
+
predates the run by a month. Pin it explicitly if you need byte-stable behaviour:
|
| 86 |
+
|
| 87 |
+
```python
|
| 88 |
+
encoder = load_adapter(
|
| 89 |
+
"quanfire-ai/embed-eulaw-multi",
|
| 90 |
+
revision="614241f622f53c4eeff9890bdc4f31cfecc418b3",
|
| 91 |
+
)
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
## How it was trained
|
| 95 |
+
|
| 96 |
+
LoRA rank 32, alpha 64, applied to the query and value projections. 589,824 adapter
|
| 97 |
+
parameters. One epoch over 19,966 aligned pairs, learning rate 1e-4, batch size 256, mean
|
| 98 |
+
pooling, 384 dimensions, max sequence length 256, normalised outputs.
|
| 99 |
+
|
| 100 |
+
The training pairs are not mined and not machine translated. The Union publishes the same act
|
| 101 |
+
as professionally aligned expressions in many languages, so the German text and the French
|
| 102 |
+
text of one regulation are two authentic expressions of the same law, aligned by the Union's
|
| 103 |
+
own structure: the same CELEX identifier, the same article position. The alignment was done by
|
| 104 |
+
the people who wrote the law.
|
| 105 |
+
|
| 106 |
+
The held out split isolates whole documents. No held out provision shares a document with
|
| 107 |
+
anything in training.
|
| 108 |
+
|
| 109 |
+
**The exact training tree cannot be handed over as a commit.** The working copy of the
|
| 110 |
+
training module on the build host was written after this adapter was, so the file on disk is
|
| 111 |
+
provably not the file that ran. What we can hand over is the pair of commits that introduced
|
| 112 |
+
the document level split, both verifiably in effect before this run started. The evaluation
|
| 113 |
+
provenance is intact and independently checkable; it is the training tree that is not
|
| 114 |
+
recoverable. No claim here asserts reproducible training.
|
| 115 |
+
|
| 116 |
+
## Provenance and licence
|
| 117 |
+
|
| 118 |
+
The corpus is EU legal text from EUR-Lex, the Union's official legal database, taken through
|
| 119 |
+
its official channels only. No mirrors and no third party re-hosts.
|
| 120 |
+
|
| 121 |
+
EUR-Lex legal texts are reusable under Creative Commons Attribution 4.0, granted by Commission
|
| 122 |
+
Decision 2011/833/EU. Commercial reuse is named in the grant, not inferred. Database metadata
|
| 123 |
+
is CC0.
|
| 124 |
+
|
| 125 |
+
Only the Official Journal is treated as the authentic source. Material that travels alongside
|
| 126 |
+
it is out of scope and is not in the corpus: no third party inserts, no publisher marks, and
|
| 127 |
+
no international accounting standards, which carry their own rights and would need separate
|
| 128 |
+
clearance.
|
| 129 |
+
|
| 130 |
+
**The weights are Apache-2.0. The corpus is not redistributed.** The model is
|
| 131 |
+
non-reconstructive: it is a 589,824 parameter adapter that emits vectors, not text, and it
|
| 132 |
+
cannot reproduce its training corpus. Attribution for the underlying legal text is to the
|
| 133 |
+
European Union via EUR-Lex.
|
| 134 |
+
|
| 135 |
+
## Scope
|
| 136 |
+
|
| 137 |
+
Five languages, EU legal provisions, in distribution. It has not been evaluated on national
|
| 138 |
+
law, on case law, on the other nineteen EU languages, or on any non legal text.
|
adapter.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"format_version": 2,
|
| 3 |
+
"checkpoint": "intfloat/multilingual-e5-small",
|
| 4 |
+
"dimension": 384,
|
| 5 |
+
"pooling": "mean",
|
| 6 |
+
"max_length": 256,
|
| 7 |
+
"normalize": true,
|
| 8 |
+
"data_provenance": "licensed",
|
| 9 |
+
"query_prefix": "",
|
| 10 |
+
"passage_prefix": "",
|
| 11 |
+
"lora": {
|
| 12 |
+
"rank": 32,
|
| 13 |
+
"alpha": 64,
|
| 14 |
+
"dropout": 0.0,
|
| 15 |
+
"targets": [
|
| 16 |
+
"query",
|
| 17 |
+
"value"
|
| 18 |
+
]
|
| 19 |
+
},
|
| 20 |
+
"adapter_parameters": 589824,
|
| 21 |
+
"notes": {
|
| 22 |
+
"experiment": "eulaw-multi-e1c",
|
| 23 |
+
"data_provenance": "licensed",
|
| 24 |
+
"trained_on": "/home/arnab/quanfire-ai-data/embedding/eulaw/corpus/pairs-e1.jsonl",
|
| 25 |
+
"scored_against": "/home/arnab/quanfire-ai-data/embedding/eulaw/corpus/pairs-e1.jsonl",
|
| 26 |
+
"train_pairs": 19966,
|
| 27 |
+
"adaptation": "in-distribution",
|
| 28 |
+
"train_kinds": [
|
| 29 |
+
"eulaw-provision-xling"
|
| 30 |
+
],
|
| 31 |
+
"train_languages": [
|
| 32 |
+
"de",
|
| 33 |
+
"en",
|
| 34 |
+
"es",
|
| 35 |
+
"fr",
|
| 36 |
+
"it"
|
| 37 |
+
],
|
| 38 |
+
"held_out_languages": [
|
| 39 |
+
"de",
|
| 40 |
+
"en",
|
| 41 |
+
"es",
|
| 42 |
+
"fr",
|
| 43 |
+
"it"
|
| 44 |
+
],
|
| 45 |
+
"recall_at_1_before": 0.2919,
|
| 46 |
+
"recall_at_1_after": 0.648,
|
| 47 |
+
"epochs": 1,
|
| 48 |
+
"learning_rate": 0.0001,
|
| 49 |
+
"batch_size": 256
|
| 50 |
+
}
|
| 51 |
+
}
|
adapter.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0683f450ed95b7b224313df6a8ce94d296c511b7739d75fc799b6738b95721b4
|
| 3 |
+
size 2376657
|