[Paper Review] Jina Embeddings 2: 8192-Token General-Purpose Text Embeddings for Long Documents
Jina Embeddings v2 introduces open-source BERT-based encoders capable of encoding up to 8192 tokens, improving long-document embeddings and matching state-of-the-art retrieval performance on MTEB while maintaining strong GLUE results.
Text embedding models have emerged as powerful tools for transforming sentences into fixed-sized feature vectors that encapsulate semantic information. While these models are essential for tasks like information retrieval, semantic clustering, and text re-ranking, most existing open-source models, especially those built on architectures like BERT, struggle to represent lengthy documents and often resort to truncation. One common approach to mitigate this challenge involves splitting documents into smaller paragraphs for embedding. However, this strategy results in a much larger set of vectors, consequently leading to increased memory consumption and computationally intensive vector searches with elevated latency. To address these challenges, we introduce Jina Embeddings 2, an open-source text embedding model capable of accommodating up to 8192 tokens. This model is designed to transcend the conventional 512-token limit and adeptly process long documents. Jina Embeddings 2 not only achieves state-of-the-art performance on a range of embedding-related tasks in the MTEB benchmark but also matches the performance of OpenAI's proprietary ada-002 model. Additionally, our experiments indicate that an extended context can enhance performance in tasks such as NarrativeQA.
Motivation & Objective
- Address the challenge of representing long documents with fixed-size embeddings without truncation or excessive vector proliferation.
- Develop and fine-tune a family of 8192-token capable encoder models based on a modified BERT backbone.
- Leverage ALiBi bidirectional attention to enable long-context encoding without traditional positional embeddings.
- Demonstrate the embeddings’ effectiveness across retrieval, clustering, and long-document tasks on standard benchmarks.
- Make the models and datasets available through Hugging Face for broad accessibility.
Proposed method
- Modify a BERT-like backbone to support up to 8192 tokens using ALiBi bidirectional attention in the encoder, replacing standard positional embeddings.
- Pre-train on the English C4 corpus with masked language modeling (MLM) and no NSP, using whole-word masking and a 30% masking rate.
- Fine-tune embeddings in two stages: (a) text-pair contrastive fine-tuning to produce single-vector representations with mean pooling; (b) hard-negatives supervised fine-tuning to improve ranking and retrieval performance.
- Utilize InfoNCE-based losses for pairing and cross-pair directions, with a temperature τ = 0.05 and bidirectional objectives.
- Adopt large-batch training with mixed precision and DeepSpeed, plus activation checkpointing to manage memory.

Experimental results
Research questions
- RQ1Can ALiBi-based bidirectional attention enable bi-encoder embeddings of long documents without 512-token truncation?
- RQ2Do 8192-token embeddings outperform previous open-source models on the MTEB benchmark and approximate OpenAI’s ada-002 performance?
- RQ3How does increasing context length affect downstream tasks like NarrativeQA and long-document clustering/retrieval?
- RQ4What is the impact of a two-stage fine-tuning (text pairs and hard negatives) on retrieval and non-retrieval tasks?
- RQ5Are the Jina Embeddings v2 models open-source and usable via Hugging Face with competitive performance across benchmarks?
Key findings
- The 8192-token Jina BERT-based encoders achieve state-of-the-art results on multiple MTEB tasks and rival ada-002 on the benchmark.
- ALiBi bidirectional attention enables long-context encoding without positional embeddings and maintains MLM accuracy up to 8192 tokens.
- Long-context fine-tuning with hard negatives improves retrieval and ranking performance across retrieval-focused tasks.
- Large-context evaluations show enhanced performance on narratives like NarrativeQA and on long-document clustering tasks, with some tasks showing mixed effects depending on document structure.
- The models and datasets are released on Hugging Face for open access.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.