Spaces:
Runtime error
Runtime error
Mikhil-jivus
commited on
Commit
•
0a5ec67
1
Parent(s):
0cd712e
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import os
|
2 |
import gradio as gr
|
|
|
3 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
4 |
|
5 |
access_token = os.getenv('HF_TOKEN')
|
@@ -10,7 +11,13 @@ access_token = "your_access_token_here"
|
|
10 |
|
11 |
# Load the tokenizer and model from the Hugging Face repository
|
12 |
tokenizer = AutoTokenizer.from_pretrained(repo_id, token=access_token)
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
def respond(
|
16 |
message,
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
+
import torch
|
4 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
5 |
|
6 |
access_token = os.getenv('HF_TOKEN')
|
|
|
11 |
|
12 |
# Load the tokenizer and model from the Hugging Face repository
|
13 |
tokenizer = AutoTokenizer.from_pretrained(repo_id, token=access_token)
|
14 |
+
|
15 |
+
model = AutoModelForCausalLM.from_pretrained(
|
16 |
+
repo_id,
|
17 |
+
token=access_token,
|
18 |
+
torch_dtype=torch.bfloat16, # or use torch.bfloat16 if supported
|
19 |
+
device_map="auto" # Automatically use available GPU/CPU efficiently
|
20 |
+
)
|
21 |
|
22 |
def respond(
|
23 |
message,
|