Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

/v1/tokenize returns a flat list when the text array holds a single string

未关闭
#4,664 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@Daksha1611 已经在做这个了。

开始于 2026年10月17日。

  • #4665 来自 @Daksha1611 —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
cpp, json

调研方向

Start with src/tokenize/tokenize_parser.cpp, especially the nesting condition based on outputShape[0] > 1, and compare it with the request parsing sequence in src/llm/servable.cpp. Update or add coverage in tokenize_parser_test.cpp and tokenize_endpoint_test.cpp for a one-element array, then update the tokenize response documentation. Done means every string array returns one token list per input, including a single string, with the endpoint behavior and documented response shape covered.

由索引模型根据 Issue 内容生成。

描述

Describe the bug

The shape of the /v1/tokenize response follows the number of strings in the request instead of the
form of the request. src/tokenize/tokenize_parser.cpp nests the tokens only when the tokenizer
output has more than one row (outputShape[0] > 1), and a one-element array produces one row, the
same as a plain string:

{"text": "hello world"}              ->  {"tokens":[14990,1879]}
{"text": ["hello world"]}           ->  {"tokens":[14990,1879]}
{"text": ["hello world", "hi"]}     ->  {"tokens":[[14990,1879],[6023]]}

A client that sends a list and reads tokens[i] for each input gets a list of token lists for
two or more inputs, but a flat list of integers for exactly one. Batches that happen to contain one
string need special handling on the client.

None of the tests send a one-element array: the list cases in tokenize_parser_test.cpp and
tokenize_endpoint_test.cpp all use two or more strings. The docs show only the single-string
response.

To Reproduce

curl http://localhost:8000/v1/tokenize -H "Content-Type: application/json" \
  -d '{"model": "Qwen/Qwen3-8B", "text": ["hello world"]}'

Reproduced with the parser and a real Qwen3 tokenizer, following the same sequence as
src/llm/servable.cpp: parse the request, encode, build the response.

Expected behavior

An array of strings always gives a list of token lists, including an array with one string.

Note that this changes the response for clients that currently send a one-element array and rely on
the flat list.

Logs

None.

Configuration

  1. OVMS version: main @ eec7daac
  2. any servable that serves /v1/tokenize (LLM, VLM, embeddings, rerank)
  3. N/A
  4. N/A
  5. N/A

Additional context

I have a patch with tests and docs and will open a PR.

主要语言
C++
星标
952
派生
285
平均合并
3 天 5 小时
30 天内合并 PR
45

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

openvinotoolkit/model_server 的其他 Issue

查看 openvinotoolkit/model_server 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。