Landmark Embedding: A Chunking-Free Embedding Method For Retrieval Augmented Long-Context Large Language Models (2024)

Abstract: Retrieval augmentation is a promising approach to handle long-context language modeling. However, the existing retrieval methods usually work with the chunked context, which is prone to inferior quality of semantic representation and incomplete retrieval of useful information. In this work, we propose a new method for the retrieval augmentation of longcontext language modeling, called Landmark Embedding. Our method is characterized by threefold technical contributions. Firstly, we introduce a chunking-free architecture, which keeps the long context coherent such that highquality embeddings can be generated for the fine-grained units within the context. Secondly, we present a position-aware objective function, which prioritizes the ultimate boundary for a consecutive span of information. By learning to discriminate such a special position, the useful information can be comprehensively retrieved for the query. Thirdly, we design a novel multistage learning algorithm, which makes the best use of readily available data and synthetic data for cost-effective training of the landmark embedding. In our experimental study, landmark embedding is able to substantially improve the performance for both LLaMA-2 and ChatGPT in a variety of long-context tasks; meanwhile, it also outperforms the existing retrieval methods with a notable advantage. Our model and code will be made publicly available1.

heading: 1 Introduction
text: Large language models (LLMs) need to handle long-sequence inputs when dealing with many important applications, such as question answering and reading comprehension (Bai et al., 2023). Unfortunately, the existing LLMs are usually constrained by a limited size of context window, e.g., 2K for LLaMA-1 (Touvron et al., 2023a) and 4K for LLaMA-2 (Touvron et al., 2023b). Although
†. Corresponding author 1. https://github.com/FlagOpen/FlagEmbedding
Bill paid a visit to Eiffel Tower on Sunday. Mesmerized by the architectural marvel, he spent the morning exploring its details and taking in breathtaking views of the city. After a delightful lunch, he joined with his friends.
They went to Louvre Museum together.
Bill paid a visit to Eiffel Tower on Sunday. Mesmerized by the architectural marvel, he spent the morning exploring its details and
taking in breathtaking views of the city. After a delightful lunch, he joined with his friends.
They, went to Louvre Museum together.
the size of context window can be extended through fine-tuning over long-sequence data (Chen et al., 2023b; Dacheng et al., 2023; Peng et al., 2023), the fine-tuned model could incur a considerable cost in both training and inference, and exerts an unfavorable impact to LLMs’ original capabilities. Recently, the retrieval-augmentation emerges as a promising option to facilitate long-context language modeling (Xu et al., 2023; Bai et al., 2023; Zhang et al., 2023a). It employs a standalone retriever where useful information can be filtered and presented as a concise input. The above working mechanism is simple, efficient, and wellcompatible with the downstream LLMs.
With a long-sequence input, the typical retrieval augmentation workflow is performed with three steps: 1) chunking, 2) embedding, and 3) retrieval. In the first place, it partitions the long-sequence input into a list of chunks. Then, it encodes each chunk into its embedding. Finally, it retrieves the useful chunks for the query based on the embedding similarity. The chunking strategy is a very tricky problem in practice. As widely discussed by many popular RAG frameworks, like Langchain (LangChain, 2023), LlamaIndex (Liu,
3268
2023), Pincone (Schwaber-Cohen, 2023), this problem is usually tackled by empirical or heuristic methods. However, no matter what chunking strategy is used, two inherent limitations are inevitable. On one hand, the input sequence is partitioned into disconnected chunks. Consequently, it will break the coherence of context which is unfavorable to the quality of embedding. On the other hand, it is also likely to split the consecutive information into different chunks. The salient chunks can be easily retrieved; nevertheless, other useful but less salient chunks can be overlooked, which results in the incomplete retrieval of necessary information.
In this paper, we come up with the Landmark Embedding, a new embedding method optimized for the retrieval-augmentation of long-context language modeling. The new method is highlighted by its technical contributions in three perspectives.
Firstly, we introduce a chunking-free model architecture, where embeddings for the fine-grained input units, e.g., sentences, can be generated based on a coherent long context. The new architecture employs a group of special tokens, namely the landmarks (LMK), and dispatches them to the end of each sentence. At the same time, it takes advantage of an LLM-based encoder to jointly process the landmarked long context. Thanks to the perception of rich contextual information, the landmark embedding can be a highly discriminative representation of each sentence, which presents a critical improvement over the conventional sentence embeddings generated from a chunked context. Besides, the new architecture will resort to a sliding window, where landmark embeddings can be generated for an arbitrary long context via stream processing.
Secondly, we propose a position-aware objective function to facilitate the complete retrieval of useful information. As discussed, one piece of information tends to be jointly conveyed by multiple consecutive sentences within the long context. Instead of treating them equally as positive samples, we assign each sentence with a differentiated weight which grows exponentially with its position in the context. As a result, the last sentence, i.e. the ultimate boundary of the information, will be emphasized and better discriminated. With the jointly selection of the front-k sentences before the ultimate boundary, the useful information to the query can be comprehensively included.
Thirdly, we design a multi-stage learning algorithm, where different training strategies and data
sources can be jointly used to facilitate the training of landmark embedding. The typical embedding model is trained by paired texts, e.g., question answering; however, such data is not directly suitable for our scenario. To address this problem, the new algorithm factorizes landmark embedding with two basic capabilities: the fundamental semantic discriminability, and the high-level contextualized representation capability, which can be progressively established in three steps: 1) distant supervision over pairwise data, 2) weak supervision over noisy long-context data generated by rules, 3) fine-tuning over high-quality long-context data synthesized by LLMs. The above workflow can make the best use of readily available data (adequate but less relevant) and synthetic data (relevant but inadequate), which leads to a superior cost-effectiveness of training.
We empirically analyze landmark embedding based on 2 popular LLMs: LLaMA-2-7B (chat) with a short context window (4K), ChatGPT-3.5 (turbo) with a much longer context window (16K). The experiment is performed on top of 6 longcontext evaluation datasets. Most of the evaluation samples are far beyond the coverage of the 4K context window, while a large portion of them are within the 16K context window. In our experiment, landmark embedding achieves a substantial advantage over both the LLaMA-2-7B baseline and the retrieval-augmentation results powered by the existing retrieval methods. Meanwhile, it also notably improves the performance of ChatGPT-3.5 using a much shorter input context. Such a result overturns the previous conclusion that retrieval-augmentation can only benefit the LLMs of weak long-context capabilities (Bai et al., 2023), which indicates a more extensive usage of the corresponding techniques.
To summarize, the following contributions are made in this work. 1) We propose landmark embedding. To the best of our knowledge, it is the first embedding model which performs systemic optimization for the retrieval augmented long-context language modeling. 2) Our method presents three technical advantages: the chunking-free model architecture, the position-aware objective function, and the multi-stage learning algorithm, which jointly contribute to the superior capability of our embedding model. 3) We perform comprehensive experiments with LLaMA-2 and ChatGPT, whose result verifies the effectiveness of landmark embedding, and indicates a broader application scope of retrieval techniques in dealing with the long-context tasks.

heading: 2 Related Work
text: The related works are reviewed from three aspects: long-context language modeling, retrievalaugmentation, embedding-based retrieval methods.
First of all, a large body of research works has been dedicated to the extension of LLMs’ lengths from different directions. One common practice is to modify the position encoding mechanism, where the LLMs trained on short texts can directly handle longer input during the inference time (Chen et al., 2023a; ntk, 2023). Despite simplicity, such methods are prone to inferior performances without further fine-tuning. Another popular method is to take advantage of continual training, where the existing LLMs are fine-tuned over long-sequence data to establish a longer context window (Dacheng et al., 2023; Chen et al., 2023b; Peng et al., 2023; Tworkowski et al., 2023; Mohtashami and Jaggi, 2023). However, the fine-tuning based methods are prone to two subsequent problems. On one hand, the fine-tuned LLM will incur an expensive cost for both training and inference. On the other hand, the fine-tuning operation could be unfavorable to the LLM’s performance with short-sequence inputs. Apart from the above common approaches, the LLM’s context can also be extended by context compression (Chevalier et al., 2023; Zhang et al., 2024) and stream processing (Xiao et al., 2023a; Han et al., 2023). Nevertheless, the compression methods are likely to result in information loss, while the stream processing will discard the useful information beyond the sliding window. It remains to explore more effective methods for long-context language modeling in the future.
In the meantime, the retrieval-augmented generation (RAG) is another important issue for LLMs’ research. Typically, it employs a standalone retriever, where useful information can be introduced from a vast open-world corpus to enhance the LLM’s generation quality (Lewis et al., 2020; Guu et al., 2020; Borgeaud et al., 2022). Previously, RAG used to be applied for knowledge-intensive tasks, such as open-domain question answering and fact verification (Petroni et al., 2020), where an external knowledge base is presented. Recently, retrieval augmentation is also found helpful to long-context language modeling, as useful information can be retrieved and presented as a concise input for the LLM (Xu et al., 2023; Bai et al., 2023; Zhang et al., 2023b). Compared with other alternative methods on context extension, the retrieval-based
methods are distinguished for the simplicity and compatibility, as they don’t need modification of the downstream LLM, and can be easily combined with other methods to establish a longer context.
Finally, the RAG system usually works with an embedding model to retrieve the useful information. In the past few years, many critical techniques have been well established for the effective learning of embedding models, e.g., pre-training (Gao and Callan, 2021; Xiao et al., 2022, 2023b; Wang et al., 2022a; Li et al., 2023), hard-negative sampling (Xiong et al., 2020; Ren et al., 2021), knowledge distillation (Hofstätter et al., 2020; Chen et al., 2024), etc. On top of these techniques, there have been a number of powerful embedding models developed for the general-purpose retrieval applications (Izacard et al., 2021; Ni et al., 2021; Neelakantan et al., 2022; Wang et al., 2022b; Xiao et al., 2023c). However, the existing methods rely on chunking when dealing with the retrieval augmentation of long-context language modeling. As a result, it will inevitably break the coherence of context, which is prone to inferior quality of embedding and incomplete retrieval of useful information.

