chemistry-knowledge / write_card.py
janwein's picture
Add a real question, scientific trace and answer to the dataset card; explain potential LLM pretraining use
c495712 verified
Raw History Blame Contribute Delete
17.1 kB
"""Write the dataset card from the measured release manifest."""
import argparse
import json
from pathlib import Path
ROOT = Path(__file__).resolve().parent
def write_card(repo_id="chembricks/chemistry-knowledge"):
manifest = json.loads((ROOT / "manifest.json").read_text())
records = [json.loads(line) for line in (ROOT / "data/records.jsonl").read_text().splitlines()]
metadata = {
"pretty_name": "ChemBricks Knowledge: Evidence-Linked Chemistry",
"license": "mit", "language": ["en"],
"task_categories": ["question-answering", "text-generation"],
"tags": ["chemistry", "computational-chemistry", "scientific-reasoning", "tool-use", "provenance", "synthetic", "text"],
"annotations_creators": ["machine-generated"],
"language_creators": ["machine-generated"],
"size_categories": ["1K<n<10K"],
"configs": [{"config_name": name, **({"default":True} if name=="records" else {}),
"data_files":[{"split":"corpus","path":"data/"+name+".jsonl"}]}
for name in ("records","claims","evidence")],
}
family_names = {"A":"Facts and molecular properties", "B":"Chemical series", "C":"Comparisons and counterfactuals",
"D":"Reactions", "E":"Molecule design and discovery tasks", "F":"Method limits", "K":"Class hypotheses"}
family_table = "\n".join("| " + family + " | " + family_names.get(family[:1],family) + " | " + str(count) + " |"
for family,count in manifest["family_counts"].items())
source_count = manifest["source_records_with_eligible_claims"]
sample = next(r for r in records if r["record_id"] == "rec_20260914_1abcb4")
(ROOT / "examples").mkdir(exist_ok=True)
(ROOT / "examples/caffeine-trace.md").write_text(sample["trace_markdown"])
excerpt_start = sample["trace_markdown"].index("## Step 6:")
excerpt_end = sample["trace_markdown"].index("\n# Checks\n", excerpt_start)
tool_excerpt = sample["trace_markdown"][excerpt_start:excerpt_end].strip().replace("## Step ", "#### Step ")
answer_excerpt = "\n\n".join(sample["answer"].strip().split("\n\n")[:3])
quoted_answer = "\n".join("> " + line if line else ">" for line in answer_excerpt.splitlines())
text = f"""# ChemBricks Knowledge
**Does caffeine prefer water or an oil-like liquid?**
**Why can adding one small group change a molecule's behavior?**
**Can we design a molecule that interacts more favorably with water while meeting other constraints?**
**How much energy does it take to remove an electron from a molecule?**
These are the kinds of questions behind this dataset. Each investigation connects a question to recorded calculations, an answer, and the evidence needed to examine that answer.
Created and curated by **[ChemBricks](https://chembricks.ai)** using our **[ChemBricks AI platform](https://cmbx.ai)**.
![Physics, models, tools, questions, claims, checks and reusable context, with a feedback loop from checks to questions](assets/knowledge-path.png)
[Download the vector figure](assets/knowledge-path.svg).
*Physics informs the models; questions guide the calculations; checks determine which claims can become reusable context. The workflow also includes empirical descriptors and semiempirical methods, identified by their actual tool and model. The figure is a workflow schematic, not a claim that every row was independently validated by a high-level reference calculation.*
## What you get
This release contains **{manifest['records']:,} complete curated investigations**, **{manifest['claims']:,} eligible claims**, and **{manifest['evidence_rows']:,} recorded tool-call pairs**.
The claim subset draws from **{source_count:,} source investigations**. It includes usable findings from investigations whose complete traces contain a disputed, failed, inconclusive or range-quarantined claim. Those full traces are excluded from the default records subset. The evidence table preserves intermediate observations, including failures; an evidence row is not itself a validated claim.
| Configuration | Rows | Contents |
|---|---:|---|
| records, default | {manifest['records']:,} | Questions, answers, scientific audit trails, molecule identities, all claims and their qualifications |
| claims | {manifest['claims']:,} | Individually eligible findings with methods, conditions, checks and evidence links |
| evidence | {manifest['evidence_rows']:,} | Chemical arguments and returned responses, with original request IDs and provenance |
All three configurations use the split **corpus**. This is an unsplit release, not an independent evaluation benchmark.
Snapshot: **{manifest['snapshot_started_at']}**. Release: **{manifest['release_version']}**. The snapshot considered {manifest['current_records_considered']:,} current records from a ledger of {manifest['source_ledger_entries']:,} entries. It contains {manifest['distinct_tool_captures']:,} distinct source captures across the claim/evidence release. Multiple records sharing a capture are not separate simulations.
## Example: does caffeine favor water or an oil-like liquid?
This is a real investigation from the dataset: **{sample['record_id']}**. The oil-like reference liquid is **octanol**. Its logP describes partitioning between octanol and water for the recorded molecular form; it does not directly measure how much caffeine dissolves in water.
### Question
> {sample['question']}
In everyday language: **{sample['beginner_question']}**
### Scientific reasoning trace, abridged
The following reading guide summarizes the recorded investigation. The expandable excerpt preserves the original tool calls, result values, and request IDs; the [complete original trace](examples/caffeine-trace.md) includes all steps, checks, interpretations, and follow-up questions.
1. **Define competing explanations.** The polarity-based hypothesis favors water. The competing structural explanation asks whether the methylated ring framework could favor octanol. State what observation would count against each explanation.
2. **Establish the input.** Canonicalize the caffeine structure and run the required safety screen so subsequent calculations refer to the same molecular representation.
3. **Measure the relevant evidence.** Record polarity and structural descriptors, then obtain the predicted logP and both solvent free energies from the primary solvation endpoint. Descriptors supply context for an explanation; their coexistence does not isolate a cause.
4. **Check the result through another route.** Obtain the screening-grade RDKit Crippen logP estimate. Use recorded calculator calls for the water-minus-octanol free-energy difference and the absolute difference between the logP predictions.
5. **Interpret within the tested scope.** The results favor water for this modeled molecular form. Review consistency between the observations, retain the limitations of the screening comparison, and propose an experimental partition measurement and a structural counterfactual to investigate the explanation further.
This record retains **prediction_timing: unverified**. The original wording of its hypotheses is preserved, but their timing relative to computation is not independently established; read the hypothesis comparison as exploratory.
<details>
<summary>Read the recorded calculation and cross-check steps</summary>
{tool_excerpt}
</details>
### Recorded answer, excerpt
These opening paragraphs are copied from the record, including the numerical evidence references:
{quoted_answer}
**What the example establishes:** a scoped computational prediction of water preference, with a screening cross-check and a traceable calculation. Its descriptor associations do not establish a causal solvent-interaction mechanism. The endpoint did not report its geometry or temperature, and the cross-route difference is not a calibrated experimental error bar. The [full trace](examples/caffeine-trace.md) retains the remaining answer, limitations, and proposed tests.
## Read a record
Load this dataset from [Hugging Face](https://huggingface.co/datasets/{repo_id}):
\x60\x60\x60python
from datasets import load_dataset
records = load_dataset("{repo_id}", "records", split="corpus")
print(records[0]["question"])
print(records[0]["answer"])
print(records[0]["limitations"])
\x60\x60\x60
For a local copy, run from this dataset directory:
\x60\x60\x60python
from datasets import load_dataset
records = load_dataset(
"json",
data_files={{"corpus": "data/records.jsonl"}},
split="corpus",
cache_dir=".cache/datasets",
)
\x60\x60\x60
The data also works with ordinary Python. See [examples/read_dataset.py](examples/read_dataset.py).
## Follow a claim to its evidence
\x60\x60\x60python
import json
from datasets import load_dataset
claims = load_dataset("{repo_id}", "claims", split="corpus")
evidence = load_dataset("{repo_id}", "evidence", split="corpus")
item = claims[0]
claim = json.loads(item["claim_json"])
reference = claim["evidence"][0]
call = next(
row for row in evidence
if row["source_capture_id"] == item["source_capture_id"]
and row["request_id"] == reference["request_id"]
)
response = json.loads(call["response_json"])
print(item["statement"])
print(item["conditions_json"])
print(reference["path"])
print(response)
\x60\x60\x60
Columns ending in **_json** contain JSON strings so varying scientific structures load consistently in the dataset viewer. [DATA_DICTIONARY.md](DATA_DICTIONARY.md) describes the columns and JSON-path convention.
## How the data was created
A question specifies molecules, methods, constraints and a budget. An isolated AI worker calls ChemBricks tools through a logging proxy and writes a scientific audit trail. Mechanical gates check schema, safety-screen completion, number provenance, methods, ranges, cross-checks and trust tags. Phase 1 uses an independent model referee and sampled replay checks. Accepted source records enter a hash-chained ledger.
For this release, the original evidence hashes and mechanical checks were verified again offline. Applicable referee and replay evidence were checked. Arithmetic claims inherit the confidence limits of their source claims; a passed calculator result cannot upgrade an unresolved source.
The default records subset requires every claim to qualify. This release includes {manifest['referee_reviewed_full_records']:,} full records with a passing independent model referee and {manifest['builder_reviewed_full_records']:,} with a matching recorded building-agent trace review. These counts overlap. Building-agent review is AI review, not an independent human annotation. Historical Phase 0 records retain their original gate states.
The original question, answer, scientific trace, numerical claims and chemical responses are not scientifically rewritten during packaging. Local client metadata is removed from public request envelopes. [CURATION.md](CURATION.md) explains selection, privacy transformations and provenance.
## Coverage
| Family | Question type | Complete records |
|---|---|---:|
{family_table}
The complete-record subset covers {manifest['molecules_in_full_records']:,} distinct canonical molecule strings in its recorded registries. This is a deliberately selected corpus of molecular properties, comparisons and design studies, not a representative sample of all chemical space. Paraphrases, related molecules and derived questions introduce substantial dependence.
## What verified means here
Verified means **traceable to the recorded computation and checked under its declared policy**. It does not mean experimentally established truth.
- Predictions retain their actual model, conditions, applicability and trust information. A high tool trust factor is not a calibrated experimental confidence probability.
- Cross-route comparisons can support consistency without proving a mechanism or supplying an experimental error bar.
- Interpretations are distinguished from measurements. A missing descriptor cannot establish a proposed causal explanation.
- Some historical traces have unverified pre-call prediction timing. Their comparisons remain descriptive. The prediction_timing column preserves this distinction.
- Low-trust and screening-grade results retain their tags. A passed claim can still have a limited domain of use.
- Model-based designs are tested computational proposals. They do not establish synthesis, laboratory safety, availability, novelty, or broad chemical laws.
- The underlying model-training datasets, model weights and full high-level simulation trajectories are not included. This release contains the recorded outputs and knowledge-building investigations.
## Potential application: LLM pretraining on scientific reasoning traces
One potential application is **pretraining or continued pretraining of large language models on scientific reasoning traces**, alongside other training material. The goal would be to learn from the connection between a question, a proposed explanation, recorded calculations, checks, and an evidence-linked answer.
A useful analogy is **coding traces with feedback from execution, compilers, type checks, and tests**. Here the traces concern scientific investigations, and the feedback comes from **physics-based or physics-informed calculations, empirical descriptors, provenance checks, and comparisons between computational routes**.
| Coding-workflow analogy | Scientific investigation in this dataset |
|---|---|
| Task or specification | Chemical question and scoped hypothesis |
| Code and execution trace | Tool calls, calculated observations, and scientific audit trail |
| Compiler diagnostics, type checks, and tests | Evidence provenance, unit and method constraints, applicability checks, and required cross-route comparisons |
| Checked program and output | Qualified claim, answer, and reusable context with its evidence |
The analogy concerns learning from testable work and feedback. Scientific verification remains conditional on the models, methods, and conditions: approximate calculations and empirical descriptors can share errors, and consistency does not establish experimental truth. This release proposes a training use; it reports no LLM pretraining experiment or measured training benefit.
## Intended uses and evaluation limits
Use the corpus to study evidence-grounded chemistry assistance, retrieve qualified computational context, inspect tool use, or develop scientific question-answering systems. Retain methods, uncertainty, limitations and provenance when constructing a downstream example.
No frozen scaffold holdout exists in the source snapshot. Before training and evaluation, define and document one that keeps linked records, shared captures, generated candidates and scaffold-related molecules from leaking across partitions. The claims and evidence subsets are alternate views of the same source material, not independent datasets.
## Integrity and release files
Run **python -B verify.py** with Python 3.11+ and jsonschema to verify file checksums, public schemas, the ledger commitment chain, preserved trace hashes, claim eligibility and evidence links.
[manifest.json](manifest.json) records the exact source state, counts, code hashes and transformations. [SHA256SUMS](SHA256SUMS) covers the distributable files. The provenance directory retains source hashes and selection decisions. See [UPLOAD.md](UPLOAD.md) for publishing instructions.
## Creators, license and citation
**Creator and publisher:** ChemBricks
**Company:** [chembricks.ai](https://chembricks.ai)
**AI platform:** [cmbx.ai](https://cmbx.ai)
**License:** [MIT](LICENSE), copyright 2026 ChemBricks
This release's curated data, documentation and figure are released under MIT at the dataset owner's direction. Historical source license labels are retained only in the provenance index. They describe the source records' earlier metadata.
\x60\x60\x60bibtex
@misc{{chembricks_knowledge_2026,
author = {{{{ChemBricks}}}},
title = {{ChemBricks Knowledge: Evidence-Linked Chemistry Questions and Claims}},
year = {{2026}},
version = {{{manifest['release_version']}}},
url = {{https://huggingface.co/datasets/{repo_id}}}
}}
\x60\x60\x60
[CITATION.cff](CITATION.cff) provides machine-readable citation metadata. Include the Hub revision when citing a particular snapshot; no DOI or associated paper is claimed.
Dataset layout follows the [Hugging Face dataset-card specification](https://huggingface.co/docs/hub/datasets-cards) and [data-file configuration](https://huggingface.co/docs/hub/datasets-data-files-configuration).
"""
(ROOT / "README.md").write_text("---\n" + json.dumps(metadata, indent=2) + "\n---\n\n" + text)
print(json.dumps({"card":"README.md","repository_example":repo_id,"records":manifest["records"]}))
if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--repo-id", default="chembricks/chemistry-knowledge")
write_card(parser.parse_args().repo_id)