Add library_name and pipeline_tag tags
Browse filesThis PR ensures a button will appear regarding "how to use" at the top right.
README.md
CHANGED
@@ -1,11 +1,14 @@
|
|
1 |
---
|
2 |
license: cc-by-nc-4.0
|
|
|
|
|
3 |
---
|
|
|
4 |
<h1 align="center">Salesforce/SFR-Embedding-Code-2B_R</h1>
|
5 |
|
6 |
**SFR-Embedding by Salesforce Research.**
|
7 |
|
8 |
-
|
9 |
|
10 |
Check out our [paper](https://arxiv.org/abs/2411.12644) for more details!
|
11 |
|
@@ -76,6 +79,24 @@ scores = (query_embeddings @ passage_embeddings.T) * 100
|
|
76 |
print(scores.tolist())
|
77 |
```
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
### Citation
|
80 |
```bibtex
|
81 |
@article{liu2024codexembed,
|
@@ -84,5 +105,4 @@ print(scores.tolist())
|
|
84 |
journal={arXiv preprint arXiv:2411.12644},
|
85 |
year={2024}
|
86 |
}
|
87 |
-
```
|
88 |
-
|
|
|
1 |
---
|
2 |
license: cc-by-nc-4.0
|
3 |
+
library_name: sentence-transformers
|
4 |
+
pipeline_tag: feature-extraction
|
5 |
---
|
6 |
+
|
7 |
<h1 align="center">Salesforce/SFR-Embedding-Code-2B_R</h1>
|
8 |
|
9 |
**SFR-Embedding by Salesforce Research.**
|
10 |
|
11 |
+
This model is based on the model described in the paper [CodeXEmbed: A Generalist Embedding Model Family for Multiligual and Multi-task Code Retrieval](https://huggingface.co/papers/2411.12644). It is a generalist embedding model family for multilingual and multi-task code and Text retrieval. It demonstrates superior performance compared to various open-source code embedding models across multiple code retrieval tasks.
|
12 |
|
13 |
Check out our [paper](https://arxiv.org/abs/2411.12644) for more details!
|
14 |
|
|
|
79 |
print(scores.tolist())
|
80 |
```
|
81 |
|
82 |
+
#### Sentence Transformers
|
83 |
+
|
84 |
+
# Requires sentence_transformers>=2.7.0
|
85 |
+
```python
|
86 |
+
from sentence_transformers import SentenceTransformer
|
87 |
+
from sentence_transformers.util import cos_sim
|
88 |
+
|
89 |
+
sentences = [
|
90 |
+
"how to implement quick sort in Python?",
|
91 |
+
"def quick_sort(arr):\n if len(arr) <= 1:\n return arr\n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n return quick_sort(left) + middle + quick_sort(right)",
|
92 |
+
"def bubble_sort(arr):\n n = len(arr)\n for i in range(n):\n for j in range(0, n-i-1):\n if arr[j] > arr[j+1]:\n arr[j], arr[j+1] = arr[j+1], arr[j]\n return arr",
|
93 |
+
]
|
94 |
+
|
95 |
+
model = SentenceTransformer('Salesforce/SFR-Embedding-Code-2B_R', trust_remote_code=True)
|
96 |
+
embeddings = model.encode(sentences)
|
97 |
+
print(cos_sim(embeddings[0], embeddings[1:]))
|
98 |
+
```
|
99 |
+
|
100 |
### Citation
|
101 |
```bibtex
|
102 |
@article{liu2024codexembed,
|
|
|
105 |
journal={arXiv preprint arXiv:2411.12644},
|
106 |
year={2024}
|
107 |
}
|
108 |
+
```
|
|