heading: 3 Landmark Embedding

heading: 3.1 Preliminary
text: The LLM presents a unified foundation to solve arbitrary NLP tasks through language modeling. Given the input prompt, the LLM optimizes the generation likelihood of the target answer (X) in the form of auto-regression. For a wide variety of applications, e.g., question answering and reading comprehension, the input prompt can be explicitly split into context (ctx) and query (q). Without loss of generality, the LLM’s generation objective can be presented as the following function:
max. log LLM(xt|q, ctx,X<t). (1)
In many situations, the input context is too long to fit into existing LLM’s context window. To address this problem, the retrieval-based method seeks to compress the context by selecting the most useful parts from it. Typically, it will chunk the context into: S : {s1, ..., sN} ← chunk(ctx), and select the top-k chunks based on a retrieval model γ(·):
S∗ : {s1, ..., sk} ← top-k.{s : γ(q, s)|S}. (2)
One critical step for the above workflow is chunking. As introduced, the chunking operation is very
tricky, which needs to be conducted empirically or heuristically. It will always break the coherence of context, leading to an inferior embedding quality and a higher probability of incomplete retrieval. In this work, we target on a new retrieval method γ′(·) without the dependency on chunking operation. Notably, it will let the useful information to be directly retrieved from a coherent context:
C∗ : {c1, ..., ck} ← γ′(q, ctx). (3)
In this place, ci indicates a fine-grained unit of the input context, e.g., a sentence. With the perception of contextual information, the underlying semantics about each fine-grained unit can be effectively represented, which facilitates the accurate retrieval of relevant information for the query.

heading: 3.2 Chunking-Free Architecture
text: We propose a novel embedding model, whose architecture is shown in Figure 2. Suppose the input context is composed of n sentences: ctx : {c1, ..., cn}. Instead of chunking the input context into disconnected segments, it dispatches a special token, called the landmark (LMK), to the end of each sentence. The landmark is used to capture the underlying semantics for its corresponding sentence. Particularly, the landmark is jointly encoded with the sentence and neighboring context, where the output embedding, a.k.a. the landmark embedding (LE), is utilized for representation of the sentence. In our work, we take advantage of a large language model (e.g., LLaMA-2-7B) as the encoding backbone, which brings forth two benefits: 1) it substantially contributes to the quality of representation thanks to the LLM’s superior expressiveness, 2) it can incorporate adequate neighboring context based on the LLM’s long context window. The same encoder is also utilized for the generation of query’s embedding. Formally, the generation of landmark embedding and query embedding are presented by the following functions:
LEi ← LLM(c1, ..., ci; LMK).embed[−1], Eq ← LLM(query; LMK).embed[−1].
Based on the results presented, the relevance between the query and each sentence is calculated using the inner product of their respective embeddings: ⟨Eq,LEi⟩. In generating the landmark embedding for a sentence, we exclusively consider the preceding context. This approach is consistent with the foundational pretraining methodology of
It’s a long context ... The i-th span. <LMK> ... The n-th span. <LMK>
… …
LE1 LEi LEn
Query embedding
… …
the LLaMA model, which utilizes causal attention mechanisms.
Note that the input context can be even longer than the LLM’s context window. To handle this problem, we leverage a sliding window where the long context can be streamingly processed. In this situation, the generation of landmark embedding will be conducted as:
LEi ← LLM(ci−l, ..., ci; LMK).embed[−1],
where l indicates the number of sentences within the current sliding window.

