pseudotensor commited on
Commit
3035e40
1 Parent(s): 1c674f6

Update with h2oGPT hash c86dd3b6ef211cef2f99ece2714de09c03e1c490

Browse files
Files changed (5) hide show
  1. app.py +25 -11
  2. client_test.py +1 -1
  3. finetune.py +1 -3
  4. requirements.txt +4 -2
  5. utils.py +33 -1
app.py CHANGED
@@ -4,7 +4,7 @@ import sys
4
  import os
5
  import traceback
6
  import typing
7
- from utils import set_seed, flatten_list, clear_torch_cache, system_info_print, zip_data, save_generate_output
8
 
9
  SEED = 1236
10
  set_seed(SEED)
@@ -556,6 +556,7 @@ def go_gradio(**kwargs):
556
  else:
557
  description = "For more information, visit [the project's website](https://github.com/h2oai/h2ogpt).<br>"
558
  if is_public:
 
559
  description += """<p><b> DISCLAIMERS: </b><ul><i><li>The model was trained on The Pile and other data, which may contain objectionable content. Use at own risk.</i></li>"""
560
  if kwargs['load_8bit']:
561
  description += """<i><li> Model is loaded in 8-bit and has other restrictions on this host. UX can be worse than non-hosted version.</i></li>"""
@@ -891,25 +892,38 @@ body.dark{background:linear-gradient(#0d0d0d,#333333);}"""
891
  lora_used2 = gr.Textbox(label="Current LORA 2", value=no_lora_str,
892
  visible=kwargs['show_lora'])
893
  with gr.TabItem("System"):
 
 
 
 
894
  system_row = gr.Row(visible=not is_public)
895
- admin_pass_textbox = gr.Textbox(label="Admin Password", type='password', visible=is_public)
896
- admin_btn = gr.Button(value="admin", visible=is_public)
897
  with system_row:
898
  with gr.Column():
899
- system_text = gr.Textbox(label='System Info')
900
- system_btn = gr.Button(value='Get System Info')
901
-
902
- zip_btn = gr.Button("Zip")
903
- file_output = gr.File()
 
 
 
 
 
 
904
 
905
  # Get flagged data
906
  zip_data1 = functools.partial(zip_data, root_dirs=['flagged_data_points', kwargs['save_dir']])
907
- zip_btn.click(zip_data1, inputs=None, outputs=file_output)
 
908
 
909
  def check_admin_pass(x):
910
  return gr.update(visible=x == admin_pass)
911
 
912
- admin_btn.click(check_admin_pass, inputs=admin_pass_textbox, outputs=system_row)
 
 
 
 
913
 
914
  # Get inputs to evaluate()
915
  inputs_list = get_inputs_list(locals(), kwargs['model_lower'])
@@ -1953,7 +1967,7 @@ if __name__ == "__main__":
1953
  can also pass --prompt_type='human_bot' and model can somewhat handle instructions without being instruct tuned
1954
  python generate.py --base_model=decapoda-research/llama-65b-hf --load_8bit=False --infer_devices=False --prompt_type='human_bot'
1955
 
1956
- python generate.py --base_model=h2oai/h2ogpt-oig-oasst1-256-6.9b
1957
 
1958
  """, flush=True)
1959
  fire.Fire(main)
 
4
  import os
5
  import traceback
6
  import typing
7
+ from utils import set_seed, flatten_list, clear_torch_cache, system_info_print, zip_data, save_generate_output, s3up
8
 
9
  SEED = 1236
10
  set_seed(SEED)
 
556
  else:
557
  description = "For more information, visit [the project's website](https://github.com/h2oai/h2ogpt).<br>"
558
  if is_public:
559
+ description += "If this host is busy, try [20B](gpt.h2o.ai) and [Chatbot1 12B](https://huggingface.co/spaces/h2oai/h2ogpt-chatbot) and [Chatbot2 12B](https://huggingface.co/spaces/h2oai/h2ogpt-chatbot2)<br>"
560
  description += """<p><b> DISCLAIMERS: </b><ul><i><li>The model was trained on The Pile and other data, which may contain objectionable content. Use at own risk.</i></li>"""
561
  if kwargs['load_8bit']:
562
  description += """<i><li> Model is loaded in 8-bit and has other restrictions on this host. UX can be worse than non-hosted version.</i></li>"""
 
892
  lora_used2 = gr.Textbox(label="Current LORA 2", value=no_lora_str,
893
  visible=kwargs['show_lora'])
894
  with gr.TabItem("System"):
895
+ admin_row = gr.Row()
896
+ with admin_row:
897
+ admin_pass_textbox = gr.Textbox(label="Admin Password", type='password', visible=is_public)
898
+ admin_btn = gr.Button(value="Admin Access", visible=is_public)
899
  system_row = gr.Row(visible=not is_public)
 
 
900
  with system_row:
901
  with gr.Column():
902
+ with gr.Row():
903
+ system_btn = gr.Button(value='Get System Info')
904
+ system_text = gr.Textbox(label='System Info')
905
+
906
+ with gr.Row():
907
+ zip_btn = gr.Button("Zip")
908
+ zip_text = gr.Textbox(label="Zip file name")
909
+ file_output = gr.File()
910
+ with gr.Row():
911
+ s3up_btn = gr.Button("S3UP")
912
+ s3up_text = gr.Textbox(label='S3UP result')
913
 
914
  # Get flagged data
915
  zip_data1 = functools.partial(zip_data, root_dirs=['flagged_data_points', kwargs['save_dir']])
916
+ zip_btn.click(zip_data1, inputs=None, outputs=[file_output, zip_text])
917
+ s3up_btn.click(s3up, inputs=zip_text, outputs=s3up_text)
918
 
919
  def check_admin_pass(x):
920
  return gr.update(visible=x == admin_pass)
921
 
922
+ def close_admin(x):
923
+ return gr.update(visible=not (x == admin_pass))
924
+
925
+ admin_btn.click(check_admin_pass, inputs=admin_pass_textbox, outputs=system_row) \
926
+ .then(close_admin, inputs=admin_pass_textbox, outputs=admin_row)
927
 
928
  # Get inputs to evaluate()
929
  inputs_list = get_inputs_list(locals(), kwargs['model_lower'])
 
1967
  can also pass --prompt_type='human_bot' and model can somewhat handle instructions without being instruct tuned
1968
  python generate.py --base_model=decapoda-research/llama-65b-hf --load_8bit=False --infer_devices=False --prompt_type='human_bot'
1969
 
1970
+ python generate.py --base_model=h2oai/h2ogpt-oig-oasst1-512-6.9b
1971
 
1972
  """, flush=True)
1973
  fire.Fire(main)
client_test.py CHANGED
@@ -3,7 +3,7 @@ Client test.
3
 
4
  Run server:
5
 
6
- python generate.py --base_model=h2oai/h2ogpt-oig-oasst1-256-6.9b
7
 
8
  NOTE: For private models, add --use-auth_token=True
9
 
 
3
 
4
  Run server:
5
 
6
+ python generate.py --base_model=h2oai/h2ogpt-oig-oasst1-512-6.9b
7
 
8
  NOTE: For private models, add --use-auth_token=True
9
 
finetune.py CHANGED
@@ -84,11 +84,9 @@ prompt_type_to_model_name = {
84
  'instruct_with_end': ['databricks/dolly-v2-12b'],
85
  'quality': [],
86
  'human_bot': [
87
- 'h2oai/h2ogpt-oig-oasst1-256-12b',
88
  'h2oai/h2ogpt-oasst1-512-12b',
89
- 'h2oai/h2ogpt-oasst1-256-20b',
90
  'h2oai/h2ogpt-oasst1-512-20b',
91
- 'h2oai/h2ogpt-oig-oasst1-256-6.9b',
92
  ],
93
  'dai_faq': [],
94
  'summarize': [],
 
84
  'instruct_with_end': ['databricks/dolly-v2-12b'],
85
  'quality': [],
86
  'human_bot': [
 
87
  'h2oai/h2ogpt-oasst1-512-12b',
 
88
  'h2oai/h2ogpt-oasst1-512-20b',
89
+ 'h2oai/h2ogpt-oig-oasst1-512-6.9b',
90
  ],
91
  'dai_faq': [],
92
  'summarize': [],
requirements.txt CHANGED
@@ -1,5 +1,5 @@
1
  # for generate (gradio server) and finetune
2
- datasets==2.10.1
3
  sentencepiece==0.1.97
4
  accelerate==0.18.0
5
  gradio==3.27.0
@@ -15,7 +15,7 @@ scikit-learn==1.2.2
15
  alt-profanity-check==1.2.2
16
  better-profanity==0.6.1
17
  numpy==1.24.2
18
- pandas==1.5.3
19
  matplotlib==3.7.1
20
  loralib==0.1.1
21
  bitsandbytes==0.38.1
@@ -26,6 +26,8 @@ tokenizers==0.13.3
26
  # optional for generate
27
  pynvml==11.5.0
28
  psutil==5.9.4
 
 
29
 
30
  # optional for finetune
31
  tensorboard==2.12.1
 
1
  # for generate (gradio server) and finetune
2
+ datasets==2.11.0
3
  sentencepiece==0.1.97
4
  accelerate==0.18.0
5
  gradio==3.27.0
 
15
  alt-profanity-check==1.2.2
16
  better-profanity==0.6.1
17
  numpy==1.24.2
18
+ pandas==2.0.0
19
  matplotlib==3.7.1
20
  loralib==0.1.1
21
  bitsandbytes==0.38.1
 
26
  # optional for generate
27
  pynvml==11.5.0
28
  psutil==5.9.4
29
+ boto3==1.26.101
30
+ botocore==1.29.101
31
 
32
  # optional for finetune
33
  tensorboard==2.12.1
utils.py CHANGED
@@ -118,7 +118,7 @@ def _zip_data(root_dirs=None, zip_file=None, base_dir='./'):
118
  assert os.path.exists(file_to_archive)
119
  path_to_archive = os.path.relpath(file_to_archive, base_dir)
120
  expt_zip.write(filename=file_to_archive, arcname=path_to_archive)
121
- return zip_file
122
 
123
 
124
  def save_generate_output(output=None, base_model=None, save_dir=None):
@@ -152,3 +152,35 @@ def _save_generate_output(output=None, base_model=None, save_dir=None):
152
  dict(text=output, time=time.ctime(), base_model=base_model)
153
  ) + ",\n"
154
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  assert os.path.exists(file_to_archive)
119
  path_to_archive = os.path.relpath(file_to_archive, base_dir)
120
  expt_zip.write(filename=file_to_archive, arcname=path_to_archive)
121
+ return zip_file, zip_file
122
 
123
 
124
  def save_generate_output(output=None, base_model=None, save_dir=None):
 
152
  dict(text=output, time=time.ctime(), base_model=base_model)
153
  ) + ",\n"
