Spaces:
Runtime error
Runtime error
app.py added
Browse files
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()
|