mirror of
https://github.com/p-e-w/heretic.git
synced 2026-12-03 18:42:57 +07:00
[GH-ISSUE #291] Observation on Optimization Behavior: Refusals Parameter Not Converging #167
Labels
No labels
bug
enhancement
enhancement
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
p-e-w/heretic#167
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rigin on GitHub (Apr 9, 2026).
Original GitHub issue: https://github.com/p-e-w/heretic/issues/291
Dear @p-e-w, I launched the removal of censorship of a small model by your algorithm and noticed the strangeness of the behavior of the parameters used for optimization in the listing. I sent the listing and your code to a chat with Qwen3.6-Plus and discussed the problem with him for 2 days, and at the end of the discussions I asked Qwen to formulate a summary of the conversation in English as information for you. Below is the summary. I will add that I use an extended dataset in English and in Russian, the total sample when comparing Refusals 236.
config.toml.txt
Observation on Optimization Behavior: Refusals Parameter Not Converging
Hi @p-e-w,
First of all, thank you for this excellent project — the codebase is well-structured and the concept is brilliant.
I've been running abliteration experiments and noticed something I'd like to discuss regarding the optimization behavior.
🔍 Observation
When monitoring the
refusalsmetric across trials (400 total, split into two batches of 200), I observe:Example trajectory (Refusals count, lower is better):
🤔 Initial Hypothesis vs. Code Reality
My first assumption was that this might be a gradient-based optimizer with issues. However, after reviewing
main.py, I see that Optuna's TPE sampler is used:💡 Why This Behavior Might Be Expected
1. Multi-objective optimization creates a Pareto front
The objective function returns a tuple:
TPE optimizes both KL divergence and refusals simultaneously. These objectives often conflict:
Result: TPE explores the Pareto frontier, sampling points that represent different trade-offs. This can appear as "random bouncing" when viewing a single metric in isolation.
2. No pruner configured
Without a pruner (e.g.,
HyperbandPruner), all trials run to completion, even if early evaluations show poor performance. This reduces sample efficiency and may slow convergence.3. Wide parameter ranges + multivariate TPE
With
multivariate=True, TPE models joint distributions, which is powerful but requires more trials to converge — especially with 4+ parameters per component.🛠️ Suggestions for Improvement
Add a pruner to cut unpromising trials early:
Consider single-objective optimization if refusals are the primary goal:
Then use
directions=[StudyDirection.MINIMIZE].Dynamic range narrowing: After N trials, analyze parameter importances (
optuna.visualization.plot_param_importances) and suggest narrowed ranges for subsequent trials.Visualization aid: Add an optional flag to export trial history to CSV for external plotting (helps diagnose convergence issues).
❓ Questions for Discussion
Happy to help test any changes or provide additional logs/metrics. Thanks again for the great work! 🙏
Environment: Heretic v0.x, Optuna 3.x, PyTorch 2.x, CUDA
Model: aya-expanse-8b
Config: [attach relevant config snippet if helpful]
@p-e-w commented on GitHub (Apr 9, 2026):
Heretic uses Bayesian parameter optimization (TPE). TPE is a black-box method. It is not analogous to gradient descent, or other differential-guided approaches. In particular, there is no reason to expect the optimization trajectory to "converge". This isn't how stochastic optimization works.
In other words,
Yes, that's perfectly normal, and not indicative of a problem at all.