MCPcopy Create free account
hub / github.com/RingBDStack/GDAP / non_pad_len

Function non_pad_len

seq2seq/utils.py:79–80  ·  view source on GitHub ↗
(tokens: np.ndarray)

Source from the content-addressed store, hash-verified

77
78def build_compute_metrics_fn(task_name: str, tokenizer: PreTrainedTokenizer) -> Callable[[EvalPrediction], Dict]:
79 def non_pad_len(tokens: np.ndarray) -> int:
80 return np.count_nonzero(tokens != tokenizer.pad_token_id)
81
82 def decode_pred(pred: EvalPrediction) -> Tuple[List[str], List[str]]:
83 pred_str = tokenizer.batch_decode(pred.predictions, skip_special_tokens=True)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected