PEFT
Safetensors
code
code-search
text-embeddings
decoder-only
supervised-contrastive-learning
codegemma
llm2vec
Run this model with HF Jobs
Run SYSUSELab/DCS-DeepSeekCoder-6.7B-It-SupCon-CSN 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/SYSUSELab/DCS-DeepSeekCoder-6.7B-It-SupCon-CSN. 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/SYSUSELab/DCS-DeepSeekCoder-6.7B-It-SupCon-CSN 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 SYSUSELab/DCS-DeepSeekCoder-6.7B-It-SupCon-CSN with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use SYSUSELab/DCS-DeepSeekCoder-6.7B-It-SupCon-CSN with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
Upload 3 files
Browse filesFiles changed (3)
- README.md+130-3
- adapter_config.jsonAdded+37
- adapter_model.safetensorsAdded+3
123---license: apache-2.0---123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130---license: apache-2.0language:- codelibrary_name: pefttags:- code-search- text-embeddings- decoder-only- supervised-contrastive-learning- codegemma- llm2vec---## ๐ Are Decoder-Only Large Language Models the Silver Bullet for Code Search?This model is an official artifact from our research paper: **"[Are Decoder-Only Large Language Models the Silver Bullet for Code Search?](https://arxiv.org/abs/2410.22240)"**.In this work, we conduct a large-scale systematic evaluation of decoder-only Large Language Models for the task of code search and present a set of effective fine-tuning and optimization strategies.For complete details on all our experiments, to reproduce the full training/evaluation pipeline, or to use other models from the paper, please visit our official GitHub repository:โก๏ธ **[GitHub: Georgepitt/DecoderLLMs-CodeSearch](https://github.com/Georgepitt/DecoderLLMs-CodeSearch)**---# Model Card: DCS-CodeGemma-7b-it-SupCon-CSN## ๐ Model DescriptionThis is a PEFT adapter for the **`deepseek-ai/deepseek-coder-6.7b-instruct`** model, fine-tuned for the task of **Code Search** as part of the research mentioned above.The model was trained using the **Supervised Contrastive Learning** method proposed in the [llm2vec](https://github.com/McGill-NLP/llm2vec) framework, designed to generate high-quality vector embeddings for code snippets.## ๐ฌ Model Performance & ReproducibilityThe table below provides details about this model, its corresponding results in our paper, and how to reproduce the evaluation.| Attribute | Details || :------------------------- | :------------------------------------------------------------------------------------------------------------------------------ || **Base Model** | `deepseek-ai/deepseek-coder-6.7b-instruct` || **Fine-tuning Method** | Supervised Contrastive Learning via `llm2vec` | || **Evaluation Script** | [CSN_Test_Finetuning_Decoder_Model.py](https://github.com/Georgepitt/DecoderLLMs-CodeSearch/blob/main/Fine-tuning/CSN_Test_Finetuning_Decoder_Model.py),<br>[CoSQA_Plus_Test_Finetuning_Decoder_Model.py](https://github.com/ChenyxEugene/DecoderLLMs-CodeSearch/blob/main/Fine-tuning/CoSQA_Plus_Test_Finetuning_Decoder_Model.py) || **Prerequisite Model** | This model must be loaded on top of an MNTP pre-trained model. |---## ๐ How to Use (with `llm2vec`)For best results, we strongly recommend using the official `llm2vec` wrapper to load and use this model.**1. Install Dependencies**```bashpip install llm2vec transformers torch peft accelerate```**2. Example Usage**> **Important**: The `llm2vec` supervised contrastive (SupCon) models are fine-tuned on top of **MNTP (Masked Next Token Prediction)** models. Therefore, loading requires first merging the MNTP weights before loading the SupCon adapter.```pythonimport torchfrom transformers import AutoTokenizer, AutoModel, AutoConfigfrom peft import PeftModelfrom llm2vec import LLM2Vec# --- 1. Define Model IDs ---base_model_id = "deepseek-ai/deepseek-coder-6.7b-instruct"mntp_model_id = "SYSUSELab/DCS-DeepSeekCoder-6.7B-It-MNTP"supcon_model_id = "SYSUSELab/DCS-DeepSeekCoder-6.7B-It-SupCon-CSN"# --- 2. Load Base Model and MNTP Adapter ---tokenizer = AutoTokenizer.from_pretrained(base_model_id)config = AutoConfig.from_pretrained(base_model_id, trust_remote_code=True)model = AutoModel.from_pretrained(base_model_id,trust_remote_code=True,config=config,torch_dtype=torch.bfloat16,device_map="cuda" if torch.cuda.is_available() else "cpu",)model = PeftModel.from_pretrained(model, mntp_model_id)model = model.merge_and_unload()# --- 3. Load the Supervised (this model) Adapter on top of the MNTP-merged model ---model = PeftModel.from_pretrained(model, supcon_model_id)# --- 4. Use the LLM2Vec Wrapper for Encoding ---l2v = LLM2Vec(model, tokenizer, pooling_mode="mean", max_length=512)queries = ["how to read a file in Python?"]code_snippets = ["with open('file.txt', 'r') as f:\n content = f.read()"]query_embeddings = l2v.encode(queries)code_embeddings = l2v.encode(code_snippets)print("Query Embedding Shape:", query_embeddings.shape)# This usage example is adapted from the official llm2vec repository. Credits to the original authors.```---## ๐ CitationIf you use our model or work in your research, please cite our paper. As our method is built upon `llm2vec`, please also cite their foundational work.**Our Paper:*** **Paper Link:** [Are Decoder-Only Large Language Models the Silver Bullet for Code Search?](https://arxiv.org/abs/2410.22240)* **GitHub:** [https://github.com/Georgepitt/DecoderLLMs-CodeSearch](https://github.com/Georgepitt/DecoderLLMs-CodeSearch)* **BibTeX:**```bibtex@article{chen2024decoder,title={Are Decoder-Only Large Language Models the Silver Bullet for Code Search?},author={Chen, Yuxuan and Liu, Mingwei and Ou, Guangsheng and Li, Anji and Dai, Dekun and Wang, Yanlin and Zheng, Zibin},journal={arXiv preprint arXiv:2410.22240},year={2024}}```**llm2vec (Foundational Work):*** **Paper Link:** [LLM2Vec: Large Language Models Are Good Contextual Text Encoders](https://arxiv.org/abs/2404.05961)* **GitHub:** [https://github.com/McGill-NLP/llm2vec](https://github.com/McGill-NLP/llm2vec)* **BibTeX:**```bibtex@article{vaishaal2024llm2vec,title={LLM2Vec: Large Language Models Are Good Contextual Text Encoders},author={Vaishaal, Shankar and Bansal, Mohit and Arora, Simran},journal={arXiv preprint arXiv:2404.05961},year={2024}}```
12345678910111213141516171819202122232425262728293031323334353637{ "alpha_pattern": {}, "auto_mapping": { "base_model_class": "LlamaBiModel", "parent_library": "llm2vec.models.bidirectional_llama" }, "base_model_name_or_path": "deepseek-ai/deepseek-coder-6.7b-instruct", "bias": "none", "fan_in_fan_out": false, "inference_mode": true, "init_lora_weights": true, "layer_replication": null, "layers_pattern": null, "layers_to_transform": null, "loftq_config": {}, "lora_alpha": 32, "lora_dropout": 0.05, "megatron_config": null, "megatron_core": "megatron.core", "modules_to_save": null, "peft_type": "LORA", "r": 16, "rank_pattern": {}, "revision": null, "target_modules": [ "up_proj", "down_proj", "gate_proj", "q_proj", "k_proj", "v_proj", "o_proj" ], "task_type": null, "use_dora": false, "use_rslora": false}123version https://git-lfs.github.com/spec/v1oid sha256:a4d3c97c24ee969b1ed0f3159d3d44779037de38e65f7428977816a8c687059dsize 80011328README.md+130-3
adapter_config.jsonAdded+37
adapter_model.safetensorsAdded+3