heading: 3.3 Position-Aware Objective
text: The landmark embedding is learned by contrastive learning, where the query and its relevant sentences can be distinguished by the higher embedding similarities. The useful information to the query tends to gather as multiple consecutive sentences within the context: {cz−m, ..., cz}, where m is the number of consecutive sentences relevant to the target query. As a result, we can derive the following general form of loss function for the contrastive learning:
min.− ∑
q
∑ i≤m lg exp(⟨Eq,LEz−i⟩)∑ j=1...n exp(⟨Eq,LEj⟩) . (4)
With the above formulation of loss function, the landmark of each relevant sentence is assigned with a positive label of equal importance. Nevertheless, the basic formulation is problematic knowing that it may let the most salient sentence (e.g., the one with the most overlapping keywords with the query) get the highest similarity. In our work, we target on the complete retrieval of useful information. Therefore, we make an emphasis on
the ultimate boundary where the whole consecutive sentences can be comprehensively included. Although it may simply assign the last landmark with a positive label, we propose to leverage all landmarks because of their valid relevance with the query. Particularly, we differentiate their importance by introducing the positional weight wi for sentence cz−i: wi ← exp(−α ∗ i), where α is the temperature parameter(set to 0.08 in practice). Based on the positional weight, we modify the basic contrastive learning with the position-aware objective function:
min.− ∑
q
∑ i≤m lg wi ∗ exp(⟨Eq,LEz−i⟩)∑ j=1...n exp(⟨Eq,LEj⟩) . (5)
The position-aware objective presents two benefits: 1) the relevant sentences can be fully utilized for the training of landmark embedding, 2) the ultimate boundary of the useful information can be emphasized and better discriminated.

heading: 3.4 Multi-Stage Learning
text: The typical training data of embedding model consists of paired texts, e.g., question and answer, which is seemingly inappropriate for the training objective in Eq 5. However, we argue that the functionality of landmark embedding can be factorized with two fundamental capabilities: 1) the basic semantic discriminability, 2) the contextualized representation capability, i.e., representing each sentence w.r.t. its context. Based on this argument, we design the multi-stage learning algorithm, which enables the two capabilities to be progressively established on top of proper training data. In the first place, the landmark embedding is initialized as a general sentence-level embedding model. Afterwards, it is enhanced as a contextual representation model where discriminative embeddings can be generated for its included sentences. The progressive training takes place with three steps. • Distant supervision. Firstly, we make use of the pairwise training data from MS MARCO (Nguyen et al., 2016), based on which the model can be initialized as a basic sentence embedder. In this place, the landmark embedding takes a special form as only one single landmark is appended to the end of answer’s context: LEa ← LLM(answer; LMK).embed[−1]. The first-stage training follows the basic training form of dense retrieval, where 15 hard negatives together with the in-batch negatives are presented for each query.
It’s a long context ... The i-th sent. <LMK> ... The n-th sent. <LMK>
… …
LE1 LEi LEn
… …
• Weak Supervision. In the second step, we make a simple modification of the pairwise training data where the model can be trained to generate discriminative sentence embeddings within a long context. Particularly, we randomly shuffle the answers from different queries, and merge them as one pseudo long document (left half of Figure 3). Therefore, the embedding for the i-th answer can be generated as: LEai ← LLM(aj ̸=i, ..., ai; LMK).embed[−1]. The second stage still relies on in-batch negatives, where the landmark embeddings from other answers LEaj ̸=i are utilized as the negative samples. • Fine-Tuning. We leverage synthetic data for the final stage of fine-tuning. In this step, we make use of the real-world long documents from Wikipedia(Foundation). For each long-document, a series of text spans are randomly sampled, where pseudo queries are generated by prompting the LLM2. The synthesized data will incur an extra cost due to the calling of LLM API. Besides, it may also be distinct from the real-world data distribution. Therefore, only a small amount of synthetic data is generated for the final training stage. However, thanks to the fundamental capabilities established in the first two stages, landmark embedding can achieve a superior performance after moderate fine-tuning. Detailed information of training data and curating method is shown in Appendix A

