asta-theorizer 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. asta_theorizer-0.1.0/.gitignore +178 -0
  2. asta_theorizer-0.1.0/CLI.md +160 -0
  3. asta_theorizer-0.1.0/GUIDE.md +616 -0
  4. asta_theorizer-0.1.0/LICENSE +201 -0
  5. asta_theorizer-0.1.0/PKG-INFO +738 -0
  6. asta_theorizer-0.1.0/README.md +699 -0
  7. asta_theorizer-0.1.0/pyproject.toml +96 -0
  8. asta_theorizer-0.1.0/src/EvaluationCommon.py +133 -0
  9. asta_theorizer-0.1.0/src/EvaluationLLMAsAJudge.py +404 -0
  10. asta_theorizer-0.1.0/src/EvaluationPredictiveAccuracy.py +1292 -0
  11. asta_theorizer-0.1.0/src/EvaluationQualifiedNovelty.py +1653 -0
  12. asta_theorizer-0.1.0/src/EvaluationSurprisal.py +246 -0
  13. asta_theorizer-0.1.0/src/ExportTheoryStoreAsHTML.py +1477 -0
  14. asta_theorizer-0.1.0/src/ExportTheoryStoreAsHTML_NoPaperstore.py +1545 -0
  15. asta_theorizer-0.1.0/src/ExportTheoryStoreAsHTML_NoPaperstore_attribution.py +1656 -0
  16. asta_theorizer-0.1.0/src/ExtractionUtils.py +1112 -0
  17. asta_theorizer-0.1.0/src/MistralOCRStore.py +154 -0
  18. asta_theorizer-0.1.0/src/PaperFinderRequests.py +239 -0
  19. asta_theorizer-0.1.0/src/PaperStore.py +1244 -0
  20. asta_theorizer-0.1.0/src/Persistence.py +399 -0
  21. asta_theorizer-0.1.0/src/SchemaExtractionQueue.py +524 -0
  22. asta_theorizer-0.1.0/src/SemanticScholar.py +620 -0
  23. asta_theorizer-0.1.0/src/Struct.py +549 -0
  24. asta_theorizer-0.1.0/src/SymbolicTheorizerDebug1.py +56 -0
  25. asta_theorizer-0.1.0/src/Theorizer.py +1439 -0
  26. asta_theorizer-0.1.0/src/Theorizer1.py +2347 -0
  27. asta_theorizer-0.1.0/src/Theorizer2.py +2713 -0
  28. asta_theorizer-0.1.0/src/Theorizer2a.py +3820 -0
  29. asta_theorizer-0.1.0/src/TheorizerModalAPI.py +441 -0
  30. asta_theorizer-0.1.0/src/TheorizerProcessing.py +6229 -0
  31. asta_theorizer-0.1.0/src/TheorizerServer.py +270 -0
  32. asta_theorizer-0.1.0/src/TheorizerServer1.py +207 -0
  33. asta_theorizer-0.1.0/src/TheorizerServer2.py +218 -0
  34. asta_theorizer-0.1.0/src/TheorizerServerTest1.py +167 -0
  35. asta_theorizer-0.1.0/src/TheorizerServerTest2.py +996 -0
  36. asta_theorizer-0.1.0/src/TheorizerWebInterface.py +1236 -0
  37. asta_theorizer-0.1.0/src/Throttle.py +61 -0
  38. asta_theorizer-0.1.0/src/VariableDiscoveryQueue.py +561 -0
  39. asta_theorizer-0.1.0/src/modal_app.py +56 -0
  40. asta_theorizer-0.1.0/src/utils/extract_results_symbolic.py +52 -0
  41. asta_theorizer-0.1.0/src/utils/missing_paper_analysis.py +70 -0
  42. asta_theorizer-0.1.0/symbolic-solver/src/symbolic_solver.py +1314 -0
  43. asta_theorizer-0.1.0/tests/RunAllTests.py +43 -0
  44. asta_theorizer-0.1.0/tests/TestCLIEndToEnd.py +133 -0
  45. asta_theorizer-0.1.0/tests/TestEvidenceChain.py +289 -0
  46. asta_theorizer-0.1.0/tests/TestLegacy.py +153 -0
  47. asta_theorizer-0.1.0/tests/TestPaperImport.py +141 -0
  48. asta_theorizer-0.1.0/tests/TestParallel.py +182 -0
  49. asta_theorizer-0.1.0/tests/TestPipeline.py +218 -0
  50. asta_theorizer-0.1.0/tests/TestProject.py +166 -0
  51. asta_theorizer-0.1.0/tests/TestSymbolic.py +258 -0
  52. asta_theorizer-0.1.0/theorizer/Config.py +227 -0
  53. asta_theorizer-0.1.0/theorizer/Evaluate.py +141 -0
  54. asta_theorizer-0.1.0/theorizer/Legacy.py +190 -0
  55. asta_theorizer-0.1.0/theorizer/PaperImport.py +491 -0
  56. asta_theorizer-0.1.0/theorizer/Parallel.py +159 -0
  57. asta_theorizer-0.1.0/theorizer/Pipeline.py +973 -0
  58. asta_theorizer-0.1.0/theorizer/Project.py +397 -0
  59. asta_theorizer-0.1.0/theorizer/Symbolic.py +407 -0
  60. asta_theorizer-0.1.0/theorizer/__init__.py +13 -0
  61. asta_theorizer-0.1.0/theorizer/cli/__init__.py +55 -0
  62. asta_theorizer-0.1.0/theorizer/cli/__main__.py +3 -0
  63. asta_theorizer-0.1.0/theorizer/cli/common.py +550 -0
  64. asta_theorizer-0.1.0/theorizer/cli/evaluate.py +92 -0
  65. asta_theorizer-0.1.0/theorizer/cli/export.py +66 -0
  66. asta_theorizer-0.1.0/theorizer/cli/papers.py +227 -0
  67. asta_theorizer-0.1.0/theorizer/cli/projects.py +331 -0
  68. asta_theorizer-0.1.0/theorizer/cli/run.py +53 -0
  69. asta_theorizer-0.1.0/theorizer/cli/stages.py +225 -0
  70. asta_theorizer-0.1.0/theorizer/cli/symbolic.py +123 -0
  71. asta_theorizer-0.1.0/theorizer/cli/theories.py +142 -0
