sci-modeling-bench 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 (65) hide show
  1. sci_modeling_bench-0.1.0/CHANGELOG.md +39 -0
  2. sci_modeling_bench-0.1.0/LICENSE +21 -0
  3. sci_modeling_bench-0.1.0/MANIFEST.in +6 -0
  4. sci_modeling_bench-0.1.0/PKG-INFO +128 -0
  5. sci_modeling_bench-0.1.0/README.md +96 -0
  6. sci_modeling_bench-0.1.0/THIRD_PARTY_NOTICES.md +24 -0
  7. sci_modeling_bench-0.1.0/docs/README.md +33 -0
  8. sci_modeling_bench-0.1.0/docs/api/README.md +13 -0
  9. sci_modeling_bench-0.1.0/docs/api/dataset.md +293 -0
  10. sci_modeling_bench-0.1.0/docs/api/objective.md +121 -0
  11. sci_modeling_bench-0.1.0/docs/api/protocol.md +108 -0
  12. sci_modeling_bench-0.1.0/docs/architecture/core-concepts.md +101 -0
  13. sci_modeling_bench-0.1.0/docs/datasets.md +3 -0
  14. sci_modeling_bench-0.1.0/docs/development/releasing.md +38 -0
  15. sci_modeling_bench-0.1.0/docs/objectives-and-protocols.md +6 -0
  16. sci_modeling_bench-0.1.0/docs/suites/design-bench/tfbind8.md +275 -0
  17. sci_modeling_bench-0.1.0/docs/tfbind8.md +4 -0
  18. sci_modeling_bench-0.1.0/pyproject.toml +67 -0
  19. sci_modeling_bench-0.1.0/setup.cfg +4 -0
  20. sci_modeling_bench-0.1.0/src/sci_modeling_bench/__init__.py +63 -0
  21. sci_modeling_bench-0.1.0/src/sci_modeling_bench/dataset/__init__.py +46 -0
  22. sci_modeling_bench-0.1.0/src/sci_modeling_bench/dataset/_hub.py +103 -0
  23. sci_modeling_bench-0.1.0/src/sci_modeling_bench/dataset/dataset.py +291 -0
  24. sci_modeling_bench-0.1.0/src/sci_modeling_bench/dataset/knowledge.py +44 -0
  25. sci_modeling_bench-0.1.0/src/sci_modeling_bench/dataset/manifest.py +217 -0
  26. sci_modeling_bench-0.1.0/src/sci_modeling_bench/dataset/metadata.py +38 -0
  27. sci_modeling_bench-0.1.0/src/sci_modeling_bench/dataset/schema.py +148 -0
  28. sci_modeling_bench-0.1.0/src/sci_modeling_bench/dataset/source.py +22 -0
  29. sci_modeling_bench-0.1.0/src/sci_modeling_bench/dataset/validation.py +306 -0
  30. sci_modeling_bench-0.1.0/src/sci_modeling_bench/exceptions.py +45 -0
  31. sci_modeling_bench-0.1.0/src/sci_modeling_bench/objective/__init__.py +9 -0
  32. sci_modeling_bench-0.1.0/src/sci_modeling_bench/objective/objective.py +96 -0
  33. sci_modeling_bench-0.1.0/src/sci_modeling_bench/protocol/__init__.py +5 -0
  34. sci_modeling_bench-0.1.0/src/sci_modeling_bench/protocol/protocol.py +25 -0
  35. sci_modeling_bench-0.1.0/src/sci_modeling_bench/py.typed +1 -0
  36. sci_modeling_bench-0.1.0/src/sci_modeling_bench/suites/__init__.py +2 -0
  37. sci_modeling_bench-0.1.0/src/sci_modeling_bench/suites/design_bench/__init__.py +21 -0
  38. sci_modeling_bench-0.1.0/src/sci_modeling_bench/suites/design_bench/tfbind8/__init__.py +25 -0
  39. sci_modeling_bench-0.1.0/src/sci_modeling_bench/suites/design_bench/tfbind8/build.py +600 -0
  40. sci_modeling_bench-0.1.0/src/sci_modeling_bench/suites/design_bench/tfbind8/dataset.py +212 -0
  41. sci_modeling_bench-0.1.0/src/sci_modeling_bench/suites/design_bench/tfbind8/objective.py +101 -0
  42. sci_modeling_bench-0.1.0/src/sci_modeling_bench/suites/design_bench/tfbind8/protocol.py +100 -0
  43. sci_modeling_bench-0.1.0/src/sci_modeling_bench.egg-info/PKG-INFO +128 -0
  44. sci_modeling_bench-0.1.0/src/sci_modeling_bench.egg-info/SOURCES.txt +63 -0
  45. sci_modeling_bench-0.1.0/src/sci_modeling_bench.egg-info/dependency_links.txt +1 -0
  46. sci_modeling_bench-0.1.0/src/sci_modeling_bench.egg-info/entry_points.txt +2 -0
  47. sci_modeling_bench-0.1.0/src/sci_modeling_bench.egg-info/requires.txt +10 -0
  48. sci_modeling_bench-0.1.0/src/sci_modeling_bench.egg-info/top_level.txt +1 -0
  49. sci_modeling_bench-0.1.0/tests/__init__.py +1 -0
  50. sci_modeling_bench-0.1.0/tests/conftest.py +116 -0
  51. sci_modeling_bench-0.1.0/tests/suites/__init__.py +1 -0
  52. sci_modeling_bench-0.1.0/tests/suites/design_bench/__init__.py +1 -0
  53. sci_modeling_bench-0.1.0/tests/suites/design_bench/tfbind8/__init__.py +1 -0
  54. sci_modeling_bench-0.1.0/tests/suites/design_bench/tfbind8/conftest.py +115 -0
  55. sci_modeling_bench-0.1.0/tests/suites/design_bench/tfbind8/test_build.py +51 -0
  56. sci_modeling_bench-0.1.0/tests/suites/design_bench/tfbind8/test_dataset.py +71 -0
  57. sci_modeling_bench-0.1.0/tests/suites/design_bench/tfbind8/test_objective.py +75 -0
  58. sci_modeling_bench-0.1.0/tests/suites/design_bench/tfbind8/test_protocol.py +95 -0
  59. sci_modeling_bench-0.1.0/tests/test_dataset.py +164 -0
  60. sci_modeling_bench-0.1.0/tests/test_hub.py +51 -0
  61. sci_modeling_bench-0.1.0/tests/test_knowledge.py +35 -0
  62. sci_modeling_bench-0.1.0/tests/test_manifest.py +94 -0
  63. sci_modeling_bench-0.1.0/tests/test_objective.py +62 -0
  64. sci_modeling_bench-0.1.0/tests/test_source.py +28 -0
  65. sci_modeling_bench-0.1.0/tests/test_validation.py +83 -0
