Rename train() with queries to train_with_queries (#4955)

Summary:
Renames SVS addition of train function that includes query data to be named `train_with_queries` to address https://github.com/facebookresearch/faiss/issues/4863

Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4955

Reviewed By: limqiying

Differential Revision: D97318136

Pulled By: mnorris11

fbshipit-source-id: c225af471c99f697f6396840524e1ba80140e224
This commit is contained in:
ethanglaser
2026-03-19 18:18:42 -07:00
committed by meta-codesync[bot]
parent 8177a3bca6
commit 94f2b51fdb
5 changed files with 12 additions and 9 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ void Index::train(idx_t /*n*/, const float* /*x*/) {
// does nothing by default
}
void Index::train(
void Index::train_with_queries(
idx_t /*n*/,
const float* /*x*/,
idx_t /*n_train_q*/,
+2 -2
View File
@@ -131,7 +131,7 @@ struct Index {
*/
virtual void train(idx_t n, const float* x);
/** Perfrom training on a representative set of vectors and a representative
/** Perform training on a representative set of vectors and a representative
* set of queries
*
* @param n nb of training vectors
@@ -139,7 +139,7 @@ struct Index {
* @param n_train_q nb of training queries
* @param xq_train training queries, size n_train_q * d
*/
virtual void train(
virtual void train_with_queries(
idx_t n,
const float* x,
idx_t n_train_q,
+2 -2
View File
@@ -375,10 +375,10 @@ def handle_Index(the_class):
)
)
# Dispatch to train_c / train_ex
# Dispatch to train_c / train_with_queries / train_ex
if numeric_type == faiss.Float32:
if train_q is not None:
self.train_c(
self.train_with_queries(
n, swig_ptr(x), n_train_q, train_q
)
else:
+2 -2
View File
@@ -66,10 +66,10 @@ void IndexSVSVamanaLeanVec::add(idx_t n, const float* x) {
}
void IndexSVSVamanaLeanVec::train(idx_t n, const float* x) {
train(n, x, 0, nullptr);
train_with_queries(n, x, 0, nullptr);
}
void IndexSVSVamanaLeanVec::train(
void IndexSVSVamanaLeanVec::train_with_queries(
idx_t n,
const float* x,
idx_t n_train_q,
+5 -2
View File
@@ -49,8 +49,11 @@ struct IndexSVSVamanaLeanVec : IndexSVSVamana {
* sampled from different distributions (e.g., cross-modal). More details in
* the original publication, arXiv:2312.16335.
*/
void train(idx_t n, const float* x, idx_t n_train_q, const float* xq_train)
override;
void train_with_queries(
idx_t n,
const float* x,
idx_t n_train_q,
const float* xq_train) override;
void serialize_training_data(std::ostream& out) const;
void deserialize_training_data(std::istream& in);