Feature Extraction
sentence-transformers
Safetensors
English
bert
multi-vector
colbert
late-interaction
Generated from Trainer
dataset_size:501907
loss:MultiVectorMultipleNegativesRankingLoss
Eval Results (legacy)
text-embeddings-inference
Instructions to use multi-vector-encoder-testing/bert-tiny-multi-vector with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use multi-vector-encoder-testing/bert-tiny-multi-vector with sentence-transformers:
from sentence_transformers import MultiVectorEncoder model = MultiVectorEncoder("multi-vector-encoder-testing/bert-tiny-multi-vector") queries = ["Which planet is known as the Red Planet?"] documents = [ "Venus is often called Earth's twin because of its similar size and proximity.", "Mars, known for its reddish appearance, is often referred to as the Red Planet.", "Jupiter, the largest planet in our solar system, has a prominent red spot.", ] query_embeddings = model.encode_query(queries) document_embeddings = model.encode_document(documents) similarities = model.similarity(query_embeddings, document_embeddings) print(similarities) - Notebooks
- Google Colab
- Kaggle
Clean up model naming and remove training comparison
Browse files- README.md +4 -5
- RUN_SUMMARY.md +0 -45
- train.py +9 -5
README.md
CHANGED
|
@@ -10,7 +10,7 @@ tags:
|
|
| 10 |
- generated_from_trainer
|
| 11 |
- dataset_size:501907
|
| 12 |
- loss:MultiVectorMultipleNegativesRankingLoss
|
| 13 |
-
base_model:
|
| 14 |
widget:
|
| 15 |
- text: 'Kroger Pharmacy - Keller 976 Keller Pkwy, Keller TX 76248 Phone Number: (817)
|
| 16 |
431-5178'
|
|
@@ -954,16 +954,15 @@ model-index:
|
|
| 954 |
name: Maxsim Map@100
|
| 955 |
---
|
| 956 |
|
| 957 |
-
See [the training comparison](RUN_SUMMARY.md) for the longer run settings and all before-and-after results.
|
| 958 |
|
| 959 |
# BERT tiny multi-vector encoder trained on MS MARCO
|
| 960 |
|
| 961 |
-
This is a [Multi-Vector Encoder](https://www.sbert.net/docs/multi_vector_encoder/usage/usage.html) model finetuned from [
|
| 962 |
## Model Details
|
| 963 |
|
| 964 |
### Model Description
|
| 965 |
- **Model Type:** Multi-Vector Encoder
|
| 966 |
-
- **Base model:** [
|
| 967 |
- **Maximum Sequence Length:** 512 tokens
|
| 968 |
- **Maximum Query Length:** 32 tokens
|
| 969 |
- **Maximum Document Length:** 256 tokens
|
|
@@ -1007,7 +1006,7 @@ Then you can load this model and run inference.
|
|
| 1007 |
from sentence_transformers import MultiVectorEncoder
|
| 1008 |
|
| 1009 |
# Download from the 🤗 Hub
|
| 1010 |
-
model = MultiVectorEncoder("multi-vector-encoder-testing/bert-tiny-
|
| 1011 |
# Run inference: each input becomes a sequence of per-token vectors (variable length).
|
| 1012 |
queries = [
|
| 1013 |
'calories in kirkland ravioli',
|
|
|
|
| 10 |
- generated_from_trainer
|
| 11 |
- dataset_size:501907
|
| 12 |
- loss:MultiVectorMultipleNegativesRankingLoss
|
| 13 |
+
base_model: prajjwal1/bert-tiny
|
| 14 |
widget:
|
| 15 |
- text: 'Kroger Pharmacy - Keller 976 Keller Pkwy, Keller TX 76248 Phone Number: (817)
|
| 16 |
431-5178'
|
|
|
|
| 954 |
name: Maxsim Map@100
|
| 955 |
---
|
| 956 |
|
|
|
|
| 957 |
|
| 958 |
# BERT tiny multi-vector encoder trained on MS MARCO
|
| 959 |
|
| 960 |
+
This is a [Multi-Vector Encoder](https://www.sbert.net/docs/multi_vector_encoder/usage/usage.html) model finetuned in two stages from [prajjwal1/bert-tiny](https://huggingface.co/prajjwal1/bert-tiny) on the [msmarco-bm25](https://huggingface.co/datasets/sentence-transformers/msmarco-bm25) dataset using the [sentence-transformers](https://www.SBERT.net) library. It maps inputs to sequences of 128-dimensional token-level vectors and scores them with late interaction (MaxSim), useful for semantic search with late interaction.
|
| 961 |
## Model Details
|
| 962 |
|
| 963 |
### Model Description
|
| 964 |
- **Model Type:** Multi-Vector Encoder
|
| 965 |
+
- **Base model:** [prajjwal1/bert-tiny](https://huggingface.co/prajjwal1/bert-tiny)
|
| 966 |
- **Maximum Sequence Length:** 512 tokens
|
| 967 |
- **Maximum Query Length:** 32 tokens
|
| 968 |
- **Maximum Document Length:** 256 tokens
|
|
|
|
| 1006 |
from sentence_transformers import MultiVectorEncoder
|
| 1007 |
|
| 1008 |
# Download from the 🤗 Hub
|
| 1009 |
+
model = MultiVectorEncoder("multi-vector-encoder-testing/bert-tiny-multi-vector")
|
| 1010 |
# Run inference: each input becomes a sequence of per-token vectors (variable length).
|
| 1011 |
queries = [
|
| 1012 |
'calories in kirkland ravioli',
|
RUN_SUMMARY.md
DELETED
|
@@ -1,45 +0,0 @@
|
|
| 1 |
-
# Longer BERT tiny training run
|
| 2 |
-
|
| 3 |
-
Continued multi-vector-encoder-testing/bert-tiny-msmarco at revision 81c5b4e78ac3bdbb01606e60e82bc34d86ed897b.
|
| 4 |
-
|
| 5 |
-
Trained for 10,000 additional steps with batch size 128 on 501,907 MS MARCO BM25 triplets, with 1,024 held-out rows for evaluation loss. This processed 1.28 million triplets over about 2.55 epochs. Learning rate was 1e-5, with 5% warmup and linear decay. Training used bf16 on one RTX 3090 and took 15.6 minutes including periodic evaluation.
|
| 6 |
-
|
| 7 |
-
Selected step 6,000 using mean nDCG@10 on NanoMSMARCO, NanoNQ, and NanoFiQA2018, evaluated every 2,000 steps. The remaining ten datasets were evaluated only before and after training.
|
| 8 |
-
|
| 9 |
-
## Mean nDCG@10
|
| 10 |
-
|
| 11 |
-
| Evaluation group | Initial model | Longer run |
|
| 12 |
-
| --- | ---: | ---: |
|
| 13 |
-
| Three selection datasets | 0.3326 | 0.3729 |
|
| 14 |
-
| All 13 datasets | 0.3999 | 0.4468 |
|
| 15 |
-
| Ten additional datasets | 0.4201 | 0.4690 |
|
| 16 |
-
|
| 17 |
-
## Per-dataset nDCG@10
|
| 18 |
-
|
| 19 |
-
| Dataset | Initial model | Longer run | Change |
|
| 20 |
-
| --- | ---: | ---: | ---: |
|
| 21 |
-
| NanoClimateFEVER | 0.1431 | 0.1919 | +0.0489 |
|
| 22 |
-
| NanoDBPedia | 0.3914 | 0.4820 | +0.0907 |
|
| 23 |
-
| NanoFEVER | 0.6310 | 0.6793 | +0.0483 |
|
| 24 |
-
| NanoFiQA2018 | 0.2658 | 0.3027 | +0.0369 |
|
| 25 |
-
| NanoHotpotQA | 0.5766 | 0.6840 | +0.1073 |
|
| 26 |
-
| NanoMSMARCO | 0.4328 | 0.3859 | -0.0469 |
|
| 27 |
-
| NanoNFCorpus | 0.2569 | 0.2852 | +0.0283 |
|
| 28 |
-
| NanoNQ | 0.2992 | 0.4300 | +0.1307 |
|
| 29 |
-
| NanoQuoraRetrieval | 0.7976 | 0.8355 | +0.0379 |
|
| 30 |
-
| NanoSCIDOCS | 0.2029 | 0.2217 | +0.0188 |
|
| 31 |
-
| NanoArguAna | 0.2863 | 0.3539 | +0.0676 |
|
| 32 |
-
| NanoSciFact | 0.5060 | 0.5650 | +0.0590 |
|
| 33 |
-
| NanoTouche2020 | 0.4096 | 0.3920 | -0.0176 |
|
| 34 |
-
|
| 35 |
-
Improved on 11 of 13 datasets. NanoMSMARCO and NanoTouche2020 declined.
|
| 36 |
-
|
| 37 |
-
## Reproduce
|
| 38 |
-
|
| 39 |
-
Run with a compatible Sentence Transformers checkout and its training dependencies:
|
| 40 |
-
|
| 41 |
-
```bash
|
| 42 |
-
python train.py --long-run
|
| 43 |
-
```
|
| 44 |
-
|
| 45 |
-
The script pins the initial model revision. Training arguments, every evaluation, and per-dataset before-and-after results are included in results.json.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
train.py
CHANGED
|
@@ -4,6 +4,7 @@ Adapted from the multi-vector training skill template and training_contrastive.p
|
|
| 4 |
Run from the repository root with Python and the training dependencies installed.
|
| 5 |
Use --smoke-test for one step, or --push-to-hub to upload the best checkpoint.
|
| 6 |
Use --long-run to continue the initial model for 10,000 steps on the full dataset.
|
|
|
|
| 7 |
"""
|
| 8 |
|
| 9 |
import argparse
|
|
@@ -30,8 +31,7 @@ from sentence_transformers.multi_vector_encoder.losses import MultiVectorMultipl
|
|
| 30 |
from sentence_transformers.multi_vector_encoder.modules import MultiVectorMask
|
| 31 |
|
| 32 |
RUN_NAME = "bert-tiny-msmarco"
|
| 33 |
-
REPO_ID =
|
| 34 |
-
INITIAL_REVISION = "81c5b4e78ac3bdbb01606e60e82bc34d86ed897b"
|
| 35 |
|
| 36 |
|
| 37 |
class LogProgress(TrainerCallback):
|
|
@@ -58,8 +58,8 @@ def main():
|
|
| 58 |
parser.add_argument("--push-to-hub", action="store_true")
|
| 59 |
parser.add_argument("--long-run", action="store_true")
|
| 60 |
cli = parser.parse_args()
|
| 61 |
-
repo_id = REPO_ID
|
| 62 |
-
run_name =
|
| 63 |
output_dir = Path("models") / run_name
|
| 64 |
output_dir.mkdir(parents=True, exist_ok=True)
|
| 65 |
Path("logs").mkdir(exist_ok=True)
|
|
@@ -82,7 +82,11 @@ def main():
|
|
| 82 |
model_id=repo_id,
|
| 83 |
)
|
| 84 |
if cli.long_run:
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
else:
|
| 87 |
# The original checkpoint lacks model_type, which recent AutoConfig versions require.
|
| 88 |
base_dir = output_dir / "base"
|
|
|
|
| 4 |
Run from the repository root with Python and the training dependencies installed.
|
| 5 |
Use --smoke-test for one step, or --push-to-hub to upload the best checkpoint.
|
| 6 |
Use --long-run to continue the initial model for 10,000 steps on the full dataset.
|
| 7 |
+
Run without --long-run first to create the local initial model.
|
| 8 |
"""
|
| 9 |
|
| 10 |
import argparse
|
|
|
|
| 31 |
from sentence_transformers.multi_vector_encoder.modules import MultiVectorMask
|
| 32 |
|
| 33 |
RUN_NAME = "bert-tiny-msmarco"
|
| 34 |
+
REPO_ID = "multi-vector-encoder-testing/bert-tiny-multi-vector"
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
class LogProgress(TrainerCallback):
|
|
|
|
| 58 |
parser.add_argument("--push-to-hub", action="store_true")
|
| 59 |
parser.add_argument("--long-run", action="store_true")
|
| 60 |
cli = parser.parse_args()
|
| 61 |
+
repo_id = REPO_ID
|
| 62 |
+
run_name = RUN_NAME + ("-long" if cli.long_run else "") + ("-smoke" if cli.smoke_test else "")
|
| 63 |
output_dir = Path("models") / run_name
|
| 64 |
output_dir.mkdir(parents=True, exist_ok=True)
|
| 65 |
Path("logs").mkdir(exist_ok=True)
|
|
|
|
| 82 |
model_id=repo_id,
|
| 83 |
)
|
| 84 |
if cli.long_run:
|
| 85 |
+
initial_model = Path("models") / RUN_NAME / "final"
|
| 86 |
+
if not initial_model.is_dir():
|
| 87 |
+
parser.error("Run without --long-run first to create the local initial model.")
|
| 88 |
+
model = MultiVectorEncoder(str(initial_model), model_card_data=card)
|
| 89 |
+
model.model_card_data.set_base_model("prajjwal1/bert-tiny")
|
| 90 |
else:
|
| 91 |
# The original checkpoint lacks model_type, which recent AutoConfig versions require.
|
| 92 |
base_dir = output_dir / "base"
|