Downloads · 30 days
0
abhshkp/litm-original-reproduction
litm-original-reproduction is a machine learning model from abhshkp. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Exact reproduction of the experiments from Liu et al. (2023) "Lost in the Middle: How Language Models Use Long Contexts" (arXiv:2307.03172).
Downloads · 30 days
0
Access
Public
Updated May 21, 2026
Repo size
—
Likes
0
Public
Click a slice to open those files.
.py66.6 KB · 94%
From the Hugging Face model README
Exact reproduction of the experiments from Liu et al. (2023) "Lost in the Middle: How Language Models Use Long Contexts" (arXiv:2307.03172).
Original Repo: https://github.com/nelson-liu/lost-in-the-middle
All files fetched directly from the official GitHub repository via raw.githubusercontent.com.
src/prompting.py — Prompt construction (exact from src/lost_in_the_middle/prompting.py)src/metrics.py — Scoring/normalization (exact from src/lost_in_the_middle/metrics.py)prompts/qa.promptprompts/kv_retrieval.promptprompts/closedbook_qa.promptprompts/qa_with_query_aware_contextualization.promptprompts/kv_retrieval_with_query_aware_contextualization.promptscripts/make_qa_data_from_retrieval_results.py — Multi-document QA data creationscripts/create_kv_pairs.py — KV retrieval synthetic data generationscripts/get_qa_responses_from_mpt.py — Multi-document QA runner (MPT-30B original)scripts/get_kv_responses_from_mpt.py — KV retrieval runner (MPT-30B original)scripts/run_qa_mistral.py — Multi-document QA on Mistral-7B-Instructscripts/run_kv_mistral.py — KV retrieval on Mistral-7B-Instructpip install transformers torch tqdm regex pydantic xopen
# 1. Generate synthetic KV data
python scripts/create_kv_pairs.py \
--num-keys 100 \
--num-examples 50 \
--output data/kv_100.jsonl.gz
# 2. Run evaluation
python scripts/run_kv_mistral.py \
--input-path data/kv_100.jsonl.gz \
--model mistralai/Mistral-7B-Instruct-v0.3 \
--gold-index 50 \
--output results/kv_100_gold50.jsonl.gz
Liu, N. F., Lin, K., Hewitt, J., Paranjape, A., Bevilacqua, M., Petroni, F., & Liang, P. (2023).
Lost in the Middle: How Language Models Use Long Contexts.
arXiv:2307.03172.