rajpurkar/squad
Viewer • Updated • 98.2k • 159k • 366
How to use llm-semantic-router/mmbert-fact-check-lora with PEFT:
from peft import PeftModel
from transformers import AutoModelForSequenceClassification
base_model = AutoModelForSequenceClassification.from_pretrained("jhu-clsp/mmBERT-base")
model = PeftModel.from_pretrained(base_model, "llm-semantic-router/mmbert-fact-check-lora")A multilingual binary classifier that determines whether a query requires external fact-checking or can be answered without verification.
This model classifies prompts into two categories:
Supports 1800+ languages through mmBERT's multilingual pretraining.
| Metric | Score |
|---|---|
| Accuracy | 96.2% |
| F1 | 96.2% |
| Precision | 96.2% |
| Recall | 96.2% |
| Training Time | 151 seconds (MI300X GPU) |
FACT_CHECK_NEEDED:
NO_FACT_CHECK_NEEDED:
from peft import PeftModel
from transformers import AutoModelForSequenceClassification, AutoTokenizer
# Load model
base_model = AutoModelForSequenceClassification.from_pretrained(
"jhu-clsp/mmBERT-base", num_labels=2
)
model = PeftModel.from_pretrained(base_model, "llm-semantic-router/mmbert-fact-check-lora")
tokenizer = AutoTokenizer.from_pretrained("jhu-clsp/mmBERT-base")
# Classify
queries = [
"When was the Eiffel Tower built?", # FACT_CHECK_NEEDED
"Write a poem about the ocean", # NO_FACT_CHECK_NEEDED
]
for query in queries:
inputs = tokenizer(query, return_tensors="pt", truncation=True)
outputs = model(**inputs)
label = "FACT_CHECK_NEEDED" if outputs.logits.argmax(-1).item() == 1 else "NO_FACT_CHECK_NEEDED"
print(f"{query} -> {label}")
This model is part of the vLLM Semantic Router project.
Apache 2.0
Base model
jhu-clsp/mmBERT-base