Instructions to use cmboulanger/tei-bibl-annotator with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use cmboulanger/tei-bibl-annotator with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="cmboulanger/tei-bibl-annotator") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("cmboulanger/tei-bibl-annotator") model = AutoModelForCausalLM.from_pretrained("cmboulanger/tei-bibl-annotator", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use cmboulanger/tei-bibl-annotator with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "cmboulanger/tei-bibl-annotator" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cmboulanger/tei-bibl-annotator", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/cmboulanger/tei-bibl-annotator
- SGLang
How to use cmboulanger/tei-bibl-annotator with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "cmboulanger/tei-bibl-annotator" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cmboulanger/tei-bibl-annotator", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "cmboulanger/tei-bibl-annotator" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "cmboulanger/tei-bibl-annotator", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use cmboulanger/tei-bibl-annotator with Docker Model Runner:
docker model run hf.co/cmboulanger/tei-bibl-annotator
TEI Bibliographic Annotator
A LoRA fine-tune of Qwen/Qwen2.5-3B-Instruct,
merged back into the base weights, that tags a plain-text bibliographic citation
with inline TEI XML markup. It reproduces the input text exactly, inserting
tags around the spans that carry bibliographic structure (author, title, date,
publisher, and so on) โ nothing is paraphrased or normalized away. The output is
just the tagged citation: no XML declaration, no wrapping element.
Source & training pipeline: github.com/cboulanger/tei-annotation-model
ยท Live demo: cmboulanger/tei-bibl-annotator-demo
The training citations come from footnotes in legal-sociology scholarship (mostly German, some English), where citations are frequently given in short-form or anaphoric form ("Id.", "ibid.", a bare case name introduced earlier) and are mixed in with the author's own prose โ harder than the clean one-per-line entries of a reference list.
Example:
input: Scheingold, The Politics of Rights (1974).
output: <author><persName><surname>Scheingold</surname></persName>,</author>
<title level="a">The Politics of Rights</title> <date>(1974).</date>
License
This checkpoint is for research use only. The base model,
Qwen/Qwen2.5-3B-Instruct, is released under Alibaba's
Qwen Research License,
which restricts commercial use. Because the LoRA adapter is merged directly
into the base weights, this checkpoint is a derivative work and inherits those
terms. See the linked license text for the exact conditions.
How to use
The model expects the same chat prompt used during training and evaluation: a
fixed system instruction plus the raw citation as the user turn. Generation is
greedy (do_sample=False), max_new_tokens=1024.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
REPO = "cmboulanger/tei-bibl-annotator"
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
INSTRUCTIONS = (
"Tag this bibliographic citation with inline TEI XML markup, exactly "
"reproducing the input text with tags inserted around the parts that "
"carry structure (author, title, date, etc). Output only the tagged "
"citation, with no XML declaration or wrapping element."
)
def build_messages(input_text: str) -> list[dict]:
return [
{"role": "system", "content": INSTRUCTIONS},
{"role": "user", "content": input_text},
]
tokenizer = AutoTokenizer.from_pretrained(REPO)
model = AutoModelForCausalLM.from_pretrained(REPO, dtype=torch.bfloat16).to(DEVICE)
model.eval()
input_text = "Scheingold, The Politics of Rights (1974)."
inputs = tokenizer.apply_chat_template(
build_messages(input_text), add_generation_prompt=True,
tokenize=True, return_dict=True, return_tensors="pt",
).to(DEVICE)
with torch.inference_mode():
generated = model.generate(**inputs, max_new_tokens=1024, do_sample=False)
completion_ids = generated[:, inputs["input_ids"].shape[1]:]
print(tokenizer.batch_decode(completion_ids, skip_special_tokens=True)[0].strip())
Results
First training pilot: LoRA fine-tune (rank 16, all attention + MLP projections) for 3 epochs over the 9,050-record train set; training loss dropped to 0.028. Scored on the full 1,207-record held-out dev set:
| Metric | Result |
|---|---|
| Parse success (valid TEI XML) | 99.83% (1,205 / 1,207) |
| Exact match (byte-identical to gold markup) | 42.50% (513 / 1,207) |
These are a lightweight sanity signal โ is the output well-formed, and how often is a citation exactly right โ not a full per-field or per-tier evaluation.
Training data
99 TEI documents, each a <listBibl> of individually tagged <bibl> citation
records extracted from footnotes. After filtering one degenerate record,
11,467 records remain, split by whole document (a document's citations are
never split across sets) at roughly an 80/10/10 ratio:
| Split | Documents | Records |
|---|---|---|
| train | 78 | 9,050 |
| dev | 10 | 1,207 |
| test | 10 | 1,210 |
The split is stratified so the rare legal tier (citations containing a case
reference) appears in the dev and test sets, not only in train.
- Downloads last month
- -