Spaces:
Runtime error
Runtime error
import streamlit as st | |
from transformers import AutoTokenizer, AutoModelForCausalLM | |
def load_model(): | |
model_dir = "./" # Ensure all files, including `vocab.txt`, are in this directory | |
tokenizer = AutoTokenizer.from_pretrained(model_dir) | |
model = AutoModelForCausalLM.from_pretrained(model_dir) | |
return tokenizer, model | |
st.set_page_config(page_title="Legal AI Chatbot", layout="centered") | |
st.title("Legal AI Chatbot") | |
st.write("Interact with a legal AI chatbot powered by transformers.") | |
# Load tokenizer and model | |
tokenizer, model = load_model() | |
# User input for chatbot | |
user_input = st.text_input("Enter your legal query:") | |
if user_input: | |
inputs = tokenizer(user_input, return_tensors="pt") | |
outputs = model.generate(inputs["input_ids"], max_length=150) | |
response = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
st.text_area("Response:", response, height=200) | |