Generating Literature-Driven Scientific Discoveries at Scale
Theorizer is also a command line tool, theorize: see CLI.md.
This is the repository for Theorizer, from the paper Generating Literature-Driven Scientific Discoveries at Scale.
Abstract: Contemporary automated scientific discovery has focused on agents for generating scientific experiments, while systems that perform higher-level scientific activities such as theory building remain underexplored. In this work, we formulate the problem of synthesizing theories consisting of qualitative and quantitative laws from large corpora of scientific literature. We study theory generation at scale, using 13.7k source papers to synthesize 2.9k theories, examining how generation using literature-grounding versus parametric knowledge, and accuracy-focused versus novelty-focused generation objectives change theory properties. Our experiments show that, compared to using parametric LLM memory for generation, our literature-supported method creates theories that are significantly better at both matching existing evidence and at predicting future results from 4.6k subsequently-written papers.
Plain Language Overview: Existing work in automated scientific discovery largely focuses on running new experiments, rather than higher-level scientific activities like theory building. In this work we show language model agents can be used for theory building, too. In normal usage, you provide a theory query (e.g. build theories about X), and the system uses this to find up to 100 papers related to that theory. It reads each of these papers, extracts relevant evidence from them that might be useful for building theories, and then uses this evidence to synthesize about 4-8 theories per theory query. How do you know if the generated theories are good theories? There are a number of desirable qualities of theories, such as making accurate predictions of future scientific results, and of being new compared to previous theories. We examine several methods of making theories, including using scientific literature versus only the language model's own knowledge, and asking the model to focus on making accurate theories, or new theories. We made 100 theory queries broadly across different areas of AI and Natural Language Processing, and used these to synthesize approximately 3,000 theories from reading almost 14,000 papers. What we found is that different methods of making theories affect their properties (like how accurate or novel they are), with some methods making theories that are (on average) 90% accurate at predicting future scientific results.
Table of Contents
- 1. Paper
- 2. Quick Start
- 2.1. Is Theorizer limited to making theories in Computer Science/AI?
- 2.2. I want to read about Theorizer or generating theories from scientific literature
- 2.3. I want to examine the theories, evaluations, and other results created by Theorizer
- 2.4. I want to run Theorizer on my local machine
- 2.5. I would like to generate theories on my own theory queries
- 2.6. I have a question not answered here
- 3. Installation and Running
- 4. Using Theorizer for Theory Generation
- 5. Theory Evaluation
- 6. Data, Example Output, and Theorizer Representation Formats
- 7. Prompts
- 8. Citation
- 9. License
- 10. Contact
1. Paper
Theorizer is described in the following paper: Generating Literature-Driven Scientific Theories at Scale [Arxiv/PDF].
|
|
2. Quick Start
2.1. Is Theorizer limited to making theories in Computer Science/AI?
You can use Theorizer to make theories in any discipline indexed by Semantic Scholar, and we have used it internally to generate theories in other domains (e.g. biomedical). The only limitation for a given field is whether the papers are likely to be downloadable by Theorizer as open-access.
2.2. I want to read about Theorizer or generating theories from scientific literature
The Theorizer paper is available here: Section 1. Paper
2.3. I want to examine the theories, evaluations, and other results created by Theorizer
- Real data (theories, theory queries, and evaluations) from the paper are available here: Section 6.3. Real Theory Dataset (from the Theorizer paper)
- Toy data (if you'd just like a small download, to examine the format) is available here: Section 6.2. Small / Toy Theory Dataset
2.4. I want to run Theorizer on my local machine
Please see the installation instructions in: Section 3. Installation and Running
2.5. I would like to generate theories on my own theory queries
To use Theorizer on your own theory queries, simply install it on your local machine, and submit theory queries. Note that each theory query may take approximately 30-60 minutes, depending on the rate limits of your API access, the number of papers selected, and the speed of the generating model.
2.6. I have a question not answered here.
Please see the documentation below. If you're question isn't answered, please add an issue, or send an e-mail: Section 10. Contact
3. Installation and Running
The installation has been tested working on Ubuntu Linux. It will likely work with minimal modification on MacOS, and some modification under Windows.
3.1 Installation Instructions
Clone the repository:
git clone https://github.com/allenai/theorizer
cd theorizer
Create a conda environment:
conda create --name theorizer python=3.12
conda activate theorizer
Install the dependencies:
pip install -r requirements.txt
3.1.1. LLM API keys
Create a file called api_keys.donotcommit.json that contains the required API keys for LLM access:
(the Mistral key is required for PDF -> Markdown conversion)
{
"openai": "sk-proj-...",
"anthropic": "sk-ant-...",
"mistral": "..."
}
3.1.2. Semantic Scholar API key
Create a file called s2_key.donotcommit.txt that contains a single line with your semantic scholar key:
<your key here>
3.1.3. Asta Paper Finder
Generating literature-supported theories using Theorizer requires the use of the local copy of Asta PaperFinder. The installation is quick, and its installation instructions can be found here:
https://github.com/allenai/asta-paper-finder
3.2. Running (Web User Interface)
There are two components that need to run simultaneously -- the back-end server, and the user-facing web server. In two terminals, run:
Back-end server:
python src/TheorizerServer.py
User-facing Server:
python src/TheorizerWebInterface.py
If you point your web browser to localhost:8080, then you should see the Theorizer interface.
3.3. Running (API)
You can also submit theory requests to Theorizer programmatically, by starting the TheorizerServer.py, and sending appropriately formatted requests to localhost:5002. The endpoint examples are in TheorizerWebInterface.py.
TODO: Make stand-alone API example.
3.4. Running (Python library)
The same machinery is also available as a Python library, if you'd rather drive the stages yourself than submit a query to the server and wait for a fixed workflow. Every stage is a function with explicit inputs and outputs, so you can start in the middle, bring your own papers, build extraction schemas several ways, or re-run one stage without repeating the others. The per-paper stages stay parallel.
import theorizer as th
th.init()
plan = th.plan_theory_query("Build theories about how agent memory affects task success")
papers = th.search_and_fetch_papers(plan.paper_search_query, limit=50)
data = th.extract_from_papers(papers, plan.schema) # parallel, one LLM call per paper
theories = th.generate_theories(data, plan.theory_query_normalized)
print(theories.summary())
There is also a task-level API — one function per step, taking (theory_query, mission, ...):
papers = th.find_papers_for_theory_building_with_paperfinder(theory_query, mission, limit=50)
schema = th.schema_build_from_papers(theory_query, mission, papers)
data = th.extract_from_papers(papers, schema)
theories = th.theory_generation_normal(theory_query, mission, data)
Papers can come from anywhere — only the first line changes:
papers = th.load_papers_from_files("./my_markdown/") # markdown already extracted
papers = th.convert_pdfs_to_markdown("./my_pdfs/", "./markdown/") # PDFs (parallel, resumable)
papers = th.find_papers_for_theory_building_with_semantic_scholar(theory_query, mission, limit=400)
Every expensive stage also writes a timestamped directory to disk — records, the schema used, a readable summary, and metadata saying what it is, what produced it, and what it cost — so a long iterative session is recoverable and comparable:
th.use_run("agent-memory") # continue an investigation across sessions
data = th.extract_from_papers(papers, schema, comment="parametric schema, gpt-5-mini")
print(data.artifact.path)
th.export_run() # assemble a theorystore + HTML from the run
See LIBRARY.md for the full guide, and examples/ for runnable scripts.
4. Using Theorizer for Theory Generation
⚠️Costs⚠️: Use of this code for theory generation, evaluation, or other purposes can incur significant costs. It is strongly encouraged to start small scale to gauge approximate costs, and to use API keys with hard limits to avoid accidental/unexpected cost overruns.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file asta_theorizer-0.1.0.tar.gz.
File metadata
- Download URL: asta_theorizer-0.1.0.tar.gz
- Upload date:
- Size: 522.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cb53ee7dfaa54b5a1ce572afe5a38bfbc51f99c4d5ab3ae45036e68d49ee13e
|
|
| MD5 |
46d352f16cb85c80b01b3a3b8ba28795
|
|
| BLAKE2b-256 |
cf5012d496b7ece96081479fe6c681ee13119946d538fed6489a3082516e8bcc
|
File details
Details for the file asta_theorizer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: asta_theorizer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 527.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43ab7aebba2f9fad1f5e1e1c985f2c1e8ace56fb1decb07ab92d1bf017fb4bd8
|
|
| MD5 |
d4d0eb7ffdd98ff519edc85290fce827
|
|
| BLAKE2b-256 |
406cd2e7a825b2e090450403e08d22d1f07c6b46178717e5c8d8172e78cf25c6
|