Add wov invnorm norm and extend slerp range - #865
Merged
gkielian merged 3 commits intoJul 22, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR expands the hf-vocab-sphere vector expression system to support model-aware functions (norm, invnorm, wov), extends SLERP to allow finite extrapolation (t outside [0, 1]), and adds a frontend toggle to display vector magnitudes in labels.
Changes:
- Allow finite SLERP extrapolation and update the UI/control contract accordingly.
- Add model-backed vector functions (
norm,invnorm,wov) with support for nesting inside expressions. - Add a “show label magnitudes” appearance setting and wire it through UI + settings persistence.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| report/threejs/hf-vocab-sphere/tests/test_vector_math.py | Updates SLERP expectations and adds coverage for nested model-function calls in expressions. |
| report/threejs/hf-vocab-sphere/tests/test_frontend_contract.py | Extends contract checks for the new magnitude-label toggle and hotkey/settings wiring. |
| report/threejs/hf-vocab-sphere/app/vector_math.py | Extends the safe evaluator to support string args + model functions and relaxes SLERP’s t constraints. |
| report/threejs/hf-vocab-sphere/app/templates/index.html | Updates SLERP input UX and adds magnitude-label toggle + hotkey documentation. |
| report/threejs/hf-vocab-sphere/app/static/app.js | Implements magnitude label rendering, updates SLERP fraction handling, and persists new appearance setting. |
| report/threejs/hf-vocab-sphere/app/model_store.py | Adds auxiliary tensor loading + caching and implements norm/invnorm/wov backend operations. |
| report/threejs/hf-vocab-sphere/app/main.py | Wires projection arithmetic evaluation to the model-backed vector function implementation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+137
to
+141
| if isinstance(node, ast.Constant) and isinstance(node.value, str): | ||
| text = node.value.strip().casefold() | ||
| if not text or len(text) > 40: | ||
| raise ValueError("String arguments must be short, non-blank selectors.") | ||
| return _Value("string", text) |
Comment on lines
58
to
+60
| fraction = float(t) | ||
| if not math.isfinite(fraction) or fraction < 0.0 or fraction > 1.0: | ||
| raise ValueError("SLERP t must be a finite scalar in the interval [0, 1].") | ||
| if not math.isfinite(fraction): | ||
| raise ValueError("SLERP t must be a finite scalar.") |
Comment on lines
+988
to
+996
| _AUX_TENSOR_CACHE: dict[tuple[str, str, bool], dict[str, torch.Tensor]] = {} | ||
|
|
||
|
|
||
| def _all_safetensor_tensors(model_name: str, *, revision: str, allow_download: bool = True) -> dict[str, torch.Tensor]: | ||
| cache_key = (model_name, revision, allow_download) | ||
| cached = _AUX_TENSOR_CACHE.get(cache_key) | ||
| if cached is not None: | ||
| return cached | ||
| tensors: dict[str, torch.Tensor] = {} |
gkielian
approved these changes
Jul 22, 2026
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.
No description provided.