Views
No views yet
| Model Name | CodeSearchNet Score |
|---|---|
| Shuu12121/CodeModernBERT-Owl | 76.89 |
| Salesforce/SFR-Embedding-Code-2B_R | 73.5 |
| CodeSage-large-v2 | 94.26 |
| Salesforce/SFR-Embedding-Code-400M_R | 72.53 |
| CodeSage-large | 90.58 |
| Voyage-Code-002 | 81.79 |
| E5-Mistral | 54.25 |
| E5-Base-v2 | 67.99 |
| OpenAI-Ada-002 | 74.21 |
| BGE-Base-en-v1.5 | 69.6 |
| BGE-M3 | 43.23 |
| UniXcoder | 60.2 |
| GTE-Base-en-v1.5 | 43.35 |
| Contriever | 34.72 |
pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer
2
3# Load the model / モデルをダウンロードしてロード
4model = SentenceTransformer("Shuu12121/CodeSearch-ModernBERT-Owl")
5
6# Example sentences for inference / 推論用の文リスト
7sentences = [
8 'Encrypts the zip file',
9 'def freeze_encrypt(dest_dir, zip_filename, config, opt):\n \n pgp_keys = grok_keys(config)\n icefile_prefix = "aomi-%s" % \\\n os.path.basename(os.path.dirname(opt.secretfile))\n if opt.icefile_prefix:\n icefile_prefix = opt.icefile_prefix\n\n timestamp = time.strftime("%H%M%S-%m-%d-%Y",\n datetime.datetime.now().timetuple())\n ice_file = "%s/%s-%s.ice" % (dest_dir, icefile_prefix, timestamp)\n if not encrypt(zip_filename, ice_file, pgp_keys):\n raise aomi.exceptions.GPG("Unable to encrypt zipfile")\n\n return ice_file',
10 'def transform(self, sents):\n \n\n def convert(tokens):\n return torch.tensor([self.vocab.stoi[t] for t in tokens], dtype=torch.long)\n\n if self.vocab is None:\n raise Exception(\n "Must run .fit() for .fit_transform() before " "calling .transform()."\n )\n\n seqs = sorted([convert(s) for s in sents], key=lambda x: -len(x))\n X = torch.LongTensor(pad_sequence(seqs, batch_first=True))\n return X',
11]
12
13# Generate embeddings / 埋め込みベクトルの生成
14embeddings = model.encode(sentences)
15print(embeddings.shape) # Output: [3, 768]
16
17# Calculate similarity scores / 類似度スコアの計算
18similarities = model.similarity(embeddings, embeddings)
19print(similarities.shape) # Output: [3, 3]1@inproceedings{reimers-2019-sentence-bert,
2 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
3 author = "Reimers, Nils and Gurevych, Iryna",
4 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
5 month = "11",
6 year = "2019",
7 publisher = "Association for Computational Linguistics",
8 url = "https://arxiv.org/abs/1908.10084",
9}1@misc{henderson2017efficient,
2 title={Efficient Natural Language Response Suggestion for Smart Reply},
3 author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
4 year={2017},
5 eprint={1705.00652},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL}
8}