OSCR

A neural-symbolic AI agent system for biomedical concept mapping.

Code ↔ Paper

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

The 3 matches
  1. [1] § Methods › MCM design and implementation ↔ utils/concept.py, lines 226–254 · score 0.74 · Reciprocal Rank Fusion, TF IDF, vector, matrix, Cosine, RRF
  2. [2] § Methods › MCM design and implementation ↔ utils/concept.py, lines 226–254 · score 0.63 · TF IDF, threshold, vectorizer, matrix, cosine, matched
  3. [3] § Methods › MCM design and implementation ↔ utils/concept.py, lines 72–101 · score 0.60 · equivalence judgment, semantically equivalent, invokes, judged, refined, prompt

Paper

Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

Python · 284 lines · 11 KB · no license · 3 matches

  1. from collections import Counter
  2. from collections import defaultdict
  3. from langchain_ollama import ChatOllama
  4. from mcp.server.fastmcp import FastMCP
  5. from pydantic import BaseModel, ValidationError
  6. from scipy.sparse import save_npz, load_npz
  7. from scispacy.linking import CandidateGenerator
  8. from sklearn.feature_extraction.text import TfidfVectorizer
  9. from sklearn.metrics.pairwise import cosine_similarity
  10. from typing import Any, List, Dict, Optional, Union
  11. from typing import Type, TypeVar
  12. from utils import umls
  13. import hydra
  14. import json
  15. import logging
  16. import numpy as np
  17. import pickle
  18. with hydra.initialize(config_path="../config", version_base=None):
  19. similary_context_config = hydra.compose(config_name="ann")
  20. similary_context_ann = json.load(open(similary_context_config.data_path))
  21. similary_context_encoding = pickle.load(open(similary_context_config.encoding_path, "rb"))
  22. similary_context_vectorizer = pickle.load(open(similary_context_config.vec_path, "rb"))
  23. similary_context_threshold = similary_context_config.threshold
  24. with hydra.initialize(config_path="../config", version_base=None):
  25. ollama_config = hydra.compose(config_name="ollama")
  26. llm = ChatOllama(
  27. model=ollama_config.model,
  28. base_url="http://localhost:11434",
  29. # base_url=ollama_config.base_url,
  30. )
  31. with hydra.initialize(config_path="../config", version_base=None):
  32. umls_config = hydra.compose(config_name="umls")
  33. umls_cuis = json.load(open(umls_config.cui_path))
  34. umls_encoding = pickle.load(open(umls_config.encoding_path, "rb"))
  35. umls_vectorizer = pickle.load(open(umls_config.vec_path, "rb"))
  36. umls_threshold = umls_config.threshold
  37. umls_top_k = umls_config.top_k
  38. cui_to_names = umls.load_umls_names_and_aliases()
  39. def extract_json_block(text: str) -> str:
  40. try:
  41. start = text.index('{')
  42. end = text.rindex('}') + 1
  43. return text[start:end].strip()
  44. except ValueError:
  45. raise ValueError(f"No valid JSON object found in the input string: {text}.")
  46. T = TypeVar("T", bound=BaseModel)
  47. def parse_llm_response_as_model(raw_response: str, model: Type[T]) -> T:
  48. """
  49. Parse and validate a JSON string from LLM output using the given Pydantic model.
  50. """
  51. try:
  52. content = raw_response.strip()
  53. content = extract_json_block(content)
  54. content = content.replace("\\n", "\n").replace("\\'", "'")
  55. parsed_json = json.loads(content)
  56. return model(**parsed_json)
  57. except (json.JSONDecodeError, ValidationError) as e:
  58. raise ValueError(f"Parsing failed: {e}")
  59. class EquivalenceJudgment(BaseModel):
  60. result: bool
  61. explanation: str
  62. def judge_refinement_equivalence(
  63. mention: str,
  64. context_snippet: str,
  65. refined_phrase: str
  66. ) -> Dict[str, Union[bool, str]]:
  67. """
  68. Return a dict containing whether the refined phrase is semantically equivalent to the original mention,
  69. and an explanation.
  70. """
  71. prompt = (
  72. f"You are a biomedical expert evaluating whether a refined phrase reasonably captures the same meaning "
  73. f"as the original concept mention, given the surrounding clinical context.\n\n"
  74. f"Original mention: \"{mention}\"\n"
  75. f"Context: \"{context_snippet}\"\n"
  76. f"Refined phrase: \"{refined_phrase}\"\n\n"
  77. f"Only respond `true` if the refined phrase can reasonably be interpreted to mean the same thing "
  78. f"in context, even if there are minor wording differences.\n"
  79. f"Only respond `false` if the meaning is clearly different.\n\n"
  80. f"Respond in JSON format:\n"
  81. '{"result": true/false, "explanation": "brief justification"}'
  82. )
  83. try:
  84. response = llm.invoke(prompt)
  85. return parse_llm_response_as_model(response.content, EquivalenceJudgment).__dict__
  86. except Exception as e:
  87. return {
  88. "result": False,
  89. "explanation": f"Fallback due to error: {str(e)}"
  90. }
  91. def search_similar_contexts(concept: str) -> dict:
  92. """Search contexts that are similar to the input."""
  93. vector = similary_context_vectorizer.transform([concept])
  94. similarity_matrix = cosine_similarity(vector, similary_context_encoding)
  95. idx_to_examples = {}
  96. similarities = similarity_matrix[0]
  97. matching_indices = np.where(similarities >= similary_context_threshold)[0]
  98. matching_scores = similarities[matching_indices]
  99. examples = []
  100. cuis = []
  101. for candidate_idx in matching_indices:
  102. candidate = similary_context_ann[candidate_idx]
  103. cui = candidate['cuis'][0]
  104. cuis.append(cui)
  105. examples.append(candidate)
  106. similar_context = {
  107. 'input': concept,
  108. 'similar_contexts': examples,
  109. }
  110. return similar_context
  111. def search_nearest_neighbors(concept: str, context_snippet: str) -> List[str]:
  112. """
  113. Retrieve CUIs that appear in similar contexts and whose representative names are
  114. semantically equivalent to the input concept within the provided context.
  115. Args:
  116. concept: The original concept mention.
  117. context_snippet: Context around the concept (e.g., sentence or paragraph).
  118. Returns:
  119. A list of CUIs that are semantically equivalent based on neighboring context.
  120. """
  121. similar_context = search_similar_contexts(concept)
  122. candidate_cuis = []
  123. for context in similar_context.get('similar_contexts', []):
  124. candidate_cuis.extend(context.get('cuis', []))
  125. cuis = []
  126. cui_counter = Counter(candidate_cuis)
  127. return [cui for cui, _ in cui_counter.most_common()]
  128. class AugmentationJudgment(BaseModel):
  129. result: bool
  130. explanation: str
  131. def judge_need_for_augmentation(
  132. mention: str,
  133. context_snippet: str
  134. ) -> AugmentationJudgment:
  135. prompt = (
  136. f"You are a biomedical language expert. Given the following concept mention, "
  137. f"determine whether the mention is expressed as regular words.\n\n"
  138. f"Concept mention: \"{mention}\"\n"
  139. f"If the term is not a regular word, respond `true`.\n"
  140. f"Otherwise, respond `false`.\n\n"
  141. f"Respond in JSON format:\n"
  142. f"{{\"result\": true/false, \"explanation\": \"brief justification\"}}"
  143. )
  144. try:
  145. response = llm.invoke(prompt)
  146. return parse_llm_response_as_model(response.content, AugmentationJudgment).__dict__
  147. except Exception as e:
  148. return {
  149. "result": False,
  150. "explanation": f"Fallback due to error: {str(e)}"
  151. }
  152. class AugmentedConcept(BaseModel):
  153. augmented_mention: str
  154. explanation: str
  155. def augment_concept_mention(
  156. mention: str,
  157. context_snippet: str
  158. ) -> Dict[str, Union[str, bool]]:
  159. """
  160. Return a dict containing an augmented version of the mention (if applicable) and an explanation.
  161. If the original mention is already clear and standard, the augmented form may be identical.
  162. """
  163. prompt = (
  164. f"You are a biomedical expert tasked with improving the clarity of a clinical concept mention.\n\n"
  165. f"Concept mention: \"{mention}\"\n"
  166. f"Context: \"{context_snippet}\"\n\n"
  167. f"If the mention is abbreviated or shortened, replace it with a fully spelled term mentioned in the context."
  168. f"If the mention is already standard and clear, keep it unchanged.\n\n"
  169. f"Respond in JSON format:\n"
  170. '{"augmented_mention": "string", "explanation": "brief justification"}'
  171. )
  172. try:
  173. response = llm.invoke(prompt)
  174. return parse_llm_response_as_model(response.content, AugmentedConcept).__dict__
  175. except Exception as e:
  176. return {
  177. "augmented_mention": mention,
  178. "explanation": f"Fallback due to error: {str(e)}. Response: {response.content}"
  179. }
  180. def link_mention_to_concept_ids(concept: str) -> List[str]:
  181. """
  182. Given a concept mention (text string), return a ranked list of UMLS concept IDs
  183. that are semantically similar to the input mention.
  184. """
  185. concept_ids = []
  186. vector = umls_vectorizer.transform([concept])
  187. similarity_matrix = cosine_similarity(vector, umls_encoding)
  188. similarities = similarity_matrix[0]
  189. matching_indices = np.where(similarities >= umls_threshold)[0]
  190. ranked_indices = matching_indices[np.argsort(
  191. similarities[matching_indices])[::-1]]
  192. for candidate_idx in ranked_indices:
  193. cui = umls_cuis[candidate_idx]
  194. if not cui in concept_ids:
  195. concept_ids.append(cui)
  196. if len(concept_ids) >= umls_top_k:
  197. break
  198. return concept_ids
  199. def link_mentions_rrf(candidates: List[str]) -> List[str]:
  200. """
  201. Given multiple textual variants of the same concept, return a merged ranked list of UMLS CUIs
  202. using Reciprocal Rank Fusion (RRF) with batched TF-IDF vectorization.
  203. Returns:
  204. A ranked list of UMLS CUIs.
  205. """
  206. k, rrf_k = umls_top_k, 60
  207. fusion_scores: Dict[str, float] = defaultdict(float)
  208. # Batch vectorize all candidates
  209. vectors = umls_vectorizer.transform(candidates) # shape: (n_candidates, vocab_dim)
  210. similarity_matrix = cosine_similarity(vectors, umls_encoding) # shape: (n_candidates, n_umls)
  211. for i, name in enumerate(candidates):
  212. similarities = similarity_matrix[i]
  213. matching_indices = np.where(similarities >= umls_threshold)[0]
  214. ranked_indices = matching_indices[np.argsort(similarities[matching_indices])[::-1]]
  215. for rank, idx in enumerate(ranked_indices):
  216. cui = umls_cuis[idx]
  217. fusion_scores[cui] += 1.0 / (rrf_k + rank + 1)
  218. if rank + 1 >= umls_top_k:
  219. break
  220. # Sort by descending RRF score
  221. sorted_cuis = sorted(fusion_scores.items(), key=lambda x: x[1], reverse=True)
  222. return [cui for cui, _ in sorted_cuis[:k]]
  223. class ConceptExtraction(BaseModel):
  224. concepts: List[str]
  225. explanation: str
  226. def extract_biomedical_concepts(passage: str) -> Dict[str, Union[List[str], str]]:
  227. """
  228. Extract biomedical concepts from a clinical sentence or paragraph.
  229. """
  230. prompt = (
  231. "You are a biomedical NLP assistant. Given the following clinical sentence or paragraph, "
  232. "identify and list key PICO-related concepts. These may include population groups, interventions, "
  233. "comparators, and outcomes. Only include medically relevant phrases. "
  234. "If no relevant concepts are found, return an empty list.\n\n"
  235. f"Text:\n\"{passage}\"\n\n"
  236. "Respond in the following JSON format:\n"
  237. "{\n"
  238. " \"concepts\": [\"...\", \"...\", ...]\n"
  239. "}"
  240. )
  241. try:
  242. response = llm.invoke(prompt)
  243. return parse_llm_response_as_model(response.content, ConceptExtraction).__dict__
  244. except Exception as e:
  245. return {"concepts": [], "explanation": f"Error: {str(e)}"}

