Views
No views yet
| Name | Quant method | Size |
|---|---|---|
| Qwen-encoder-1.5B.Q2_K.gguf | Q2_K | 0.63GB |
| Qwen-encoder-1.5B.IQ3_XS.gguf | IQ3_XS | 0.68GB |
| Qwen-encoder-1.5B.IQ3_S.gguf | IQ3_S | 0.71GB |
| Qwen-encoder-1.5B.Q3_K_S.gguf | Q3_K_S | 0.71GB |
| Qwen-encoder-1.5B.IQ3_M.gguf | IQ3_M | 0.72GB |
| Qwen-encoder-1.5B.Q3_K.gguf | Q3_K | 0.77GB |
| Qwen-encoder-1.5B.Q3_K_M.gguf | Q3_K_M | 0.77GB |
| Qwen-encoder-1.5B.Q3_K_L.gguf | Q3_K_L | 0.82GB |
| Qwen-encoder-1.5B.IQ4_XS.gguf | IQ4_XS | 0.84GB |
| Qwen-encoder-1.5B.Q4_0.gguf | Q4_0 | 0.87GB |
| Qwen-encoder-1.5B.IQ4_NL.gguf | IQ4_NL | 0.88GB |
| Qwen-encoder-1.5B.Q4_K_S.gguf | Q4_K_S | 0.88GB |
| Qwen-encoder-1.5B.Q4_K.gguf | Q4_K | 0.92GB |
| Qwen-encoder-1.5B.Q4_K_M.gguf | Q4_K_M | 0.92GB |
| Qwen-encoder-1.5B.Q4_1.gguf | Q4_1 | 0.95GB |
| Qwen-encoder-1.5B.Q5_0.gguf | Q5_0 | 1.02GB |
| Qwen-encoder-1.5B.Q5_K_S.gguf | Q5_K_S | 1.02GB |
| Qwen-encoder-1.5B.Q5_K.gguf | Q5_K | 1.05GB |
| Qwen-encoder-1.5B.Q5_K_M.gguf | Q5_K_M | 1.05GB |
| Qwen-encoder-1.5B.Q5_1.gguf | Q5_1 | 1.1GB |
| Qwen-encoder-1.5B.Q6_K.gguf | Q6_K | 1.19GB |
| Qwen-encoder-1.5B.Q8_0.gguf | Q8_0 | 1.53GB |
LLM2Vec is a simple recipe to convert decoder-only LLMs into text encoders. It consists of 3 simple steps: 1) enabling bidirectional attention, 2) masked next token prediction, and 3) unsupervised contrastive learning. The model can be further fine-tuned to achieve state-of-the-art performance.
pip install llm2vec1from llm2vec.models import Qwen2BiModel
2
3import torch
4from transformers import AutoTokenizer
5
6# Loading base Mistral model, along with custom code that enables bidirectional connections in decoder-only LLMs. MNTP LoRA weights are merged into the base model.
7tokenizer = AutoTokenizer.from_pretrained(
8 "knowledgator/Qwen-encoder-1.5B"
9)
10
11model = Qwen2BiModel.from_pretrained("knowledgator/Qwen-encoder-1.5B")
12
13text = "The quick brown fox jumps over the lazy dog."
14
15inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=512)
16
17device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
18model = model.to(device)
19inputs = {k: v.to(device) for k, v in inputs.items()}
20
21with torch.no_grad():
22 outputs = model(**inputs)
23
24last_hidden_states = outputs.last_hidden_state1git clone https://github.com/Knowledgator/llm2vec.git
2cd llm2vec
3pip install -e .-e flag installs the package in editable mode, which is useful for development.1from llm2vec import (
2 AutoLLMEncoderForSequenceClassification,
3 AutoLLMEncoderForQuestionAnswering,
4 AutoLLMEncoderForTokenClassification
5)
6
7# Load models for different tasks
8classification_model = AutoLLMEncoderForSequenceClassification.from_pretrained('knowledgator/Qwen-encoder-1.5B')
9question_answering_model = AutoLLMEncoderForQuestionAnswering.from_pretrained('knowledgator/Qwen-encoder-1.5B')
10token_classification_model = AutoLLMEncoderForTokenClassification.from_pretrained('knowledgator/Qwen-encoder-1.5B')1from transformers import AutoTokenizer
2
3# Load tokenizer
4tokenizer = AutoTokenizer.from_pretrained('knowledgator/Qwen-encoder-1.5B')
5
6# Prepare input
7text = "This movie is great!"
8inputs = tokenizer(text, return_tensors="pt")
9
10# Get classification logits
11outputs = classification_model(**inputs)
12logits = outputs.logits
13
14# The logits can be used with a softmax function to get probabilities
15# or you can use torch.argmax(logits, dim=1) to get the predicted classdatasets library.Trainer class from HuggingFace's transformers library to fine-tune the model.1from transformers import Trainer, TrainingArguments
2from datasets import load_dataset
3
4# Load your dataset
5dataset = load_dataset("your_dataset")
6
7# Define training arguments
8training_args = TrainingArguments(
9 output_dir="./results",
10 num_train_epochs=3,
11 per_device_train_batch_size=8,
12 per_device_eval_batch_size=8,
13 warmup_steps=500,
14 weight_decay=0.01,
15 logging_dir="./logs",
16)
17
18# Initialize Trainer
19trainer = Trainer(
20 model=classification_model,
21 args=training_args,
22 train_dataset=dataset["train"],
23 eval_dataset=dataset["test"],
24)
25
26# Fine-tune the model
27trainer.train()