Tom Aarsen commited on
Commit
6967a46
·
1 Parent(s): 6ee74d0

Add modules.json to start using 1_Pooling/config.json

Browse files
Files changed (3) hide show
  1. README.md +10 -1
  2. modules.json +14 -0
  3. sentence_bert_config.json +4 -0
README.md CHANGED
@@ -1,5 +1,11 @@
1
  ---
2
  license: cc-by-nc-4.0
 
 
 
 
 
 
3
  ---
4
  <h1 align="center">Salesforce/SFR-Embedding-Code-400M_R</h1>
5
 
@@ -64,6 +70,7 @@ embeddings = outputs.last_hidden_state[:, 0]
64
  embeddings = F.normalize(embeddings, p=2, dim=1)
65
  scores = (embeddings[:1] @ embeddings[1:].T) * 100
66
  print("Similarity Scores:", scores.tolist())
 
67
  ```
68
 
69
  ### Sentence Transformers
@@ -80,7 +87,9 @@ sentences = [
80
 
81
  model = SentenceTransformer('Salesforce/SFR-Embedding-Code-400M_R', trust_remote_code=True)
82
  embeddings = model.encode(sentences)
83
- print(cos_sim(embeddings[0], embeddings[1:]))
 
 
84
  ```
85
 
86
  ### Citation
 
1
  ---
2
  license: cc-by-nc-4.0
3
+ pipeline_tag: feature-extraction
4
+ tags:
5
+ - transformers
6
+ - sentence-transformers
7
+ - code
8
+ - retrieval
9
  ---
10
  <h1 align="center">Salesforce/SFR-Embedding-Code-400M_R</h1>
11
 
 
70
  embeddings = F.normalize(embeddings, p=2, dim=1)
71
  scores = (embeddings[:1] @ embeddings[1:].T) * 100
72
  print("Similarity Scores:", scores.tolist())
73
+ # Similarity Scores: [[74.84745025634766, 65.39266967773438]]
74
  ```
75
 
76
  ### Sentence Transformers
 
87
 
88
  model = SentenceTransformer('Salesforce/SFR-Embedding-Code-400M_R', trust_remote_code=True)
89
  embeddings = model.encode(sentences)
90
+ similarities = cos_sim(embeddings[0], embeddings[1:])
91
+ print(similarities)
92
+ # tensor([[0.7485, 0.6539]])
93
  ```
94
 
95
  ### Citation
modules.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": "",
6
+ "type": "sentence_transformers.models.Transformer"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Pooling",
12
+ "type": "sentence_transformers.models.Pooling"
13
+ }
14
+ ]
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 8192,
3
+ "do_lower_case": false
4
+ }