org.llm4s.vectorstore.testkit

Members list

Type members

Classlikes

The contract every org.llm4s.vectorstore.KeywordIndex must meet (#3000), as a ScalaTest suite: mix it into a spec, implement newStore and releaseStore, and every case below runs against your index:

The contract every org.llm4s.vectorstore.KeywordIndex must meet (#3000), as a ScalaTest suite: mix it into a spec, implement newStore and releaseStore, and every case below runs against your index:

class SQLiteKeywordIndexContractSpec extends AnyFunSuite with KeywordIndexContract {
 protected def newStore(): KeywordIndex               = SQLiteKeywordIndex.inMemory().toOption.get
 protected def releaseStore(index: KeywordIndex): Unit = index.close()
}

The cases:

  • '''Reads and writes.''' index, indexBatch, get, delete, deleteBatch, deleteByPrefix (a literal prefix), count and clear, on an empty index, a populated one and after clear; re-indexing an existing id, through index, indexBatch or update, leaving none of its old terms searchable and the document found once.
  • '''Queries.''' A term finding the documents that hold it, best first, cut at topK; quotes, operator words and symbols, hyphens and colons searched as text rather than failing as syntax; a blank query answered with nothing; a query of only stopwords answered, not failed; a natural-language question finding a document that lacks some of its words; non-Latin text, both space-separated and unsegmented.
  • '''Filters.''' MetadataFilterMatrix in search and searchWithHighlights; filters on keys holding ., a space or :.
  • '''Metadata''' and content read back exactly as written; highlights that show the matched term.

A backend with a known defect lists the case in knownFailures with its issue; one that cannot run a case lists it in unsupported (see StoreContractCases).

Attributes

Source
KeywordIndexContract.scala
Supertypes
trait Matchers
trait Explicitly
trait MatcherWords
trait ShouldVerb
trait Tolerance
trait AnyFunSuiteLike
trait Documenting
trait Alerting
trait Notifying
trait Informing
trait TestRegistration
trait TestSuite
trait Suite
trait Serializable
trait Assertions
trait TripleEquals
trait TripleEqualsSupport
class Object
trait Matchable
class Any
Show all
@Experimental

The filter matrix every VectorStore and KeywordIndex answers alike (#2996, #3000): five records and, for each filter, the ids it selects.

The filter matrix every VectorStore and KeywordIndex answers alike (#2996, #3000): five records and, for each filter, the ids it selects.

The answers are the trait's semantics, written out by hand rather than read from a reference backend: Equals and Contains are exact and case-sensitive, Contains is a literal substring test (% and _ are not wildcards), HasKey asks whether the key is present, Not keeps a record that lacks the key, and an empty In or Not(All) selects nothing.

Attributes

Source
MetadataFilterMatrix.scala
Supertypes
class Object
trait Matchable
class Any
Self type
@Experimental
trait StoreContractCases[S] extends AnyFunSuiteLike, Matchers

How VectorStoreContract and KeywordIndexContract register their cases against a store: a fresh store per case, released afterwards, and two ways for a backend's spec to say that a case does not hold for it yet.

How VectorStoreContract and KeywordIndexContract register their cases against a store: a fresh store per case, released afterwards, and two ways for a backend's spec to say that a case does not hold for it yet.

  • knownFailures: a case the backend fails today because of a known defect, named with the issue that tracks it. The case still runs, as ScalaTest's pendingUntilFixed: it is reported pending while it fails and fails once it passes, so the change that fixes the defect also removes the entry.
  • unsupported: a case the backend cannot run at all, such as a query a search engine does not offer, with the reason. It is cancelled.

A name in either map that matches no case fails the suite, so a renamed case cannot silently stop being excused.

Attributes

Source
StoreContractCases.scala
Supertypes
trait Matchers
trait Explicitly
trait MatcherWords
trait ShouldVerb
trait Tolerance
trait AnyFunSuiteLike
trait Documenting
trait Alerting
trait Notifying
trait Informing
trait TestRegistration
trait TestSuite
trait Suite
trait Serializable
trait Assertions
trait TripleEquals
trait TripleEqualsSupport
class Object
trait Matchable
class Any
Show all
Known subtypes
@Experimental

The contract every org.llm4s.vectorstore.VectorStore must meet (#3000), as a ScalaTest suite: mix it into a spec, implement newStore and releaseStore, and every case below runs against your store:

The contract every org.llm4s.vectorstore.VectorStore must meet (#3000), as a ScalaTest suite: mix it into a spec, implement newStore and releaseStore, and every case below runs against your store:

class SQLiteVectorStoreContractSpec extends AnyFunSuite with VectorStoreContract {
 protected def newStore(): VectorStore              = SQLiteVectorStore.inMemory().toOption.get
 protected def releaseStore(store: VectorStore): Unit = store.close()
}

The cases:

  • '''Reads and writes.''' upsert, upsertBatch, get, getBatch (missing ids skipped), delete, deleteBatch, deleteByPrefix (a literal prefix: % and _ are not wildcards), deleteByFilter and clear, on an empty store, on a populated one and after clear; an upsert of an existing id replacing its embedding, content and metadata.
  • '''Filters.''' MetadataFilterMatrix in list, count, search and deleteByFilter; filters on keys holding ., a space or :.
  • '''Metadata''' read back exactly as written: ", \, newline, tab, unicode, %, _, and keys with ., a space or :.
  • '''Search.''' Results best first, cut at topK, the filter applied before the cut; scores of (1 + cos) / 2 (identical 1, orthogonal 0.5, opposite 0); a zero vector stored or queried never failing a search or giving a score outside [0, 1]; a query of another dimension refused.
  • '''Listing.''' list in insertion order, and pages that together hold every record once; count with and without a filter.
  • '''Batches''' larger than a statement's parameter limit or a server's request limit (largeIdBatch, largeUpsertBatch).

A backend with a known defect lists the case in knownFailures with its issue; one that cannot run a case lists it in unsupported (see StoreContractCases).

Attributes

Source
VectorStoreContract.scala
Supertypes
trait Matchers
trait Explicitly
trait MatcherWords
trait ShouldVerb
trait Tolerance
trait AnyFunSuiteLike
trait Documenting
trait Alerting
trait Notifying
trait Informing
trait TestRegistration
trait TestSuite
trait Suite
trait Serializable
trait Assertions
trait TripleEquals
trait TripleEqualsSupport
class Object
trait Matchable
class Any
Show all