Feature Extraction
sentence-transformers
Safetensors
Transformers
codexembed2b
code
retrieval
custom_code
Instructions to use Salesforce/SFR-Embedding-Code-2B_R with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use Salesforce/SFR-Embedding-Code-2B_R with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("Salesforce/SFR-Embedding-Code-2B_R", trust_remote_code=True) 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-Code-2B_R with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="Salesforce/SFR-Embedding-Code-2B_R", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Salesforce/SFR-Embedding-Code-2B_R", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -80,7 +80,7 @@ passage_embeddings = F.normalize(passage_embeddings, p=2, dim=1)
|
|
| 80 |
|
| 81 |
scores = (query_embeddings @ passage_embeddings.T) * 100
|
| 82 |
print(scores.tolist())
|
| 83 |
-
# [[
|
| 84 |
```
|
| 85 |
|
| 86 |
#### Sentence Transformers
|
|
@@ -108,7 +108,7 @@ passage_embeddings = model.encode(passages)
|
|
| 108 |
# Compute the similarities between the queries and passages
|
| 109 |
similarities = model.similarity(query_embeddings, passage_embeddings)
|
| 110 |
print(similarities)
|
| 111 |
-
# tensor([[0.
|
| 112 |
```
|
| 113 |
|
| 114 |
### Citation
|
|
|
|
| 80 |
|
| 81 |
scores = (query_embeddings @ passage_embeddings.T) * 100
|
| 82 |
print(scores.tolist())
|
| 83 |
+
# [[69.26929473876953, 58.41606903076172]]
|
| 84 |
```
|
| 85 |
|
| 86 |
#### Sentence Transformers
|
|
|
|
| 108 |
# Compute the similarities between the queries and passages
|
| 109 |
similarities = model.similarity(query_embeddings, passage_embeddings)
|
| 110 |
print(similarities)
|
| 111 |
+
# tensor([[0.6927, 0.5842]])
|
| 112 |
```
|
| 113 |
|
| 114 |
### Citation
|