A neural-symbolic AI agent system for biomedical concept mapping.
The 3 matches
- [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] § Methods › MCM design and implementation ↔ utils/concept.py, lines 226–254 · score 0.63 · TF IDF, threshold, vectorizer, matrix, cosine, matched
- [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
- from collections import Counter
- from collections import defaultdict
- from langchain_ollama import ChatOllama
- from mcp.server.fastmcp import FastMCP
- from pydantic import BaseModel, ValidationError
- from scipy.sparse import save_npz, load_npz
- from scispacy.linking import CandidateGenerator
- from sklearn.feature_extraction.text import TfidfVectorizer
- from sklearn.metrics.pairwise import cosine_similarity
- from typing import Any, List, Dict, Optional, Union
- from typing import Type, TypeVar
- from utils import umls
- import hydra
- import json
- import logging
- import numpy as np
- import pickle
- with hydra.initialize(config_path="../config", version_base=None):
- similary_context_config = hydra.compose(config_name="ann")
- similary_context_ann = json.load(open(similary_context_config.data_path))
- similary_context_encoding = pickle.load(open(similary_context_config.encoding_path, "rb"))
- similary_context_vectorizer = pickle.load(open(similary_context_config.vec_path, "rb"))
- similary_context_threshold = similary_context_config.threshold
- with hydra.initialize(config_path="../config", version_base=None):
- ollama_config = hydra.compose(config_name="ollama")
- llm = ChatOllama(
- model=ollama_config.model,
- base_url="http://localhost:11434",
- # base_url=ollama_config.base_url,
- )
- with hydra.initialize(config_path="../config", version_base=None):
- umls_config = hydra.compose(config_name="umls")
- umls_cuis = json.load(open(umls_config.cui_path))
- umls_encoding = pickle.load(open(umls_config.encoding_path, "rb"))
- umls_vectorizer = pickle.load(open(umls_config.vec_path, "rb"))
- umls_threshold = umls_config.threshold
- umls_top_k = umls_config.top_k
- cui_to_names = umls.load_umls_names_and_aliases()
- def extract_json_block(text: str) -> str:
- try:
- start = text.index('{')
- end = text.rindex('}') + 1
- return text[start:end].strip()
- except ValueError:
- raise ValueError(f"No valid JSON object found in the input string: {text}.")
- T = TypeVar("T", bound=BaseModel)
- def parse_llm_response_as_model(raw_response: str, model: Type[T]) -> T:
- """
- Parse and validate a JSON string from LLM output using the given Pydantic model.
- """
- try:
- content = raw_response.strip()
- content = extract_json_block(content)
- content = content.replace("\\n", "\n").replace("\\'", "'")
- parsed_json = json.loads(content)
- return model(**parsed_json)
- except (json.JSONDecodeError, ValidationError) as e:
- raise ValueError(f"Parsing failed: {e}")
- class EquivalenceJudgment(BaseModel):
- result: bool
- explanation: str
- def judge_refinement_equivalence(
- mention: str,
- context_snippet: str,
- refined_phrase: str
- ) -> Dict[str, Union[bool, str]]:
- """
- Return a dict containing whether the refined phrase is semantically equivalent to the original mention,
- and an explanation.
- """
- prompt = (
- f"You are a biomedical expert evaluating whether a refined phrase reasonably captures the same meaning "
- f"as the original concept mention, given the surrounding clinical context.\n\n"
- f"Original mention: \"{mention}\"\n"
- f"Context: \"{context_snippet}\"\n"
- f"Refined phrase: \"{refined_phrase}\"\n\n"
- f"Only respond `true` if the refined phrase can reasonably be interpreted to mean the same thing "
- f"in context, even if there are minor wording differences.\n"
- f"Only respond `false` if the meaning is clearly different.\n\n"
- f"Respond in JSON format:\n"
- '{"result": true/false, "explanation": "brief justification"}'
- )
- try:
- response = llm.invoke(prompt)
- return parse_llm_response_as_model(response.content, EquivalenceJudgment).__dict__
- except Exception as e:
- return {
- "result": False,
- "explanation": f"Fallback due to error: {str(e)}"
- }
- def search_similar_contexts(concept: str) -> dict:
- """Search contexts that are similar to the input."""
- vector = similary_context_vectorizer.transform([concept])
- similarity_matrix = cosine_similarity(vector, similary_context_encoding)
- idx_to_examples = {}
- similarities = similarity_matrix[0]
- matching_indices = np.where(similarities >= similary_context_threshold)[0]
- matching_scores = similarities[matching_indices]
- examples = []
- cuis = []
- for candidate_idx in matching_indices:
- candidate = similary_context_ann[candidate_idx]
- cui = candidate['cuis'][0]
- cuis.append(cui)
- examples.append(candidate)
- similar_context = {
- 'input': concept,
- 'similar_contexts': examples,
- }
- return similar_context
- def search_nearest_neighbors(concept: str, context_snippet: str) -> List[str]:
- """
- Retrieve CUIs that appear in similar contexts and whose representative names are
- semantically equivalent to the input concept within the provided context.
- Args:
- concept: The original concept mention.
- context_snippet: Context around the concept (e.g., sentence or paragraph).
- Returns:
- A list of CUIs that are semantically equivalent based on neighboring context.
- """
- similar_context = search_similar_contexts(concept)
- candidate_cuis = []
- for context in similar_context.get('similar_contexts', []):
- candidate_cuis.extend(context.get('cuis', []))
- cuis = []
- cui_counter = Counter(candidate_cuis)
- return [cui for cui, _ in cui_counter.most_common()]
- class AugmentationJudgment(BaseModel):
- result: bool
- explanation: str
- def judge_need_for_augmentation(
- mention: str,
- context_snippet: str
- ) -> AugmentationJudgment:
- prompt = (
- f"You are a biomedical language expert. Given the following concept mention, "
- f"determine whether the mention is expressed as regular words.\n\n"
- f"Concept mention: \"{mention}\"\n"
- f"If the term is not a regular word, respond `true`.\n"
- f"Otherwise, respond `false`.\n\n"
- f"Respond in JSON format:\n"
- f"{{\"result\": true/false, \"explanation\": \"brief justification\"}}"
- )
- try:
- response = llm.invoke(prompt)
- return parse_llm_response_as_model(response.content, AugmentationJudgment).__dict__
- except Exception as e:
- return {
- "result": False,
- "explanation": f"Fallback due to error: {str(e)}"
- }
- class AugmentedConcept(BaseModel):
- augmented_mention: str
- explanation: str
- def augment_concept_mention(
- mention: str,
- context_snippet: str
- ) -> Dict[str, Union[str, bool]]:
- """
- Return a dict containing an augmented version of the mention (if applicable) and an explanation.
- If the original mention is already clear and standard, the augmented form may be identical.
- """
- prompt = (
- f"You are a biomedical expert tasked with improving the clarity of a clinical concept mention.\n\n"
- f"Concept mention: \"{mention}\"\n"
- f"Context: \"{context_snippet}\"\n\n"
- f"If the mention is abbreviated or shortened, replace it with a fully spelled term mentioned in the context."
- f"If the mention is already standard and clear, keep it unchanged.\n\n"
- f"Respond in JSON format:\n"
- '{"augmented_mention": "string", "explanation": "brief justification"}'
- )
- try:
- response = llm.invoke(prompt)
- return parse_llm_response_as_model(response.content, AugmentedConcept).__dict__
- except Exception as e:
- return {
- "augmented_mention": mention,
- "explanation": f"Fallback due to error: {str(e)}. Response: {response.content}"
- }
- def link_mention_to_concept_ids(concept: str) -> List[str]:
- """
- Given a concept mention (text string), return a ranked list of UMLS concept IDs
- that are semantically similar to the input mention.
- """
- concept_ids = []
- vector = umls_vectorizer.transform([concept])
- similarity_matrix = cosine_similarity(vector, umls_encoding)
- similarities = similarity_matrix[0]
- matching_indices = np.where(similarities >= umls_threshold)[0]
- ranked_indices = matching_indices[np.argsort(
- similarities[matching_indices])[::-1]]
- for candidate_idx in ranked_indices:
- cui = umls_cuis[candidate_idx]
- if not cui in concept_ids:
- concept_ids.append(cui)
- if len(concept_ids) >= umls_top_k:
- break
- return concept_ids
- def link_mentions_rrf(candidates: List[str]) -> List[str]:
- """
- Given multiple textual variants of the same concept, return a merged ranked list of UMLS CUIs
- using Reciprocal Rank Fusion (RRF) with batched TF-IDF vectorization.
- Returns:
- A ranked list of UMLS CUIs.
- """
- k, rrf_k = umls_top_k, 60
- fusion_scores: Dict[str, float] = defaultdict(float)
- # Batch vectorize all candidates
- vectors = umls_vectorizer.transform(candidates) # shape: (n_candidates, vocab_dim)
- similarity_matrix = cosine_similarity(vectors, umls_encoding) # shape: (n_candidates, n_umls)
- for i, name in enumerate(candidates):
- similarities = similarity_matrix[i]
- matching_indices = np.where(similarities >= umls_threshold)[0]
- ranked_indices = matching_indices[np.argsort(similarities[matching_indices])[::-1]]
- for rank, idx in enumerate(ranked_indices):
- cui = umls_cuis[idx]
- fusion_scores[cui] += 1.0 / (rrf_k + rank + 1)
- if rank + 1 >= umls_top_k:
- break
- # Sort by descending RRF score
- sorted_cuis = sorted(fusion_scores.items(), key=lambda x: x[1], reverse=True)
- return [cui for cui, _ in sorted_cuis[:k]]
- class ConceptExtraction(BaseModel):
- concepts: List[str]
- explanation: str
- def extract_biomedical_concepts(passage: str) -> Dict[str, Union[List[str], str]]:
- """
- Extract biomedical concepts from a clinical sentence or paragraph.
- """
- prompt = (
- "You are a biomedical NLP assistant. Given the following clinical sentence or paragraph, "
- "identify and list key PICO-related concepts. These may include population groups, interventions, "
- "comparators, and outcomes. Only include medically relevant phrases. "
- "If no relevant concepts are found, return an empty list.\n\n"
- f"Text:\n\"{passage}\"\n\n"
- "Respond in the following JSON format:\n"
- "{\n"
- " \"concepts\": [\"...\", \"...\", ...]\n"
- "}"
- )
- try:
- response = llm.invoke(prompt)
- return parse_llm_response_as_model(response.content, ConceptExtraction).__dict__
- except Exception as e:
- return {"concepts": [], "explanation": f"Error: {str(e)}"}
concept.py at commit 0e996f5, no license · at the source
Overview
- Department of Biomedical Informatics, Columbia University, New York, NY USA
- Observational Health Data Analytics, Janssen Research and Development, Titusville, NJ USA
- Department of Population Health Science, Weill Cornell Medicine, New York, NY USA
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
0e996f51f8204a67914845e4518b78590e6216e4, 14 January 2026Availability: 1 check, the latest on 28 September 2026: the link answers
- 28 September 2026: the link answers
13 files
- run_exp.py, Python, 249 lines
- utils/
__init__.py , Python, 1 line - utils/
concept.py , Python, 284 lines, 3 matches - utils/
dataset.py , Python, 262 lines - utils/
evaluate.py , Python, 209 lines - utils/
umls.py , Python, 150 lines - utils/
utils.py , Python, 613 lines - utils/
workflow/ , Python, 102 lines.ipynb_checkpoints/ augmentation-checkpoint. py - utils/
workflow/ , Python, 166 lines.ipynb_checkpoints/ search_and_augment-check point.py - utils/
workflow/ , Python, 1 line__init__.py - utils/
workflow/ , Python, 102 linesaugmentation.py - utils/
workflow/ , Python, 166 linessearch_and_augment.py - README.md, Text, 80 lines
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:
- it points to the authors' code: ebmlab/
MedicalConceptMapping
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://
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/
url = {https://
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/
VL - 9
IS - 1
SP - 425
SN - 2398-6352
PB - Nature Publishing Group
DO - 10.1038/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1038/
"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":
"volume": "9",
"issue": "1",
"page": "425",
"DOI": "10.1038/
"PMID": "41935204",
"PMCID": "PMC13230558",
"ISSN": "2398-6352",
"publisher": "Nature Publishing Group",
"URL": "https://
"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 oneIn 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: NatureIn 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 communicationsIn 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 oneIn 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 mappingIn 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 analysisJournal: n/aIn 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 biologyIn 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: eLifeIn 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 medicineIn 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.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 1 repository of the authors' code, each at its verified commit and with its license, 12 scripts, and 3 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:081a4a703d4fc1a1…
Add the badge to its README
The badge links the code to this page. Copy one of these into the README of the paper's code: only you decide where it goes, and nothing is changed for you.
Markdown
[, paste the snippet at the top, then “Commit changes…” and, to review it first, “Create a new branch and start a pull request”. You open the pull request; OSCR asks for no permission.
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.
