Spaces:
Sleeping
Sleeping
Lingo-IITGN
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,19 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
def greet(name):
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|