MESA Core · v0.9.3

Arama ve çizge

v0.9.3 kaynak: docs/retrieval-and-graph.md

Bu rehberin Türkçe ve İngilizce sürümleri aynı konuyu açıklar. Bu sayfayla ilgili kaynak bölümleri en altta yer alır.

Dört arama kanalı farklı ipuçları kullanır#

Vektör kanalı, uyumlu sayısal temsiller arasındaki benzerliği karşılaştırır. BM25, FTS5 üzerinden pasaj ve kanıt metnini sözcüklerle arar; erişim kapsamındaki atıfları da kullanır. Bilgi kaydı kanalı özne, ilişki, nesne ve dayanağı değerlendirir. Çizge kanalı ise kaynakları belli olan sınırlı bağlantı yollarını bulur. Bir kaydın sahipliği ve erişime uygunluğu, sıralamaya katkı vermesinden önce denetlenir.

RRF sıralamaları birleştirir; olasılık hesaplamaz#

Çalışma zamanı varsayılanları k=60, vektör ağırlığı 8.0; BM25, bilgi kaydı ve çizge ağırlıkları 1.0’dır. Eski vektör ağırlığı için MESA_RRF_VECTOR_WEIGHT=1 kullanın. Sıfır ağırlık, kanalın birleştirmeye katkısını kapatır. Hesaplayıcı, öğretici örnek olarak birim ağırlık kullanır. Sıralar 1’den başlar. Aynı aday bir kanalda birden çok kez görünse de yalnızca bir katkı verir: RRF(c)=Σ w/(k+rank). Kanal içindeki atıf artırımları o kanalın sırasını değiştirir; RRF puanına doğrudan eklenmez. Birleştirmeden sonra, sorguya bağlı ayrı bir hukuk katsayısı uygulanabilir. Arama sayfasındaki örnek hesaplayıcıyla farkı inceleyebilirsiniz.

Çizge ve bağlam sınırları#

Çizge araması en fazla 20 başlangıç düğümü, üç bağlantı adımı, istenen 500 sonuç, 64 düğümlük ilerleme kümesi ve düğüm başına 32 bağlantıyla sınırlandırılır. Varsayılan zaman aşımı 15 saniyedir. Bunlar kaynak tüketimini sınırlayan değerlerdir; hız garantisi değildir. Bağlam oluşturma varsayılan olarak tek arama ve 2048 token’lık biçimlendirilmiş kanıt bütçesi kullanır. İsteğe bağlı uyarlamalı mod, erişim kapsamını genişletmeden en fazla bir planlayıcı çağrısı ve iki ek arama yapar.

v0.9.3 ile çalışma#

Modeller kapalıyken BM25 saklanan kaynak metnini getirir. Kapalı veya eksik vektör ve çizge adımları degraded_sources içinde bildirilir. MESA_GRAPH_ENABLED=false, Kùzu’yu atlar; çizge veya embedding yeniden açıldığında başlangıçta eksikler tamamlanır.

İsteğe bağlı BGE yeniden sıralama#

Varsayılan MESA_RERANK_ENABLED=false değeridir. Açmak için [ml] eki gerekir. MESA_RERANK_MODEL=BAAI/bge-reranker-v2-m3 ve MESA_RERANK_DEPTH=50 (1–50 aralığı) aşamayı yapılandırır. Model ilk kullanımda yüklenir; ilk sorguya yükleme gecikmesi eklenir. Birleştirmeden sonra izinli adayların tam parça metinleri, ortak arama bağlantısı dışında bir worker thread’de puanlanır. Sonuçlara rerank_score eklenir; rrf_score ve final_score birleştirme değerleri olarak kalır. Eşit puanlarda birleştirme sırası korunur. DEV kanıtı ve donanım gecikmelerine bakın.

Eşzamanlı arama ve kapsam önbelleği#

MESA_SEARCH_SCOPE_CACHE=true, kapsama özel geçici FTS indekslerini ve satır/metin özelliklerini dört kapsamlık LRU önbelleğinde yeniden kullanır. SQLite commit değişiklikleri önbelleği geçersiz kılar; her istekte yetkilendirme yeniden denetlenir. Sorgu embedding’i arama kilidinden önce hesaplanır; yeniden sıralama bağlantı bırakıldıktan sonra çalışır. scrypt doğrulama, anahtar oluşturma ve döndürme işlemleri event loop dışında yürütülür; yetki sonuçları önbelleğe alınmaz. Çizge kapalıysa başlangıç düğümlerinin hazırlığı atlanır.

Kapsama bağlı hukuki kimlikler ve tam eşleşme önceliği#

Hukuk kuralları açıkken izinli başlıklar ve ilk parça kanun başlıkları, K. dâhil kapsam önbellekli kanun adları öğretir. Tam kanun/madde veya kararın kendi esas/karar numarası, birleştirme ve isteğe bağlı yeniden sıralamadan sonra belge sırasıyla en fazla üç konumu başa alabilir; diğer sonuçlar düzenini korur. Karar kimliği sıfırıncı parçanın ilk 300 karakterinde başlamalıdır. Sonraki alıntılar sayılmaz. Yalnızca AYM gibi mahkeme adları Anayasa’yı seçmez.

