Skip to content

Commit

Permalink
fix w2ner.pieces2word nil slice issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sunhailin committed Jul 8, 2024
1 parent 6e384dd commit 2dba54d
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions models/transformers/bert_w2ner.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,11 @@ func (w *W2NerModelService) getBertInputFeature(batchInferData [][]string) []*W2
for j := 0; j < padTokenLen; j++ {
gridMask2d[j] = generateAllTrueSlice(padTokenLen)

if j >= len(inferTokens) {
if j >= len(inferTokens) || len(inferTokens[j]) == 0 {
pieces2word[j] = make([]bool, len(batchInputFeatures[i].TokenIDs))
continue
}

if len(inferTokens[j]) == 0 {
continue
}

idx := utils.GenerateRange[int](start, start+len(inferTokens[j]))
pieces2word[j] = make([]bool, len(batchInputFeatures[i].TokenIDs))
for k := 0; k < len(pieces2word[j]); k++ {
Expand Down

0 comments on commit 2dba54d

Please sign in to comment.