SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2310.02954 · ICLR · 2024

DQ-LORE: DUAL QUERIES WITH LOW RANK APPROX-IMATION RE-RANKING FOR IN-CONTEXT LEARNING

Xiaodan Liang, Enze Xie, Zhijiang Guo, Jing Tang, Mbzuai, Chuanyang Zheng, Jing Xiong, Zixuan Li, Yichun Yin, Zhicheng Yang, Qingxing Cao, Haiming Wang, and 2 more

arXiv · PDF · Open in the Atlas

Code that ran

5 of 6 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 2 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 2 failures of our instrument; 1 no recorded run), measured 2026-11-24; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2310.02954.json · badge: /api/ran/2310.02954.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
menik1126/dq-lore canonical (classifier label)
classifier basis: classifier_2025
3 ran · 0 no recorded run
ai4fun/dq-lore marked official in Papers with Code
Papers with Code archive
2 ran · 1 no recorded run
FunctionStatusWhere it lives
BiEncoder Ran
ran on a synthesized input · constructed an object; no result was computed
ai4fun/dq-lore/src/models/biencoder.py
pointer only (licence: NONE) · get_code("dfaca1f598a59445")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, ai4fun/dq-lore when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

create_indices Ran
ran, honoured the contract we drafted
ai4fun/dq-lore/src/models/biencoder.py
pointer only (licence: NONE) · get_code("fbb2083d3607d94f")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, ai4fun/dq-lore when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

encode_field Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
menik1126/dq-lore/src/dataset_readers/base_dsr.py
code served (permissive licence) · get_code("5f8edb1ac23fb481")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Mock. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from unittest.mock import Mock

torch.manual_seed(0)

# Create a minimal tokenizer stand-in
class MinimalTokenizer:
    def encode_plus(self, text, truncation=False, return_tensors=None):
        # Return a mock object with input_ids and attention_mask
        result = Mock()
        # Create small tensors: batch_size=1, seq_len=4
        result.input_ids = torch.tensor([[101, 2054, 2003, 102]], dtype=torch.long)
        result.attention_mask = torch.tensor([[1, 1, 1, 1]], dtype=torch.long)
        return result

# Create a minimal field getter wrapper
class FieldGetterWrapper:
    def __init__(self):
        self.functions = {
            'text_field': lambda example: example.get('text', 'default text')
        }

# Create a minimal dataset wrapper
class DatasetWrapper:
    def __init__(self):
        self.field_getter = FieldGetterWrapper()
        self.dataset = self._create_mock_dataset()
    
    def _create_mock_dataset(self):
        # Create a mock dataset with map method
        mock_dataset = Mock()
        mock_dataset.column_names = ['text', 'label']
        
        # Mock the map method to return a processed dataset
        def mock_map(fn, load_from_cache_file=False, with_indices=False, remove_columns=None, fn_kwargs=None):
            # Simulate processing a couple of examples
            result = Mock()
            result.column_names = ['input_ids', 'attention_mask', 'metadata']
            return result
        
        mock_dataset.map = mock_map
        return mock_dataset

# Create instances
tokenizer = MinimalTokenizer()
dataset_wrapper = DatasetWrapper()
field = 'text_field'
truncation = True

