SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2106.03760 · NeurIPS · 2021

DSelect-k: Differentiable Selection in the Mixture of Experts with Applications to Multi-Task Learning

Ed Chi, Hussein Hazimeh, Rahul Mazumder, Zhe Zhao, Aakanksha Chowdhery, Maheswaran Sathiamoorthy, Yihua Chen, Lichan Hong

arXiv · PDF · Open in the Atlas

Code that ran

8 of 9 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 8 have no contract verdict; 0 failures of our instrument; 1 no recorded run), measured 2026-11-22; 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/2106.03760.json · badge: /api/ran/2106.03760.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
Andy1314Chen/PaddleRec community (classifier label)
classifier basis not recorded on the link
7 ran · 0 no recorded run
google-research/google-research unrelated (classifier label)
classifier basis: classifier_2025
1 ran · 1 no recorded run
FunctionStatusWhere it lives
SmoothStep Ran
ran on a synthesized input
google-research/google-research/dselect_k_moe/dselect_k_moe.py
code served (permissive licence) · get_code("c7f7716bc175db79")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned EagerTensor, ndim 2, dtype family float; 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 tensorflow as tf
import numpy as np

# INIT_ARGS for SmoothStep.__init__
INIT_ARGS = {
    'gamma': 2.0
}

# ARGS for SmoothStep.call (or __call__)
ARGS = {
    'inputs': tf.constant([[-1.5, -0.5, 0.0, 0.5, 1.5],
                          [-2.0, -0.25, 0.25, 1.0, 2.0]], dtype=tf.float32)
}

METHOD = 'call'
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EagerTensor, ndim 2, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
fun1 Ran
ran on a synthesized input
Andy1314Chen/PaddleRec/datasets/census/data_preparation.py
code served (permissive licence) · get_code("b0a4669173a5fc3d")
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, through the batch API) and returned int, ndim 0, dtype family int, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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 numpy as np

torch.manual_seed(0)

ARGS = {
    'x': ' 50000+.'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, shape () — shape () as a later run recorded it
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
fun2 Ran
ran on a synthesized input
Andy1314Chen/PaddleRec/datasets/census/data_preparation.py
code served (permissive licence) · get_code("4b20e0a2441ecb28")
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, through the batch API) and returned int, ndim 0, dtype family int, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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 numpy as np

torch.manual_seed(0)

# The function fun2 takes a single parameter x and compares it to the string ' Never married'
# It returns 1 if x equals ' Never married', else 0
# No complex objects or models are needed - just a string value

ARGS = {
    'x': ' Never married'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, shape () — shape () as a later run recorded it
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
load_graph Ran
ran on a synthesized input
Andy1314Chen/PaddleRec/datasets/AmazonBook/preprocess.py
code served (permissive licence) · get_code("e192b64a7c6ac2de")
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, through the batch API) and returned dict. 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 tempfile
import os

# Create a temporary CSV file with test data
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.csv')
temp_file.write("1,10,100\n")
temp_file.write("1,20,50\n")
temp_file.write("2,30,200\n")
temp_file.write("1,40,75\n")
temp_file.write("2,35,150\n")
temp_file.close()

ARGS = {
    "source": temp_file.name
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 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
native_to_unicode Ran
ran on a synthesized input
Andy1314Chen/PaddleRec/datasets/one_billion/preprocess.py
code served (permissive licence) · get_code("30082085af20d54d")
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, through the batch API) and returned str. 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 six

def _is_unicode(s):
    if six.PY2:
        if isinstance(s, unicode):
            return True
    elif isinstance(s, str):
        return True
    return False

def _to_unicode(s, ignore_errors=False):
    if _is_unicode(s):
        return s
    error_mode = 'ignore' if ignore_errors else 'strict'
    return s.decode('utf-8', errors=error_mode)

def native_to_unicode(s):
    if _is_unicode(s):
        return s
    try:
        return _to_unicode(s)
    except UnicodeDecodeError:
        res = _to_unicode(s, ignore_errors=True)
        return res

# Test case 1: unicode string (already unicode)
test_unicode_string = "hello world"

# Test case 2: bytes that decode cleanly to utf-8
test_bytes_utf8 = "café".encode('utf-8')

# Test case 3: bytes with invalid utf-8 that will trigger UnicodeDecodeError
test_bytes_invalid = b'\xff\xfe'

ARGS = {
    "s": test_unicode_string
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
six — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 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
read_embedding Ran
ran on a synthesized input
Andy1314Chen/PaddleRec/datasets/letor07/process.py
code served (permissive licence) · get_code("d1c5bda937752b7c")
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, through the batch API) and returned dict. 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 tempfile
import os

# Create a temporary file with embedding data
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt')
temp_filename = temp_file.name

