|
|
|
import streamlit as st |
|
import transformers |
|
|
|
st.title("A Simple Interface for a Language Model") |
|
|
|
st.subheader("Input Text") |
|
input_text = st.text_area("Enter your text here", "Type something here...") |
|
|
|
if st.button("Generate Response"): |
|
|
|
tokenizer = transformers.AutoTokenizer.from_pretrained("microsoft/phi-2") |
|
model = transformers.AutoModelForCausalLM.from_pretrained("microsoft/phi-2") |
|
|
|
|
|
inputs = tokenizer(input_text, return_tensors="pt") |
|
|
|
|
|
response = model.generate(**inputs, max_length=100, do_sample=True) |
|
|
|
|
|
st.subheader("Generated Response") |
|
st.write(tokenizer.decode(response[0])) |