1
0
Fork 0
mirror of https://github.com/p-e-w/heretic.git synced 2026-12-03 18:42:57 +07:00

[PR #31] [MERGED] Add trust_remote_code configuration option #245

Closed
opened 2026-11-01 04:19:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/p-e-w/heretic/pull/31
Author: @kldzj
Created: 11/20/2025
Status: ✅ Merged
Merged: 11/24/2025
Merged by: @p-e-w

Base: master ← Head: trust-remote-code


📝 Commits (6)

  • 261c38e Add trust_remote_code configuration option and apply it when loading models and tokenizers
  • d0abac7 Default trust_remote_code to None and set it to True if previously None so the user wouldn't be asked multiple times
  • ebc4f8e Consistently access trust_remote_code from self.settings instead of the global settings object.
  • 4cf314e Introduce trusted_models dictionary to manage and confirm trust_remote_code settings during model loading
  • 8206bd4 Assign trust_remote_code to evaluate_model in trusted_models instead of model
  • 6b02c6b Merge branch 'p-e-w:master' into trust-remote-code

📊 Changes

2 files changed (+21 additions, -1 deletions)

View changed files

📝 src/heretic/config.py (+5 -0)
📝 src/heretic/model.py (+16 -1)

📄 Description

Problem

Some models require running custom code. If we don't specify trust_remote_code, the process will be interrupted and we'll be asked everytime the tokenizer or model is reloaded, for whether we want to allow it.

Solution

Introduce a --trust-remote-code flag, which defaults to False, and pass it to all .from_pretrained() calls.

Result

The process will now run uninterrupted. If we didn't specify the flag and the model needs to run custom code, it will fail when trying to load the model the first time with a error that specifies that remote code must be trusted.

One minor inconvenience is that the flag needs to explicitly needs to be followed with a boolean value. I didn't want to overcomplicate the model arg parsing logic, which in its current iteration prevents us from setting cli_implicit_flags=True in the SettingsConfigDict, meaning heretic --trust-remote-code [...] isn't sufficient, instead a boolean value must be passed like heretic --trust-remote-code true [...].


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/p-e-w/heretic/pull/31 **Author:** [@kldzj](https://github.com/kldzj) **Created:** 11/20/2025 **Status:** ✅ Merged **Merged:** 11/24/2025 **Merged by:** [@p-e-w](https://github.com/p-e-w) **Base:** `master` ← **Head:** `trust-remote-code` --- ### 📝 Commits (6) - [`261c38e`](https://github.com/p-e-w/heretic/commit/261c38eb6e457dbba7d3108cef718cb197220f64) Add `trust_remote_code` configuration option and apply it when loading models and tokenizers - [`d0abac7`](https://github.com/p-e-w/heretic/commit/d0abac72db9cf8eec3a5a5cc5f8cb91ee1406e79) Default `trust_remote_code` to `None` and set it to `True` if previously `None` so the user wouldn't be asked multiple times - [`ebc4f8e`](https://github.com/p-e-w/heretic/commit/ebc4f8ed5f969710927cc6105ed5bcba67ced884) Consistently access `trust_remote_code` from `self.settings` instead of the global `settings` object. - [`4cf314e`](https://github.com/p-e-w/heretic/commit/4cf314efbd7371e1462664cc17f3728dd558f4f9) Introduce `trusted_models` dictionary to manage and confirm `trust_remote_code` settings during model loading - [`8206bd4`](https://github.com/p-e-w/heretic/commit/8206bd483d82e45f3666dc3b78303ad9596a54f8) Assign `trust_remote_code` to `evaluate_model` in `trusted_models` instead of `model` - [`6b02c6b`](https://github.com/p-e-w/heretic/commit/6b02c6bc3d504d89cf2f70aa7b7f15995c6815d1) Merge branch 'p-e-w:master' into trust-remote-code ### 📊 Changes **2 files changed** (+21 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/heretic/config.py` (+5 -0) 📝 `src/heretic/model.py` (+16 -1) </details> ### 📄 Description ## Problem Some models require running custom code. If we don't specify `trust_remote_code`, the process will be interrupted and we'll be asked everytime the tokenizer or model is reloaded, for whether we want to allow it. ## Solution Introduce a `--trust-remote-code` flag, which defaults to `False`, and pass it to all `.from_pretrained()` calls. ## Result The process will now run uninterrupted. If we didn't specify the flag and the model needs to run custom code, it will fail when trying to load the model the first time with a error that specifies that remote code must be trusted. One minor inconvenience is that the flag needs to explicitly needs to be followed with a boolean value. I didn't want to overcomplicate [the model arg parsing logic](https://github.com/p-e-w/heretic/blob/master/src/heretic/main.py#L60-L68), which in its current iteration prevents us from setting `cli_implicit_flags=True` in the [`SettingsConfigDict`](https://github.com/p-e-w/heretic/blob/master/src/heretic/config.py#L153-L158), meaning `heretic --trust-remote-code [...]` isn't sufficient, instead a boolean value must be passed like `heretic --trust-remote-code true [...]`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 04:19:10 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
p-e-w/heretic#245
No description provided.