concept.py at commit 0e996f5, no license · at the source

Overview

Authors: Gongbo Zhang1, Yilu Fang1, Fangyi Chen1, Casey Ta1, George Hripcsak1, Patrick Ryan1,2, Yifan Peng3, Chunhua Weng1
  1. Department of Biomedical Informatics, Columbia University, New York, NY USA
  2. Observational Health Data Analytics, Janssen Research and Development, Titusville, NJ USA
  3. Department of Population Health Science, Weill Cornell Medicine, New York, NY USA
Institutions: Columbia University (United States); Janssen (United States) (United States); Weill Cornell Medicine (United States)
Journal: NPJ digital medicine, volume 9, issue 1, article 425
Dates: received 30 October 2025; accepted 20 March 2026; published online 4 April 2026
Type: Research article · Language: English
License: CC BY-NC-ND
Identifiers: DOI 10.1038/s41746-026-02594-6 · PMID 41935204 · PMCID PMC13230558 · OpenAlex W7149388393
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: methods / tools (subfield)
Methods: Physiology & signal measures
Keywords: Computational biology and bioinformatics, Mathematics and computing
Topic: Biomedical Text Mining and Ontologies (Molecular Biology, Biochemistry, Genetics and Molecular Biology), according to OpenAlex
Funding: NLM NIH HHS (R01 LM014344); National Institutes of Health
Citations: cited by 1 paper (Europe PMC); 50 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 3 matches between paragraphs and lines of code.

