Paper extract (hybrid)
Do not treat direct PDF reading as the main path. Normalize machine output in _raw/ into extracted/.
Layout
sources/<source-id>/
├── original/ # PDF original (placed by human)
├── _raw/ # Machine extract (not the citation source of truth)
│ ├── marker.md # Marker full-text draft (single full-text extractor)
│ ├── arxiv/ # arXiv LaTeX / e-print source (authoritative math; preferred)
│ ├── mathpix/ # high-accuracy math pages (fallback for math)
│ └── pages/ # page images pXX.png (optional, for re-extract)
└── extracted/ # human-readable source of truth (cite here)
Path priority (full text)
- Markdown exists under
_raw/ (Marker) → read it and generate/update extracted/
_raw/ missing → ask the user to run Marker (see tooling). Do not silently fill extracted/ by reading the whole PDF
- Exceptions: short checks (e.g., Abstract) or filling pages missing from
_raw may use the PDF / page images
Math / equation reference priority
Equations and algorithms must come from an authoritative source, not from full-text OCR. Use this fixed order:
- arXiv LaTeX / e-print source (
_raw/arxiv/) — preferred (compiled TeX; no OCR guesswork)
- Mathpix (or equivalent high-accuracy math OCR) on the PDF math pages (
_raw/mathpix/)
- PDF page image + vision re-extract of only the affected pages (
_raw/pages/)
Fallback on fetch failure (must be explicit)
- If the arXiv source cannot be obtained (paper not on arXiv, source withheld / PDF-only, or the fetch fails), fall to the next path in the list above (Mathpix → page image + vision).
- Do not substitute an undefined or arbitrary source (blog, mirror, a different paper, or model memory) for the missing equations.
- If no path resolves an equation, keep it and mark
[extraction uncertain], and state which source was used. When math correctness is load-bearing (survey / both), ask the user before proceeding.
Tooling (Windows-friendly)
| Use case |
Tool |
Output |
| Full-text draft (all modes) |
Marker (single full-text extractor) |
_raw/marker.md |
| Math / algorithms (survey) |
arXiv source → Mathpix → page image + vision (in that order) |
_raw/arxiv/ → _raw/mathpix/ → _raw/pages/ |
| Scanned PDF only |
OCR (Llama vision OCR, or Tesseract) |
_raw/ocr.md |
| Naive OCR on text-layer PDFs |
Not the main path (math breaks easily) |
— |
Marker: known weaknesses and how to complement them
Marker is the single full-text extractor (Docling is no longer used):
- Equations / inline math can be imperfect → take math from the arXiv source (or Mathpix); do not trust Marker's math for
algorithm.md
- Complex / nested tables can be misparsed → keep the caption only, verify against the original PDF page, and note "See original for table"
- Multi-column layout, footnotes, references can be reordered → sanity-check reading order against the PDF when a section looks scrambled
- Figures are captured as captions only (by design) → note "See original for figure"
- Mark any doubtful span
[extraction uncertain] and re-extract only those pages via the math reference priority
OCR (Llama) configuration
- Keep the OCR (Llama) configuration — API key, endpoint / model name, and cost-bearing options — under the user's own management (a local, gitignored env / config file that the user owns)
- Reason: it carries credentials and billable settings, so it must never be committed or auto-edited by the agent
- The agent may ask the user to run Llama OCR, but must not generate, hardcode, or commit these settings
By mode:
- study: full-text
_raw from Marker is enough to ingest
- survey / both: use the math reference priority (arXiv first) for method / math / algorithm pages; re-extract page-by-page if still broken
Normalize _raw → extracted/
- Do not change meaning. No translation, no “helpful” paraphrase that alters sense
- Split by chapter/section into
extracted/NN-<section-slug>.md (~300–500 lines)
- Figures/tables: captions only; "See original for figure"
- Symbol corruption (e.g.,
π→⇡, ρ→⇢), broken equation line breaks, or likely omissions: mark [extraction uncertain] and, if possible, re-extract only those pages via the math reference priority
- Never cite
_raw/ (wikilinks must target extracted/)
Block IDs (Obsidian)
- One ID names one block. Latin letters, digits, hyphens only. Unique within the file. Same-page blocks:
^p12-a, ^p12-b
- Simple paragraph: space +
^id at the end of the last line
Body text of the paragraph. ^p12-a
- Structured blocks (blockquote, list, callout, table): ID on its own line, with a blank line before and after
> Quoted body from the paper.
^p12
Next paragraph.
- Do not invent a range ID to cover several blocks. If later citations need each paragraph, give each its own ID
Roles
| Location |
Role |
_raw/ |
Machine output; ingest input |
extracted/ |
Reading / citation source of truth |
survey/algorithm.md |
Cleaned math / pseudocode for implementation (cross-check the arXiv source or high-accuracy _raw) |
Forbidden
- Skipping
_raw/ and filling extracted/ by reading the whole PDF
- Treating broken extract as “correct math” without checking
- Using naive OCR (e.g., Tesseract) as the main path for text-layer papers
- On arXiv-source fetch failure, silently pulling equations from an undefined / arbitrary source instead of the defined fallback
- Committing or auto-editing OCR (Llama) credentials / config
Done when
extracted/ chunks exist; meaning was not changed
- Each
extracted/ file has unique block IDs; placement matches the paragraph vs structured-block rules above
- Uncertain math is marked
[extraction uncertain] rather than silently “fixed”
- Citations, if any were added in this pass, resolve to existing block IDs
1---2name: paper-extract3description: Hybrid PDF extract: prefer Marker `_raw/` for full text; take math from arXiv source, then Mathpix, then page image plus vision. Use when normalizing `_raw/` into `extracted/`, fixing equations or algorithms, or when the user mentions Marker, Docling, Mathpix, OCR, or arXiv source.4---56# Paper extract (hybrid)78Do not treat direct PDF reading as the main path. Normalize machine output in `_raw/` into `extracted/`.910## Layout1112```13sources/<source-id>/14├── original/ # PDF original (placed by human)15├── _raw/ # Machine extract (not the citation source of truth)16│ ├── marker.md # Marker full-text draft (single full-text extractor)17│ ├── arxiv/ # arXiv LaTeX / e-print source (authoritative math; preferred)18│ ├── mathpix/ # high-accuracy math pages (fallback for math)19│ └── pages/ # page images pXX.png (optional, for re-extract)20└── extracted/ # human-readable source of truth (cite here)21```2223## Path priority (full text)24251. Markdown exists under `_raw/` (Marker) → read it and generate/update `extracted/`262. `_raw/` missing → ask the user to run Marker (see tooling). **Do not silently fill `extracted/` by reading the whole PDF**273. Exceptions: short checks (e.g., Abstract) or filling pages missing from `_raw` may use the PDF / page images2829## Math / equation reference priority3031Equations and algorithms must come from an authoritative source, not from full-text OCR. Use this fixed order:32331. **arXiv LaTeX / e-print source** (`_raw/arxiv/`) — preferred (compiled TeX; no OCR guesswork)342. **Mathpix** (or equivalent high-accuracy math OCR) on the PDF math pages (`_raw/mathpix/`)353. **PDF page image + vision re-extract** of only the affected pages (`_raw/pages/`)3637### Fallback on fetch failure (must be explicit)3839- If the arXiv source cannot be obtained (paper not on arXiv, source withheld / PDF-only, or the fetch fails), fall to the **next path in the list above** (Mathpix → page image + vision).40- **Do not** substitute an undefined or arbitrary source (blog, mirror, a different paper, or model memory) for the missing equations.41- If no path resolves an equation, keep it and mark `[extraction uncertain]`, and state which source was used. When math correctness is load-bearing (survey / both), ask the user before proceeding.4243## Tooling (Windows-friendly)4445| Use case | Tool | Output |46|---|---|---|47| Full-text draft (all modes) | **Marker** (single full-text extractor) | `_raw/marker.md` |48| Math / algorithms (survey) | arXiv source → Mathpix → page image + vision (in that order) | `_raw/arxiv/` → `_raw/mathpix/` → `_raw/pages/` |49| Scanned PDF only | OCR (Llama vision OCR, or Tesseract) | `_raw/ocr.md` |50| Naive OCR on text-layer PDFs | **Not the main path** (math breaks easily) | — |5152### Marker: known weaknesses and how to complement them5354Marker is the single full-text extractor (Docling is no longer used):5556- **Equations / inline math** can be imperfect → take math from the arXiv source (or Mathpix); do not trust Marker's math for `algorithm.md`57- **Complex / nested tables** can be misparsed → keep the caption only, verify against the original PDF page, and note "See original for table"58- **Multi-column layout, footnotes, references** can be reordered → sanity-check reading order against the PDF when a section looks scrambled59- **Figures** are captured as captions only (by design) → note "See original for figure"60- Mark any doubtful span `[extraction uncertain]` and re-extract only those pages via the math reference priority6162### OCR (Llama) configuration6364- Keep the OCR (Llama) configuration — API key, endpoint / model name, and cost-bearing options — **under the user's own management** (a local, gitignored env / config file that the user owns)65- Reason: it carries credentials and billable settings, so it must never be committed or auto-edited by the agent66- The agent may ask the user to run Llama OCR, but must not generate, hardcode, or commit these settings6768By mode:6970- **study**: full-text `_raw` from Marker is enough to ingest71- **survey / both**: use the math reference priority (arXiv first) for method / math / algorithm pages; re-extract page-by-page if still broken7273## Normalize `_raw` → `extracted/`7475- Do not change meaning. No translation, no “helpful” paraphrase that alters sense76- Split by chapter/section into `extracted/NN-<section-slug>.md` (~300–500 lines)77- Figures/tables: captions only; "See original for figure"78- Symbol corruption (e.g., `π`→`⇡`, `ρ`→`⇢`), broken equation line breaks, or likely omissions: mark `[extraction uncertain]` and, if possible, re-extract only those pages via the math reference priority79- Never cite `_raw/` (wikilinks must target `extracted/`)8081### Block IDs (Obsidian)8283- One ID names one block. Latin letters, digits, hyphens only. Unique within the file. Same-page blocks: `^p12-a`, `^p12-b`84- Simple paragraph: space + `^id` at the end of the last line8586```markdown87Body text of the paragraph. ^p12-a88```8990- Structured blocks (blockquote, list, callout, table): ID on its own line, with a blank line before and after9192```markdown93> Quoted body from the paper.9495^p129697Next paragraph.98```99100- Do not invent a range ID to cover several blocks. If later citations need each paragraph, give each its own ID101102## Roles103104| Location | Role |105|---|---|106| `_raw/` | Machine output; ingest input |107| `extracted/` | Reading / citation source of truth |108| `survey/algorithm.md` | Cleaned math / pseudocode for implementation (cross-check the arXiv source or high-accuracy `_raw`) |109110## Forbidden111112- Skipping `_raw/` and filling `extracted/` by reading the whole PDF113- Treating broken extract as “correct math” without checking114- Using naive OCR (e.g., Tesseract) as the main path for text-layer papers115- On arXiv-source fetch failure, silently pulling equations from an undefined / arbitrary source instead of the defined fallback116- Committing or auto-editing OCR (Llama) credentials / config117118## Done when119120- `extracted/` chunks exist; meaning was not changed121- Each `extracted/` file has unique block IDs; placement matches the paragraph vs structured-block rules above122- Uncertain math is marked `[extraction uncertain]` rather than silently “fixed”123- Citations, if any were added in this pass, resolve to existing block IDs