Views
No views yet
Qwen/Qwen3-4B-Instruct-2507. Trained to convert a
rough extracted span of an arXiv paper into the frontier-cleaned funding
statement (with surrounding LaTeX/markdown artifacts stripped, whitespace
normalized, and multi-line statements joined), or to emit NONE if the rough
span is not actually a funding statement.cometadata/funding-extraction-modernbert-base-spanhead); this LoRA
cleans that rough span into the canonical text that frontier labelers
(Claude / GPT) would write.1from transformers import AutoModelForCausalLM, AutoTokenizer
2from peft import PeftModel
3
4base = "Qwen/Qwen3-4B-Instruct-2507"
5tokenizer = AutoTokenizer.from_pretrained(base)
6model = AutoModelForCausalLM.from_pretrained(base, dtype="bfloat16", device_map="auto")
7model = PeftModel.from_pretrained(model, "cometadata/funding-cleaning-qwen3-4b-lora")
8model.eval()
9
10SYSTEM = (
11 "You are a funding statement cleaner. Given a rough extracted funding "
12 "statement and its surrounding context from an academic paper, output the "
13 "exact funding statement as it should appear in a database. Clean up LaTeX "
14 "markers ($^{N}$, \\textsuperscript), hyphenated line breaks, and "
15 "abnormal whitespace, but DO NOT paraphrase. If the rough span is not "
16 "actually a funding statement, output the single word: NONE"
17)
18
19# `rough_span` is the output of a span-tagger (e.g., a ModernBERT BIO model).
20# `context_left` and `context_right` are ~400 chars of the document on each side.
21user = f"{context_left}<ROUGH>{rough_span}</ROUGH>{context_right}"
22
23messages = [
24 {"role": "system", "content": SYSTEM},
25 {"role": "user", "content": user},
26]
27inputs = tokenizer.apply_chat_template(
28 messages, tokenize=True, add_generation_prompt=True, return_tensors="pt"
29).to(model.device)
30out = model.generate(inputs, max_new_tokens=512, do_sample=False)
31pred = tokenizer.decode(out[0, inputs.shape[1]:], skip_special_tokens=True).strip()
32# If pred == "NONE", treat as no funding statement.cometadata/arxiv-pdf-only-works-funding-statement-extraction-train-test.
Each training example is a chat-format triple (SYSTEM, USER, ASSISTANT):vlm_markdown window of ±400 characters around a rough
span, with the rough span itself marked by literal <ROUGH>...</ROUGH> tags.funding_statements field (or the literal string NONE for negatives).vlm_markdown (verbatim where
possible; otherwise rapidfuzz.partial_ratio_alignment); rows where no
alignment ≥ 0.7 is found are dropped (~24 rows);[-80, +80]
characters and snapping each endpoint to the nearest whitespace. This
simulates the boundary noise produced by an upstream extractive tagger.<ROUGH>...</ROUGH> window of 100–300
characters inside a random 800-char chunk of vlm_markdown; target is NONE.You are a funding statement cleaner. Given a rough extracted funding statement
and its surrounding context from an academic paper, output the exact funding
statement as it should appear in a database. Clean up LaTeX markers ($^{N}$,
\textsuperscript), hyphenated line breaks, and abnormal whitespace, but DO
NOT paraphrase. If the rough span is not actually a funding statement, output
the single word: NONE... left context up to 400 chars ...
<ROUGH>rough extracted span as a single block, no line breaks added</ROUGH>
... right context up to 400 chars ...NONE.Qwen/Qwen3-4B-Instruct-2507q_proj, k_proj, v_proj, o_proj, gate_proj,
up_proj, down_proj (attention + MLP only — NOT embed_tokens/lm_head)completion_only_loss=True — loss is computed only on the assistant tokensSFTTrainer 0.29.0, transformers 5.2.0, peft 0.18.1ModernBERT-base span tagger,
cometadata/funding-extraction-modernbert-base-spanhead, supplies the rough
span; this adapter does the cleanup):| Metric | Precision | Recall | F1 | F0.5 |
|---|---|---|---|---|
| Binary detection | 0.9887 | 0.9510 | 0.9694 | 0.9809 |
Strict span (token_sort_ratio≥0.95) | 0.7394 | 0.7112 | 0.7250 | 0.7336 |
| Loose span (max-of-4 fuzz ≥ 0.85) | 0.9717 | 0.9346 | 0.9528 | 0.9640 |
$^{N}$ markers and joining
sentences correctly. Cases where the LoRA over-rewrites (changes which
sentence it emits) sometimes hurt; net effect is positive.NONE for negatives; if your pipeline cannot route NONE to an
empty prediction, you'll see it as a literal string.cometadata/arxiv-pdf-only-works-funding-statement-extraction-train-test
dataset. The labels in that dataset were produced by frontier models; this
adapter learns to match that label distribution.