lvwerra HF Staff commited on
Commit
8346f7f
·
1 Parent(s): bb0956e

Update Space (evaluate main: f05792ff)

Browse files
Files changed (2) hide show
  1. perplexity.py +1 -1
  2. requirements.txt +1 -1
perplexity.py CHANGED
@@ -166,7 +166,7 @@ class Perplexity(evaluate.Metric):
166
  encoded_batch = encoded_texts[start_index:end_index]
167
  attn_mask = attn_masks[start_index:end_index]
168
 
169
- if add_start_token:
170
  bos_tokens_tensor = torch.tensor([[tokenizer.bos_token_id]] * encoded_batch.size(dim=0)).to(device)
171
  encoded_batch = torch.cat([bos_tokens_tensor, encoded_batch], dim=1)
172
  attn_mask = torch.cat(
 
166
  encoded_batch = encoded_texts[start_index:end_index]
167
  attn_mask = attn_masks[start_index:end_index]
168
 
169
+ if add_start_token and tokenizer.bos_token_id is not None:
170
  bos_tokens_tensor = torch.tensor([[tokenizer.bos_token_id]] * encoded_batch.size(dim=0)).to(device)
171
  encoded_batch = torch.cat([bos_tokens_tensor, encoded_batch], dim=1)
172
  attn_mask = torch.cat(
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
- git+https://github.com/huggingface/evaluate@b39b26694046961b9ae97a0458b290fc992df2b1
2
  torch
3
  torch
4
  transformers
 
1
+ git+https://github.com/huggingface/evaluate@f05792fff67a356f696fdf17ac64bd99602794c4
2
  torch
3
  torch
4
  transformers