Instructions to use FurkanNar/gpt-2_svamp with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use FurkanNar/gpt-2_svamp with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="FurkanNar/gpt-2_svamp")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("FurkanNar/gpt-2_svamp", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use FurkanNar/gpt-2_svamp with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "FurkanNar/gpt-2_svamp" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FurkanNar/gpt-2_svamp", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/FurkanNar/gpt-2_svamp
- SGLang
How to use FurkanNar/gpt-2_svamp 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 "FurkanNar/gpt-2_svamp" \ --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": "FurkanNar/gpt-2_svamp", "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 "FurkanNar/gpt-2_svamp" \ --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": "FurkanNar/gpt-2_svamp", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use FurkanNar/gpt-2_svamp with Docker Model Runner:
docker model run hf.co/FurkanNar/gpt-2_svamp
GPT-2 Fine-tuning on SVAMP Dataset
This project fine-tunes OpenAI's GPT-2 model on the SVAMP (Simple Variants of Arithmetic Math Problems) dataset to improve mathematical problem-solving capabilities.
Overview
The model is trained to solve arithmetic word problems by fine-tuning GPT-2 on the SVAMP dataset. This enhances the model's ability to understand and solve mathematical reasoning tasks.
Model & Dataset Information
Base Model
- Model:
openai-community/gpt2 - Architecture: GPT-2 (Causal Language Modeling)
- Tokenizer: tiktoken (GPT-2 encoding)
- EOT Token ID: 50256 (used for end-of-text and padding)
Dataset
- Name:
ChilleD/SVAMP - Task: Mathematical problem solving (arithmetic word problems)
- Purpose: Improve mathematical reasoning and problem-solving capabilities
Training Configuration
Hyperparameters
- Epochs: 10
- Batch Size: 4
- Learning Rate: 1e-4
- Optimizer: AdamW (Adam with weight decay)
- Gradient Clipping: Max norm 1.0 (prevents gradient explosion)
- Max Sequence Length: 256 tokens
Hardware
- GPU: Tesla T4
- CUDA: Enabled
Training Results
The model was trained for 8 epochs with the following metrics:
| Epoch | Train Loss | Val Loss | Val Acc |
|---|---|---|---|
| 1 | 3.4209 | 2.0873 | 0.5634 |
| 2 | 2.1413 | 1.7239 | 0.6115 |
| 3 | 1.7929 | 1.5186 | 0.6445 |
| 4 | 1.6145 | 1.3977 | 0.6729 |
| 5 | 1.4897 | 1.3221 | 0.6829 |
| 6 | 1.4032 | 1.2842 | 0.6920 |
| 7 | 1.3729 | 1.2702 | 0.6955 |
| 8 | 1.3733 | 1.2693 | 0.6961 |
The model achieved a final validation accuracy of 69.61% with validation loss decreasing from 2.0873 to 1.2693 over 8 epochs. The training loss decreased from 3.4209 to 1.3733, indicating successful learning of the mathematical problem-solving task.
Training Details
Gradient Clipping
Gradient clipping with a maximum norm of 1.0 was applied during training to prevent gradient explosions and ensure training stability.
Tokenization
- Uses tiktoken tokenizer for GPT-2 encoding
- Sequences are truncated/padded to 256 tokens
- EOT token (50256) marks end of text and serves as padding token
Optimization
- AdamW optimizer with weight decay for regularization
- Learning rate of 1e-4 for stable convergence
- Batch size of 4 due to memory constraints on Tesla T4
Notes
- Training was performed on Google Colab with Tesla T4 GPU
- The model shows consistent improvement in loss reduction across all epochs
- Gradient clipping was essential for training stability
- Small batch size (4) was used due to usage limits
