Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,32 @@
|
|
1 |
import streamlit as st
|
2 |
-
from
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
if text :
|
7 |
-
out = classifier(text)
|
8 |
-
st.json(out)
|
|
|
1 |
import streamlit as st
|
2 |
+
from datasets import load_dataset
|
3 |
+
from transformers import AutoModelForSeq2SeqLM
|
4 |
+
from transformers import AutoTokenizer
|
5 |
+
from transformers import GenerationConfig
|
6 |
+
|
7 |
+
huggingface_dataset_name = "dshihk/llm-generated-essay"
|
8 |
+
dataset = load_dataset(huggingface_dataset_name)
|
9 |
+
|
10 |
+
model_name = 'google/flan-t5-base'
|
11 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
12 |
+
|
13 |
+
|
14 |
+
# get the topic
|
15 |
+
topic = st.text_enter("Enter your desired Topic of Blog")
|
16 |
+
|
17 |
+
if topic:
|
18 |
+
# Configurations
|
19 |
+
# generation_config = GenerationConfig(max_new_tokens=50, do_sample=True, temperature=0.7)
|
20 |
+
generation_config = GenerationConfig(max_new_tokens=50)
|
21 |
+
|
22 |
+
# Encode input:
|
23 |
+
inputs_encoded = tokenizer(topic, return_tensors='pt')
|
24 |
+
|
25 |
+
# Model Output:
|
26 |
+
model_output = model.generate(inputs_encoded["input_ids"], generation_config=generation_config)[0]
|
27 |
+
|
28 |
+
# Decode the output
|
29 |
+
zero_output = tokenizer.decode(model_output, skip_special_tokens=True)
|
30 |
+
|
31 |
+
st.json(zero_output)
|
32 |
|
|
|
|
|
|