Research map / Image generation / Text-to-image diffusion
PinNet: Pinpoint Instructive Information for Retrieval Augmented Code-to-Text Generation
Read the paperCheck your idea against 108,967 papers
AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.
Proposes PinNet, a retrieval-augmented code-to-text model whose discriminator scores how well a retrieved reference matches the input code and whose representations steer decoder attention (PinAttention), plus a hierarchical contrastive retrieval loss.
Problem
Retrieval-augmented code-to-text generation is hurt when retrieved descriptions are irrelevant or misleading, and dense retrievers trained with contrastive loss suffer a train/inference mismatch because all non-ground-truth descriptions are treated as negatives.
Approach
A discriminator over the retrieved reference is trained to predict BLEU-based relevance classes; its last-layer representations are injected into decoder cross-attention (PinAttention) to emphasize useful reference content, and a hierarchical triplet retrieval loss ranks relevant-but-not-ground-truth descriptions between random and ground-truth ones.
Key results
- PinNet achieves BLEU-4 of 21.83 on CodeXGLUE Python and 23.48 on Java, versus 21.01 and 22.94 for REDCODER.
- On WikiSQL, PinNet reaches BLEU 38.4 vs 32.1 for PreQR2Seq (prior SOTA), and 21.9 on StackOverflow.
- Ablation: removing PinNet-Dis drops Python BLEU from 21.83 to 18.52, and removing the hierarchical retrieval loss drops it to 19.93.
Measured effects reported in the paper
| What was changed | Where | Measured | Effect |
|---|---|---|---|
| Add PinNet-Dis (ablation) | PinNet · CodeXGLUE Python | BLEU-4: 18.52 -> 21.83 | Helped |
| Add PinNet-Dis (ablation) | PinNet · CodeXGLUE Java | BLEU-4: 21.65 -> 23.48 | Helped |
| Add hierarchical retrieval loss LHR (ablation) | PinNet · CodeXGLUE Python | BLEU-4: 19.93 -> 21.83 | Helped |
| Add hierarchical retrieval loss LHR (ablation) | PinNet · CodeXGLUE Java | BLEU-4: 21.78 -> 23.48 | Helped |
| Add PinNet-Dis and LHR (ablation) | PinNet · CodeXGLUE Python | BLEU-4: 17.88 -> 21.83 | Helped |
| Add PinNet-Dis and LHR (ablation) | PinNet · CodeXGLUE Java | BLEU-4: 20.31 -> 23.48 | Helped |
| Add PinNet-Dis (ablation) | PinNet · WikiSQL | BLEU: 37.8 -> 38.4 | Helped |
| Add PinNet-Dis (ablation) | PinNet · StackOverflow | BLEU: 20.4 -> 21.9 | Helped |
| Add hierarchical retrieval loss LHR (ablation) | PinNet-Ret · CodeXGLUE Python retrieval | BLEU-4: 15.13 -> 16.15 | Helped |
| Add hierarchical retrieval loss LHR (ablation) | PinNet-Ret · CodeXGLUE Java retrieval | BLEU-4: 15.88 -> 17.07 | Helped |
Surprising findings
- Vanilla retrieval-augmented GraphCodeBERT (without PinNet-Dis and LHR) performs worse than plain GraphCodeBERT on Python (17.88 vs 17.98), showing misleading retrievals can hurt.
- Thresholding retrieval similarity to remove outliers monotonically decreases REDCODER BLEU, so simple outlier removal does not help.
Limitations
- Top-1 retrieved reference may still be irrelevant, especially with long-distance dependencies beyond the input snippet.
- Added modules increase parameter count and incur about 30% runtime overhead.
Experimental setup
Datasets: CodeXGLUE WikiSQL StackOverflow
Benchmarks: CodeXGLUE Python CodeXGLUE Java WikiSQL StackOverflow
Metrics: BLEU-4 BLEU METEOR ROUGE-L SentenceBERT
Baselines: Seq2Seq Transformer RoBERTa (code) CodeBERT GraphCodeBERT CodeT5 UniXcoder PLBART CodeT5+ kNN-Transformer BM25 + PLBART REDCODER
Builds on: REDCODER GraphCodeBERT CodeBERT Transformer BM25
Closest papers by meaning
- Towards A Generalist Code Embedding Model Based On Massive Data Synthesis (NeurIPS 2025 · similarity 0.87)
- Repoformer: Selective Retrieval for Repository-Level Code Completion (ICML 2024 · similarity 0.87)
- CodeMMR: Bridging Natural Language, Code, and Image for Unified Retrieval (CVPR 2026 · similarity 0.86)
- CoRNStack: High-Quality Contrastive Data for Better Code Retrieval and Reranking (ICLR 2025 · similarity 0.85)
- CONSIDER: Commonalities and Specialties Driven Multilingual Code Retrieval Framework (AAAI 2024 · similarity 0.85)
- CPRet: A Dataset, Benchmark, and Model for Retrieval in Competitive Programming (NeurIPS 2025 · similarity 0.84)
Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.
