Skip to content

Commit b22acc0

Browse files
davanstrienclaude
andauthored
Migrate gliner + object-detection into the repo (#22)
* Migrate gliner + object-detection into the repo (seed-then-flip) Seeded both folders from their live Hub dataset repos (hf download, dropped .cache/.gitattributes), added thin sync callers, and listed them in the README's in-repo line. Both are vLLM-free (NER + CPU dataset utilities) so no #9-class FlashInfer/driver risk. Superset gate passes for both (gliner 2 files, object-detection 6), so the --delete="*" sync can't remove anything on the Hub. Added viewer:false to gliner/README.md to match the AGENTS.md convention and its sibling object-detection. Scripts seeded faithfully — pre-existing ruff findings (mostly unused imports) left untouched; a lint pass is a separate additive follow-up. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Soften public 'source of truth' framing in the README Drop the 'GitHub is the source of truth' phrasing from the two public-facing README spots (the migrated-folders line + footer) — keep the neutral mirror mechanic. It's accurate internally (AGENTS.md keeps it) but undersells the Hub on the public landing surfaces. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent e19733a commit b22acc0

11 files changed

Lines changed: 2692 additions & 2 deletions

.github/workflows/sync-gliner.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Sync gliner → HF
2+
on:
3+
push:
4+
branches: [main]
5+
paths: ['gliner/**', '.github/workflows/sync-gliner.yml']
6+
7+
jobs:
8+
sync:
9+
uses: ./.github/workflows/_sync-folder.yml
10+
with:
11+
folder: gliner
12+
secrets:
13+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Sync object-detection → HF
2+
on:
3+
push:
4+
branches: [main]
5+
paths: ['object-detection/**', '.github/workflows/sync-object-detection.yml']
6+
7+
jobs:
8+
sync:
9+
uses: ./.github/workflows/_sync-folder.yml
10+
with:
11+
folder: object-detection
12+
secrets:
13+
HF_TOKEN: ${{ secrets.HF_TOKEN }}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ A self-contained, pinned script is easy to run and reuse, for a few reasons:
7373
| **entity extraction** | NER / structured extraction over text | [`gliner`](https://huggingface.co/datasets/uv-scripts/gliner) |
7474
| ***…and more*** | *Training, evaluation, RAG indexing — migrating as they mature* | [`training`](https://huggingface.co/datasets/uv-scripts/training) · [`transformers-training`](https://huggingface.co/datasets/uv-scripts/transformers-training) |
7575

76-
So far **[ocr/](ocr/)**, **[sam3/](sam3/)**, **[transcription/](transcription/)**, **[build-atlas/](build-atlas/)**, and **[vlm-object-detection/](vlm-object-detection/)** live in this repo; the rest link to the [`uv-scripts`](https://huggingface.co/uv-scripts) Hugging Face org where they run today, and migrate here over time. (GitHub is the source of truth; each folder mirrors to its Hub dataset.)
76+
So far **[ocr/](ocr/)**, **[sam3/](sam3/)**, **[transcription/](transcription/)**, **[build-atlas/](build-atlas/)**, **[vlm-object-detection/](vlm-object-detection/)**, **[gliner/](gliner/)**, and **[object-detection/](object-detection/)** live in this repo; the rest link to the [`uv-scripts`](https://huggingface.co/uv-scripts) Hugging Face org where they run today, and migrate here over time. (each folder mirrors to its Hub dataset repo.)
7777

7878
**What fits here:** any self-contained UV script for data or ML work on the Hub. OCR and dataset work are the current focus, but inference, evaluation, RAG indexing, and **training** (fine-tuning with TRL / `transformers`, producing a model) are all in scope. If it's one pinned script that reads from or writes to the Hub, it belongs.
7979

@@ -118,4 +118,4 @@ The code and documentation in this repository are licensed under the [Apache Lic
118118

119119
---
120120

121-
*Recipes mirror to the [`uv-scripts`](https://huggingface.co/uv-scripts) Hugging Face org via GitHub Actions — GitHub is the source of truth. See [CONTRIBUTING.md](CONTRIBUTING.md) to add one.*
121+
*Recipes mirror to the [`uv-scripts`](https://huggingface.co/uv-scripts) Hugging Face org via GitHub Actions. See [CONTRIBUTING.md](CONTRIBUTING.md) to add one.*

gliner/README.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
---
2+
viewer: false
3+
license: apache-2.0
4+
tags:
5+
- uv-script
6+
- ner
7+
- zero-shot
8+
- gliner
9+
- hf-jobs
10+
---
11+
12+
# GLiNER UV Scripts
13+
14+
Zero-shot named-entity recognition over Hugging Face datasets using [GLiNER](https://github.com/urchade/GLiNER). Pass a list of entity types at runtime — no fine-tuning required.
15+
16+
| Script | What it does | Output |
17+
|---|---|---|
18+
| `extract-entities.py` | Extract entities from a text column with a custom set of types | New `entities` column (list of `{start, end, text, label, score}`) |
19+
20+
## Quick start
21+
22+
Run on any HF dataset with a text column. No setup — `uv` resolves dependencies inline.
23+
24+
```bash
25+
# Local CPU (small samples)
26+
uv run extract-entities.py \
27+
librarian-bots/model_cards_with_metadata \
28+
yourname/model-cards-entities \
29+
--text-column card \
30+
--entity-types Person Organization Dataset Model Framework \
31+
--max-samples 100
32+
```
33+
34+
## On HF Jobs
35+
36+
```bash
37+
# CPU job — fine for small/medium datasets, free or near-free
38+
hf jobs uv run --flavor cpu-basic --secrets HF_TOKEN \
39+
https://huggingface.co/datasets/uv-scripts/gliner/raw/main/extract-entities.py \
40+
librarian-bots/model_cards_with_metadata \
41+
yourname/model-cards-entities \
42+
--text-column card \
43+
--entity-types Person Organization Dataset Model Framework \
44+
--max-samples 1000
45+
46+
# GPU job — worth it once you're processing >~1000 samples
47+
hf jobs uv run --flavor t4-small --secrets HF_TOKEN \
48+
https://huggingface.co/datasets/uv-scripts/gliner/raw/main/extract-entities.py \
49+
librarian-bots/model_cards_with_metadata \
50+
yourname/model-cards-entities \
51+
--text-column card \
52+
--entity-types Person Organization Dataset Model Framework \
53+
--device cuda \
54+
--batch-size 32
55+
```
56+
57+
## Reading from local files or a mounted bucket
58+
59+
The `input_dataset` argument also accepts local file paths (parquet, jsonl, json, csv). Useful when the input is staged in a [Storage Bucket](https://huggingface.co/docs/hub/storage-buckets) — typical pattern for multi-stage pipelines where an upstream Job has prepared the data:
60+
61+
```bash
62+
hf jobs uv run --flavor t4-small --secrets HF_TOKEN \
63+
-v hf://buckets/yourname/working-data:/input \
64+
https://huggingface.co/datasets/uv-scripts/gliner/raw/main/extract-entities.py \
65+
/input/data.parquet \
66+
yourname/output-entities \
67+
--text-column text --entity-types Person Organization Location \
68+
--device cuda --batch-size 32
69+
```
70+
71+
Local paths are detected heuristically — anything starting with `/`, `./`, `../`, or ending in a known data extension is treated as a file path; otherwise the argument is interpreted as a HF dataset ID.
72+
73+
## Recommended entity-type vocabularies
74+
75+
GLiNER is open-vocabulary, so any string works. Some starting points:
76+
77+
- **General news/web text**: `Person Organization Location Date Event`
78+
- **ML/AI text (e.g. model cards)**: `Person Organization Dataset Model Framework Metric License`
79+
- **Legal/policy**: `Person Organization Court Statute Date Jurisdiction`
80+
- **Biomedical**: `Drug Disease Gene Protein Symptom`
81+
82+
Quality drops on very abstract or polysemous types — start simple, iterate.
83+
84+
## Models
85+
86+
Default: `urchade/gliner_multi-v2.1` (multilingual, ~600 MB). Override with `--gliner-model`.
87+
88+
Other useful checkpoints:
89+
- `urchade/gliner_small-v2.1` — English, faster
90+
- `urchade/gliner_large-v2.1` — English, larger / higher quality
91+
- `knowledgator/gliner-multitask-large-v0.5` — multitask (NER + classification + relation)
92+
93+
See the [Knowledgator org](https://huggingface.co/knowledgator) and [urchade's models](https://huggingface.co/urchade) for the full set.
94+
95+
## Pairing with Label Studio
96+
97+
Output of this script is a Hugging Face dataset of texts + extracted entities. To put those entities in front of human reviewers, see the `bootstrap-labels` skill (or the workflow it documents): pull this dataset's predictions into a Label Studio project for review, then export a corrected dataset back to the Hub.
98+
99+
## Caveats
100+
101+
- GLiNER predictions are **bootstrap labels** — useful as a starting point, not as ground truth. Plan a review pass before downstream training.
102+
- Texts longer than `--max-text-chars` (default 8000) are truncated. Long-form documents may need chunking + reassembly.
103+
- Entity types are case-sensitive labels in output. Pass them as you want them to appear.

0 commit comments

Comments
 (0)