Skip to content

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

50 Commits

Folders and files

Repository files navigation

UNLP 2026 Solution: Off-the-Shelf RAG for Ukrainian Multi-Domain Document Understanding

This repository contains our solution for the UNLP 2026 Shared Task on Multi-Domain Document Understanding.

Our system is a retrieval-augmented multiple-choice QA pipeline for Ukrainian PDF documents. Given a question with six answer options, it predicts:

  • the correct answer (A-F)
  • the supporting document
  • the supporting page

The final approach combines:

  1. structure-aware PDF chunking
  2. dense retrieval over contextualized chunks
  3. reranking
  4. constrained answer generation from top reranked evidence

Final Result

Our best submission achieved:

Split Score
Public leaderboard 0.9452
Private leaderboard 0.9598

This was obtained with:

  • Retriever: Qwen3-Embedding-8B
  • Reranker: Qwen3-Reranker-8B fine-tuned on UA-SQuAD
  • Answer model: Qwen3-32B-AWQ

Final Pipeline

1. Contextual chunking of PDFs

We do not treat PDF pages as plain text.
Instead, each chunk includes:

  • a document prefix with global context
  • the heading path / section context
  • the local chunk body

Final chunking settings used in the strongest setup:

  • max_tokens = 512
  • overlap_tokens = 64
  • doc_prefix_tokens = 128

This preserves document-level structure and gives each chunk enough context to be retrievable on its own.

2. Dense retrieval

We use Qwen3-Embedding-8B to retrieve the top-20 candidate chunks.

The retriever query is built from the full multiple-choice instance:

  • question
  • answer options A-F
  • instruction focused on finding the correct supporting document and page

This was important: retrieving with only the question was weaker than retrieving with question + options.

3. Reranking

The retrieved top-20 chunks are reranked with Qwen3-Reranker-8B.

The reranker sees:

  • the question
  • all answer options
  • the candidate chunk

In the final system, we keep only the top-2 reranked passages.

4. Constrained answer generation

The final answer is selected by Qwen3-32B-AWQ using:

  • the question
  • answer options
  • the top-2 reranked passages

Decoding is constrained to a single token from A-F, which makes inference stable and efficient.

The predicted document and page are taken from the highest-ranked selected chunk.


Repository Structure

unlp2026_shared_task/
├── inference/                          # Final Kaggle submission notebooks
│   ├── unlp26-sota-no-train.ipynb      # Strong no-training baseline
│   └── emb-3-8b-reranker-3-8b-squad-q-a-llm-32b.ipynb  # Best final pipeline
├── notebooks/                          # Development and experiment notebooks
│   ├── reranker/
│   │   ├── train_reranker.ipynb        # Reranker fine-tuning on UA-SQuAD
│   │   └── reranker_datasets_merge.ipynb  # Hard-negative dataset construction
│   ├── baseline-vllm.ipynb             # Early RAG baseline (vLLM)
│   ├── baseline-no-vllm.ipynb          # Kaggle-compatible baseline (no vLLM)
│   ├── chunking_example.ipynb          # Contextual chunker walkthrough
│   ├── create_summaries.ipynb          # Document title/summary prefix generation
│   ├── rerank-vllm.ipynb               # Reranking experiment with vLLM
│   ├── summary_wcontextual_chunk_eval_qwen3emb8b_reranker8b.ipynb  # Summary-injection evaluation
│   ├── agentic_exp.ipynb               # Agentic pipeline experiment
│   ├── pplx_context.ipynb              # Page-level context experiment
│   └── train_rerank.ipynb              # Early reranking experiment
├── src/unlp26/                         # Core library
│   ├── chunker/contextual.py           # Contextual PDF chunker
│   ├── embedding/                      # Embedding model training scripts
│   ├── reranker/                       # Reranker training scripts
│   └── retriever/                      # Retriever training scripts
├── data/
│   ├── competition/                    # Official train/test splits and PDFs
│   └── unlp2026_domain_extended/       # Extended domain_1 PDFs + train split
└── kaggle/                             # Kaggle dataset upload helpers

Main Notebooks

This repository is centered around two main notebooks.

unlp26-sota-no-train.ipynb

Inference-only strong baseline with fully off-the-shelf models:

  • Qwen3-Embedding-8B
  • Qwen3-Reranker-8B
  • Qwen3-32B-AWQ

This corresponds to our strong no-training pipeline and matches the paper’s baseline setup.

Paper result for this setup:

Variant Public Private
Baseline 0.9426 0.9592

emb-3-8b-reranker-3-8b-squad-q-a-llm-32b.ipynb

Final improved pipeline with:

  • Qwen3-Embedding-8B
  • fine-tuned Qwen3-Reranker-8B + squad
  • Qwen3-32B-AWQ

This is our best final configuration.

Paper result for this setup:

Variant Public Private
Final pipeline (fine-tuned reranker) 0.9452 0.9598

Training Notebooks

The notebooks/ directory contains experiment and training notebooks used during development.

notebooks/reranker/train_reranker.ipynb

Fine-tunes Qwen3-Reranker-8B (and 0.6B) on UA-SQuAD using the FlagEmbedding training framework:

  • loads the UA-SQuAD dataset via ua-datasets
  • mines BM25 hard negatives for each question–passage pair
  • runs a single-GPU contrastive training loop with FlagLLMReranker
  • evaluates the fine-tuned model on a held-out dev split

This notebook produces the Qwen3-Reranker-8B + squad checkpoint used in the final best run.

