Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
|
| 4 |
from transformers import pipeline, AutoTokenizer, AutoModel
|
| 5 |
|
| 6 |
-
|
| 7 |
|
| 8 |
-
tokenizer = AutoTokenizer.from_pretrained("furquan/opt_2_7_b_prompt_tuned_sentiment_analysis", trust_remote_code=True)
|
| 9 |
-
model = AutoModel.from_pretrained("furquan/opt_2_7_b_prompt_tuned_sentiment_analysis",trust_remote_code=True)
|
| 10 |
|
| 11 |
title = "OPT-2.7B"
|
| 12 |
description = "This demo uses meta's opt-2.7b model prompt tuned on the Stanford Sentiment Treebank-5 way dataset to only output the sentiment of a given text."
|
|
@@ -14,12 +14,7 @@ article = "<p style='text-align: center'><a href='https://arxiv.org/pdf/2104.086
|
|
| 14 |
|
| 15 |
|
| 16 |
def sentiment(text):
|
| 17 |
-
|
| 18 |
-
with torch.no_grad():
|
| 19 |
-
outputs = model.generate(
|
| 20 |
-
input_ids=tokenized["input_ids"], attention_mask=tokenized["attention_mask"]
|
| 21 |
-
)
|
| 22 |
-
return f"text: {text} Sentiment: {tokenizer.decode(outputs[0][-3:], skip_special_tokens=True)}"
|
| 23 |
|
| 24 |
iface = gr.Interface(fn=sentiment, inputs="text", outputs="text", title=title,
|
| 25 |
description=description, article=article)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
|
| 3 |
|
| 4 |
from transformers import pipeline, AutoTokenizer, AutoModel
|
| 5 |
|
| 6 |
+
pipe = pipeline("text-generation", model="furquan/opt_2_7_b_prompt_tuned_sentiment_analysis", trust_remote_code=True)
|
| 7 |
|
| 8 |
+
# tokenizer = AutoTokenizer.from_pretrained("furquan/opt_2_7_b_prompt_tuned_sentiment_analysis", trust_remote_code=True)
|
| 9 |
+
# model = AutoModel.from_pretrained("furquan/opt_2_7_b_prompt_tuned_sentiment_analysis",trust_remote_code=True)
|
| 10 |
|
| 11 |
title = "OPT-2.7B"
|
| 12 |
description = "This demo uses meta's opt-2.7b model prompt tuned on the Stanford Sentiment Treebank-5 way dataset to only output the sentiment of a given text."
|
|
|
|
| 14 |
|
| 15 |
|
| 16 |
def sentiment(text):
|
| 17 |
+
return pipe(text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
iface = gr.Interface(fn=sentiment, inputs="text", outputs="text", title=title,
|
| 20 |
description=description, article=article)
|