OSCR

Human-like cognitive generalization for large models via mental representation-guided supervision.

Code ↔ Paper

7 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

5 blocks of code here have a permanent identifier (oscr:b:…), listed with the matches below: citable for good, with a page of its own. Select a match and press Cite to copy it. What a block identifier is.

The 7 matches · 1 of them tie a paragraph to a whole file without given lines: a weak match, whose lines are not tinted
  1. [1] § Methods › Mental representation-guided supervised learning › Correspondence construction via optimal transport (OT) ↔ modules/LSP/optimal_Transport.py, lines 4 to 93 · score 0.78 · optimal transport plan, Sinkhorn algorithm, regularized OT, Wasserstein, iterative, matrix · block oscr:b:EADF6DJRW0K5K-N · Report a mismatch
  2. [2] § Methods › Architecture and optimization › Loss function ↔ modules/LSP/optimal_Transport.py, lines 4 to 93 · score 0.74 · Sinkhorn iterations, regularized OT, transport plan, cost matrix · block oscr:b:EADF6DJRW0K5K-N · Report a mismatch
  3. [3] § Methods › Datasets › fMRI data ↔ data/data_config.py, the whole file · a weak match · score 0.62 · ImageNet, fMRI, FFA, LOC, PPA, stimuli · block oscr:b:MEPAZM4QB5M1P-V · Report a mismatch
  4. [4] § Methods › Architecture and optimization › Loss function ↔ modules/LSP/encoder.py, lines 30 to 127 · score 0.59 · fMRI encoders, cost matrix, kernel, OT, iterations, Loss · block oscr:b:XH4TGFBP0ABZ7-4 · Report a mismatch
  5. [5] § Methods › Architecture and optimization › Model architecture ↔ modules/LSP/encoder.py, lines 30 to 127 · score 0.59 · Gumbel Softmax, GNN, sampler, scores, head, encoders · block oscr:b:XH4TGFBP0ABZ7-4 · Report a mismatch
  6. [6] § Methods › Architecture and optimization › Loss function ↔ modules/LSP/GW_OT.py, lines 269 to 286 · score 0.53 · probability vectors, GW distance · block oscr:b:1FC7N0E5653VT-C · Report a mismatch
  7. [7] § Methods › Mental representation-guided supervised learning › Correspondence construction via optimal transport (OT) ↔ modules/LSP/GW_OT.py, lines 8 to 19 · score 0.51 · cosine distance, cost matrix, OT, transport · block oscr:b:E4DRET5JJREKW-Z · Report a mismatch

Paper

Loaded from Europe PMC by your browser; OSCR does not store it: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

Python · 134 lines · 4.9 KB · no license · 2 matches

  1. import torch
  2. import torch.nn as nn
  3. # Adapted from https://github.com/gpeyre/SinkhornAutoDiff
  4. class SinkhornDistance(nn.Module):
  5. r"""
  6. Given two empirical measures each with :math:`P_1` locations
  7. :math:`x\in\mathbb{R}^{D_1}` and :math:`P_2` locations :math:`y\in\mathbb{R}^{D_2}`,
  8. outputs an approximation of the regularized OT cost for point clouds.
  9. Args:
  10. eps (float): regularization coefficient
  11. max_iter (int): maximum number of Sinkhorn iterations
  12. reduction (string, optional): Specifies the reduction to apply to the output:
  13. 'none' | 'mean' | 'sum'. 'none': no reduction will be applied,
  14. 'mean': the sum of the output will be divided by the number of
  15. elements in the output, 'sum': the output will be summed. Default: 'none'
  16. Shape:
  17. - Input: :math:`(N, P_1, D_1)`, :math:`(N, P_2, D_2)`
  18. - Output: :math:`(N)` or :math:`()`, depending on `reduction`
  19. """
  20. def __init__(self, eps, max_iter, reduction='none'):
  21. super(SinkhornDistance, self).__init__()
  22. self.eps = eps
  23. self.max_iter = max_iter
  24. self.reduction = reduction
  25. def forward(self, x, y):
  26. # The Sinkhorn algorithm takes as input three variables :
  27. C = self._cost_matrix(x, y) # Wasserstein cost function
  28. x_points = x.shape[-2]
  29. y_points = y.shape[-2]
  30. if x.dim() == 2:
  31. batch_size = 1
  32. else:
  33. batch_size = x.shape[0]
  34. # both marginals are fixed with equal weights
  35. mu = torch.empty(batch_size, x_points, dtype=torch.float,
  36. requires_grad=False).fill_(1.0 / x_points).squeeze()
  37. nu = torch.empty(batch_size, y_points, dtype=torch.float,
  38. requires_grad=False).fill_(1.0 / y_points).squeeze()
  39. u = torch.zeros_like(mu)
  40. v = torch.zeros_like(nu)
  41. # To check if algorithm terminates because of threshold
  42. # or max iterations reached
  43. actual_nits = 0
  44. # Stopping criterion
  45. thresh = 1e-1
  46. # Sinkhorn iterations
  47. for i in range(self.max_iter):
  48. u1 = u # useful to check the update
  49. u = self.eps * (torch.log(mu+1e-8) - torch.logsumexp(self.M(C, u, v), dim=-1)) + u
  50. v = self.eps * (torch.log(nu+1e-8) - torch.logsumexp(self.M(C, u, v).transpose(-2, -1), dim=-1)) + v
  51. err = (u - u1).abs().sum(-1).mean()
  52. actual_nits += 1
  53. if err.item() < thresh:
  54. break
  55. U, V = u, v
  56. # Transport plan pi = diag(a)*K*diag(b)
  57. pi = torch.exp(self.M(C, U, V))
  58. # Sinkhorn distance
  59. cost = torch.sum(pi * C, dim=(-2, -1))
  60. if self.reduction == 'mean':
  61. cost = cost.mean()
  62. elif self.reduction == 'sum':
  63. cost = cost.sum()
  64. return cost, pi, C
  65. def M(self, C, u, v):
  66. "Modified cost for logarithmic updates"
  67. "$M_{ij} = (-c_{ij} + u_i + v_j) / \epsilon$"
  68. return (-C + u.unsqueeze(-1) + v.unsqueeze(-2)) / self.eps
  69. @staticmethod
  70. def _cost_matrix(x, y, p=2):
  71. "Returns the matrix of $|x_i-y_j|^p$."
  72. x_col = x.unsqueeze(-2)
  73. y_lin = y.unsqueeze(-3)
  74. C = torch.sum((torch.abs(x_col - y_lin)) ** p, -1)
  75. return C
  76. @staticmethod
  77. def ave(u, u1, tau):
  78. "Barycenter subroutine, used by kinetic acceleration through extrapolation."
  79. return tau * u + (1 - tau) * u1
  80. def log_sinkhorn_iterations(Z, log_mu, log_nu, iters: int):
  81. """ Perform Sinkhorn Normalization in Log-space for stability"""
  82. u, v = torch.zeros_like(log_mu), torch.zeros_like(log_nu)
  83. for _ in range(iters):
  84. u = log_mu - torch.logsumexp(Z + v.unsqueeze(1), dim=2)
  85. v = log_nu - torch.logsumexp(Z + u.unsqueeze(2), dim=1)
  86. return Z + u.unsqueeze(2) + v.unsqueeze(1)
  87. def log_optimal_transport(scores, alpha, iters: int, use_bin = False):
  88. """ Perform Differentiable Optimal Transport in Log-space for stability"""
  89. b, m, n = scores.shape
  90. one = scores.new_tensor(1)
  91. ms, ns = (m*one).to(scores), (n*one).to(scores)
  92. if(use_bin):
  93. bins0 = alpha.expand(b, m, 1)
  94. bins1 = alpha.expand(b, 1, n)
  95. alpha = alpha.expand(b, 1, 1)
  96. couplings = torch.cat([torch.cat([scores, bins0], -1),
  97. torch.cat([bins1, alpha], -1)], 1)
  98. norm = - (ms + ns).log()
  99. log_mu = torch.cat([norm.expand(m), ns.log()[None] + norm])
  100. log_nu = torch.cat([norm.expand(n), ms.log()[None] + norm])
  101. log_mu, log_nu = log_mu[None].expand(b, -1), log_nu[None].expand(b, -1)
  102. else:
  103. couplings = scores
  104. norm = - (ms + ns).log()
  105. log_mu = norm.expand(m)
  106. log_nu = norm.expand(n)
  107. log_mu, log_nu = log_mu[None].expand(b, -1), log_nu[None].expand(b, -1)
  108. Z = log_sinkhorn_iterations(couplings, log_mu, log_nu, iters)
  109. Z = Z - norm # multiply probabilities by M+N
  110. return Z

optimal_Transport.py at commit 9bf6b66, no license · at the source

Overview

Authors: Jiaxuan Chen1,2, Yu Qi2,3, Yueming Wang1, Gang Pan1,2
  1. College of Computer Science and Technology, Zhejiang University, Hangzhou, China
  2. State Key Lab of Brain-Machine Intelligence, Zhejiang University, Hangzhou, China
  3. Affiliated Mental Health Center and Hangzhou Seventh People’s Hospital, MOE Frontier Science Center for Brain Science and Brain-Machine Integration, Zhejiang University, Hangzhou, China
