Skip to content

Commit

Permalink
#52: 修复 end position, 保留导致下一个 epoch 错误的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
cjopengler committed Nov 23, 2021
1 parent 2ddd82a commit 8bee885
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
17 changes: 7 additions & 10 deletions data/dataset/mrc_msra_ner/sample.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
[

{
"context": "根 据 选 举 新 闻 中 心 公 布 的 初 步 统 计 结 果 , 至 夜 晚 2 2 时 3 0 分 投 票 结 束 , 全 港 共 有 1 4 8 9 7 0 5 地 区 直 选 选 民 投 票 , 投 票 率 达 5 3 . 2 9 % , 比 1 9 9 5 年 分 别 增 加 近 5 7 万 人 和 1 7 个 多 百 分 点 , 为 香 港 历 史 最 高 纪 录 ; 共 有 7 7 8 1 3 功 能 界 别 选 举 选 民 投 票 , 投 票 率 达 6 3 . 5 % ; 选 举 委 员 会 选 举 投 票 选 民 达 到 7 9 0 人 , 投 票 率 高 达 9 8 . 7 5 %",
"context": "各 方 力 量 的 共 同 努 力 , 使 瑞 金 1 8 0 多 处 不 可 移 动 文 物 绝 大 部 分 得 到 应 有 的 保 护 , 为 合 理 利 用 革 命 文 物 打 下 了 基 础",
"end_position": [
7,
129
12
],
"entity_label": "NT",
"entity_label": "NS",
"impossible": false,
"qas_id": "13563.3",
"query": "组织包括公司,政府党派,学校,政府,新闻机构",
"qas_id": "36875.1",
"query": "按照地理位置划分的国家,城市,乡镇,大洲",
"span_position": [
"2;7",
"125;129"
"11;12"
],
"start_position": [
2,
125
11
]
}
]
1 change: 0 additions & 1 deletion mrc/data/bert_model_collate.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ def __call__(self, instances: List[Instance]) -> MRCModelInputs:

# 是因为在 offset 中, 对于 index 的设置,就是 [start, end)
end_positions = [end_pos + 1 for end_pos in end_positions]
instance["end_positions"] = end_positions

# 因为 query 和 context 拼接在一起了,所以 start_position 和 end_position 的位置要重新映射
origin_offset2token_idx_start = {}
Expand Down

0 comments on commit 8bee885

Please sign in to comment.