Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
3 |
+
|
4 |
+
# Load the tokenizer and model
|
5 |
+
tokenizer = AutoTokenizer.from_pretrained("arabic-text-stanceEvalV1")
|
6 |
+
model = AutoModelForCausalLM.from_pretrained("arabic-text-stanceEvalV1")
|
7 |
+
|
8 |
+
def generate_text(prompt, max_length=50):
|
9 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
10 |
+
outputs = model.generate(inputs['input_ids'], max_length=max_length, num_return_sequences=1)
|
11 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
12 |
+
|
13 |
+
st.title("SatnceEval LLM testing with Hugging Face and Streamlit")
|
14 |
+
|
15 |
+
prompt = st.text_input("Enter your prompt:", "Once upon a time")
|
16 |
+
|
17 |
+
if st.button("Generate"):
|
18 |
+
with st.spinner("Generating..."):
|
19 |
+
generated_text = generate_text(prompt)
|
20 |
+
st.success("Generated Text:")
|
21 |
+
st.write(generated_text)
|