Skip to content

Add HuggingFace Transformers model support#174

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-transformers-support
Draft

Add HuggingFace Transformers model support#174
Copilot wants to merge 2 commits intomainfrom
copilot/add-transformers-support

Conversation

Copy link
Contributor

Copilot AI commented Mar 2, 2026

Adds a GIMKit adapter for HuggingFace transformers models, mirroring the pattern of existing adapters (vLLM, OpenAI).

Changes

  • src/gimkit/models/transformers.py: New Transformers class extending outlines.models.transformers.Transformers with GIMKit's __call__ interface, plus from_transformers(model, tokenizer) factory function
  • pyproject.toml: Added transformers>=4.50.0 as an optional dependency ([transformers] extra)
  • src/gimkit/models/__init__.py, src/gimkit/__init__.py: Exported from_transformers

Usage

from transformers import AutoModelForCausalLM, AutoTokenizer
from gimkit import from_transformers, guide

model_name = "Qwen/Qwen2.5-1.5B-Instruct"
hf_model = AutoModelForCausalLM.from_pretrained(model_name)
hf_tokenizer = AutoTokenizer.from_pretrained(model_name)

model = from_transformers(hf_model, hf_tokenizer)
result = model(f"The capital of France is {guide(name='city')}.")
print(result.tags["city"].content)  # e.g. "Paris"

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Ki-Seki Ki-Seki linked an issue Mar 2, 2026 that may be closed by this pull request
Co-authored-by: Ki-Seki <60967965+Ki-Seki@users.noreply.github.com>
Copilot AI changed the title [WIP] Add transformers support for model outlines Add HuggingFace Transformers model support Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add transformers backend

2 participants