| # mlx7-two-tower-retrieval | |
| This repository contains models trained using the Two-Tower (Dual Encoder) architecture for document retrieval. | |
| ## Model Description | |
| The Two-Tower model is a dual encoder neural network architecture designed for semantic search and document retrieval. It consists of two separate "towers" - one for encoding queries and one for encoding documents - that map text to dense vector representations in a shared embedding space. | |
| ## Usage | |
| ```python | |
| from twotower import load_model_from_hub | |
| from twotower.encoders import TwoTower | |
| from twotower.tokenisers import CharTokeniser | |
| # Load the model | |
| model, tokenizer, config = load_model_from_hub( | |
| repo_id="mlx7-two-tower-retrieval", | |
| model_class=TwoTower, | |
| tokenizer_class=CharTokeniser | |
| ) | |
| # Use for document embedding | |
| doc_ids = tokenizer.encode("This is a document") | |
| doc_embedding = model.encode_document(doc_ids) | |
| # Use for query embedding | |
| query_ids = tokenizer.encode("This is a query") | |
| query_embedding = model.encode_query(query_ids) | |
| ``` | |
| ## Training | |
| This model was trained on the MS MARCO dataset using the Two-Tower architecture with contrastive learning. | |
| ## Repository Information | |
| This model is part of the [Two-Tower Retrieval Model](https://github.com/yourusername/two-towers) project. | |