Toxic span detection asks a model to highlight exactly which characters of a post make it offensive, so that moderators see the violation without rereading the whole post. Current detectors find single swear words well and fail on longer toxic phrases. On the SemEval-2021 benchmark, a strong transformer tagger scores about 0.65 F1 on one-word spans and below 0.10 on spans of five or more words (Cisco at SemEval-2021 Task 5). We think this is an imbalance problem in disguise. Most tokens in a post are non-toxic, and the inner tokens of a long toxic phrase are an even rarer group within the toxic tokens. They are also far from any lexical cue. A per-token loss gives the model almost no signal on them. Low-resource languages make it worse: the best code-mixed Tamil system reaches 0.4489 character F1 (NITK-IT_NLP@TamilNLP-ACL2022).
We propose to split the task in two. First, find "anchor" words that are clearly toxic, which models already do well. Then decide how far the toxicity extends by choosing among the syntactic units that contain the anchor. Those units come from a dependency parse, which is a tree linking each word to the word it grammatically depends on. The extent decision becomes a small, roughly balanced choice among a handful of nested phrases, instead of thousands of rare per-token labels. The parse gives the candidates a linguistically sensible shape. A deliberately matched non-syntactic candidate set tells us whether the syntax actually matters.
Core Claim
Recasting span extent as a choice among the dependency subtrees that contain each anchor should raise F1 on spans of three or more words, without hurting single-word spans. The gain should exceed what loss reweighting, contiguity constraints, or linear-window growth achieve, and it should hold up under realistic parser errors in Turkish and code-mixed Tamil. If gold toxic spans do not line up with subtrees, or if equally many linear windows work as well, the claim is false. Both outcomes are measured directly.
Relation to Prior Work
Two systems already put toxicity and syntax in one pipeline. Neither uses tree structure to decide extent.
Muted finds offensive words from attention maps and then applies spaCy subject and object rules to find who is attacked. Its parses degraded badly on German tweets, and syntax acted only as a fixed post-filter. Its result constrains our design: we must measure and hedge against parser noise rather than assume clean trees.
Cisco used a biaffine dependency-parsing architecture only as a scorer over start–end index pairs. It did not use any head–dependent relations, and the file reports no number for it. Cisco motivates our proposal, since it measured the long-span collapse, but it did not address that collapse.
The winning SemEval system, HITSZ-HLT, ensembles BIO-style taggers with a start/end boundary model. It enforces contiguity but has no notion of grammatical constituents.
On the imbalance side, two vision papers offer reusable alternatives. Smile Transformer scales the loss by sample difficulty. CCL-Net replaces one-hot targets with learned soft labels. We adapt the first as a competitor, because it is the obvious "fix imbalance in the loss" answer.
On the low-resource side, two papers shape the setup. HATECAT-TR shows that local encoders such as BERTurk beat multilingual LLMs on Turkish spans, so we use local encoders. The typology-based treebank selection method chooses which treebanks to combine using word-order subtree statistics; we reuse it to build parsers for languages with little syntactic data.
Research Program
The anchor stage is an ordinary token tagger, trained with cross-entropy on gold toxic tokens and tuned for precision. It uses the same encoder as each baseline: RoBERTa for English, BERTurk for Turkish, MuRIL for Tamil.
For each predicted anchor $a$, let $h(a)$ be its syntactic head and $T(w)$ the set of characters covered by the subtree rooted at word $w$. The candidate set is the anchor alone plus $T(a)$, $T(h(a))$, $T(h(h(a)))$, and so on, up to the clause root, which typically gives three to six nested candidates. A scorer $s_\theta(a,c,x)$ reads the encoder states pooled over candidate $c$, its boundaries, and the dependency label on the path. It defines
$$p(c \mid a, x) = \frac{\exp s_\theta(a,c,x)}{\sum_{c' \in C(a)} \exp s_\theta(a,c',x)},$$
where $x$ is the post and $C(a)$ is the candidate set. The training target is the candidate with the highest character overlap with the gold span containing $a$. Predictions from all anchors are merged by union.
Every anchor contributes exactly one training decision of this kind. A ten-word span therefore costs one example, not ten weakly supervised minority tokens. This is where the imbalance argument enters.
The parsers are trained on Universal Dependencies treebanks. For Tamil and Turkish, source treebanks are combined following the typology-based selection method. To hedge against parse errors, we take candidates from the top few parses and remove duplicates.
As a secondary output, the subtree chosen for an anchor exposes its subject and object dependents. This gives a learned version of Muted's target extraction, which we evaluate on German TBO.
Baselines
The naive reference is the anchor tagger alone, with no growth stage. It is the same model minus the proposal's key ingredient, so the difference between them is the effect of growing.
The strongest existing single model on SemEval-2021 is HITSZ-HLT's BERT+CRF tagger, at 69.44% character F1 (HITSZ-HLT). Their majority-vote ensemble reaches 70.83%, the shared-task best. Cisco's XLNet-Large BiLSTM-CRF reports 0.6922. We reimplement a CRF tagger and a start/end boundary model on our backbone. Every system gets the same preprocessing, because Cisco reports that text cleaning alone moved F1 by over 16 points. Every system also gets the same seeds and the same hyperparameter search budget.
Beating the baseline has two parts. On the five-or-more-word bucket, F1 must improve by a margin larger than the seed variance. Overall F1 must be at least equal to the reimplemented CRF tagger. Overall F1 is reported against 70.83 only for context, because that figure comes from an ensemble.
For Tamil, the reference is fine-tuned MuRIL at 0.4489 character F1 (NITK-IT_NLP). For Turkish, BERTurk on HATECAT-TR is the reference. No aggregate span-detection F1 for BERTurk on HATECAT-TR was found on Lacuna; only per-category figures such as about 0.44 on threats are reported. We therefore retrain BERTurk ourselves.
The key ablation replaces the subtree candidates with linear windows around the anchor. These windows are matched in number and length distribution to the subtree candidates, and the scorer and training are identical. This isolates whether syntax adds anything beyond growing outward.
Why not just…?
Why not just reweight the loss toward long spans or hard tokens? Weighting inner tokens by the length of their span, or a difficulty-scaled loss like the one in Smile Transformer, is the cheapest fix and a real threat. One concern is that it may also upweight noisy boundaries: span annotations have only moderate agreement (0.77 F1 on HATECAT-TR), so hard tokens are often ambiguous rather than learnable. We run both length-bucket reweighting and dynamic difficulty weighting on the anchor tagger. If either matches our long-span gains, the decomposition is unnecessary, and we will report that outcome.
Why not just rely on a CRF or a start/end boundary model, which already produce contiguous spans? These are exactly the systems Cisco and HITSZ-HLT used. Cisco's under-0.10 long-span figure came from a CRF system, so contiguity alone evidently does not solve extent. Our length-bucket comparison against both systems tests this directly.
Why not just grow anchors over linear windows, or fill small gaps between predicted words? If toxicity extends to adjacent words regardless of grammar, syntax is decoration. The matched linear-window ablation and a gap-filling heuristic, with its window size tuned on the development set, settle this question. We expect syntax to win mainly on non-adjacent and clause-sized spans. If it does not, the paper's conclusion becomes "grow, don't parse."
Why not just use a bigger or more local pretrained model? Local encoders do help, as HATECAT-TR shows. Our method uses the same local encoder in every comparison, so any gain is in addition to that choice and not a substitute for it.
Proposed Experiments
The first check comes before any training. It parses the gold data and computes, for each language, the fraction of gold spans whose character overlap with the best candidate in $C(a)$ exceeds 0.8. This is the oracle ceiling, computed separately for each length bucket. If the oracle is not clearly higher for subtree candidates than for matched linear windows on multi-word spans, we stop.
The main experiments train every system on SemEval-2021 (English), HATECAT-TR (Turkish), and the DravidianLangTech Tamil set. We report character F1 overall and in buckets of one, two to four, and five or more words, across five seeds.
The parser-robustness check runs on English. We train parsers on progressively smaller treebank subsets to reach a range of labeled attachment scores, then plot span F1 against parser accuracy. The goal is to locate the parser accuracy below which syntax-based growth stops beating linear windows. We then compare where the Turkish and Tamil parsers likely fall relative to that threshold. Because there is no gold syntax for code-mixed Tamil, we estimate its parse quality by agreement among the top few parses.
Finally, we evaluate target-plus-argument F1 on German TBO against Piccolo-HAP's 0.44 (Muted). This tests whether learned subtree growth improves on rule-based extraction over noisy parses.
References
- Cisco at SemEval-2021 Task 5: What's Toxic?: Leveraging Transformers for Multiple Toxic Span Extraction from Online Comments
- NITK-IT_NLP@TamilNLP-ACL2022: Transformer based model for Toxic Span Identification in Tamil
- Muted: Multilingual Targeted Offensive Speech Identification and Visualization
- HITSZ-HLT at SemEval-2021 Task 5: Ensemble Sequence Labeling and Span Boundary Detection for Toxic Span Detection
- Fine-Grained Facial Expression Recognition in Multiple Smiles
- Learning and Exploiting Interclass Visual Correlations for Medical Image Classification
- HATECAT-TR: A Hate Speech Span Detection and Categorization Dataset for Turkish
- Corpus-based Syntactic Typological Methods for Dependency Parsing Improvement