Journal: Nature communications, volume 17, issue 1, article 4709
Dates: received 14 July 2025; accepted 16 March 2026; published online 1 April 2026
Type: Research article · Language: English
License: CC BY-NC-ND
Identifiers: DOI 10.1038/s41467-026-71267-5 · PMID 41922362 · PMCID PMC13212952 · OpenAlex W7147099499
Open access: gold, a free copy (OpenAlex)
Status: code verified (how the code is found and verified)
Categories: human (organism), cognitive (subfield)
Methods: Statistics, Machine learning, Smoothing, state filtering, decompositions
Keywords: Computer science, Cognitive neuroscience
MeSH: Cognition*, Generalization, Psychological*, Neural Networks, Computer*, Brain, Comprehension, Deep Learning, Humans, Large Language Models (* major topic)
Topic: Domain Adaptation and Few-Shot Learning (Artificial Intelligence, Computer Science), according to OpenAlex
Funding: National Natural Science Foundation of China (National Science Foundation of China) (624B2127); Natural Science Foundation of Zhejiang Province (LR24F020002)
Citations: not cited yet (Europe PMC); 55 references in the paper

Abstract

The abstract is not reproduced here: the paper's license (CC BY-NC-ND) does not allow it. Read it in the paper, at the publisher or on Europe PMC.

Repository

Its files are read in the Code ↔ Paper reader above, with 7 matches between paragraphs and lines of code.

JxuanC/mental-representation-guided-learning

License: none: the authors keep all their rights
State: the link answers, verified on 28 September 2026
Evidence: files inventoried
Commit: 9bf6b6629033823e786142eaa00eff332d2bd929, 14 August 2026
Languages: Python (33)
Size: 39 files, 33 scripts
Software Heritage: not archived
Found in: “Code availability”
Holds: README, environment (requirements.txt)
Not found: license file, CITATION.cff, tests, continuous integration, documentation
Tools: PyTorch (29 files), NumPy (19 files), Pillow (13 files), pandas (12 files), h5py (8 files), Hugging Face Transformers (8 files), Matplotlib (3 files), scikit-learn (3 files), PyTorch Geometric (1 file), scikit-image (1 file), SciPy (1 file), UMAP (1 file)
Availability: 1 check, the latest on 28 September 2026: the link answers
  • 28 September 2026: the link answers
34 files

Code availability statement

The paper has a code availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:

Read it in the paper: doi.org/10.1038/s41467-026-71267-5.

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

  • 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 33 scripts, each with its path and the digest of its content;
  • 7 matches between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

Datasets cited

Data availability statement

The paper has a data availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:

Read it in the paper: doi.org/10.1038/s41467-026-71267-5.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 1, 28 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 4 authors, 2 keywords, 8 MeSH terms, 2 funders, 25 references.

Cite

This paper

Chen, J., Qi, Y., Wang, Y., & Pan, G. (2026). Human-like cognitive generalization for large models via mental representation-guided supervision. Nature communications, 17(1), 4709. https://doi.org/10.1038/s41467-026-71267-5

BibTeX

