citation-topics
Research topics and broad areas for any list of works (papers, theses, projects, patents) from their citation links, with Leiden clustering of the direct-citation network as CWTS does for the OpenAlex topics. It also gives each work a second and a third topic, describes every topic from whatever the input carries (titles, abstracts, keywords, journals, categories, countries), and ships Claude skills and an agent that name the topics.
It was extracted from restrepo/inspireauth10, where it groups 1.9 million INSPIRE-HEP papers into 304 topics and 6 areas.
- How the topics are made: the method, step by step.
- Sample board: the citation community of the INSPIRE-HEP author 991924, and the same network of works in VOSviewer Online.
Install
pip install citation-topics
citation-topics --help
Input
A JSON array or JSON Lines file (optionally gzipped), one object per work:
{"id": "W1", "references": ["W7", "W9"], "year": 2019, "title": "...", "abstract": "...",
"keywords": ["..."], "journal": "...", "categories": ["..."], "countries": ["..."],
"authors": ["..."], "citations": 41, "url": "https://..."}
id(unique; strings or integers, compared as strings) andreferences(ids of other works) are required. References to ids outside the list and self-citations are ignored and counted.- Every other field is optional. Other names are read with
--id-field,--refs-fieldand--map NAME=FIELD(for example--map year=publication_year).
| Optional field | Adds |
|---|---|
year |
years of each topic, time windows (--from-year, --to-year), comparisons between epochs |
title, abstract, keywords, journal, categories |
the description of each topic (describe), hence its name |
citations |
most cited works by that count (otherwise by citations inside the list) |
countries |
countries of each topic in the description |
authors |
the Authors tab of the board, and the authors of each work in the Network tab and in works_vosviewer.json (with author_count and collaborations, when present, for long author lists) |
url |
links from the board and the description to each work |
any true/false field, e.g. own |
a tab of the board that follows those works (board --highlight own) |
Naming needs at least one of title, abstract, keywords, journal or categories: describe lists the
ones missing in dossier.json (missing), and the topic-namer skill stops and says so when none is there. No
field is fetched or inferred from elsewhere. Fields the package does not know are kept in the input and ignored,
so a list can carry them from the start for a later board.
Commands
citation-topics run works.jsonl.gz out/ # network, topics, areas, second and third topics
citation-topics describe works.jsonl.gz out/ # out/dossier.json: what each topic is about
citation-topics names out/ names.json # put names into topics.json and areas.json
citation-topics export out/ # VOSviewer files of the topics, CSVs
citation-topics export out/ --works works.jsonl.gz # also the network of works for VOSviewer (up to 10,000 works)
citation-topics board works.jsonl.gz out/ # out/board.html: tabs for what the fields allow
citation-topics agreement out_s1/ out_s2/ ... # NMI/ARI between seeds, and the medoid to keep
citation-topics compare old/ new/ cmp/ # where earlier topics went; names carried over
citation-topics skills install # Claude skills and the topic-namer agent into ./.claude
run options and defaults (those of the INSPIRE run): --resolution 16 (higher = more, smaller topics),
--min-size 100 (smaller topics are merged into the topic they share the most links with), --passes 20
(stops early when the quality stops rising), --seed 1, --area-resolution 0.3, --area-seeds 50 (the best
of that many runs). Tune them for other lists; the skill topics-run explains how.
Example: the citation community of an INSPIRE-HEP profile
The topics of an author's papers together with every paper citing them. Tried on the INSPIRE-HEP author 991924: 79 papers and 1,888 citing papers, 1,967 works, 11 topics in 3 areas, in about a minute; the result is the sample board.
-
Install (Python 3.10 or newer):
pip install citation-topics curl -O https://raw.githubusercontent.com/restrepo/citation-topics/main/examples/inspire_profile.py
-
Get the works from INSPIRE, with the number of the profile (
https://inspirehep.net/authors/991924) or its INSPIRE BAI:python inspire_profile.py 991924 works.jsonl
It writes, for each paper, its references, year, title, abstract, keywords, journal, arXiv categories, authors (the first 10, with the author count and collaboration), citation count and link, and
"own": truefor the author's papers. -
Topics. A list of about 2,000 works needs smaller topics than the defaults, which suit millions of works:
citation-topics run works.jsonl out/ --resolution 1 --min-size 20
Try two or three resolutions (for example 1, 2, 4) and keep the one whose topics are solid (
share_insideinout/topics.json) and readable in number. Optionally run seeds 1 to 4 into different folders and keep the onecitation-topics agreementcalls the medoid. -
Describe and export:
citation-topics describe works.jsonl out/ --abstracts citation-topics export out/ --works works.jsonl --highlight own --highlight-label "The author's papers"
-
Name the topics, with or without Claude:
-
With Claude Desktop (optional; the Code tab, or Claude Code): install the skills in the folder, open the folder in the Code tab and ask, for example, "name the topics in out/ with the topic-namer skill". Claude reads
out/dossier.json, writesnames.jsonwith a name and a reason for every topic and area, and applies it.citation-topics skills install
-
Without Claude: read
out/dossier.json(distinctive terms, most cited titles, journals and categories of each topic), writenames.jsonyourself in the format of thenamescommand, and apply it:citation-topics names out/ names.json citation-topics export out/ --works works.jsonl --highlight own --highlight-label "The author's papers"
Unnamed topics are shown as "Topic N".
-
-
Board: one page with the map and table of topics, works per year, a searchable list of works, the network of works with one labelled cluster per topic (click a work to see only its citation links, magenta to the works it cites and amber to the works citing it, its first author beside it, and its authors, year, citations and INSPIRE link below the graph), and a tab with the author's own papers by topic:
citation-topics board works.jsonl out/ --highlight own --highlight-label "Your papers" --title "Your name: citation topics"
Open
out/board.htmlin a browser, or ask Claude to publish it (skilltopics-board). -
VOSviewer (optional):
out/works_vosviewer.jsonis the network of works (one item per work, its topic as the cluster, the board's positions) andout/topics_vosviewer.jsonthe graph of topics. Open either in VOSviewer Online (Open → the file) or in VOSviewer. To share a link, put the file at a public address that allows cross-site reads (GitHub Pages does) and openhttps://app.vosviewer.com/?json=followed by its URL;board --vosviewer-url URLadds that link to the board's Network tab. The sample:https://app.vosviewer.com/?json=https%3A%2F%2Frestrepo.github.io%2Fcitation-topics%2Fexamples%2Finspire-991924%2Fworks_vosviewer.json
Method
- Network: one node per work, an edge for each reference to another work of the list; undirected, each pair of works once.
- Topics: Leiden maximizing modularity with a resolution parameter (the RB configuration model), with
igraph's
community_leiden, pass after pass until the quality stops rising. Works with no link stay unassigned; topics under--min-sizeare merged into their most linked neighbour; topics are numbered by size. - Areas: Leiden (leidenalg) on the graph of topics weighted by the links between them, with the links
inside each topic as self-loops, the best of
--area-seedsruns. Every topic is in one area. - Second and third topics: a work's links are counted by the topic at the other end; the second and third
topics are the most linked other topics, scored as links to them / links to the main topic, capped at 1.
Works the clustering left out take as main topic the one they link to most (
inferred). - Description (
describe): per topic, its distinctive terms (shares in the topic against the rest of the list), journals, categories, keywords, countries, years, linked topics and most cited works. - Network of works (
board,export --works, up to--network-maxworks, 10,000 by default): each topic is a disc with area proportional to its works, placed by the links between topics and pushed apart until none overlap; inside it, the topic's works are placed by the links among them (Fruchterman-Reingold, igraph). Comfortable up to 10,000 works and about 50 topics (the default limit); usable to about 20,000 works (--network-max 20000), where zooming gets slower and the board weighs about 5 MB. Above 150,000 links the board starts with the links hidden. Measured sizes and times are in thecommunity-graphskill. - Names: written by Claude from the description (skill
topic-namer), never by the package.comparecarries names over from an earlier run: a topic sharing 60% of its works both ways with an earlier one keeps its name.
The same input, parameters and versions of igraph and leidenalg give the same topics; meta.json records them
with the MD5 of the input.
Checked against inspireauth10. On its 1,872,221 INSPIRE papers (44 million citation links) with the
defaults, run gives the same network, the same 304 topics and 6 areas, the same Leiden quality and the same
second and third topics as inspireauth10's own scripts, array for array (igraph 1.0.0, leidenalg 0.12.0, numpy
2.5.4, Python 3.13). It took 45 minutes and more than 4 GB of memory; describe with titles, keywords,
journals, categories and countries took 10 minutes and 4.4 GB.
Output
| File | Content |
|---|---|
works.jsonl.gz |
per work: id, topic, area (null if none), topics (three, with score and links), n_links, inferred |
topics.json |
per topic: area, name, works, links inside and out, share_inside, years, most cited works |
areas.json |
per area: name, works, topics, links, share_inside |
meta.json |
parameters, versions, input MD5, network counts, optional fields present, quality |
dossier.json |
description of each topic and area (describe) |
topics_vosviewer.json, topics_map.txt, topics_network.txt |
graph of topics for VOSviewer (export) |
works_vosviewer.json |
network of works for VOSviewer: one item per work with a link, cluster = its topic, the board's positions (export --works) |
topics.csv, works_topics.csv.gz |
the same as tables (export) |
board.html |
self-contained board: Overview always, then Timeline, Works, Network (up to 10,000 works), highlight, Countries and Authors as the fields allow, and About (board) |
network.npz, clusters.npz |
arrays reused by the other commands |
Claude skills
citation-topics skills install copies into ./.claude (or ~/.claude with --user):
topics-run: checks the input, chooses the parameters, runs, describes and exports, and explains the result;topic-namer: names topics and areas fromdossier.jsonand applies them, after carrying over earlier names;topics-compare: seeds (which run to keep) and earlier runs or time windows (fates, flows, names);community-graph: the whole path from an INSPIRE-HEP profile or any list of works to the community graph (topics as labelled clusters of real works, the board, the VOSviewer file and link), with the size limits;topics-board: builds the board with the tabs the fields allow and says which fields would add the others;- the agent
topic-namer, which names a batch of topics when the skill hands it one.
In Claude Desktop or Claude Code, ask for topics of a list of works and the skills take it from there.
Development
python -m pip install -e ".[dev]"
python -m pytest
ruff check . && ruff format --check .
The site (docs/: the method page, the home page and the sample board with its VOSviewer files) is copied to
the gh-pages branch, served at https://restrepo.github.io/citation-topics/, by .github/workflows/pages.yml on
every merge to main that changes it.
Releases are published to PyPI from GitHub Actions when a v* tag is pushed; see PUBLISHING.md
and CHANGELOG.md.
Metadata
Release files for citation-topics 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| citation_topics-0.3.0.tar.gz | 57.1 kB | With provenance | Details for citation_topics-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| citation_topics-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for citation_topics-0.3.0-py3-none-any.whl |
Total release size: 118.7 kB
Release files / citation_topics-0.3.0.tar.gz
| Download URL | citation_topics-0.3.0.tar.gz |
|---|---|
| Size | 57.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b69e357c8b2f0c0cf4a8f2b6f6bab17ba1278b9780b82f1907ebe5fd5105ea0d
|
|
BLAKE2b-256 checksum How to use checksums |
119294a50d5340c3d743644611a29eeafc41121ff70d95c69dbb7a866111233a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logRelease files / citation_topics-0.3.0-py3-none-any.whl
| Download URL | citation_topics-0.3.0-py3-none-any.whl |
|---|---|
| Size | 61.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b16ee5e5ea3d1ca9054213d5506596c6af6e548c6309a48977da35e77b562e2b
|
|
BLAKE2b-256 checksum How to use checksums |
d735fb6d29621e276dca050f8a3f97da897a4b30b97bc84240f5e0d80e186b76
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logSecurity for citation-topics 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for citation_topics-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.