Imp.Retrieve.Memory (Imp v0.5.0)

Copy Markdown View Source

Token-overlap in-memory retriever for deterministic local workflows.

Memory is useful for examples, tests, Livebooks, and portable save/load workflows. It scores documents by token overlap with the query and returns up to k of the documents that share at least one token with it, best first, each with an added :score field. A document that shares none is not a match and is not returned.

Summary

Functions

Builds an in-memory retriever from document maps or keyword-list documents.

Functions

new(docs, opts \\ [])

Builds an in-memory retriever from document maps or keyword-list documents.

iex> retriever = Imp.Retrieve.Memory.new([[text: "Elixir runs on the BEAM"]], k: 1)
iex> {:ok, docs} = Imp.Retrieve.retrieve(retriever, "BEAM")
iex> docs
[%{text: "Elixir runs on the BEAM", score: 1}]