From 2dba54df8c60c1e311d83818260249f2d190050d Mon Sep 17 00:00:00 2001 From: sunhailin Date: Mon, 8 Jul 2024 11:26:41 +0800 Subject: [PATCH] fix w2ner.pieces2word nil slice issues --- models/transformers/bert_w2ner.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/models/transformers/bert_w2ner.go b/models/transformers/bert_w2ner.go index 53f0f95..bf99f5e 100644 --- a/models/transformers/bert_w2ner.go +++ b/models/transformers/bert_w2ner.go @@ -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++ {