docs/fast_merge.md
merge_from API in our fork of the FAISS codebase.ivf,rabitq or when using bivf-sq8/bivf-flat for binary quantization.The feature can be enabled by first passing a key-value pair in the config part while creating a new index. If the flag is false, then the behavior falls back to the more expensive naive merge.
kvConfig := map[string]interface{}{
"vector_index_fast_merge": true,
}
index, err := bleve.NewUsing("example.bleve", bleve.NewIndexMapping(), bleve.Config.DefaultIndexType, bleve.Config.DefaultMemKVStore, kvConfig)
if err != nil {
log.Fatal(err)
}
The user should now "train" the index on a random sample of the vector dataset they're planning to index and search.
The training is done using the new Train() API which takes the existing Batch construct we have
batch := index.NewBatch()
for _, doc := range trainingDocuments {
batch.Index(doc.ID, doc)
}
// train the index on the batch of data
// NOTE: the training can be done in an incremental manner as well, by using the same Train() API but repeatedly calling it on a particular batch of data.
if err := index.Train(batch); err != nil {
log.Fatal(err)
}
batch.Reset()
batch.SetInternal(util.BoltTrainCompleteKey, []byte("true"))
if err := index.Train(batch); err != nil {
log.Fatal(err)
}
// at this point the index is trained completely, and any training related constructs in the background will be cleaned up