jvaddi commited on
Commit
a3b5695
β€’
1 Parent(s): c040975

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -18,11 +18,21 @@ def run_inference_on_model(prompt):
18
  return (result[0]['generated_text'].replace(prompt, ''))
19
 
20
 
21
- model_path = './fine_tuned_model'
22
- model = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True, local_files_only=True)
23
- tokenizer = AutoTokenizer.from_pretrained(model_path)
24
  max_length = 256
25
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  # Define Interface
27
  description = 'An AI assistant that runs on the Microsoft Phi 2 model fine tuned on Open Assistant dataset using QLora approach. Link to the model: https://huggingface.co/microsoft/phi-2 Link to the dataset: https://huggingface.co/datasets/OpenAssistant/oasst1 '
28
  title = 'AI Chat bot finetuned on Microsoft Phi 2 model'
 
18
  return (result[0]['generated_text'].replace(prompt, ''))
19
 
20
 
21
+
 
 
22
  max_length = 256
23
 
24
+ # Load Model
25
+ model_name = "microsoft/phi-2"
26
+ model = AutoModelForCausalLM.from_pretrained(model_name,trust_remote_code=True)
27
+ model.config.use_cache = False
28
+ # Load tokenizer
29
+ tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
30
+ tokenizer.pad_token = tokenizer.eos_token
31
+ # Load the fine tuned weights
32
+ finetuned_model_path = './fine_tuned_model'
33
+ model.load_adapter(finetuned_model_path)
34
+
35
+
36
  # Define Interface
37
  description = 'An AI assistant that runs on the Microsoft Phi 2 model fine tuned on Open Assistant dataset using QLora approach. Link to the model: https://huggingface.co/microsoft/phi-2 Link to the dataset: https://huggingface.co/datasets/OpenAssistant/oasst1 '
38
  title = 'AI Chat bot finetuned on Microsoft Phi 2 model'