Transformers: Transformers: the model-definition framework for state-of-the-art machine learning…
huggingface/transformers🤗 Transformers: the model-definition framework for state-of-the-art machine learning models in text, vision, audio, and multimodal models, for both inference and training.
Evaluate and collect.
What the project says.
English 简体中文 繁體中文 한국어 Español 日本語 हिन्दी मराठी Русский Português తెలుగు Français Deutsch Italiano Tiếng Việt العربية اردو বাংলা فارسی Română Türkçe State-of-the-art pretrained models for inference and training Transformers is the model-definition framework for machine learning models in text, computer vision, audio, video, and multimodal tasks. It defines each model once, in PyTorch, and you use that definition for both inference and training. Training frameworks, inference engines, and local runtimes build on that definition instead of writing their own. Transformers adds new architectures as they're released and matches each one to its original results, so those tools get each new model as soon as it's added. Fine-tune with less memory. Unsloth trains LLMs in 4-bit, 8-bit, and 16-bit precision with custom kernels. Serve LLMs at scale. vLLM batches requests continuously and keeps KV cache memory compact with PagedAttention. Serve LLMs with low latency. SGLang is a high-throughput inference engine with a frontend language for agentic workflows. Run LLMs locally without Python. llama.cpp is a C/C++ inference engine that runs quantized models in the GGUF format. Transformers standardizes how every model is written, so hundreds of architectures share one structure. Each model is one file that reads from top to bottom and stays simple without giving up performance. An improvement made once reaches every architecture, so if you find one, contribute it. Transformers is designed to be read and modified by humans and coding agents alike. To swap how a model computes, register your own attention or experts function, or load an optimized kernel from the Hub, and the model uses it without edits to its code. Try a model Install Transformers with PyTorch. See the Installation guide for other setups. Create a Pipeline with a chat model from the Hugging Face Hub and pass it a message. The Quickstart covers loading models, running inference on other tasks, and training. Set up your coding agent Copy the prompt below into your coding agent. It has the agent check your installed version, read the docs for that version, and use the current Transformers v5 APIs. Run inference Load a pretrained model and run it on text, images, audio, video, or any combination of modalities. - Pipeline: Preprocess the input, run the model, and postprocess the output for a task with one class. - Text generation: Generate text with LLMs and VLMs, and control the decoding strategy and streaming. - Chat with models: Start a chat in your terminal with transformers chat , or pass a chat history to a pipeline. Serve models Serve a model to other applications over HTTP. transformers serve is for evaluation, experimentation, and moderate load. For large production deployments, use an inference engine with a Transformers model as the backend. - Serve CLI: Start a local server compatible with the OpenAI SDK with transformers serve . - Continuous batching: Raise throughput by adding new requests to the batch as other requests finish. - Inference engines: Use a Transformers model as the backend for vLLM or SGLang. Train models Fine-tune a pretrained model on your data, on one GPU or many. - Trainer: Run the training loop with support for mixed precision and torch.compile . - PEFT: Train a small adapter instead of all of a model's weights. - FSDP: Shard a model's parameters across GPUs to train models that don't fit on one. - Tensor parallelism: Split each weight matrix across GPUs so every GPU computes part of each layer. - Expert parallelism: Place the experts of a mixture-of-experts model on different GPUs and route tokens to them. Use less memory and run faster Fit a model on your hardware and speed it up. - Quantization: Store weights in fewer bits so a model needs less memory. - Kernels: Load precompiled operations for your hardware from the Hub. - Attention backends: Switch between attention implementations without changing the model. Add or change a model Add a model to...
Continue the conversation.
Comments, one-level replies, owner highlights, and discussion notifications are included with ORYNT membership.
Sign in with GitHub