Instructions to use Deepakvictor/tan-ta with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Deepakvictor/tan-ta with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "translation" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("translation", model="Deepakvictor/tan-ta")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("Deepakvictor/tan-ta") model = AutoModelForSeq2SeqLM.from_pretrained("Deepakvictor/tan-ta", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download handler.py from Deepakvictor/tan-ta: direct link, hf CLI and curl.
- Browser
- Download file 775 Bytes
-
https://huggingface.co/Deepakvictor/tan-ta/resolve/main/handler.py
- Command line
-
hf download hf://Deepakvictor/tan-ta/handler.py
-
curl -L -o handler.py https://huggingface.co/Deepakvictor/tan-ta/resolve/main/handler.py
775 Bytes
| from typing import Dict, List, Any | |
| from transformers import AutoTokenizer, AutoModelForSeq2SeqLM | |
| import torch | |
| class EndpointHandler(): | |
| def __init__(self, path=""): | |
| self.tokenizer = AutoTokenizer.from_pretrained(path) | |
| self.tokenizer.src_lang = "en" | |
| self.tokenizer.tgt_lang = "ta" | |
| self.model = AutoModelForSeq2SeqLM.from_pretrained(path) | |
| def __call__(self, data: str) -> str: | |
| inputs = data.pop("inputs", data) | |
| parameters = data.pop("parameters", None) | |
| inp = self.tokenizer(inputs, return_tensors="pt") | |
| with torch.inference_mode(): | |
| out= self.model.generate(**inp) | |
| final_output = self.tokenizer.batch_decode(out,skip_special_tokens=True) | |
| return {"translation": final_output[0]} |