@@ -0,0 +1,39 @@
1
+ # Changelog
2
+
3
+ All notable changes to SciModelingBench are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2026-07-16
9
+
10
+ ### Added
11
+
12
+ - Initial Python 3.10+ package with typed public exports.
13
+ - Core Dataset framework for resolving Hugging Face revisions to immutable
14
+ commits, selecting collection configs and splits, loading regular or
15
+ streaming datasets, and checking declared schemas and row counts.
16
+ - Strict collection and dataset manifests with provenance metadata, semantic
17
+ input, target, and context fields, common constraints, and split metadata.
18
+ - Structured validation reports and dataset-specific validator hooks that
19
+ report violations without mutating observations or candidates.
20
+ - Read-only, lazily loaded Knowledge resources pinned to the Dataset revision.
21
+ - Minimal Objective and Protocol contracts for validated target evaluation and
22
+ construction of agent-visible inputs.
23
+ - One black-box optimization integration for TFBind8 `SIX6_REF_R1`, including
24
+ the complete canonical 65,536-sequence landscape, exact E-score lookup, and
25
+ a Design-Bench-compatible bottom-50% Protocol exposing 32,768 unique offline
26
+ candidates.
27
+ - Reproducible TFBind8 release builder and `smb-build-tfbind8` command with
28
+ source checks, canonicalization, integrity validation, provenance output,
29
+ and optional parity checks against legacy Design-Bench arrays.
30
+ - Public documentation for the framework concepts and TFBind8 integration.
31
+
32
+ ### Known Limitations
33
+
34
+ - Dataset, Objective, and Protocol interfaces remain experimental, and a Task
35
+ or evaluation-harness interface is not included in this release.
36
+ - Dataset artifacts are distributed separately from the Python package and
37
+ retain their own source, citation, provenance, and license metadata.
38
+
39
+ [0.1.0]: https://github.com/xukp20/sci-modeling-bench/releases/tag/v0.1.0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SciModelingBench contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,6 @@
1
+ include CHANGELOG.md
2
+ include LICENSE
3
+ include README.md
4
+ include THIRD_PARTY_NOTICES.md
5
+ recursive-include docs *.md
6
+ recursive-include tests *.py
@@ -0,0 +1,128 @@
1
+ Metadata-Version: 2.4
2
+ Name: sci-modeling-bench
3
+ Version: 0.1.0
4
+ Summary: An observation-grounded benchmark framework for scientific modeling and design.
5
+ Author: SciModelingBench contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/xukp20/sci-modeling-bench
8
+ Project-URL: Documentation, https://github.com/xukp20/sci-modeling-bench/tree/main/docs
9
+ Project-URL: Repository, https://github.com/xukp20/sci-modeling-bench.git
10
+ Project-URL: Issues, https://github.com/xukp20/sci-modeling-bench/issues
11
+ Project-URL: Changelog, https://github.com/xukp20/sci-modeling-bench/blob/main/CHANGELOG.md
12
+ Keywords: agent,benchmark,black-box-optimization,scientific-machine-learning
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: datasets>=3.1
23
+ Requires-Dist: huggingface-hub>=0.26
24
+ Requires-Dist: numpy>=1.26
25
+ Requires-Dist: pydantic>=2.10
26
+ Requires-Dist: pyarrow>=15
27
+ Provides-Extra: dev
28
+ Requires-Dist: build>=1.2; extra == "dev"
29
+ Requires-Dist: pytest>=8; extra == "dev"
30
+ Requires-Dist: twine>=5.1; extra == "dev"
31
+ Dynamic: license-file
32
+
33
+ # SciModelingBench
34
+
35
+ SciModelingBench is a Python framework for reproducible scientific modeling
36
+ and design benchmarks. Version 0.1.0 provides the first experimental package
37
+ surface for loading versioned observations, validating scientific schemas,
38
+ constructing agent-visible inputs, and evaluating candidates against trusted
39
+ objectives.
40
+
41
+ ## Installation
42
+
43
+ SciModelingBench requires Python 3.10 or later.
44
+
45
+ From PyPI:
46
+
47
+ ```bash
48
+ python -m pip install "sci-modeling-bench==0.1.0"
49
+ ```
50
+
51
+ From the GitHub v0.1.0 source tag:
52
+
53
+ ```bash
54
+ python -m pip install \
55
+ "git+https://github.com/xukp20/sci-modeling-bench.git@v0.1.0"
56
+ ```
57
+
58
+ ## Scope
59
+
60
+ SciModelingBench provides:
61
+
62
+ - revision-pinned loading of scientific datasets hosted on Hugging Face;
63
+ - semantic manifests, schemas, provenance metadata, and structured validation;
64
+ - trusted Objectives for candidate-to-target evaluation;
65
+ - Protocols that construct the information exposed to an optimization agent;
66
+ - optional, lazily loaded domain-knowledge resources.
67
+
68
+ The package does not yet define Tasks, submission formats, metrics, query
69
+ budgets, agent workflows, or evaluation harnesses.
70
+
71
+ ## Minimal TFBind8 Example
72
+
73
+ The first integration exposes the canonical TFBind8 `SIX6_REF_R1` landscape,
74
+ an exact black-box Objective, and the Design-Bench bottom-50% offline-data
75
+ Protocol:
76
+
77
+ ```python
78
+ from sci_modeling_bench.suites.design_bench import (
79
+ TFBind8Dataset,
80
+ TFBind8DesignBenchProtocol,
81
+ TFBind8ExactObjective,
82
+ )
83
+
84
+ dataset = TFBind8Dataset.from_hub(
85
+ revision="2ee2856f4255bb6a64c11b6c2660a6f41418e654"
86
+ )
87
+ offline_data = TFBind8DesignBenchProtocol().build_input(dataset)
88
+ score = TFBind8ExactObjective(dataset).evaluate({"sequence": "AACCGGTT"})
89
+ ```
90
+
91
+ The TFBind8 observations are downloaded from the public SciModelingBench
92
+ Hugging Face organization and are not bundled in the Python wheel.
93
+
94
+ ## Core Concepts
95
+
96
+ - **Dataset** binds immutable observations to metadata, semantic fields,
97
+ validation rules, splits, and optional knowledge.
98
+ - **Objective** validates candidates and returns declared target values while
99
+ preserving batch order and repeated candidates.
100
+ - **Protocol** derives the data or context visible to an agent without
101
+ modifying the underlying Dataset.
102
+ - **Knowledge** provides read-only explanatory resources pinned to the same
103
+ dataset revision.
104
+
105
+ ## Dataset Artifacts
106
+
107
+ Dataset artifacts are hosted separately from this package. Neither the PyPI
108
+ distribution nor the GitHub source repository bundles observation tables.
109
+ Loaders resolve dedicated Hugging Face Dataset repositories at pinned commits;
110
+ the package contains the framework, integrations, validators, and reproducible
111
+ builders.
112
+
113
+ ## Documentation
114
+
115
+ - [Documentation index](https://github.com/xukp20/sci-modeling-bench/tree/main/docs)
116
+ - [Architecture and core concepts](https://github.com/xukp20/sci-modeling-bench/blob/main/docs/architecture/core-concepts.md)
117
+ - [Dataset API](https://github.com/xukp20/sci-modeling-bench/blob/main/docs/api/dataset.md)
118
+ - [Objective API](https://github.com/xukp20/sci-modeling-bench/blob/main/docs/api/objective.md)
119
+ - [Protocol API](https://github.com/xukp20/sci-modeling-bench/blob/main/docs/api/protocol.md)
120
+ - [TFBind8 integration](https://github.com/xukp20/sci-modeling-bench/blob/main/docs/suites/design-bench/tfbind8.md)
121
+ - [Changelog](https://github.com/xukp20/sci-modeling-bench/blob/main/CHANGELOG.md)
122
+
123
+ ## Release Status
124
+
125
+ Version 0.1.0 is the initial experimental release. Dataset, Objective, and
126
+ Protocol interfaces are implemented but may change as additional scientific
127
+ benchmarks are integrated. The TFBind8 code path has been validated against
128
+ the pinned public Hugging Face artifact and the legacy Design-Bench arrays.
@@ -0,0 +1,96 @@
1
+ # SciModelingBench
2
+
3
+ SciModelingBench is a Python framework for reproducible scientific modeling
4
+ and design benchmarks. Version 0.1.0 provides the first experimental package
5
+ surface for loading versioned observations, validating scientific schemas,
6
+ constructing agent-visible inputs, and evaluating candidates against trusted
7
+ objectives.
8
+
9
+ ## Installation
10
+
11
+ SciModelingBench requires Python 3.10 or later.
12
+
13
+ From PyPI:
14
+
15
+ ```bash
16
+ python -m pip install "sci-modeling-bench==0.1.0"
17
+ ```
18
+
19
+ From the GitHub v0.1.0 source tag:
20
+
21
+ ```bash
22
+ python -m pip install \
23
+ "git+https://github.com/xukp20/sci-modeling-bench.git@v0.1.0"
24
+ ```
25
+
26
+ ## Scope
27
+
28
+ SciModelingBench provides:
29
+
30
+ - revision-pinned loading of scientific datasets hosted on Hugging Face;
31
+ - semantic manifests, schemas, provenance metadata, and structured validation;
32
+ - trusted Objectives for candidate-to-target evaluation;
33
+ - Protocols that construct the information exposed to an optimization agent;
34
+ - optional, lazily loaded domain-knowledge resources.
35
+
36
+ The package does not yet define Tasks, submission formats, metrics, query
37
+ budgets, agent workflows, or evaluation harnesses.
38
+
39
+ ## Minimal TFBind8 Example
40
+
41
+ The first integration exposes the canonical TFBind8 `SIX6_REF_R1` landscape,
42
+ an exact black-box Objective, and the Design-Bench bottom-50% offline-data
43
+ Protocol:
44
+
45
+ ```python
46
+ from sci_modeling_bench.suites.design_bench import (
47
+ TFBind8Dataset,
48
+ TFBind8DesignBenchProtocol,
49
+ TFBind8ExactObjective,
50
+ )
51
+
52
+ dataset = TFBind8Dataset.from_hub(
53
+ revision="2ee2856f4255bb6a64c11b6c2660a6f41418e654"
54
+ )
55
+ offline_data = TFBind8DesignBenchProtocol().build_input(dataset)
56
+ score = TFBind8ExactObjective(dataset).evaluate({"sequence": "AACCGGTT"})
57
+ ```
58
+
59
+ The TFBind8 observations are downloaded from the public SciModelingBench
60
+ Hugging Face organization and are not bundled in the Python wheel.
61
+
62
+ ## Core Concepts
63
+
64
+ - **Dataset** binds immutable observations to metadata, semantic fields,
65
+ validation rules, splits, and optional knowledge.
66
+ - **Objective** validates candidates and returns declared target values while
67
+ preserving batch order and repeated candidates.
68
+ - **Protocol** derives the data or context visible to an agent without
69
+ modifying the underlying Dataset.
70
+ - **Knowledge** provides read-only explanatory resources pinned to the same
71
+ dataset revision.
72
+
73
+ ## Dataset Artifacts
74
+
75
+ Dataset artifacts are hosted separately from this package. Neither the PyPI
76
+ distribution nor the GitHub source repository bundles observation tables.
77
+ Loaders resolve dedicated Hugging Face Dataset repositories at pinned commits;
78
+ the package contains the framework, integrations, validators, and reproducible
79
+ builders.
80
+
81
+ ## Documentation
82
+
83
+ - [Documentation index](https://github.com/xukp20/sci-modeling-bench/tree/main/docs)
84
+ - [Architecture and core concepts](https://github.com/xukp20/sci-modeling-bench/blob/main/docs/architecture/core-concepts.md)
85
+ - [Dataset API](https://github.com/xukp20/sci-modeling-bench/blob/main/docs/api/dataset.md)
86
+ - [Objective API](https://github.com/xukp20/sci-modeling-bench/blob/main/docs/api/objective.md)
87
+ - [Protocol API](https://github.com/xukp20/sci-modeling-bench/blob/main/docs/api/protocol.md)
88
+ - [TFBind8 integration](https://github.com/xukp20/sci-modeling-bench/blob/main/docs/suites/design-bench/tfbind8.md)
89
+ - [Changelog](https://github.com/xukp20/sci-modeling-bench/blob/main/CHANGELOG.md)
90
+
91
+ ## Release Status
92
+
93
+ Version 0.1.0 is the initial experimental release. Dataset, Objective, and
94
+ Protocol interfaces are implemented but may change as additional scientific
95
+ benchmarks are integrated. The TFBind8 code path has been validated against
96
+ the pinned public Hugging Face artifact and the legacy Design-Bench arrays.
@@ -0,0 +1,24 @@
1
+ # Third-Party Notices
2
+
3
+ SciModelingBench integrates benchmark definitions and derived data from
4
+ third-party projects. The project code license does not replace the terms that
5
+ apply to external datasets and publications.
6
+
7
+ ## Design-Bench
8
+
9
+ The TFBind8 integration reproduces the task semantics and preprocessing of
10
+ Design-Bench:
11
+
12
+ - Project: https://github.com/brandontrabucco/design-bench
13
+ - Referenced revision: `e52939588421b5433f6f2e9b359cf013c542bd89`
14
+ - Copyright: Copyright (c) 2020 Brandon Trabucco
15
+ - License: MIT License
16
+
17
+ ## TFBind8 Data
18
+
19
+ The TFBind8 observations originate from the protein-binding microarray data
20
+ published by Barrera et al. (Science, 2016), UniPROBE accession `BAR15A`.
21
+ SciModelingBench publishes only the derived contiguous 8-mer landscape and
22
+ does not assert that the project MIT license applies to those observations.
23
+ The Hugging Face Dataset card records the source, citations, checksums,
24
+ transformations, and applicable upstream terms.
@@ -0,0 +1,33 @@
1
+ # SciModelingBench Documentation
2
+
3
+ SciModelingBench is an observation-grounded framework for scientific modeling
4
+ and design benchmarks. The first release provides experimental `Dataset`,
5
+ `Objective`, and `Protocol` APIs plus an end-to-end black-box optimization
6
+ integration for TFBind8.
7
+
8
+ ## Start Here
9
+
10
+ - [Architecture and core concepts](architecture/core-concepts.md) explains the
11
+ framework boundaries, trust model, and data flow.
12
+ - [API documentation](api/README.md) covers the three implemented public
13
+ interfaces:
14
+ - [Dataset API](api/dataset.md)
15
+ - [Objective API](api/objective.md)
16
+ - [Protocol API](api/protocol.md)
17
+ - [TFBind8](suites/design-bench/tfbind8.md) documents the first supported
18
+ black-box optimization setting, its canonical data, and Design-Bench parity.
19
+
20
+ ## First-Release Scope
21
+
22
+ The implemented layers load revision-pinned scientific observations, construct
23
+ the information visible to an optimization agent, and evaluate candidates
24
+ against trusted targets. A benchmark `Task`, runner, query-budget policy,
25
+ submission format, and metrics layer are not implemented. Those responsibilities
26
+ remain with the external harness in this release.
27
+
28
+ The public interfaces are experimental. Pin dataset revisions and package
29
+ versions in reproducible work.
30
+
31
+ ## Maintainers
32
+
33
+ - [Release process](development/releasing.md)
@@ -0,0 +1,13 @@
1
+ # API Documentation
2
+
3
+ The first release exposes three experimental interfaces:
4
+
5
+ - [Dataset API](dataset.md): revision-pinned observations, manifests, semantic
6
+ schemas, validation, splits, and knowledge resources.
7
+ - [Objective API](objective.md): trusted, Dataset-bound candidate evaluation.
8
+ - [Protocol API](protocol.md): construction of agent-visible benchmark input.
9
+
10
+ For how these interfaces fit together, read
11
+ [Architecture and core concepts](../architecture/core-concepts.md). The
12
+ [TFBind8 suite guide](../suites/design-bench/tfbind8.md) shows all three in one
13
+ black-box optimization workflow.
@@ -0,0 +1,293 @@
1
+ # Dataset API
2
+
3
+ > **Status:** Experimental. Pin the package version and dataset revision in
4
+ > reproducible work.
5
+
6
+ The `Dataset` layer represents published scientific observations together with
7
+ their identity, provenance, semantic field roles, validity rules, split
8
+ metadata, and optional domain knowledge. It intentionally does not select
9
+ task-specific agent input or evaluate candidate designs.
10
+
11
+ ## Loading a Dataset
12
+
13
+ Load a repository config directly:
14
+
15
+ ```python
16
+ from sci_modeling_bench import Dataset
17
+
18
+ dataset = Dataset.from_hub(
19
+ "sci-modeling-bench/design-bench",
20
+ config_name="tfbind8",
21
+ revision="full-commit-sha",
22
+ )
23
+ ```
24
+
25
+ `Dataset.from_hub()` has this signature:
26
+
27
+ ```python
28
+ Dataset.from_hub(
29
+ repo_id: str,
30
+ config_name: str | None = None,
31
+ revision: str | None = None,
32
+ *,
33
+ token: str | None = None,
34
+ validator: DatasetValidator | None = None,
35
+ ) -> Dataset
36
+ ```
37
+
38
+ When `config_name` is omitted, the collection manifest's `default_config` is
39
+ used. The requested revision, including the repository default when `None`, is
40
+ resolved once to a full commit SHA. All manifests, data, and knowledge resources
41
+ are read from that SHA with remote code disabled.
42
+
43
+ For a reusable or replaceable source reference, use `HubDatasetSource`:
44
+
45
+ ```python
46
+ from sci_modeling_bench import Dataset, HubDatasetSource
47
+
48
+ source = HubDatasetSource(
49
+ repo_id="internal-mirror/design-bench",
50
+ config_name="tfbind8",
51
+ revision="full-commit-sha",
52
+ )
53
+ dataset = Dataset.from_source(source)
54
+ ```
55
+
56
+ `Dataset.from_source(source, *, token=None, validator=None)` applies the same
57
+ resolution and loading behavior. `HubDatasetSource` stores only repository,
58
+ config, and revision identity. Authentication comes from the local Hugging Face
59
+ configuration or the explicit `token` argument.
60
+
61
+ Dataset-specific classes may provide a default source. For example,
62
+ `TFBind8Dataset.from_hub()` fills in the Design-Bench repository and config
63
+ while still accepting a mirror or pinned revision.
64
+
65
+ ## Dataset Properties
66
+
67
+ | Property | Type | Meaning |
68
+ |---|---|---|
69
+ | `repo_id` | `str` | Hugging Face Dataset repository used by this instance |
70
+ | `resolved_revision` | `str` | Full commit SHA used for every repository access |
71
+ | `config_name` | `str` | Selected repository config |
72
+ | `metadata` | `DatasetMetadata` | Dataset ID, version, description, license, sources, and citations |
73
+ | `schema` | `DatasetSchema` | Input, target, and context field declarations |
74
+ | `default_split` | `str` | Manifest-selected split name |
75
+ | `splits` | `tuple[DatasetSplit, ...]` | Immutable split metadata |
76
+ | `available_splits` | `tuple[str, ...]` | Declared split names in manifest order |
77
+ | `knowledge` | `Knowledge` | Read-only mapping of lazy text resources |
78
+ | `features` | Hugging Face `Features` | Physical features for the loaded default split |
79
+
80
+ Metadata, schema, field, split, constraint, violation, and validation-report
81
+ objects are immutable Pydantic models. `HubDatasetSource` and knowledge resource
82
+ metadata are immutable dataclasses.
83
+
84
+ ## Splits and Data Loading
85
+
86
+ ```python
87
+ split_metadata = dataset.split() # Default split
88
+ named_metadata = dataset.split("six6_ref_r1")
89
+
90
+ observations = dataset.load()
91
+ stream = dataset.load("six6_ref_r1", streaming=True)
92
+ ```
93
+
94
+ `split(name=None)` returns metadata for a declared split and raises `ValueError`
95
+ for an undeclared name. `load(split=None, *, streaming=False)` returns a standard
96
+ Hugging Face `Dataset` or, for streaming loads, an `IterableDataset`.
97
+
98
+ Non-streaming data are cached by split on the `Dataset` instance. When Hugging
99
+ Face feature metadata is available, loading checks that every manifest-declared
100
+ field exists. When a split declares `num_rows`, non-streaming loading also
101
+ checks the row count. Streaming loads are not cached and cannot perform the
102
+ row-count check.
103
+
104
+ A published split is an observation group with one schema and shared metadata.
105
+ It is not an agent-visible train/test view; constructing that view is a
106
+ [Protocol](protocol.md) responsibility.
107
+
108
+ ## Semantic Schema
109
+
110
+ `dataset.schema` contains ordered `inputs`, `targets`, and `context` tuples of
111
+ `FieldSpec` objects. Field names must be unique across all roles. Each field has
112
+ a name, description, optional unit, `required` flag, and zero or more common
113
+ constraints.
114
+
115
+ | Constraint kind | Model | Behavior |
116
+ |---|---|---|
117
+ | `range` | `NumericRangeConstraint` | Minimum and maximum numeric bounds; each bound can be inclusive or exclusive |
118
+ | `allowed_values` | `AllowedValuesConstraint` | Finite allowed set for scalar values or sequence leaves |
119
+ | `alphabet` | `AlphabetConstraint` | Allowed single-character symbols for a string |
120
+ | `length` | `LengthConstraint` | Minimum and maximum length for strings or sized sequences |
121
+ | `finite` | `FiniteConstraint` | Reject NaN and infinite numeric leaves |
122
+
123
+ Example field declarations in a config manifest:
124
+
125
+ ```json
126
+ {
127
+ "inputs": [
128
+ {
129
+ "name": "sequence",
130
+ "description": "DNA sequence of exactly eight nucleotides.",
131
+ "constraints": [
132
+ {"kind": "alphabet", "symbols": ["A", "C", "G", "T"]},
133
+ {"kind": "length", "minimum": 8, "maximum": 8}
134
+ ]
135
+ }
136
+ ],
137
+ "targets": [
138
+ {
139
+ "name": "normalized_e_score",
140
+ "description": "Condition-level normalized E-score.",
141
+ "constraints": [
142
+ {"kind": "finite"},
143
+ {"kind": "range", "minimum": 0.0, "maximum": 1.0}
144
+ ]
145
+ }
146
+ ],
147
+ "context": []
148
+ }
149
+ ```
150
+
151
+ Hugging Face `Features` remain the authority for physical dtype and shape.
152
+ Field specifications add semantic roles and scientific constraints.
153
+
154
+ ## Validation
155
+
156
+ ```python
157
+ input_report = dataset.validate_inputs(
158
+ {"sequence": "AACCGGTT"},
159
+ context=None,
160
+ )
161
+ target_report = dataset.validate_targets(
162
+ {"normalized_e_score": 0.5},
163
+ inputs={"sequence": "AACCGGTT"},
164
+ context=None,
165
+ )
166
+ row_report = dataset.validate_observation(observation)
167
+ full_report = dataset.validate_dataset()
168
+ ```
169
+
170
+ The validation methods return `ValidationReport`; expected data errors are not
171
+ raised as exceptions. A report contains immutable `Violation` objects with a
172
+ machine-readable `code`, message, optional field and row index, and `error` or
173
+ `warning` severity. `report.valid` is false when at least one error is present.
174
+
175
+ - `validate_inputs()` checks the input role, context role, physical features,
176
+ common constraints, and custom input hooks. Unknown role fields are rejected.
177
+ - `validate_targets()` checks the target and context roles, then passes optional
178
+ inputs and context to custom target checks. It does not separately validate
179
+ the supplied `inputs` mapping.
180
+ - `validate_observation()` checks all declared fields in one row and permits
181
+ additional published columns.
182
+ - `validate_dataset(data=None)` validates every row and then runs the custom
183
+ dataset-level hook. It can be expensive for large or streaming data.
184
+
185
+ Validation reports findings without clipping, repairing, or mutating values.
186
+
187
+ For scientific checks that cannot be expressed in a manifest, subclass
188
+ `DatasetValidator` and pass an instance while loading:
189
+
190
+ ```python
191
+ from sci_modeling_bench import DatasetValidator, ValidationReport, Violation
192
+
193
+
194
+ class RejectHomopolymers(DatasetValidator):
195
+ def validate_inputs(self, inputs, context=None):
196
+ sequence = inputs.get("sequence")
197
+ if isinstance(sequence, str) and sequence and len(set(sequence)) == 1:
198
+ return ValidationReport(
199
+ violations=(
200
+ Violation(
201
+ code="homopolymer",
202
+ field="sequence",
203
+ message="homopolymers are not accepted",
204
+ ),
205
+ )
206
+ )
207
+ return ValidationReport()
208
+ ```
209
+
210
+ Custom validators are local code. Dataset repositories cannot provide remotely
211
+ executed validators.
212
+
213
+ ## Knowledge Resources
214
+
215
+ `dataset.knowledge` is always a read-only mapping and is falsey when the
216
+ manifest declares no resources. Resource contents are loaded only when read:
217
+
218
+ ```python
219
+ for name, resource in dataset.knowledge.items():
220
+ print(name, resource.title, resource.media_type)
221
+
222
+ overview = dataset.knowledge.read_text("domain_overview")
223
+ # Equivalent: dataset.knowledge["domain_overview"].read_text()
224
+ ```
225
+
226
+ Supported media types are `text/markdown` and `text/plain`. Resources are read
227
+ from the Dataset's resolved repository revision. They should explain scientific
228
+ meaning, priors, constraints, and limitations, not contain executable code or
229
+ agent workflow instructions.
230
+
231
+ ## Repository Contract
232
+
233
+ One Hugging Face Dataset repository can publish multiple related configs:
234
+
235
+ ```text
236
+ README.md
237
+ scimodelingbench.json
238
+ manifests/
239
+ └── tfbind8.json
240
+ data/
241
+ └── tfbind8/
242
+ └── six6_ref_r1.parquet
243
+ knowledge/
244
+ └── tfbind8/
245
+ └── domain-overview.md
246
+ ```
247
+
248
+ The Dataset Card's YAML metadata maps configs and splits to data files.
249
+ `scimodelingbench.json` maps the same config names to semantic manifests:
250
+
251
+ ```json
252
+ {
253
+ "schema_version": 1,
254
+ "default_config": "tfbind8",
255
+ "configs": {
256
+ "tfbind8": {"manifest": "manifests/tfbind8.json"}
257
+ }
258
+ }
259
+ ```
260
+
261
+ The config manifest schema version is `1` and defines these field groups:
262
+
263
+ | Field | Meaning |
264
+ |---|---|
265
+ | `dataset_id`, `version`, `description`, `license` | Stable identity and release metadata |
266
+ | `default_split`, `splits` | Published split declarations; each split has a name, description, optional row count, optional sources, and scalar attributes |
267
+ | `inputs`, `targets`, `context` | Semantic field roles and constraints |
268
+ | `source`, `citation` | Upstream provenance and citation records |
269
+ | `knowledge` | Stable snake-case names mapped to repository-relative text resources |
270
+
271
+ `source`, `citation`, `context`, and `knowledge` may be omitted or empty. Input,
272
+ target, and split collections may not be empty. Unknown manifest fields,
273
+ duplicate names, unsafe repository paths, and references to undeclared defaults
274
+ are rejected. Raw data and preprocessing code may stay upstream, but provenance
275
+ should record the source version, revision, and checksum when available.
276
+
277
+ Dataset loading never executes Python code from the remote repository.
278
+
279
+ ## Exceptions
280
+
281
+ | Exception | Raised when |
282
+ |---|---|
283
+ | `ManifestError` | A collection or config manifest is missing, malformed, or internally inconsistent |
284
+ | `DatasetLoadError` | A Hub revision or repository resource cannot be resolved or loaded |
285
+ | `SchemaMismatchError` | Loaded data omit declared columns or violate a declared non-streaming row count |
286
+ | `ValueError` | A caller requests an undeclared split or constructs an invalid `HubDatasetSource` |
287
+
288
+ All package-specific exceptions inherit from `SciModelingBenchError`.
289
+
290
+ ## Concrete Dataset
291
+
292
+ See [TFBind8](../suites/design-bench/tfbind8.md) for the first Dataset-specific
293
+ loader, validator, exact Objective, and offline-data Protocol.