retrieval_provenance.legal_items, özgün parça konumlarıyla sürümlü öğeleri döndürür; SPO kayıtlarından ayrıdır ve birleştirme skoruna eklenmez. MESA_LEGAL_RULES_ENABLED=false, hukuki işlemeyi atlar, sonuç kopyalarındaki mevcut hukuki ekleri gizler ve genel aramayı açık tutar. Kalıcı anlık görüntüler/kimlikler saklanır.

Şemalar

UML · Etkinlik şemasıOkuma yolu: dört paralel kanal, tek birleşik sonuç
Oturumu çözyetkili veri kümeleri Uygunları süzkurum · zaman · tamamlanmış VektörLanceDB · anlamBM25SQLite FTS5 · sözcükBilgi kaydıSQLite · düzenli bilgiÇizge yoluKùzu · ≤ 3 adım Birleştir / sıralaRRF · legal · rerank Tam eşleşme baştahukuk açıksa · ≤ 3 Kanıtı paketle≤ 2048 token çatal: her kanal aynı uygun küme üzerinde çalışır · birleşim: aday başına kanal başına bir oy

Kapsam sıralamadan önce uygulanır. Birleştirmeyi hukuk katsayıları ve isteğe bağlı yeniden sıralama izler; tam kanun/madde veya kararın kendi ilk parça referansı en fazla üç sonucu başa alabilir. Diğer sonuçların düzeni korunur. Hukuk kuralları kapalıysa hukuki aşamalar atlanır; PageRank izleme verisi kalır.

Tüm şemalar ve gerekçeleri: Mimari →

Kaynak belgedeki ilgili bölümler

Bu bölüm, kaynak belgenin bu sayfayla ilgili kısımlarını değiştirmeden gösterir. Kaynak içindeki bir bölüme giden bağlantıyı açtığınızda metin otomatik olarak görünür.

Four lanes and scoring#

MemoryDAO.search_v4_memory is the canonical search primitive. Tenant, dataset,

agent, committed-state, jurisdiction and temporal eligibility are checked

before candidate rank contribution. Physical vector IDs and graph assertions

must agree with canonical ownership/evidence.

BM25 uses a temporary FTS5 index containing only authorized assertions, so

out-of-scope rows do not enter its corpus statistics. The scope cache reuses

that index only while SQLite's data version matches the pinned read snapshot.

The scope_audit describes eligibility; negative tests also check rank and

observable diagnostic isolation.

LaneCandidate signal
VectorCompatible ASSERTION_VECTOR semantic representation; query embedding
BM25FTS5 passage/evidence and lexical matching; scoped typed citation lookup
AssertionPredicate, subject, object/literal, evidence, token coverage and confidence
GraphBounded paths from legal, vector, lexical and entity-name seeds

For candidate c, RRF(c) = Σ w_lane / (k + rank_lane(c)), with ranks starting

at 1 and default k=60. Runtime defaults are vector weight 8.0 and the other

three weights 1.0, selected by the dev benchmark.

Duplicate backend hits cast one vote. Ties use candidate identity. The RRF

helper in mesa_storage/retrieval_scope.py uses unit weights when none are

passed; the server passes its configuration to the DAO.

Lexical exact citation +200 and same-statute +40 change the BM25/lexical lane

ordering. Assertion exact citation +150 and same-statute +40 change assertion

ordering. These are not RRF score increments. After fusion a query-dependent

legal factor is applied: exact statute/article 1.5, same statute 1.25, competing

statute 0.25, otherwise 1.0. A query without recognized legal citations has

factor 1.0. HTTP/SDK final_score is final fused relevance; higher is better.

rrf_score, legal_factor and lane raw_score are separate diagnostics;

MCP response adapters may expose a normalized score field.

Optional reranking orders fused

candidates by a cross-encoder score after the search connection is released.

It adds rerank_score; rrf_score and final_score retain their fusion values.

Equal reranker scores retain fused order. Reranking is off by default.

Typed ingestion identity uses a bounded alias ontology and immutable provenance.

It improves scoped pre-rank candidate discovery, including article chunks with

little title context. Reserved caller metadata cannot opt into trusted identity.

This contract checks structural linkage; it cannot prove a producer attached

the correct law, revision or real-world interpretation.

Graph bounds and failure behavior#

SQLite owns entities/assertions; Kùzu is a projection. Search uses at most 20

ranked seeds and 3 hops. The DAO asks for at most 500 graph hits; the provider

bounds frontiers to 64 and per-node fan-out to 32, with bounded native fetches.

The default graph request timeout is 15 seconds. These are traversal/resource

bounds, not exhaustive multi-hop completeness or latency guarantees.

Graph evidence preserves path assertion IDs, entities, predicates and direction,

and is reconciled against authorized canonical records. PageRank is telemetry

only. graph_mode=disabled turns off this lane for matched ablation; it does

not disable canonical assertion retrieval or graph projection writes.

