Prompt

How do I build RAG over PDFs, wikis, and tickets with citations?

Artificial Intelligence / AI Search2 observationsLast seen Nov 20, 2026

Latest observation

Nov 20, 2026OpenAI APIWeb search: off

To build RAG over PDFs, wikis, and tickets with citations, think of it as four layers:

  1. Ingest
  2. Chunk + enrich
  3. Retrieve + rank
  4. Answer with evidence/citations

Below is a practical blueprint.


1) Ingest documents from each source

PDFs

  • Extract text with layout awareness if possible.
  • Preserve:
    • page number
    • section heading
    • figure/table references
    • document title / version
  • If PDFs are scanned, run OCR.

Wikis

  • Pull page content via API or export.
  • Preserve:
    • page title
    • section headings
    • last updated time
    • page URL

Tickets

  • Ingest the ticket body, comments, resolution, and tags.
  • Preserve:
    • ticket ID
    • subject
    • timestamps
    • author/assignee
    • status
    • URL

2) Normalize into one common schema

Convert every source into a shared document format, for example:

{
  "doc_id": "unique-id",
  "source_type": "pdf|wiki|ticket",
  "source_name": "Acme Handbook",
  "source_url": "https://...",
  "title": "How to Reset Passwords",
  "section": "Authentication > Password Reset",
  "text": "chunk text here",
  "page": 12,
  "ticket_id": "INC-1234",
  "updated_at": "2026-01-01T10:00:00Z",
  "metadata": {
    "author": "Jane",
    "version": "v3"
  }
}

This makes retrieval and citation generation much easier.


3) Chunk the content carefully

Good citations depend on good chunk boundaries.

Best practices

  • Chunk by semantic structure:
    • headings
    • paragraphs
    • ticket comment boundaries
    • page boundaries for PDFs
  • Keep chunks small enough to retrieve precisely, but large enough to retain context.

Typical chunking

  • 200–500 tokens per chunk
  • 10–20% overlap if needed
  • Store chunk IDs and provenance

Example chunk record:

{
  "chunk_id": "wiki-456#section-2#chunk-3",
  "doc_id": "wiki-456",
  "text": "The password reset process requires...",
  "citation": {
    "source_type": "wiki",
    "title": "Password Reset Policy",
    "url": "https://wiki.company.com/page/123",
    "section": "Process",
    "page": null
  }
}

4) Index for retrieval

Use at least one of:

  • Vector index for semantic search
  • Keyword/BM25 index for exact matches
  • Often best: hybrid search

Recommended retrieval pipeline

  1. User query
  2. Query rewrite/expansion if needed
  3. Hybrid retrieve top 20–50 chunks
  4. Rerank with a cross-encoder or LLM reranker
  5. Select top evidence chunks for generation

Why hybrid?

  • PDFs often contain exact terms, codes, IDs
  • Wikis are semantic and structured
  • Tickets often include noisy but critical phrasing
    Hybrid improves recall across all three.

5) Attach citations at the chunk level

Citations should point to the exact retrieved chunk, not just the source document.

For each chunk, keep:

  • source type
  • document title
  • URL
  • page number or section
  • chunk offset/range if available
  • ticket ID if relevant

Example citation format

In the answer:

  • “Passwords expire every 90 days. [1]”
  • “The rollback procedure is documented in the release wiki. [2]”

Then provide references:

  1. Acme Security Policy, page 12, “Password Expiration”, PDF
  2. Release Process Wiki, section “Rollback”, URL

6) Generate answers grounded in evidence

Prompt the model to:

  • answer only from retrieved evidence
  • cite every factual claim
  • say “I couldn’t find that in the sources” if evidence is insufficient

Useful prompt instruction

Use only the supplied context. For every important statement, include one or more citations. If the context does not support the answer, say so.

Safer generation pattern

  • First, retrieve evidence.
  • Second, have the model draft an answer with inline citations.
  • Third, optionally verify citation coverage.

7) Make citations trustworthy

Citations should be:

  • traceable: user can open the original source
  • specific: page/section/comment, not just doc title
  • stable: use immutable IDs where possible
  • verifiable: chunk text should match the cited source

Good citation metadata

  • PDF: title, page number, page anchor, document version
  • Wiki: page title, section heading, URL, revision ID
  • Ticket: ticket ID, comment ID, timestamp, URL

8) Handle source-specific quirks

PDFs

  • Tables may need special extraction.
  • Multi-column layouts can scramble text.
  • Use OCR for scans.
  • Preserve page numbers.

Wikis

  • Some pages are long and poorly structured.
  • Use heading-based splitting.
  • Track page revisions to avoid stale citations.

Tickets

  • Conversation threads can contradict each other.
  • Prefer the resolution/accepted answer if present.
  • Keep comment timestamps so the model can weigh latest info.

9) Recommended architecture

Simple version

  • Ingestion jobs -> document store
  • Chunking pipeline -> vector DB
  • Retrieval API -> reranker -> LLM answer

More robust version

  • Raw source store: S3/GCS
  • Metadata DB: Postgres
  • Search:
    • vector DB (Pinecone, Weaviate, pgvector, Milvus)
    • keyword index (Elasticsearch/OpenSearch)
  • Reranker
  • Citation-aware answer service
  • Audit logs for retrieved evidence

10) Minimal implementation checklist

  • Extract text from PDFs, wiki pages, tickets
  • Normalize metadata into one schema
  • Chunk semantically
  • Store chunk text + metadata + source pointer
  • Build hybrid retrieval
  • Rerank results
  • Generate answer from retrieved chunks only
  • Return inline citations and reference list
  • Add source URLs/page numbers/IDs to every chunk
  • Test citation accuracy with QA samples

11) Example answer format

Answer:
The password reset policy requires users to verify their identity before resetting a password. Passwords expire every 90 days, and users are notified 7 days before expiry. [1][2]

References:
[1] Security Policy, PDF, page 12, “Password Expiration”
[2] Help Center Wiki, section “Password Reset”, https://wiki.company.com/reset


12) Practical advice on quality

To improve answer quality:

  • deduplicate near-identical chunks
  • use metadata filters like product, team, date, source type
  • prefer latest revision for wikis
  • surface source confidence or freshness
  • log which chunks were used for each answer

To improve citation quality:

  • cite at sentence or clause level when possible
  • avoid citing an entire source if only one paragraph was used
  • include page/section anchors in the citation object

13) If you want a strong baseline stack

A common setup:

  • Parsing: Unstructured, Apache Tika, pdfplumber, OCR engine
  • Storage: S3 + Postgres
  • Search: Elasticsearch/OpenSearch + vector DB
  • Reranker: bge-reranker or a hosted reranker
  • LLM: your chosen chat model
  • Framework: LlamaIndex or LangChain if you want orchestration

If you want, I can also give you:

  1. a reference architecture diagram,
  2. a Python implementation skeleton, or
  3. a citation format and prompt template for production use.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (2 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.