Spaces:
Sleeping
Sleeping
Download utils.py from raj22rishi/Text_Summarization: direct link, hf CLI and curl.
- Browser
- Download file 353 Bytes
-
https://huggingface.co/spaces/raj22rishi/Text_Summarization/resolve/main/utils.py
- Command line
-
hf download hf://spaces/raj22rishi/Text_Summarization/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/raj22rishi/Text_Summarization/resolve/main/utils.py
353 Bytes
| from transformers import AutoTokenizer | |
| model_nm = 't5-base' | |
| device = 'cuda' | |
| def tokenize_for_inference(text): | |
| tokenizer = AutoTokenizer.from_pretrained(model_nm) | |
| model_inputs = tokenizer.encode( | |
| text, | |
| max_length = 512, | |
| padding=True, | |
| truncation=True, | |
| return_tensors='pt' | |
| ) | |
| return model_inputs.to(device) | |