Instructions to use ai4data/datause-extraction-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use ai4data/datause-extraction-v2 with PEFT:
Task type is invalid.
- Transformers
How to use ai4data/datause-extraction-v2 with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("ai4data/datause-extraction-v2", dtype="auto") - GLiNER2
How to use ai4data/datause-extraction-v2 with GLiNER2:
from gliner2 import GLiNER2 model = GLiNER2.from_pretrained("ai4data/datause-extraction-v2") # Extract entities text = "Apple CEO Tim Cook announced iPhone 15 in Cupertino yesterday." result = extractor.extract_entities(text, ["company", "person", "product", "location"]) print(result) - Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -20,38 +20,28 @@ This is a fine-tuned LoRA adapter for `fastino/gliner2-large-v1` trained to extr
|
|
| 20 |
|
| 21 |
---
|
| 22 |
|
| 23 |
-
##
|
| 24 |
-
|
| 25 |
-
The model is trained on a **7-field all-string schema** to optimize the GLiNER2 count head and prevent collapse.
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
| 32 |
|
| 33 |
-
###
|
| 34 |
-
```python
|
| 35 |
-
SCHEMA = {
|
| 36 |
-
"data_mention": [
|
| 37 |
-
"name::str::The exact full name of the data source or dataset",
|
| 38 |
-
"acronym::str::The acronym or abbreviation if any",
|
| 39 |
-
"specificity::str::Whether this mention is named, descriptive, or vague",
|
| 40 |
-
"usage::str::Whether this is primary, supporting, or background data",
|
| 41 |
-
"datatype::str::The type of data verbatim from text such as survey, report, census, program, system, or assessment",
|
| 42 |
-
"producer::str::The organization or entity that produced or published the data",
|
| 43 |
-
"timeframe::str::The year or time period of the data such as 2019 or 2019 to 2020",
|
| 44 |
-
]
|
| 45 |
-
}
|
| 46 |
-
```
|
| 47 |
|
| 48 |
-
|
| 49 |
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
-
###
|
| 53 |
|
| 54 |
-
|
| 55 |
|
| 56 |
```python
|
| 57 |
from ai4data import extract_from_text, extract_from_document
|
|
@@ -69,57 +59,73 @@ pdf_results = extract_from_document("report.pdf", pages=[0, 1, 2])
|
|
| 69 |
print(pdf_results)
|
| 70 |
```
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
If you want to use the raw `gliner2` model and adapter:
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
"
|
| 90 |
-
"
|
| 91 |
-
"
|
| 92 |
-
"
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
"
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
"
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
"
|
| 102 |
-
"
|
| 103 |
-
"
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
text
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
```
|
| 122 |
|
|
|
|
|
|
|
| 123 |
## Annotation Guidelines & What Counts as a Data Mention
|
| 124 |
|
| 125 |
### Specificity Taxonomy
|
|
|
|
| 20 |
|
| 21 |
---
|
| 22 |
|
| 23 |
+
## How to Get Started with the Model
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
It is **highly recommended** to use this model through the official **`ai4data`** Python library wrapper. The library automatically handles:
|
| 26 |
+
- **Markdown-aware chunking** (respecting model context limits).
|
| 27 |
+
- **Character offset index adjustment** across multiple chunk pages.
|
| 28 |
+
- **Greedy overlap resolution** and text normalization.
|
| 29 |
+
- **Pre-filtering pre-classifiers** to skip non-data pages.
|
| 30 |
+
- **Deduplication** and acronym matching.
|
| 31 |
|
| 32 |
+
### 1. Installation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
Clone and install the repository:
|
| 35 |
|
| 36 |
+
```bash
|
| 37 |
+
git clone <repository-url>
|
| 38 |
+
cd monitoring_of_datause
|
| 39 |
+
uv sync
|
| 40 |
+
```
|
| 41 |
|
| 42 |
+
### 2. Python Usage
|
| 43 |
|
| 44 |
+
To extract dataset mentions and their attributes (like timeframe, producer, and acronyms):
|
| 45 |
|
| 46 |
```python
|
| 47 |
from ai4data import extract_from_text, extract_from_document
|
|
|
|
| 59 |
print(pdf_results)
|
| 60 |
```
|
| 61 |
|
| 62 |
+
---
|
|
|
|
|
|
|
| 63 |
|
| 64 |
+
## Model Schema & Response Structure
|
| 65 |
+
|
| 66 |
+
The model extracts up to 7 attributes per data mention. When querying via `ai4data`, each extracted entity in the `"datasets"` list has the following structure:
|
| 67 |
+
|
| 68 |
+
```json
|
| 69 |
+
{
|
| 70 |
+
"mention_name": {
|
| 71 |
+
"text": "Demographic and Health Survey",
|
| 72 |
+
"confidence": 0.9999,
|
| 73 |
+
"start": 23,
|
| 74 |
+
"end": 52
|
| 75 |
+
},
|
| 76 |
+
"specificity_tag": {
|
| 77 |
+
"text": "named",
|
| 78 |
+
"confidence": 0.9999,
|
| 79 |
+
"start": 23,
|
| 80 |
+
"end": 52
|
| 81 |
+
},
|
| 82 |
+
"usage_context": {
|
| 83 |
+
"text": "primary",
|
| 84 |
+
"confidence": 0.9999,
|
| 85 |
+
"start": 23,
|
| 86 |
+
"end": 52
|
| 87 |
+
},
|
| 88 |
+
"typology_tag": {
|
| 89 |
+
"text": "survey",
|
| 90 |
+
"confidence": 0.9999,
|
| 91 |
+
"start": 23,
|
| 92 |
+
"end": 52
|
| 93 |
+
},
|
| 94 |
+
"acronym": {
|
| 95 |
+
"text": "DHS",
|
| 96 |
+
"confidence": 0.9996,
|
| 97 |
+
"start": 54,
|
| 98 |
+
"end": 57
|
| 99 |
+
},
|
| 100 |
+
"producer": {
|
| 101 |
+
"text": "National Statistics Office",
|
| 102 |
+
"confidence": 0.9999,
|
| 103 |
+
"start": 72,
|
| 104 |
+
"end": 98
|
| 105 |
+
},
|
| 106 |
+
"reference_year": {
|
| 107 |
+
"text": "2022",
|
| 108 |
+
"confidence": 0.9999,
|
| 109 |
+
"start": 18,
|
| 110 |
+
"end": 22
|
| 111 |
+
},
|
| 112 |
+
"is_used": {
|
| 113 |
+
"text": "True",
|
| 114 |
+
"confidence": 0.9999,
|
| 115 |
+
"start": 23,
|
| 116 |
+
"end": 52
|
| 117 |
+
},
|
| 118 |
+
"geography": {
|
| 119 |
+
"text": "",
|
| 120 |
+
"confidence": 0.9999,
|
| 121 |
+
"start": 23,
|
| 122 |
+
"end": 52
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
```
|
| 126 |
|
| 127 |
+
---
|
| 128 |
+
|
| 129 |
## Annotation Guidelines & What Counts as a Data Mention
|
| 130 |
|
| 131 |
### Specificity Taxonomy
|