Metadata-Version: 2.4
Name: arxanon
Version: 1.0.0
Summary: Cross-domain structural analogy discovery engine for AI/ML researchers
Project-URL: Homepage, https://github.com/Serhii2009/arxanon
Project-URL: Repository, https://github.com/Serhii2009/arxanon
Project-URL: Design Document, https://github.com/Serhii2009/arxanon/blob/main/ARXANON_DESIGN_DOCUMENT.md
Project-URL: Bug Tracker, https://github.com/Serhii2009/arxanon/issues
Author-email: Serhii Kravchenko <serhiikravchenko@gmail.com>
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship made available under
              the License, as indicated by a copyright notice that is included in
              or attached to the work (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other transformations
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean, as submitted to the Licensor for inclusion
              in the Work by the copyright owner or by an individual or Legal Entity
              authorized to submit on behalf of the copyright owner. For the purposes
              of this definition, "submitted" means any form of electronic, verbal,
              or written communication sent to the Licensor or its representatives,
              including but not limited to communication on electronic mailing lists,
              source code control systems, and issue tracking systems that are managed
              by, or on behalf of, the Licensor for the purpose of discussing and
              improving the Work, but excluding communication that is conspicuously
              marked or designated in writing by the copyright owner as "Not a
              Contribution."
        
              "Contributor" shall mean Licensor and any Legal Entity on behalf of
              whom a Contribution has been received by the Licensor and included
              within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by the combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a cross-claim
              or counterclaim in a lawsuit) alleging that the Work or any
              Contribution embodied within the Work constitutes direct or contributory
              patent infringement, then any patent licenses granted to You under
              this License for that Work shall terminate as of the date such
              litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or Derivative
                  Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, You must include a readable copy of the
                  attribution notices contained within such NOTICE file, in
                  at least one of the following places: within a NOTICE text
                  file distributed as part of the Derivative Works; within
                  the Source form or documentation, if provided along with the
                  Derivative Works; or, within a display generated by the
                  Derivative Works, if and wherever such third-party notices
                  normally appear. The contents of the NOTICE file are for
                  informational purposes only and do not modify the License.
                  You may add Your own attribution notices within Derivative
                  Works that You distribute, alongside or in addition to the
                  NOTICE text from the Work, provided that such additional
                  attribution notices cannot be construed as modifying the
                  License.
        
              You may add Your own license statement for Your modifications and
              may provide additional grant of rights to use, copy, modify, merge,
              publish, distribute, sublicense, and/or sell copies of the
              Derivative Works, and to permit persons to whom the Derivative Works
              are furnished to do so, subject to the following conditions: the
              above copyright notice and this permission notice shall be included
              in all copies or substantial portions of the Software.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or reproducing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or exemplary damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (even if such Contributor has been advised of the possibility
              of such damages).
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may offer only
              conditions consistent with this License.
        
           END OF TERMS AND CONDITIONS
        
           Copyright 2026 Serhii Kravchenko
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
License-File: LICENSE
Keywords: arxiv,cross-domain,embeddings,literature-based-discovery,scientific-discovery,structural-analogy
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: arxiv>=2.1.0
Requires-Dist: click>=8.1.0
Requires-Dist: faiss-cpu>=1.7.4
Requires-Dist: hdbscan>=0.8.33
Requires-Dist: numpy>=1.26.0
Requires-Dist: ollama>=0.5.0
Requires-Dist: prompt-toolkit>=3.0.0
Requires-Dist: questionary>=2.0.0
Requires-Dist: requests>=2.31.0
Requires-Dist: rich>=13.7.0
Requires-Dist: sentence-transformers>=3.0.0
Provides-Extra: dev
Requires-Dist: mypy>=1.9.0; extra == 'dev'
Requires-Dist: pytest-mock>=3.12.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.4.0; extra == 'dev'
Provides-Extra: tda
Requires-Dist: giotto-tda>=0.6.0; extra == 'tda'
Description-Content-Type: text/markdown

<div align="center">

# ARXANON

**Cross-domain research engine for AI/ML**

