-
Notifications
You must be signed in to change notification settings - Fork 697
#920 with renames #943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
#920 with renames #943
Changes from all commits
56d3713
079e596
fa8c889
0e777fa
f9e6228
c8ef928
6ec76d4
5d87ae2
a5b34ad
e77a391
fbd4999
21e7968
3f7c512
baba228
d43ca12
92a1fd9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -169,22 +169,22 @@ def get_regressor_v2_6(cls) -> ModelSource: # noqa: D102 | |||||||
| @classmethod | ||||||||
| def get_classifier_v3(cls) -> ModelSource: # noqa: D102 | ||||||||
| filenames = [ | ||||||||
| "tabpfn-v3-classifier-20260506.ckpt", | ||||||||
| "tabpfn-v3-classifier-v3_default.ckpt", | ||||||||
| ] | ||||||||
| return cls( | ||||||||
| repo_id="Prior-Labs/tabpfn_3", | ||||||||
| default_filename="tabpfn-v3-classifier-20260506.ckpt", | ||||||||
| default_filename="tabpfn-v3-classifier-v3_default.ckpt", | ||||||||
| filenames=filenames, | ||||||||
| ) | ||||||||
|
|
||||||||
| @classmethod | ||||||||
| def get_regressor_v3(cls) -> ModelSource: # noqa: D102 | ||||||||
| filenames = [ | ||||||||
| "tabpfn-v3-regressor-20260506.ckpt", | ||||||||
| "tabpfn-v3-regressor-v3_default.ckpt", | ||||||||
| ] | ||||||||
| return cls( | ||||||||
| repo_id="Prior-Labs/tabpfn_3", | ||||||||
| default_filename="tabpfn-v3-regressor-20260506.ckpt", | ||||||||
| default_filename="tabpfn-v3-regressor-v3_default.ckpt", | ||||||||
| filenames=filenames, | ||||||||
| ) | ||||||||
|
|
||||||||
|
|
@@ -499,13 +499,14 @@ def _download_model( | |||||||
| ModelVersion.V2_6: "tabpfn_2_6", | ||||||||
| ModelVersion.V3: "tabpfn_3", | ||||||||
| } | ||||||||
| if version in _HF_REPOS: | ||||||||
| try: | ||||||||
| from tabpfn.browser_auth import ensure_license_accepted # noqa: PLC0415 | ||||||||
| # Skip license check for now until tabpfn_3 is public | ||||||||
| # if version in _HF_REPOS: | ||||||||
| # try: | ||||||||
| # from tabpfn.browser_auth import ensure_license_accepted | ||||||||
|
|
||||||||
| ensure_license_accepted(hf_repo_id=_HF_REPOS[version]) | ||||||||
| except Exception as e: # noqa: BLE001 | ||||||||
| return [e] | ||||||||
| # ensure_license_accepted(hf_repo_id=_HF_REPOS[version]) | ||||||||
| # except Exception as e: | ||||||||
| # return [e] | ||||||||
|
|
||||||||
| try: | ||||||||
| model_source = _get_model_source(version, ModelType(which)) | ||||||||
|
|
@@ -975,10 +976,10 @@ def load_model( | |||||||
| ) | ||||||||
|
|
||||||||
| if "test_targets_MB" in inspect.signature(model.forward).parameters: | ||||||||
| # The model computes the loss internally. Support for this was only added after | ||||||||
| # v2.5, so we can safely assume that the inference config is stored in the | ||||||||
| # checkpoint. | ||||||||
| model.load_state_dict(full_state) | ||||||||
| # The model computes the loss internally. Strip criterion keys that | ||||||||
| # save_tabpfn_model may have written so load_state_dict doesn't reject them. | ||||||||
| model_state = {k: v for k, v in full_state.items() if "criterion." not in k} | ||||||||
| model.load_state_dict(model_state) | ||||||||
| model.eval() | ||||||||
| inference_config = InferenceConfig( | ||||||||
| **_rename_old_inference_config_keys(checkpoint["inference_config"]) | ||||||||
|
|
@@ -1102,6 +1103,7 @@ def save_tabpfn_model( | |||||||
| "state_dict": state_dict, | ||||||||
| "config": asdict(config), | ||||||||
| "architecture_name": architecture_name, | ||||||||
| "inference_config": asdict(model.inference_config_), | ||||||||
|
Comment on lines
1105
to
+1106
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This added line is redundant and potentially problematic. The
Suggested change
|
||||||||
| } | ||||||||
| if inference_config is not None: | ||||||||
| checkpoint["inference_config"] = asdict(inference_config) | ||||||||
|
|
@@ -1227,11 +1229,14 @@ def load_fitted_tabpfn_model( | |||||||
|
|
||||||||
| def _resolve_architecture_name(config: ArchitectureConfig) -> str: | ||||||||
| """Resolve the architecture name from the config.""" | ||||||||
| name = getattr(config, "name", "") | ||||||||
| if "v3" in name: | ||||||||
| from tabpfn.architectures.tabpfn_v2_5 import TabPFNV2p5Config # noqa: PLC0415 | ||||||||
| from tabpfn.architectures.tabpfn_v2_6 import TabPFNV2p6Config # noqa: PLC0415 | ||||||||
| from tabpfn.architectures.tabpfn_v3 import TabPFNV3Config # noqa: PLC0415 | ||||||||
|
|
||||||||
| if isinstance(config, TabPFNV3Config): | ||||||||
| return "tabpfn_v3" | ||||||||
| if "2.6" in name: | ||||||||
| if isinstance(config, TabPFNV2p6Config): | ||||||||
| return "tabpfn_v2_6" | ||||||||
| if "2.5" in name: | ||||||||
| if isinstance(config, TabPFNV2p5Config): | ||||||||
| return "tabpfn_v2_5" | ||||||||
| return "base" | ||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| [ | ||
| [ | ||
| 0.9999734163284302, | ||
| 1.3569095244747587e-05, | ||
| 1.2983076885575429e-05 | ||
| ], | ||
| [ | ||
| 0.00036331909359432757, | ||
| 0.9991976618766785, | ||
| 0.0004389923997223377 | ||
| ], | ||
| [ | ||
| 2.672282062121667e-05, | ||
| 0.0005141739966347814, | ||
| 0.9994590878486633 | ||
| ] | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| [ | ||
| [ | ||
| 0.9999734163284302, | ||
| 1.3569095244747587e-05, | ||
| 1.2983076885575429e-05 | ||
| ], | ||
| [ | ||
| 0.00036331909359432757, | ||
| 0.9991976618766785, | ||
| 0.0004389923997223377 | ||
| ], | ||
| [ | ||
| 2.672282062121667e-05, | ||
| 0.0005141739966347814, | ||
| 0.9994590878486633 | ||
| ] | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| [ | ||
| [ | ||
| 0.745369017124176, | ||
| 0.2546309530735016 | ||
| ], | ||
| [ | ||
| 0.42508718371391296, | ||
| 0.5749127864837646 | ||
| ], | ||
| [ | ||
| 0.6312955617904663, | ||
| 0.3687044084072113 | ||
| ] | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| [ | ||
| [ | ||
| 0.6735507845878601, | ||
| 0.3264492154121399 | ||
| ], | ||
| [ | ||
| 0.44950684905052185, | ||
| 0.5504931807518005 | ||
| ], | ||
| [ | ||
| 0.6495934128761292, | ||
| 0.35040655732154846 | ||
| ] | ||
| ] |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| [ | ||
| [ | ||
| 0.7227111458778381, | ||
| 0.27728888392448425 | ||
| ], | ||
| [ | ||
| 0.47503453493118286, | ||
| 0.5249655246734619 | ||
| ], | ||
| [ | ||
| 0.4784924387931824, | ||
| 0.5215075612068176 | ||
| ] | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| [ | ||
| [ | ||
| 0.678566575050354, | ||
| 0.3214334547519684 | ||
| ], | ||
| [ | ||
| 0.46058961749076843, | ||
| 0.5394103527069092 | ||
| ], | ||
| [ | ||
| 0.6697312593460083, | ||
| 0.3302687108516693 | ||
| ] | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| [ | ||
| 5.081058502197266, | ||
| 4.23805046081543, | ||
| 4.6899261474609375 | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| [ | ||
| 5.081058502197266, | ||
| 4.23805046081543, | ||
| 4.6899261474609375 | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The filtering condition
"criterion." not in kis too broad and might accidentally strip valid model parameters if their names contain the string "criterion." (e.g.,layer.criterion_weight). Sincesave_tabpfn_modelspecifically prefixes criterion keys withcriterion., it is safer and more precise to usenot k.startswith("criterion.").