Spaces:
Running
Running
Upload 2 files
Browse files- app.py +1 -8
- requirements.txt +1 -1
app.py
CHANGED
@@ -1,23 +1,17 @@
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
4 |
from einops import einsum
|
5 |
from tqdm import tqdm
|
6 |
|
7 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
8 |
model_name = 'microsoft/Phi-3-mini-4k-instruct'
|
9 |
|
10 |
-
quantization_config = BitsAndBytesConfig(
|
11 |
-
load_in_4bit=True,
|
12 |
-
bnb_4bit_compute_dtype=torch.float16
|
13 |
-
)
|
14 |
-
|
15 |
model = AutoModelForCausalLM.from_pretrained(
|
16 |
model_name,
|
17 |
device_map=device,
|
18 |
torch_dtype="auto",
|
19 |
trust_remote_code=True,
|
20 |
-
quantization_config=quantization_config,
|
21 |
)
|
22 |
|
23 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
@@ -179,4 +173,3 @@ def launch_app():
|
|
179 |
|
180 |
if __name__ == "__main__":
|
181 |
launch_app()
|
182 |
-
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
4 |
from einops import einsum
|
5 |
from tqdm import tqdm
|
6 |
|
7 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
8 |
model_name = 'microsoft/Phi-3-mini-4k-instruct'
|
9 |
|
|
|
|
|
|
|
|
|
|
|
10 |
model = AutoModelForCausalLM.from_pretrained(
|
11 |
model_name,
|
12 |
device_map=device,
|
13 |
torch_dtype="auto",
|
14 |
trust_remote_code=True,
|
|
|
15 |
)
|
16 |
|
17 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
|
|
173 |
|
174 |
if __name__ == "__main__":
|
175 |
launch_app()
|
|
requirements.txt
CHANGED
@@ -10,7 +10,7 @@ appnope==0.1.4
|
|
10 |
asttokens==2.4.1
|
11 |
astunparse==1.6.3
|
12 |
attrs==24.2.0
|
13 |
-
bitsandbytes==0.
|
14 |
certifi==2024.8.30
|
15 |
charset-normalizer==3.3.2
|
16 |
click==8.1.7
|
|
|
10 |
asttokens==2.4.1
|
11 |
astunparse==1.6.3
|
12 |
attrs==24.2.0
|
13 |
+
bitsandbytes==0.42.0
|
14 |
certifi==2024.8.30
|
15 |
charset-normalizer==3.3.2
|
16 |
click==8.1.7
|