notebooks/reranker/reranker_datasets_merge.ipynb

Constructs the merged training dataset for reranker fine-tuning:

  • chunks all competition PDFs with docling HybridChunker
  • encodes chunks and MCQ-style queries with Qwen3-Embedding-0.6B
  • mines hard negatives using dense retrieval (ANN over chunk embeddings)
  • aligns gold passages using doc ID + page number from the competition labels
  • merges the competition-derived pairs with UA-SQuAD examples into a single JSONL file ready for train_reranker.ipynb

Other development notebooks

Notebook Purpose
baseline-vllm.ipynb Early end-to-end RAG pipeline with vLLM serving
baseline-no-vllm.ipynb Kaggle-compatible baseline (HuggingFace Transformers, no vLLM)
chunking_example.ipynb Walkthrough of the contextual chunker on competition PDFs
create_summaries.ipynb Generates per-document title and summary prefixes via an LLM
rerank-vllm.ipynb Reranking pipeline experiment with vLLM-served reranker
summary_wcontextual_chunk_eval_qwen3emb8b_reranker8b.ipynb Ablation: summary-prefix injection with Qwen3-Embedding-8B + Reranker-8B
agentic_exp.ipynb Agentic pipeline prototype using a self-hosted Qwen model
pplx_context.ipynb Page-level perplexity context experiment
train_rerank.ipynb Early reranking experiment (prior to the FlagEmbedding approach)

Key Experimental Results

Embedding model comparison

With fixed reranker and generator:

Model Public Private
Qwen3-Embedding-8B 0.9426 0.9592
Qwen3-Embedding-8B + squad 0.9414 0.9591
Qwen3-Embedding-0.6B + 80k + squad 0.9390 0.9581
Qwen3-Embedding-0.6B + squad 0.9345 0.9534
Qwen3-Embedding-0.6B 0.9370 0.9507
pplx-embed-v1-4b 0.8737 0.8759

Conclusion: the off-the-shelf 8B embedder was the strongest retrieval backbone, but the much smaller 0.6B embedder fine-tuned on our translated retrieval dataset and UA-SQuAD nearly matched 8B performance, making it a strong efficiency-quality trade-off under tighter compute constraints.


Reranker comparison

With fixed Qwen3-Embedding-8B retriever and Qwen3-32B-AWQ generator:

Model Public Private
Qwen3-Reranker-8B 0.9426 0.9592
Qwen3-Reranker-8B + unlp 0.9286 0.9477
Qwen3-Reranker-8B + squad 0.9452 0.9598
Qwen3-Reranker-8B + squad + unlp 0.9330 0.9514
Qwen3-Reranker-8B + 80k + squad 0.9456 0.9590
Qwen3-Reranker-4B 0.9429 0.9562
Qwen3-Reranker-0.6B 0.9172 0.9395
No reranker 0.9099 0.9243

Conclusion: reranking was one of the biggest contributors to end-to-end quality, and 8B + squad gave the best private score.


Important ablations

Variant Public Private
Generator only (no RAG) 0.3352 0.3392
Early system (BM25, Qwen2.5-32B) 0.9035 0.9114
w/o document-context prepending 0.8610 0.8891
w/ summary injection (1024→80) 0.9177 0.9408
14B generator, top-10→1 0.9346 0.9483
Rerank Q+A only, retrieval with Q only 0.9397 0.9570
Baseline 0.9426 0.9592
Final pipeline 0.9452 0.9598

Important finding: removing document-context prepending caused a huge drop:

  • from 0.9452 to 0.8610 on public
  • from 0.9598 to 0.8891 on private

This confirms that document structure preservation was one of the most important parts of the whole system.


Why the Solution Worked

The final system worked well because it aligned all stages with the actual competition objective:

  • chunking preserved the structure of long PDFs
  • retrieval searched using the full MCQ instance
  • reranking judged relevance using question + answer options
  • generation was forced to choose only among valid answer letters
  • localization was inherited from the best selected evidence chunk

In short, we treated the task as evidence-grounded multiple-choice reasoning over long structured documents, not just as plain text generation.


Competition Constraints

The solution was designed for the Kaggle code competition setting:

  • no internet access
  • strict runtime budget
  • hidden larger test set
  • hidden unseen domain_3

Because of this, we prioritized:

  • robustness
  • simple multi-stage inference
  • efficient vLLM-based serving
  • minimal brittle domain-specific heuristics

Technical Summary

Final retained configuration:

  • Chunking

    • contextual chunking
    • 512 max tokens
    • 64 overlap
    • 128 document-prefix tokens
  • Retrieval

    • Qwen3-Embedding-8B
    • top-20 chunks
  • Reranking

    • Qwen3-Reranker-8B
    • fine-tuned on UA-SQuAD in the final best run
    • keep top-2 chunks
  • Generation

    • Qwen3-32B-AWQ
    • constrained single-token decoding over A-F
  • Inference stack

    • vLLM
    • 2×T4-friendly pipeline design

Repository Purpose

This repo is intended to provide:

  • the main inference notebooks for our best solution
  • a reproducible structure for chunking, retrieval, reranking, and answer generation
  • a reference implementation of a strong Ukrainian RAG pipeline for long PDF MCQA

Citation

If you use this repository, please cite our UNLP 2026 shared task paper:

Qwen Goes Brrr: Off-the-Shelf RAG for Ukrainian Multi-Domain Document Understanding


Acknowledgements

We thank the organizers of the UNLP 2026 Shared Task for the benchmark and the code-only competition setup.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages