Skip to content

Commit

Permalink
Merge pull request #26 from huggingface/fix-qa-offsets
Browse files Browse the repository at this point in the history
Fix inequalities in answer spans for QA chapter
  • Loading branch information
lewtun committed Mar 21, 2022
1 parent 82c57b1 commit 1a8221f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions chapters/en/chapter7/section7.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ for i, offset in enumerate(inputs["offset_mapping"]):
context_end = idx - 1

# If the answer is not fully inside the context, label is (0, 0)
if offset[context_start][0] > end_char or offset[context_end][1] < start_char:
if offset[context_start][0] > start_char or offset[context_end][1] < end_char:
start_positions.append(0)
end_positions.append(0)
else:
Expand Down Expand Up @@ -398,7 +398,7 @@ def preprocess_training_examples(examples):
context_end = idx - 1

# If the answer is not fully inside the context, label is (0, 0)
if offset[context_start][0] > end_char or offset[context_end][1] < start_char:
if offset[context_start][0] > start_char or offset[context_end][1] < end_char:
start_positions.append(0)
end_positions.append(0)
else:
Expand Down

0 comments on commit 1a8221f

Please sign in to comment.