Skip to content

Commit 3237ec7

Browse files
committed
feat: compute eds.ner_crf loss as mean over words
1 parent b6833c2 commit 3237ec7

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@
9999
- The loss of `eds.ner_crf` is now computed as the mean over the words instead of the sum. This change is compatible with multi-gpu training.
100100
- Having multiple stats keys matching a batching pattern now warns instead of raising an error.
101101

102+
### Changed
103+
104+
- The loss of `eds.ner_crf` is now computed as the mean over the words instead of the sum. This change is compatible with multi-gpu training.
105+
- Having multiple stats keys matching a batching pattern now warns instead of raising an error.
106+
102107
### Fixed
103108

104109
- Support packaging with poetry 2.0

edsnlp/pipes/trainable/ner_crf/ner_crf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,9 @@ def collate(self, preps) -> NERBatchInput:
454454
k: sum(v) for k, v in preps["stats"].items() if not k.startswith("__")
455455
},
456456
}
457+
collated["stats"] = {
458+
k: sum(v) for k, v in preps["stats"].items() if not k.startswith("__")
459+
}
457460
lengths = [length for sample in preps["lengths"] for length in sample]
458461
max_len = max(lengths)
459462
if "targets" in preps:

0 commit comments

Comments
 (0)