Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -61,7 +61,7 @@ def generate_response(image, prompt):
|
|
| 61 |
image_token = getattr(proc, "image_token", "<|image|>")
|
| 62 |
image_token_str = f"{image_token}\n"
|
| 63 |
|
| 64 |
-
#
|
| 65 |
formatted_prompt = f"<|turn>user\n{image_token_str}{prompt}<|turn>\n<|turn>model\n"
|
| 66 |
|
| 67 |
inputs = proc(
|
|
@@ -77,7 +77,7 @@ def generate_response(image, prompt):
|
|
| 77 |
outputs = mod.generate(
|
| 78 |
**inputs,
|
| 79 |
max_new_tokens=256,
|
| 80 |
-
do_sample=False, # Greedy decoding
|
| 81 |
eos_token_id=proc.tokenizer.eos_token_id,
|
| 82 |
pad_token_id=proc.tokenizer.pad_token_id
|
| 83 |
)
|
|
@@ -123,7 +123,7 @@ demo = gr.Interface(
|
|
| 123 |
description=(
|
| 124 |
"Multimodal SFT alignment model trained to reject malicious instructions "
|
| 125 |
"and pivot securely to defensive engineering practices. "
|
| 126 |
-
"|[View
|
| 127 |
)
|
| 128 |
)
|
| 129 |
|
|
|
|
| 61 |
image_token = getattr(proc, "image_token", "<|image|>")
|
| 62 |
image_token_str = f"{image_token}\n"
|
| 63 |
|
| 64 |
+
# Native Gemma 4 turn formatting
|
| 65 |
formatted_prompt = f"<|turn>user\n{image_token_str}{prompt}<|turn>\n<|turn>model\n"
|
| 66 |
|
| 67 |
inputs = proc(
|
|
|
|
| 77 |
outputs = mod.generate(
|
| 78 |
**inputs,
|
| 79 |
max_new_tokens=256,
|
| 80 |
+
do_sample=False, # Greedy decoding stops repetitive text loops
|
| 81 |
eos_token_id=proc.tokenizer.eos_token_id,
|
| 82 |
pad_token_id=proc.tokenizer.pad_token_id
|
| 83 |
)
|
|
|
|
| 123 |
description=(
|
| 124 |
"Multimodal SFT alignment model trained to reject malicious instructions "
|
| 125 |
"and pivot securely to defensive engineering practices. "
|
| 126 |
+
"|[View Notebook](https://huggingface.co/spaces/byte-vortex/gemma-4-goodbot-badbot/blob/main/good-bot-vs-bad-bot.ipynb)|"
|
| 127 |
)
|
| 128 |
)
|
| 129 |
|