transformers-convert

Solid

Use this skill when converting custom PyTorch models to Hugging Face Transformers format. Helps with: (1) Creating PretrainedConfig and PreTrainedModel classes, (2) Writing ImageProcessor/Tokenizer, (3) Compatibility testing, (4) Hub upload preparation. Use when the user wants to make their model compatible with transformers library.

Data & Documents 142 stars 5 forks Updated today MIT

Install

View on GitHub

Quality Score: 86/100

Stars 20%
72
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Hugging Face Transformers Model Conversion Convert custom PyTorch models to Hugging Face Transformers format while maintaining exact compatibility with the original implementation. ## Overview This skill provides a systematic workflow for transformers conversion: - Extract hardcoded values into PretrainedConfig - Create PreTrainedModel wrapper - Build ImageProcessor/Tokenizer - Test equivalence thoroughly - Prepare for Hub upload **Important**: Use validation mode (parallel implementations) first to verify equivalence, then replace the original. ## Conversion Workflow ### Step 1: Analyze the Custom Model Ask the user to specify: - Path to the custom model implementation - Model type (vision, text, multimodal) - Task (classification, segmentation, generation, etc.) - Validation mode or replacement mode Then identify: - Model architecture and components - Input/output formats - Key hyperparameters and hardcoded values - Pretrained weights location - Preprocessing pipeline - Custom layers or modules ### Step 2: Create PretrainedConfig Class **Key principle**: Extract ALL hardcoded values from the model as configurable parameters. Template: ```python from transformers import PretrainedConfig from typing import List, Optional class {ModelName}Config(PretrainedConfig): model_type = "{model_name}" def __init__( self, # Core architecture parameters hidden_dim: int = 128, num_layers: int = 4, # Input/output parameters...

Details

Author
shunk031
Repository
shunk031/dotfiles
Created
10 years ago
Last Updated
today
Language
Shell
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Solid

transformers-config-tokenizers-expert

Preflight reference for HuggingFace snapshots — what vLLM, sglang, and transformers.generate see at runtime. Covers config-file precedence (tokenizer.json, tokenizer_config.json, generation_config.json, chat_template.jinja), transformers v5 tokenizer-class taxonomy (TokenizersBackend, PythonBackend, MistralCommonBackend, TikTokenTokenizer), special-token discovery (all_special_ids, added_tokens_decoder, extra_special_tokens, backend_tokenizer.get_added_tokens_decoder), chat-template Jinja contract (ImmutableSandboxedEnvironment, loopcontrols, raise_exception, strftime_now, tojson, add_generation_prompt), and engine knobs (skip_special_tokens, trust_request_chat_template, chat_template_kwargs allowlist, adjust_request, incremental detokenizer, EOS merge). Ships verified 2026 hall-of-shame for Kimi-K2.6, GLM-5.1, Gemma-4, Qwen3, DeepSeek-V3, plus drop-in Python for resolving markers to IDs, detecting turn-primer-as-EOS leaks, and cross-referencing tokenizer.json vs tokenizer_config.json.

3 Updated 2 days ago
air-gapped
Data & Documents Featured

converter

Convert AgentOps skill formats. Triggers: "converter", "convert agentops skill formats.", "converter skill".

414 Updated today
boshu2
Data & Documents Solid

convert

Convert files between 140+ formats using Conversion Tools. Two surfaces are available - the `ctio` CLI (preferred when shell access is available) and the hosted Conversion Tools MCP server (zero-install, works everywhere). Covers documents (Word, PDF, Excel, PowerPoint), data formats (JSON, CSV, XML, YAML, Parquet), images (PNG, JPG, WebP, AVIF, HEIC, JXL, SVG), audio (MP3, WAV, FLAC), video (MOV, MKV, AVI to MP4), e-books (EPUB, MOBI, AZW), OCR text extraction, AI-powered data extraction, AI text-to-speech (TTS), AI speech-to-text transcription (STT), subtitle conversion (SRT, VTT, ASS), and website screenshots. Plus build custom converters on demand - describe a transformation in plain language and Conversion Tools creates, runs, and returns a reusable converter when no standard one fits.

5 Updated yesterday
conversiontools