Repository navigation
fix(llm): pass token, not use_auth_token, so local models load on transformers 5 - #448
Merged
Merged
Conversation
…formers Installing from main into a fresh environment now resolves transformers 5.17.0 (CI resolves the same). transformers 5 no longer defines `use_auth_token` anywhere, and from_pretrained forwards keywords it does not recognise to the model's constructor. load_model_from_transformer passed `use_auth_token=token` to both AutoTokenizer and AutoModelForCausalLM, so the local-model path, including running on CPU with no API key, was exposed on any current install. CI did not catch it: the loader tests replace from_pretrained with fakes that accept any keyword. The loader now passes `token=` only when a token is given, and nothing when it is not, so public models load the same way on every transformers version. Two tests pin this: a given token reaches both from_pretrained calls as `token` and `use_auth_token` is never sent, and no token keyword is sent when the token is None or empty. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Code Hygiene The following items are defined but not yet in active use. Routine cleanup — no impact on functionality.
|
|
Complexity Analysis Average: C — Moderate (13.75) Hotspots tracked below. These are functional, well-exercised components — listed for visibility as the codebase scales.
|
2 tasks
phanindra-max
added a commit
that referenced
this pull request
Sep 17, 2026
Release to main: load local models on transformers 5 (#448)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On current
main, a fresh install cannot create a local-model extractor. That includes the CPU, no-API-key path the documentation and the JOSS review thread point reviewers to.Reproduced by running the documented command in a new virtual environment:
pip install "git+https://github.com/LAiSER-Software/extract-module@main"The install resolves to
mainat86a2e32, with transformers 5.17.0, torch 2.14.0 and sentence-transformers 6.0.1. Creating the extractor then fails:load_model_from_transformerpasseduse_auth_token=tokento bothfrom_pretrainedcalls. transformers 5 no longer definesuse_auth_tokenanywhere. Itsfrom_pretrainedforwards keywords it does not recognise to the model's constructor, which rejects them.CI did not catch this. It resolves the same transformers 5.17.0, but the loader tests replace
from_pretrainedwith fakes that accept any keyword. My earlier end-to-end runs used a local transformers 4.49, whereuse_auth_tokenwas only deprecated.Fix
b015a10passestoken=only when a token is given, and no token keyword when it is not, so public models load the same way on every transformers version.Two new tests pin it down:
from_pretrainedcalls astoken, anduse_auth_tokenis never sent.Noneor empty.Verification
black,isortandflake8: clean-m "not index"): 61 passed, 5 skipped (need API keys), 1 deselectedb015a10there, with dependencies unchanged, and ran the documented no-API-key example on CPU (Qwen/Qwen2.5-0.5B-Instruct,use_gpu=False). The extractor initialised, routed to the transformers backend, and returned 8 aligned skills. The same run againstmain(86a2e32) fails with the error above.Follow-up
This needs to reach
mainbefore the no-API-key instructions work for a fresh install. The JOSS review thread and #438 point there, so both will be updated once it has.🤖 Generated with Claude Code