Views
No views yet
allenai/scibert_scivocab_uncased trained for scientific paper retrieval inside the Research Library project. It embeds paper queries and metadata cards so a user can search, rank, and navigate papers by title, abstract, category, and author metadata.allenai/scibert_scivocab_uncased.PeytonT/1m_papers_text, a 1M-paper full-text and metadata dataset. Training used the metadata fields available in the local Research Library pipeline:titleabstractcategoriesauthorsallenai/scibert_scivocab_uncasedFEATURE_EXTRACTION8320.05query, value512256bf16adamw1e-4100039071.00.02501import torch
2import torch.nn.functional as F
3from transformers import AutoModel, AutoTokenizer
4from peft import PeftModel
5
6repo_id = "PeytonT/1m-paper-embedding-model"
7base_id = "allenai/scibert_scivocab_uncased"
8
9tokenizer = AutoTokenizer.from_pretrained(repo_id)
10base = AutoModel.from_pretrained(base_id)
11model = PeftModel.from_pretrained(base, repo_id)
12model.eval()
13
14def embed(texts):
15 batch = tokenizer(
16 texts,
17 padding=True,
18 truncation=True,
19 max_length=256,
20 return_tensors="pt",
21 )
22 with torch.no_grad():
23 outputs = model(**batch)
24 mask = batch["attention_mask"].unsqueeze(-1)
25 pooled = (outputs.last_hidden_state * mask).sum(dim=1) / mask.sum(dim=1).clamp_min(1)
26 return F.normalize(pooled, dim=1)
27
28query = embed(["retrieval augmented generation for scientific literature"])
29docs = embed([
30 "Title: Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks\nCategories: cs.CL",
31 "Title: Quantum error correction with superconducting qubits\nCategories: quant-ph",
32])
33
34scores = query @ docs.T
35print(scores)0.19.1