ebmlab/MedicalConceptMapping

License: none: the authors keep all their rights
State: the link answers, verified on 28 September 2026
Evidence: files inventoried
Commit: 0e996f51f8204a67914845e4518b78590e6216e4, 14 January 2026
Languages: Python (12)
Size: 50 files, 12 scripts
Software Heritage: not archived
Found in: “Data availability”
Holds: README
Not found: license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: NumPy (5 files), scikit-learn (3 files), PyTorch (2 files), Hugging Face Transformers (2 files), SciPy (1 file)
Availability: 1 check, the latest on 28 September 2026: the link answers
  • 28 September 2026: the link answers
13 files

The paper's code and data availability statement is in the Data section.

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;
  • 12 scripts, each with its path and the digest of its content;
  • 3 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

No dataset and no data link were found in the paper.

Code and data availability statement

The paper has a code and 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/s41746-026-02594-6.

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, 8 authors, 2 keywords, 2 funders, 17 references.

Cite

This paper

Zhang, G., Fang, Y., Chen, F., Ta, C., Hripcsak, G., Ryan, P., Peng, Y., & Weng, C. (2026). A neural-symbolic AI agent system for biomedical concept mapping. NPJ digital medicine, 9(1), 425. https://doi.org/10.1038/s41746-026-02594-6

