File size: 978 Bytes
88eeb34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import streamlit as st
from transformers import AutoModelForCausalLM, AutoTokenizer,pipeline
import torch

st.title("Text_Generator Fine tunning model")

# Load model and tokenizer
model_dir = "fine_tuned_model (1)"
tokenizer = AutoTokenizer.from_pretrained(model_dir)
model = AutoModelForCausalLM.from_pretrained(model_dir)


code_generator = pipeline("text-generation", model=model, tokenizer=tokenizer)

prompt = "def quicksort(arr):"


inputs_text=st.text_input("Please enter the text",value="I think I really like this place. Ayesha and I had a chance to visit  Cheuvront on a Monday night. It wasn\'t terribly busy when we arrived and we were warmly greeted. Unfortunately we were seated next to a loud group of young children that thought they knew something of the world ")

if st.button("submit"):
    generated_code = code_generator(inputs_text, max_length=200, num_return_sequences=1)
    
    st.write(generated_code[0]["generated_text"])