@article{chen2026human,
author = {Chen, Jiaxuan and Qi, Yu and Wang, Yueming and Pan, Gang},
title = {{Human-like cognitive generalization for large models via mental representation-guided supervision}},
journal = {Nature communications},
year = {2026},
month = apr,
volume = {17},
number = {1},
pages = {4709},
publisher = {Nature Portfolio},
issn = {2041-1723},
doi = {10.1038/s41467-026-71267-5},
url = {https://doi.org/10.1038/s41467-026-71267-5},
pmid = {41922362},
pmcid = {PMC13212952}
}

RIS

TY - JOUR
AU - Chen, Jiaxuan
AU - Qi, Yu
AU - Wang, Yueming
AU - Pan, Gang
TI - Human-like cognitive generalization for large models via mental representation-guided supervision
T2 - Nature communications
J2 - Nat Commun
PY - 2026
DA - 2026/04/01
VL - 17
IS - 1
SP - 4709
SN - 2041-1723
PB - Nature Portfolio
DO - 10.1038/s41467-026-71267-5
UR - https://doi.org/10.1038/s41467-026-71267-5
LA - en
ER -

CSL-JSON

{
"id": "10.1038/s41467-026-71267-5",
"type": "article-journal",
"title": "Human-like cognitive generalization for large models via mental representation-guided supervision",
"container-title": "Nature communications",
"author": [
{
"family": "Chen",
"given": "Jiaxuan"
},
{
"family": "Qi",
"given": "Yu"
},
{
"family": "Wang",
"given": "Yueming"
},
{
"family": "Pan",
"given": "Gang"
}
],
"container-title-short": "Nat Commun",
"volume": "17",
"issue": "1",
"page": "4709",
"DOI": "10.1038/s41467-026-71267-5",
"PMID": "41922362",
"PMCID": "PMC13212952",
"ISSN": "2041-1723",
"publisher": "Nature Portfolio",
"URL": "https://doi.org/10.1038/s41467-026-71267-5",
"language": "en",
"issued": {
"date-parts": [
[
2026,
4,
1
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.1073/pnas.2512514122 [code]
Revealing emergent human-like conceptual representations from language prediction.
Journal: Proceedings of the National Academy of Sciences of the United States of America
In common: Hugging Face Transformers, PyTorch, scikit-learn, 4 other tools, OSF f5rn6, cognitive, 7 references
[2] doi:10.1038/s42003-026-09685-w [code]
Achieving more human brain-like vision via human EEG representational alignment.
Journal: Communications biology
In common: Hugging Face Transformers, h5py, Pillow, 6 other tools, figshare 7033577, cognitive, 4 references
[3] doi:10.1126/sciadv.adj3906 [code]
Reconstructing visual illusory experiences from human brain activity.
Journal: Science advances
In common: scikit-image, h5py, Pillow, 6 other tools, OpenNeuro ds001506, 2 references
[4] doi:10.3389/fnins.2021.795488 [code]
Natural Image Reconstruction From fMRI Using Deep Learning: A Survey.
Journal: Frontiers in neuroscience
In common: h5py, Pillow, scikit-learn, 4 other tools, OpenNeuro ds001506, 4 references
[5] doi:10.1038/s42003-021-02975-5 [code]
Attention modulates neural representation to render reconstructions according to subjective appearance.
Journal: Communications biology
In common: scikit-image, h5py, Pillow, 5 other tools, OpenNeuro ds001506, cognitive, 2 references
[6] doi:10.1016/j.neuroimage.2022.119754 [code]
A large and rich EEG dataset for modeling human visual object recognition.
Journal: NeuroImage
In common: Pillow, PyTorch, scikit-learn, 4 other tools, 7 references
[7] doi:10.1038/s41467-026-69345-9 [code]
A 7T fMRI dataset of synthetic images for out-of-distribution modeling of vision.
Journal: Nature communications
In common: h5py, Pillow, PyTorch, 5 other tools, 6 references
[8] doi:10.1038/s42003-026-10144-9 [code]
Low-power differencing feature extracts spiking-band activities for high-performance intracortical brain-computer interfaces.
Journal: Communications biology
In common: PyTorch, scikit-learn, SciPy, 2 other tools, 2 authors
[9] doi:10.1162/imag.a.1299 [code]
A modular semantic-structural pipeline for visual decoding from primate spiking data via selective temporal integration.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: Hugging Face Transformers, scikit-image, h5py, 7 other tools, 3 references
[10] doi:10.7554/elife.107933 [code]
Modality-agnostic decoding of vision and language from fMRI.
Journal: eLife
In common: Hugging Face Transformers, scikit-image, h5py, 7 other tools, cognitive, 3 references

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

Add the badge to the code's README

OSCR: the badge of this paper

If you are an author or a maintainer of this paper's code, you can add this badge. It says what OSCR knows of the paper (its code, its validated tracing map) and links the code to this page. Paste one of these snippets under the README's title. Keep the two marks around it, so that the badge can be replaced in place and is never added twice. OSCR changes nothing in your repository.

Markdown
<!-- oscr-badge:start -->
[![OSCR](https://openscicode.org/badge/doi/10.1038/s41467-026-71267-5.svg)](https://openscicode.org/badge/doi/10.1038/s41467-026-71267-5)
<!-- oscr-badge:end -->
reStructuredText
.. oscr-badge:start

.. image:: https://openscicode.org/badge/doi/10.1038/s41467-026-71267-5.svg
   :target: https://openscicode.org/badge/doi/10.1038/s41467-026-71267-5
   :alt: OSCR

.. oscr-badge:end
HTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.1038/s41467-026-71267-5"><img src="https://openscicode.org/badge/doi/10.1038/s41467-026-71267-5.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->

On GitHub, open the README, choose Edit (the pencil), paste the snippet under the title, then "Commit changes".

If you choose to, you can have the badge kept up to date for you, with oscr badge --write from the command line or with the GitHub Action in your repository's workflows. Every other form and option (a card, AsciiDoc, LaTeX, shields.io) is on the badge page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: code errors and mismatches between the code and the paper about this paper and its code, from readers and its authors, beside the paper and its tracing map.

Report a mismatch between the code and the paper · Report a code error (signed in)

Reproductions: reports from readers who ran the authors' code and did not get the paper's result, what they ran, with which environment, commit and data.

Report a reproduction failure (signed in)

Versions of its code: the releases of its code tied to a version of this paper (the preprint, the accepted manuscript, the version of record…), each with the tracing map versioned with it.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.