# model-exporter

Export HuggingFace models to different formats for inference.

## Installation

```bash
pip install model-exporter
```

## Supported Models

- GPT-2 family: `gpt2`, `gpt2-medium`, `gpt2-large`, `gpt2-xl`, `distilgpt2`

## Supported Formats

- **binary** - Simple binary format for C++ inference
- **safetensors** - Fast and safe tensor format

## Usage

### Export a model

```bash
model-exporter export MODEL_NAME --format FORMAT --output OUTPUT_DIR
```

**Options:**
- `--format` - Export format (binary or safetensors)
- `--output` - Output directory (default: ./weights)
- `--info` - Print model info before export
- `--no-vocab` - Skip vocabulary export

### Examples

```bash
# Export with model info
model-exporter export gpt2-medium --format binary --output ./my_weights --info

# Export without vocabulary
model-exporter export distilgpt2 --format binary --no-vocab
```

## Python API

```python
from model_exporter import get_exporter

# Create exporter
exporter = get_exporter('gpt2')

# Load model
exporter.load_model()

# Export
exporter.export(output_dir='./weights', format_name='binary')
```


## Work in Progress

We're actively working on adding support for:

### Model Families
- **LLaMA/LLaMA-2** - Meta's LLaMA models
- **BERT** - BERT and variants (RoBERTa, DistilBERT)
- **T5/FLAN-T5** - Encoder-decoder models
- **Mistral/Mixtral** - Mistral AI models

### Export Formats
- **GGUF** - llama.cpp compatible format with quantization
- **ONNX** - Cross-platform inference format
- **TensorFlow Lite** - Mobile inference format

### Features
- **Quantization** - int8, int4 quantization support
- **Model sharding** - Split large models across multiple files
- **Batch export** - Export multiple models at once

Want to contribute? Check out our [GitHub repository](https://github.com/therrshan/model-exporters)!

## License

MIT