Responses expose bounded scope_audit, graph_ablation and vector_lane

diagnostics. Their hashes identify contracts/config/scope, not a certification.

A configured operational backend failure yields explicit 503 rather than

silently claiming complete search. Projection-only graph adapters have no

neighbor implementation and report the capability false. A request timeout does

not permanently mark the graph provider unhealthy. Custom embedding providers

are configured but non-operational until a successful embedding call.

GET /v4/sessions/{session_id}/context defaults to token_budget=2048 and

retrieval_mode=single. ContextBuilder packs evidence once using cl100k_base.

The budget applies to formatted model-visible context, not the entire HTTP

response. If canonical BPE cannot load, the current OpenAI counting path uses

one token per UTF-8 byte as a conservative offline upper bound, even when

strict=True is passed. This may pack less evidence and is not exact cl100k

measurement. Exceptions raised by the counting interface propagate.

Complete graph proof must fit atomically; compact proof retains canonical

supporting evidence and may omit optional structural details.

Adaptive mode plans only if Q0 is empty or no top-three candidate has two-lane

support. It sends only normalized query text to one planner call, accepts at

most two reformulations, rejects invented legal citations and reuses the original

scope. Outer query fusion uses Q0=1.0, Q1/Q2=0.5. query_fusion_score and

query_origins remain separate from lane provenance. Planner/expansion failure

preserves Q0. This mode does not generate an answer or certify model quality.

Interpreting examples#

For a neutral single-hop “archive hours” query, inspect source evidence and

mutation state. For a multi-hop query, require every supporting assertion in

the path; a reachable entity alone is insufficient. An empty result is a valid

no-evidence outcome, not proof that a statement is false. Version/date-sensitive

queries should supply timezone-qualified valid_at or an interval and, when

needed, jurisdiction. These are request patterns, not measured benchmark results.

Core context packing is distinct from the independently sealed Profile B

context and scorer in E2E Certification.

Round 14 dev benchmark#

Measured on 2026-11-01 using the frozen Tier M corpus: 141 documents and 5,041

chunks ingested through this branch's authenticated document endpoint, with

article chunking enabled, extraction off, embeddings and graph on. Only the

101-question dev split was evaluated (85 answerable, 16 no-answer); the test

split was not accessed. The unmodified mesa_eval.py computes passage hit@5

and MRR on answerable questions; latency covers all 101 questions. Retrieval

limit and reranker depth are both 50, with max_length 1024 for the reranker.

Embeddings use BAAI/bge-m3 (1024 dimensions, normalized), and reranking uses

BAAI/bge-reranker-v2-m3. Each row below uses the same complete store, GPU

models and other lane weights of 1. Model revisions, package versions, source

hashes, unrounded MRR and the selection rule are in

the measurement data.

Vector weightRerankerPassage hit@5Passage MRRSearch p50 (s)Search p95 (s)
1Off0.51760.39531.26932.0035
1On0.74120.68161.95482.5736
2Off0.57650.45651.27081.9640
2On0.75290.70551.95692.6364
4Off0.65880.51521.28361.9469
4On0.77650.70691.92792.6100
8Off0.67060.56631.28491.9115
8On0.76470.69731.91612.5360

The default is selected from reranker-off MRR because reranking is off by

default. Weight 8 has unrounded MRR 0.566347, versus 0.395339 at weight 1: a

gain of 0.171008, exceeding the required 0.02. The runtime default

is therefore 8.0. Without that gain the default would stay 1; ties use the

smaller weight. Weight 4 has the best reranker-on MRR in this sweep. Overrides

remain available through MESA_RRF_VECTOR_WEIGHT. These measurements describe

this Turkish legal corpus and these models; other corpora/models need their own

measurements.

A separate device pass at vector weight 1 measured the optional reranker:

Inference device / rerankerPassage hit@5Passage MRRSearch p50 (s)Search p95 (s)
GPU / Off0.51760.39531.25311.9953
GPU / On0.74120.68161.96272.6029
CPU / On0.74120.681626.915833.8756

Hardware: Colab A100-SXM4 40GB and Intel Xeon 2.20GHz CPU, with eight CPU

threads. Python 3.13.16, Torch 2.11.0+cu130, sentence-transformers 5.7.0,

transformers 5.21.0, NumPy 2.5.4, LanceDB 0.41.0 and Kùzu 0.11.3. These are

compatible installed Colab packages, rather than the lockfile's exact ML pins;

the local gate uses the locked dev environment. Both models were explicitly

acquired before runtime startup. The device pass moves both models to CPU

without quantization for its CPU row.

Requests use the actual authenticated HTTP route through ASGI, without TCP.

Passes run sequentially, reusing the store and caches; one first-query warmup

is excluded from each pass (warmup values are in the data). These are descriptive

latencies, including embedding, scoped retrieval and optional reranking, rather

than a controlled hardware speedup claim. The benchmark store was ingested with

the measured source commit and then reused after the search-lock change, which

kept all 101 dev top-50 result dictionaries identical. The original frozen

corpus and question files were read only throughout.