|
from datasets import load_dataset |
|
from transformers import AutoAdapterModel, AutoTokenizer, Trainer, TrainingArguments |
|
|
|
|
|
dataset_pentesting = load_dataset("canstralian/pentesting-ai") |
|
dataset_redpajama = load_dataset("togethercomputer/RedPajama-Data-1T") |
|
|
|
|
|
tokenizer = AutoTokenizer.from_pretrained("canstralian/rabbitredeux") |
|
|
|
def tokenize_function(examples): |
|
return tokenizer(examples['text'], padding="max_length", truncation=True) |
|
|
|
|
|
tokenized_dataset_pentesting = dataset_pentesting.map(tokenize_function, batched=True) |
|
tokenized_dataset_redpajama = dataset_redpajama.map(tokenize_function, batched=True) |
|
|
|
|
|
train_dataset_pentesting = tokenized_dataset_pentesting["train"] |
|
validation_dataset_pentesting = tokenized_dataset_pentesting["validation"] |
|
|
|
|
|
model = AutoAdapterModel.from_pretrained("canstralian/rabbitredeux") |
|
model.load_adapter("Canstralian/RabbitRedux", set_active=True) |
|
|
|
|
|
training_args = TrainingArguments( |
|
output_dir="./results", |
|
num_train_epochs=3, |
|
per_device_train_batch_size=8, |
|
per_device_eval_batch_size=8, |
|
warmup_steps=500, |
|
weight_decay=0.01, |
|
logging_dir="./logs", |
|
logging_steps=10, |
|
evaluation_strategy="epoch", |
|
) |
|
|
|
|
|
trainer = Trainer( |
|
model=model, |
|
args=training_args, |
|
train_dataset=train_dataset_pentesting, |
|
eval_dataset=validation_dataset_pentesting, |
|
) |
|
|
|
|
|
trainer.train() |
|
|
|
|
|
trainer.evaluate() |
|
|
|
|
|
model.save_pretrained("./fine_tuned_model") |