Text Generation
Transformers
Safetensors
gpt2
causal-lm
from-scratch
reuters
text-generation-inference
Instructions to use MeshMax/gpt2-reuters with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MeshMax/gpt2-reuters with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MeshMax/gpt2-reuters")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("MeshMax/gpt2-reuters") model = AutoModelForCausalLM.from_pretrained("MeshMax/gpt2-reuters", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MeshMax/gpt2-reuters with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MeshMax/gpt2-reuters" # 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", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/MeshMax/gpt2-reuters
- SGLang
How to use MeshMax/gpt2-reuters 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 "MeshMax/gpt2-reuters" \ --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", "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 "MeshMax/gpt2-reuters" \ --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", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use MeshMax/gpt2-reuters with Docker Model Runner:
docker model run hf.co/MeshMax/gpt2-reuters
|
Download README.md from MeshMax/gpt2-reuters: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/MeshMax/gpt2-reuters/resolve/main/README.md
- Command line
-
hf download hf://MeshMax/gpt2-reuters/README.md
-
curl -L -o README.md https://huggingface.co/MeshMax/gpt2-reuters/resolve/main/README.md
1.32 kB
| library_name: transformers | |
| tags: [gpt2, causal-lm, from-scratch, reuters] | |
| datasets: [ingeniumacademy/reuters_articles] | |
| # GPT-2 (small, from scratch) on Reuters articles | |
| 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`. | |
| ## Results | |
| | metric | value | | |
| |---|---| | |
| | parameters | 18,116,608 | | |
| | epochs | 5 | | |
| | training time | 7.8 min | | |
| | validation loss / perplexity | 4.4245 / 83.47 | | |
| | test loss / perplexity | 4.1997 / 66.67 | | |
| ## Configuration | |
| ```json | |
| { | |
| "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": 465.7, | |
| "final_train_loss": 4.1007, | |
| "avg_train_loss": 4.7803, | |
| "val_loss": 4.4245, | |
| "val_perplexity": 83.47, | |
| "test_loss": 4.1997, | |
| "test_perplexity": 66.67 | |
| } | |
| ``` | |
|  | |
| ## Usage | |
| ```python | |
| from transformers import AutoTokenizer, AutoModelForCausalLM | |
| tok = AutoTokenizer.from_pretrained("MeshMax/gpt2-reuters") | |
| model = AutoModelForCausalLM.from_pretrained("MeshMax/gpt2-reuters") | |
| ``` | |