Feature Extraction
sentence-transformers
Safetensors
Transformers
English
mistral
mteb
Eval Results (legacy)
text-embeddings-inference
Instructions to use Salesforce/SFR-Embedding-2_R with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use Salesforce/SFR-Embedding-2_R with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("Salesforce/SFR-Embedding-2_R") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Transformers
How to use Salesforce/SFR-Embedding-2_R with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="Salesforce/SFR-Embedding-2_R")# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("Salesforce/SFR-Embedding-2_R") model = AutoModel.from_pretrained("Salesforce/SFR-Embedding-2_R") - Notebooks
- Google Colab
- Kaggle
How to use quantized version?
#2
by jawad1347 - opened
Kindly write code to use it in colab loading it with 4bit quants. Thanks
Sure, loading it with 4bit quant can be used by BitsAndBytes
from transformers import BitsAndBytesConfig
# Ref: https://huggingface.co/blog/4bit-transformers-bitsandbytes
quantization_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True,
bnb_4bit_compute_dtype=torch.bfloat16,
)
model = AutoModel.from_pretrained(
'Salesforce/SFR-Embedding-2_R',
device_map='auto',
trust_remote_code=True,
quantization_config=quantization_config,
**model_kwargs,
)
can be quantized to gptq o awq? or those format will not be compatible with this arch ?