skaltenp commited on
Commit
ba7e4e4
1 Parent(s): 9df7c97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -1,7 +1,20 @@
1
  import gradio as gr
2
- from transformers import AutoModelForCausalLM, AutoTokenizer
 
3
 
4
  model_name = "DiscoResearch/DiscoLM_German_7b_v1"
 
 
 
 
 
 
 
 
 
 
 
 
5
  model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True)
6
  tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
7
 
 
1
  import gradio as gr
2
+ import torch
3
+ from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
4
 
5
  model_name = "DiscoResearch/DiscoLM_German_7b_v1"
6
+ bnb_config = BitsAndBytesConfig(
7
+ load_in_4bit=True,
8
+ bnb_4bit_quant_type="nf4",
9
+ bnb_4bit_compute_dtype=torch.float16,
10
+ )
11
+ base_model = AutoModelForCausalLM.from_pretrained(
12
+ model_name,
13
+ quantization_config=bnb_config,
14
+ device_map="auto",
15
+ trust_remote_code=True,
16
+ token=True,
17
+ )
18
  model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True)
19
  tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
20