Skip to main content

createMemoryKnowledgeBackend

@forge/monorepo


@forge/monorepo / backend/src / createMemoryKnowledgeBackend

Function: createMemoryKnowledgeBackend()

createMemoryKnowledgeBackend(): object

Defined in: backend/src/adapters/memory/knowledge.ts:67

Shared state, so the two ports can be backed by one table the way pgvector backs them.

Returns

index

index: VectorIndex

keyword

keyword: KeywordIndex

BM25 over the same rows.

A real ranking function rather than a substring match, because the whole point of #136 is that keyword and semantic retrieval have different strengths — and a substring matcher has none. BM25 gives rarer terms more weight and saturates on repetition, which is what makes ERR-4021 beat a document that says "error" forty times.

k1 = 1.2, b = 0.75 are the standard parameters and the same operating point Postgres's ts_rank_cd approximates, so the reference adapter and the production one rank alike on the cases that matter.

store

store: KnowledgeStore