Spaces:
Runtime error
Runtime error
pseudotensor
commited on
Commit
•
6a0a9f7
1
Parent(s):
83d9f95
Update with h2oGPT hash 12617a0d8f901cf2e3de0601fbdb52b492b0bd2e
Browse files- app.py +27 -11
- client_test.py +1 -1
- finetune.py +1 -3
- requirements.txt +2 -0
- 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)
|
@@ -891,25 +891,41 @@ 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 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
|
|
|
|
|
|
|
|
913 |
|
914 |
# Get inputs to evaluate()
|
915 |
inputs_list = get_inputs_list(locals(), kwargs['model_lower'])
|
@@ -1953,7 +1969,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-
|
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)
|
|
|
891 |
lora_used2 = gr.Textbox(label="Current LORA 2", value=no_lora_str,
|
892 |
visible=kwargs['show_lora'])
|
893 |
with gr.TabItem("System"):
|
894 |
+
admin_row = gr.Row()
|
895 |
+
with admin_row:
|
896 |
+
admin_pass_textbox = gr.Textbox(label="Admin Password", type='password', visible=is_public)
|
897 |
+
admin_btn = gr.Button(value="Admin Access", visible=is_public)
|
898 |
system_row = gr.Row(visible=not is_public)
|
|
|
|
|
899 |
with system_row:
|
900 |
with gr.Column():
|
901 |
+
with gr.Row():
|
902 |
+
system_btn = gr.Button(value='Get System Info')
|
903 |
+
system_text = gr.Textbox(label='System Info')
|
904 |
+
|
905 |
+
with gr.Row():
|
906 |
+
zip_btn = gr.Button("Zip")
|
907 |
+
zip_text = gr.Textbox(label="Zip file name")
|
908 |
+
file_output = gr.File()
|
909 |
+
with gr.Row():
|
910 |
+
s3up_btn = gr.Button("S3UP")
|
911 |
+
s3up_text = gr.Textbox(label='S3UP result')
|
912 |
|
913 |
# Get flagged data
|
914 |
zip_data1 = functools.partial(zip_data, root_dirs=['flagged_data_points', kwargs['save_dir']])
|
915 |
+
zip_btn.click(zip_data1, inputs=None, outputs=[file_output, zip_text])
|
916 |
+
|
917 |
+
#def update_s3(x):
|
918 |
+
# return gr.update(value="S3UP [%s]" % x)
|
919 |
+
s3up_btn.click(s3up, inputs=zip_text, outputs=s3up_text)
|
920 |
|
921 |
def check_admin_pass(x):
|
922 |
return gr.update(visible=x == admin_pass)
|
923 |
|
924 |
+
def close_admin(x):
|
925 |
+
return gr.update(visible=not (x == admin_pass))
|
926 |
+
|
927 |
+
admin_btn.click(check_admin_pass, inputs=admin_pass_textbox, outputs=system_row) \
|
928 |
+
.then(close_admin, inputs=admin_pass_textbox, outputs=admin_row)
|
929 |
|
930 |
# Get inputs to evaluate()
|
931 |
inputs_list = get_inputs_list(locals(), kwargs['model_lower'])
|
|
|
1969 |
can also pass --prompt_type='human_bot' and model can somewhat handle instructions without being instruct tuned
|
1970 |
python generate.py --base_model=decapoda-research/llama-65b-hf --load_8bit=False --infer_devices=False --prompt_type='human_bot'
|
1971 |
|
1972 |
+
python generate.py --base_model=h2oai/h2ogpt-oig-oasst1-512-6.9b
|
1973 |
|
1974 |
""", flush=True)
|
1975 |
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-
|
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-
|
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
@@ -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
|
|
|
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
|