Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧠 LIP: Latent Injection Protocol

PyPI version License: MIT Python 3.11+

LIP (Latent Injection Protocol) is a production-grade framework for direct model-to-model communication. It enables latent intent biasing between heterogeneous Large Language Models (LLMs) by extracting internal hidden representations, translating them through a bottleneck adapter, and injecting them into a target model, bypassing textual serialization entirely.

Stop forcing your neural networks to exchange strings and JSONs. Let them communicate in their native thermodynamic language: tensors.

📦 Installation

pip install lip-protocol

⚡ Quickstart: "Machine Telepathy"

LIP abstracts away the thermodynamic calibration, dimensionality translation, and transport serialization. Here is how you can transmit a latent intent from a 1.3B parameter model to an 8B parameter model in just a few lines.

import torch
from lip.api import LIPSender, LIPReceiver
from lip.models.registry import AdapterRegistry

# 1. The Source: A smaller model (e.g., DeepSeek) emits a latent intent (2048 dims)
source_tensor = torch.randn(2048)
sender = LIPSender(source_model="deepseek-coder-1.3b")
packet = sender.transmit(tensor=source_tensor, intent_class="logic_routing")

# --- Packet is transmitted over the network (JSON/gRPC) ---

# 2. The Bridge: Load a pretrained latent translator from Hugging Face Hub
adapter = AdapterRegistry.load_adapter(
    source_family="deepseek",
    target_family="llama3",
)

# 3. The Target: A larger model (e.g., Llama-3) receives and calibrates (4096 dims)
receiver = LIPReceiver(
    target_model_family="llama3",
    target_reference_energy=12.5,  # The target model's base L2 activation norm
    adapter=adapter,
)

# The resulting tensor is mathematically translated, calibrated, and ready for injection!
calibrated_tensor = receiver.receive(packet)
print(f"Injection ready. Target Shape: {calibrated_tensor.shape}")

🏗️ Core Architecture

LIP is built for both research reproducibility and production microservices:

  • Transport-Agnostic Core (lip.core & lip.transport): Packets (LIPPacket) manage metadata and payload independently. Tensors are safely serialized while keeping the networking layer agnostic of ML framework concerns.
  • Hugging Face Adapter Hub (lip.models): Seamless integration with huggingface_hub to instantly download, cache, and apply translation matrices for heterogeneous latent spaces.
  • Energy Calibration (lip.core.energy): Built-in L2-norm thermodynamic scaling prevents internal activation collapse and stabilizes the target LLM during injection.

📖 Research & Paper

This package is the official implementation of the Latent Injection Protocol. If you use lip-protocol in your research or architecture, please consider citing our work:

@article{silva2026lip,
  title={LIP: Enabling Asymmetric Latent Communication Between Heterogeneous Large Language Models},
  author={Silva, Cristiano},
  year={2026},
  journal={arXiv preprint}
}

🤝 Contributing

Contributions are welcome. Please ensure that all tests pass with pytest tests/ before submitting a Pull Request.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages