Instructions to use Tensormorph/distillgpt2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use Tensormorph/distillgpt2 with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://Tensormorph/distillgpt2") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use Tensormorph/distillgpt2 with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf Tensormorph/distillgpt2:F16 # Run inference directly in the terminal: llama cli -hf Tensormorph/distillgpt2:F16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Tensormorph/distillgpt2:F16 # Run inference directly in the terminal: llama cli -hf Tensormorph/distillgpt2:F16
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf Tensormorph/distillgpt2:F16 # Run inference directly in the terminal: ./llama-cli -hf Tensormorph/distillgpt2:F16
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf Tensormorph/distillgpt2:F16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf Tensormorph/distillgpt2:F16
Use Docker
docker model run hf.co/Tensormorph/distillgpt2:F16
- LM Studio
- Jan
- Ollama
How to use Tensormorph/distillgpt2 with Ollama:
ollama run hf.co/Tensormorph/distillgpt2:F16
- Unsloth Desktop
- Docker Model Runner
How to use Tensormorph/distillgpt2 with Docker Model Runner:
docker model run hf.co/Tensormorph/distillgpt2:F16
- Lemonade
How to use Tensormorph/distillgpt2 with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Tensormorph/distillgpt2:F16
Run and chat with the model
lemonade run user.distillgpt2-F16
List all available models
lemonade list
- Atomic Chat
distilgpt2: export fixtures
35 variants: 34 ok, 0 mismatch, 0 failed, 1 skipped.
Generated by python -m tools.export_formats.run_all; machine-readable twin: manifest.json (sha256 per file).
Every file was loaded back with its own runtime (PyTorch, onnxruntime, gguf-py, Keras/TF, TFLite, Core ML, OpenVINO) and its
logits on the fixed [2, 8] ids compared with the PyTorch model. max rel diff is relative to max |logit|; ok means within the
variant's tolerance (1e-4 for float32, looser for fp16 / int8 / 4-bit). graph says what the file holds besides weights.
| format | variant | files | size | graph | status | max rel diff | notes |
|---|---|---|---|---|---|---|---|
| pytorch | state_dict (our names, zip) .pt | pytorch/distilgpt2.state_dict.pt |
312.5 MiB | none | ok | 0.0e+00 | |
| pytorch | state_dict (HF names, zip) .pth | pytorch/distilgpt2.hf_state_dict.pth |
336.5 MiB | none | ok | 0.0e+00 | |
| pytorch | training checkpoint .pt | pytorch/distilgpt2.training_checkpoint.pt |
937.5 MiB | none | ok | 0.0e+00 | {model: state_dict with 'module.' prefix, optimizer: AdamW state, epoch, global_step} |
| pytorch | lightning-style .ckpt | pytorch/distilgpt2.lightning_style.ckpt |
937.5 MiB | none | ok | 0.0e+00 | PyTorch zip pickle with a .ckpt extension; layout mimics PyTorch Lightning (Lightning itself not used) |
| pytorch | full model pickle .pt | pytorch/distilgpt2.full_model_pickle.pt |
318.5 MiB | pickled classes | ok | 0.0e+00 | torch.save(model): needs the Python classes and arbitrary unpickling; an importer must refuse it |
| torchscript | torch.jit.trace .pt | pytorch/distilgpt2.torchscript.pt |
318.6 MiB | TorchScript code | ok | 0.0e+00 | |
| torch.export | ExportedProgram .pt2 | pytorch/distilgpt2.pt2 |
319.0 MiB | ATen graph | ok | 0.0e+00 | |
| binary | pytorch_model.bin (zip pickle) | pytorch/pytorch_model.bin |
336.5 MiB | none | ok | 0.0e+00 | |
| binary | pytorch_model.bin (legacy pickle) | pytorch/pytorch_model.legacy.bin |
336.5 MiB | none | ok | 0.0e+00 | pre-1.6 non-zip pickle (copy of Hugging Face's original file, storages on cuda:0) |
| safetensors | HF names, lm_head omitted (tied) | pytorch/model.safetensors |
336.5 MiB | none | ok | 0.0e+00 | |
| onnx | dynamo exporter, static [2,8] | onnx/distilgpt2.onnx |
318.9 MiB | ONNX graph | ok | 2.3e-06 | weights inline in the .onnx |
| onnx | dynamo exporter, dynamic axes | onnx/distilgpt2.dynamic.onnxonnx/distilgpt2.dynamic.onnx.data |
318.9 MiB | ONNX graph | ok | 2.6e-06 | symbolic batch / sequence; weights in .onnx.data (exporter default) |
| onnx | legacy exporter, opset 17 | onnx/distilgpt2.legacy_opset17.onnx |
460.9 MiB | ONNX graph | ok | 2.6e-06 | TorchScript-based exporter (dynamo=False): Gemm/MatMul patterns differ |
| onnx | external data (.onnx + .bin) | onnx/distilgpt2.external.onnxonnx/distilgpt2.external.bin |
637.4 MiB | ONNX graph | ok | 2.3e-06 | all initializers in one sibling .bin file |
| onnx | dynamic int8 (MatMulInteger) | onnx/distilgpt2.int8_dynamic.onnx |
116.8 MiB | ONNX graph | ok | 1.1e-01 | onnxruntime quantize_dynamic on the opset-17 model: per-channel int8 weights; activations quantized per tensor at run time, so lossy by design (DistilGPT2: ~11% of max |
| gguf | f32 | gguf/distilgpt2.f32.gguf |
312.5 MiB | none (arch + hyperparameters) | ok | 0.0e+00 | |
| gguf | f16 (1-D tensors f32) | gguf/distilgpt2.f16.gguf |
156.4 MiB | none (arch + hyperparameters) | ok | 3.1e-04 | |
| gguf | q8_0 (1-D tensors f32) | gguf/distilgpt2.q8_0.gguf |
83.2 MiB | none (arch + hyperparameters) | ok | 1.1e-02 | block-quantized: 32 values per 34-byte block |
| gguf | q4_0 (1-D tensors f32) | gguf/distilgpt2.q4_0.gguf |
44.1 MiB | none (arch + hyperparameters) | ok | 2.0e-01 | block-quantized: 32 values per 18-byte block |
| keras | rebuilt model (in memory) | โ | โ | - | ok | 2.2e-06 | reference for the files below; nothing written |
| keras | Keras 3 .keras (zip) | tensorflow/distilgpt2.keras |
312.7 MiB | Keras config | ok | 2.2e-06 | zip: config.json + metadata.json + model.weights.h5 |
| hdf5 | Keras full model .h5 | tensorflow/distilgpt2.h5 |
312.7 MiB | Keras config (model_config attr) | ok | 2.2e-06 | legacy HDF5 format |
| hdf5 | Keras weights only .weights.h5 | tensorflow/distilgpt2.weights.h5 |
312.7 MiB | none | ok | 2.2e-06 | no architecture: needs the code or a template |
| tf-checkpoint | TF2 object checkpoint .ckpt | tensorflow/distilgpt2.ckpt.indextensorflow/distilgpt2.ckpt.data-00000-of-00001 |
312.5 MiB | none (object graph only) | ok | 2.2e-06 | |
| tf-checkpoint | TF1 checkpoint .ckpt + .meta | tensorflow/distilgpt2_tf1.ckpt.indextensorflow/distilgpt2_tf1.ckpt.data-00000-of-00001tensorflow/distilgpt2_tf1.ckpt.metatensorflow/checkpoint |
312.7 MiB | TF1 GraphDef in .meta | ok | 2.3e-06 | variable names like OpenAI's GPT-2 release (model/h0/attn/c_attn/w); weights are [in, out] |
| savedmodel | SavedModel directory | tensorflow/distilgpt2_saved_model |
625.6 MiB | TF GraphDef (saved_model.pb) | ok | 2.2e-06 | |
| tflite | float32 | tensorflow/distilgpt2.float32.tflite |
309.6 MiB | TFLite subgraph | ok | 7.5e-07 | static input [2, 8] |
| tflite | float16 weights | tensorflow/distilgpt2.float16.tflite |
154.8 MiB | TFLite subgraph | ok | 4.1e-04 | static input [2, 8]; weights fp16 + DEQUANTIZE ops |
| tflite | dynamic-range int8 weights | tensorflow/distilgpt2.int8_dynamic.tflite |
115.5 MiB | TFLite subgraph | ok | 5.4e-02 | static input [2, 8]; int8 weights, float activations |
| coreml | mlprogram FP32 .mlpackage | coreml/distilgpt2.mlpackage |
309.8 MiB | MIL program | ok | 1.2e-06 | directory: Manifest.json + Data/com.apple.CoreML/{model.mlmodel, weights/weight.bin} |
| coreml | mlprogram FP16 .mlpackage | coreml/distilgpt2.fp16.mlpackage |
154.9 MiB | MIL program | ok | 1.1e-03 | weights and compute in fp16 |
| coreml | neuralnetwork .mlmodel | coreml/distilgpt2.mlmodel |
456.9 MiB | NeuralNetwork layers | ok | 1.0e-06 | single protobuf file, weights inline |
| openvino | IR fp32 (.xml + .bin) | openvino/distilgpt2.xmlopenvino/distilgpt2.bin |
313.7 MiB | OpenVINO IR graph (.xml) | ok | 1.2e-06 | |
| openvino | IR fp16-compressed weights | openvino/distilgpt2.fp16.xmlopenvino/distilgpt2.fp16.bin |
157.5 MiB | OpenVINO IR graph (.xml) | ok | 4.1e-04 | weights stored fp16 in the .bin, decompressed by Convert ops in the graph |
| tensorrt | .engine from ONNX | โ | โ | โ | skipped | โ | needs TensorRT + an NVIDIA CUDA GPU (tensorrt importable: False, CUDA: False); on such a machine run this script or: trtexec --onnx=exports/distilgpt2/onnx/distilgpt2.onnx --saveEngine=exports/distilgpt2/tensorrt/distilgpt2.engine --exportLayerInfo=exports/distilgpt2/tensorrt/distilgpt2.layers.json --profilingVerbosity=detailed |
Environment: torch 2.14.1, onnx 1.23.2, onnxscript 0.7.2, onnxruntime 1.31.0, gguf 0.19.0, tensorflow 2.21.0, keras 3.15.1, coremltools 9.0, openvino 2026.4.1, safetensors 0.8.0, numpy 2.5.4; macOS-26.6.2-arm64-arm-64bit, Python 3.12.11.
- Downloads last month
- 27
4-bit
8-bit
16-bit
32-bit