Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Extract structured text, metadata, and references from academic PDFs
.claude/skills/brycewang-stanford-grobid-pdf-parsing/SKILL.md| Model | Eval pass | Runs |
|---|---|---|
| gemini-3.6-flash | 100% | 13 |
| gemini-3.1-pro-preview | 100% | 1 |
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-05 | ✗→✓ | ▲ Improved | 166% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 122% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 93% | 0% |
| case-20 | ✗→✓ | ▲ Improved | 115% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 74% | 0% |
Academic PDFs are the primary format for distributing research, yet extracting structured data from them remains challenging. PDFs encode visual layout, not semantic structure -- headings, paragraphs, equations, tables, and citations are all just positioned text and graphics. GROBID (GeneRation Of BIbliographic Data) is the leading open-source tool for parsing academic PDFs into structured XML/TEI format, extracting metadata, body text, references, and figures with high accuracy.
GROBID is used by major academic platforms including CORE, ResearchGate, and others for large-scale document processing. It combines machine learning models (CRF and deep learning) with heuristic rules to handle the diverse formatting of academic papers across publishers and disciplines.
This guide covers installing and running GROBID, using its REST API for batch processing, extracting specific elements (metadata, references, body sections), and integrating GROBID output into downstream workflows such as knowledge bases, systematic reviews, and literature analysis pipelines.
bash# Pull the latest GROBID image docker pull grobid/grobid:0.8.1 # Run GROBID server docker run --rm --init \ --ulimit core=0 \ -p 8070:8070 \ grobid/grobid:0.8.1 # GROBID is now running at http://localhost:8070 # Web console: http://localhost:8070/console
bashgit clone https://github.com/kermitt2/grobid.git cd grobid ./gradlew clean install ./gradlew run
bash# Process a single PDF and get TEI XML curl -v --form input=@paper.pdf \ http://localhost:8070/api/processFulltextDocument \ -o paper.tei.xml # With options curl -v --form input=@paper.pdf \ --form consolidateHeader=1 \ --form consolidateCitations=1 \ --form includeRawCitations=1 \ http://localhost:8070/api/processFulltextDocument \ -o paper.tei.xml
| Endpoint | Purpose | Input | Output | |----------|---------|-------|--------| | /api/processFulltextDocument | Full paper parsing | PDF | TEI XML | | /api/processHeaderDocument | Metadata only | PDF | TEI XML (header) | | /api/processReferences | Reference parsing | PDF | TEI XML (refs) | | /api/processCitation | Parse citation string | Text | TEI XML | | /api/processDate | Parse date string | Text | Structured date |
pythonimport requests from pathlib import Path class GrobidClient: def __init__(self, base_url='http://localhost:8070'): self.base_url = base_url def process_fulltext(self, pdf_path, consolidate_header=True, consolidate_citations=True): """Process a PDF and return TEI XML.""" url = f'{self.base_url}/api/processFulltextDocument' files = {'input': open(pdf_path, 'rb')} data = { 'consolidateHeader': '1' if consolidate_header else '0', 'consolidateCitations': '1' if consolidate_citations else '0', } response = requests.post(url, files=files, data=data) response.raise_for_status() return response.text def process_header(self, pdf_path): """Extract only header metadata from PDF.""" url = f'{self.base_url}/api/processHeaderDocument' files = {'input': open(pdf_path, 'rb')} response = requests.post(url, files=files) response.raise_for_status() return response.text def is_alive(self): """Check if GROBID server is running.""" try: resp = requests.get(f'{self.base_url}/api/isalive') return resp.status_code == 200 except requests.ConnectionError: return False # Usage client = GrobidClient() if client.is_alive(): tei_xml = client.process_fulltext('paper.pdf') with open('paper.tei.xml', 'w') as f: f.write(tei_xml)
pythonfrom lxml import etree def parse_tei_metadata(tei_xml): """Extract title, authors, abstract from TEI XML.""" ns = {'tei': 'http://www.tei-c.org/ns/1.0'} root = etree.fromstring(tei_xml.encode('utf-8')) # Title title_el = root.find('.//tei:titleStmt/tei:title', ns) title = title_el.text if title_el is not None else '' # Authors authors = [] for author in root.findall('.//tei:sourceDesc//tei:author', ns): forename = author.findtext('.//tei:forename', '', ns) surname = author.findtext('.//tei:surname', '', ns) if surname: authors.append(f'{forename} {surname}'.strip()) # Abstract abstract_el = root.find('.//tei:profileDesc/tei:abstract', ns) abstract = ''.join(abstract_el.itertext()).strip() if abstract_el is not None else '' # DOI doi_el = root.find('.//tei:idno[@type="DOI"]', ns) doi = doi_el.text if doi_el is not None else '' return { 'title': title, 'authors': authors, 'abstract': abstract, 'doi': doi, }
pythondef parse_tei_sections(tei_xml): """Extract structured sections from TEI XML body.""" ns = {'tei': 'http://www.tei-c.org/ns/1.0'} root = etree.fromstring(tei_xml.encode('utf-8')) sections = [] for div in root.findall('.//tei:body/tei:div', ns): head = div.findtext('tei:head', '', ns).strip() paragraphs = [] for p in div.findall('tei:p', ns): text = ''.join(p.itertext()).strip() if text: paragraphs.append(text) sections.append({ 'heading': head, 'n': div.get('n', ''), 'paragraphs': paragraphs, }) return sections
pythondef parse_tei_references(tei_xml): """Extract structured references from TEI XML.""" ns = {'tei': 'http://www.tei-c.org/ns/1.0'} root = etree.fromstring(tei_xml.encode('utf-8')) refs = [] for bib in root.findall('.//tei:listBibl/tei:biblStruct', ns): ref = {'id': bib.get('{http://www.w3.org/XML/1998/namespace}id', '')} # Title title_el = bib.find('.//tei:title[@level="a"]', ns) if title_el is None: title_el = bib.find('.//tei:title', ns) ref['title'] = title_el.text if title_el is not None else '' # Authors ref['authors'] = [] for author in bib.findall('.//tei:author', ns): name = f"{author.findtext('.//tei:forename', '', ns)} {author.findtext('.//tei:surname', '', ns)}".strip() if name: ref['authors'].append(name) # Year date_el = bib.find('.//tei:date[@type="published"]', ns) ref['year'] = date_el.get('when', '') if date_el is not None else '' # DOI doi_el = bib.find('.//tei:idno[@type="DOI"]', ns) ref['doi'] = doi_el.text if doi_el is not None else '' refs.append(ref) return refs
pythonfrom pathlib import Path import json from concurrent.futures import ThreadPoolExecutor def batch_process(pdf_dir, output_dir, max_workers=4): """Process all PDFs in a directory using GROBID.""" client = GrobidClient() pdf_dir = Path(pdf_dir) output_dir = Path(output_dir) output_dir.mkdir(parents=True, exist_ok=True) pdf_files = list(pdf_dir.glob('*.pdf')) print(f"Processing {len(pdf_files)} PDFs...") def process_one(pdf_path): try: tei = client.process_fulltext(str(pdf_path)) meta = parse_tei_metadata(tei) refs = parse_tei_references(tei) # Save TEI XML tei_path = output_dir / f'{pdf_path.stem}.tei.xml' tei_path.write_text(tei) # Save structured JSON json_path = output_dir / f'{pdf_path.stem}.json' json_path.write_text(json.dumps({ 'metadata': meta, 'references': refs, 'n_references': len(refs), }, indent=2)) return pdf_path.name, 'success' except Exception as e: return pdf_path.name, f'error: {str(e)}' with ThreadPoolExecutor(max_workers=max_workers) as executor: results = list(executor.map(process_one, pdf_files)) for name, status in results: print(f" {name}: {status}") batch_process('papers/', 'parsed_output/')
consolidateHeader=1 and consolidateCitations=1 cross-reference against Crossref for better metadata.| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 26,827 | 50,239 | +87% | 1 | 1 | 0% | 5,956 | 6,965 | +17% | 0 | 0 | — |
case-02 | pass→pass | 23,881 | 37,691 | +58% | 1 | 1 | 0% | 5,317 | 9,266 | +74% | 0 | 0 | — |
case-03 | pass→pass | 19,869 | 48,976 | +146% | 1 | 1 | 0% | 2,670 | 5,362 | +101% | 0 | 0 | — |
case-04 | pass→pass | 19,678 | 34,796 | +77% | 1 | 1 | 0% | 3,116 | 7,945 | +155% | 0 | 0 | — |
case-05 | fail→pass | 13,436 | 48,623 | +262% | 1 | 1 | 0% | 2,375 | 6,329 | +166% | 0 | 0 | — |
case-06 | fail→pass | 10,894 | 6,175 | -43% | 1 | 1 | 0% | 1,631 | 3,627 | +122% | 0 | 0 | — |
case-07 | pass→pass | 7,459 | 3,285 | -56% | 1 | 1 | 0% | 1,499 | 3,411 | +128% | 0 | 0 | — |
case-08 | pass→pass | 9,102 | 18,084 | +99% | 1 | 1 | 0% | 1,962 | 5,861 | +199% | 0 | 0 | — |
case-09 | pass→pass | 9,459 | 4,656 | -51% | 1 | 1 | 0% | 1,780 | 3,531 | +98% | 0 | 0 | — |
case-10 | fail→pass | 12,057 | 10,632 | -12% | 1 | 1 | 0% | 2,482 | 4,789 | +93% | 0 | 0 | — |
case-11 | pass→pass | 11,158 | 7,407 | -34% | 1 | 1 | 0% | 2,103 | 4,220 | +101% | 0 | 0 | — |
case-12 | pass→pass | 10,602 | 12,735 | +20% | 1 | 1 | 0% | 1,967 | 4,739 | +141% | 0 | 0 | — |
case-13 | fail→fail | 6,803 | 4,731 | -30% | 1 | 1 | 0% | 1,236 | 3,575 | +189% | 0 | 0 | — |
case-14 | pass→pass | 10,477 | 12,786 | +22% | 1 | 1 | 0% | 2,104 | 5,297 | +152% | 0 | 0 | — |
case-15 | pass→pass | 12,920 | 8,706 | -33% | 1 | 1 | 0% | 2,292 | 4,281 | +87% | 0 | 0 | — |
case-16 | pass→pass | 6,955 | 4,431 | -36% | 1 | 1 | 0% | 950 | 3,590 | +278% | 0 | 0 | — |
case-17 | pass→pass | 16,959 | 19,688 | +16% | 1 | 1 | 0% | 2,666 | 5,609 | +110% | 0 | 0 | — |
case-18 | pass→pass | 13,155 | 11,776 | -10% | 1 | 1 | 0% | 2,610 | 5,083 | +95% | 0 | 0 | — |
case-19 | pass→pass | 12,012 | 12,337 | +3% | 1 | 1 | 0% | 1,999 | 4,480 | +124% | 0 | 0 | — |
case-20 | fail→pass | 9,287 | 5,152 | -45% | 1 | 1 | 0% | 1,696 | 3,645 | +115% | 0 | 0 | — |
case-21 | pass→pass | 23,307 | 20,990 | -10% | 1 | 1 | 0% | 4,172 | 7,068 | +69% | 0 | 0 | — |
case-22 | pass→pass | 9,965 | 7,629 | -23% | 1 | 1 | 0% | 1,406 | 4,056 | +188% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +18 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.