# LLMs can natively read and write entire vector databases

> Source: <https://gist.github.com/jxmorris12/e46b73b75415f98a3e25c435a5d6f8d8>
> Published: 2026-12-06 21:50:37+00:00

**Recommendation:** Combine reciprocal-rank consensus across lexical views with stable matching on sparse reply scores when queries are corpus passages; the source measured 76.38 versus 61.15 for initial rules on ArguAna.
More in the playbook "Retrieval and RAG": <https://wpnews.pro/playbooks/rag-retrieval>

We built dataset-specific retrieval systems for ArguAna, SciFact, and NFCorpus. Astra authored the scoring code. Encoding and ranking use sparse features, corpus statistics, graph operations, or classical matrix factorization. They run without neural inference.

All numbers are nDCG@10 on a 0–100 scale.

| Method | ArguAna | SciFact | NFCorpus | 
|---|---|---|---|
| [BM25](https://arxiv.org/abs/0911.5046) | 31.50 | 66.50 | 32.50 | 
| [DPR](https://arxiv.org/abs/2004.04906) | 17.50 | 31.80 | 18.90 | 
| [CDE](https://arxiv.org/abs/2410.02525) | 54.90 | 72.80 | 36.50 | 
| handwritten by GPT-6.2 Astra | **76.38** | **75.61** | **41.18** | 

The baseline scores come from [BEIR](https://arxiv.org/abs/2104.08663) and the unsupervised CDE results. The final row combines the best verified dataset-specific runs. Each first-to-final sequence is discussed below. The systems used different inputs, including public corpus text and, for some recipes, external lexical or bibliographic resources.

**Vector.** One sparse row per document, with 8,565 coordinates for distinct public corpus passages. A coordinate scores how well the document replies to that passage.

```
V = build_sparse_reply_scores(passages)
    # Compare argument and reply spans using word overlap,
    # ConceptNet, and debate-specific word weights.
    # Downweight replies that fit another argument better.

for (argument, reply) in V.nonzero_edges:
    agreement = median_across_views(
        reciprocal_rank_in_both_directions(argument, reply, offset=24)
        for view in [word_tfidf, character_tfidf, word_svd_128]
    )
    V[reply, argument] *= exp(1.8 * agreement)

pairs = top_32_acceptable_partners_per_endpoint(V)
acceptance = average(proposer_optimal_matching(pairs),
                     receiver_optimal_matching(pairs))
V *= exp(0.4 * acceptance)
save_csr(V, document_ids, hashes_of_public_passages)

rank(query) = sort_descending(V[:, hash_lookup(query.text)])
              excluding query.document_id
```

Each view combines forward and reverse reciprocal rank by geometric mean, with zero if either direction is missing. The matching operations adjust existing sparse edges. The 8,674 × 8,565 matrix supports exact lookup because ArguAna queries are public corpus passages. This export provides no column for a new passage.

**Results.** Initial rules **61.15** → reply matching **75.57** → rank consensus **76.31** → stable matching **76.38**. The final run scored **76.30** excluding the five inspected queries. Entity features and sequence alignment failed to improve their matched ArguAna controls.

**Vectors.** The lexical system uses sparse term features. A separate terminology layer assigns 112 SVD components to each supported stem and drops the leading component for cosine comparisons. The best score includes passage and sentence reranking.

```
contexts = count_contexts(MEDLINE, fields=[sentence, title, MeSH])
term_vectors = truncated_svd(smoothed_positive_pmi(contexts), rank=112)
term_vectors = normalize(term_vectors[:, 1:])
paper_features = encode(title, abstract, evidence_sentences, term_vectors)
citation_vectors = tfidf(external_citation_passages)

scores = base_claim_scores(claim, paper_features)
q = encode_in_citation_vocabulary(claim)
for paper in corpus:
    best = max_cosine(q, passages_citing(paper), exclude_near_copy_sources)
    margin = max(0, best - cosine(q, paper_in_citation_space) - 0.10)
    scores[paper] += max_base_score * margin

top = top_10(scores)
terms = normalize_greek_and_hyphenated_aliases(claim)
weights = corpus_rarity(terms) * shortlist_rarity(terms, top)
for paper in top:
    scores[paper] += 0.10 * max_current_score *
                     best_weighted_sentence_overlap(paper, terms, weights) /
                     sum_weights_of_terms_seen_in(top)
```

The citation layer rewards an independently written passage citing the paper when it matches the query better than the paper text does. The sentence layer can reward one specific result in a broadly related abstract. The pseudocode groups the earlier retrieval stages behind `base_claim_scores` and shows the final two scoring adjustments explicitly.

**Results.** First run **69.44**, round two **72.34**, fixed-membership predecessor **74.96**, citation-passage margin **75.45**, observed-term normalization **75.52**, and spelling aliases **75.61**. The last run scored **76.14** excluding 50 inspected queries. A later citation residual fell to **75.22** despite positive public results.

**Vectors.** The first stage uses sparse lexical and biomedical concept features. The final stage uses sparse title-and-abstract TF-IDF vectors for cosine scoring and the underlying term-count vectors for query likelihood and coverage.

```
base_features = encode_words_and_biomedical_concepts(corpus)
counts = sparse_word_counts(title + abstract, remove_stopwords=True)
vectors = l2_normalize(counts * corpus_idf(counts))

head = composed_top_10(query, base_features)
q_counts = word_counts(query, vocabulary=counts.columns)
q_vector = l2_normalize(q_counts * corpus_idf(counts))
cos = range_scale(vectors[head] @ q_vector)
likelihood = range_scale(dirichlet_query_likelihood(q_counts, counts[head], mu=500))

prior = 61 / [61, ..., 70]
first_three_score = prior[:3] + 0.05 * cos[:3]
last_seven = sort_descending(head[3:], prior[3:] + 0.05 * likelihood[3:])

present = counts[head, query_terms] > 0
weights = q_counts[query_terms] / (1 + count_present(present[3:]))
coverage = range_scale(present[:3] @ weights)
first_three = sort_descending(head[:3], first_three_score + 0.025 * coverage)
return first_three + last_seven
```

The final adjustment keeps membership fixed. Query-likelihood scoring orders ranks four through ten. Within the first three, a query term contributes less coverage credit when it already appears in several of the remaining seven papers.

**Results.** First run **34.51**, round two **39.01**, mixed ranking **41.09**, and inverse-tail coverage **41.18**. The last run scored **40.43** across 290 previously uninspected queries. A rank-ten replacement that helped both public consumer panels fell to **40.74** on sealed scoring. Perfect ordering of the existing top ten would reach **47.71** under benchmark judgments, so candidate quality alone does not explain the remaining errors.

The pseudocode omits tokenizer details, stable tie handling, and intermediate recipe variants. Scores are full-test results from iterative benchmark development with repeated aggregate feedback. Some queries were inspected under the protocol. The exclusion scores remove those query texts from the metric, while still reflecting the history of aggregate feedback. NFCorpus public evidence grades and observed citations measure different outcomes, and some citation fixtures had too few observed links to evaluate the papers a candidate changed.
