Feature Extraction
Transformers
PyTorch
Safetensors
English
bert
sentiment-analysis
text-classification
generic
sentiment-classification
text-embeddings-inference
Instructions to use numind/NuSentiment with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use numind/NuSentiment with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="numind/NuSentiment")# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("numind/NuSentiment") model = AutoModel.from_pretrained("numind/NuSentiment", device_map="auto") - Notebooks
- Google Colab
- Kaggle
| license: mit | |
| language: | |
| - en | |
| pipeline_tag: feature-extraction | |
| tags: | |
| - sentiment-analysis | |
| - text-classification | |
| - generic | |
| - sentiment-classification | |
| datasets: | |
| - Numind/C4_sentiment-analysis | |
| ## Model | |
| The base version of [e5-v2](https://huggingface.co/intfloat/e5-base-v2) finetunned on an annotated subset of [C4](https://huggingface.co/datasets/Numind/C4_sentiment-analysis). This model provides generic embedding for sentiment analysis. Embeddings can be used out of the box or fine-tuned on specific datasets. | |
| Blog post: https://www.numind.ai/blog/creating-task-specific-foundation-models-with-gpt-4 | |
| ## Usage | |
| Below is an example to encode text and get embedding. | |
| ```python | |
| import torch | |
| from transformers import AutoTokenizer, AutoModel | |
| model = AutoModel.from_pretrained("Numind/e5-base-sentiment_analysis") | |
| tokenizer = AutoTokenizer.from_pretrained("Numind/e5-base-sentiment_analysis") | |
| device = torch.device('cuda') if torch.cuda.is_available() else torch.device('cpu') | |
| model.to(device) | |
| size = 256 | |
| text = "This movie is amazing" | |
| encoding = tokenizer( | |
| text, | |
| truncation=True, | |
| padding='max_length', | |
| max_length= size, | |
| ) | |
| emb = model( | |
| torch.reshape(torch.tensor(encoding.input_ids),(1,len(encoding.input_ids))).to(device),output_hidden_states=True | |
| ).hidden_states[-1].cpu().detach() | |
| embText = torch.mean(emb,axis = 1) | |
| ``` |