---
title: "Packaging & Context Handling"
source: "https://systems-analysis.info/eng/Packaging_%26_Context_Handling"
wiki: "systems-analysis.info/eng"
article: "Packaging_&_Context_Handling"
language: "en"
categories:
  - "Category:English"
  - "Category:Large language models"
  - "Category:Prompt engineering"
  - "Category:Technology"
revision_id: 297
wiki_created_at: 2026-09-06T22:20:12Z
wiki_modified_at: 2026-09-06T22:20:12Z
downloaded_at: 2026-09-07T22:22:32Z
---

# Packaging & Context Handling

**Packaging & Context Handling** — a set of techniques for selecting, compressing, arranging, and delivering extracted knowledge fragments into the context of [LLMs](https://systems-analysis.info/eng/Large_language_model "Large language model") within [Retrieval-Augmented Generation](https://systems-analysis.info/eng/Retrieval-augmented_generation_(RAG) "Retrieval-augmented generation (RAG)") (RAG). The goal is to maximize the utility of a limited [token](https://systems-analysis.info/eng/Token_(LLM) "Token (LLM)") budget, improve accuracy and robustness of responses, and ensure traceable source citation. "Packaging" refers not only to forming a list of fragments but also to their compression, ordering, grouping, and model instructions, including *stuff*, *map-reduce*, *refine*, and *tree-of-chunks* strategies.<sup>[\[1\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-lewis2020-1)[\[2\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-langchain-sum-2)</sup>

## Definition and Motivation

In RAG systems, the quality of the final response is determined not only by retrieval but also by *how* the selected fragments are incorporated into the prompt. Context limitations and token costs require balancing between completeness and precision: excessive fragments increase the risk of *lost-in-the-middle* and extend latency, while aggressive filtering/compression may remove key evidence.<sup>[\[3\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-lostmiddle-3)</sup> In classic RAG, sources serve as external "non-parametric memory," providing relevance and citability when packaging allows the LLM to reliably operate with facts and references.<sup>[\[1\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-lewis2020-1)</sup>

## Chunking and Content Extraction

The segmentation policy (*chunking*) defines chunk size/overlap, normalization, and granularity (*document*→*passage*→*sentence*). Typical approaches:

- **Fixed-size rule** (by characters/tokens) with overlap to preserve coherence between chunks;<sup>[\[4\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-lc-splitters-4)[\[5\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-llama-splitters-5)</sup>
- **Semantic chunking** (boundaries based on [embedding](https://systems-analysis.info/eng/Embedding_(NLP) "Embedding (NLP)") similarity), reducing "meaning breaks."<sup>[\[6\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-llama-sem-6)</sup>
- **Sentence-window retrieval** — sentences are initially indexed; during retrieval, relevant sentences are extracted with a *window* of neighboring sentences before/after to restore local context.<sup>[\[7\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-haystack-sentwin-7)</sup>
- **Passage-level indexing** — splitting Wikipedia into ~100-word passages became standard in open QA (DPR), reflecting the benefit of fine granularity for initial stages.<sup>[\[8\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-dpr-8)</sup>
- **Normalization and cleaning** (removing noise, headers/footers, whitespace unification), tracking sources/pages/offsets at the metadata level for traceability.<sup>[\[9\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-haystack-pre-9)</sup>
- **Deduplication** of candidate chunks (exact and *near-duplicate*): shingles + MinHash/LSH to reduce repetition.<sup>[\[10\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-broder1997-10)</sup>

## Diversification and Selection (MMR and Others)

When forming the context set, high relevance and low redundancy are required. The classic Maximal Marginal Relevance function selects the next fragment considering proximity to the query and *maximum* similarity with already selected items (penalty for duplicates):

${MMR}(d_{i}) = \arg\max\limits_{d_{i} \in D \smallsetminus S}\left\lbrack \lambda \cdot {sim}(q,d_{i}) - (1 - \lambda) \cdot \max\limits_{d_{j} \in S}{sim}(d_{i},d_{j}) \right\rbrack,\ \lambda \in \lbrack 0,1\rbrack$.<sup>[\[11\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-mmr-11)</sup>

Combining signals: [hybrid retrieval](https://systems-analysis.info/eng/Hybrid_retrieval "Hybrid retrieval") (BM25 + dense) → fusion (e.g., Reciprocal Rank Fusion, RRF) → reranking with cross-[encoder](https://systems-analysis.info/eng/Encoder_(Transformer) "Encoder (Transformer)")/ColBERT:

- **RRF**: a simple and effective unsupervised scheme for merging rankings from heterogeneous retrievers.<sup>[\[12\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-rrf-12)</sup>
- **Cross-encoder rerankers** ([BERT](https://systems-analysis.info/eng/BERT_(language_model) "BERT (language model)")/MonoT5/modern commercial APIs) significantly improve [top-k](https://systems-analysis.info/eng/Top-k_sampling "Top-k sampling") precision but add latency.<sup>[\[13\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-nogueira2019-13)[\[14\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-cohere-rerank-14)</sup>
- **Multi-vector retriever** ColBERT (*late interaction*) often serves as an effective reranker/first-level retriever on large corpora.<sup>[\[15\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-colbert-15)</sup>
- **Hybrid search** (BM25F+vector) is implemented in industrial engines and libraries with configurable weight/fusion (alpha, RRF, etc.).<sup>[\[16\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-weav-hybrid-16)[\[17\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-pine-hybrid-17)</sup>

## Context Compression

Reducing context volume without losing facts is critical for cost and latency:

- **Extractive compression** (extracting key sentences/phrases); **abstractive summarization** (paraphrasing/compression). The classic perspective — Nenkova & McKeown.<sup>[\[18\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-nenkova2011-18)</sup>
- **Query-guided / instruction-guided** compression: summarization tailored to query/task (highlighting evidence and removing irrelevant content).
- **Prompt/context compression** using LLM filtering/token pruning (e.g., LLMLingua/LLMLingua-2) reduces token budget with minimal quality loss but requires careful *faithfulness* validation.<sup>[\[19\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-llmlingua-19)</sup>
- Compression is a *quality↔cost↔latency* tradeoff: aggressive compression increases the risk of missing nuances/premises and degrades fact attribution.<sup>[\[20\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-ji2023-20)</sup>

## Packaging Strategies (stuff/map-reduce/refine/tree)

Below are four basic schemes for arranging sources in the prompt and typical scenarios for their application (see also the comparison table).

**Stuff** (direct input)  
Concatenate selected fragments (after possible compression) and feed them entirely. Simple and fast, but limited by volume and susceptible to *lost-in-the-middle* on long inputs.<sup>[\[2\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-langchain-sum-2)</sup>

**Map-Reduce**  
In the *map* stage, locally answer/summarize each fragment/document, then *reduce* aggregates (comparison, voting, merging). Scales well with the number of sources, reducing load on a single prompt; risk of losing cross-source connections with naive aggregation.<sup>[\[2\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-langchain-sum-2)[\[21\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-fid-21)</sup>

**Refine**  
Sequential improvement: initial answer from the first fragment, then iterative *refine* considering the next fragment (adding/correcting). Convenient when source order matters; risk of "sticking" to early errors and accumulating distortions.<sup>[\[22\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-llama-refine-22)</sup>

**Tree-of-chunks**  
Hierarchical compression/summarization: local summaries by chunks → section-level rollups → final summary. Useful for long documents; requires careful passing of source identifiers between levels for correct attribution.<sup>[\[23\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-llama-tree-23)</sup>

| Strategy           | Idea                                | Cost/Latency              | Context Loss Risk                          | When to Apply                       | Sources                                                                                                                                                                                                        |
|--------------------|-------------------------------------|---------------------------|--------------------------------------------|-------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Stuff**          | All fragments at once in one prompt | Low (up to context limit) | High on long inputs (*lost-in-the-middle*) | Small volume, simple questions      | <sup>[\[2\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-langchain-sum-2)[\[3\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-lostmiddle-3)</sup> |
| **Map-Reduce**     | Local answers → aggregation         | Medium/high (many calls)  | Medium (depends on reduce quality)         | Many sources, scalability needed    | <sup>[\[2\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-langchain-sum-2)[\[21\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-fid-21)</sup>      |
| **Refine**         | Sequential answer improvement       | Medium                    | Order-dependent, error reinforcement risk  | When order/answer evolution matters | <sup>[\[22\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-llama-refine-22)</sup>                                                                                                |
| **Tree-of-chunks** | Hierarchical summaries              | Medium/high               | Detail loss at upper levels                | Long documents/collections          | <sup>[\[23\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-llama-tree-23)</sup>                                                                                                  |

Comparison of Packaging Strategies

## Source Ordering and Positioning

LLMs use information from the middle of long contexts less effectively; useful facts are better placed at the beginning/end, grouped by topics/sources, and marked with headers and IDs. Reranking with *query-aware* importance and diversification helps bring key fragments closer to the beginning.<sup>[\[3\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-lostmiddle-3)[\[13\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-nogueira2019-13)</sup>

## Integration into RAG Pipeline (fusion → rerank → packaging)

A typical multi-stage pipeline: **hybrid retrieval** (BM25 + dense) → **fusion** (RRF/weighted mix) → **rerank** (Cross-Encoder/ColBERT) → **packaging** (one of the strategies) → **generation** + **citation**. Hybrid search and RRF are robust to scoring incompatibility of different retrievers; cross-encoder improves LLM input precision, saving tokens.<sup>[\[16\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-weav-hybrid-16)[\[12\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-rrf-12)[\[14\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-cohere-rerank-14)[\[15\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-colbert-15)</sup>

## Quality Evaluation and Ablations

Evaluation is conducted at retrieval, packaging, and generation levels:

- **Retrieval**: Recall@k, nDCG@k, MRR — standard IR metrics.<sup>[\[24\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-manning2008-24)</sup>
- **Faithfulness/groundedness**: proportion of statements supported by citations; automated frameworks (RAGAS, TruLens) + manual attribution validation.<sup>[\[25\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-ragas-25)[\[26\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-trulens-26)[\[27\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-rashkin2023-27)</sup>
- **End-to-end QA**: EM/F1/[ROUGE](https://systems-analysis.info/eng/ROUGE_(metric) "ROUGE (metric)") depending on task/dataset (NQ/HotpotQA, etc.).<sup>[\[1\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-lewis2020-1)</sup>
- **Efficiency**: latency p50/p95, token count, \$-cost; comparison of packaging strategies and compression levels by *quality↔cost*.
- **Ablations**: disabling MMR/deduplication/compression/changing order to measure each component's contribution (as of 2025-09-10, RAG research practice recommends clearly documenting k, λ, chunk sizes, and token limits).<sup>[\[28\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-rag-survey-28)</sup>

## Practical Recommendations and Checklist

- **k and diversification**: start with k=20–40 candidates from hybrid retrieval; apply MMR with λ≈0.5–0.8; strictly penalize duplicates by URL/ID/text hash.<sup>[\[11\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-mmr-11)[\[16\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-weav-hybrid-16)</sup>
- **Chunking**: 200–400 tokens with 10–20% overlap for fixed chunking; for legal-technical documents, sentence/window scheme often helps.<sup>[\[4\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-lc-splitters-4)[\[7\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-haystack-sentwin-7)</sup>
- **Compression**: use extractive filtering by query and careful abstraction; decrease/increase LLMLingua-like methods depending on *faithfulness* on your data (A/B validation required).<sup>[\[19\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-llmlingua-19)[\[27\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-rashkin2023-27)</sup>
- **Order**: important/high-confidence fragments — at the beginning of the prompt; group by sources/topics, explicitly mark IDs and headers; consider the *lost-in-the-middle* effect (duplicating key facts at the beginning and end may help).<sup>[\[3\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-lostmiddle-3)</sup>
- **Rerank**: if budget allows, add Cross-Encoder/ColBERT on top-k (k≈50–200) before packaging — this saves generation tokens and improves precision.<sup>[\[13\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-nogueira2019-13)[\[15\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-colbert-15)</sup>
- **Fallback strategies**: (1) insufficient facts → request additional sources; (2) token limit exceeded → switch *stuff→refine* or enable compression; (3) low confidence/contradictions → refusal response with explicit list of missing IDs (see template below).

### Packaging Pipeline Pseudocode

    # Input: query q
    cands = retrieve(q, K_sparse, K_dense)          # search BM25, DPR etc.
    cands = diversify_MMR(cands, lambda=0.7)        # diversification (MMR)
    snips = compress(query=q, items=cands, mode="extractive|abstractive", budget=tokens)
    pkg   = package(snips, strategy="stuff|map_reduce|refine|tree")
    resp  = generate(prompt=build_prompt(q, pkg), citations=True)  # LLM with citations

### Prompt Template Skeleton (Fragment)

    [USER QUERY]
    {q}

    [SOURCES]
    {# Each fragment with ID, title, and link #}
    - [{id}] {title} — {url}
    {content_snippet}

    [REQUIREMENTS]
    1) Use only facts from sources, reference [ID].
    2) If data is insufficient, say so and request clarification/additional sources.
    3) Maintain response structure and list used [IDs].

## Limitations and Open Questions

- **[Hallucinations](https://systems-analysis.info/eng/LLM_hallucinations "LLM hallucinations") and aggregation** in map-reduce/refine: abstractive summaries may introduce new facts; clear attribution instructions and citation verification mechanisms are critical.<sup>[\[20\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-ji2023-20)[\[27\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-rashkin2023-27)</sup>
- **Detail loss** with aggressive compression/hierarchical summarization; storing back-references to original source/page/offset is important.
- **Domain transferability** of retrievers/rerankers and compressors; adaptation/[fine-tuning](https://systems-analysis.info/eng/Fine-tuning_(deep_learning) "Fine-tuning (deep learning)") on domain corpora is required.<sup>[\[28\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-rag-survey-28)</sup>
- **Privacy/PII** and LLM memorization: generation without strict *grounding* may leak private strings; apply filters, private storage, and refusal policies.<sup>[\[29\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-carlini-29)[\[30\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-shokri-30)</sup>
- **Trainable "packagers"**, adaptive ordering/arrangement, [RLHF](https://systems-analysis.info/eng/Reinforcement_learning_from_human_feedback_(RLHF) "Reinforcement learning from human feedback (RLHF)")/feedback loops for improving *faithfulness*, multilingual and ultra-long context — active research directions.<sup>[\[28\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-rag-survey-28)[\[3\]](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_note-lostmiddle-3)</sup>

## External links

- LangChain: *Summarization* (stuff/map_reduce/refine). <a href="https://python.langchain.com/docs/tutorials/summarization/" class="external autonumber" rel="nofollow">[29]</a>
- LangChain: *Text splitters*. <a href="https://python.langchain.com/docs/concepts/text_splitters/" class="external autonumber" rel="nofollow">[30]</a>
- LlamaIndex: *Response Synthesizers (refine/tree)*. <a href="https://docs.llamaindex.ai/en/stable/module_guides/deploying/response_synthesizers/" class="external autonumber" rel="nofollow">[31]</a>
- LlamaIndex: *Node Parsers / SentenceSplitter / SemanticSplitter*. <a href="https://docs.llamaindex.ai/en/stable/module_guides/loading/node_parsers/modules/" class="external autonumber" rel="nofollow">[32]</a>
- Haystack: *SentenceWindowRetriever*. <a href="https://docs.haystack.deepset.ai/docs/sentencewindowretrieval" class="external autonumber" rel="nofollow">[33]</a>
- Haystack: *PreProcessors / DocumentSplitter*. <a href="https://docs.haystack.deepset.ai/docs/preprocessors" class="external autonumber" rel="nofollow">[34]</a>
- Weaviate: *Hybrid search*. <a href="https://docs.weaviate.io/weaviate/concepts/search/hybrid-search" class="external autonumber" rel="nofollow">[35]</a>
- Pinecone: *Hybrid search*. <a href="https://docs.pinecone.io/docs/hybrid-search" class="external autonumber" rel="nofollow">[36]</a>
- Cohere: *Rerank API*. <a href="https://docs.cohere.com/docs/rerank-overview" class="external autonumber" rel="nofollow">[37]</a>
- RAGAS (repo/docs). <a href="https://arxiv.org/abs/2309.15217" class="external autonumber" rel="nofollow">[38]</a> <a href="https://github.com/explodinggradients/ragas" class="external autonumber" rel="nofollow">[39]</a>
- TruLens (docs). <a href="https://www.trulens.org/trulens_eval/getting_started/evaluation/" class="external autonumber" rel="nofollow">[40]</a>
- <a href="https://en.wikipedia.org/wiki/Prompt_engineering#Context_engineering" class="external text" rel="nofollow">Context engineering — Wikipedia</a>

## Bibliography

- Manning, C. D., Raghavan, P., Schütze, H. (2008). *Introduction to Information Retrieval*. Cambridge University Press. ISBN 978-0521865715.
- Nenkova, A., McKeown, K. (2011). *Automatic Summarization*. FnT IR, 5(2–3), 103–233. DOI:10.1561/1500000015.
- Lewis, P., et al. (2020). *Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks*. NeurIPS. arXiv:2005.11401.
- Khattab, O., Zaharia, M. (2020). *ColBERT*. SIGIR'20. DOI:10.1145/3397271.3401075.
- Izacard, G., Grave, E. (2021). *Fusion-in-Decoder*. EACL. arXiv:2007.01282.
- Ji, Z., et al. (2023). *Survey of Hallucination in NLG*. ACM CS. DOI:10.1145/3571730.
- Gao, S., et al. (2024). *RAG for LLM: A Survey*. arXiv:2312.10997.

## References

1.  <span id="cite_note-lewis2020-1">↑ <sup>[1.0](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-lewis2020_1-0)</sup> <sup>[1.1](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-lewis2020_1-1)</sup> <sup>[1.2](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-lewis2020_1-2)</sup> Lewis, P., Perez, E., Piktus, A., Petroni, F., Karpukhin, V., et al. (2020). *Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks*. NeurIPS. arXiv:2005.11401. <a href="https://arxiv.org/abs/2005.11401" class="external autonumber" rel="nofollow">[1]</a></span>
2.  <span id="cite_note-langchain-sum-2">↑ <sup>[2.0](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-langchain-sum_2-0)</sup> <sup>[2.1](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-langchain-sum_2-1)</sup> <sup>[2.2](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-langchain-sum_2-2)</sup> <sup>[2.3](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-langchain-sum_2-3)</sup> <sup>[2.4](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-langchain-sum_2-4)</sup> LangChain Docs. *Summarization* (stuff/map_reduce/refine/map_rerank). (accessed: 2025-09-10). <a href="https://python.langchain.com/docs/tutorials/summarization/" class="external autonumber" rel="nofollow">[2]</a></span>
3.  <span id="cite_note-lostmiddle-3">↑ <sup>[3.0](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-lostmiddle_3-0)</sup> <sup>[3.1](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-lostmiddle_3-1)</sup> <sup>[3.2](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-lostmiddle_3-2)</sup> <sup>[3.3](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-lostmiddle_3-3)</sup> <sup>[3.4](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-lostmiddle_3-4)</sup> Liu, N. F., Lin, K., Hewitt, J., Paranjape, A., Bevilacqua, M., Petroni, F., Liang, P. (2024). *Lost in the Middle: How Language Models Use Long Contexts*. TACL. arXiv:2307.03172. <a href="https://arxiv.org/abs/2307.03172" class="external autonumber" rel="nofollow">[3]</a></span>
4.  <span id="cite_note-lc-splitters-4">↑ <sup>[4.0](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-lc-splitters_4-0)</sup> <sup>[4.1](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-lc-splitters_4-1)</sup> LangChain Docs. *Text splitters* (RecursiveCharacter/TokenTextSplitter). (accessed: 2025-09-10). <a href="https://python.langchain.com/docs/concepts/text_splitters/" class="external autonumber" rel="nofollow">[4]</a></span>
5.  <span id="cite_note-llama-splitters-5">[↑](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-llama-splitters_5-0) LlamaIndex Docs. *SentenceSplitter / TokenTextSplitter / SemanticSplitter*. (accessed: 2025-09-10). <a href="https://docs.llamaindex.ai/en/stable/api_reference/node_parsers/sentence_splitter/" class="external autonumber" rel="nofollow">[5]</a> <a href="https://docs.llamaindex.ai/en/stable/api_reference/node_parsers/token_text_splitter/" class="external autonumber" rel="nofollow">[6]</a> <a href="https://docs.llamaindex.ai/en/stable/api_reference/node_parsers/semantic_splitter/" class="external autonumber" rel="nofollow">[7]</a></span>
6.  <span id="cite_note-llama-sem-6">[↑](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-llama-sem_6-0) LlamaIndex Docs. *SemanticSplitterNodeParser*. (accessed: 2025-09-10). <a href="https://docs.llamaindex.ai/en/stable/api_reference/node_parsers/semantic_splitter/" class="external autonumber" rel="nofollow">[8]</a></span>
7.  <span id="cite_note-haystack-sentwin-7">↑ <sup>[7.0](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-haystack-sentwin_7-0)</sup> <sup>[7.1](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-haystack-sentwin_7-1)</sup> Haystack Docs. *SentenceWindowRetriever*. (accessed: 2025-09-10). <a href="https://docs.haystack.deepset.ai/docs/sentencewindowretrieval" class="external autonumber" rel="nofollow">[9]</a></span>
8.  <span id="cite_note-dpr-8">[↑](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-dpr_8-0) Karpukhin, V., Oguz, B., Min, S., Lewis, P., Wu, L., Edunov, S., Chen, D., Yih, W.-T. (2020). *Dense Passage Retrieval for Open-Domain Question Answering*. EMNLP. arXiv:2004.04906. <a href="https://arxiv.org/abs/2004.04906" class="external autonumber" rel="nofollow">[10]</a></span>
9.  <span id="cite_note-haystack-pre-9">[↑](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-haystack-pre_9-0) Haystack Docs. *PreProcessors / DocumentSplitter*. (accessed: 2025-09-10). <a href="https://docs.haystack.deepset.ai/docs/preprocessors" class="external autonumber" rel="nofollow">[11]</a> <a href="https://docs.haystack.deepset.ai/docs/documentsplitter" class="external autonumber" rel="nofollow">[12]</a></span>
10. <span id="cite_note-broder1997-10">[↑](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-broder1997_10-0) Broder, A. Z. (1997). *On the Resemblance and Containment of Documents*. Compression and Complexity of Sequences. <a href="https://www.cs.princeton.edu/courses/archive/spring13/cos598C/broder97resemblance.pdf" class="external autonumber" rel="nofollow">[13]</a></span>
11. <span id="cite_note-mmr-11">↑ <sup>[11.0](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-mmr_11-0)</sup> <sup>[11.1](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-mmr_11-1)</sup> Carbonell, J., Goldstein, J. (1998). *The Use of MMR, Diversity-Based Reranking for Reordering Documents and Producing Summaries*. SIGIR'98, pp. 335–336. DOI:10.1145/290941.291025.</span>
12. <span id="cite_note-rrf-12">↑ <sup>[12.0](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-rrf_12-0)</sup> <sup>[12.1](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-rrf_12-1)</sup> Cormack, G. V., Clarke, C. L. A., Büttcher, S. (2009). *Reciprocal Rank Fusion outperforms Condorcet and Individual Rank Learning Methods*. SIGIR'09, pp. 758–759. DOI:10.1145/1571941.1572114. <a href="https://cormack.uwaterloo.ca/cormacksigir09-rrf.pdf" class="external autonumber" rel="nofollow">[14]</a></span>
13. <span id="cite_note-nogueira2019-13">↑ <sup>[13.0](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-nogueira2019_13-0)</sup> <sup>[13.1](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-nogueira2019_13-1)</sup> <sup>[13.2](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-nogueira2019_13-2)</sup> Nogueira, R., Cho, K. (2019). *Passage Re-ranking with BERT*. arXiv:1901.04085. <a href="https://arxiv.org/abs/1901.04085" class="external autonumber" rel="nofollow">[15]</a></span>
14. <span id="cite_note-cohere-rerank-14">↑ <sup>[14.0](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-cohere-rerank_14-0)</sup> <sup>[14.1](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-cohere-rerank_14-1)</sup> Cohere Docs. *Rerank API overview*. (accessed: 2025-09-10). <a href="https://docs.cohere.com/docs/rerank-overview" class="external autonumber" rel="nofollow">[16]</a></span>
15. <span id="cite_note-colbert-15">↑ <sup>[15.0](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-colbert_15-0)</sup> <sup>[15.1](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-colbert_15-1)</sup> <sup>[15.2](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-colbert_15-2)</sup> Khattab, O., Zaharia, M. (2020). *ColBERT: Efficient and Effective Passage Search via Contextualized Late Interaction over BERT*. SIGIR'20, pp. 39–48. DOI:10.1145/3397271.3401075. arXiv:2004.12832.</span>
16. <span id="cite_note-weav-hybrid-16">↑ <sup>[16.0](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-weav-hybrid_16-0)</sup> <sup>[16.1](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-weav-hybrid_16-1)</sup> <sup>[16.2](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-weav-hybrid_16-2)</sup> Weaviate Docs. *Hybrid search (BM25F + vector)*. (accessed: 2025-09-10). <a href="https://docs.weaviate.io/weaviate/concepts/search/hybrid-search" class="external autonumber" rel="nofollow">[17]</a></span>
17. <span id="cite_note-pine-hybrid-17">[↑](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-pine-hybrid_17-0) Pinecone Docs. *Hybrid search*. (accessed: 2025-09-10). <a href="https://docs.pinecone.io/docs/hybrid-search" class="external autonumber" rel="nofollow">[18]</a></span>
18. <span id="cite_note-nenkova2011-18">[↑](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-nenkova2011_18-0) Nenkova, A., McKeown, K. (2011). *Automatic Summarization*. Foundations and Trends in Information Retrieval, 5(2–3), 103–233. DOI:10.1561/1500000015.</span>
19. <span id="cite_note-llmlingua-19">↑ <sup>[19.0](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-llmlingua_19-0)</sup> <sup>[19.1](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-llmlingua_19-1)</sup> Zhu, Y., Shao, Z., Li, M., et al. (2023). *LLMLingua: Compressing Prompts for Accelerating LLM Inference*. arXiv:2310.05736. <a href="https://arxiv.org/abs/2310.05736" class="external autonumber" rel="nofollow">[19]</a></span>
20. <span id="cite_note-ji2023-20">↑ <sup>[20.0](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-ji2023_20-0)</sup> <sup>[20.1](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-ji2023_20-1)</sup> Ji, Z., Lee, N., Frieske, R., et al. (2023). *Survey of Hallucination in Natural Language Generation*. ACM Computing Surveys, 55(12), Art.248. DOI:10.1145/3571730.</span>
21. <span id="cite_note-fid-21">↑ <sup>[21.0](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-fid_21-0)</sup> <sup>[21.1](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-fid_21-1)</sup> Izacard, G., Grave, E. (2021). *Leveraging Passage Retrieval with Generative Models for Open-Domain QA (Fusion-in-Decoder)*. EACL. arXiv:2007.01282. <a href="https://arxiv.org/abs/2007.01282" class="external autonumber" rel="nofollow">[20]</a></span>
22. <span id="cite_note-llama-refine-22">↑ <sup>[22.0](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-llama-refine_22-0)</sup> <sup>[22.1](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-llama-refine_22-1)</sup> LlamaIndex Docs. *Response Synthesizers: refine*. (accessed: 2025-09-10). <a href="https://docs.llamaindex.ai/en/stable/module_guides/deploying/response_synthesizers/#refine" class="external autonumber" rel="nofollow">[21]</a></span>
23. <span id="cite_note-llama-tree-23">↑ <sup>[23.0](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-llama-tree_23-0)</sup> <sup>[23.1](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-llama-tree_23-1)</sup> LlamaIndex Docs. *Tree Summarize*. (accessed: 2025-09-10). <a href="https://docs.llamaindex.ai/en/stable/module_guides/deploying/response_synthesizers/#tree-summarize" class="external autonumber" rel="nofollow">[22]</a></span>
24. <span id="cite_note-manning2008-24">[↑](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-manning2008_24-0) Manning, C. D., Raghavan, P., Schütze, H. (2008). *Introduction to Information Retrieval*. Cambridge Univ. Press. (see chapters on nDCG/MRR). <a href="https://nlp.stanford.edu/IR-book/" class="external autonumber" rel="nofollow">[23]</a></span>
25. <span id="cite_note-ragas-25">[↑](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-ragas_25-0) Es, S., et al. (2023). *RAGAS: Automated Evaluation of Retrieval-Augmented Generation*. arXiv:2309.15217. <a href="https://arxiv.org/abs/2309.15217" class="external autonumber" rel="nofollow">[24]</a></span>
26. <span id="cite_note-trulens-26">[↑](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-trulens_26-0) TruLens Docs. *Evaluating RAG (groundedness, relevance)*. (accessed: 2025-09-10). <a href="https://www.trulens.org/trulens_eval/getting_started/evaluation/" class="external autonumber" rel="nofollow">[25]</a></span>
27. <span id="cite_note-rashkin2023-27">↑ <sup>[27.0](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-rashkin2023_27-0)</sup> <sup>[27.1](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-rashkin2023_27-1)</sup> <sup>[27.2](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-rashkin2023_27-2)</sup> Rashkin, H., Nakov, P., et al. (2023). *Measuring Attribution in Natural Language Generation*. Computational Linguistics, 49(4), 1207–1261. DOI:10.1162/coli_a_00486.</span>
28. <span id="cite_note-rag-survey-28">↑ <sup>[28.0](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-rag-survey_28-0)</sup> <sup>[28.1](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-rag-survey_28-1)</sup> <sup>[28.2](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-rag-survey_28-2)</sup> Gao, S., et al. (2024). *Retrieval-Augmented Generation for Large Language Models: A Survey*. arXiv:2312.10997. <a href="https://arxiv.org/abs/2312.10997" class="external autonumber" rel="nofollow">[26]</a></span>
29. <span id="cite_note-carlini-29">[↑](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-carlini_29-0) Carlini, N., Tramèr, F., et al. (2021). *Extracting Training Data from Large Language Models*. USENIX Security. <a href="https://www.usenix.org/system/files/sec21-carlini-extracting.pdf" class="external autonumber" rel="nofollow">[27]</a></span>
30. <span id="cite_note-shokri-30">[↑](https://systems-analysis.info/eng/Packaging_%26_Context_Handling#cite_ref-shokri_30-0) Shokri, R., Stronati, M., Song, C., Shmatikov, V. (2017). *Membership Inference Attacks Against ML Models*. IEEE S&P. <a href="https://www.cs.cornell.edu/~shmat/shmat_oak17.pdf" class="external autonumber" rel="nofollow">[28]</a></span>
