Datasets:
Vietnamese National Legal Database (vbpl.vn) corpus with structure + embedding layers
Browse files- README.md +35 -92
- embedding-legal-type-umap.png +2 -2
- manifest.json +1 -1
README.md
CHANGED
|
@@ -29,14 +29,6 @@ configs:
|
|
| 29 |
data_files:
|
| 30 |
- split: train
|
| 31 |
path: documents-*.parquet
|
| 32 |
-
- config_name: embed
|
| 33 |
-
data_files:
|
| 34 |
-
- split: train
|
| 35 |
-
path: embed-*.parquet
|
| 36 |
-
- config_name: reduce
|
| 37 |
-
data_files:
|
| 38 |
-
- split: train
|
| 39 |
-
path: reduce-*.parquet
|
| 40 |
---
|
| 41 |
|
| 42 |
# Vietnamese National Legal Database — `vbpl.vn`
|
|
@@ -371,91 +363,34 @@ for sec in structure.get("sections", []):
|
|
| 371 |
print(sec["kind"], sec["label"])
|
| 372 |
```
|
| 373 |
|
| 374 |
-
##
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
(147,317
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
| `doc_name` | string | Join key back to `documents-*.parquet`. |
|
| 394 |
-
| `text_hash` | string | SHA-256 of the post-normalisation `markdown` (stable across re-runs). |
|
| 395 |
-
| `embedding` | list<float64> | **2048-D** dense vector from `nvidia/llama-nemotron-embed-1b-v2` (default; other models give other dims). |
|
| 396 |
-
| `embedding_dim` | int64 | Length of `embedding` (denormalised for fast filtering, always `2048` in this release). |
|
| 397 |
-
| `embedding_model_id` | string | Model slug as the embedder backend reports it. |
|
| 398 |
-
| `embedding_text_hash` | string | SHA-256 of the exact text fed to the embedder (differs from `text_hash` when sliding-window chunking applies). |
|
| 399 |
-
| `embedding_chunks_used` | int64 | Number of windows mean-pooled into the final vector (1 when the doc fits in one window). |
|
| 400 |
-
| `embedding_chunking` | string | Chunking strategy: `off` / `sliding` / `sentence`. |
|
| 401 |
-
|
| 402 |
-
### `reduce-*.parquet` — 2-D projections + cluster ids
|
| 403 |
-
|
| 404 |
-
15 shards (~0.5 MB each, ~7 MB total). PCA + t-SNE + UMAP run
|
| 405 |
-
with `cfg.reducer.n_components=2` so the `*_z` columns that
|
| 406 |
-
existed in the on-disk per-doc shards are dropped here.
|
| 407 |
-
HDBSCAN cluster ids land in `[-1, N]` (`-1` is the noise
|
| 408 |
-
bucket).
|
| 409 |
-
|
| 410 |
-
| Field | Type | Description |
|
| 411 |
-
|---|---|---|
|
| 412 |
-
| `doc_name` / `text_hash` | string | Join keys back to `documents-*.parquet` and `embed-*.parquet`. |
|
| 413 |
-
| `pca_x` / `pca_y` | float64 | 2-D PCA projection of the 2048-D embedding. |
|
| 414 |
-
| `umap_x` / `umap_y` | float64 | 2-D UMAP projection (the one used in the scatter PNGs above). Fit globally across all rows for cross-doc comparability. |
|
| 415 |
-
| `cluster_id` | int64 | HDBSCAN cluster label; `-1` is the noise / unclustered bucket. |
|
| 416 |
-
|
| 417 |
-
Quick load (each stage is a `data_files` glob; the default
|
| 418 |
-
`load_dataset("tmquan/vbpl-vn")` still resolves to the
|
| 419 |
-
`documents` config):
|
| 420 |
-
|
| 421 |
-
```python
|
| 422 |
-
from datasets import load_dataset
|
| 423 |
-
|
| 424 |
-
embed = load_dataset(
|
| 425 |
-
"tmquan/vbpl-vn",
|
| 426 |
-
data_files="embed-*.parquet",
|
| 427 |
-
split="train",
|
| 428 |
-
)
|
| 429 |
-
print(embed[0]["doc_name"], len(embed[0]["embedding"]))
|
| 430 |
-
# e.g. "100000 2048"
|
| 431 |
-
|
| 432 |
-
reduce = load_dataset(
|
| 433 |
-
"tmquan/vbpl-vn",
|
| 434 |
-
data_files="reduce-*.parquet",
|
| 435 |
-
split="train",
|
| 436 |
-
)
|
| 437 |
-
print(reduce[0]["doc_name"], reduce[0]["umap_x"], reduce[0]["cluster_id"])
|
| 438 |
-
# e.g. "100000 1.7142 -1"
|
| 439 |
```
|
| 440 |
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
```python
|
| 445 |
-
import pandas as pd
|
| 446 |
-
|
| 447 |
-
docs = load_dataset("tmquan/vbpl-vn", split="train").to_pandas()
|
| 448 |
-
embed = load_dataset("tmquan/vbpl-vn",
|
| 449 |
-
data_files="embed-*.parquet",
|
| 450 |
-
split="train").to_pandas()
|
| 451 |
-
joined = docs.merge(embed, on="doc_name", how="inner")
|
| 452 |
-
# joined now has the title / so_hieu / markdown / ... columns
|
| 453 |
-
# next to the 2048-D embedding vector for every embeddable doc.
|
| 454 |
-
```
|
| 455 |
|
| 456 |
## Trực quan hoá embedding · Embedding visualization
|
| 457 |
|
| 458 |
-
Mỗi điểm là một văn bản pháp luật; toạ độ là vector embedding 2048-D từ `nvidia/llama-nemotron-embed-1b-v2` chiếu xuống 2D bằng UMAP
|
| 459 |
|
| 460 |
### UMAP colored by `scope`
|
| 461 |
|
|
@@ -503,9 +438,17 @@ intercepts the resulting authenticated XHRs, downloads any
|
|
| 503 |
4. **Embed** -- `nvidia/llama-nemotron-embed-1b-v2` (2048-D) over the
|
| 504 |
normalised markdown; sliding-window mean pool when a doc exceeds
|
| 505 |
the model's native context window.
|
| 506 |
-
5. **Reduce** -- PCA +
|
| 507 |
-
|
| 508 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 509 |
|
| 510 |
All five layers are deterministic and re-runnable; re-running any
|
| 511 |
stage with the same `--limit` is a no-op (each stage skips
|
|
@@ -529,7 +472,7 @@ embedding parquets for the NULL-markdown rows are dropped from
|
|
| 529 |
the embedding corpus entirely so the reducer fits on the
|
| 530 |
embeddable rows only (147,317-row corpus).
|
| 531 |
|
| 532 |
-
Captured: `2026-05-23T14:
|
| 533 |
|
| 534 |
## Nguồn · Source
|
| 535 |
|
|
|
|
| 29 |
data_files:
|
| 30 |
- split: train
|
| 31 |
path: documents-*.parquet
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
---
|
| 33 |
|
| 34 |
# Vietnamese National Legal Database — `vbpl.vn`
|
|
|
|
| 363 |
print(sec["kind"], sec["label"])
|
| 364 |
```
|
| 365 |
|
| 366 |
+
## Embedding + reduction artefacts
|
| 367 |
+
|
| 368 |
+
The Hub ships the **`documents` config only**
|
| 369 |
+
(`documents-*.parquet`, one row per document, with text +
|
| 370 |
+
structure). The 2048-D
|
| 371 |
+
`nvidia/llama-nemotron-embed-1b-v2` embeddings, the global UMAP / PCA
|
| 372 |
+
coordinates, and the HDBSCAN cluster ids are computed during the
|
| 373 |
+
build (over 147,317 embeddable rows,
|
| 374 |
+
i.e. all documents with non-null `markdown`) and used to render
|
| 375 |
+
the scatter PNGs below, but they are **not bundled as separate
|
| 376 |
+
parquet configs on the Hub** -- 1.3 GB of dense vectors per
|
| 377 |
+
re-build is too costly to ship for a corpus this size when the
|
| 378 |
+
embeddings are deterministic from `markdown` + a model id.
|
| 379 |
+
Re-derive the same matrices locally via:
|
| 380 |
+
|
| 381 |
+
```bash
|
| 382 |
+
git clone https://github.com/<owner>/ViLA # the build repo
|
| 383 |
+
python -m packages.datasites.vbpl --pipeline embed
|
| 384 |
+
python -m packages.datasites.vbpl.\_reduce\_inproc # global UMAP
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 385 |
```
|
| 386 |
|
| 387 |
+
which yields `parquet/embeddings/<doc_name>.parquet` and
|
| 388 |
+
`parquet/reduced/<doc_name>.parquet` per-doc shards keyed back to
|
| 389 |
+
`documents.doc_name`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 390 |
|
| 391 |
## Trực quan hoá embedding · Embedding visualization
|
| 392 |
|
| 393 |
+
Mỗi điểm là một văn bản pháp luật; toạ độ là vector embedding 2048-D từ `nvidia/llama-nemotron-embed-1b-v2` chiếu xuống 2D bằng **UMAP fit globally** trên toàn bộ kho văn bản (không chia batch) để toạ độ so sánh được giữa các tài liệu. Năm mặt phân hoạch: `scope`, `doc_type` (mã ngắn), `legal_type` (tên đầy đủ), `legal_area` (lĩnh vực pháp luật), `year`. Các nhãn tail-end (sau top-18) được dồn vào nhóm *Khác / Other* màu xám để chú giải đọc được. — Each dot is one legal document; coordinates are the 2D UMAP projection of a 2048-D embedding from `nvidia/llama-nemotron-embed-1b-v2`, **fit globally across the whole corpus** so positions are directly comparable across documents. Five facets: `scope`, `doc_type` (canonical short code), `legal_type` (canonical full name), `legal_area` (subject domain), `year`. Tail-end labels beyond the top 18 are collapsed into a grey *Khác / Other* bucket to keep the legend legible.
|
| 394 |
|
| 395 |
### UMAP colored by `scope`
|
| 396 |
|
|
|
|
| 438 |
4. **Embed** -- `nvidia/llama-nemotron-embed-1b-v2` (2048-D) over the
|
| 439 |
normalised markdown; sliding-window mean pool when a doc exceeds
|
| 440 |
the model's native context window.
|
| 441 |
+
5. **Reduce** -- PCA + UMAP on the embedding matrix + HDBSCAN
|
| 442 |
+
cluster ids. The May-2026 rerun switched from per-batch
|
| 443 |
+
reduction (each Curator `DocumentBatch` independently) to a
|
| 444 |
+
**global in-process fit** over the full 147,317
|
| 445 |
+
× 2048-D matrix so the projection is comparable
|
| 446 |
+
across documents (`packages/datasites/vbpl/_reduce_inproc.py`).
|
| 447 |
+
t-SNE was dropped from the rerun because a single global fit
|
| 448 |
+
under `random_state=0` (single-threaded by construction) took
|
| 449 |
+
prohibitively long on this corpus; PCA + UMAP cover the same
|
| 450 |
+
visual story without it. cuML on a GPU worker; sklearn /
|
| 451 |
+
umap-learn / hdbscan otherwise.
|
| 452 |
|
| 453 |
All five layers are deterministic and re-runnable; re-running any
|
| 454 |
stage with the same `--limit` is a no-op (each stage skips
|
|
|
|
| 472 |
the embedding corpus entirely so the reducer fits on the
|
| 473 |
embeddable rows only (147,317-row corpus).
|
| 474 |
|
| 475 |
+
Captured: `2026-05-23T14:29:39.492383+00:00`.
|
| 476 |
|
| 477 |
## Nguồn · Source
|
| 478 |
|
embedding-legal-type-umap.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
manifest.json
CHANGED
|
@@ -536,5 +536,5 @@
|
|
| 536 |
"share": 0.07243958645527698
|
| 537 |
}
|
| 538 |
},
|
| 539 |
-
"completed_at": "2026-05-23T14:
|
| 540 |
}
|
|
|
|
| 536 |
"share": 0.07243958645527698
|
| 537 |
}
|
| 538 |
},
|
| 539 |
+
"completed_at": "2026-05-23T14:29:39.492383+00:00"
|
| 540 |
}
|