154
  )
155
+
156
+
157
+ def s3up(filename):
158
+ try:
159
+ return _s3up(filename)
160
+ except Exception as e:
161
+ traceback.print_exc()
162
+ print('Exception for file %s in s3up: %s' % (filename, str(e)))
163
+ return "Failed to upload %s: Error: %s" % (filename, str(e))
164
+
165
+
166
+ def _s3up(filename):
167
+ import boto3
168
+
169
+ aws_access_key_id = os.getenv('AWS_SERVER_PUBLIC_KEY')
170
+ aws_secret_access_key = os.getenv('AWS_SERVER_SECRET_KEY')
171
+ bucket = os.getenv('AWS_BUCKET')
172
+ assert aws_access_key_id, "Set AWS key"
173
+ assert aws_secret_access_key, "Set AWS secret"
174
+ assert bucket, "Set AWS Bucket"
175
+
176
+ s3 = boto3.client('s3',
177
+ aws_access_key_id=os.getenv('AWS_SERVER_PUBLIC_KEY'),
178
+ aws_secret_access_key=os.getenv('AWS_SERVER_SECRET_KEY'),
179
+ )
180
+ ret = s3.upload_file(
181
+ Filename=filename,
182
+ Bucket=os.getenv('AWS_BUCKET'),
183
+ Key=filename,
184
+ )
185
+ if ret in [None, '']:
186
+ return "Successfully uploaded %s" % filename