Text Generation
Transformers
Safetensors
English
gpt2
toy-llm
from-scratch
huggingface
english
casual-lm
educational
text-generation-inference
Instructions to use mehta/CooperLM-354M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mehta/CooperLM-354M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mehta/CooperLM-354M")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("mehta/CooperLM-354M") model = AutoModelForCausalLM.from_pretrained("mehta/CooperLM-354M", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use mehta/CooperLM-354M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mehta/CooperLM-354M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mehta/CooperLM-354M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/mehta/CooperLM-354M
- SGLang
How to use mehta/CooperLM-354M 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 "mehta/CooperLM-354M" \ --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": "mehta/CooperLM-354M", "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 "mehta/CooperLM-354M" \ --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": "mehta/CooperLM-354M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use mehta/CooperLM-354M with Docker Model Runner:
docker model run hf.co/mehta/CooperLM-354M
Commit History
-
Update README.md
Verified signature1cbe431
-
Delete quantized
Verified signaturead0626c -
Upload folder using huggingface_hub
Verified signaturedb31dd6
-
Update README.md
Verified signature5892635
-
Update README.md
Verified signature2ad1963 -
Update README.md
Verified signatureaa3099e -
Update README.md
Verified signature# 🧠 CooperLM-354M **CooperLM-354M** is a 354 million parameter GPT-2 based language model trained from scratch on a filtered subset of Wikipedia, BookCorpus, and OpenWebText. It was created as a toy project to explore end-to-end LLM training using Hugging Face’s Transformers and Datasets libraries. --- ## 🧱 Architecture - GPT-2 with 24 layers, 16 heads, 1024 hidden size - 256-token context window - Trained for 1 epoch on 100k samples (~1.2M sequences) --- ## 📊 Training Details | Setting | Value | |------------------------|-----------------| | Model Type | GPT2LMHeadModel | | Epochs | 1 | | Precision | fp16 | | Batch Size (effective) | 16 | | GPU | RTX 4080 | | Final Eval Loss | 5.63 | | Perplexity | ~263 | --- ## 📥 Usage ```python from transformers import GPT2LMHeadModel, GPT2TokenizerFast model = GPT2L…abd54de -
Upload folder using huggingface_hub
Verified signaturebef563e -
initial commit
Verified signaturedeeab87