Repository navigation
Return a list of token lists for a text array with one string - #4665
Merged
przepeck merged 4 commits intoOct 26, 2026
Merged
Conversation
The /v1/tokenize response nested the tokens only when the tokenizer returned more than one row, so "text": ["hello world"] was answered with the flat list used for "text": "hello world". TokenizeRequest records whether text was an array of strings, and parseTokenizeResponse() takes that as a new last parameter and nests accordingly. The LLM servable, embeddings and rerank callers pass it through. A single string and arrays of two or more strings are unchanged. Adds request and response tests and documents the list form.
przepeck
requested changes
Oct 20, 2026
parseInput() now returns a plain string for an unbatched input and an array of strings for a batch, so validateTokenizeRequest() no longer looks at the JSON again to tell them apart. Errors are returned as an absl::StatusOr status, with the same messages as before. The embeddings request parser is updated for the new return type. Adds tests for the values parseInput() returns.
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The shared parser interface and production callers still need validation with actual dependencies in a full Bazel build.
No open issues 🎉
What changed in this PR
Fixes #4664 by preserving the request’s input form in /v1/tokenize responses: a one-string array now returns nested token lists, while a plain string remains unchanged.
Changes:
- Track batch input and pass it through all three tokenizer integrations.
- Adapt embeddings parsing to the shared parser’s updated return type.
- Add regression tests and document list responses.
| File | Description |
|---|---|
| src/tokenize/tokenize_parser.hpp | Declare batch tracking and updated parser interfaces. |
| src/tokenize/tokenize_parser.cpp | Preserve input form and serialize batches consistently. |
| src/test/tokenize_parser_test.cpp | Test parsing and response shapes. |
| src/rerank/rerank_calculator_ov.cc | Forward batch metadata for rerank tokenization. |
| src/llm/servable.cpp | Forward batch metadata for LLM tokenization. |
| src/embeddings/embeddings_calculator_ov.cc | Forward batch metadata for embeddings tokenization. |
| src/embeddings/embeddings_api.cpp | Handle the updated shared parser result. |
| docs/model_server_rest_api_tokenizer.md | Document nested responses for string arrays. |
Review effort: Balanced
Contributor
Author
|
@przepeck I've pushed the change you suggested (parseInput now reports the unbatched case and errors through a status) and all checks are green. Could you take another look when you have a moment? Thanks. |
przepeck
approved these changes
Oct 26, 2026
Collaborator
|
PR merged, thank you for your contribution @Daksha1611 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🛠 Summary
Fixes #4664.
The /v1/tokenize response nested the tokens only when the tokenizer returned more than one row, so
"text": ["hello world"]got the same flat list as"text": "hello world".TokenizeRequestnow records whethertextwas given as an array of strings (inputIsBatch), andparseTokenizeResponse()takes it as a new last parameter, defaulting to false. When it is set theresponse is always a list of token lists. The three callers (LLM servable, embeddings and rerank
calculators) pass it through.
This changes the response for a client that sends a one-element array and reads the flat list. A
single string is unchanged, as are arrays of two or more strings. The docs now show the list form.
Tests: three request tests (string, one-element array, longer array) and three response tests in
tokenize_parser_test.cpp.I have no OVMS build container available, so this is not compiled with Bazel. I compiled the real
tokenize_parser.cppandtokenize_parser_test.cppagainst the OpenVINO runtime with abseil stubbed;all 24 tests in the file pass. I also ran the request through a real Qwen3 tokenizer: before,
["hello world"]gave[14990,1879]; now it gives[[14990,1879]]. The one-argument additions in thethree callers could not be compiled here.
🧪 Checklist