[![PyPI version](https://img.shields.io/pypi/v/arxanon?cachebust=0)](https://pypi.org/project/arxanon/)
[![Python](https://img.shields.io/badge/python-3.10%2B-blue)](https://pypi.org/project/arxanon/)
[![License](https://img.shields.io/badge/license-Apache%202.0-green)](LICENSE)

</div>

---

Arxanon takes a description of an ML phenomenon, generates arXiv search queries in the native vocabulary of adjacent scientific fields, and uses an LLM to determine which cross-domain paper pairs share the same underlying mathematical structure. Each run produces a full analysis report, a ranked reference list, and an interactive connection graph — grounded entirely in papers retrieved from arXiv in that session.

## The problem it solves

A researcher encountering grokking knows the ML vocabulary: delayed generalization, phase transition in loss, weight norm growth. The relevant physics literature uses none of those terms. The same phenomenon appears in statistical physics as _critical slowing down_ and in the theory of dynamical systems as _rate-dependent bifurcation delay_. Standard arXiv search, Google Scholar, and semantic similarity over ML corpora will not surface those papers, because the connection has never been named explicitly in an ML paper. Arxanon finds them by translating the phenomenon into the vocabulary of each candidate field before searching.

## How it works

1. Gemma 4 generates ML search queries from the researcher's question, targeting papers that study the phenomenon during training.
2. Gemma 4 translates the phenomenon into structural vocabulary from adjacent fields — dynamical systems, statistical physics, neuroscience, control theory, economics — and generates queries using the terminology of those fields.
3. arXiv is searched with both sets of queries; the paper budget is split evenly between the two channels.
4. Papers are embedded with bge-large-en-v1.5 and indexed in FAISS; a citation graph is built via Semantic Scholar to identify which similar-looking paper pairs are already in the same citation network.
5. Gemma 4 validates whether cross-domain paper pairs (semantically similar but not citation-connected) share the same mathematical object or mechanism, classifying each as STRUCTURAL, METHODOLOGICAL, THEMATIC, or discarded.
6. Results are synthesized into a report with grounded claims and a suggested experiment derived from the strongest outside-ML finding.

Asking an LLM to suggest relevant physics papers directly will only surface papers it has already connected to ML during training. The vocabulary translation step finds papers where the connection has not yet been made in the ML literature.

## Installation

```bash
pip install arxanon
```

To use OpenRouter (recommended):

```bash
export OPENROUTER_API_KEY=your_key_here
```

Ollama works as a free local alternative with no API key required, but Ollama must be running with a Gemma model installed:

```bash
ollama serve
ollama pull gemma4:e2b
```

## Usage

```
arxanon
```

On first run, a one-time setup wizard configures your embedding model, LLM provider, and pipeline parameters. Settings are saved to `~/.arxanon/settings.json`.

```
╭──────────────────────────────────────────────────────────────────────╮
│  A R X A N O N  v1.0.0                                               │
│  Cross-domain research engine for AI/ML                              │
╰──────────────────────────────────────────────────────────────────────╯
  Embedding: bge-large-en-v1.5  ·  LLM: OpenRouter · google/gemma-4-31b-it
  Results: 100  ·  Validate: 50  ·  Clusters: 3  ·  /help for commands


  Research problem > grokking delayed generalization in neural networks

Generating search queries…

  ML search                                        Structural vocabulary
  "grokking delayed generalization training"       "critical slowing down bifurcation"
  "phase transition generalization dynamics"       "rate-dependent tipping nonlinear systems"
  "weight norm growth algorithmic alignment"       "slow manifold emergence complex systems"

Fetching papers from arXiv…
✓ 186 papers — 93 ML · 93 structural

Building citation network…
✓ Citation graph — 408 direct · 1 187 co-citation edges

Computing embeddings…
✓ 186 papers indexed

[Bridge detection → TDA → HDBSCAN clustering]
✓ 3 bridge clusters found

Validating cross-domain pairs with Gemma…
✓ Validation complete — 12 pairs

Running direct cross-domain comparison…
✓ 5 cross-domain pair(s)

╭─ What I found ────────────────────────────────────────────────────────────────╮
│  Searched outside ML using: critical slowing down bifurcation |              │
│  rate-dependent tipping nonlinear systems | slow manifold emergence          │
│  ✓ 3 outside-ML framework(s) found across 5 connection(s).                  │
│                                                                              │
│  **What we found:** A paper in nonlinear dynamics on rate-dependent          │
│  bifurcation delay [GROUNDED: arxiv:XXXX] shows the pre-transition          │
│  duration scales with a specific exponent of the rate parameter —            │
│  matching the relationship between grokking onset and learning rate          │
│  schedule length. [INFERRED] This predicts a quantitative relationship       │
│  not yet measured in the ML literature.                                      │
│                                                                              │
│  **Experiment:** Rate-dependent bifurcation delay predicts that halving      │
│  the learning rate schedule length shifts the generalization transition      │
│  step by a specific factor. Test: train the same network at 5 schedule      │
│  lengths and measure the step at which test accuracy first exceeds train     │
│  accuracy by < 1%.                                                           │
│                                                                              │
│  Full analysis → ./grokking_delayed_generalization/                          │
╰──────────────────────────────────────────────────────────────────────────────╯
```

> Paper counts, query text, and arXiv IDs in this example are illustrative. Actual output depends on arXiv's current index and what the LLM generates for your query.

### Slash commands

| Command        | Description                                    |
| -------------- | ---------------------------------------------- |
| `/help`        | Show all commands                              |
| `/settings`    | Change provider, model, or pipeline parameters |
| `/history`     | List past queries — select to re-run           |
| `/fields`      | Show which arXiv categories were retrieved     |
| `/pairs`       | Show validated cross-domain pairs in a table   |
| `/save [dest]` | Copy output files to a named location          |
| `/rerun`       | Re-run the most recent query                   |
| `/quit`        | Exit                                           |

## Output files

Each run writes a folder named after the first ML query generated (e.g. `grokking_delayed_generalization/`). Inside:

| File                     | Contents                                                                                                                                                                                                                                                                               |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `cross_domain_report.md` | Full analysis: synthesis with inline provenance tags (`[GROUNDED: arxiv:X]`, `[INFERRED]`, `[SPECULATIVE]`), cross-domain connections grouped by outside-ML paper with reasoning, top ML papers by relevance, and a suggested experiment derived from the strongest outside-ML finding |
| `references.md`          | Outside-ML papers found in the run, deduplicated and ranked by connection strength (STRUCTURAL first, then METHODOLOGICAL and THEMATIC), with clickable arXiv links                                                                                                                    |
| `connection_map.html`    | Interactive D3.js force graph of the paper network — hover any node to highlight its connections, click to open the arXiv page                                                                                                                                                         |

## Configuration

Type `/settings` at the prompt to change your provider, model, or pipeline parameters:

| Parameter            | Default               | Range  | Description                               |
| -------------------- | --------------------- | ------ | ----------------------------------------- |
| LLM provider / model | Ollama · `gemma4:e2b` | —      | OpenRouter (cloud) or Ollama (local)      |
| `max_results`        | 100                   | 10–500 | Papers fetched per query                  |
| `max_validate`       | 50                    | 1–100  | Bridge pairs sent to Gemma for validation |

All settings persist between sessions.

## Scope and limitations

The tool works well when:

- The ML phenomenon has a vocabulary gap to physics or mathematics (grokking, loss spikes, learning rate warmup, emergent capabilities during training).
- The relevant outside literature exists on arXiv.

The tool adds less value when:

- The cross-domain name is already established in the ML literature. Reward hacking is already called Goodhart's Law in ML papers; the structural channel retrieves nothing that standard search would miss.
- The relevant literature is primarily in non-arXiv journals — behavioral economics, evolutionary biology, clinical neuroscience, and most social science are largely absent from arXiv.

## Technical notes

- Embedding model: `BAAI/bge-large-en-v1.5` (1024-dim, CPU). `nvidia/NV-Embed-v2` (4096-dim, GPU) is available via the setup wizard.
- LLM: Gemma 4 31B via OpenRouter (`google/gemma-4-31b-it`, recommended) or any local model via Ollama.
- Vector index: FAISS; citation graph via Semantic Scholar; topological structure detection via persistent homology (`pip install "arxanon[tda]"`).

---

**Built by [Serhii Kravchenko](https://www.linkedin.com/in/serhii-kravchenko1/) 🔥**
