ModelAutoEncoder: Pre-trained Model Parameter Embeddings
Model Description
ModelAutoEncoder is a specialized autoencoder designed to compress high-dimensional pre-trained model parameter vectors (8192-dim) into compact 512-dimensional embeddings that preserve essential architectural characteristics. This model is part of a research project on pre-trained model recommendation for specific hardware using transformers.
Key Features
18M parameter autoencoder with symmetric encoder-decoder architecture
Compresses model parameter statistics from 8192 dimensions to 512 dimensions (16x reduction)
GELU activations with dropout regularization for robust representations
Trained with Smooth L1 loss + L1 sparsity penalty for stability
Achieves 0.246 validation loss (Smooth L1 metric)
Fast inference: ~0.1ms per sample on V100 GPU
Throughput: 100,000 samples/second
Use Cases
This autoencoder enables:
Efficient Model Comparison: 512-dim embeddings enable fast similarity computation for model recommendation
Feature Learning: The bottleneck learns meaningful representations of model architecture patterns
Dimensionality Reduction: Reduces computational burden for downstream transformer models that predict model-dataset compatibility
The model converged rapidly with stable training dynamics, achieving best validation performance at epoch 4.
Computational Performance
Metric
Value
Model Size (FP32)
68.04 MB
Model Size (FP16)
34.02 MB
Inference Latency (single)
~0.1ms on V100 GPU
Inference Latency (batch=256)
~2ms on V100 GPU
Throughput
100,000 samples/second
Memory (inference)
~273 MB (model + optimizer states)
Usage
Installation
pip install torch transformers
Loading the Model
python
1import torch
2from transformers import AutoModel
34# Load the model from HuggingFace Hub5model = AutoModel.from_pretrained("parthvpatil18/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", trust_remote_code=True)6model.eval()78# Move to GPU if available9device = torch.device("cuda"if torch.cuda.is_available()else"cpu")10model = model.to(device)
Basic Inference
python
1import torch
2import numpy as np
34# Example: 8192-dim model parameter vector (normalized)5# IMPORTANT: Apply z-score normalization with training dataset statistics6model_params = torch.randn(1,8192).to(device)# Replace with your normalized data78# Extract 512-dim embedding9with torch.no_grad():10 encoded, reconstructed = model(model_params)1112print(f"Input shape: {model_params.shape}")# [1, 8192]13print(f"Embedding shape: {encoded.shape}")# [1, 512]14print(f"Reconstruction shape: {reconstructed.shape}")# [1, 8192]
Batch Processing
python
1# Process multiple models at once2batch_params = torch.randn(32,8192).to(device)# Batch of 32 models34with torch.no_grad():5 embeddings, reconstructions = model(batch_params)67# Use embeddings for downstream tasks (similarity search, clustering, etc.)
Integration with Full Pipeline
For a complete example of using this model in the pre-trained model recommendation pipeline, see the GitHub repository.
python
1# Extract model parameters using specialized extractors2from extractors import HuggingFacePipelineExtractor
34extractor = HuggingFacePipelineExtractor()5raw_params = extractor.extract("your-model-name")# Returns 8192-dim vector67# Apply normalization (CRITICAL STEP)8# You must use mean/std from the training dataset9normalized_params =(raw_params - train_mean)/ train_std
1011# Generate embedding12with torch.no_grad():13 embedding, _ = model(torch.tensor(normalized_params).unsqueeze(0).to(device))1415# Use embedding for model recommendation16print(f"Model embedding: {embedding.shape}")# [1, 512]
Input Requirements
IMPORTANT: Normalization is Required
The model requires z-score normalization of input data using statistics computed from the training dataset:
train/model_autoencoder_trainer.py: Training pipeline
dataloader/model_npz_dataset.py: Dataset loader for model parameters
extractors/: Tools for extracting parameter statistics from pre-trained models
config.ini: Full configuration file with hyperparameters
Running Training
bash
1# Clone the repository2git clone https://github.com/Parth1811/ptm-recommendation-with-transformers.git
3cd ptm-recommendation-with-transformers
45# Install dependencies6pip install -r requirements.txt
78# Train the autoencoder9python train.py ModelAutoEncoderTrainer
Extracting Model Embeddings
bash
1# Extract embeddings for all models in a directory2python evaluate_model_autoencoder.py
Model Card Authors
Developed by: Parth Patil
Model Type: Autoencoder for model parameter embedding
Language(s): Python, PyTorch
License: MIT
Research Project: Pre-trained Model Recommendation with Transformers
Acknowledgments
This model is part of a research thesis project on pre-trained model recommendation for specific hardware using transformers. The system learns to recommend which pre-trained models will perform best on given datasets by extracting compact embeddings from model parameters and dataset features.
Contact
For questions, issues, or collaboration inquiries: