Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,9 +2,20 @@ import gradio as gr
|
|
| 2 |
|
| 3 |
# Load your model and tokenizer
|
| 4 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 9 |
|
| 10 |
def single_inference(question):
|
|
|
|
| 2 |
|
| 3 |
# Load your model and tokenizer
|
| 4 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 5 |
+
import torch
|
| 6 |
|
| 7 |
+
# Specify the model name
|
| 8 |
+
model_name = "ahmedbasemdev/llama-3.2-3b-ChatBot"
|
| 9 |
+
|
| 10 |
+
# Load the model with 8-bit quantization
|
| 11 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 12 |
+
model_name,
|
| 13 |
+
device_map="auto", # Automatically map the model to the available device (CPU)
|
| 14 |
+
load_in_8bit=True, # Enable 8-bit quantization
|
| 15 |
+
torch_dtype=torch.float16 # Use mixed precision
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
# Load the tokenizer
|
| 19 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 20 |
|
| 21 |
def single_inference(question):
|