PhantHive commited on
Commit
d2222b4
1 Parent(s): dcd91cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -4,22 +4,22 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
4
  import torch
5
 
6
  # Load the model and config when the script starts
7
- config = PeftConfig.from_pretrained("phearion/bigbrain-v0.0.1")
8
-
9
- model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-v0.1")
10
- model = PeftModel.from_pretrained(model,"phearion/bigbrain-v0.0.1")
11
-
12
- # Load the tokenizer
13
- tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-v0.1")
14
 
 
 
15
 
16
 
17
  def greet(text):
18
- batch = tokenizer(f"'{text}' ->: ", return_tensors='pt')
19
 
20
  # Use torch.no_grad to disable gradient calculation
21
  with torch.no_grad():
22
- output_tokens = model.generate(**batch, do_sample=True, max_new_tokens=15)
 
23
 
24
  return tokenizer.decode(output_tokens[0], skip_special_tokens=True)
25
 
 
4
  import torch
5
 
6
  # Load the model and config when the script starts
7
+ peft_model_id = "phearion/bigbrain-v0.0.1"
8
+ config = PeftConfig.from_pretrained(peft_model_id)
9
+ model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, return_dict=True)
10
+ tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
 
 
 
11
 
12
+ # Load the Lora model
13
+ model = PeftModel.from_pretrained(model, peft_model_id)
14
 
15
 
16
  def greet(text):
17
+ batch = tokenizer(f"\"{text}\" ->: ", return_tensors='pt')
18
 
19
  # Use torch.no_grad to disable gradient calculation
20
  with torch.no_grad():
21
+ output_tokens = model.generate(**batch, do_sample=True, max_new_tokens=15
22
+ )
23
 
24
  return tokenizer.decode(output_tokens[0], skip_special_tokens=True)
25