opf-finetune

Fine-tune OpenAI Privacy Filter for custom token-classification span tagging of legal text.

1|Updated May 8, 2026
One-click install
npx skills add https://github.com/franklinbaldo/skills --skill opf-finetune-franklinbaldo
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: opf-finetune
Source: https://github.com/franklinbaldo/skills/tree/main/opf-finetune
Command: npx skills add https://github.com/franklinbaldo/skills --skill opf-finetune-franklinbaldo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires cyclopts, and includes scripts (resource) and references (resource) components.

What problem does it solve? Tagging regions and spans of text (document sections, structural markers, field values) usually means brittle regex or expensive prompt-based extraction. This Skill guides fine-tuning the OpenAI Privacy Filter (OPF), a small bidirectional token-classifier, to detect arbitrary custom span categories with a trained model instead. ## Core Features & Use Cases - Custom label-space fine-tuning: Define your own span ontology (JSON label space + JSONL annotations with character offsets) and train OPF via its opf train CLI, with replace-vs-union guidance for keeping native PII categories. - Ontology design patterns: Anchor-based schemes (single-anchor and start/end pairs) that work around OPF's banded attention so long regions are reconstructed in post-processing rather than dense-labeled. - Annotation tooling and validation: A bundled opf_annotate.py script validates offsets, overlaps, and label-space coverage, converts match-based spans to offsets, and previews boundaries inline. - Use Case: Segment Brazilian legal decisions into relatório, fundamentação, and dispositivo sections by fine-tuning OPF on a few thousand PT-BR annotated examples, then extracting the operative outcome for downstream statistics. ## Quick Start Ask the agent to design a span label space and fine-tune OPF on your annotated JSONL training file to tag custom regions in your documents.

Frequently Asked Questions about opf-finetune

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fine-tune OpenAI Privacy Filter on custom labels?▼

Prepare JSONL annotations with character-offset spans, define a label-space JSON with O as the first entry, then run opf train with --validation-dataset, --label-space-json, and --output-dir flags. Confirm exact flags with opf train --help.

What is the annotation format for OPF token classification training?▼

One JSON object per line with text, a label list of {category, start, end} spans, and optional info metadata. Offsets are character offsets, start inclusive and end exclusive, so text[start:end] equals the span surface.

Can OPF tag long document regions like an entire legal section?▼

Not directly, because banded attention and BIOES decoding favor short contiguous spans. Tag short anchor cues or start/end marker pairs instead, then reconstruct the long region in post-processing between matched anchors.

Does OPF work on Portuguese or non-English text?▼

OPF is English-primary and its model card warns of degraded performance on non-English text. PT-BR legal text is out of distribution, so budget more annotated examples and always validate on an in-domain PT-BR held-out split.

When should I not use OPF fine-tuning for extraction?▼

Avoid it for generative extraction like writing summaries, for patterns a stable regex already nails, and for out-of-the-box PII redaction which needs no fine-tune. OPF is a span detector, not a chat model.

Why do my OPF span offsets shift after accented characters?▼

The offsets are character offsets, not byte offsets. Accented PT-BR characters are multi-byte in UTF-8 but single characters in Python str, so counting bytes silently shifts every span after the first accent.