Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,12 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
-
from transformers import AutoTokenizer
|
4 |
import torch
|
5 |
|
6 |
-
# Load the tokenizer from the Hugging Face Hub
|
7 |
tokenizer = AutoTokenizer.from_pretrained("adarsh3601/my_gemma3_pt")
|
8 |
|
9 |
-
# Load the
|
10 |
-
|
11 |
-
model = f.load()
|
12 |
|
13 |
# Function to generate response using the model
|
14 |
def generate_response(input_text):
|
@@ -17,7 +15,7 @@ def generate_response(input_text):
|
|
17 |
|
18 |
# Generate output using the model
|
19 |
with torch.no_grad(): # Disable gradients for inference
|
20 |
-
outputs = model.generate(inputs['input_ids'])
|
21 |
|
22 |
# Decode the output and return it
|
23 |
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
|
3 |
import torch
|
4 |
|
5 |
+
# Load the tokenizer from the Hugging Face Hub
|
6 |
tokenizer = AutoTokenizer.from_pretrained("adarsh3601/my_gemma3_pt")
|
7 |
|
8 |
+
# Load the model from Hugging Face Hub (Assuming you are using a transformer model here)
|
9 |
+
model = AutoModelForCausalLM.from_pretrained("adarsh3601/my_gemma3_pt")
|
|
|
10 |
|
11 |
# Function to generate response using the model
|
12 |
def generate_response(input_text):
|
|
|
15 |
|
16 |
# Generate output using the model
|
17 |
with torch.no_grad(): # Disable gradients for inference
|
18 |
+
outputs = model.generate(inputs['input_ids'], max_length=50) # You can adjust max_length and other parameters
|
19 |
|
20 |
# Decode the output and return it
|
21 |
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|