KaizeShi commited on
Commit
05fe8e0
·
1 Parent(s): f52d254

Add application file

Browse files
Files changed (2) hide show
  1. app.py +13 -11
  2. requirements.txt +5 -8
app.py CHANGED
@@ -52,7 +52,9 @@ elif device == "mps":
52
  )
53
  else:
54
  model = LlamaForCausalLM.from_pretrained(
55
- BASE_MODEL, device_map={"": device}, low_cpu_mem_usage=True
 
 
56
  )
57
  model = PeftModel.from_pretrained(
58
  model,
@@ -65,16 +67,16 @@ print("Model: " + str(model))
65
  def generate_prompt(instruction, input=None):
66
  if input:
67
  return f"""Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
68
- ### Instruction:
69
- {instruction}
70
- ### Input:
71
- {input}
72
- ### Response:"""
73
  else:
74
  return f"""Below is an instruction that describes a task. Write a response that appropriately completes the request.
75
- ### Instruction:
76
- {instruction}
77
- ### Response:"""
78
 
79
  if device != "cpu":
80
  model.half()
@@ -89,8 +91,8 @@ def evaluate(
89
  temperature=0.1,
90
  top_p=0.75,
91
  top_k=40,
92
- num_beams=4,
93
- max_new_tokens=128,
94
  **kwargs,
95
  ):
96
  prompt = generate_prompt(instruction, input)
 
52
  )
53
  else:
54
  model = LlamaForCausalLM.from_pretrained(
55
+ BASE_MODEL,
56
+ device_map={"": device},
57
+ low_cpu_mem_usage=True
58
  )
59
  model = PeftModel.from_pretrained(
60
  model,
 
67
  def generate_prompt(instruction, input=None):
68
  if input:
69
  return f"""Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
70
+ ### Instruction:
71
+ {instruction}
72
+ ### Input:
73
+ {input}
74
+ ### Response:"""
75
  else:
76
  return f"""Below is an instruction that describes a task. Write a response that appropriately completes the request.
77
+ ### Instruction:
78
+ {instruction}
79
+ ### Response:"""
80
 
81
  if device != "cpu":
82
  model.half()
 
91
  temperature=0.1,
92
  top_p=0.75,
93
  top_k=40,
94
+ num_beams=2,
95
+ max_new_tokens=64,
96
  **kwargs,
97
  ):
98
  prompt = generate_prompt(instruction, input)
requirements.txt CHANGED
@@ -1,12 +1,9 @@
1
- accelerate
2
- appdirs
3
  loralib
 
 
 
4
  bitsandbytes
5
- black
6
- black[jupyter]
7
- datasets
8
- fire
9
  git+https://github.com/huggingface/peft.git
10
- transformers>=4.28.0
11
- sentencepiece
12
  gradio
 
 
1
+ datasets
 
2
  loralib
3
+ sentencepiece
4
+ git+https://github.com/huggingface/transformers.git
5
+ accelerate
6
  bitsandbytes
 
 
 
 
7
  git+https://github.com/huggingface/peft.git
 
 
8
  gradio
9
+ scipy