Spaces:
Paused
Paused
Arturo Jiménez de los Galanes Reguillos
commited on
Commit
·
314c465
1
Parent(s):
0a193bf
Refactor to fit model recomended usage
Browse files- app.py +3 -9
- requirements.txt +0 -2
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import login
|
3 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer,
|
4 |
from threading import Thread
|
5 |
import torch
|
6 |
|
@@ -20,15 +20,9 @@ def messages_for(python):
|
|
20 |
{"role": "user", "content": user_prompt_for(python)}
|
21 |
]
|
22 |
|
23 |
-
quant_config = BitsAndBytesConfig(
|
24 |
-
load_in_4bit=True,
|
25 |
-
bnb_4bit_use_double_quant=True,
|
26 |
-
bnb_4bit_compute_dtype=torch.bfloat16,
|
27 |
-
bnb_4bit_quant_type="nf4"
|
28 |
-
)
|
29 |
-
|
30 |
tokenizer = AutoTokenizer.from_pretrained(MODEL)
|
31 |
-
model = AutoModelForCausalLM.from_pretrained(MODEL, device_map="auto"
|
|
|
32 |
streamer = TextIteratorStreamer(tokenizer)
|
33 |
|
34 |
cplusplus = None
|
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import login
|
3 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
|
4 |
from threading import Thread
|
5 |
import torch
|
6 |
|
|
|
20 |
{"role": "user", "content": user_prompt_for(python)}
|
21 |
]
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
tokenizer = AutoTokenizer.from_pretrained(MODEL)
|
24 |
+
model = AutoModelForCausalLM.from_pretrained(MODEL, torch_dtype=torch.bfloat16, device_map="auto")
|
25 |
+
model.eval()
|
26 |
streamer = TextIteratorStreamer(tokenizer)
|
27 |
|
28 |
cplusplus = None
|
requirements.txt
CHANGED
@@ -1,4 +1,2 @@
|
|
1 |
-
accelerate
|
2 |
-
bitsandbytes
|
3 |
torch
|
4 |
transformers
|
|
|
|
|
|
|
1 |
torch
|
2 |
transformers
|