Skip to content

About

Cross-lingual QA evaluation showing how span F1 can mis-score correct answers and distort model rankings and transfer claims.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Right Answer, Wrong Language

Paper in progress: Right Answer, Wrong Language: How Span F1 Changes Conclusions in Cross-Lingual QA Evaluation

Repository study: Span F1 Misreads Cross-Lingual Retrieval

tests

Cross-lingual reading tests often ask a question in one language about a passage in another, then score the answer against a span written in the passage language. A model that retrieves the right fact but answers in the question language can receive zero token-overlap F1. This project measures how strongly that scoring choice changes model rankings, apparent fine-tuning gains, and claims of cross-script transfer.

The repository began as a multilingual needle-in-a-haystack experiment; the current study expands it into a controlled audit of cross-lingual QA evaluation.

Main findings

  • Across 33 open models in the MLQA evaluation harness, crediting correct answers expressed in the question language raises cross-lingual scores by 15.2 F1 on average and changes the ranking (Kendall's τ = 0.73).
  • In the controlled XQuAD needle study, 88% of zero-scored answers from the English-fine-tuned Llama model are produced in English rather than the passage language.
  • Fair-language credit removes 61% of that model's apparent gap to German and Spanish.
  • Apparent held-out cross-script transfer of +9.4 to +30.8 F1 shrinks to −0.4 to +5.6 after matched controls and fair credit.

All reported values are generated from analysis artifacts by analysis/generate_macros_v2.py rather than typed by hand. The accompanying paper is in preparation and is not included in this repository.

Technical scope

  • Cross-lingual long-context retrieval over XQuAD, MLQA, and XOR-style tasks.
  • SQuAD-style span F1 alongside script-aware and translation-based credit.
  • Llama, Gemma, Mistral, Qwen, Aya, Phi, and OLMo model comparisons.
  • QLoRA training with 4-bit NF4 base models and rank-16 adapters over attention projections.
  • Held-out-content, needle-absent, counterfactual, prompt-matched, and closed-book controls.
  • Optional FastAPI inference service with lazy model initialization and readiness reporting.

This is an evaluation and research repository, not a hosted production service.

Repository layout

analysis/        metric audits, rescoring, bootstrap analyses, and paper macros
harness_tasks/   lm-evaluation-harness task implementations
human_eval/      human-evaluation utilities
scripts/         SLURM launchers and experiment matrices
app.py           optional local FastAPI inference wrapper
train.py         4-bit QLoRA adapter training
evaluate.py      controlled needle evaluation
qa_utils.py      shared prompting and span-F1 implementation
tests/           lightweight unit/API tests

Model weights, adapters, datasets, raw predictions, cluster logs, and internal research notes are excluded.

Setup

uv sync

The full experiments require locally cached Hugging Face models and GPUs. The lightweight tests require no model downloads:

uv run --extra dev pytest

QLoRA training

uv run python train.py \
  --model_id meta-llama/Llama-3.1-8B \
  --data_langs en \
  --exclude_needle_pool \
  --out models/llama3.1_finetuned_en

The training code uses bitsandbytes NF4 quantization and LoRA rank 16, α = 32 over q_proj, k_proj, v_proj, and o_proj.

FastAPI service

Configure local model paths and start the optional service:

export NIAH_BASE_MODEL=meta-llama/Llama-3.1-8B
export NIAH_ADAPTER_PATH=./models/llama3.1_finetuned_en
uv run uvicorn app:app --host 127.0.0.1 --port 8000

The service provides GET /health and POST /generate. It loads the model during application startup rather than at module import.

Reproducibility notes

  • The manuscript is not part of this repository while it is in preparation.
  • analysis/generate_macros_v2.py regenerates data-derived paper values.
  • analysis/scan_hardcoded_numbers.py checks that headline results remain linked to generated artifacts.
  • Cluster scripts resolve the repository relative to their own location and read cache paths from environment variables.

License

MIT. Models and datasets retain their original licenses.

About

Cross-lingual QA evaluation showing how span F1 can mis-score correct answers and distort model rankings and transfer claims.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages