I am building another 'ask PDF a question' RAG.<p>I have successfully converted PDF to markdown.<p>Then I used Jina segmenter to split it into chunks.<p>Each chunk is ~1000 characters long, but sometimes it is as short as just the title of the section.<p>I have then stored all of these chunks in a vector database and use cosine distance to sort chunks, pick the first 100, and include the associated chunks into LLM prompt that's used to answer user's question.<p>However...<p>I feel like I am missing a step.<p>The chunks that are returned by the query, while mostly relevant, they ...<p>* do not include the full recipe
* include snippets of unrelated recipes<p>Is there a step am I missing?
RAG is so yesterday.<p>Upload entire PDF directly[1] to API, don't convert PDF to markdown, don't vectorise.. Put that in API cache [2] and keep asking questions.<p>Chunking and vector search gives mediocre results [3]. Same with full-time search. Difficult to calibrate when structure of PDF is volatile.<p>[1] - <a href="https://docs.anthropic.com/en/docs/build-with-claude/pdf-support" rel="nofollow">https://docs.anthropic.com/en/docs/build-with-claude/pdf-sup...</a><p>[2] - <a href="https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching" rel="nofollow">https://docs.anthropic.com/en/docs/build-with-claude/prompt-...</a><p>[3] - This works but for well formated PDFs where you chunk intelligently and extract reasonable metadata.
If you load something into the LLM context, there's a non-zero chance that it'll be referenced.<p>How are you chunking things? Can you chunk it in a way that sidesteps the problem?<p>It's kind of hard to give generic advice without knowing your PDF structure.<p>But generally, you have two ways forward:<p>- Optimise chunking to be more context aware of the chunked content
- Allow the LLM to refer to adjacent chunks via some kind of a pointer