Skip to content

Commit 0dae66d

Browse files
committed
min as score for token level
1 parent 9068a2f commit 0dae66d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

gliner/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.2.16"
1+
__version__ = "0.2.17"
22

33
from .model import GLiNER
44
from .config import GLiNERConfig

gliner/decoding/decoder.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,13 @@ def calculate_span_score(self, start_idx, end_idx, scores_inside_i, start_i, end
7171
ins = scores_inside_i[st:ed + 1, cls_st]
7272
if (ins < threshold).any():
7373
continue
74-
spn_score = ins.mean().item()
74+
# Get the start and end scores for this span
75+
start_score = start_i[st, cls_st]
76+
end_score = end_i[ed, cls_st]
77+
# Concatenate the inside scores with start and end scores
78+
combined = torch.cat([ins, start_score.unsqueeze(0), end_score.unsqueeze(0)])
79+
# The span score is the minimum value among these scores
80+
spn_score = combined.min().item()
7581
span_i.append((st, ed, id_to_classes[cls_st + 1], spn_score))
7682
return span_i
7783

0 commit comments

Comments
 (0)