david-thrower commited on
Commit
ac41acd
·
verified ·
1 Parent(s): 90a6958

Update app.py

Browse files

Try Unsloth...

Files changed (1) hide show
  1. app.py +25 -17
app.py CHANGED
@@ -1,32 +1,40 @@
1
 
2
  import gc
3
 
4
- import gradio as gr
5
- import torch
6
- from transformers import AutoTokenizer, AutoModelForCausalLM, HqqConfig
7
 
8
- # quant_config = HqqConfig(nbits=8, group_size=64)
9
 
10
- MODEL_ID = "HuggingFaceTB/SmolLM3-3B"
11
- DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
12
 
13
- print("Loading tokenizer & model…")
14
- tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
15
- # model = AutoModelForCausalLM.from_pretrained(MODEL_ID, torch_dtype=torch.bfloat16).to(DEVICE)
16
 
17
- model =\
18
- AutoModelForCausalLM\
19
- .from_pretrained(
20
- MODEL_ID,
21
- torch_dtype=torch.float16,
22
- # device_map="cuda",
23
- # quantization_config=quant_config
24
- ).to(DEVICE)
25
 
26
  #gc.collect()
27
 
28
  #########
29
 
 
 
 
 
 
 
 
 
30
  # import gc
31
 
32
  # import gradio as gr
 
1
 
2
  import gc
3
 
4
+ # import gradio as gr
5
+ # import torch
6
+ # from transformers import AutoTokenizer, AutoModelForCausalLM, HqqConfig
7
 
8
+ # # quant_config = HqqConfig(nbits=8, group_size=64)
9
 
10
+ # MODEL_ID = "HuggingFaceTB/SmolLM3-3B"
11
+ # DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
12
 
13
+ # print("Loading tokenizer & model…")
14
+ # tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
15
+ # # model = AutoModelForCausalLM.from_pretrained(MODEL_ID, torch_dtype=torch.bfloat16).to(DEVICE)
16
 
17
+ # model =\
18
+ # AutoModelForCausalLM\
19
+ # .from_pretrained(
20
+ # MODEL_ID,
21
+ # torch_dtype=torch.float16,
22
+ # # device_map="cuda",
23
+ # # quantization_config=quant_config
24
+ # ).to(DEVICE)
25
 
26
  #gc.collect()
27
 
28
  #########
29
 
30
+ model, tokenizer = FastLanguageModel.from_pretrained(
31
+ "unsloth/Llama-3.2-3B-Instruct-bnb-4bit",
32
+ max_seq_length=128_000,
33
+ load_in_4bit=True
34
+ )
35
+
36
+ #########
37
+
38
  # import gc
39
 
40
  # import gradio as gr