Artificial Intelligence, Machine Learning, Python, Data Science, Deep Learning.
torch.no_grad(): model_output = model(**encoded_input) # Compute mean-pooled embeddings embeddings = mean_pooling(model_output, encoded_input['attention_mask']) # Convert embeddings to NumPy for FAISS embeddings_np = embeddings.numpy() # Create a FAISS index (FlatL2 is simple but efficient for