dkhatate commited on
Commit
6d0cded
1 Parent(s): 1ca7973

app.py added

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForCausalLM
3
+ import torch
4
+
5
+ # Load the model and tokenizer
6
+ tokenizer = AutoTokenizer.from_pretrained("Cognitive-Lab/LLama3-Gaja-Hindi-8B-v0.1")
7
+ model = AutoModelForCausalLM.from_pretrained("Cognitive-Lab/LLama3-Gaja-Hindi-8B-v0.1").to("cuda")
8
+
9
+ def generate_text(prompt):
10
+ inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
11
+ with torch.no_grad():
12
+ output = model.generate(inputs["input_ids"], max_new_tokens=50)
13
+ return tokenizer.decode(output[0], skip_special_tokens=True)
14
+
15
+ # Launch Gradio app
16
+ interface = gr.Interface(fn=generate_text, inputs="text", outputs="text")
17
+ interface.launch()