Skip to content

unixsysdev/EigenForge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Proteus: Zero-Shot Semantic HyperLoRA Architecture

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.

🚀 Key Features

  • 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-v2 encoder. 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$.

🏗 Pipeline Components

The framework dictates a precise 5-Phase mathematical lifecycle distributed natively across multiple modules seamlessly:

1. extract_svd.py (Phase 1: Offline Data Pipeline)

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 $\Delta W$, applies logarithmic clamping algorithms on $\Sigma$, and outputs a compiled PyTorch .pt dataset.

2. hypernet.py (Phase 3: The Synthesizer)

Houses the backbone monolithic neural network architecture processing the $z \in \mathbb{R}^{768}$ continuous vectors. Includes decoupled, dynamically named linear projection heads targeting $U_{gen}$, $\log(\Sigma_{gen})$, and $V_{gen}^T$ matrices matching layer-specific input and output dimensions.

3. loss.py (Phase 4: The Teacher)

Defines OrthogonalSVDLoss, enforcing topological fidelity constraint logic coupled with robust Mean Squared Error convergence checks spanning massive tensor batches.

4. train.py (Phase 2 & Phase 4 orchestration)

The main PyTorch entry point. Handles Dataset batched grouping, dynamically extracts sentence-transformers vector mappings, and supervises the continuous gradients loop.

5. inference.py (Phase 5: The Deployer)

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.

🏃 Usage

Step 1: Pre-Process Offline Weights

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 8

Step 2: Supervised Training Loop

Train the Proteus Neural network with native backpropagation:

python train.py

Step 3: Zero-Shot Injection

from 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.

About

Zero-shot semantic HyperLoRA generation on constrained SVD manifolds

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages