Sentence Similarity
Safetensors
sentence-transformers
PyLate
lfm2
liquid
lfm2.5
edge
ColBERT
multi-vector
feature-extraction
custom_code
Run this model with HF Jobs
Run LiquidAI/LFM2.5-ColBERT-350M on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/LiquidAI/LFM2.5-ColBERT-350M. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/LiquidAI/LFM2.5-ColBERT-350M on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use LiquidAI/LFM2.5-ColBERT-350M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use LiquidAI/LFM2.5-ColBERT-350M with sentence-transformers:
from pylate import models queries = [ "Which planet is known as the Red Planet?", "What is the largest planet in our solar system?", ] documents = [ ["Mars is the Red Planet.", "Venus is Earth's twin."], ["Jupiter is the largest planet.", "Saturn has rings."], ] model = models.ColBERT(model_name_or_path="LiquidAI/LFM2.5-ColBERT-350M") queries_emb = model.encode(queries, is_query=True) docs_emb = model.encode(documents, is_query=False) - Notebooks
- Google Colab
- Kaggle
Fix transformers 5.x loading and add Sentence Transformers usage
Browse filesFiles changed (2)
18 unmodified lines19202122232475 unmodified lines10010110210310410510610710810911011111211311418 unmodified lines- ColBERT- PyLate- sentence-transformers- sentence-similarity- feature-extractionpipeline_tag: sentence-similarity75 unmodified lines<a href="https://colab.research.google.com/drive/1uLswYrRTNw4P2P2qZ8JG-b8j-KDkQqwL?usp=sharing"><img src="https://huggingface.co/proxy/cdn-uploads.huggingface.co/production/uploads/61b8e2ba285851687028d395/vlOyMEjwHa_b_LXysEu2E.png" width=120 alt="Colab link"></a>First, install the PyLate and transformers libraries:```bashpip install -U pylate```### RetrievalUse this model with PyLate to index and retrieve documents. The index uses [FastPLAID](https://github.com/lightonai/fast-plaid) for efficient similarity search.#### Indexing documents18 unmodified lines1920212223242575 unmodified lines10110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414518 unmodified lines- ColBERT- PyLate- sentence-transformers- multi-vector- sentence-similarity- feature-extractionpipeline_tag: sentence-similarity75 unmodified lines<a href="https://colab.research.google.com/drive/1uLswYrRTNw4P2P2qZ8JG-b8j-KDkQqwL?usp=sharing"><img src="https://huggingface.co/proxy/cdn-uploads.huggingface.co/production/uploads/61b8e2ba285851687028d395/vlOyMEjwHa_b_LXysEu2E.png" width=120 alt="Colab link"></a>### Using Sentence TransformersThis model can be used as a multi-vector (ColBERT-style late interaction) retriever directly with [Sentence Transformers](https://www.sbert.net/) via the `MultiVectorEncoder`.```bashpip install "sentence-transformers>=6.0.0"``````pythonfrom sentence_transformers import MultiVectorEncodermodel = MultiVectorEncoder("LiquidAI/LFM2.5-ColBERT-350M", trust_remote_code=True)query = "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.","Saturn, famous for its rings, is sometimes mistaken for the Red Planet.",]query_embeddings = model.encode_query([query])document_embeddings = model.encode_document(documents)print(query_embeddings[0].shape, document_embeddings[0].shape)# (32, 128) (17, 128)# MaxSim late-interaction scoring (the Mars document ranks highest)scores = model.similarity(query_embeddings, document_embeddings)print(scores)# tensor([[27.1628, 28.2510, 27.7368, 28.2090]])```### Using PyLateUse this model with PyLate to index and retrieve documents. The index uses [FastPLAID](https://github.com/lightonai/fast-plaid) for efficient similarity search. First, install PyLate and transformers:```bashpip install -U pylate```#### Indexing documents
70 unmodified lines7172737475767770 unmodified linespast_key_values=None,cache_position=None,attention_mask: Optional[torch.Tensor] = None,) -> torch.Tensor:# Only the flash_attention_2 path expects padding states zeroed before the# conv. On eager/sdpa the checkpoints were trained WITHOUT zeroing: under# transformers 4.56 the conv received the 4D additive mask, on which70 unmodified lines717273747576777879808170 unmodified linespast_key_values=None,cache_position=None,attention_mask: Optional[torch.Tensor] = None,**kwargs,) -> torch.Tensor:# transformers >=5.x passes seq_idx (packed-sample conv-state reset) to the conv. This full# sequence non-causal conv has no cache and no packing, so it is ignored, like the cache args# above. **kwargs absorbs it and any future additions rather than breaking on each new one.# Only the flash_attention_2 path expects padding states zeroed before the# conv. On eager/sdpa the checkpoints were trained WITHOUT zeroing: under# transformers 4.56 the conv received the 4D additive mask, on which
README.md+35-4
modeling_lfm2_bidirectional.py+4