Downloads · 30 days
20
22% of all-time downloads
aditeyabaral/langcache-colbert-v1-4gpu
langcache-colbert-v1-4gpu is a sentence similarity model from aditeyabaral. Use it when you need a score for how close two texts are. It is set up for PyLate. The card lists the license as apache-2.0.
This is a PyLate model finetuned from colbert-ir/colbertv2.0 on the [LangCache Sentence Pairs (subsets=['all'], train+val=True)](https://huggingface.co/datasets/redis/langcache-sentencepairs-v1) dataset. It maps sente…
Downloads · 30 days
20
22% of all-time downloads
All-time downloads
89
Public
Parameters
109M
438 MB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors219 MB · 100%
From the Hugging Face model README
This is a PyLate model finetuned from colbert-ir/colbertv2.0 on the LangCache Sentence Pairs (subsets=['all'], train+val=True) dataset. It maps sentences & paragraphs to sequences of 128-dimensional dense vectors and can be used for semantic textual similarity using the MaxSim operator.
ColBERT(
(0): Transformer({'max_seq_length': 127, 'do_lower_case': False, 'architecture': 'BertModel'})
(1): Dense({'in_features': 768, 'out_features': 128, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity', 'use_residual': False})
)
First install the PyLate library:
pip install -U pylate
Use this model with PyLate to index and retrieve documents. The index uses FastPLAID for efficient similarity search.
Load the ColBERT model and initialize the PLAID index, then encode and index your documents:
from pylate import indexes, models, retrieve
# Step 1: Load the ColBERT model
model = models.ColBERT(
model_name_or_path="aditeyabaral/langcache-colbert-v1-4gpu",
)
# Step 2: Initialize the PLAID index
index = indexes.PLAID(
index_folder="pylate-index",
index_name="index",
override=True, # This overwrites the existing index if any
)
# Step 3: Encode the documents
documents_ids = ["1", "2", "3"]
documents = ["document 1 text", "document 2 text", "document 3 text"]
documents_embeddings = model.encode(
documents,
batch_size=32,
is_query=False, # Ensure that it is set to False to indicate that these are documents, not queries
show_progress_bar=True,
)
# Step 4: Add document embeddings to the index by providing embeddings and corresponding ids
index.add_documents(
documents_ids=documents_ids,
documents_embeddings=documents_embeddings,
)
Note that you do not have to recreate the index and encode the documents every time. Once you have created an index and added the documents, you can re-use the index later by loading it:
# To load an index, simply instantiate it with the correct folder/name and without overriding it
index = indexes.PLAID(
index_folder="pylate-index",
index_name="index",
)
Once the documents are indexed, you can retrieve the top-k most relevant documents for a given set of queries. To do so, initialize the ColBERT retriever with the index you want to search in, encode the queries and then retrieve the top-k documents to get the top matches ids and relevance scores:
# Step 1: Initialize the ColBERT retriever
retriever = retrieve.ColBERT(index=index)
# Step 2: Encode the queries
queries_embeddings = model.encode(
["query for document 3", "query for document 1"],
batch_size=32,
is_query=True, # # Ensure that it is set to False to indicate that these are queries
show_progress_bar=True,
)
# Step 3: Retrieve top-k documents
scores = retriever.retrieve(
queries_embeddings=queries_embeddings,
k=10, # Retrieve the top 10 matches for each query
)
If you only want to use the ColBERT model to perform reranking on top of your first-stage retrieval pipeline without building an index, you can simply use rank function and pass the queries and documents to rerank:
from pylate import rank, models
queries = [
"query A",
"query B",
]
documents = [
["document A", "document B"],
["document 1", "document C", "document B"],
]
documents_ids = [
[1, 2],
[1, 3, 2],
]
model = models.ColBERT(
model_name_or_path="aditeyabaral/langcache-colbert-v1-4gpu",
)
queries_embeddings = model.encode(
queries,
is_query=True,
)
documents_embeddings = model.encode(
documents,
is_query=False,
)
reranked_documents = rank.rerank(
documents_ids=documents_ids,
queries_embeddings=queries_embeddings,
documents_embeddings=documents_embeddings,
)
<!--
### Direct Usage (Transformers)
<details><summary>Click to see the direct usage in Transformers</summary>
</details>
-->
<!--
### Downstream Usage (Sentence Transformers)
You can finetune this model on your own dataset.
<details><summary>Click to expand</summary>
</details>
-->
<!--
### Out-of-Scope Use
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
-->
test_triplet| Metric | Value |
|---|---|
| accuracy | 0.8206 |
| anchor | positive | negative_1 | |
|---|---|---|---|
| type | string | string | string |
| details | <ul><li>min: 9 tokens</li><li>mean: 29.49 tokens</li><li>max: 73 tokens</li></ul> | <ul><li>min: 8 tokens</li><li>mean: 29.18 tokens</li><li>max: 58 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 23.79 tokens</li><li>max: 52 tokens</li></ul> |
| anchor | positive | negative_1 |
|---|---|---|
| <code> Any Canadian teachers (B.Ed. holders) teaching in U.S. schools?</code> | <code> Any Canadian teachers (B.Ed. holders) teaching in U.S. schools?</code> | <code>Are there many Canadians living and working illegally in the United States?</code> |
| <code> Are there any underlying psychological tricks/tactics that are used when designing the lines for rides at amusement parks?</code> | <code> Are there any underlying psychological tricks/tactics that are used when designing the lines for rides at amusement parks?</code> | <code>Is there any tricks for straight lines mcqs?</code> |
| <code> Can I pay with a debit card on PayPal?</code> | <code> Can I pay with a debit card on PayPal?</code> | <code>Can you transfer PayPal funds onto a debit card/credit card?</code> |
| anchor | positive | negative_1 | |
|---|---|---|---|
| type | string | string | string |
| details | <ul><li>min: 5 tokens</li><li>mean: 28.57 tokens</li><li>max: 121 tokens</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 28.01 tokens</li><li>max: 121 tokens</li></ul> | <ul><li>min: 7 tokens</li><li>mean: 20.73 tokens</li><li>max: 65 tokens</li></ul> |
| anchor | positive | negative_1 |
|---|---|---|
| <code> What high potential jobs are there other than computer science?</code> | <code> What high potential jobs are there other than computer science?</code> | <code>Why IT or Computer Science jobs are being over rated than other Engineering jobs?</code> |
| <code> Would India ever be able to develop a missile system like S300 or S400 missile?</code> | <code> Would India ever be able to develop a missile system like S300 or S400 missile?</code> | <code>Should India buy the Russian S400 air defence missile system?</code> |
| <code> water from the faucet is being drunk by a yellow dog</code> | <code>A yellow dog is drinking water from the faucet</code> | <code>Do you get more homework in 9th grade than 8th?</code> |
per_device_train_batch_size: 48num_train_epochs: 5learning_rate: 0.0002warmup_steps: 0.1optim: adamw_torchweight_decay: 0.001eval_strategy: stepsper_device_eval_batch_size: 48eval_on_start: Truepush_to_hub: Truehub_model_id: aditeyabaral/langcache-colbert-v1-4gpuload_best_model_at_end: Trueddp_find_unused_parameters: Truebatch_sampler: no_duplicatesper_device_train_batch_size: 48num_train_epochs: 5max_steps: -1learning_rate: 0.0002lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0.1optim: adamw_torchoptim_args: Noneweight_decay: 0.001adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08optim_target_modules: Nonegradient_accumulation_steps: 1average_tokens_across_devices: Truemax_grad_norm: 1.0label_smoothing_factor: 0.0bf16: Falsefp16: Falsebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Nonetorch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneuse_liger_kernel: Falseliger_kernel_config: Noneuse_cache: Falseneftune_noise_alpha: Nonetorch_empty_cache_steps: Noneauto_find_batch_size: Falselog_on_each_node: Truelogging_nan_inf_filter: Trueinclude_num_input_tokens_seen: nolog_level: passivelog_level_replica: warningdisable_tqdm: Falseproject: huggingfacetrackio_space_id: trackioeval_strategy: stepsper_device_eval_batch_size: 48prediction_loss_only: Trueeval_on_start: Trueeval_do_concat_batches: Trueeval_use_gather_object: Falseeval_accumulation_steps: Noneinclude_for_metrics: []batch_eval_metrics: Falsesave_only_model: Falsesave_on_each_node: Falseenable_jit_checkpoint: Falsepush_to_hub: Truehub_private_repo: Nonehub_model_id: aditeyabaral/langcache-colbert-v1-4gpuhub_strategy: every_savehub_always_push: Falsehub_revision: Noneload_best_model_at_end: Trueignore_data_skip: Falserestore_callback_states_from_checkpoint: Falsefull_determinism: Falseseed: 42data_seed: Noneuse_cpu: Falseaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedataloader_drop_last: Truedataloader_num_workers: 0dataloader_pin_memory: Truedataloader_persistent_workers: Falsedataloader_prefetch_factor: Noneremove_unused_columns: Truelabel_names: Nonetrain_sampling_strategy: randomlength_column_name: lengthddp_find_unused_parameters: Trueddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falseddp_backend: Noneddp_timeout: 1800fsdp: []fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}deepspeed: Nonedebug: []skip_memory_metrics: Truedo_predict: Falseresume_from_checkpoint: Nonewarmup_ratio: Nonelocal_rank: -1prompts: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | Validation Loss | accuracy |
|---|---|---|---|---|
| 0 | 0 | - | 1261.8169 | 0.8206 |
| 0.1322 | 1000 | 100.6328 | - | - |
| 0.2644 | 2000 | 0.6220 | - | - |
| 0.3966 | 3000 | 0.5276 | - | - |
| 0.5288 | 4000 | 0.7564 | - | - |
| 0.6609 | 5000 | 0.5519 | - | - |
| 0.7931 | 6000 | 1.8754 | - | - |
| 0.9253 | 7000 | 4.2339 | - | - |
| 1.0575 | 8000 | 1.8449 | - | - |
| 1.1897 | 9000 | 1.6022 | - | - |
| 1.3219 | 10000 | 1.4372 | - | - |
| 1.4541 | 11000 | 1.2331 | - | - |
| 1.5863 | 12000 | 1.1511 | - | - |
| 1.7184 | 13000 | 1.0779 | - | - |
| 1.8506 | 14000 | 1.0823 | - | - |
| 1.9828 | 15000 | 0.9632 | - | - |
| 2.1150 | 16000 | 0.8800 | - | - |
| 2.2472 | 17000 | 0.8625 | - | - |
| 2.3794 | 18000 | 0.8055 | - | - |
| 2.5116 | 19000 | 0.6943 | - | - |
| 2.6438 | 20000 | 0.7342 | - | - |
| 2.7759 | 21000 | 0.7034 | - | - |
| 2.9081 | 22000 | 0.6930 | - | - |
| 3.0403 | 23000 | 0.6543 | - | - |
| 3.1725 | 24000 | 0.6544 | - | - |
| 3.3047 | 25000 | 0.5769 | - | - |
| 3.4369 | 26000 | 0.5262 | - | - |
| 3.5691 | 27000 | 0.5684 | - | - |
| 3.7013 | 28000 | 0.5433 | - | - |
| 3.8334 | 29000 | 0.5481 | - | - |
| 3.9656 | 30000 | 0.5552 | - | - |
| 4.0978 | 31000 | 0.5399 | - | - |
| 4.2300 | 32000 | 0.5605 | - | - |
| 4.3622 | 33000 | 0.5385 | - | - |
| 4.4944 | 34000 | 0.4941 | - | - |
| 4.6266 | 35000 | 0.5287 | - | - |
| 4.7588 | 36000 | 0.5289 | - | - |
| 4.8909 | 37000 | 0.5502 | - | - |
@inproceedings{reimers-2019-sentence-bert,
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
author = "Reimers, Nils and Gurevych, Iryna",
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
month = "11",
year = "2019",
publisher = "Association for Computational Linguistics",
url = "https://arxiv.org/abs/1908.10084"
}
@inproceedings{DBLP:conf/cikm/ChaffinS25,
author = {Antoine Chaffin and
Rapha{"{e}}l Sourty},
editor = {Meeyoung Cha and
Chanyoung Park and
Noseong Park and
Carl Yang and
Senjuti Basu Roy and
Jessie Li and
Jaap Kamps and
Kijung Shin and
Bryan Hooi and
Lifang He},
title = {PyLate: Flexible Training and Retrieval for Late Interaction Models},
booktitle = {Proceedings of the 34th {ACM} International Conference on Information
and Knowledge Management, {CIKM} 2025, Seoul, Republic of Korea, November
10-14, 2025},
pages = {6334--6339},
publisher = {{ACM}},
year = {2025},
url = {https://github.com/lightonai/pylate},
doi = {10.1145/3746252.3761608},
}
<!--
## Glossary
*Clearly define terms in order to be accessible across audiences.*
-->
<!--
## Model Card Authors
*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
-->
<!--
## Model Card Contact
*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
-->