ingeniumacademy/reuters_articles
Viewer โข Updated โข 21.6k โข 400
How to use MeshMax/gpt2-reuters-from-scratch with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="MeshMax/gpt2-reuters-from-scratch") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("MeshMax/gpt2-reuters-from-scratch")
model = AutoModelForCausalLM.from_pretrained("MeshMax/gpt2-reuters-from-scratch", device_map="auto")How to use MeshMax/gpt2-reuters-from-scratch with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "MeshMax/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": "MeshMax/gpt2-reuters-from-scratch",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/MeshMax/gpt2-reuters-from-scratch
How to use MeshMax/gpt2-reuters-from-scratch with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "MeshMax/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": "MeshMax/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 "MeshMax/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": "MeshMax/gpt2-reuters-from-scratch",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use MeshMax/gpt2-reuters-from-scratch with Docker Model Runner:
docker model run hf.co/MeshMax/gpt2-reuters-from-scratch
Trained from random initialisation with the causal (next-token) language-modelling objective
on the concatenated title + body of ingeniumacademy/reuters_articles, using the tokenizer ingeniumacademy/gpt2-reuters-tokenizer.
| metric | value |
|---|---|
| parameters | 18,116,608 |
| epochs | 5 |
| training time | 7.9 min |
| validation loss / perplexity | 4.3802 / 79.85 |
| test loss / perplexity | 4.1682 / 64.6 |
{
"run": "main",
"epochs": 5,
"n_embd": 256,
"n_layer": 6,
"n_head": 8,
"block_size": 256,
"learning_rate": 0.0005,
"batch_size": 32,
"total_params": 18116608,
"embedding_params": 13377536,
"non_embedding_params": 4739072,
"train_time_sec": 474.4,
"final_train_loss": 4.0094,
"avg_train_loss": 4.7307,
"val_loss": 4.3802,
"val_perplexity": 79.85,
"test_loss": 4.1682,
"test_perplexity": 64.6
}
from transformers import AutoTokenizer, AutoModelForCausalLM
tok = AutoTokenizer.from_pretrained("MeshMax/gpt2-reuters-from-scratch")
model = AutoModelForCausalLM.from_pretrained("MeshMax/gpt2-reuters-from-scratch")