heading: 4 Experiment
text: The experimental study focuses on the following three research questions. RQ 1. The exploration of landmark embedding’s impact on the retrieval augmentation of long-context language modeling.
2. We make use of ChatGPT-35-turbo’s API in this work: https://openai.com/blog/chatgpt
RQ 2. The comparison between landmark embedding and the existing retrieval methods based on chunked contexts. RQ 3. The analysis of technical factors in landmark embedding.

heading: 4.1 Settings
text: We utilize two popular LLMs for RAG in our experiment. One is the LLaMA-2-7B (chat) model. It is a lightweight open-source LLM, whose context length is 4K. The other one is the ChatGPT-3.5 (turbo). It is a more powerful but closed-source LLM, whose context length is 16K. The evaluations are performed with the following long-context language understanding datasets from LongBench (Bai et al., 2023), where explicit queries are available for the evaluation samples: NarrativeQA (Kočiskỳ et al., 2018), Qasper (Dasigi et al., 2021), MultifieldQA (Bai et al., 2023), HotpotQA (Yang et al., 2018), 2WikiMQA (Ho et al., 2020), MuSiQue (Trivedi et al., 2022). The first three datasets are about single-doc QA where the useful information is concentrated in the long context. The last three datasets are about multi-doc QA where useful information may exist in different parts of the long context. We follow LongBench(Bai et al., 2023) using F1 score as the evaluation metric. It is worth noting that the above datasets are differentiated in their sequence lengths. As demonstrated by Figure 4, the majority of evaluation samples are longer than 4K, which is far beyond the context length of LLaMA-2. However, many of them are shorter than 16K, especially for Qasper, MultifieldQA, 2WikiMQA, and HotpotQA,
which is within the coverage of ChatGPT-3.5-turbo. We consider the following baseline methods. 1) Contriever (Izacard et al., 2021), 2) OpenAI Text Embedding (Ada-002) (Neelakantan et al., 2022), 3) BGE-v1.5-large (Xiao et al., 2023c), 4) E5Mistral (Wang et al., 2023). Notably, E5-Mistral is the state-of-the-art text embedding model upon the time of this paper. It is trained from a Mistral7B model (Jiang et al., 2023), which achieves the leading performance on MTEB benchmark (Muennighoff et al., 2023) with an overwhelming advantage. The baseline retrievers utilize two alternative chunking strategies. One is chunking by sentences; the other one is chunking by equal-sized text spans. In our work, each text span is made up of 200 words as empirically determined by Longbench (Bai et al., 2023). The baselines will select the top-N chunks for each query, and will take their front and back sentences together as evidence for retrieval augmentation. We select top-7 chunks for span-based chunking and top-15 chunks for sentence-based chunking, which leads to similar context lengths. As landmark embedding is to identify the ultimate boundary of information, it will retrieve the font two sentences together with its top-N results.
Landmark embedding is based on a LLaMA-27B backbone (Touvron et al., 2023b), whose context is extended to 32K by LongLora (Chen et al., 2023b). All training operations take place on a single 8×A100 (40GB) GPUs. The learning rate is 1×10−4, the weight decay is 1×10−6. The batch size for the 1st-stage training is 32; the batch size for the 2nd and 3rd stage training is 1, where we accumulate the gradient over 64 steps. We leverage Flash-attention-v2 (Dao, 2023), Gradient Checkpointing (Chen et al., 2016), and Deepspeed-Zero (Rajbhandari et al., 2020) to speed up the training.

heading: 4.2 Main Result
text: The experiment result on retrieval augmented longcontext language modeling is presented in Table 2, where the following observations can be made.

