nextcloud / nextcloud/context_chat_backend
Mismatch between embedding model's context length and chunk size
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 27
- Forks
- 24
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 6
Description
Which version of Nextcloud are you using?
32.0.0
Which version of PHP context_chat are you using?
4.5.0
Which version of backend context_chat are you using?
4.5.0
Which browser are you using? In case you are using the phone App, specify the Android or iOS version and device please.
Chrome 128
Nextcloud deployment method?
docker compose
Describe the Bug
decode: cannot decode batches with this context (calling encode() instead)
init: embeddings required but some input tokens were not marked as outputs -> overriding
the context length of the embedding model is 512 which is exceeded by our config and the chunk size of texts we pass in, which is why the error. It would be tricky to fix without re-indexing but our first effort should be to keep the impact of the change minimal in terms of doc search quality.
one solution would be to just reduce the chunk size and the context size config to match the native context size of the model. The quality of the doc search may not change much with the previously indexed docs since the embedding of the query we would use to search them most of the time would be small enough. For the newer indexed docs, it is yet to be seen since 512 is the no. of token, chunk size would be around this, lesser even with non-english languages.
one other solution would be to use rope scaling and try to increase the context length of the model through the config only. It would allow larger context lengths and a better doc search than the above solution. It is, however, yet to be seen how much we can scale it keeping the results good.
https://github.com/ggml-org/llama.cpp/discussions/1965
To Reproduce
embed some docs into the vector db and inspect the output of "<persistent_storage>/logs/em_server.log".
PHP logs (Warning these might contain sensitive information)
No response
Ex-App logs (Warning these might contain sensitive information)
No response
Server logs (if applicable)
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing document embedding and inspecting persistent_storage/logs/em_server.log, then compare the configured chunk and context sizes with the model's 512-token limit. Review the two proposed approaches, including the linked llama.cpp rope-scaling discussion, and assess their effect on existing and newly indexed documents. Done means an agreed approach is implemented and embedding succeeds without the reported errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning, search
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100