This issue has been created
 
 
LLM AI Integration / cid:jira-generated-image-avatar-b6b0a43e-b62b-4b9c-830c-2e6522909171 LLMAI-173 Open

Chunking is character-based and ignores the embedding model's maximum input length, so chunk tails are silently never embedded

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-28c7173c-a828-467e-82eb-957fc3654552 Sebastian Elsner created this issue on 17/Aug/26 16:01
 
Summary: Chunking is character-based and ignores the embedding model's maximum input length, so chunk tails are silently never embedded
Issue Type: cid:jira-generated-image-avatar-b6b0a43e-b62b-4b9c-830c-2e6522909171 Bug
Affects Versions: 0.9
Assignee: Unassigned
Created: 17/Aug/26 16:01
Environment: XWiki 18.6.0, ai-llm 0.9, bundled Solr 9.4.1, DJL 0.36.0, internal inference server with sentence-transformers/all-MiniLM-L6-v2.
Priority: cid:jira-generated-image-static-major-dd274648-b382-4f59-9bae-2b56a42a4cbe Major
Reporter: Sebastian Elsner
Description:

What happens

ChunkingUtils.chunkDocument splits content by collection.getChunkingMaxSize() characters (chunking method maxChars). Nothing in that path consults the maximum input length of the collection's embedding model.

The internal inference server's default model, sentence-transformers/all-MiniLM-L6-v2, declares maxLength=256 word pieces in its DJL serving.properties, and the DJL HuggingFace text-embedding translator truncates beyond that silently โ€“ no warning, no error.

2000 characters of English prose is roughly 500 word pieces, and considerably more for wiki markup, code or tabular content. So with a 2000-character chunk size, very roughly the second half of every chunk never reaches the model.

Why it matters

This is silent, invisible data loss, and it is inconsistent between the two retrieval halves:

  • the stored content field and posFirstChar / posLastChar claim the full character range
  • the keyword half indexes the full text
  • the vector only represents the truncated head

A chunk can therefore be found by keyword search on text that its own embedding cannot represent, and semantic search silently misses anything in the tail of a chunk. Nothing in the admin UI hints that the configured chunk size exceeds what the selected model can consume.

Observed

Collection configured with chunking method maxChars, chunkingMaxSize 2000, chunkingOverlapOffset 250. Retrieved chunks of 2000 / 1972 / 1966 characters; only about the first half of each is inside the model's 256 word-piece window.

Suggested fix

At minimum, warn when chunkingMaxSize exceeds what the selected embedding model can consume. Better: derive the character budget from the model's declared maximum input length, or add a token-based chunking method alongside maxChars. Surfacing truncation as a per-chunk warning โ€“ the errorMessage field already exists โ€“ would also make it diagnosable.