[Feature Request] Optimize AI suggestion generation #13056
Replies: 2 comments 4 replies
-
|
I would like to suggest an additional enhancement to the metadata‑generation pipeline: 1. Extend document types and tags with a structured 2. Enforce stricter tag selection behavior in the model. 3. Provide a mechanism for user‑ or installation‑specific context injection. |
Beta Was this translation helpful? Give feedback.
-
|
Okay, while looking into this further (and checking if I could implement this myself), I noticed that the AI classifier sees the Title and some of the content of similar documents, but the important information, the tags, is omitted. In my opinion, the tags (and other fields) are the most important information that the LLM needs for suggesting good tags (and not inventing new versions) paperless-ngx/src/paperless_ai/indexing.py Lines 464 to 468 in d8d8872 The context builder has those complete records but serializes only title + content: paperless-ngx/src/paperless_ai/ai_classifier.py Lines 117 to 122 in d8d8872
The indexing layer explicitly preserves this metadata for LLM use — only paperless-ngx/src/paperless_ai/indexing.py Lines 179 to 208 in d8d8872 …and a comment states the design intent that these fields are "shown to the LLM via metadata prepend": paperless-ngx/src/paperless_ai/embedding.py Lines 123 to 127 in d8d8872 So the metadata is intentionally kept available to the LLM, but the classification retrieval path bypasses llama-index's node rendering (it reloads Documents by id) and therefore drops it. The chat feature, which does render nodes, is unaffected. I am unsure if this classifies as a genuine bug or an enhancement. Thus I'm only mentioning it here instead of in the Issues (And yes, I had AI help me write this.) I would be open to give implementing this a try, but before starting on this, I'd like to get feedback from maintainers if this would be in scope and discuss some design choices. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
Right now in v3 beta, AI suggestion generation (title, category, tags, ...) will include additional context chunks from similar documents if an embedding model is configured. The prompt built with RAG looks like this:
From my understanding, the goal is to improve generation of titles, tags, and other metadata by adding RAG context. However, metadata (such as tags or correspondents) of these additional documents is not included in the prompt. As a result, the LLM has to guess this information.
Besides increased processing time, this also likely leads to outputs that do not match the existing metadata (e.g. tags or correspondents) of the similar documents.
I would like to suggest the following improvements:
This could reduce processing time significantly (in my case by up to 110s, depending on size/similar docs, using an RTX A2000 12 GB GPU).
Instead of including full text chunks, include only relevant metadata (tags, correspondents, etc.), or include both. This may help the model align better with existing metadata.
No RAG chunks at all, only existing tags/correspondents, with an instruction to align outputs with them where appropriate.
Would be great to hear your thoughts on this. Thank you for your efforts!
Edit: I logged and analyzed the generated prompts and updated this request with (hopefully) more helpful suggestions.
Other
No response
Beta Was this translation helpful? Give feedback.
All reactions