Spaces:
Sleeping
Sleeping
Download modules/models.py from Raahulthakur/NLP-Assistant: direct link, hf CLI and curl.
- Browser
- Download file 530 Bytes
-
https://huggingface.co/spaces/Raahulthakur/NLP-Assistant/resolve/main/modules/models.py
- Command line
-
hf download hf://spaces/Raahulthakur/NLP-Assistant/modules/models.py
-
curl -L -o models.py https://huggingface.co/spaces/Raahulthakur/NLP-Assistant/resolve/main/modules/models.py
530 Bytes
| from transformers import pipeline | |
| from keybert import KeyBERT | |
| import torch | |
| device = 0 if torch.cuda.is_available() else -1 | |
| print("Device set to:", "cuda" if device == 0 else "cpu") | |
| summarizer = pipeline( | |
| "summarization", | |
| model="pszemraj/led-large-book-summary", | |
| tokenizer="pszemraj/led-large-book-summary", | |
| device=device | |
| ) | |
| classifier = pipeline( | |
| "text-classification", | |
| model="ranudee/news-category-classifier", | |
| tokenizer="ranudee/news-category-classifier", | |
| device=device | |
| ) | |
| kw_model = KeyBERT() | |