heading: 4.2.1 Analysis on retrieval augmentation
text: Our method achieves a remarkable retrieval augmentation effect, as it consistently outperforms the basic LLaMa-2-7B, i.e., w/o retrieval, in every evaluation task, which ultimately results in a remarkable improvement of +8.8 points in terms of the average performance. At the same time, our method also brings forth the biggest improvement in comparison with other baseline retrievers.
The retrieval-augmentation’s impact is relatively smaller with ChatGPT-3.5, as most of the baseline retrievers are unable to improve the performance of w/o retrieval. Such an observation is consistent with the reported result in recent study (Xu et al., 2023), and it is intuitive to understand this result considering that the context length of ChatGPT3.5 is expanded to 16K. With such a large context window, ChatGPT can intake more than 15K input tokens for each evaluation sample, whereas the retrieval augmentation methods only utilize about 2K input tokens. In many situations, the evaluation samples can almost be fully covered by such a long context window (Figure 4), which means the retrieval methods can hardly introduce extra information outside ChatGPT’s context.
Despite these challenges, our method can still outperform ChatGPT-3.5, which leads to a +2.9 points improvement in the average performance. It consistently outperforms ChatGPT in the multidoc QA tasks, i.e. HQA, 2WIKI, MSQ; mean-
while, it achieves improved or comparable performances in the single-doc QA tasks. The distinction between the two tasks is probably because the useful information tends to be more scattered and exists within multiple documents in the multidoc scenario, while it is more concentrated in the single-doc scenario. It is also worth noting that our method only works with 2,190 input tokens, which is much less than the 15,500 tokens used by ChatGPT. In other words, its empirical advantage is achieved along with a higher running efficiency.

heading: 4.2.2 Pilot analysis on retrieval
text: In addition to the end-to-end performance on the above long-context tasks, we conduct pilot experiments for more detailed analysis about the retrieval accuracy. In Table 3, we leverage the hold-back test set of the synthetic data from Wikipedia for evaluation (1000 samples in total). We also curate the synthetic testing samples based on ArXiv(Clement et al., 2019) documents (500 samples in total), which will reflect the retriever’s generalization with
the o.o.d. corpus. For both datasets, our method can achieve a much higher retrieval accuracy than the baseline retrievers which rely on the chunked context. Besides, we also perform the needle in a haystack test as Figure 5, where the ground-truth document span is randomly placed in 30K context (Liu et al., 2023; Ivgi et al., 2023). Detailed setting is described in Appendix B. We compare two alternative formulations of landmark embedding: one works with the sliding window, and the other one directly generates the landmark embeddings from the LLM’s context (denoted as FullAttention). Although the pre-trained backbone encoder is extended to 32K by LongLora, the training of the embedding model is mostly conducted within 8K (Table 1). Two alternatives result in comparable performances when the ground-truth position is small. However, the Full-Attention method decreases dramatically after the ground-truth position goes beyond the valid fine-tuning scope. In contrast, the default method with the sliding window can always maintain a high retrieval accuracy.
In brief, landmark embedding exhibits a major advantage over the baseline retrievers. It substantially improves the performance of LLaMA-2-7B whose context length is small. Besides, it further benefits the performance of ChatGPT-3.5 and helps to reduce its computation cost by a big margin.

heading: 4.3 Ablation Study
text: The ablation study is performed to explore the critical factors of landmark embedding, where the default settings are marked by * (Table 4). In the first place, we analyze the impact from positionaware objective (§3.3). For comparison, we disable the positional weight in Eq. 5 and switch to the basic objective in Eq. 4, denoted by w/o Positionaware. The position-ware objective function is to train landmark embedding as an indicator of the information’s ultimate boundary. Therefore, it is
applied with the Front-k retrieval scheme, where the targeted sentence and its front k − 1 neighbors are retrieved together. In contrast, the Surround-k method makes selection for the (k − 1)/2 neighbors from both sides of the targeted sentence. According to the evaluation result, the position-aware objective with Front-k outperforms the ablation baselines in the downstream language modeling tasks, which indicates its more accurate retrieval of useful information from the long context. Besides, it can also be observed that applying Front-k alone does not bring any empirical benefit, as the basic objective focuses more on the salient part of the information rather than its ultimate boundary.
We make further analysis for the impact of multistage learning. In our experiment, we apply each individual training stage alone (I: distant supervision, II: weak supervision, III: fine-tuning), and make arbitrary combinations of different stages. As we can observe from the evaluation result, the third stage, i.e. the fine-tuning over synthetic data, presents the highest individual training effect. This result can probably be attributed to its closest relationship with the downstream task. However, the other two training stages are also beneficial. With the joint conduct of all three training stages, optimal empirical performance can be acquired.

heading: 5 Conclusion
text: In this paper, we present a new method, landmark embedding, which facilitates the retrieval augmentation of long-context language modeling. The new method is featured by its chunking-free architecture, where discriminative embeddings can be generated for each fine-grained input unit based on the semantic information within a coherent context. A position-aware objective function is proposed; it enables landmark embedding to identify the ultimate boundary of information, which benefits the completeness of retrieval. A novel multi-stage
learning algorithm is designed, which makes the best of the readily available data and synthetic data for the effective training of the embedding model. Landmark embedding is empirically verified by comprehensive evaluations, where it notably outperforms the existing retrieval methods, bringing in a superior retrieval augmentation effect for both LLaMA-2-7B (4K) and ChatGPT-3.5 (16K).

