minGRU-Sentiment-Analysis
12
4
license:apache-2.0
by
suayptalha
Other
OTHER
New
12 downloads
Early-stage
Edge AI:
Mobile
Laptop
Server
Unknown
Mobile
Laptop
Server
Quick Summary
First Hugging Face integration of minGRU models from the paper "Were RNNs All We Needed?
Code Examples
Example Usage:pythontransformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"suayptalha/minGRU-Sentiment-Analysis",
trust_remote_code = True
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
text = "The movie was absolutely wonderful, I loved it!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128).to("cuda")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
sentiment = "positive" if prediction == 1 else "negative"
print(f"Text: {text}")
print(f"Predicted sentiment: {sentiment}")Example Usage:pythontransformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"suayptalha/minGRU-Sentiment-Analysis",
trust_remote_code = True
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
text = "The movie was absolutely wonderful, I loved it!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128).to("cuda")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
sentiment = "positive" if prediction == 1 else "negative"
print(f"Text: {text}")
print(f"Predicted sentiment: {sentiment}")Example Usage:pythontransformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"suayptalha/minGRU-Sentiment-Analysis",
trust_remote_code = True
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
text = "The movie was absolutely wonderful, I loved it!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128).to("cuda")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
sentiment = "positive" if prediction == 1 else "negative"
print(f"Text: {text}")
print(f"Predicted sentiment: {sentiment}")Example Usage:pythontransformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"suayptalha/minGRU-Sentiment-Analysis",
trust_remote_code = True
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
text = "The movie was absolutely wonderful, I loved it!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128).to("cuda")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
sentiment = "positive" if prediction == 1 else "negative"
print(f"Text: {text}")
print(f"Predicted sentiment: {sentiment}")Example Usage:pythontransformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"suayptalha/minGRU-Sentiment-Analysis",
trust_remote_code = True
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
text = "The movie was absolutely wonderful, I loved it!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128).to("cuda")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
sentiment = "positive" if prediction == 1 else "negative"
print(f"Text: {text}")
print(f"Predicted sentiment: {sentiment}")Example Usage:pythontransformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"suayptalha/minGRU-Sentiment-Analysis",
trust_remote_code = True
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
text = "The movie was absolutely wonderful, I loved it!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128).to("cuda")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
sentiment = "positive" if prediction == 1 else "negative"
print(f"Text: {text}")
print(f"Predicted sentiment: {sentiment}")Example Usage:pythontransformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"suayptalha/minGRU-Sentiment-Analysis",
trust_remote_code = True
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
text = "The movie was absolutely wonderful, I loved it!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128).to("cuda")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
sentiment = "positive" if prediction == 1 else "negative"
print(f"Text: {text}")
print(f"Predicted sentiment: {sentiment}")Example Usage:pythontransformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"suayptalha/minGRU-Sentiment-Analysis",
trust_remote_code = True
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
text = "The movie was absolutely wonderful, I loved it!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128).to("cuda")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
sentiment = "positive" if prediction == 1 else "negative"
print(f"Text: {text}")
print(f"Predicted sentiment: {sentiment}")Example Usage:pythontransformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"suayptalha/minGRU-Sentiment-Analysis",
trust_remote_code = True
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
text = "The movie was absolutely wonderful, I loved it!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128).to("cuda")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
sentiment = "positive" if prediction == 1 else "negative"
print(f"Text: {text}")
print(f"Predicted sentiment: {sentiment}")Example Usage:pythontransformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"suayptalha/minGRU-Sentiment-Analysis",
trust_remote_code = True
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
text = "The movie was absolutely wonderful, I loved it!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128).to("cuda")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
sentiment = "positive" if prediction == 1 else "negative"
print(f"Text: {text}")
print(f"Predicted sentiment: {sentiment}")Example Usage:pythontransformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"suayptalha/minGRU-Sentiment-Analysis",
trust_remote_code = True
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
text = "The movie was absolutely wonderful, I loved it!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128).to("cuda")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
sentiment = "positive" if prediction == 1 else "negative"
print(f"Text: {text}")
print(f"Predicted sentiment: {sentiment}")Example Usage:pythontransformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"suayptalha/minGRU-Sentiment-Analysis",
trust_remote_code = True
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
text = "The movie was absolutely wonderful, I loved it!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128).to("cuda")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
sentiment = "positive" if prediction == 1 else "negative"
print(f"Text: {text}")
print(f"Predicted sentiment: {sentiment}")Example Usage:pythontransformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"suayptalha/minGRU-Sentiment-Analysis",
trust_remote_code = True
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
text = "The movie was absolutely wonderful, I loved it!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128).to("cuda")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
sentiment = "positive" if prediction == 1 else "negative"
print(f"Text: {text}")
print(f"Predicted sentiment: {sentiment}")Example Usage:pythontransformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"suayptalha/minGRU-Sentiment-Analysis",
trust_remote_code = True
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
text = "The movie was absolutely wonderful, I loved it!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128).to("cuda")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
sentiment = "positive" if prediction == 1 else "negative"
print(f"Text: {text}")
print(f"Predicted sentiment: {sentiment}")Example Usage:pythontransformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"suayptalha/minGRU-Sentiment-Analysis",
trust_remote_code = True
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
text = "The movie was absolutely wonderful, I loved it!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128).to("cuda")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
sentiment = "positive" if prediction == 1 else "negative"
print(f"Text: {text}")
print(f"Predicted sentiment: {sentiment}")Example Usage:pythontransformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"suayptalha/minGRU-Sentiment-Analysis",
trust_remote_code = True
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
text = "The movie was absolutely wonderful, I loved it!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128).to("cuda")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
sentiment = "positive" if prediction == 1 else "negative"
print(f"Text: {text}")
print(f"Predicted sentiment: {sentiment}")Example Usage:pythontransformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"suayptalha/minGRU-Sentiment-Analysis",
trust_remote_code = True
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
text = "The movie was absolutely wonderful, I loved it!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128).to("cuda")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
sentiment = "positive" if prediction == 1 else "negative"
print(f"Text: {text}")
print(f"Predicted sentiment: {sentiment}")Example Usage:pythontransformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"suayptalha/minGRU-Sentiment-Analysis",
trust_remote_code = True
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
text = "The movie was absolutely wonderful, I loved it!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128).to("cuda")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
sentiment = "positive" if prediction == 1 else "negative"
print(f"Text: {text}")
print(f"Predicted sentiment: {sentiment}")Example Usage:pythontransformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"suayptalha/minGRU-Sentiment-Analysis",
trust_remote_code = True
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
text = "The movie was absolutely wonderful, I loved it!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128).to("cuda")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
sentiment = "positive" if prediction == 1 else "negative"
print(f"Text: {text}")
print(f"Predicted sentiment: {sentiment}")Example Usage:pythontransformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"suayptalha/minGRU-Sentiment-Analysis",
trust_remote_code = True
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
text = "The movie was absolutely wonderful, I loved it!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128).to("cuda")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
sentiment = "positive" if prediction == 1 else "negative"
print(f"Text: {text}")
print(f"Predicted sentiment: {sentiment}")Example Usage:pythontransformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"suayptalha/minGRU-Sentiment-Analysis",
trust_remote_code = True
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
text = "The movie was absolutely wonderful, I loved it!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128).to("cuda")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
sentiment = "positive" if prediction == 1 else "negative"
print(f"Text: {text}")
print(f"Predicted sentiment: {sentiment}")Example Usage:pythontransformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained(
"suayptalha/minGRU-Sentiment-Analysis",
trust_remote_code = True
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
text = "The movie was absolutely wonderful, I loved it!"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128).to("cuda")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
prediction = torch.argmax(logits, dim=-1).item()
sentiment = "positive" if prediction == 1 else "negative"
print(f"Text: {text}")
print(f"Predicted sentiment: {sentiment}")Deploy This Model
Production-ready deployment in minutes
Together.ai
Instant API access to this model
Production-ready inference API. Start free, scale to millions.
Try Free APIReplicate
One-click model deployment
Run models in the cloud with simple API. No DevOps required.
Deploy NowDisclosure: We may earn a commission from these partners. This helps keep LLMYourWay free.