{"id":5760,"library":"curated-transformers","title":"Curated Transformers","description":"Curated Transformers is a PyTorch library offering a collection of transformer models and components, optimized for efficiency and integration. It provides a consistent API for popular models like MPT, Llama 2, Falcon, BERT, and ELECTRA, supporting features like generation, 8-bit/4-bit quantization, and Safetensor checkpoints. The latest version is 2.0.1, with releases occurring as needed for features and bug fixes, often with a focus on PyTorch compatibility.","status":"active","version":"2.0.1","language":"en","source_language":"en","source_url":"https://github.com/explosion/curated-transformers","tags":["pytorch","transformers","nlp","llm","deep-learning","explosion"],"install":[{"cmd":"pip install curated-transformers torch safetensors huggingface_hub","lang":"bash","label":"Recommended install for Hugging Face Hub"}],"dependencies":[{"reason":"Core deep learning framework","package":"torch","optional":false},{"reason":"Recommended for faster model loading from Hugging Face Hub","package":"safetensors","optional":true},{"reason":"Required for loading models from Hugging Face Hub and related utilities","package":"huggingface_hub","optional":true},{"reason":"For using alternative filesystems as model repositories","package":"fsspec","optional":true}],"imports":[{"symbol":"AutoCausalLM","correct":"from curated_transformers.models import AutoCausalLM"},{"symbol":"AutoEncoder","correct":"from curated_transformers.models import AutoEncoder"},{"symbol":"AutoDecoder","correct":"from curated_transformers.models import AutoDecoder"},{"symbol":"AutoTokenizer","correct":"from curated_transformers.tokenization import AutoTokenizer"},{"symbol":"Generator","correct":"from curated_transformers.generation import Generator"}],"quickstart":{"code":"import torch\nfrom curated_transformers.generation import Generator\nfrom curated_transformers.models import AutoCausalLM\nfrom curated_transformers.tokenization import AutoTokenizer\n\n# Example model, replace with your desired model\n# Ensure `explosion/mpt-7b-peft-ct2-int4` is accessible or use a local path.\nmodel = AutoCausalLM.from_hf_hub(\"explosion/mpt-7b-peft-ct2-int4\")\ntokenizer = AutoTokenizer.from_hf_hub(\"explosion/mpt-7b-peft-ct2-int4\")\ngenerator = Generator(model, tokenizer)\n\ntext = \"Hello, I'm a language model,\"\ntokenized = tokenizer([text])\n\n# Generate text (returns an iterator of generated strings)\nfor generated_text in generator(tokenized, max_length=50, eos_token_id=tokenizer.eos_token_id):\n    print(generated_text)\n","lang":"python","description":"This quickstart demonstrates how to load a causal language model and its tokenizer from the Hugging Face Hub, and then use the `Generator` to produce new text. This requires `huggingface_hub` and `safetensors` to be installed."},"warnings":[{"fix":"Update `curated_transformers.repository.HFHubRepository` to `curated_transformers.repository.HFHubModelRepository`. Modify model loading calls to pass a `repository` object explicitly, e.g., `AutoCausalLM.from_hf_hub(\"model\", repository=HFHubModelRepository())`.","message":"In v2.0.0, the `HFHubRepository` class was renamed to `HFHubModelRepository`. Additionally, `AutoEncoder`, `AutoDecoder`, and `AutoCausalLM` models now require an explicit `repository` object instead of a direct `revision` argument for loading.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Adjust any code that accesses `MPTModelOutput` to rely solely on the `last_hidden_state` attribute, as `past_key_values` is no longer available directly from this output.","message":"In v2.0.0, the `MPTModelOutput` class was changed to only output `last_hidden_state`. Previous versions also included `past_key_values`.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Always check the `curated-transformers` changelog or documentation for specific PyTorch version compatibility. For PyTorch 2.1.0+, it's recommended to upgrade to `curated-transformers` v2.0.0 or newer.","message":"Prior to v2.0.0, `curated-transformers` had strict upper bounds on supported PyTorch versions (e.g., v1.3.1 was limited to PyTorch <2.1.0). Attempting to use incompatible PyTorch versions could lead to runtime errors.","severity":"gotcha","affected_versions":"All, but especially <2.0.0"},{"fix":"Users running on Python 3.12.3 should upgrade to `curated-transformers>=2.0.1` (for the 2.x series) or `curated-transformers>=1.3.2` (for the 1.x series) to resolve this compatibility issue.","message":"Versions `2.0.0`, `1.3.0`, and `1.3.1` of `curated-transformers` contained a bug that caused an activation lookup error when running on Python 3.12.3.","severity":"gotcha","affected_versions":"2.0.0, 1.3.0, 1.3.1"},{"fix":"If you are defining or configuring these embedding layers directly, update the parameter name from `n_vocab` to `n_pieces`.","message":"In v2.0.0, the parameter `n_vocab` in `curated_transformers.models.bertish.BertEmbedding` and `curated_transformers.models.gpt_neo.GPTNeoEmbedding` was renamed to `n_pieces`.","severity":"gotcha","affected_versions":"<2.0.0"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}