ingeniumacademy/reuters_articles
Viewer โข Updated โข 21.6k โข 183
How to use randeepa02/gpt2-reuters-from-scratch with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="randeepa02/gpt2-reuters-from-scratch") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("randeepa02/gpt2-reuters-from-scratch")
model = AutoModelForCausalLM.from_pretrained("randeepa02/gpt2-reuters-from-scratch", device_map="auto")How to use randeepa02/gpt2-reuters-from-scratch with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "randeepa02/gpt2-reuters-from-scratch"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "randeepa02/gpt2-reuters-from-scratch",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/randeepa02/gpt2-reuters-from-scratch
How to use randeepa02/gpt2-reuters-from-scratch with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "randeepa02/gpt2-reuters-from-scratch" \
--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": "randeepa02/gpt2-reuters-from-scratch",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "randeepa02/gpt2-reuters-from-scratch" \
--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": "randeepa02/gpt2-reuters-from-scratch",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use randeepa02/gpt2-reuters-from-scratch with Docker Model Runner:
docker model run hf.co/randeepa02/gpt2-reuters-from-scratch
GPT-2 style causal language model trained from random initialisation on the Reuters articles dataset (title + body concatenated) with the next-token prediction objective. Tokenizer: ingeniumacademy/gpt2-reuters-tokenizer.
| Setting | Value |
|---|---|
| Layers / heads / d_model | 6 / 6 / 384 |
| Context length | 256 |
| Parameters | 30,713,856 |
| Epochs | 5 |
| Batch size / LR | 32 / 0.0005 (cosine, 5% warmup) |
| Training time | 561.2 s |
| Validation loss (ppl) | 4.1743 (65.00) |
| Test loss (ppl) | 3.9747 (53.24) |
Supporting files: training_summary.json, log_history.csv, loss_curve.png.
from transformers import AutoTokenizer, AutoModelForCausalLM
tok = AutoTokenizer.from_pretrained('randeepa02/gpt2-reuters-from-scratch')
model = AutoModelForCausalLM.from_pretrained('randeepa02/gpt2-reuters-from-scratch')