Code Embedding Models
Collection
1 item β’ Updated
How to use divakantpandey/code-embed with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("divakantpandey/code-embed")
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]CodeEmbed is a lightweight, high-performance code embedding model (β€130M parameters) developed by Divakant Pandey. Specialized for semantic code search, code retrieval, and repository navigation with 8,192 token context and Matryoshka representation learning.
| Benchmark | Metric | Value | Gate Status |
|---|---|---|---|
| CodeSearchNet (Python) | MRR@10 | 0.7514 | PASS (β₯ 0.65) |
| CoSQA (Code Search QA) | MRR@10 | 0.7509 | PASS (β₯ 0.50) |
| Hypersphere Uniformity | Uniformity | -1.9758 | PASS (β€ -1.0) |
| Single-Snippet Latency | CPU Latency | 20.8 ms | PASS (< 100 ms) |
from sentence_transformers import SentenceTransformer
# Automatically downloads from Hugging Face Hub
model = SentenceTransformer("divakantpandey/code-embed")
queries = ["binary search in sorted list", "read json file"]
snippets = [
"def binary_search(arr, target): ...",
"import json\ndef load_json(path): return json.load(open(path))"
]
query_embeddings = model.encode(queries, normalize_embeddings=True)
code_embeddings = model.encode(snippets, normalize_embeddings=True)
# Compute cosine similarity
similarities = query_embeddings @ code_embeddings.T
print(similarities)
This model and its weights are released under the Creative Commons Attribution-NonCommercial 4.0 International (CC-BY-NC 4.0) license.
divakant01@gmail.com