Lingo-IITGN commited on
Commit
0df52d4
·
verified ·
1 Parent(s): c723f30

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -1,7 +1,19 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  demo.launch()
 
1
  import gradio as gr
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
3
 
 
 
4
 
5
+ tokenizer = AutoTokenizer.from_pretrained("LingoIITGN/ganga-1b")
6
+ model = AutoModelForCausalLM.from_pretrained(
7
+ "LingoIITGN/ganga-1b",
8
+ device_map="auto"
9
+ )
10
+
11
+ def greet(input_text):
12
+ input_token = tokenizer.encode(input_text, return_tensors="pt").to("cuda")
13
+
14
+ output = model.generate(input_token, max_new_tokens=100, num_return_sequences=1, do_sample=True, top_k=50, top_p=0.95, temperature=0.7)
15
+ output_text = tokenizer.batch_decode(output)[0]
16
+ return output_text
17
+
18
+ demo = gr.Interface(fn=greet, inputs=["text"], outputs=["text"],)
19
  demo.launch()