Krooz commited on
Commit
c03a470
·
verified ·
1 Parent(s): ae6739d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -1,10 +1,13 @@
1
  import gradio as gr
2
 
 
3
  import torch
 
4
  from datasets import load_dataset
5
  from peft import AutoPeftModelForCausalLM
6
  from transformers import AutoTokenizer, AutoModelForCausalLM
7
 
 
8
 
9
  def format_instruction(report):
10
  return """### Instruction:
@@ -30,12 +33,12 @@ def run_model(report):
30
 
31
  # load base LLM model, LoRA params and tokenizer
32
  model = AutoPeftModelForCausalLM.from_pretrained(
33
- Model_Repo_ID,
34
  low_cpu_mem_usage=True,
35
  torch_dtype=torch.float16,
36
  load_in_4bit=True,
37
  )
38
- tokenizer = AutoTokenizer.from_pretrained(Model_Repo_ID)
39
  input_ids = tokenizer(prompt, return_tensors="pt", truncation=True).input_ids.cpu()
40
 
41
  # inference
 
1
  import gradio as gr
2
 
3
+ import os
4
  import torch
5
+ from dotenv import load_dotenv
6
  from datasets import load_dataset
7
  from peft import AutoPeftModelForCausalLM
8
  from transformers import AutoTokenizer, AutoModelForCausalLM
9
 
10
+ load_dotenv()
11
 
12
  def format_instruction(report):
13
  return """### Instruction:
 
33
 
34
  # load base LLM model, LoRA params and tokenizer
35
  model = AutoPeftModelForCausalLM.from_pretrained(
36
+ os.getenv('Model_Repo_ID'),
37
  low_cpu_mem_usage=True,
38
  torch_dtype=torch.float16,
39
  load_in_4bit=True,
40
  )
41
+ tokenizer = AutoTokenizer.from_pretrained(os.getenv('Model_Repo_ID'))
42
  input_ids = tokenizer(prompt, return_tensors="pt", truncation=True).input_ids.cpu()
43
 
44
  # inference