Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
-
import
|
|
|
2 |
|
3 |
data_args = DataArguments(chat_template=None, dataset_mixer={'HuggingFaceH4/no_robots': 1.0}, dataset_splits=['train_sft', 'test_sft'], max_train_samples=None, max_eval_samples=None, preprocessing_num_workers=12, truncation_side=None)
|
4 |
model_args = ModelArguments(base_model_revision=None, model_name_or_path='mistralai/Mistral-7B-v0.1', model_revision='main', model_code_revision=None, torch_dtype='auto', trust_remote_code=True, use_flash_attention_2=True, use_peft=True, lora_r=64, lora_alpha=16, lora_dropout=0.1, lora_target_modules=['q_proj', 'k_proj', 'v_proj', 'o_proj'], lora_modules_to_save=None, load_in_8bit=False, load_in_4bit=True, bnb_4bit_quant_type='nf4', use_bnb_nested_quant=False)
|
@@ -21,4 +22,37 @@ tokenizer = get_tokenizer(model_args, data_args)
|
|
21 |
#####################
|
22 |
raw_datasets = raw_datasets.map(apply_chat_template, fn_kwargs={"tokenizer": tokenizer, "task": "sft"})
|
23 |
train_dataset = raw_datasets["train"]
|
24 |
-
eval_dataset = raw_datasets["test"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from . import DataArguments, ModelArguments, apply_chat_template, get_datasets, get_tokenizer
|
3 |
|
4 |
data_args = DataArguments(chat_template=None, dataset_mixer={'HuggingFaceH4/no_robots': 1.0}, dataset_splits=['train_sft', 'test_sft'], max_train_samples=None, max_eval_samples=None, preprocessing_num_workers=12, truncation_side=None)
|
5 |
model_args = ModelArguments(base_model_revision=None, model_name_or_path='mistralai/Mistral-7B-v0.1', model_revision='main', model_code_revision=None, torch_dtype='auto', trust_remote_code=True, use_flash_attention_2=True, use_peft=True, lora_r=64, lora_alpha=16, lora_dropout=0.1, lora_target_modules=['q_proj', 'k_proj', 'v_proj', 'o_proj'], lora_modules_to_save=None, load_in_8bit=False, load_in_4bit=True, bnb_4bit_quant_type='nf4', use_bnb_nested_quant=False)
|
|
|
22 |
#####################
|
23 |
raw_datasets = raw_datasets.map(apply_chat_template, fn_kwargs={"tokenizer": tokenizer, "task": "sft"})
|
24 |
train_dataset = raw_datasets["train"]
|
25 |
+
eval_dataset = raw_datasets["test"]
|
26 |
+
|
27 |
+
with gr.Blocks() as demo:
|
28 |
+
gr.Markdown("## AutoTrain Merge Adapter")
|
29 |
+
gr.Markdown("Please duplicate this space and attach a GPU in order to use it.")
|
30 |
+
token = gr.Textbox(
|
31 |
+
label="Hugging Face Write Token",
|
32 |
+
value="",
|
33 |
+
lines=1,
|
34 |
+
max_lines=1,
|
35 |
+
interactive=True,
|
36 |
+
type="password",
|
37 |
+
)
|
38 |
+
base_model = gr.Textbox(
|
39 |
+
label="Base Model (e.g. meta-llama/Llama-2-7b-chat-hf)",
|
40 |
+
value="",
|
41 |
+
lines=1,
|
42 |
+
max_lines=1,
|
43 |
+
interactive=True,
|
44 |
+
)
|
45 |
+
trained_adapter = gr.Textbox(
|
46 |
+
label="Trained Adapter Model (e.g. username/autotrain-my-llama)",
|
47 |
+
value="",
|
48 |
+
lines=1,
|
49 |
+
max_lines=1,
|
50 |
+
interactive=True,
|
51 |
+
)
|
52 |
+
submit = gr.Button(value="Merge & Push")
|
53 |
+
op = gr.Markdown(interactive=False)
|
54 |
+
submit.click(merge, inputs=[base_model, trained_adapter, token], outputs=[op])
|
55 |
+
|
56 |
+
|
57 |
+
if __name__ == "__main__":
|
58 |
+
demo.launch()
|