Run this model with HF Jobs

Run omaralshareef/Fine-tuning-Gpt-2 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/omaralshareef/Fine-tuning-Gpt-2. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/omaralshareef/Fine-tuning-Gpt-2 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/omaralshareef/Fine-tuning-Gpt-2. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.

Quantize for lower memory use

Use HF Jobs to create a 4-bit version of https://huggingface.co/omaralshareef/Fine-tuning-Gpt-2. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.

Fine-tuning-Gpt-2

LoRA adapter for openai-community/gpt2, fine-tuned with TRL SFT on TinyStories.

The base GPT-2 weights are unchanged. This repo contains the adapter only.

Training

  • 500 steps on train[:8000], sequence length 256
  • LoRA rank 16, alpha 32, dropout 0.05, targets c_attn, c_proj, c_fc
  • Batch size 1, gradient accumulation 8, learning rate 2e-4
  • Final train loss 2.145, eval loss 1.986

Trained locally on an Apple M3 Pro.

Usage

from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer

base_id = "openai-community/gpt2"
adapter_id = "omaralshareef/Fine-tuning-Gpt-2"

tokenizer = AutoTokenizer.from_pretrained(adapter_id)
model = AutoModelForCausalLM.from_pretrained(base_id)
model = PeftModel.from_pretrained(model, adapter_id)

prompt = "Once upon a time there was a little girl named Lucy."
inputs = tokenizer(prompt, return_tensors="pt")
output = model.generate(**inputs, max_new_tokens=80, do_sample=True, temperature=0.8, top_p=0.95)
print(tokenizer.decode(output[0], skip_special_tokens=True))
Downloads last month
59
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for omaralshareef/Fine-tuning-Gpt-2

Adapter
(1,729)
this model

Dataset used to train omaralshareef/Fine-tuning-Gpt-2