Spaces:
Running
on
Zero
Running
on
Zero
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -1,17 +1,17 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 4 |
-
|
| 5 |
|
| 6 |
# Load model and tokenizer
|
| 7 |
model_id = "LiquidAI/LFM2-2.6B"
|
| 8 |
-
setup_zerogpu()
|
| 9 |
model = AutoModelForCausalLM.from_pretrained(
|
| 10 |
model_id,
|
| 11 |
device_map="auto", # Ensure proper device mapping for zero-gpu
|
| 12 |
)
|
| 13 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 14 |
|
|
|
|
| 15 |
def chat_with_model(message, history):
|
| 16 |
# Format conversation history
|
| 17 |
conversation = []
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 4 |
+
import spaces
|
| 5 |
|
| 6 |
# Load model and tokenizer
|
| 7 |
model_id = "LiquidAI/LFM2-2.6B"
|
|
|
|
| 8 |
model = AutoModelForCausalLM.from_pretrained(
|
| 9 |
model_id,
|
| 10 |
device_map="auto", # Ensure proper device mapping for zero-gpu
|
| 11 |
)
|
| 12 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 13 |
|
| 14 |
+
@spaces.GPU(duration=120)
|
| 15 |
def chat_with_model(message, history):
|
| 16 |
# Format conversation history
|
| 17 |
conversation = []
|