Download benchmark_encode.py from SyvaAI/SyvaAI-Bv1: direct link, hf CLI and curl.
- Browser
- Download file 354 Bytes
-
https://huggingface.co/SyvaAI/SyvaAI-Bv1/resolve/main/benchmark_encode.py
- Command line
-
hf download hf://SyvaAI/SyvaAI-Bv1/benchmark_encode.py
-
curl -L -o benchmark_encode.py https://huggingface.co/SyvaAI/SyvaAI-Bv1/resolve/main/benchmark_encode.py
354 Bytes
| from sentence_transformers import SentenceTransformer | |
| import time, numpy as np | |
| model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2") | |
| texts = ["This is a test."] * 1000 # batch you plan to use | |
| t0 = time.time() | |
| emb = model.encode(texts, convert_to_numpy=True) | |
| t1 = time.time() | |
| print("seconds for 1000:", t1-t0) | |
| print("shape:", emb.shape) | |