Instructions to use thenlper/gte-large with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use thenlper/gte-large with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("thenlper/gte-large") sentences = [ "That is a happy person", "That is a happy dog", "That is a very happy person", "Today is a sunny day" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Inference
- Notebooks
- Google Colab
- Kaggle
Running the model on GPU
Did anyone try running the model on GPU?
device = "cuda:0" if torch.cuda.is_available() else "cpu"
batch_dict = self.tokenizer(input_texts, max_length=512,
padding=True, truncation=True, return_tensors='pt').to(device)
outputs = self.model(**batch_dict).to(device)
I get the below error,
File..
outputs = self.model(**batch_dict).to(device)
...
File "../python3.9/site-packages/torch/nn/functional.py", line 2233, in embedding
return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument index in method wrapper_CUDA__index_select)