File size: 1,100 Bytes
6f8d97e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Minimal Ryno usage: load with transformers, enable DBAttention, talk to it."""
import torch
from transformers import AutoConfig, AutoModel, AutoTokenizer

REPO = "FuryLogic-Labs/Ryno-0.8B"      # or "." for a local clone

cfg = AutoConfig.from_pretrained(REPO, trust_remote_code=True)
model = AutoModel.from_pretrained(REPO, trust_remote_code=True, config=cfg,
                                 torch_dtype=torch.float16)
tok = AutoTokenizer.from_pretrained(REPO, trust_remote_code=True)

# 1. plain text, native in-VRAM attention
print(model.chat("What is the capital of France?", max_new_tokens=48))

# 2. DBAttention: K/V rows go to a database, nothing is cached in the model
model.enable_db_attention(path=".ryno-db/serve.db", max_tokens=2_000_000, window=None)
print(model.chat("Who made you?", max_new_tokens=48))
print(model.db_stats())

# 3. context far past VRAM: prefill into the store in chunks
model.ingest(open("long_document.txt").read() if __import__("os").path.exists(
    "long_document.txt") else "The passage discusses database-backed attention. " * 500)
print(model.db_stats())