Skip to content

Better nav for agents - #922

Merged
mishig25 merged 3 commits into
huggingface:mainfrom
stevhliu:markdown-pointers
Dec 2, 2026
Merged

mishig25 merged 3 commits into
huggingface:mainfrom
stevhliu:markdown-pointers

Conversation

@stevhliu

@stevhliu stevhliu commented Dec 1, 2026

Copy link
Copy Markdown
Member

Adds a header to the docs for agents to improve how it navigates and discovers docs. This helps the most for new or moved docs because agents often guess a docs URL from memory, which can be outdated and give the wrong or incomplete answer (on topics it's already familiar with, it doesn't make much of a difference). The header tells the agent to check the docs index, llms.txt first and to read the Markdown which is much smaller than the HTML page.

In my testing, I asked an agent about using Google TPUs, dequantizing, and quantizing an exporter in Transformers.

doc with header (2 runs) without header (2 runs)
Google TPU llms.txt → google_tpu.md, 2 steps each, both complete One correct in 3 steps, and one wrong in 5 steps. It never reached the page, answered from the blog, and said to move inputs with .to("tpu").
Dequantize llms.txt → dequantize.md, 2 and 3 steps, both complete Neither found the dequantize page. Both partial answers, built from the bitsandbytes and API reference pages. One took 13 steps.
Quantize an export llms.txt → exporters_quantization.md, 2 steps each, both complete Both complete in 2 and 3 steps, through the quantization overview.

@stevhliu
stevhliu requested a review from mishig25 December 1, 2026 21:50
@ArthurZucker

Copy link
Copy Markdown

❤️

- Search: process_hf_docs strips the header before chunking. It was indexed once per page,
  and was the only record kept for compact API pages (transformers model_doc, diffusers api).
- PR previews (`pr_*` versions) get no header: they're served from moon-ci-docs, not the
  huggingface.co URLs the header links to.
- The header regex (Python and the Copy page copy in the kit) is anchored on the header's own
  "> Agents: ... Fetch <base>/llms.txt": a page's own opening quote is never taken for it, and a
  long first line can't make it backtrack. A test checks the kit's copy against `markdown_pointer`.
- `doc-builder preview` writes each Markdown file once, header included
  (`write_markdown_route_file(..., pointer)`).
- Translation: a header-only change keeps the existing translation and its tries, with the new
  header. The page text is hashed like `walk` hashes files (xet hash in the bucket), so pages
  translated before English pages had a header are matched too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@mishig25 mishig25 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mishig25
mishig25 merged commit d26805e into huggingface:main Dec 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants