Skip to main content

A hybrid AI context gateway combining Headroom cloud compression and In-Place Local Test-Time Training (TTT).

Project description

Infinite Context

A hybrid AI context gateway combining Headroom cloud compression and In-Place Local Test-Time Training (TTT).

Installation

To install the base gateway:

pip install infinite_context

To install with Cloud Phase 1 dependencies (Headroom API):

pip install infinite_context[cloud]

To install with Local Phase 2 dependencies (PyTorch, Transformers, PEFT):

pip install infinite_context[local]

Usage

Phase 1: Cloud Compression

Uses the Headroom API to semantically compress a massive context and send it to cloud providers (OpenAI, Anthropic) while keeping costs low.

from infinite_context import ContextGateway

gateway = ContextGateway(
    engine="cloud",
    model_id="claude-3-5-sonnet-20240620",
    api_key="your_anthropic_api_key",
    compression_ratio=0.8
)

# You can pass in conversational history (rolling window)
history = [
    {"role": "user", "content": "What is the codebase about?"},
    {"role": "assistant", "content": "It is a Python application..."}
]

response = gateway.chat("How does the failover protocol work?", massive_context, history=history)
print(response)

Phase 2: Local Test-Time Training (TTT)

Bypasses the KV-Cache entirely by injecting a PEFT LoRA adapter and baking the context directly into the model's neural weights on your local GPU. Includes Early Stopping latency optimizations and Generation repetition penalties.

from infinite_context import ContextGateway

gateway = ContextGateway(
    engine="local",
    model_id="Qwen/Qwen2.5-0.5B-Instruct",
    load_in_4bit=True
)

response = gateway.chat("What is the failover protocol?", massive_context)
print(response)

Checkpoint Persistence

Save trained Fast Weights to disk and resume later without re-reading the document:

from infinite_context import ContextGateway

# Train and keep state
gateway = ContextGateway(engine="local", model_id="Qwen/Qwen2.5-0.5B-Instruct")
gateway.chat("Summarise the document.", massive_context, keep_state=True)
gateway.save_state("./my_checkpoint")

del gateway  # Free all GPU memory

# Resume later — zero re-training
gateway = ContextGateway(engine="local", model_id="Qwen/Qwen2.5-0.5B-Instruct")
gateway.load_state("./my_checkpoint")
response = gateway.chat("What was the protocol?", context="")
print(response)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

infinite_context_gateway-0.1.0.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

infinite_context_gateway-0.1.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file infinite_context_gateway-0.1.0.tar.gz.

File metadata

  • Download URL: infinite_context_gateway-0.1.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for infinite_context_gateway-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2658c28665c8bb9625f7e51b38a0a47adc3170c52ac53674cc6764977d057f38
MD5 8f05ddd34617864af05ced69519508fd
BLAKE2b-256 c3ff2df169c7583e8c288a8487961dbffe7bb691fcd0f68e484e5bd82911965b

See more details on using hashes here.

File details

Details for the file infinite_context_gateway-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for infinite_context_gateway-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 85a5a17d17321c76b9fc5e7659157538abe529c24bcb87252e395867ff7133d4
MD5 0d3798d69686407f8c52b1bac82268a5
BLAKE2b-256 6a09bc0bc354664f94d55cfc1a2c2e72f2bbbd218e4b73a23283a7e5152a6d51

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page