Skip to content

feat(3120): Auto Model#3311

Open
Elvis339 wants to merge 6 commits intohuggingface:mainfrom
Elvis339:feature/auto-model-causal-lm-3120
Open

feat(3120): Auto Model#3311
Elvis339 wants to merge 6 commits intohuggingface:mainfrom
Elvis339:feature/auto-model-causal-lm-3120

Conversation

@Elvis339
Copy link
Contributor

@Elvis339 Elvis339 commented Jan 18, 2026

Closes #3120

I took inspiration from Python HuggingFace Transformers. Since candle is also a HuggingFace project, I use the same naming (AutoModelForCausalLM, from_pretrained) so users familiar with the Python API feel at home.

The shared base (AutoConfig, Weights) is designed so subsequent PRs can add AutoModelForSequenceClassification, AutoModelForMaskedLM, etc. if maintainers agree with this direction.

Currently supports
llama, mistral, phi3, qwen2, gemma

Suggested review path
Commit 1 - auto/ module f35d137
Commit 2 - trait impls in model files 6336ff6
Commit 3 - example a9c086f

Add auto module with composable base for loading models from HuggingFace Hub.
- AutoConfig: loads config.json, parses model_type
- Weights: loads safetensors (single or sharded)
- Model + CausalLM traits
- AutoModelForCausalLM: factory returning Box<dyn CausalLM>

Supports: llama, mistral, phi3, qwen2, gemma
Add Model and CausalLM trait implementations to:
- llama (LlamaForCausalLM wrapper)
- mistral
- phi3
- qwen2
- gemma
@Elvis339 Elvis339 marked this pull request as ready for review January 18, 2026 12:49
@Elvis339 Elvis339 changed the title Feature/auto model causal lm 3120 feat(3120): Auto Model Jan 18, 2026
@Elvis339
Copy link
Contributor Author

Looping in maintainer for review, thank you!

cc @ivarflakstad

@ivarflakstad
Copy link
Member

Don't worry I was already looped in - just haven't had the time yet :)

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.

AutoModel / PreTrainedModel equivalent magic ?

2 participants