Recommendations for cleanly parsing the latex large_string for RAG?

#6
by Gwance - opened

I’m using the scholarweave/arxiv-latex dataset and want to convert the latex large_string field into clean, section-aware chunks for RAG.

The field appears to contain the full reconstructed source archive, including .tex, .cls, .sty, .bib, and sometimes multiple or older manuscript files. Some older papers, such as “Dynamic Backtracking,” are especially difficult to parse, and custom macros can make simple LaTeX-to-text conversion unreliable.

Has anyone developed or recommended a robust pipeline for:

  • identifying the main .tex file
  • following only relevant \input and \include files
  • excluding .cls, .sty, old drafts, generated files, and bibliography noise
  • safely handling custom macros and environments
  • converting the result into clean Markdown or plain text
  • enforcing chunk-size limits when a submission is malformed or extremely large

I’d appreciate any scripts, libraries, heuristics, or examples that have worked well on this dataset.

Sign up or log in to comment