heading: 6 Limitation
text: While Landmark Embedding achieves substantial progress in long-context retrieval augmentation, computational limitations have necessitated the use of a relatively small encoding backbone (7B) during the experimental phase. It is anticipated that the proposed technique could yield even better performance with future scalability enhancements. Additionally, there is potential for further exploration into the capacity and methods for Landmark Embedding to process longer texts, including those of unlimited length, multi-sourced scenarios. Deeper exploration into more efficient methods for curating high-quality synthetic data can also be pursued in the future.

heading: 7 Ethical consideration
text: Landmark Embedding builds upon the foundation of the open-source LLM, specifically LLaMA-27B(Touvron et al., 2023b) (with an extended context window using LongLoRA(Chen et al., 2023b)). Consequently, it inherits similar ethical and social risks, such as bias, discrimination, and toxicity, as those associated with LLaMA-2. In particular, open-source LLMs may involve the incorporation of private or contentious data during the training phase. The usage of synthetic data may also lead to potential bias during retrieval process.

heading: 8 Ackonwledgements
text: This work was supported by the Strategic Priority Research Program of Chinese Academy of Sciences (No. XDA27020203) and National Science and Technology Major Project (2023ZD0121504).

heading: A Detailed Training Data for Multi-Stage Learning
text: In this section, we present detailed information of training data for different learning stages and the method we adopt to curate synthetic data using realword long documents with the help of ChatGPT35-Turbo API3. Stage I and Stage II Training data. We use pairwise training data from MS MARCO (Nguyen et al., 2016). The total number of training set is 480k. To ensure a fair comparison between the effects of Stage I and Stage II, we partition the training data evenly into two distinct training stages. During Stage I, we leverage hard negative passages from dense retrieval to enhance the model’s performance. Specifically, each positive passage is paired with 15 hard negative passages during the training process. Moving to Stage II, we concatenate 40 hard negative passages and 120 passages randomly sampled from the corpus with ground truth passage inserted into it, forming composited long documents up to 16k context length. Synthetic Data Curating Method. In this section, we present the method for curating synthetic data, which facilitates Stage III fine-tuning. Firstly, we sample long documents from Wikipedia. Then we select a portion of it (e.g., 200 words) as the Background Text and then select consecutive 1-5 sentences randomly from this excerpt as the Ground Truth Text. We utilize the ChatGPT-35-Turbo API to ask questions about the Background Text, with the requirement that the answers must be contained within the Ground Truth Text. This approach ensures that the synthetic questions contain contextual information while maintaining their answers within smaller semantic segments. The details prompt for constructing synthetic data is shown in Figure 7. To make sure the synthetic data’s quality, we ask ChatGPT to generate concrete and valuable questions. If the provided text does not contain meaningful information, we will distinguish and filter it. Finally, we curate 90k real-word long document data with the generated question and related ground truth span for Stage III fine-tuning, the length distribution is shown in Figure 1

heading: B Needle in a Haystack Test
text: In this section, we present the detailed experimental setup for the Needle in a Haystack Test. As
3. https://openai.com/blog/chatgpt
illustrated in Figure 5, we conducted the experiment using the MS MARCO (Nguyen et al., 2016) development set. Specifically, we concatenated 40 hard negative passages and 280 randomly sampled passages from the corpus for each test data instance, creating composite long documents of up to 32k context length. Subsequently, we inserted the corresponding ground truth passage at a random position within the target insertion interval. An independent experiment was conducted for each 6k length insertion interval. Additionally, we utilized test data from NaturalQuestions (Kwiatkowski et al., 2019) under the same conditions, aiming to assess the model’s generalization with out-of-domain corpus. Similar findings were observed in the NaturalQuestions dataset. The results are shown in Figure 6

heading: Future Work
text: It is anticipated that the proposed technique could yield even better performance with future scalability enhancements. Additionally, there is potential for further exploration into the capacity and methods for Landmark Embedding to process longer texts, including those of unlimited length, multi-sourced scenarios. Deeper exploration into more efficient methods for curating high-quality synthetic data can also be pursued in the future