Skip to content

DeepInfer: High-performance, large-scale inference framework for DeepSeek models

Python
524 B
Raw Blame
"""文本段处理:引擎请求的文本段只携带长度(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))