Download lib/python3.11/site-packages/dashscope/tokenizers/tokenizer_base.py from michaelu0826/phantom_env: direct link, hf CLI and curl.
- Browser
- Download file 815 Bytes
-
https://huggingface.co/datasets/michaelu0826/phantom_env/resolve/main/lib/python3.11/site-packages/dashscope/tokenizers/tokenizer_base.py
- Command line
-
hf download hf://datasets/michaelu0826/phantom_env/lib/python3.11/site-packages/dashscope/tokenizers/tokenizer_base.py
-
curl -L -o tokenizer_base.py https://huggingface.co/datasets/michaelu0826/phantom_env/resolve/main/lib/python3.11/site-packages/dashscope/tokenizers/tokenizer_base.py
815 Bytes
| # -*- coding: utf-8 -*- | |
| # Copyright (c) Alibaba, Inc. and its affiliates. | |
| from typing import List | |
| class Tokenizer: | |
| """Base tokenizer interface for local tokenizers.""" | |
| def __init__(self): | |
| pass | |
| def encode(self, text: str, **kwargs) -> List[int]: # type: ignore[empty-body] # noqa: E501 | |
| """Encode input text string to token ids. | |
| Args: | |
| text (str): The string to be encoded. | |
| Returns: | |
| List[int]: The token ids. | |
| """ | |
| def decode(self, token_ids: List[int], **kwargs) -> str: # type: ignore[empty-body] # pylint: disable=line-too-long # noqa: E501 | |
| """Decode token ids to string. | |
| Args: | |
| token_ids (List[int]): The input token ids. | |
| Returns: | |
| str: The string of the token ids. | |
| """ | |