Instructions to use chariot-ai/indic-shift-262k with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use chariot-ai/indic-shift-262k with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("chariot-ai/indic-shift-262k", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download tokenization_indic_shift.py from chariot-ai/indic-shift-262k: direct link, hf CLI and curl.
- Browser
- Download file 1.72 kB
-
https://huggingface.co/chariot-ai/indic-shift-262k/resolve/main/tokenization_indic_shift.py
- Command line
-
hf download hf://chariot-ai/indic-shift-262k/tokenization_indic_shift.py
-
curl -L -o tokenization_indic_shift.py https://huggingface.co/chariot-ai/indic-shift-262k/resolve/main/tokenization_indic_shift.py
1.72 kB
| """Indic Shift tokenizer for Hugging Face transformers. | |
| AutoTokenizer loads this file when called with trust_remote_code=True. The tokenizer files and the | |
| text transform come from the indic-shift package (pip install indic-shift), so the ids and the | |
| decoded text are exactly those of indic_shift.load(...). This file only makes the package's | |
| transformers class loadable from this repository. | |
| https://github.com/Chariot-AI/indic-shift | |
| """ | |
| from __future__ import annotations | |
| from typing import Any | |
| _REQUIREMENT = "indic-shift>=1.0,<2" | |
| try: | |
| import indic_shift | |
| from indic_shift.hf import IndicShiftTokenizer as _PackageTokenizer | |
| except ImportError as exc: | |
| raise ImportError( | |
| f"This tokenizer needs the indic-shift package. Install it with: pip install '{_REQUIREMENT}'" | |
| ) from exc | |
| if indic_shift.__version__.split(".")[0] != "1": | |
| raise ImportError( | |
| f"This tokenizer needs indic-shift 1.x, found {indic_shift.__version__}. " | |
| f"Install it with: pip install '{_REQUIREMENT}'" | |
| ) | |
| __all__ = ["IndicShiftTokenizer"] | |
| class IndicShiftTokenizer(_PackageTokenizer): | |
| """The package's ``indic_shift.hf.IndicShiftTokenizer``; encoding and decoding are inherited as is.""" | |
| def __init__(self, vocab_file: str | None = None, **kwargs: Any) -> None: | |
| # indic_shift.json names the tokenizer ("indic-shift-262k" or "indic-shift-131k"); without it | |
| # the package would fall back to the 262K tokenizer, which is wrong for the 131K repository. | |
| if vocab_file is None and "name" not in kwargs: | |
| raise ValueError("indic_shift.json is missing: it names the Indic Shift tokenizer to load") | |
| super().__init__(vocab_file=vocab_file, **kwargs) | |