sayril007 commited on
Commit
02a11eb
1 Parent(s): cca19c6
Files changed (1) hide show
  1. app.py +17 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import streamlit as st
3
+ from transformers import AutoModelForCausalLM, AutoTokenizer
4
+
5
+ peft_model_id = "sksayril/bpt-v-4-Bengali"
6
+ model = AutoModelForCausalLM.from_pretrained(peft_model_id, load_in_8bit=True)
7
+ tokenizer = AutoTokenizer.from_pretrained(peft_model_id)
8
+ st.title("Bengali Text Generation")
9
+
10
+ prompt = st.text_input("Enter a prompt:", "What is Machine Learning")
11
+ if st.button("Generate Answer"):
12
+ with torch.no_grad():
13
+ input_ids = tokenizer(prompt, return_tensors="pt").input_ids
14
+ output = model.generate(input_ids, max_length=100)
15
+ generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
16
+ st.write("Generated Answer:")
17
+ st.write(generated_text)