0

BERT線形レイヤーとその上のレイヤーで事前トレーニングされた質問応答システムを作成していsoftmaxます。ネットで入手可能なテンプレートに従うと、通常、1 つの例のラベルは 1answer_start_indexと 1だけで構成されanswer_end_indexます。たとえば、オブジェクトHuggingfaceをインスタンス化するときから:SQUADFeatures

```
self.input_ids = input_ids
self.attention_mask = attention_mask
self.token_type_ids = token_type_ids
self.cls_index = cls_index
self.p_mask = p_mask

self.example_index = example_index
self.unique_id = unique_id
self.paragraph_len = paragraph_len
self.token_is_max_context = token_is_max_context
self.tokens = tokens
self.token_to_orig_map = token_to_orig_map

self.start_position = start_position
self.end_position = end_position
self.is_impossible = is_impossible
self.qas_id = qas_id
```

しかし、私自身のデータセットでは、回答語がコンテキスト内の複数の場所で見つかった例があります。つまり、回答を構成する正しいスパンがいくつかある可能性があります。

私の問題は、そのような例を管理する方法がわからないことですか? ネット ラベルで利用可能なテンプレートは、通常、次のように一覧表示されます。

  • [start_example1, start_example2, start_example3]
  • [end_example1, end_example2, end_example3]

私の場合、これは次のようになります。

  • [start_example1, [start_example2_1, start_example2_2], start_example3]
  • もちろん最後も同じ

言い換えれば、例ごとに 1 つのラベルを含むリストはありませんが、例として単一ラベルまたは「ラベル」のリスト、つまりリストで構成されるリストのいずれかを含むリストがあります。

他のテンプレートに従う場合、プロセスの次のステップは次のとおりです。

```
input_ids = torch.cat(input_ids, dim=0)
attention_masks = torch.cat(attention_masks, dim=0)
token_type_ids = torch.cat(token_type_ids, dim=0)
span_starts = torch(span_starts) #Something like this
span_ends = torch(span_ends) #Something like this
```

ただし、これはもちろん (?) 私の span_start リストと span_end リストには単一項目だけが含まれているのではなく、リスト内のリストが含まれている場合があるため、エラーが発生します。

この問題にどのように取り組むことができるかについて誰にも考えがありますか? コンテキストに存在する回答を構成するスパンが 1 つしかない例のみを使用する必要がありますか?

torch-error を回避した場合、損失の逆伝播 / 評価 / 計算は引き続き機能しますか?

ありがとう!/B

4

1 に答える 1