BibTeX

@article{zhang2026neural,
author = {Zhang, Gongbo and Fang, Yilu and Chen, Fangyi and Ta, Casey and Hripcsak, George and Ryan, Patrick and Peng, Yifan and Weng, Chunhua},
title = {{A neural-symbolic AI agent system for biomedical concept mapping}},
journal = {NPJ digital medicine},
year = {2026},
month = apr,
volume = {9},
number = {1},
pages = {425},
publisher = {Nature Publishing Group},
issn = {2398-6352},
doi = {10.1038/s41746-026-02594-6},
url = {https://doi.org/10.1038/s41746-026-02594-6},
pmid = {41935204},
pmcid = {PMC13230558}
}

RIS

TY - JOUR
AU - Zhang, Gongbo
AU - Fang, Yilu
AU - Chen, Fangyi
AU - Ta, Casey
AU - Hripcsak, George
AU - Ryan, Patrick
AU - Peng, Yifan
AU - Weng, Chunhua
TI - A neural-symbolic AI agent system for biomedical concept mapping
T2 - NPJ digital medicine
J2 - NPJ Digit Med
PY - 2026
DA - 2026/04/04
VL - 9
IS - 1
SP - 425
SN - 2398-6352
PB - Nature Publishing Group
DO - 10.1038/s41746-026-02594-6
UR - https://doi.org/10.1038/s41746-026-02594-6
LA - en
ER -

CSL-JSON

{
"id": "10.1038/s41746-026-02594-6",
"type": "article-journal",
"title": "A neural-symbolic AI agent system for biomedical concept mapping",
"container-title": "NPJ digital medicine",
"author": [
{
"family": "Zhang",
"given": "Gongbo"
},
{
"family": "Fang",
"given": "Yilu"
},
{
"family": "Chen",
"given": "Fangyi"
},
{
"family": "Ta",
"given": "Casey"
},
{
"family": "Hripcsak",
"given": "George"
},
{
"family": "Ryan",
"given": "Patrick"
},
{
"family": "Peng",
"given": "Yifan"
},
{
"family": "Weng",
"given": "Chunhua"
}
],
"container-title-short": "NPJ Digit Med",
"volume": "9",
"issue": "1",
"page": "425",
"DOI": "10.1038/s41746-026-02594-6",
"PMID": "41935204",
"PMCID": "PMC13230558",
"ISSN": "2398-6352",
"publisher": "Nature Publishing Group",
"URL": "https://doi.org/10.1038/s41746-026-02594-6",
"language": "en",
"issued": {
"date-parts": [
[
2026,
4,
4
]
]
}
}

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.1371/journal.pone.0354511 [code]
TokenUNet: A new case for transformers integration in efficient and interpretable 3D UNets for brain imaging segmentation.
Journal: PloS one
In common: Hugging Face Transformers, PyTorch, scikit-learn, 2 other tools, methods / tools
[2] 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, PyTorch, scikit-learn, 2 other tools, methods / tools
[3] doi:10.1038/s41586-026-10658-6 [code]
An AI system to help scientists write expert-level empirical software.
Journal: Nature
In common: Hugging Face Transformers, PyTorch, scikit-learn, 2 other tools, methods / tools
[4] doi:10.1038/s41467-026-72253-7 [code]
Spurious alignment between large language models and brains can emerge from non-robust methods and overlooked confounds.
Journal: Nature communications
In common: Hugging Face Transformers, PyTorch, scikit-learn, 2 other tools, methods / tools
[5] doi:10.1371/journal.pone.0346575 [code]
Statistically valid explainable black-box machine learning: applications in sex classification across species using brain imaging.
Journal: PloS one
In common: Hugging Face Transformers, PyTorch, scikit-learn, 2 other tools, methods / tools
[6] doi:10.1002/hbm.70469 [code]
VarCoNet: A Variability-Aware Self-Supervised Framework for Functional Connectome Extraction From Resting-State fMRI.
Journal: Human brain mapping
In common: Hugging Face Transformers, PyTorch, scikit-learn, 2 other tools, methods / tools
[7] doi:10.1038/s41598-025-29587-x [code]
Evaluating EEG-to-text models through noise-based performance analysis
Journal: n/a
In common: Hugging Face Transformers, PyTorch, scikit-learn, 2 other tools, methods / tools
[8] doi:10.1038/s42003-026-10957-8 [code]
Brain defence by the extracellular matrix protein Cochlin.
Journal: Communications biology
In common: Hugging Face Transformers, PyTorch, scikit-learn, 2 other tools
[9] doi:10.7554/elife.101204 [code]
Larger language models better align with neural representations of natural language.
Journal: eLife
In common: Hugging Face Transformers, PyTorch, scikit-learn, 2 other tools
[10] doi:10.1038/s43856-026-01817-x [code]
Visual prompt engineering for multimodal and irregularly sampled medical data.
Journal: Communications medicine
In common: Hugging Face Transformers, PyTorch, scikit-learn, 2 other tools

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.

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: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.

Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.

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