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.
pip install lip-protocolLIP 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}")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 withhuggingface_hubto 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.
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}
}Contributions are welcome. Please ensure that all tests pass with pytest tests/ before submitting a Pull Request.