You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While using bert_score, I'm trying to use a model that restricted to 512 tokens, i.e. BiomedNLP-PubMedBERT-base-uncased-abstract-fulltext. But there's an error implying I'm trying to use larger tensor than 512 tokens, even though I set the max_length as something lower than 512, that is 500.
File "/root/miniconda3/envs/pl/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/root/miniconda3/envs/pl/lib/python3.9/site-packages/torchmetrics/metric.py", line 236, in forward
self._forward_cache = self._forward_reduce_state_update(*args, **kwargs)
File "/root/miniconda3/envs/pl/lib/python3.9/site-packages/torchmetrics/metric.py", line 303, in _forward_reduce_state_update
batch_val = self.compute()
File "/root/miniconda3/envs/pl/lib/python3.9/site-packages/torchmetrics/metric.py", line 532, in wrapped_func
value = compute(*args, **kwargs)
File "/root/miniconda3/envs/pl/lib/python3.9/site-packages/torchmetrics/text/bert.py", line 221, in compute
return bert_score(
File "/root/miniconda3/envs/pl/lib/python3.9/site-packages/torchmetrics/functional/text/bert.py", line 414, in bert_score
preds_embeddings, preds_idf_scale = _get_embeddings_and_idf_scale(
File "/root/miniconda3/envs/pl/lib/python3.9/site-packages/torchmetrics/functional/text/bert.py", line 98, in _get_embeddings_and_idf_scale
out = model(batch["input_ids"], batch["attention_mask"], output_hidden_states=True)
File "/root/miniconda3/envs/pl/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/root/miniconda3/envs/pl/lib/python3.9/site-packages/transformers/models/bert/modeling_bert.py", line 979, in forward
buffered_token_type_ids_expanded = buffered_token_type_ids.expand(batch_size, seq_length)
RuntimeError: The expanded size of the tensor (523) must match the existing size (512) at non-singleton dimension 1. Target sizes: [1, 523]. Tensor sizes: [1, 512]
May I ask why using this? Or could there be a flag that control whether truncate or not?
that is a good question @stancld?
from my perspective, we can make it an argument... @zhoubay could you pls send a PR with a proposed implementation?
In the context of language models (LLMs), truncation refers to the process of shortening the input text to fit within the model's maximum token limit. Language models like GPT-4 have a maximum number of tokens (words, subwords, or characters) they can process in a single input. If the input text exceeds this limit, truncation is applied to ensure the input does not surpass the model's capacity.
May I ask why using this? Or could there be a flag that control whether truncate or not?
that is a good question @stancld? from my perspective, we can make it an argument... @zhoubay could you pls send a PR with a proposed implementation?
In the context of language models (LLMs), truncation refers to the process of shortening the input text to fit within the model's maximum token limit. Language models like GPT-4 have a maximum number of tokens (words, subwords, or characters) they can process in a single input. If the input text exceeds this limit, truncation is applied to ensure the input does not surpass the model's capacity.
Sure, my pleasure! I'll get down to it as soon as possible!
While using
bert_score
, I'm trying to use a model that restricted to 512 tokens, i.e.BiomedNLP-PubMedBERT-base-uncased-abstract-fulltext
. But there's an error implying I'm trying to use larger tensor than 512 tokens, even though I set themax_length
as something lower than512
, that is500
.The snippets here:
After detailed checking codes, the culprit is the following line, which setting
truncation
asFalse
.torchmetrics/src/torchmetrics/text/bert.py
Line 213 in 6a2fc72
May I ask why using this? Or could there be a flag that control whether truncate or not?
The text was updated successfully, but these errors were encountered: