Papers › Dice Loss for Data-imbalanced NLP Tasks

Dice Loss for Data-imbalanced NLP Tasks

7 Nov 2019ACL 2020 6arXiv:1911.02855archive 2025-07-28

Xiaoya Li, Xiaofei Sun, Yuxian Meng, Junjun Liang, Fei Wu, Jiwei Li

Many NLP tasks such as tagging and machine reading comprehension are faced with the severe data imbalance issue: negative examples significantly outnumber positive examples, and the huge number of background examples (or easy-negative examples) overwhelms the training. The most commonly used cross entropy (CE) criteria is actually an accuracy-oriented objective, and thus creates a discrepancy between training and test: at training time, each training instance contributes equally to the objective function, while at test time F1 score concerns more about positive examples. In this paper, we propose to use dice loss in replacement of the standard cross-entropy objective for data-imbalanced NLP tasks. Dice loss is based on the Sorensen-Dice coefficient or Tversky index, which attaches similar importance to false positives and false negatives, and is more immune to the data-imbalance issue. To further alleviate the dominating influence from easy-negative examples in training, we propose to associate training examples with dynamically adjusted weights to deemphasize easy-negative examples.Theoretical analysis shows that this strategy narrows down the gap between the F1 score in evaluation and the dice loss in training. With the proposed training objective, we observe significant performance boost on a wide range of data imbalanced NLP tasks. Notably, we are able to achieve SOTA results on CTB5, CTB6 and UD1.4 for the part of speech tagging task; SOTA results on CoNLL03, OntoNotes5.0, MSRA and OntoNotes4.0 for the named entity recognition task; along with competitive results on the tasks of machine reading comprehension and paraphrase identification.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="1911.02855")

Code

Syntology Ran 0 of 3 code samples harvested from 1 repository linked to this paper; 3 have no recorded run.

By repository: official repository: 3 samples from 1 repository, 0 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

ShannonAI/dice_loss_for_NLP officialmentioned in papermentioned on GitHubpytorchApache-2.0 report
fursovia/self-adj-dice mentioned on GitHubpytorchApache-2.0 report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

3 samples harvested; 0 ran; 0 honoured the contract we drafted; 3 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

3unverified

Licence: 0 of the 3 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from ShannonAI/dice_loss_for_NLP. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

collate_to_max_length ShannonAI/dice_loss_for_NLP/datasets/collate_functions.py official repository unverified Apache-2.0 (permissive) · 56ac661b02728040 · report
sample_positive_and_negative_by_ratio ShannonAI/dice_loss_for_NLP/datasets/data_sampling.py official repository unverified Apache-2.0 (permissive) · 3ab7993575889e4a · report
truncated_normal_ ShannonAI/dice_loss_for_NLP/models/classifier.py official repository unverified Apache-2.0 (permissive) · db9f3807cf1d3857 · report

Tasks

Chinese Named Entity RecognitionMachine Reading ComprehensionNamed Entity RecognitionNamed Entity Recognition (NER)Paraphrase IdentificationPart-Of-Speech TaggingQuestion AnsweringReading Comprehensionnamed-entity-recognition

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Chinese Named Entity Recognition MSRA BERT-MRC+DSC F1 96.72 #1 of 21 Archive leaderboard report
Chinese Named Entity Recognition OntoNotes 4 BERT-MRC+DSC F1 84.47 #1 of 15 Archive leaderboard report
Named Entity Recognition (NER) CoNLL 2003 (English) BERT-MRC+DSC F1 93.33 #26 of 73 Archive leaderboard report
Named Entity Recognition (NER) Ontonotes v5 (English) BERT-MRC+DSC F1 92.07 #1 of 28 Archive leaderboard report
Question Answering SQuAD1.1 dev XLNet+DSC EM 89.79 #3 of 55 Archive leaderboard report
Question Answering SQuAD1.1 dev XLNet+DSC F1 95.77 #3 of 55 Archive leaderboard report
Question Answering SQuAD2.0 dev XLNet+DSC EM 87.65 #2 of 13 Archive leaderboard report
Question Answering SQuAD2.0 dev XLNet+DSC F1 89.51 #2 of 13 Archive leaderboard report

Ranks are positions in the archive's leaderboards as they stood at the 2025-07-28 snapshot. Results published since then are not among these rows, so a rank here is not a current standing.

Methods

Dice LossTest

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections