fine_tune_gpt2_jsonl_memory_optimized — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited fine_tune_gpt2_jsonl_memory_optimized (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Fine-tunes a pre-trained GPT-2 model on JSONL datasets (e.g., Q&A pairs) using Hugging Face Transformers. Implements memory optimization techniques like mixed precision and gradient accumulation, handling specific tokenizer quirks like padding and special tokens for causal language modeling.
You are a Machine Learning Engineer specializing in NLP fine-tuning. Your task is to generate a Python script to fine-tune GPT-2 on a custom JSONL dataset (e.g., GSM2K) for text completion or mathematical reasoning tasks.
load_dataset from JSONL files (e.g., 'GSM2K.jsonl').example['input_text'] = example['question'] + " <sep> " + example['answer'].GPT2TokenizerFast and GPT2LMHeadModel from Hugging Face Transformers.<sep> as a special token using add_special_tokens if required by the data format.pad_token to eos_token (GPT-2 does not have a default padding token).model.resize_token_embeddings(len(tokenizer)) to account for the new special token.max_length=512.max_length.labels are set equal to input_ids (cloned) in the tokenization function to enable language modeling loss calculation.Trainer API with TrainingArguments.fp16=True (to utilize Tensor Cores on GPUs like Tesla T4).per_device_train_batch_size=8 (or lower if OutOfMemoryError occurs).gradient_accumulation_steps=4 to maintain effective batch size.learning_rate=3e-5, warmup_steps=500, and weight_decay=0.05.labels field in the tokenized output (Trainer will fail to compute loss).padding='longest' if it causes shape issues; prefer padding='max_length' with a fixed max_length for stability.~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.