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/convert2tf.py from Norod78/distilgpt2-base-pretrained-he: direct link, hf CLI and curl.
- Browser
- Download file 892 Bytes
-
https://huggingface.co/Norod78/distilgpt2-base-pretrained-he/resolve/refs%2Fpr%2F1/converters/convert2tf.py
- Command line
-
hf download hf://Norod78/distilgpt2-base-pretrained-he@refs/pr/1/converters/convert2tf.py
-
curl -L -o convert2tf.py https://huggingface.co/Norod78/distilgpt2-base-pretrained-he/resolve/refs%2Fpr%2F1/converters/convert2tf.py
892 Bytes
| # Requires transformers >= 4.21.0; | |
| # Sampling outputs may differ, depending on your hardware. | |
| from transformers import AutoTokenizer, TFAutoModelForCausalLM | |
| model_checkpoint = "./distilgpt2-base-pretrained-he" | |
| save_directory = "tmp/tf/" | |
| file_name = "tf_model.h5" | |
| tokenizer = AutoTokenizer.from_pretrained(model_checkpoint) | |
| model = TFAutoModelForCausalLM.from_pretrained(model_checkpoint, from_pt=True) | |
| model.config.pad_token_id = model.config.eos_token_id | |
| inputs = tokenizer(["צחוקים ושיגועים"], return_tensors="tf") | |
| generated = model.generate(**inputs, do_sample=True, seed=(42, 0)) | |
| print("Sampling output: ", tokenizer.decode(generated[0])) | |
| model.save_pretrained(save_directory, file_name=file_name) | |
| tokenizer.save_pretrained(save_directory) | |
| # > Sampling output: TensorFlow is a great learning platform for learning about | |
| # data structure and structure in data science.. | |