Ibrahemqasim commited on
Commit
e76dfb4
Β·
1 Parent(s): 053930d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import gradio as gr
2
  import torch
 
3
  from transformers import AutoTokenizer, AutoModelForCausalLM
4
  model_path = "inception-mbzuai/jais-13b-chat"
5
 
@@ -10,7 +11,10 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
10
 
11
  tokenizer = AutoTokenizer.from_pretrained(model_path)
12
  #model = AutoModelForCausalLM.from_pretrained(model_path, device_map="auto", trust_remote_code=True)
13
- model = AutoModelForCausalLM.from_pretrained(model_path, torch_dtype=torch.float16, trust_remote_code=True)
 
 
 
14
 
15
  def get_response(text,tokenizer=tokenizer,model=model):
16
  input_ids = tokenizer(text, return_tensors="pt").input_ids
 
1
  import gradio as gr
2
  import torch
3
+ from peft import prepare_model_for_kbit_training
4
  from transformers import AutoTokenizer, AutoModelForCausalLM
5
  model_path = "inception-mbzuai/jais-13b-chat"
6
 
 
11
 
12
  tokenizer = AutoTokenizer.from_pretrained(model_path)
13
  #model = AutoModelForCausalLM.from_pretrained(model_path, device_map="auto", trust_remote_code=True)
14
+ #model = AutoModelForCausalLM.from_pretrained(model_path, torch_dtype=torch.float16, trust_remote_code=True)
15
+
16
+ model = AutoModelForCausalLM.from_pretrained("inception-mbzuai/jais-13b-chat", load_in_8bit=True, device_map="auto", trust_remote_code=True)
17
+ model = prepare_model_for_kbit_training(model)
18
 
19
  def get_response(text,tokenizer=tokenizer,model=model):
20
  input_ids = tokenizer(text, return_tensors="pt").input_ids