DeepInfer/deepinfer/ve/processor/text_processor.py
2026-10-20 12:09:42 +08:00

14 lines
524 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""文本段处理:引擎请求的文本段只携带长度(TextLengthInput),token 本体在 engine 侧。"""
from __future__ import annotations
import torch
from deepinfer.ve.processor.common import BaseProcessor, TextLengthInput
class TextTokenProcessor(BaseProcessor):
def process(self, text_input: TextLengthInput) -> dict:
# 只按长度产出 mm_token_type 缺省值(UNDEFINED=0),不产生 token 内容
return dict(mm_token_type=torch.zeros(text_input.length, dtype=torch.int32))