Views
No views yet
TheBloke/Mistral-7B-Instruct-v0.2-code-ft-GGUF model, pre-trained with the Masked Next Token Prediction (MNTP) objective from the llm2vec framework.1from transformers import AutoTokenizer, AutoModel, AutoConfig
2from peft import PeftModel
3from llm2vec import LLM2Vec
4
5base_model_id = "TheBloke/Mistral-7B-Instruct-v0.2-code-ft-GGUF"
6mntp_model_id = "[SYSUSELab/DCS-CodeMistral-7B-It-MNTP]"
7
8tokenizer = AutoTokenizer.from_pretrained(base_model_id)
9config = AutoConfig.from_pretrained(base_model_id, trust_remote_code=True)
10model = AutoModel.from_pretrained(base_model_id, trust_remote_code=True, config=config,
11 torch_dtype=torch.bfloat16, device_map="auto")
12model = PeftModel.from_pretrained(model, mntp_model_id)
13
14l2v = LLM2Vec(model, tokenizer, pooling_mode="mean", max_length=512)
15embeddings = l2v.encode(["def hello_world():\n print('Hello, World!')"])
16print("Embedding from MNTP model:", embeddings.shape)llm2vec paper. If you wish to train your own MNTP model from scratch, please refer to the instructions in the Fine-tuning/Fine-tuning_method/MNTP/ directory of our GitHub repository.llm2vec.1@article{chen2024decoder,
2 title={Are Decoder-Only Large Language Models the Silver Bullet for Code Search?},
3 author={Chen, Yuxuan and Liu, Mingwei and Ou, Guangsheng and Li, Anji and Dai, Dekun and Wang, Yanlin and Zheng, Zibin},
4 journal={arXiv preprint arXiv:2410.22240},
5 year={2024}
6}
7
8@article{vaishaal2024llm2vec,
9 title={LLM2Vec: Large Language Models Are Good Contextual Text Encoders},
10 author={Vaishaal, Shankar and Bansal, Mohit and Arora, Simran},
11 journal={arXiv preprint arXiv:2404.05961},
12 year={2024}
13}