rajpurkar/squad_v2
Viewer • Updated • 142k • 41.1k • 274
How to use much1na/ettin-400m-squadv2 with Transformers:
# Use a pipeline as a high-level helper
# Warning: Pipeline type "question-answering" is no longer supported in transformers v5.
# You must load the model directly (see below) or downgrade to v4.x with:
# pip install "transformers<5.0.0"
from transformers import pipeline
pipe = pipeline("question-answering", model="much1na/ettin-400m-squadv2") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForQuestionAnswering
tokenizer = AutoTokenizer.from_pretrained("much1na/ettin-400m-squadv2")
model = AutoModelForQuestionAnswering.from_pretrained("much1na/ettin-400m-squadv2", device_map="auto")This model is fine-tuned from jhu-clsp/ettin-encoder-400m for extractive question answering. Given a question and a passage, it marks the span of the passage that answers the question. It was trained on the SQuAD 2.0 train split of rajpurkar/squad_v2.
learning_rate = 5e-05
batch_size = 32 (global, over 1 process(es); 8 per GPU x 4 accumulation steps)
optimizer = adamw_torch
gradient_checkpointing = True
n_epochs = 2
max_steps = -1 (-1 means use n_epochs)
max_seq_len = 384
doc_stride = 128
warmup_ratio = 0.1
weight_decay = 0.01
seed = 42
precision = fp16
| Split | Exact match | F1 | Training loss |
|---|---|---|---|
| SQuAD 2.0 validation | 86.63 | 90.01 | 0.5903 |
import torch
from transformers import AutoModelForQuestionAnswering, AutoTokenizer
tok = AutoTokenizer.from_pretrained("much1na/ettin-400m-squadv2")
model = AutoModelForQuestionAnswering.from_pretrained("much1na/ettin-400m-squadv2")
question = "Who designed the Eiffel Tower?"
context = "The Eiffel Tower was built by the company of Gustave Eiffel."
enc = tok(question, context, return_tensors="pt", truncation="only_second", max_length=384, return_offsets_mapping=True)
offsets = enc.pop("offset_mapping")[0].tolist()
ctx = [i for i, s in enumerate(enc.sequence_ids(0)) if s == 1]
with torch.no_grad():
out = model(**enc)
start = ctx[int(out.start_logits[0, ctx].argmax())]
end = ctx[int(out.end_logits[0, ctx].argmax())]
print(context[offsets[start][0]:offsets[end][1]])
Trained with train.py (v2 settings, 1 process(es), fp16) on 2026-11-08.
Base model
jhu-clsp/ettin-encoder-400m