Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,28 +1,29 @@
|
|
1 |
import gradio as gr
|
2 |
from . import DataArguments, ModelArguments, apply_chat_template, get_datasets, get_tokenizer
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
)
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
26 |
|
27 |
with gr.Blocks() as demo:
|
28 |
gr.Markdown("## AutoTrain Merge Adapter")
|
|
|
1 |
import gradio as gr
|
2 |
from . import DataArguments, ModelArguments, apply_chat_template, get_datasets, get_tokenizer
|
3 |
|
4 |
+
def template(base_model, trained_adapter, token):
|
5 |
+
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)
|
6 |
+
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)
|
7 |
+
|
8 |
+
###############
|
9 |
+
# Load datasets
|
10 |
+
###############
|
11 |
+
raw_datasets = get_datasets(data_args, splits=data_args.dataset_splits)
|
12 |
+
logger.info(
|
13 |
+
f"Training on the following datasets and their proportions: {[split + ' : ' + str(dset.num_rows) for split, dset in raw_datasets.items()]}"
|
14 |
+
)
|
15 |
+
|
16 |
+
################
|
17 |
+
# Load tokenizer
|
18 |
+
################
|
19 |
+
tokenizer = get_tokenizer(model_args, data_args)
|
20 |
+
|
21 |
+
#####################
|
22 |
+
# Apply chat template
|
23 |
+
#####################
|
24 |
+
raw_datasets = raw_datasets.map(apply_chat_template, fn_kwargs={"tokenizer": tokenizer, "task": "sft"})
|
25 |
+
train_dataset = raw_datasets["train"]
|
26 |
+
eval_dataset = raw_datasets["test"]
|
27 |
|
28 |
with gr.Blocks() as demo:
|
29 |
gr.Markdown("## AutoTrain Merge Adapter")
|