kzfastino commited on
Commit
7d046fd
·
verified ·
1 Parent(s): 2125c8a

Add a Fine-tuning section with training-row formats

Browse files

Adds a **Fine-tuning** section, answering [discussion #9](https://huggingface.co/fastino/GLiNER2.5-Decide/discussions/9).

- A table maps each `classify_text` schema on this card (plain, `multi_label`, `prompt`, described labels, ordinal, several decisions) to its training-row form.
- Five example JSONL rows, one per schema type. All pass `gliner2` `TrainingDataset.validate()`.
- A minimal `ExtractorTrainer` snippet.
- A note that ordinal labels train as plain classes, so report MAE as well as accuracy.

Only the new section is added; nothing else on the card changes.

Files changed (1) hide show
  1. README.md +36 -0
README.md CHANGED
@@ -475,6 +475,42 @@ Potential output:
475
  {"rating": "7"}
476
  ```
477
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
478
  ## Details
479
 
480
  - **What it is:** a specialist classifier for operational decisions, including questions over a passage, books, described labels, and ordinal scores
 
475
  {"rating": "7"}
476
  ```
477
 
478
+ ## Fine-tuning
479
+
480
+ Every schema on this card has a training form. One JSONL row holds the text and the correct answer for each decision. Each object in `classifications` is one decision, with the same `task`, `labels`, `prompt` and `multi_label` you pass to `classify_text`.
481
+
482
+ | On this card | In a training row |
483
+ | --- | --- |
484
+ | `{"intent": [...]}` | `{"task": "intent", "labels": [...], "true_label": ["refund_request"]}` |
485
+ | `"multi_label": True` | `"multi_label": true`, with every correct label in `true_label`. `cls_threshold` is inference-only |
486
+ | `"prompt": "Did …?"` | the same `"prompt"` |
487
+ | `"labels": {name: description}` | `"labels": [names]` plus `"label_descriptions": {name: description}` |
488
+ | ordinal `["0", …, "10"]` | an ordinary single-label row, for example `"true_label": ["7"]` |
489
+ | several decisions in one call | several objects in `classifications` |
490
+
491
+ ```jsonl
492
+ {"input": "My subscription renewed after the service was already down. Can I get that charge refunded?", "output": {"classifications": [{"task": "intent", "labels": ["order_status", "refund_request", "cancel_subscription", "other"], "true_label": ["refund_request"]}]}}
493
+ {"input": "Battery dies before lunch, but the keyboard and the screen are great.", "output": {"classifications": [{"task": "aspects", "labels": ["battery", "keyboard", "screen", "camera", "price"], "true_label": ["battery", "keyboard", "screen"], "multi_label": true}]}}
494
+ {"input": "The treaty was signed in Paris in 1992 and entered into force the following year.", "output": {"classifications": [{"task": "answer", "labels": ["yes", "no"], "prompt": "Did the treaty enter into force in 1992?", "true_label": ["no"]}]}}
495
+ {"input": "Please reset the card PIN. The old one is locked after three tries.", "output": {"classifications": [{"task": "intent", "labels": ["card_pin_change", "card_lost", "balance_inquiry"], "label_descriptions": {"card_pin_change": "The customer wants a new PIN or the current PIN replaced", "card_lost": "The physical card is missing", "balance_inquiry": "The customer wants the current balance"}, "true_label": ["card_pin_change"]}]}}
496
+ {"input": "I finished it in two nights. The ending is earned and the middle drags.", "output": {"classifications": [{"task": "rating", "labels": ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"], "true_label": ["7"]}]}}
497
+ ```
498
+
499
+ ```python
500
+ # pip install "gliner2[train]"
501
+ from gliner2 import AutoExtractor
502
+ from gliner2.training.trainer import ExtractorTrainer, TrainingConfig
503
+
504
+ model = AutoExtractor.from_pretrained("fastino/GLiNER2.5-Decide")
505
+ config = TrainingConfig(output_dir="out", num_epochs=3, batch_size=8)
506
+ ExtractorTrainer(model, config).train(train_data="train.jsonl")
507
+ tuned = AutoExtractor.from_pretrained("out/final")
508
+ ```
509
+
510
+ An ordinal scale trains as plain classes. Each label is scored on its own, and the loss does not know that `"6"` is closer to `"7"` than `"0"` is. Measure an ordinal head with mean absolute error as well as accuracy.
511
+
512
+ More row formats are in the [GLiNER2 training data guide](https://github.com/fastino-ai/GLiNER2/blob/main/tutorial/8-train_data.md). Or describe the task to [Fastino Agent](https://agent.fastino.ai) and it builds the data and runs the fine-tune for you.
513
+
514
  ## Details
515
 
516
  - **What it is:** a specialist classifier for operational decisions, including questions over a passage, books, described labels, and ordinal scores