ARGS = {
    'tokenizer': tokenizer,
    'dataset_wrapper': dataset_wrapper,
    'field': field,
    'truncation': truncation
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Mock — a Mock output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
no_init Ran
ran; our contract draft was wrong, not the code
menik1126/dq-lore/src/models/model.py
code served (permissive licence) · get_code("9b34c50ac4c6a1bb")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Sequential. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

def loading_code():
    """A simple function that creates a model with Linear, Embedding, and LayerNorm layers"""
    model = nn.Sequential(
        nn.Embedding(10, 4),
        nn.Linear(4, 3),
        nn.LayerNorm(3)
    )
    return model

ARGS = {
    "loading_code": loading_code
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Sequential — a Sequential output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Sequential output the recorded ndim 1 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
ppl_generate Ran
ran, honoured the contract we drafted
menik1126/dq-lore/src/models/model.py
code served (permissive licence) · get_code("1d6653999130d877")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned list, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import numpy as np

torch.manual_seed(0)

# Create a minimal tokenizer stand-in
class MinimalTokenizer:
    def __init__(self):
        self.pad_token_id = 0
        self.vocab_size = 100
    
    def __call__(self, texts, padding=True, return_tensors=None, truncation=True):
        # Simulate tokenization: convert texts to token ids
        # Return a dict with 'input_ids' and 'attention_mask'
        batch_size = len(texts)
        max_len = 8
        
        input_ids = torch.randint(1, self.vocab_size, (batch_size, max_len))
        # Add some padding tokens
        input_ids[:, 6:] = self.pad_token_id
        
        attention_mask = (input_ids != self.pad_token_id).long()
        
        return {
            'input_ids': input_ids,
            'attention_mask': attention_mask
        }

# Create a minimal language model
class MinimalLM(nn.Module):
    def __init__(self, vocab_size=100, hidden_dim=4):
        super().__init__()
        self.vocab_size = vocab_size
        self.hidden_dim = hidden_dim
        self.embedding = nn.Embedding(vocab_size, hidden_dim)
        self.linear = nn.Linear(hidden_dim, vocab_size)
    
    def forward(self, input_ids, attention_mask=None):
        # Simple forward pass
        x = self.embedding(input_ids)  # (batch, seq_len, hidden_dim)
        logits = self.linear(x)  # (batch, seq_len, vocab_size)
        
        class Output:
            pass
        
        output = Output()
        output.logits = logits
        return output

# Instantiate components
tokenizer = MinimalTokenizer()
model = MinimalLM(vocab_size=100, hidden_dim=4)
device = torch.device('cpu')

# Create input data
input_texts = ["Hello world", "How are you"]
choices_list = [
    ["!", "?"],
    [" today", " now"]
]

ARGS = {
    'input_texts': input_texts,
    'model': model,
    'tokenizer': tokenizer,
    'choices_list': choices_list,
    'device': device
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family int — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
indexing Not yet run
unverified (harvested, no recorded run)
ai4fun/dq-lore/src/models/biencoder.py
pointer only (licence: NONE) · get_code("a063ab5e235969a8")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, ai4fun/dq-lore when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 0 later) and 4 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
indexing
brick of this paper's assembly: helper
1 other paper
1 dated earlier
2302.05698 (2023-02)
Compositional Exemplars for In-context Learning
no_init 1 other paper
1 dated earlier
2212.10375 (2022-12)
Self-Adaptive In-Context Learning: An Information Compression Perspective for In-Context Example Selection and Ordering

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-24.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Recent advances in natural language processing, primarily propelled by Large Language Models (LLMs), have showcased their remarkable capabilities grounded in in-context learning. A promising avenue for guiding LLMs in intricate reasoning tasks involves the utilization of intermediate reasoning steps within the Chain-of-Thought (CoT) paradigm. Nevertheless, the central challenge lies in the effective selection of exemplars for facilitating in-context learning. In this study, we introduce a framework that leverages Dual Queries and Low-rank approximation Re-ranking (DQ-LoRe) to automatically select exemplars for in-context learning. Dual Queries first query LLM to obtain LLM-generated knowledge such as CoT, then query the retriever to obtain the final exemplars via both question and the knowledge. Moreover, for the second query, LoRe employs dimensionality reduction techniques to refine exemplar selection, ensuring close alignment with the input question's knowledge. Through extensive experiments, we demonstrate that DQ-LoRe significantly outperforms prior state-of-the-art methods in the automatic selection of exemplars for GPT-4, enhancing performance from 92.5% to 94.2%. Our comprehensive analysis further reveals that DQ-LoRe consistently outperforms retrieval-based approaches in terms of both performance and adaptability, especially in scenarios characterized by distribution shifts. DQ-LoRe pushes the boundary of in-context learning and opens up new avenues for addressing complex reasoning challenges.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2310.02954")
get_code_for_paper("2310.02954")
have("2310.02954")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2310.02954.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2310.02954.svg)](https://syntology.ai/paper/2310.02954)

Connect an agent — have() is free.