Run this model with HF Jobs
Run rIsHu009/codeparrot-gpt2-trainer 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 and TRL to fine-tune https://huggingface.co/rIsHu009/codeparrot-gpt2-trainer. 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/rIsHu009/codeparrot-gpt2-trainer 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/rIsHu009/codeparrot-gpt2-trainer. 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/rIsHu009/codeparrot-gpt2-trainer. 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.
Instructions to use rIsHu009/codeparrot-gpt2-trainer with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use rIsHu009/codeparrot-gpt2-trainer with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="rIsHu009/codeparrot-gpt2-trainer")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("rIsHu009/codeparrot-gpt2-trainer") model = AutoModelForCausalLM.from_pretrained("rIsHu009/codeparrot-gpt2-trainer", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use rIsHu009/codeparrot-gpt2-trainer with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "rIsHu009/codeparrot-gpt2-trainer" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rIsHu009/codeparrot-gpt2-trainer", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/rIsHu009/codeparrot-gpt2-trainer
- SGLang
How to use rIsHu009/codeparrot-gpt2-trainer with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "rIsHu009/codeparrot-gpt2-trainer" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rIsHu009/codeparrot-gpt2-trainer", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "rIsHu009/codeparrot-gpt2-trainer" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rIsHu009/codeparrot-gpt2-trainer", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use rIsHu009/codeparrot-gpt2-trainer with Docker Model Runner:
docker model run hf.co/rIsHu009/codeparrot-gpt2-trainer
CodeParrot GPT-2 โ Trainer Experiment
A GPT-2-style causal language model for code generation, trained as part of my hands-on study of language-model training with the Hugging Face ecosystem.
This checkpoint represents the Trainer implementation of the experiment. A companion repository reproduces the same learning workflow using a lower-level Accelerate-based training loop:
โก๏ธ rIsHu009/codeparrot-gpt2-accelerate
This repository is preserved as an educational training artifact rather than presented as a production code-generation model.
Experiment
The goal of this project was to explore the end-to-end workflow behind training a causal language model on source code:
source code
โ
code-oriented BPE tokenizer
โ
GPT-2 causal language model
โ
Hugging Face Trainer
โ
next-token prediction
The companion Accelerate checkpoint provides a useful contrast between Hugging Face's high-level Trainer abstraction and a more explicit training workflow.
Model Architecture
| Property | Value |
|---|---|
| Architecture | GPT2LMHeadModel |
| Task | Causal Language Modeling / Text Generation |
| Transformer layers | 12 |
| Hidden size | 768 |
| Attention heads | 12 |
| Vocabulary size | 50,000 |
| Training context length | 128 tokens |
| Maximum position embeddings | 1,024 |
| Weight precision | FP32 |
| Activation | GELU New |
The model configuration follows the GPT-2 architecture while using a code-oriented tokenizer and a shortened training context.
Tokenizer
The repository includes a 50,000-token Byte-Level BPE tokenizer adapted for source-code text.
Its vocabulary contains common programming patterns and tokens such as:
def
return
self
None
value
file
data
error
config
This allows the tokenizer to represent common code structures more efficiently than treating the experiment as ordinary natural-language generation.
The special <|endoftext|> token is used for sequence boundaries and padding in the Trainer workflow.
Training Configuration
The preserved Trainer metadata records the following configuration:
| Hyperparameter | Value |
|---|---|
| Learning rate | 5e-4 |
| Train batch size | 64 |
| Evaluation batch size | 64 |
| Gradient accumulation | 8 |
| Effective train batch size | 512 |
| Seed | 42 |
| Optimizer | AdamW |
| LR scheduler | Cosine |
| Warmup steps | 1000 |
| Epochs | 1 |
| Mixed precision | Native AMP |
Historical software environment
- Transformers
4.51.3 - PyTorch
2.6.0+cu124 - Datasets
3.6.0 - Tokenizers
0.21.1
Quick Start
from transformers import AutoTokenizer, AutoModelForCausalLM
MODEL_ID = "rIsHu009/codeparrot-gpt2-trainer"
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForCausalLM.from_pretrained(MODEL_ID)
prompt = """def fibonacci(n):
if n <= 1:
"""
inputs = tokenizer(
prompt,
return_tensors="pt",
)
outputs = model.generate(
**inputs,
max_new_tokens=80,
do_sample=True,
temperature=0.8,
top_p=0.95,
)
print(
tokenizer.decode(
outputs[0],
skip_special_tokens=True,
)
)
Trainer vs Accelerate
This checkpoint is useful together with its companion experiment:
| Repository | Training approach |
|---|---|
codeparrot-gpt2-trainer |
Hugging Face Trainer |
codeparrot-gpt2-accelerate |
Accelerate/manual training workflow |
The pair is retained to document two levels of abstraction for Transformer training.
Trainer handles much of the training infrastructure automatically, while an Accelerate-oriented workflow exposes more of the optimization and training loop directly.
Intended Use
This checkpoint is primarily useful for:
- learning causal language modeling;
- experimenting with code generation;
- studying code-oriented tokenization;
- learning the Hugging Face
Trainer; - comparing
Trainerwith Accelerate; - experimenting with GPT-2 architecture and generation;
- educational inference demonstrations.
Evaluation
No verified benchmark results were preserved with this checkpoint.
For that reason, this model card intentionally does not report unsupported code-generation accuracy, pass@k, perplexity, or other performance claims.
The repository should be treated as a reproducible learning checkpoint rather than a benchmarked code model.
Limitations
This is a relatively small educational code-generation model.
Generated code may:
- be syntactically incorrect;
- contain logical errors;
- reference nonexistent APIs;
- reproduce undesirable patterns from training data;
- fail to complete complex programming tasks;
- contain insecure or inefficient code.
Generated programs should always be reviewed and tested before execution.
Learning Context
This experiment was created while studying Hugging Face language-model training workflows.
The broader learning progression on this profile includes:
- Transformer encoders;
- question answering;
- sequence classification;
- named-entity recognition;
- machine translation;
- causal language modeling;
- tokenizer training;
Trainer;- Accelerate;
- dataset processing.
Repository Contents
The repository includes:
- GPT-2 model configuration;
model.safetensors;- custom tokenizer files;
- generation configuration;
- Trainer metadata;
- historical training arguments;
- TensorBoard training artifacts.
Companion Model
Accelerate implementation
rIsHu009/codeparrot-gpt2-accelerate
The companion checkpoint represents the same learning direction using an Accelerate-oriented training workflow rather than the high-level Trainer abstraction.
Author
Naman Chanana
- Hugging Face:
rIsHu009 - GitHub:
Rishy-09
Educational code-language-model artifact preserved as part of an ongoing study of LLM training and the Hugging Face ecosystem.
- Downloads last month
- 251
Model tree for rIsHu009/codeparrot-gpt2-trainer
Base model
openai-community/gpt2