check this code '''import streamlit as st
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

# Load pre-trained language model and tokenizer
model_name = "gpt2"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)

# Define function for generating next word predictions
def generate_predictions(text, num_predictions=5, max_length=50):
    # Tokenize text and convert to tensors
    input_ids = tokenizer.encode(text, return_tensors="pt")
    # Generate predictions using model
    output = model.generate(input_ids, num_return_sequences=num_predictions, max_length=max_length, do_sample=True)
    # Convert predictions to text and return as list
    predictions = []
    for i in range(num_predictions):
        text = tokenizer.decode(output[i], skip_special_tokens=True)
        predictions.append(text)
    return predictions

# Define Streamlit app
def app():
    st.title("Next Word Prediction")
    st.write("This app uses a pre-trained language model to generate next word predictions.")
    
    # Allow user to upload a file
    uploaded_file = st.file_uploader("Upload a text file", type=["txt"])
    
    if uploaded_file is not None:
        # Read uploaded file as string
        text = uploaded_file.read().decode("utf-8")
        # Show uploaded text to user
        st.write("Uploaded text:")
        st.write(text)
        
        # Allow user to input starting text
        prefix = st.text_input("Enter starting text:")
        if le