@@ -0,0 +1,178 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ pip-wheel-metadata/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ target/
76
+
77
+ # Jupyter Notebook
78
+ .ipynb_checkpoints
79
+
80
+ # IPython
81
+ profile_default/
82
+ ipython_config.py
83
+
84
+ # pyenv
85
+ .python-version
86
+
87
+ # pipenv
88
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
90
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
91
+ # install all needed dependencies.
92
+ #Pipfile.lock
93
+
94
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95
+ __pypackages__/
96
+
97
+ # Celery stuff
98
+ celerybeat-schedule
99
+ celerybeat.pid
100
+
101
+ # SageMath parsed files
102
+ *.sage.py
103
+
104
+ # Environments
105
+ .env
106
+ .venv
107
+ venv/
108
+ ENV/
109
+ env.bak/
110
+ venv.bak/
111
+
112
+ # Spyder project settings
113
+ .spyderproject
114
+ .spyproject
115
+
116
+ # Rope project settings
117
+ .ropeproject
118
+
119
+ # mkdocs documentation
120
+ /site
121
+
122
+ # mypy
123
+ .mypy_cache/
124
+ .dmypy.json
125
+ dmypy.json
126
+
127
+ # Pyre type checker
128
+ .pyre/
129
+
130
+ # Don't add the /prompts/ directory (which is a debug directory)
131
+ prompts/
132
+
133
+ # Large files that are preprocessed versions of conceptnet that shouldn't be committed
134
+
135
+ # Don't commit anything with `donotcommit` in its name
136
+ *donotcommit*
137
+
138
+ # Don't commit the exclusion patterns that are automatically scanned for in commits (like API keys)
139
+ EXCLUDE_PATTERNS.TXT
140
+
141
+ # Runtime data, caches, and debug output
142
+ data/
143
+ ocr-cache/
144
+ output/
145
+
146
+ # OS files
147
+ .DS_Store
148
+
149
+ # Project data (VIP interneuron corpus + extraction output)
150
+ vip-interneuron-project/
151
+
152
+ # theorizer library: project directories and verbose logs
153
+ theorizer-run/
154
+ example-*-run/
155
+ theorizer-verbose.log
156
+ paperstore_log.txt
157
+ paperstore_successfail_log.jsonl
158
+ pf-check/
159
+ vip-sweep-run/
160
+ vip-sweep-html/
161
+ sweep-html-export/
162
+ vip-full-sweep/
163
+ vip-full-sweep-html/
164
+ vip-schema2-sweep/
165
+ vip-sol-sweep/
166
+ vip-*-sweep/
167
+ vip-*-html/
168
+ vip-*-html-*/
169
+ vip-cache-test/
170
+ vip-reflect-gauge/
171
+ vip-2run-compare/
172
+ vip-luna-test/
173
+
174
+ # Theorizer run/project directories (any name), and their stores
175
+ vip-s1-full/
176
+ vip-s1-sol/
177
+ theorystore.json
178
+ store.json
@@ -0,0 +1,160 @@
1
+ # Theorizer CLI
2
+
3
+ ## Install and check
4
+
5
+ ```bash
6
+ pip install asta-theorizer
7
+ export OPENAI_API_KEY=... # the default models are gpt-5.2 and gpt-5-mini
8
+ export S2_API_KEY=... # optional: faster paper fetching
9
+ export MISTRAL_API_KEY=... # optional: Mistral OCR for PDFs instead of local conversion
10
+
11
+ theorize doctor
12
+ theorize -p vip/ init --model gpt-5-mini --extraction-model gpt-5-mini
13
+ theorize --help
14
+ theorize papers --help
15
+ ```
16
+
17
+ ## Papers from PaperFinder
18
+
19
+ ```bash
20
+ theorize -p vip/ papers search "VIP interneurons visual cortex gain"
21
+ theorize -p vip/ papers fetch --top 1 # fetches the full text of the top candidate into the project
22
+ theorize -p vip/ papers fetch 225095372 244348308 # or of these corpus ids
23
+ theorize -p vip/ show papers
24
+ theorize -p vip/ show papers --status metadata-only
25
+ theorize -p vip/ show candidates
26
+ ```
27
+
28
+ ## Papers from your own files or a store
29
+
30
+ ```bash
31
+ theorize -p vip/ papers import tests/fixtures/one-paper.md
32
+ theorize -p vip/ papers import my-papers/*.pdf # local conversion
33
+ theorize -p vip/ papers import my-papers/*.pdf --ocr mistral # Mistral OCR
34
+ theorize -p vip/ papers import my-papers/ --no-metadata # skip the metadata call
35
+
36
+ asta-papers search "VIP interneurons visual cortex" --limit 1 | asta-papers store > store.json
37
+ theorize -p vip/ papers import store.json
38
+ theorize -p vip/ show papers
39
+ ```
40
+
41
+ ## The whole run in one command
42
+
43
+ ```bash
44
+ theorize -p vip/ run "Build a theory of how VIP interneurons control response gain in mouse V1" --max-papers 1
45
+ theorize -p vip/ export html
46
+ open vip/html/index.html
47
+ ```
48
+
49
+ ## Stage by stage
50
+
51
+ ```bash
52
+ theorize -p vip/ plan "Build a theory of how VIP interneurons control response gain in mouse V1"
53
+ theorize -p vip/ show plan
54
+ theorize -p vip/ show plan --full
55
+ theorize -p vip/ extract --max-papers 1
56
+ theorize -p vip/ extract
57
+ theorize -p vip/ show extraction
58
+ theorize -p vip/ theories generate
59
+ theorize -p vip/ show theories
60
+ theorize -p vip/ export html
61
+ ```
62
+
63
+ ## Refine the schema from what came out
64
+
65
+ ```bash
66
+ theorize -p vip/ report
67
+ theorize -p vip/ show variable-report
68
+ theorize -p vip/ schemas extend
69
+ theorize -p vip/ schemas extend --max-suggestions 5 --save-as schema-wide
70
+ theorize -p vip/ show schema-extended
71
+ theorize -p vip/ extract --schema schema-extended --save-as extraction-extended
72
+ theorize -p vip/ theories generate --extraction extraction-extended
73
+ ```
74
+
75
+ ## Let the papers propose the schema
76
+
77
+ ```bash
78
+ theorize -p vip/ discover
79
+ theorize -p vip/ schemas from-discovery
80
+ theorize -p vip/ show schemas#0
81
+ theorize -p vip/ extract --schema schemas#0 --save-as extraction-discovered
82
+ theorize -p vip/ theories generate --extraction extraction-discovered
83
+ ```
84
+
85
+ ## Other theory generators
86
+
87
+ ```bash
88
+ theorize -p vip/ theories generate --objective novelty --save-as theories-novelty
89
+ theorize -p vip/ theories generate --no-reflection --max-laws 2 --model gpt-5.2
90
+ theorize -p vip/ theories generate --suggestions variable-report
91
+ theorize -p vip/ theories sweep --debug-limit 2
92
+ theorize -p vip/ theories sweep --output-types "MECHANISTIC EXPLANATION" --inference-types none
93
+ theorize -p vip/ show theories
94
+ ```
95
+
96
+ ## Symbolic laws
97
+
98
+ ```bash
99
+ theorize -p vip/ schemas symbolic
100
+ theorize -p vip/ show symbolic-schema
101
+ theorize -p vip/ extract --schema symbolic-schema --save-as extraction-symbolic
102
+ theorize -p vip/ symbolic table
103
+ theorize -p vip/ symbolic solve
104
+ theorize -p vip/ symbolic solve --skip pysr_symbolic --skip gplearn_symbolic --timeout 60
105
+ theorize -p vip/ symbolic laws
106
+ theorize -p vip/ symbolic report symbolic-report
107
+ theorize -p vip/ symbolic report symbolic-report --out vip/laws.md
108
+ ```
109
+
110
+ ## Evaluate the theories
111
+
112
+ ```bash
113
+ theorize -p vip/ evaluate judge
114
+ theorize -p vip/ evaluate judge --only-novel --model gpt-5.2
115
+ theorize -p vip/ evaluate belief --samples 2 --limit 1
116
+ theorize -p vip/ evaluate novelty --limit 1
117
+ theorize -p vip/ show evaluation-novelty
118
+ theorize -p vip/ evaluate predictive --evidence-from 2024-01 --limit 1 --max-papers 1
119
+ theorize -p vip/ export html
120
+ ```
121
+
122
+ ## Inspect and pipe
123
+
124
+ ```bash
125
+ theorize -p vip/ show
126
+ theorize -p vip/ show 3
127
+ theorize -p vip/ load plan
128
+ theorize -p vip/ load plan --key output.paper_search_query
129
+ theorize -p vip/ load extraction > extraction.json
130
+ theorize -p vip/ --json show | jq '.data.items[].name'
131
+ theorize -p vip/ --json theories generate --no-reflection | jq '.data.theory_ids'
132
+ theorize -p vip/ -q show theories
133
+ ```
134
+
135
+ ## Models and keys
136
+
137
+ ```bash
138
+ theorize -p vip/ init --model gpt-5.2 --extraction-model gpt-5-mini
139
+ THEORIZER_MODEL=gpt-5.2 theorize -p vip/ theories generate
140
+ theorize -p vip/ theories generate --model gpt-5.2
141
+ LITELLM_BASE_URL=https://proxy.example/v1 LITELLM_USER_KEY=... theorize -p vip/ doctor
142
+ THEORIZER_PAPERFINDER_URL=http://localhost:8000 theorize -p vip/ papers search "VIP interneurons"
143
+ ```
144
+
145
+ ## Resume and retry
146
+
147
+ ```bash
148
+ theorize -p vip/ extract # reruns pick up where the last one stopped
149
+ theorize -p vip/ papers fetch 225095372 # a failed paper is fetched again
150
+ theorize -p vip/ theories sweep --debug-limit 2 --debug-seed 1
151
+ ```
152
+
153
+ ## Exit codes
154
+
155
+ ```
156
+ 0 done
157
+ 1 a stage ran and failed (no theories, nothing extracted, solver error)
158
+ 2 usage (missing input, unknown reference, no papers)
159
+ 3 preflight (another command holds the project, doctor found a problem)
160
+ ```