BERT
Collection
5 items
•
Updated
This model is a fine-tuned version of microsoft/MiniLM-L12-H384-uncased on hf-tuner/squad_v2.0.1 dataset.
It achieves the following results on the evaluation set:
Several correct predictions were incorrectly marked as false negatives due to strict exact-match criteria being sensitive to minor differences in tokenization, formatting, or span boundaries:
schrodinger equation → Rejected (expected: schrödinger equation)feynman diagrams → Rejected (expected: feynman)electromagnetic force → Rejected (expected: electromagnetic)45 000 pounds → Rejected (expected: 45000 pounds)MiniLMv1-L12-H384-uncased: 12-layer, 384-hidden, 12-heads, 33M parameters, 2.7x faster than BERT-Base
Can be integrated into chatbots, virtual assistants, or search systems that require question answering over text.
import torch
from transformers import BertForQuestionAnswering, AutoTokenizer
model_id='hf-tuner/bert-mini-squadv2'
device = 'cuda' if torch.cuda.is_available() else 'cpu'
tokenizer = AutoTokenizer.from_pretrained(model_id)
bert_qa = BertForQuestionAnswering.from_pretrained(model_id).to(device)
bert_qa = bert_qa.half()
def get_answers(ctxq):
inputs = tokenizer(ctxq, padding=True, return_tensors='pt')
for k,v in inputs.items():
inputs[k] = v.to(device)
with torch.no_grad():
outputs = bert_qa(**inputs)
start_idxs = outputs.start_logits.argmax(dim=-1)
end_idxs = outputs.end_logits.argmax(dim=-1)
predictions = []
for i, (start_idx, end_idx) in enumerate(zip(start_idxs, end_idxs)):
if start_idx == end_idx:
predictions.append("<no_answer>")
else:
predict_answer_tokens = inputs['input_ids'][i, start_idx : end_idx]
pred_answer = tokenizer.decode(predict_answer_tokens)
predictions.append(pred_answer)
return predictions
context = """In Q3 2024, xAI raised $6 billion in a Series C round led by Valor Equity Partners and Andreessen Horowitz, with participation from Sequoia Capital, Fidelity, and Saudi Arabia’s Kingdom Holding Company, bringing its post-money valuation to $50 billion.
"""
question_1 = "Which two investors co-led xAI’s $6 billion Series C round announced in Q3 2024?"
question_2 = "On what exact date in Q3 2024 was xAI’s $6 billion Series C funding round officially closed?"
get_answers([
[context, question_1],
[context, question_2],
])
>>> ['valor equity partners and andreessen horowitz', '<no_answer>']
The following hyperparameters were used during training:
| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| 1.3678 | 1.0 | 8134 | 1.4974 |
| 1.1809 | 2.0 | 16268 | 1.4653 |
Base model
microsoft/MiniLM-L12-H384-uncased