Create app.py
Browse filesInitial version
app.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 3 |
+
|
| 4 |
+
# Load the model and tokenizer
|
| 5 |
+
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-3B-Instruct")
|
| 6 |
+
model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.2-3B-Instruct")
|
| 7 |
+
|
| 8 |
+
st.title("Llama 3.2 3B Instruct Text Generation")
|
| 9 |
+
st.write("Enter a prompt and generate text using theLlama 3.2 3B model.")
|
| 10 |
+
|
| 11 |
+
user_input = st.text_area("Enter your prompt:", "Here is your input...")
|
| 12 |
+
|
| 13 |
+
if st.button("Generate"):
|
| 14 |
+
inputs = tokenizer(user_input, return_tensors="pt")
|
| 15 |
+
outputs = model.generate(inputs["input_ids"], max_length=200)
|
| 16 |
+
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 17 |
+
st.write(generated_text)
|