Release unilineal model
Browse files- README.md +60 -0
- tokenizer.json +0 -0
- tokenizer_config.json +16 -0
- unilineal/config.json +92 -0
- unilineal/model.safetensors +3 -0
README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: transformers
|
| 3 |
+
pipeline_tag: token-classification
|
| 4 |
+
tags:
|
| 5 |
+
- name-splitting
|
| 6 |
+
- ner
|
| 7 |
+
- modernbert
|
| 8 |
+
- names
|
| 9 |
+
language:
|
| 10 |
+
- es
|
| 11 |
+
- en
|
| 12 |
+
- pt
|
| 13 |
+
license: mit
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# Tori v2 — Name Splitter
|
| 17 |
+
|
| 18 |
+
ModernBERT-base (149M params) fine-tuned for splitting full name strings into
|
| 19 |
+
**forenames** and **surnames** using BIO token classification.
|
| 20 |
+
|
| 21 |
+
## Variants
|
| 22 |
+
|
| 23 |
+
| Variant | Countries | Surname Pattern | Subfolder |
|
| 24 |
+
|---------|-----------|-----------------|-----------|
|
| 25 |
+
| **bilineal** (default) | MX, CO, ES, PE, CL | Double surname (paternal + maternal) | `/` (root) |
|
| 26 |
+
| **unilineal** | AR, US, BR, PT | Single surname | `unilineal/` |
|
| 27 |
+
|
| 28 |
+
## Usage
|
| 29 |
+
|
| 30 |
+
```python
|
| 31 |
+
from tori.inference import load_pipeline, split_name
|
| 32 |
+
|
| 33 |
+
# Default: bilineal model (double-surname countries)
|
| 34 |
+
pipe = load_pipeline("ittailup/tori2")
|
| 35 |
+
result = split_name(pipe, "Juan Carlos García López")
|
| 36 |
+
print(result.forenames) # ['Juan', 'Carlos']
|
| 37 |
+
print(result.surnames) # ['García', 'López']
|
| 38 |
+
|
| 39 |
+
# Unilineal model (single-surname countries)
|
| 40 |
+
pipe = load_pipeline("ittailup/tori2", variant="unilineal")
|
| 41 |
+
result = split_name(pipe, "John Michael Smith")
|
| 42 |
+
print(result.forenames) # ['John', 'Michael']
|
| 43 |
+
print(result.surnames) # ['Smith']
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
## Labels
|
| 47 |
+
|
| 48 |
+
- `O` — Outside any name entity
|
| 49 |
+
- `B-forenames` — Beginning of forename
|
| 50 |
+
- `I-forenames` — Inside forename (continuation)
|
| 51 |
+
- `B-surnames` — Beginning of surname
|
| 52 |
+
- `I-surnames` — Inside surname (continuation)
|
| 53 |
+
|
| 54 |
+
## Important: Custom Aggregation Required
|
| 55 |
+
|
| 56 |
+
This model uses ModernBERT's GPT-style BPE tokenizer (Ġ prefix), which is
|
| 57 |
+
**not compatible** with HuggingFace's built-in `aggregation_strategy="simple"`.
|
| 58 |
+
Use the `tori.inference` module which handles subword aggregation correctly,
|
| 59 |
+
or use `aggregation_strategy="none"` and aggregate tokens yourself using
|
| 60 |
+
character offsets.
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"clean_up_tokenization_spaces": true,
|
| 4 |
+
"cls_token": "[CLS]",
|
| 5 |
+
"is_local": false,
|
| 6 |
+
"mask_token": "[MASK]",
|
| 7 |
+
"model_input_names": [
|
| 8 |
+
"input_ids",
|
| 9 |
+
"attention_mask"
|
| 10 |
+
],
|
| 11 |
+
"model_max_length": 8192,
|
| 12 |
+
"pad_token": "[PAD]",
|
| 13 |
+
"sep_token": "[SEP]",
|
| 14 |
+
"tokenizer_class": "TokenizersBackend",
|
| 15 |
+
"unk_token": "[UNK]"
|
| 16 |
+
}
|
unilineal/config.json
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"ModernBertForTokenClassification"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"bos_token_id": null,
|
| 8 |
+
"classifier_activation": "gelu",
|
| 9 |
+
"classifier_bias": false,
|
| 10 |
+
"classifier_dropout": 0.0,
|
| 11 |
+
"classifier_pooling": "mean",
|
| 12 |
+
"cls_token_id": 50281,
|
| 13 |
+
"decoder_bias": true,
|
| 14 |
+
"deterministic_flash_attn": false,
|
| 15 |
+
"dtype": "float32",
|
| 16 |
+
"embedding_dropout": 0.0,
|
| 17 |
+
"eos_token_id": null,
|
| 18 |
+
"global_attn_every_n_layers": 3,
|
| 19 |
+
"gradient_checkpointing": false,
|
| 20 |
+
"hidden_activation": "gelu",
|
| 21 |
+
"hidden_size": 768,
|
| 22 |
+
"id2label": {
|
| 23 |
+
"0": "O",
|
| 24 |
+
"1": "B-forenames",
|
| 25 |
+
"2": "I-forenames",
|
| 26 |
+
"3": "B-surnames",
|
| 27 |
+
"4": "I-surnames"
|
| 28 |
+
},
|
| 29 |
+
"initializer_cutoff_factor": 2.0,
|
| 30 |
+
"initializer_range": 0.02,
|
| 31 |
+
"intermediate_size": 1152,
|
| 32 |
+
"label2id": {
|
| 33 |
+
"B-forenames": 1,
|
| 34 |
+
"B-surnames": 3,
|
| 35 |
+
"I-forenames": 2,
|
| 36 |
+
"I-surnames": 4,
|
| 37 |
+
"O": 0
|
| 38 |
+
},
|
| 39 |
+
"layer_norm_eps": 1e-05,
|
| 40 |
+
"layer_types": [
|
| 41 |
+
"full_attention",
|
| 42 |
+
"sliding_attention",
|
| 43 |
+
"sliding_attention",
|
| 44 |
+
"full_attention",
|
| 45 |
+
"sliding_attention",
|
| 46 |
+
"sliding_attention",
|
| 47 |
+
"full_attention",
|
| 48 |
+
"sliding_attention",
|
| 49 |
+
"sliding_attention",
|
| 50 |
+
"full_attention",
|
| 51 |
+
"sliding_attention",
|
| 52 |
+
"sliding_attention",
|
| 53 |
+
"full_attention",
|
| 54 |
+
"sliding_attention",
|
| 55 |
+
"sliding_attention",
|
| 56 |
+
"full_attention",
|
| 57 |
+
"sliding_attention",
|
| 58 |
+
"sliding_attention",
|
| 59 |
+
"full_attention",
|
| 60 |
+
"sliding_attention",
|
| 61 |
+
"sliding_attention",
|
| 62 |
+
"full_attention"
|
| 63 |
+
],
|
| 64 |
+
"local_attention": 128,
|
| 65 |
+
"max_position_embeddings": 8192,
|
| 66 |
+
"mlp_bias": false,
|
| 67 |
+
"mlp_dropout": 0.0,
|
| 68 |
+
"model_type": "modernbert",
|
| 69 |
+
"norm_bias": false,
|
| 70 |
+
"norm_eps": 1e-05,
|
| 71 |
+
"num_attention_heads": 12,
|
| 72 |
+
"num_hidden_layers": 22,
|
| 73 |
+
"pad_token_id": 50283,
|
| 74 |
+
"position_embedding_type": "absolute",
|
| 75 |
+
"rope_parameters": {
|
| 76 |
+
"full_attention": {
|
| 77 |
+
"rope_theta": 160000.0,
|
| 78 |
+
"rope_type": "default"
|
| 79 |
+
},
|
| 80 |
+
"sliding_attention": {
|
| 81 |
+
"rope_theta": 10000.0,
|
| 82 |
+
"rope_type": "default"
|
| 83 |
+
}
|
| 84 |
+
},
|
| 85 |
+
"sep_token_id": 50282,
|
| 86 |
+
"sparse_pred_ignore_index": -100,
|
| 87 |
+
"sparse_prediction": false,
|
| 88 |
+
"tie_word_embeddings": true,
|
| 89 |
+
"transformers_version": "5.2.0",
|
| 90 |
+
"use_cache": false,
|
| 91 |
+
"vocab_size": 50368
|
| 92 |
+
}
|
unilineal/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0660ea79c428e1e2991c25982ea283f727ff83bf4697d0a56dbb2365a5adbde6
|
| 3 |
+
size 598449012
|