2 Commits
Author SHA1 Message Date
opencode 51fe7873c5 Plugin: chunk long documents and return one merged vector
Previously a document longer than --max-model-len got HTTP 400. Now pre_process
splits text into overlapping token windows (offsets from the fast tokenizer,
recursively halved if a piece still does not fit) and post_process merges the
per chunk results, so the client always receives one vector per input text.

- new request fields: chunk_tokens (default: only chunk what does not fit,
  window = max_model_len - 8), chunk_overlap (128), merge (max/sum/mean,
  sparse defaults to max, dense to mean + renormalise)
- response gains chunks, merge, chunk_tokens, chunk_overlap
- dense chunked output stays L2 normalised (norm 1.0000)
- regression: texts that fit are still processed as a single chunk with the
  same weights as before (verified against the FlagEmbedding reference)

Measured on the GPU stand: 100k characters -> 3 chunks in 0.8 s, 0.6 s with
chunk_tokens=1024 (48 chunks); chunking a 1.1k token text into 400-token
windows keeps 92% of the whole-document tokens (dot 0.481).

Adds sync_cpu_compose.py: docker-compose.cpu.yml is now generated from
docker-compose.yml, so the two embedded copies of the plugin cannot drift
(--check mode for CI). smoke_test.py covers chunking, merge modes and grouping.
2026-10-07 09:15:41 +07:00
opencode 75816679b2 README: sync with the tested deployment, add smoke_test.py
- fix the wrong warning about GPU_MEMORY_UTILIZATION: 0.15 is enough for
  BAAI/bge-m3 (measured: 2.1 GB of VRAM on an 8 GB card)
- document batch/dense response shapes, token ids, and that BGE-M3 has a single
  ReLU sparse logit per token (no rel/abs pair as in ColBERT)
- Portainer: env vars belong to the stack's Environment variables field,
  stack must run in docker compose (standalone) mode
- add the measured verification table (determinism, thresholds, nnz,
  max|delta| vs the FlagEmbedding reference)
- add smoke_test.py: dependency-free checks of every scenario plus an optional
  --reference mode that recomputes weights with torch/transformers
2026-09-28 14:17:40 +07:00