This model accompanies the
scifact-relevance-classifier project, the Lab 3 / Assignment 1 deliverable for
Information Retrieval 5LN712 (Master's in Language Technology, Uppsala University, 2026).
1import pickle
2import numpy as np
3from huggingface_hub import hf_hub_download
4from sentence_transformers import SentenceTransformer
5
6REPO = "andreiaalexa/scifact-relevance-classifier"
7
8# 1) Download the trained classifier
9clf_path = hf_hub_download(REPO, "classifier.pkl")
10with open(clf_path, "rb") as f:
11 clf = pickle.load(f)
12
13# 2) Load the (public) embedding model used at training time
14encoder = SentenceTransformer("intfloat/e5-small-v2")
15
16# 3) Build pair features (E5 asymmetric prefixes, then InferSent recipe)
17def pair_features(claims, documents):
18 q = encoder.encode([f"query: {c}" for c in claims], normalize_embeddings=True)
19 d = encoder.encode([f"passage: {p}" for p in documents], normalize_embeddings=True)
20 cos = np.sum(q * d, axis=1, keepdims=True)
21 return np.hstack([q, d, np.abs(q - d), q * d, cos])
22
23# 4) Predict
24claim = "Vitamin D supplementation reduces respiratory infections."
25title = "Vitamin D supplementation to prevent acute respiratory tract infections."
26abstract = "Randomized trials have evaluated whether vitamin D supplementation prevents acute respiratory tract infections in diverse populations."
27document = f"{title}. {abstract}"
28
29X = pair_features([claim], [document])
30pred_id = int(clf.predict(X)[0])
31proba = clf.predict_proba(X)[0]
32
33label = {0: "not_relevant", 1: "relevant"}[pred_id]
34print(f"prediction = {label} | P(relevant) = {proba[1]:.3f}")
Five classifier families compared. Best-in-row in bold.
If you use this model, please cite both the underlying dataset (SciFact / BEIR) and the embedding model:
1@inproceedings{wadden-etal-2020-fact,
2 title = "Fact or Fiction: Verifying Scientific Claims",
3 author = "Wadden, David and Lin, Shanchuan and Lo, Kyle and Wang, Lucy Lu and van Zuylen, Madeleine and Cohan, Arman and Hajishirzi, Hannaneh",
4 booktitle = "EMNLP", year = "2020",
5 url = "https://aclanthology.org/2020.emnlp-main.609/"
6}
7
8@article{wang-etal-2022-text-embeddings,
9 title = "Text Embeddings by Weakly-Supervised Contrastive Pre-training",
10 author = "Wang, Liang and Yang, Nan and Huang, Xiaolong and Jiao, Binxing and Yang, Linjun and Jiang, Daxin and Majumder, Rangan and Wei, Furu",
11 journal = "arXiv:2212.03533", year = "2022",
12 url = "https://arxiv.org/abs/2212.03533"
13}
14
15@inproceedings{conneau-etal-2017-supervised,
16 title = "Supervised Learning of Universal Sentence Representations from Natural Language Inference Data",
17 author = "Conneau, Alexis and Kiela, Douwe and Schwenk, Holger and Barrault, Lo{\"i}c and Bordes, Antoine",
18 booktitle = "EMNLP", year = "2017",
19 url = "https://aclanthology.org/D17-1070/"
20}
MIT.