Spaces:
Runtime error
Runtime error
Update app.py from anycoder
Browse files
app.py
CHANGED
|
@@ -1,24 +1,28 @@
|
|
| 1 |
import torch
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
from transformers import (
|
| 4 |
Mistral3ForConditionalGeneration,
|
| 5 |
MistralCommonBackend,
|
| 6 |
)
|
| 7 |
|
| 8 |
-
# Initialize model and tokenizer with
|
| 9 |
model_id = "mistralai/Devstral-Small-2-24B-Instruct-2512"
|
| 10 |
|
| 11 |
# Load tokenizer
|
| 12 |
tokenizer = MistralCommonBackend.from_pretrained(model_id)
|
| 13 |
|
| 14 |
-
# Load model
|
| 15 |
model = Mistral3ForConditionalGeneration.from_pretrained(
|
| 16 |
model_id,
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
low_cpu_mem_usage=True # Reduce memory usage during loading
|
| 20 |
)
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
# System prompt
|
| 23 |
SP = """You are operating as and within Mistral Vibe, a CLI coding-agent built by Mistral AI and powered by default by the Devstral family of models. It wraps Mistral's Devstral models to enable natural language interaction with a local codebase. Use the available tools when helpful.
|
| 24 |
|
|
|
|
| 1 |
import torch
|
| 2 |
import gradio as gr
|
| 3 |
+
import spaces
|
| 4 |
from transformers import (
|
| 5 |
Mistral3ForConditionalGeneration,
|
| 6 |
MistralCommonBackend,
|
| 7 |
)
|
| 8 |
|
| 9 |
+
# Initialize model and tokenizer with ZeroGPU configuration
|
| 10 |
model_id = "mistralai/Devstral-Small-2-24B-Instruct-2512"
|
| 11 |
|
| 12 |
# Load tokenizer
|
| 13 |
tokenizer = MistralCommonBackend.from_pretrained(model_id)
|
| 14 |
|
| 15 |
+
# Load model with ZeroGPU compatibility
|
| 16 |
model = Mistral3ForConditionalGeneration.from_pretrained(
|
| 17 |
model_id,
|
| 18 |
+
torch_dtype=torch.float16, # Use float16 for better GPU efficiency
|
| 19 |
+
low_cpu_mem_usage=True
|
|
|
|
| 20 |
)
|
| 21 |
|
| 22 |
+
# Move model to GPU when available
|
| 23 |
+
if torch.cuda.is_available():
|
| 24 |
+
model = model.to('cuda')
|
| 25 |
+
|
| 26 |
# System prompt
|
| 27 |
SP = """You are operating as and within Mistral Vibe, a CLI coding-agent built by Mistral AI and powered by default by the Devstral family of models. It wraps Mistral's Devstral models to enable natural language interaction with a local codebase. Use the available tools when helpful.
|
| 28 |
|