Feature Extraction
Transformers
Safetensors
PEFT
English
llama
llm2vec
embedding
sentence-similarity
text-encoder
llama3
kimodo
quantized
bitsandbytes
nf4
4-bit precision
lora
text-embeddings-inference
Instructions to use matbee/kimodo-llm2vec-nf4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use matbee/kimodo-llm2vec-nf4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="matbee/kimodo-llm2vec-nf4")# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("matbee/kimodo-llm2vec-nf4") model = AutoModel.from_pretrained("matbee/kimodo-llm2vec-nf4") - PEFT
How to use matbee/kimodo-llm2vec-nf4 with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- .gitignore +1 -0
- README.md +8 -8
- chat_template.jinja +5 -0
- config.json +47 -0
- model.safetensors +3 -0
- tokenizer.json +3 -0
- tokenizer_config.json +13 -0
.gitattributes
CHANGED
|
@@ -34,3 +34,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
base/tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
base/tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
.cache/
|
README.md
CHANGED
|
@@ -75,11 +75,11 @@ The ~5% per-prompt embedding cosine drift (0.953 mean vs bf16) propagates into ~
|
|
| 75 |
|
| 76 |
```
|
| 77 |
.
|
| 78 |
-
├──
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
├── supervised_adapter/ # second LoRA stack (kept un-merged)
|
| 84 |
│ ├── adapter_config.json
|
| 85 |
│ └── adapter_model.safetensors
|
|
@@ -99,12 +99,12 @@ CUDA_VISIBLE_DEVICES=0 \
|
|
| 99 |
TEXT_ENCODER_DEVICE=cuda:0 \
|
| 100 |
TEXT_ENCODER_MODE=local \
|
| 101 |
LLM2VEC_QUANTIZE=nf4 \
|
| 102 |
-
LLM2VEC_LOCAL_BASE=$HOME/llm2vec-nf4
|
| 103 |
LLM2VEC_LOCAL_PEFT=$HOME/llm2vec-nf4/supervised_adapter \
|
| 104 |
python kimodo_daemon.py
|
| 105 |
```
|
| 106 |
|
| 107 |
-
`LLM2VEC_QUANTIZE=nf4` tells the wrapper to honor the bnb config in `
|
| 108 |
|
| 109 |
## Standalone use (without kimodo)
|
| 110 |
|
|
@@ -118,7 +118,7 @@ from llm2vec import LLM2Vec # from McGill's llm2vec package
|
|
| 118 |
|
| 119 |
# Load the bnb-quantized base; quantization_config is in config.json so
|
| 120 |
# transformers re-applies bnb automatically.
|
| 121 |
-
base_dir = "<local clone>
|
| 122 |
adapter_dir = "<local clone>/supervised_adapter"
|
| 123 |
|
| 124 |
model = LLM2Vec.from_pretrained(
|
|
|
|
| 75 |
|
| 76 |
```
|
| 77 |
.
|
| 78 |
+
├── config.json # contains quantization_config (auto-applied on load)
|
| 79 |
+
├── model.safetensors # bnb 4-bit weights (Llama-3-8B + merged MNTP)
|
| 80 |
+
├── tokenizer.json
|
| 81 |
+
├── tokenizer_config.json
|
| 82 |
+
├── chat_template.jinja
|
| 83 |
├── supervised_adapter/ # second LoRA stack (kept un-merged)
|
| 84 |
│ ├── adapter_config.json
|
| 85 |
│ └── adapter_model.safetensors
|
|
|
|
| 99 |
TEXT_ENCODER_DEVICE=cuda:0 \
|
| 100 |
TEXT_ENCODER_MODE=local \
|
| 101 |
LLM2VEC_QUANTIZE=nf4 \
|
| 102 |
+
LLM2VEC_LOCAL_BASE=$HOME/llm2vec-nf4 \
|
| 103 |
LLM2VEC_LOCAL_PEFT=$HOME/llm2vec-nf4/supervised_adapter \
|
| 104 |
python kimodo_daemon.py
|
| 105 |
```
|
| 106 |
|
| 107 |
+
`LLM2VEC_QUANTIZE=nf4` tells the wrapper to honor the bnb config in `config.json`. The two `LLM2VEC_LOCAL_*` vars short-circuit the Hub download.
|
| 108 |
|
| 109 |
## Standalone use (without kimodo)
|
| 110 |
|
|
|
|
| 118 |
|
| 119 |
# Load the bnb-quantized base; quantization_config is in config.json so
|
| 120 |
# transformers re-applies bnb automatically.
|
| 121 |
+
base_dir = "<local clone>"
|
| 122 |
adapter_dir = "<local clone>/supervised_adapter"
|
| 123 |
|
| 124 |
model = LLM2Vec.from_pretrained(
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% set loop_messages = messages %}{% for message in loop_messages %}{% set content = '<|start_header_id|>' + message['role'] + '<|end_header_id|>
|
| 2 |
+
|
| 3 |
+
'+ message['content'] | trim + '<|eot_id|>' %}{% if loop.index0 == 0 %}{% set content = bos_token + content %}{% endif %}{{ content }}{% endfor %}{% if add_generation_prompt %}{{ '<|start_header_id|>assistant<|end_header_id|>
|
| 4 |
+
|
| 5 |
+
' }}{% endif %}
|
config.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"LlamaBiModel"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"bos_token_id": 128000,
|
| 8 |
+
"dtype": "bfloat16",
|
| 9 |
+
"eos_token_id": 128009,
|
| 10 |
+
"head_dim": 128,
|
| 11 |
+
"hidden_act": "silu",
|
| 12 |
+
"hidden_size": 4096,
|
| 13 |
+
"initializer_range": 0.02,
|
| 14 |
+
"intermediate_size": 14336,
|
| 15 |
+
"max_position_embeddings": 8192,
|
| 16 |
+
"mlp_bias": false,
|
| 17 |
+
"model_type": "llama",
|
| 18 |
+
"num_attention_heads": 32,
|
| 19 |
+
"num_hidden_layers": 32,
|
| 20 |
+
"num_key_value_heads": 8,
|
| 21 |
+
"pad_token_id": null,
|
| 22 |
+
"pretraining_tp": 1,
|
| 23 |
+
"quantization_config": {
|
| 24 |
+
"_load_in_4bit": true,
|
| 25 |
+
"_load_in_8bit": false,
|
| 26 |
+
"bnb_4bit_compute_dtype": "bfloat16",
|
| 27 |
+
"bnb_4bit_quant_storage": "uint8",
|
| 28 |
+
"bnb_4bit_quant_type": "nf4",
|
| 29 |
+
"bnb_4bit_use_double_quant": true,
|
| 30 |
+
"llm_int8_enable_fp32_cpu_offload": false,
|
| 31 |
+
"llm_int8_has_fp16_weight": false,
|
| 32 |
+
"llm_int8_skip_modules": null,
|
| 33 |
+
"llm_int8_threshold": 6.0,
|
| 34 |
+
"load_in_4bit": true,
|
| 35 |
+
"load_in_8bit": false,
|
| 36 |
+
"quant_method": "bitsandbytes"
|
| 37 |
+
},
|
| 38 |
+
"rms_norm_eps": 1e-05,
|
| 39 |
+
"rope_parameters": {
|
| 40 |
+
"rope_theta": 500000.0,
|
| 41 |
+
"rope_type": "default"
|
| 42 |
+
},
|
| 43 |
+
"tie_word_embeddings": false,
|
| 44 |
+
"transformers_version": "5.1.0",
|
| 45 |
+
"use_cache": true,
|
| 46 |
+
"vocab_size": 128256
|
| 47 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:64d4bea7b029f5ea40c52eb84c11cb370ddb4d7d45f4e9f8d3babe92e3665c5d
|
| 3 |
+
size 4652064697
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3c5cf44023714fb39b05e71e425f8d7b92805ff73f7988b083b8c87f0bf87393
|
| 3 |
+
size 17209961
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"bos_token": "<|begin_of_text|>",
|
| 4 |
+
"clean_up_tokenization_spaces": true,
|
| 5 |
+
"eos_token": "<|eot_id|>",
|
| 6 |
+
"is_local": true,
|
| 7 |
+
"model_input_names": [
|
| 8 |
+
"input_ids",
|
| 9 |
+
"attention_mask"
|
| 10 |
+
],
|
| 11 |
+
"model_max_length": 1000000000000000019884624838656,
|
| 12 |
+
"tokenizer_class": "TokenizersBackend"
|
| 13 |
+
}
|