# Write sample embedding data to the temp file
# Format: id followed by embedding values
temp_file.write("0 0.1 0.2 0.3 0.4\n")
temp_file.write("1 0.5 0.6 0.7 0.8\n")
temp_file.write("2 0.9 1.0 1.1 1.2\n")
temp_file.close()

ARGS = {
    'filename': temp_filename
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 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
text_strip Ran
ran on a synthesized input
Andy1314Chen/PaddleRec/datasets/one_billion/preprocess.py
code served (permissive licence) · get_code("fc15fd4903900e23")
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, through the batch API) and returned str. 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 re

prog = re.compile('[^a-z ]', flags=0)

def text_strip(text):
    return prog.sub('', text.lower())

ARGS = {
    'text': 'Hello World! 123 @#$% Test'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 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
word_count Ran
ran on a synthesized input
Andy1314Chen/PaddleRec/datasets/ag_news/text2paddle.py
code served (permissive licence) · get_code("5d079a1802fd6cb9")
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, through the batch API) and returned defaultdict. 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 collections
import csv
import re
import io

# Create a small CSV file in memory
csv_content = """hello world,test data
foo bar baz,another row
hello foo test,final row"""

input_file = io.StringIO(csv_content)

ARGS = {
    "column_num": 0,
    "input_file": input_file,
    "word_freq": None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type defaultdict — a defaultdict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a defaultdict output the recorded ndim 0 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
DSelectKGate Not yet run
unverified (harvested, no recorded run)
google-research/google-research/dselect_k_moe/dselect_k_moe.py
code served (permissive licence) · get_code("7f0363937bd725ba")
How it ran

no invocation recorded.

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 5 are also present in other papers whose code we hold (5 with at least one paper dated earlier, 0 the same month, 2 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
load_graph 3 other papers
2 dated earlier, 1 later
2003.11235 (2020-03)
AutoFIS: Automatic Feature Interaction Selection in Factorization Models for Click-Through Rate Prediction
2008.13535 (2020-08)
DCN V2: Improved Deep & Cross Network and Practical Lessons for Web-scale Learning to Rank Systems
2204.05125 (2022-04)
ESCM$^2$: Entire Space Counterfactual Multi-Task Model for Post-Click Conversion Rate Estimation
word_count 3 other papers
2 dated earlier, 1 later
2003.11235 (2020-03)
AutoFIS: Automatic Feature Interaction Selection in Factorization Models for Click-Through Rate Prediction
2008.13535 (2020-08)
DCN V2: Improved Deep & Cross Network and Practical Lessons for Web-scale Learning to Rank Systems
2204.05125 (2022-04)
ESCM$^2$: Entire Space Counterfactual Multi-Task Model for Post-Click Conversion Rate Estimation
fun1 2 other papers
2 dated earlier
2003.11235 (2020-03)
AutoFIS: Automatic Feature Interaction Selection in Factorization Models for Click-Through Rate Prediction
2008.13535 (2020-08)
DCN V2: Improved Deep & Cross Network and Practical Lessons for Web-scale Learning to Rank Systems
fun2 2 other papers
2 dated earlier
2003.11235 (2020-03)
AutoFIS: Automatic Feature Interaction Selection in Factorization Models for Click-Through Rate Prediction
2008.13535 (2020-08)
DCN V2: Improved Deep & Cross Network and Practical Lessons for Web-scale Learning to Rank Systems
read_embedding 1 other paper
1 dated earlier
2008.13535 (2020-08)
DCN V2: Improved Deep & Cross Network and Practical Lessons for Web-scale Learning to Rank Systems

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-22.

Repositories linked to this paper

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

Abstract

The Mixture-of-Experts (MoE) architecture is showing promising results in improving parameter sharing in multi-task learning (MTL) and in scaling high-capacity neural networks. State-of-the-art MoE models use a trainable "sparse gate" to select a subset of the experts for each input example. While conceptually appealing, existing sparse gates, such as Top-k, are not smooth. The lack of smoothness can lead to convergence and statistical performance issues when training with gradientbased methods. In this paper, we develop DSelect-k: a continuously differentiable and sparse gate for MoE, based on a novel binary encoding formulation. The gate can be trained using first-order methods, such as stochastic gradient descent, and offers explicit control over the number of experts to select. We demonstrate the effectiveness of DSelect-k on both synthetic and real MTL datasets with up to 128 tasks. Our experiments indicate that DSelect-k can achieve statistically significant improvements in prediction and expert selection over popular MoE gates. Notably, on a real-world, large-scale recommender system, DSelect-k achieves over 22% improvement in predictive performance compared to Top-k. We provide an open-source implementation of DSelect-k 1 .

For agents

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

get_harvested_code_for_paper("2106.03760")
get_code_for_paper("2106.03760")
have("2106.03760")

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

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

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

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

Connect an agent — have() is free.