Text Generation
Transformers
PyTorch
TensorFlow
JAX
Core ML
ONNX
Safetensors
Hebrew
gpt2
text-generation-inference
Instructions to use Norod78/distilgpt2-base-pretrained-he with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Norod78/distilgpt2-base-pretrained-he with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Norod78/distilgpt2-base-pretrained-he")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Norod78/distilgpt2-base-pretrained-he") model = AutoModelForCausalLM.from_pretrained("Norod78/distilgpt2-base-pretrained-he", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Norod78/distilgpt2-base-pretrained-he with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Norod78/distilgpt2-base-pretrained-he" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Norod78/distilgpt2-base-pretrained-he", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Norod78/distilgpt2-base-pretrained-he
- SGLang
How to use Norod78/distilgpt2-base-pretrained-he 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 "Norod78/distilgpt2-base-pretrained-he" \ --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": "Norod78/distilgpt2-base-pretrained-he", "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 "Norod78/distilgpt2-base-pretrained-he" \ --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": "Norod78/distilgpt2-base-pretrained-he", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Norod78/distilgpt2-base-pretrained-he with Docker Model Runner:
docker model run hf.co/Norod78/distilgpt2-base-pretrained-he
Download converters/convert2flax.py from Norod78/distilgpt2-base-pretrained-he: direct link, hf CLI and curl.
- Browser
- Download file 714 Bytes
-
https://huggingface.co/Norod78/distilgpt2-base-pretrained-he/resolve/refs%2Fpr%2F1/converters/convert2flax.py
- Command line
-
hf download hf://Norod78/distilgpt2-base-pretrained-he@refs/pr/1/converters/convert2flax.py
-
curl -L -o convert2flax.py https://huggingface.co/Norod78/distilgpt2-base-pretrained-he/resolve/refs%2Fpr%2F1/converters/convert2flax.py
714 Bytes
| import argparse | |
| import logging | |
| import numpy as np | |
| import torch | |
| import os | |
| from transformers import AutoConfig, FlaxAutoModelForCausalLM | |
| logging.basicConfig( | |
| format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", | |
| datefmt="%m/%d/%Y %H:%M:%S", | |
| level=logging.INFO, | |
| ) | |
| logger = logging.getLogger(__name__) | |
| model_path = "./distilgpt2-base-pretrained-he" | |
| save_directory = "./tmp/flax/" | |
| config_path = os.path.join(model_path, 'config.json') | |
| # Loading from a PyTorch checkpoint file instead of a TensorFlow model (slower) | |
| config = AutoConfig.from_pretrained(config_path) | |
| model = FlaxAutoModelForCausalLM.from_pretrained(model_path, from_pt=True, config=config) | |
| model.save_pretrained(save_directory) |