Feature Extraction
sentence-transformers
ONNX
Safetensors
GGUF
English
code
roberta
python
javascript
go
java
ruby
php
code-search
code-embeddings
matryoshka
unixcoder
mteb
Eval Results (legacy)
text-embeddings-inference
Run this model with HF Jobs
Run divakantpandey/code-embed-v2 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/divakantpandey/code-embed-v2. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/divakantpandey/code-embed-v2 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use divakantpandey/code-embed-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use divakantpandey/code-embed-v2 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("divakantpandey/code-embed-v2") 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] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use divakantpandey/code-embed-v2 with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible embeddings server: llama serve -hf divakantpandey/code-embed-v2:Q8_0 --embeddings
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible embeddings server: llama serve -hf divakantpandey/code-embed-v2:Q8_0 --embeddings
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible embeddings server: ./build/bin/llama serve -hf divakantpandey/code-embed-v2:Q8_0 --embeddings
- Llama new
- LM Studio
- Jan
- Ollama
How to use divakantpandey/code-embed-v2 with Ollama:
ollama run hf.co/divakantpandey/code-embed-v2:Q8_0
- Unsloth Desktop
- Docker Model Runner
How to use divakantpandey/code-embed-v2 with Docker Model Runner:
docker model run hf.co/divakantpandey/code-embed-v2:Q8_0
- Lemonade
How to use divakantpandey/code-embed-v2 with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull divakantpandey/code-embed-v2:Q8_0
Run and chat with the model
lemonade run user.code-embed-v2-Q8_0
List all available models
lemonade list
- Atomic Chat
clean: remove duplicate folders (sentence_transformers, backbone), remove legacy weights, sync max_seq_length to 1024
Browse filesFiles changed (22)
- README.md+2-2
- backbone/config.jsonDeleted-31
- backbone/model.safetensorsDeleted-3
- backbone/tokenizer.jsonDeleted
- backbone/tokenizer_config.jsonDeleted-24
- projection_head.ptDeleted-3
- pycode_embed_config.jsonDeleted-9
- sentence_bert_config.json+1-1
- sentence_transformers/1_Pooling/config.jsonDeleted-5
- sentence_transformers/2_Dense/config.jsonDeleted-8
- sentence_transformers/2_Dense/model.safetensorsDeleted-3
- sentence_transformers/3_Dense/config.jsonDeleted-8
- sentence_transformers/3_Dense/model.safetensorsDeleted-3
- sentence_transformers/4_Normalize/config.jsonDeleted-4
- sentence_transformers/README.mdDeleted-154
- sentence_transformers/config.jsonDeleted-31
- sentence_transformers/config_sentence_transformers.jsonDeleted-14
- sentence_transformers/model.safetensorsDeleted-3
- sentence_transformers/modules.jsonDeleted-32
- sentence_transformers/sentence_bert_config.jsonDeleted-11
- sentence_transformers/tokenizer.jsonDeleted
- sentence_transformers/tokenizer_config.jsonDeleted-17
234 unmodified lines235236237238239240241242243244245246247248234 unmodified lines# 💻 code-embed-v2**CodeEmbed v2** is a lightweight, state-of-the-art multilingual code embedding model (≤131M parameters) developed by **[Divakant Pandey](https://github.com/divakantpandey)**. Specialized for semantic code search, code-to-code retrieval, text-to-SQL mapping, and repository navigation across **6 major programming languages** with an extended **8,192 token context window** and native **Matryoshka Representation Learning (MRL)**.---## 🚀 Highlights & Functional Capabilities- **Multilingual Support**: High-accuracy semantic search across **Python, JavaScript, Go, Java, Ruby, and PHP**.- **Extended Context**: Full **8,192 token context window** allowing whole-file, multi-function, and long class embeddings without aggressive truncation.- **Matryoshka Representation Learning (MRL)**: Embeddings can be dynamically truncated from **1536** down to **768, 384, 256, 128, or 64 dimensions** with negligible loss in accuracy, enabling significant vector database memory and latency savings.- **Compact & Efficient**: ~131M parameters (**~484 MB** safetensors footprint) optimized for low-latency CPU inference and fast GPU batch indexing.- **Universal Compatibility**: Works out of the box with `sentence-transformers`, `transformers`, and PyTorch.234 unmodified lines235236237238239240241242243244245246247248234 unmodified lines# 💻 code-embed-v2**CodeEmbed v2** is a lightweight, state-of-the-art multilingual code embedding model (≤131M parameters) developed by **[Divakant Pandey](https://github.com/divakantpandey)**. Specialized for semantic code search, code-to-code retrieval, text-to-SQL mapping, and repository navigation across **6 major programming languages** with an extended **1,024 token context window** and native **Matryoshka Representation Learning (MRL)**.---## 🚀 Highlights & Functional Capabilities- **Multilingual Support**: High-accuracy semantic search across **Python, JavaScript, Go, Java, Ruby, and PHP**.- **Extended Context**: Full **1,024 token context window** allowing whole-file, multi-function, and long class embeddings without aggressive truncation.- **Matryoshka Representation Learning (MRL)**: Embeddings can be dynamically truncated from **1536** down to **768, 384, 256, 128, or 64 dimensions** with negligible loss in accuracy, enabling significant vector database memory and latency savings.- **Compact & Efficient**: ~131M parameters (**~484 MB** safetensors footprint) optimized for low-latency CPU inference and fast GPU batch indexing.- **Universal Compatibility**: Works out of the box with `sentence-transformers`, `transformers`, and PyTorch.
12345678910111213141516171819202122232425262728293031{ "add_cross_attention": false, "architectures": [ "RobertaModel" ], "attention_probs_dropout_prob": 0.1, "bos_token_id": 0, "classifier_dropout": null, "dtype": "float32", "eos_token_id": 2, "gradient_checkpointing": false, "hidden_act": "gelu", "hidden_dropout_prob": 0.1, "hidden_size": 768, "initializer_range": 0.02, "intermediate_size": 3072, "is_decoder": false, "layer_norm_eps": 1e-05, "max_position_embeddings": 1026, "model_type": "roberta", "num_attention_heads": 12, "num_hidden_layers": 12, "output_past": true, "pad_token_id": 1, "position_embedding_type": "absolute", "tie_word_embeddings": true, "transformers_version": "5.20.1", "type_vocab_size": 10, "use_cache": true, "vocab_size": 51416}123version https://git-lfs.github.com/spec/v1oid sha256:cee5b2e4cde154164d9dbabab7f8dedaecc81f5cc9e605b0ca1774ef38577837size 503741296123456789101112131415161718192021222324{ "add_prefix_space": false, "backend": "tokenizers", "bos_token": "<s>", "cls_token": "<s>", "eos_token": "</s>", "errors": "replace", "is_local": true, "local_files_only": false, "mask_token": "<mask>", "max_length": 1024, "model_max_length": 8192, "pad_to_multiple_of": null, "pad_token": "<pad>", "pad_token_type_id": 0, "padding_side": "right", "sep_token": "</s>", "stride": 0, "tokenizer_class": "RobertaTokenizer", "trim_offsets": true, "truncation_side": "right", "truncation_strategy": "longest_first", "unk_token": "<unk>"}123version https://git-lfs.github.com/spec/v1oid sha256:cab1e7ca82bb911a0b6362f2d543ae62d7053c74db66be77563faf8334b9d917size 14170320123456789{ "base_model_name_or_path": "checkpoints_v2/stage2/last_model/backbone", "backbone_hidden_size": 768, "embedding_dim": 1536, "projection_hidden_dim": 1536, "pooling": "mean", "max_seq_length": 1024, "dropout": 0.1}6 unmodified lines78910116 unmodified lines}},"module_output_name": "token_embeddings","max_seq_length": 8192}6 unmodified lines78910116 unmodified lines}},"module_output_name": "token_embeddings","max_seq_length": 1024}
12345{ "embedding_dimension": 768, "pooling_mode": "mean", "include_prompt": true}12345678{ "in_features": 768, "out_features": 1536, "bias": true, "activation_function": "torch.nn.modules.activation.GELU", "module_input_name": "sentence_embedding", "module_output_name": "sentence_embedding"}123version https://git-lfs.github.com/spec/v1oid sha256:2c1ffd47ef8b067f3ce5f53bf78238a4647f014177f0d6d5422971b1b04b3c19size 472489612345678{ "in_features": 1536, "out_features": 1536, "bias": true, "activation_function": "torch.nn.modules.linear.Identity", "module_input_name": "sentence_embedding", "module_output_name": "sentence_embedding"}123version https://git-lfs.github.com/spec/v1oid sha256:457d921f992dd8ecf6e63a1a00dcfc5f7bdca4fa54c3bf989fbf40a95bb526ddsize 94434881234{ "module_input_name": "sentence_embedding", "module_output_name": "sentence_embedding"}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154---tags:- sentence-transformers- sentence-similarity- feature-extraction- densebase_model: microsoft/unixcoder-basepipeline_tag: sentence-similaritylibrary_name: sentence-transformers---
# SentenceTransformer based on microsoft/unixcoder-base
This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [microsoft/unixcoder-base](https://huggingface.co/microsoft/unixcoder-base). It maps inputs to a 1536-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, classification, clustering, and more.
## Model Details
### Model Description- **Model Type:** Sentence Transformer- **Base model:** [microsoft/unixcoder-base](https://huggingface.co/microsoft/unixcoder-base) <!-- at revision 5604afdc964f6c53782a6813140ade5216b99006 -->- **Maximum Sequence Length:** 1024 tokens- **Output Dimensionality:** 1536 dimensions- **Similarity Function:** Cosine Similarity- **Supported Modality:** Text<!-- - **Training Dataset:** Unknown --><!-- - **Language:** Unknown --><!-- - **License:** Unknown -->
### Model Sources
- **Documentation:** [Sentence Transformers Documentation](https://sbert.net)- **Repository:** [Sentence Transformers on GitHub](https://github.com/huggingface/sentence-transformers)- **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
### Full Model Architecture
```SentenceTransformer( (0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'RobertaModel'}) (1): Pooling({'embedding_dimension': 768, 'pooling_mode': 'mean', 'include_prompt': True}) (2): Dense({'in_features': 768, 'out_features': 1536, 'bias': True, 'activation_function': 'torch.nn.modules.activation.GELU', 'module_input_name': 'sentence_embedding', 'module_output_name': 'sentence_embedding'}) (3): Dense({'in_features': 1536, 'out_features': 1536, 'bias': True, 'activation_function': 'torch.nn.modules.linear.Identity', 'module_input_name': 'sentence_embedding', 'module_output_name': 'sentence_embedding'}) (4): Normalize({'module_input_name': 'sentence_embedding', 'module_output_name': 'sentence_embedding'}))```
## Usage
### Direct Usage (Sentence Transformers)
First install the Sentence Transformers library:
```bashpip install -U sentence-transformers```Then you can load this model and run inference.```pythonfrom sentence_transformers import SentenceTransformer
# Download from the 🤗 Hubmodel = SentenceTransformer("sentence_transformers_model_id")# Run inferencesentences = [ 'The weather is lovely today.', "It's so sunny outside!", 'He drove to the stadium.',]embeddings = model.encode(sentences)print(embeddings.shape)# [3, 1536]
# Get the similarity scores for the embeddingssimilarities = model.similarity(embeddings, embeddings)print(similarities)# tensor([[1.0000, 0.4229, 0.2403],# [0.4229, 1.0000, 0.3388],# [0.2403, 0.3388, 1.0000]])```<!--### Direct Usage (Transformers)
<details><summary>Click to see the direct usage in Transformers</summary>
</details>-->
<!--### Downstream Usage (Sentence Transformers)
You can finetune this model on your own dataset.
<details><summary>Click to expand</summary>
</details>-->
<!--### Out-of-Scope Use
*List how the model may foreseeably be misused and address what users ought not to do with the model.*-->
<!--## Bias, Risks and Limitations
*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*-->
<!--### Recommendations
*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*-->
## Training Details
### Framework Versions- Python: 3.11.10- Sentence Transformers: 6.1.0- Transformers: 5.20.1- PyTorch: 2.6.0+cu124- Accelerate: 1.15.0- Datasets: 5.1.0- Tokenizers: 0.23.3
## Additional Resources
- [Training and Finetuning Embedding Models with Sentence Transformers](https://huggingface.co/blog/train-sentence-transformers): the end-to-end guide for training or finetuning Sentence Transformer models.- [Introduction to Matryoshka Embedding Models](https://huggingface.co/blog/matryoshka): variable-size embeddings that can be truncated with minimal quality loss.- [Binary and Scalar Embedding Quantization for Significantly Faster & Cheaper Retrieval](https://huggingface.co/blog/embedding-quantization): post-training compression of embedding vectors.- [Multimodal Embedding & Reranker Models with Sentence Transformers](https://huggingface.co/blog/multimodal-sentence-transformers): use text, image, audio, and video models through the same API.- [Training and Finetuning Multimodal Embedding & Reranker Models with Sentence Transformers](https://huggingface.co/blog/train-multimodal-sentence-transformers): train multimodal embedding models, with a Visual Document Retrieval walkthrough.
## Citation
### BibTeX
<!--## Glossary
*Clearly define terms in order to be accessible across audiences.*-->
<!--## Model Card Authors
*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*-->
<!--## Model Card Contact
*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*-->12345678910111213141516171819202122232425262728293031{ "add_cross_attention": false, "architectures": [ "RobertaModel" ], "attention_probs_dropout_prob": 0.1, "bos_token_id": 0, "classifier_dropout": null, "dtype": "float32", "eos_token_id": 2, "gradient_checkpointing": false, "hidden_act": "gelu", "hidden_dropout_prob": 0.1, "hidden_size": 768, "initializer_range": 0.02, "intermediate_size": 3072, "is_decoder": false, "layer_norm_eps": 1e-05, "max_position_embeddings": 1026, "model_type": "roberta", "num_attention_heads": 12, "num_hidden_layers": 12, "output_past": true, "pad_token_id": 1, "position_embedding_type": "absolute", "tie_word_embeddings": true, "transformers_version": "5.20.1", "type_vocab_size": 10, "use_cache": true, "vocab_size": 51416}1234567891011121314{ "__version__": { "pytorch": "2.6.0+cu124", "sentence_transformers": "6.1.0", "transformers": "5.20.1" }, "default_prompt_name": null, "model_type": "SentenceTransformer", "prompts": { "document": "", "query": "" }, "similarity_fn_name": "cosine"}123version https://git-lfs.github.com/spec/v1oid sha256:19327aee05f08b6018ec4bfafef13c8f1174e75fd16a9be255f029d7ae90c668size 5037412961234567891011121314151617181920212223242526272829303132[ { "idx": 0, "name": "0", "path": "", "type": "sentence_transformers.base.modules.transformer.Transformer" }, { "idx": 1, "name": "1", "path": "1_Pooling", "type": "sentence_transformers.sentence_transformer.modules.pooling.Pooling" }, { "idx": 2, "name": "2", "path": "2_Dense", "type": "sentence_transformers.base.modules.dense.Dense" }, { "idx": 3, "name": "3", "path": "3_Dense", "type": "sentence_transformers.base.modules.dense.Dense" }, { "idx": 4, "name": "4", "path": "4_Normalize", "type": "sentence_transformers.base.modules.normalize.Normalize" }]1234567891011{ "transformer_task": "feature-extraction", "modality_config": { "text": { "method": "forward", "method_output_name": "last_hidden_state" } }, "module_output_name": "token_embeddings", "max_seq_length": 1024}1234567891011121314151617{ "add_prefix_space": false, "backend": "tokenizers", "bos_token": "<s>", "cls_token": "<s>", "eos_token": "</s>", "errors": "replace", "is_local": false, "local_files_only": false, "mask_token": "<mask>", "model_max_length": 1024, "pad_token": "<pad>", "sep_token": "</s>", "tokenizer_class": "RobertaTokenizer", "trim_offsets": true, "unk_token": "<unk>"}README.md+2-2
backbone/config.jsonDeleted-31
backbone/model.safetensorsDeleted-3
backbone/tokenizer.jsonDeleted
backbone/tokenizer_config.jsonDeleted-24
projection_head.ptDeleted-3
pycode_embed_config.jsonDeleted-9
sentence_bert_config.json+1-1
sentence_transformers/1_Pooling/config.jsonDeleted-5
sentence_transformers/2_Dense/config.jsonDeleted-8
sentence_transformers/2_Dense/model.safetensorsDeleted-3
sentence_transformers/3_Dense/config.jsonDeleted-8
sentence_transformers/3_Dense/model.safetensorsDeleted-3
sentence_transformers/4_Normalize/config.jsonDeleted-4
sentence_transformers/README.mdDeleted-154
sentence_transformers/config.jsonDeleted-31
sentence_transformers/config_sentence_transformers.jsonDeleted-14
sentence_transformers/model.safetensorsDeleted-3
sentence_transformers/modules.jsonDeleted-32
sentence_transformers/sentence_bert_config.jsonDeleted-11
sentence_transformers/tokenizer.jsonDeleted
sentence_transformers/tokenizer_config.jsonDeleted-17