Proteus is an end-to-end PyTorch pipeline for Zero-Shot Semantic HyperLoRA generation. It introduces a radically efficient architecture for dynamic adapter synthesis targeting Large Language Models (specifically designed and tested around Mistral-7B-v0.1).
Instead of traditional, iterative textual adapter routing or switching paradigms, Proteus mathematically bridges frozen natural language sentence embeddings with the rigorous geometry of SVD (Singular Value Decomposition) manifolds. By mapping arbitrary semantic intents to dynamically constructed singular values and orthogonal components, Proteus allows for lightweight, zero-shot LoRA adapter injection mapped directly from text.
-
Geometric Manifold Constraints: By enforcing Stiefel Manifold constraints during Hypernetwork training (
$U^T U = I_r$ ,$V V^T = I_r$ ), the outputs inherently conform to true, mathematically valid orthogonal vector spaces. -
Semantic Topology Continuity: Prompts are mapped through a frozen
sentence-transformers/all-mpnet-base-v2encoder. Similar prompts result in closely clustered mathematical outputs, interpolating weights automatically for unseen prompts. -
Agnostic Rank Reduction: Regardless of original source adapter rank sizes (
$r=16, r=64$ ), Proteus rigorously extracts, compresses via SVD truncation, and standardizes everything internally to$r=8$ .
The framework dictates a precise 5-Phase mathematical lifecycle distributed natively across multiple modules seamlessly:
Processes an entire directory of offline pretrained HuggingFace adapters. Automatically handles internal PyTorch structural dependencies or safetensors, groups linear layers accurately by modules (e.g., q_proj), performs strict Singular Value Decompositions on .pt dataset.
Houses the backbone monolithic neural network architecture processing the
Defines OrthogonalSVDLoss, enforcing topological fidelity constraint logic coupled with robust Mean Squared Error convergence checks spanning massive tensor batches.
The main PyTorch entry point. Handles Dataset batched grouping, dynamically extracts sentence-transformers vector mappings, and supervises the continuous gradients loop.
Bridges unseen semantic text inputs entirely back to tangible LLM weights. It mathematically reconstructs the generated vectors through strict A and B linear projection derivations ready for standard parameter efficient adapter (PEFT) implementations natively.
Download highly optimized adapters (instruction tuning, mathematics, RP) corresponding to Mistral-7B that strictly implement equivalent parameters spanning target_modules. Run:
python extract_svd.py --base_dir path/to/your/lora_directory --r 8Train the Proteus Neural network with native backpropagation:
python train.pyfrom inference import inject_hyperlora
target_modules = {"q_proj": (4096, 4096), "v_proj": (1024, 4096)} # Example dimension
lora_matrices = inject_hyperlora(
text_prompt="Write a distributed Python pipeline",
hypernet_path="hypernet_final.pt",
target_shapes=target_modules,
r=8
)You can now map lora_matrices["q_proj"]["A"] and lora_matrices["q_proj"]["B"] back into the local base network parameters dynamically.