Text Classification
Transformers
PyTorch
sentiment-head
feature-extraction
sentiment-analysis
openai-embeddings
custom_code
Instructions to use marcovise/TextEmbedding3SmallSentimentHead with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use marcovise/TextEmbedding3SmallSentimentHead with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="marcovise/TextEmbedding3SmallSentimentHead", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("marcovise/TextEmbedding3SmallSentimentHead", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
Upload modeling_te3s_head.py with huggingface_hub
Browse files- modeling_te3s_head.py +3 -4
modeling_te3s_head.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
-
from __future__ import annotations
|
| 2 |
-
|
| 3 |
import torch
|
| 4 |
import torch.nn as nn
|
|
|
|
| 5 |
from transformers import PreTrainedModel, PretrainedConfig
|
| 6 |
|
| 7 |
|
|
@@ -44,8 +43,8 @@ class TextEmbedding3SmallSentimentHead(PreTrainedModel):
|
|
| 44 |
def forward(
|
| 45 |
self,
|
| 46 |
inputs_embeds: torch.FloatTensor,
|
| 47 |
-
labels: torch.LongTensor
|
| 48 |
-
**
|
| 49 |
):
|
| 50 |
logits = self.net(inputs_embeds)
|
| 51 |
loss = None
|
|
|
|
|
|
|
|
|
|
| 1 |
import torch
|
| 2 |
import torch.nn as nn
|
| 3 |
+
from typing import Optional
|
| 4 |
from transformers import PreTrainedModel, PretrainedConfig
|
| 5 |
|
| 6 |
|
|
|
|
| 43 |
def forward(
|
| 44 |
self,
|
| 45 |
inputs_embeds: torch.FloatTensor,
|
| 46 |
+
labels: Optional[torch.LongTensor] = None,
|
| 47 |
+
**kwargs,
|
| 48 |
):
|
| 49 |
logits = self.net(inputs_embeds)
|
| 50 |
loss = None
|