# /// script # requires-python = ">=3.11,<3.14" # dependencies = [ # "gliner2[train]==2.0.0", # "protobuf", # "sentencepiece", # "datasets>=4.0.0,<6", # "scikit-learn", # "huggingface-hub", # ] # # [tool.hf-jobs] # flavor = "t4-small" # timeout = "1h" # secrets = ["HF_TOKEN"] # /// """ Fine-tune GLiNER2 into a text classifier — a small model (74M to 287M parameters, depending on the base checkpoint) that already works zero-shot. GLiNER2 reads the label names as part of its input, so it classifies with no training at all. This script measures that zero-shot score first, fine-tunes on your labels, then measures again on the same held-out rows. The model card reports both numbers. One model can answer several questions at once: pass --label-column more than once and each column becomes a task. Run on HF Jobs (t4-small is enough for a few thousand short texts): hf jobs uv run --flavor t4-small --timeout 1h --secrets HF_TOKEN \\ https://huggingface.co/datasets/uv-scripts/classification/raw/main/train-gliner2.py \\ biglam/blbooksgenre username/gliner2-blbooks-genre \\ --dataset-config title_genre_classifiction --text-column title The output model repo is PRIVATE unless you pass --public. The [tool.hf-jobs] header above gives `hf` CLI 1.32+ the defaults (t4-small, a 1 hour timeout, the HF_TOKEN secret), so there `hf jobs uv run