Scoring¶
We can compute similarity between queries and documents without using a retriever using
the scores
method.
ColBERT¶
import torch
from neural_cherche import models
model = models.ColBERT(
model_name_or_path="raphaelsty/neural-cherche-colbert",
device=torch.device("cuda" if torch.cuda.is_available() else "cpu"),
)
model.scores(
queries=[
"What is the capital of France?",
"What is the largest city in Quebec?",
"Where is Bordeaux?",
],
documents=[
"Paris is the capital of France.",
"Montreal is the largest city in Quebec.",
"Bordeaux in Southwestern France.",
],
batch_size=32,
)
Splade¶
import torch
from neural_cherche import models
model = models.Splade(
model_name_or_path="raphaelsty/neural-cherche-sparse-embed",
device=torch.device("cuda" if torch.cuda.is_available() else "cpu"),
)
model.scores(
queries=[
"What is the capital of France?",
"What is the largest city in Quebec?",
"Where is Bordeaux?",
],
documents=[
"Paris is the capital of France.",
"Montreal is the largest city in Quebec.",
"Bordeaux in Southwestern France.",
],
batch_size=32,
)
SparseEmbed¶
import torch
from neural_cherche import models
model = models.SparseEmbed(
model_name_or_path="raphaelsty/neural-cherche-sparse-embed",
device=torch.device("cuda" if torch.cuda.is_available() else "cpu"),
)
model.scores(
queries=[
"What is the capital of France?",
"What is the largest city in Quebec?",
"Where is Bordeaux?",
],
documents=[
"Paris is the capital of France.",
"Montreal is the largest city in Quebec.",
"Bordeaux in Southwestern France.",
],
batch_size=32,
)