jupyterjazz's picture
feat: example
ffb90c2
|
raw
history blame
985 Bytes

Jina Embeddings v5 600M

Usage

Using AutoModel (Transformers)

import torch
from transformers import AutoModel

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
dtype = torch.bfloat16
max_length = 8192

model = AutoModel.from_pretrained(
    "jinaai/jina-embeddings-v5-text-small",
    trust_remote_code=True
)
model = model.to(device=device, dtype=dtype)

embeddings = model.encode(
    ["what is the origin of COVID-19"],
    task="retrieval",
    prompt_name="query",
    max_length=max_length,
)

Using SentenceTransformer

import torch
from sentence_transformers import SentenceTransformer

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

model = SentenceTransformer(
    "jinaai/jina-embeddings-v5-text-small",
    trust_remote_code=True,
    device=device,
)

query_embeddings = model.encode(
    sentences=["what is the origin of COVID-19"],
    task="retrieval",
    prompt_name="query",
)