fix(LLM): 限制模型输入分词内存
模型 worker 在 token 化阶段最多处理配置上限加一个 token,超限请求直接失败,避免先完整构造超长输入张量再拒绝。
This commit is contained in:
1 parent
b331927773
commit
45e45948bd
1 file changed
+2
-1
@@ -54,7 +54,8 @@ def guard_worker_main(
|
||||
inputs = tokenizer(
|
||||
[text],
|
||||
return_tensors="pt",
|
||||
truncation=False,
|
||||
truncation=True,
|
||||
max_length=limits["max_input_tokens"] + 1,
|
||||
)
|
||||
if inputs["input_ids"].shape[1] > limits["max_input_tokens"]:
|
||||
_send(connection, {"ok": False, "error": "ModelInputTooLong"})
|
||||
|
||||
Reference in new issue
Block a user