Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import torch, textwrap, gradio as gr
|
2 |
from transformers import (
|
3 |
AutoTokenizer,
|
@@ -5,15 +6,17 @@ from transformers import (
|
|
5 |
BitsAndBytesConfig,
|
6 |
pipeline,
|
7 |
)
|
|
|
8 |
MODEL_ID = "mistralai/Mixtral-8x7B-Instruct-v0.1" # FP16 weights
|
9 |
bnb_cfg = BitsAndBytesConfig(
|
10 |
load_in_4bit=True,
|
11 |
bnb_4bit_compute_dtype=torch.float16, # keeps mat-mul fast
|
12 |
)
|
13 |
|
14 |
-
tok = AutoTokenizer.from_pretrained(MODEL_ID, use_fast=True)
|
15 |
model = AutoModelForCausalLM.from_pretrained(
|
16 |
MODEL_ID,
|
|
|
17 |
device_map="auto",
|
18 |
trust_remote_code=True,
|
19 |
quantization_config=bnb_cfg, # perfectly fine here
|
|
|
1 |
+
import os, textwrap, torch, gradio as gr
|
2 |
import torch, textwrap, gradio as gr
|
3 |
from transformers import (
|
4 |
AutoTokenizer,
|
|
|
6 |
BitsAndBytesConfig,
|
7 |
pipeline,
|
8 |
)
|
9 |
+
AUTH = os.environ.get("HF_TOKEN")
|
10 |
MODEL_ID = "mistralai/Mixtral-8x7B-Instruct-v0.1" # FP16 weights
|
11 |
bnb_cfg = BitsAndBytesConfig(
|
12 |
load_in_4bit=True,
|
13 |
bnb_4bit_compute_dtype=torch.float16, # keeps mat-mul fast
|
14 |
)
|
15 |
|
16 |
+
tok = AutoTokenizer.from_pretrained(MODEL_ID, token=AUTH, use_fast=True)
|
17 |
model = AutoModelForCausalLM.from_pretrained(
|
18 |
MODEL_ID,
|
19 |
+
token=AUTH,
|
20 |
device_map="auto",
|
21 |
trust_remote_code=True,
|
22 |
quantization_config=bnb_cfg, # perfectly fine here
|