我想使用小队数据集微调 LabSE 以进行问答。我收到这个错误:
ValueError: The model did not return a loss from the inputs, only the following keys: last_hidden_state,pooler_output. For reference, the inputs it received are input_ids,token_type_ids,attention_mask.
我正在尝试使用 pytorch 微调模型。我尝试使用较小的批量大小,但只使用了 10% 的训练数据集,因为我遇到了内存分配问题。如果内存分配问题消失,则会发生此错误。老实说,我坚持了下来。你有什么提示吗?
我正在尝试使用 Huggingface 教程,但我想使用其他评估(我想自己做),所以我跳过了使用数据集的评估部分。
from datasets import load_dataset
raw_datasets = load_dataset("squad", split='train')
from transformers import BertTokenizerFast, BertModel
from transformers import AutoTokenizer
model_checkpoint = "setu4993/LaBSE"
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
model = BertModel.from_pretrained(model_checkpoint)
max_length = 384
stride = 128
def preprocess_training_examples(examples):
questions = [q.strip() for q in examples["question"]]
inputs = tokenizer(
questions, …
Run Code Online (Sandbox Code Playgroud)