Views
No views yet

verbatim-rag-modern-bert-v1.
Built on
Alibaba-NLP/gte-reranker-modernbert-base,
which provides the long ModernBERT context (up to 8192 tokens) and a
query-conditioned reranking prior on top of which span extraction is fine-tuned.KRLabsOrg/verbatim-spans,
which adds financial tables, legal contracts, medical literature, product
manuals, and — uniquely among public extractors — coding-agent tool output
(pytest failures, git diff hunks, stack traces). The result is a single
150M-parameter encoder usable across the content shapes a real RAG or agent
pipeline tends to retrieve, not just article paragraphs.KRLabsOrg/acl-verbatim-modernbert.KRLabsOrg/verbatim-spans (multi-domain)| content shape | source |
|---|---|
| scientific paragraphs with citations | ACL silver |
| Wikipedia / general QA, multi-hop | RAGBench (HotpotQA, MS MARCO, ExpertQA, ...) |
| financial tables | RAGBench (TAT-QA, FinQA) |
| medical literature | RAGBench (PubMedQA, CovidQA) |
| legal contracts | RAGBench (CUAD) |
| product manuals | RAGBench (eManual, TechQA) |
| code, tool output, stack traces, logs | Squeez (SWE-bench tool outputs) |
(question, context) pair is encoded as a single sequence; the model
predicts a per-token positive-class probability over the context tokens. Above
a threshold, contiguous positive runs are merged into character spans, with
post-processing (min_span_chars, merge_gap_chars) that removes
fragmentation artifacts. Long contexts are handled with sliding windows of
max_length tokens stepped by doc_stride, and spans are merged across
windows.1from transformers import AutoModel
2
3model = AutoModel.from_pretrained(
4 "KRLabsOrg/verbatim-rag-modern-bert-v2",
5 trust_remote_code=True,
6)
7
8result = model.process(
9 question="What is ModernBERT?",
10 context=(
11 "ModernBERT is a long-context encoder for NLP. "
12 "It supports sequences up to 8192 tokens. "
13 "Unlike earlier BERT variants, it uses rotary position embeddings."
14 ),
15 threshold=0.2,
16)
17
18for span in result["spans"]:
19 print(f"[{span['score']:.2f}] {span['text']}")1from verbatim_rag.core import VerbatimRAG
2from verbatim_rag.index import VerbatimIndex
3from verbatim_rag.extractors import ModelSpanExtractor
4from verbatim_rag.vector_stores import LocalMilvusStore
5from verbatim_rag.embedding_providers import SpladeProvider
6
7# v2 is the default ModelSpanExtractor model, but passing it explicitly makes
8# the dependency clear.
9extractor = ModelSpanExtractor(
10 model_path="KRLabsOrg/verbatim-rag-modern-bert-v2",
11 threshold=0.2,
12 min_span_chars=30,
13 merge_gap_chars=20,
14 device=None, # auto-detects cuda, then mps, then cpu
15)
16
17sparse_provider = SpladeProvider(
18 model_name="opensearch-project/opensearch-neural-sparse-encoding-doc-v2-distill",
19 device="cuda", # use "cpu" if no GPU is available
20)
21
22vector_store = LocalMilvusStore(
23 db_path="./index.db",
24 collection_name="verbatim_rag",
25 enable_dense=False,
26 enable_sparse=True,
27)
28
29# Assumes the index has already been populated with your documents.
30index = VerbatimIndex(
31 vector_store=vector_store,
32 sparse_provider=sparse_provider,
33)
34
35rag = VerbatimRAG(
36 index=index,
37 extractor=extractor,
38 k=5,
39)
40
41response = rag.query("Main findings of the paper?")
42print(response.answer)1from transformers import AutoModel
2
3extractor = AutoModel.from_pretrained(
4 "KRLabsOrg/verbatim-rag-modern-bert-v2",
5 trust_remote_code=True,
6)
7
8question = "What evidence supports using DINOv2 as the visual backbone?"
9context = (
10 "We investigate different visual backbones for feature extraction. "
11 "The results demonstrate DINOv2's effectiveness as a feature extractor "
12 "for sign language translation."
13)
14
15result = extractor.process(question=question, context=context)
16
17for span in result["spans"]:
18 print(
19 {
20 "start": span["start"],
21 "end": span["end"],
22 "text": span["text"],
23 "score": span["score"],
24 }
25 ).process() accepts: question, context, threshold (default 0.2),
max_length (default 8192), doc_stride (default 256), min_span_chars
(default 30), merge_gap_chars (default 20), return_sentence_metrics
(default False). For short-answer benchmarks (file paths, table cells,
numbers), threshold=0.1 and min_span_chars=10 is the recall-tuned config
documented in Performance below.{"spans": [{"start": int, "end": int, "text": str, "score": float}, ...]}, with "sentences" added when
return_sentence_metrics=True. Spans are character offsets into the input
context and are merged across sliding windows.acl-verbatim. The current
metric protocol scores every row in a slice: rows without gold spans are
negative examples, and false-positive extracted text lowers precision.| dataset | system | Word-P | Word-R | Word-F1 | IoU@0.5 | AnyOverlap | OverPred |
|---|---|---|---|---|---|---|---|
| ACL gold | verbatim-rag-modern-bert-v2 | 0.625 | 0.368 | 0.463 | 0.366 | 0.449 | 0.679 |
| ACL gold | Zilliz semantic-highlight | 0.470 | 0.221 | 0.301 | 0.113 | 0.513 | 1.500 |
| ACL gold | Provence | 0.276 | 0.457 | 0.344 | 0.153 | 0.718 | 3.013 |
| RAGBench | verbatim-rag-modern-bert-v2 | 0.516 | 0.770 | 0.618 | 0.309 | 0.753 | 0.732 |
| RAGBench | Zilliz semantic-highlight | 0.573 | 0.362 | 0.443 | 0.316 | 0.358 | 0.581 |
| RAGBench | Provence | 0.430 | 0.547 | 0.481 | 0.317 | 0.547 | 0.922 |
| Squeez | verbatim-rag-modern-bert-v2 | 0.506 | 0.700 | 0.588 | 0.511 | 0.809 | 1.572 |
| Squeez | Zilliz semantic-highlight | 0.184 | 0.352 | 0.242 | 0.098 | 0.658 | 3.866 |
| Squeez | Provence | 0.107 | 0.576 | 0.180 | 0.103 | 0.756 | 3.951 |
| QASPER | verbatim-rag-modern-bert-v2 | 0.688 | 0.409 | 0.513 | 0.366 | 0.515 | 0.848 |
| QASPER | Zilliz semantic-highlight | 0.622 | 0.191 | 0.293 | 0.122 | 0.479 | 0.793 |
| QASPER | Provence | 0.522 | 0.435 | 0.474 | 0.285 | 0.737 | 1.413 |
docs/GENERIC_EVAL.md.1@misc{Recski:2026,
2 title={ACL-Verbatim: hallucination-free question answering for research},
3 author={Gábor Recski and Szilveszter Tóth and Nadia Verdha and István Boros and Ádám Kovács},
4 year={2026},
5 eprint={2605.21102},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2605.21102},
9}