Download inference.py from Supernova11c/Supernova-NepaliTextEncoder-V1: direct link, hf CLI and curl.
- Browser
- Download file 532 Bytes
-
https://huggingface.co/Supernova11c/Supernova-NepaliTextEncoder-V1/resolve/main/inference.py
- Command line
-
hf download hf://Supernova11c/Supernova-NepaliTextEncoder-V1/inference.py
-
curl -L -o inference.py https://huggingface.co/Supernova11c/Supernova-NepaliTextEncoder-V1/resolve/main/inference.py
532 Bytes
| import torch | |
| from model import SupernovaNepaliEncoder, SupernovaEncoderConfig | |
| def load_model(model_path='.'): | |
| config = SupernovaEncoderConfig.from_pretrained(model_path) | |
| model = SupernovaNepaliEncoder(config) | |
| # Load weights if necessary, or use from_pretrained | |
| return model | |
| def get_sana_embeddings(model, input_ids, attention_mask=None): | |
| model.eval() | |
| with torch.no_grad(): | |
| # Returns [batch, seq_len, 2304] | |
| embeddings = model(input_ids, attention_mask=attention_mask) | |
| return embeddings | |