Effective Context Capacity for OERSI
Persistent external memory, source-linked retrieval, and bounded evidence packs for tasks whose history exceeds a single model context window.
Measured synthetic result
The 200 benchmark questions contained each target record's unique identifier. The candidate retrieved the target fact in top 5 and included it in the bounded evidence pack in all 200 trials. A recency-only baseline retaining the final 24 records contained 6 sampled targets (3.0%). Two executions reproduced the same deterministic hit counts and integrity results. This evaluates retrieval mechanics, not semantic understanding or model answer quality.
| Measure | Observed result | Limit |
|---|---|---|
| Median lexical search | 23.43–23.93 ms | Two runs; one server, synthetic corpus |
| P95 lexical search | 25.35–34.53 ms | Not a production latency SLO |
| Automated unit tests | 8 / 8 passed | Prototype contract checks only |
| Integrity audit | 2,000 hashes checked; 0 mismatches | SHA-256 is not access control |
Architecture
- Persistent archive: stores original UTF-8 text with source labels, document hashes and ingestion metadata.
- Overlapping chunks: maintains retrieval-sized slices while preserving the original source text.
- Lexical retrieval: uses BM25-style scoring plus a small explicit-priority factor; no external model or embeddings.
- Context compiler: selects whole excerpts under an estimated prompt budget, links each excerpt to document/chunk hashes, and reports omitted candidates rather than silently clipping them.
- Safety and audit: labels retrieved material as untrusted evidence, abstains on empty searches, and verifies stored hashes.
Token-budget caveat: this prototype estimates tokens as ceil(UTF-8 bytes divided by four). That is a heuristic, not a model tokenizer. A real adapter must use the exact tokenizer and reserve space for system prompts, tools and generated output.
Reproduce it
Python 3.10+, standard library only. No network calls, model inference or private user data are used by the benchmark.
python3 -m py_compile context_memory.py benchmark.py test_context_memory.py
python3 -m unittest -v test_context_memory.py
python3 benchmark.py
Limitations and next gate
The fixture uses query-visible identifiers, so the observed 100% hit rate is not a real-world memory score. The benchmark does not evaluate paraphrase, LLM-generated answers, long-term reasoning, model-specific tokenizers, production load, multi-tenant isolation or adversarial source content. The candidate is not connected to the public OERSI inference route.
The next gate is a held-out long-memory QA test on appropriately licensed public datasets, comparing recency truncation, lexical retrieval, hybrid retrieval and verified hierarchical memory at the same model and token budget. Proposed production criteria: at least a 10-percentage-point answer-accuracy gain, no material increase in unsupported claims, source-grounded citations, enforced tenant isolation and zero unauthorized consequential actions.
Scientific grounding: Titans (NeurIPS 2025), InftyThink (ICLR 2026), MemGPT, FlashMemory-DeepSeek-V4, and Stanford HAI AI Index 2026.
ظرفیت مؤثر زمینه برای OERSI
سقف سخت توکنِ هر فراخوانی مدل حذف نشده است. این نمونه، تاریخچهٔ بزرگ را در SQLite نگه میدارد و برای هر سؤال فقط قطعات مرتبط، دارای منشأ و هش را داخل یک بستهٔ زمینهای محدود قرار میدهد. در آزمایش مصنوعی، از ۱۰۰۰ رکورد و ۲۰۰ پرسوجو استفاده شد؛ بازیابیِ مورد هدف و حضور آن در بستهٔ زمینه در هر ۲۰۰ آزمون موفق بود، درحالیکه سیاست سادهٔ نگهداشتن ۲۴ رکورد آخر فقط ۶ مورد را پوشش داد. چون شناسهٔ رکورد در پرسوجو وجود داشت، این نتیجه تنها سازوکار بازیابی را میسنجد و اثبات توانایی استدلال یا حافظهٔ عمومی نیست.
هشت آزمون نرمافزاری موفق شدند و ۲۰۰۰ هش سند/قطعه بدون مغایرت بررسی شد. برآورد توکن فعلی تقریبی است؛ اتصال به مدل زنده، سنجش با توکنایزر دقیق، آزمون مجموعهدادههای واقعی، کنترل حریم خصوصی چندکاربره و اعتبارسنجی پاسخ هنوز انجام نشدهاند.