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).
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, url |
counted in meta.json; url is copied to the most cited works of the description |
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 JSON and map/network files, CSVs
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.
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. - 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) |
topics.csv, works_topics.csv.gz |
the same as tables (export) |
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);- 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 .
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.1.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.1.0.tar.gz | 30.9 kB | With provenance | Details for citation_topics-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| citation_topics-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for citation_topics-0.1.0-py3-none-any.whl |
Total release size: 66.1 kB
Release files / citation_topics-0.1.0.tar.gz
| Download URL | citation_topics-0.1.0.tar.gz |
|---|---|
| Size | 30.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d8858771ea59e21f1dbde928f06fb2ca45271c82aeb8beaefb9cbd2aa260353a
|
|
BLAKE2b-256 checksum How to use checksums |
7616b7310d6e9211234dee4e1abdd337714934b10db05b0b04470b74a1e5db3f
|
| 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 15, 2026.
Transparency logRelease files / citation_topics-0.1.0-py3-none-any.whl
| Download URL | citation_topics-0.1.0-py3-none-any.whl |
|---|---|
| Size | 35.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0b23073a9453f5ee5ab8d4492324e5668b46132e9af15e3de4d059d4b7d43968
|
|
BLAKE2b-256 checksum How to use checksums |
fcf4a44b7ced48620fd6e8bd6a112650f2b4a89703c79a65c3bec368eb909717
|
| 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 15, 2026.
Transparency logSecurity for citation-topics 0.1.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.1.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 15, 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.