silver-lang 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.
- silver_lang-0.1.0/CHANGELOG.md +20 -0
- silver_lang-0.1.0/CODE_OF_CONDUCT.md +15 -0
- silver_lang-0.1.0/CONTRIBUTING.md +66 -0
- silver_lang-0.1.0/LICENSE +12 -0
- silver_lang-0.1.0/MANIFEST.in +11 -0
- silver_lang-0.1.0/PKG-INFO +211 -0
- silver_lang-0.1.0/README.md +181 -0
- silver_lang-0.1.0/SECURITY.md +33 -0
- silver_lang-0.1.0/docs/agents/contracts.md +25 -0
- silver_lang-0.1.0/docs/api.md +54 -0
- silver_lang-0.1.0/docs/architecture/diamond-design.md +35 -0
- silver_lang-0.1.0/docs/architecture/full-pipeline.md +28 -0
- silver_lang-0.1.0/docs/choose-your-path.md +66 -0
- silver_lang-0.1.0/docs/ecosystem.md +53 -0
- silver_lang-0.1.0/docs/ieee-inverse-diagnoser.md +41 -0
- silver_lang-0.1.0/docs/index.md +49 -0
- silver_lang-0.1.0/docs/language/syntax.md +30 -0
- silver_lang-0.1.0/docs/ml/core-principles-side-by-side.md +43 -0
- silver_lang-0.1.0/docs/ml/neural-network-learning-views.md +48 -0
- silver_lang-0.1.0/docs/ml/tiny-gpt.md +21 -0
- silver_lang-0.1.0/docs/publishing.md +71 -0
- silver_lang-0.1.0/docs/repository-split.md +73 -0
- silver_lang-0.1.0/docs/voice.md +40 -0
- silver_lang-0.1.0/pyproject.toml +56 -0
- silver_lang-0.1.0/setup.cfg +4 -0
- silver_lang-0.1.0/silver_lang.egg-info/PKG-INFO +211 -0
- silver_lang-0.1.0/silver_lang.egg-info/SOURCES.txt +69 -0
- silver_lang-0.1.0/silver_lang.egg-info/dependency_links.txt +1 -0
- silver_lang-0.1.0/silver_lang.egg-info/entry_points.txt +2 -0
- silver_lang-0.1.0/silver_lang.egg-info/requires.txt +4 -0
- silver_lang-0.1.0/silver_lang.egg-info/top_level.txt +1 -0
- silver_lang-0.1.0/silverlang/__init__.py +57 -0
- silver_lang-0.1.0/silverlang/__main__.py +7 -0
- silver_lang-0.1.0/silverlang/agents/__init__.py +1 -0
- silver_lang-0.1.0/silverlang/agents/runtime.py +149 -0
- silver_lang-0.1.0/silverlang/bytecode/__init__.py +21 -0
- silver_lang-0.1.0/silverlang/bytecode/model.py +115 -0
- silver_lang-0.1.0/silverlang/core/__init__.py +1 -0
- silver_lang-0.1.0/silverlang/core/errors.py +17 -0
- silver_lang-0.1.0/silverlang/core/trace.py +53 -0
- silver_lang-0.1.0/silverlang/frontend/__init__.py +1 -0
- silver_lang-0.1.0/silverlang/frontend/ast.py +61 -0
- silver_lang-0.1.0/silverlang/frontend/lexer.py +146 -0
- silver_lang-0.1.0/silverlang/frontend/parser.py +184 -0
- silver_lang-0.1.0/silverlang/interop/__init__.py +1 -0
- silver_lang-0.1.0/silverlang/interop/contracts.py +39 -0
- silver_lang-0.1.0/silverlang/ir/__init__.py +1 -0
- silver_lang-0.1.0/silverlang/ir/compiler.py +94 -0
- silver_lang-0.1.0/silverlang/ml/__init__.py +44 -0
- silver_lang-0.1.0/silverlang/ml/network.py +422 -0
- silver_lang-0.1.0/silverlang/ml/principles.py +225 -0
- silver_lang-0.1.0/silverlang/ml/teaching.py +129 -0
- silver_lang-0.1.0/silverlang/ml/tensor.py +69 -0
- silver_lang-0.1.0/silverlang/ml/tiny_gpt.py +64 -0
- silver_lang-0.1.0/silverlang/optimizer/__init__.py +5 -0
- silver_lang-0.1.0/silverlang/optimizer/passes.py +126 -0
- silver_lang-0.1.0/silverlang/pipeline.py +103 -0
- silver_lang-0.1.0/silverlang/py.typed +1 -0
- silver_lang-0.1.0/silverlang/tools/__init__.py +1 -0
- silver_lang-0.1.0/silverlang/tools/cli.py +114 -0
- silver_lang-0.1.0/silverlang/visualization/__init__.py +21 -0
- silver_lang-0.1.0/silverlang/visualization/svg.py +726 -0
- silver_lang-0.1.0/silverlang/vm/__init__.py +1 -0
- silver_lang-0.1.0/silverlang/vm/runtime.py +83 -0
- silver_lang-0.1.0/silverlang/workbench.py +143 -0
- silver_lang-0.1.0/tests/test_agents_ml_interop.py +131 -0
- silver_lang-0.1.0/tests/test_bytecode_pipeline.py +65 -0
- silver_lang-0.1.0/tests/test_diamond_language.py +76 -0
- silver_lang-0.1.0/tests/test_java_maven_package.py +195 -0
- silver_lang-0.1.0/tests/test_open_source_package.py +69 -0
- silver_lang-0.1.0/tests/test_workbench.py +33 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable Silver changes should be recorded here.
|
|
4
|
+
|
|
5
|
+
## 0.1.0
|
|
6
|
+
|
|
7
|
+
- Added the native `silver-lang` npm package for Node.js 18 and newer.
|
|
8
|
+
- Added TypeScript declarations, ESM exports, and the `silver` CLI.
|
|
9
|
+
- Added native language execution, deterministic traces, compiler, bytecode,
|
|
10
|
+
stack VM, runtime memory utilities, graph models, package management, agent
|
|
11
|
+
workflows, application planning, module loading, and IDE models.
|
|
12
|
+
- Added native ML layers, classifiers, tensor inspection, autodiff, and ML source
|
|
13
|
+
compilation.
|
|
14
|
+
- Added computed neural-network inspection, Silver/Python teaching translation,
|
|
15
|
+
deterministic TinyGPT generation, virtual large-model profiles, and typed
|
|
16
|
+
blueprints for Transformer and deep-learning model families.
|
|
17
|
+
- Documented the executable reference path separately from architecture
|
|
18
|
+
blueprints and added a clearer contributor and local tarball workflow.
|
|
19
|
+
- Added local tarball testing instructions so consumers can validate a release
|
|
20
|
+
before registry publication.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Code of Conduct
|
|
2
|
+
|
|
3
|
+
Silver contributors are expected to make participation respectful, practical,
|
|
4
|
+
and accessible to people with different backgrounds and levels of experience.
|
|
5
|
+
|
|
6
|
+
Unacceptable behavior includes harassment, discrimination, personal attacks,
|
|
7
|
+
deliberate intimidation, unwanted contact, and publishing private information.
|
|
8
|
+
|
|
9
|
+
Report conduct concerns privately to the repository maintainers through the
|
|
10
|
+
security contact listed in [SECURITY.md](SECURITY.md). Do not use public issue
|
|
11
|
+
discussion for sensitive reports.
|
|
12
|
+
|
|
13
|
+
Maintainers may remove comments, close discussions, or restrict participation
|
|
14
|
+
when necessary to protect the project community. They will explain moderation
|
|
15
|
+
decisions when doing so is safe and appropriate.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Contributing To Silver
|
|
2
|
+
|
|
3
|
+
Thank you for taking a look. Silver is intentionally small: the best
|
|
4
|
+
contributions make one behavior clearer, more useful, or more testable without
|
|
5
|
+
making the reference implementation harder to understand.
|
|
6
|
+
|
|
7
|
+
The central idea is inspectability. A contribution should preserve as much of
|
|
8
|
+
the following as the feature allows:
|
|
9
|
+
|
|
10
|
+
- source behavior can be followed through syntax, IR, bytecode, VM, or traces;
|
|
11
|
+
- agent workflows can be replayed and checked;
|
|
12
|
+
- ML operations expose their data and gradients in the reference path;
|
|
13
|
+
- public Python contracts say what callers can rely on;
|
|
14
|
+
- tests demonstrate behavior rather than only checking object shape.
|
|
15
|
+
|
|
16
|
+
## Before You Start
|
|
17
|
+
|
|
18
|
+
Silver targets Python 3.9 or newer. Install the root development package and
|
|
19
|
+
the companion package test dependencies with pip.
|
|
20
|
+
|
|
21
|
+
## Local Development
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
python3 -m pip install -e '.[dev]' \
|
|
25
|
+
-e 'packages/data[dev,pandas]' \
|
|
26
|
+
-e 'packages/run[dev]' \
|
|
27
|
+
-e 'packages/diagnostics[dev]' \
|
|
28
|
+
-e 'packages/adapters[dev,remote]'
|
|
29
|
+
python3 -m pytest tests packages/data/tests packages/run/tests packages/diagnostics/tests packages/adapters/tests
|
|
30
|
+
python3 -m build
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Pull Request Bar
|
|
34
|
+
|
|
35
|
+
- Add or update tests for language, runtime, compiler, agent, or ML changes.
|
|
36
|
+
- Add docs for new syntax, agent semantics, public APIs, or ML behavior.
|
|
37
|
+
- Do not introduce parser generators or hidden ML dependencies in the reference
|
|
38
|
+
path.
|
|
39
|
+
- Keep deterministic traces stable unless the change intentionally updates the
|
|
40
|
+
trace schema.
|
|
41
|
+
- Keep documentation honest about whether a feature executes today or is an
|
|
42
|
+
inspectable design contract.
|
|
43
|
+
- Keep the change focused and explain its user-facing reason in the pull request.
|
|
44
|
+
|
|
45
|
+
## How We Code Here
|
|
46
|
+
|
|
47
|
+
- Keep low-level paths explicit.
|
|
48
|
+
- Add convenience only when it teaches or removes real friction.
|
|
49
|
+
- Write names a human would say out loud: `compileSilverMl`, `explain`, and
|
|
50
|
+
`stableDigest`.
|
|
51
|
+
- Let tests describe the promise.
|
|
52
|
+
- Prefer a small implementation over a general abstraction introduced for one
|
|
53
|
+
caller.
|
|
54
|
+
|
|
55
|
+
## Good First Contributions
|
|
56
|
+
|
|
57
|
+
- Add a regression test for an edge case in the language or VM.
|
|
58
|
+
- Improve an example so a new user can run it without knowing the internals.
|
|
59
|
+
- Add an executable ML operation with forward, gradient, serialization, and
|
|
60
|
+
inspection tests.
|
|
61
|
+
- Turn one architecture blueprint into a small, deterministic executable model.
|
|
62
|
+
- Improve error messages while preserving stable behavior where callers depend
|
|
63
|
+
on it.
|
|
64
|
+
|
|
65
|
+
Please open an issue first for a broad architectural change. That gives the
|
|
66
|
+
design a chance to settle before implementation begins.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
|
|
4
|
+
Copyright 2026 Silver Contributors
|
|
5
|
+
|
|
6
|
+
Licensed under the Apache License, Version 2.0. You may obtain a copy of the
|
|
7
|
+
License at https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
10
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
11
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
12
|
+
specific language governing permissions and limitations under the License.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include LICENSE
|
|
3
|
+
include CONTRIBUTING.md
|
|
4
|
+
include SECURITY.md
|
|
5
|
+
include CODE_OF_CONDUCT.md
|
|
6
|
+
include CHANGELOG.md
|
|
7
|
+
recursive-include silverlang *.py py.typed
|
|
8
|
+
recursive-include docs *.md
|
|
9
|
+
recursive-include tests *.py
|
|
10
|
+
global-exclude __pycache__
|
|
11
|
+
global-exclude *.py[cod]
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: silver-lang
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: From-scratch AI systems language with deterministic agents, ML graphs, and runtime traces.
|
|
5
|
+
Author: Silver Contributors
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/adfgdartec/silver-lang
|
|
8
|
+
Project-URL: Repository, https://github.com/adfgdartec/silver-lang
|
|
9
|
+
Project-URL: Issues, https://github.com/adfgdartec/silver-lang/issues
|
|
10
|
+
Project-URL: Documentation, https://github.com/adfgdartec/silver-lang#readme
|
|
11
|
+
Keywords: language,compiler,agents,machine-learning,deterministic-runtime
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
28
|
+
Requires-Dist: build>=1.0; extra == "dev"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# Silver
|
|
32
|
+
|
|
33
|
+
Silver is a small, inspectable language and machine-learning toolkit for
|
|
34
|
+
Python.
|
|
35
|
+
|
|
36
|
+
The Silver ecosystem also includes lightweight Python packages for datasets,
|
|
37
|
+
training lifecycles, diagnostics, and bridges to PyTorch, TensorFlow, Keras,
|
|
38
|
+
notebooks, and remote jobs. Start with [Choose your Silver path](docs/choose-your-path.md)
|
|
39
|
+
to install only what your project needs.
|
|
40
|
+
|
|
41
|
+
It is for people who want to see what a program, model, compiler, or agent is
|
|
42
|
+
doing instead of handing the important parts to opaque infrastructure. Silver
|
|
43
|
+
keeps source structure, intermediate representations, tensor operations,
|
|
44
|
+
execution traces, and model metadata available to the caller.
|
|
45
|
+
|
|
46
|
+
Silver is useful for:
|
|
47
|
+
|
|
48
|
+
- teaching language runtimes, compilers, autodiff, and neural networks;
|
|
49
|
+
- building deterministic experiments and replayable agent workflows;
|
|
50
|
+
- inspecting a model while it runs, not only reading its final prediction;
|
|
51
|
+
- prototyping small Python tools without a large native ML dependency;
|
|
52
|
+
- explaining how a larger architecture is organized before choosing a heavy
|
|
53
|
+
production backend.
|
|
54
|
+
|
|
55
|
+
It is not a replacement for PyTorch, TensorFlow, or a hosted model service.
|
|
56
|
+
Some larger architecture APIs are deliberately inspectable blueprints. The
|
|
57
|
+
executable reference path currently focuses on the language runtime, tensors,
|
|
58
|
+
autodiff, dense classifiers, ML source compilation, and TinyGPT.
|
|
59
|
+
|
|
60
|
+
## Install From PyPI
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
python -m pip install silver-lang
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Requirements: Python 3.9 or newer.
|
|
67
|
+
|
|
68
|
+
## First Program
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from silverlang import build_pipeline, run_source
|
|
72
|
+
|
|
73
|
+
source = """
|
|
74
|
+
fn main():
|
|
75
|
+
value = 6 * 7
|
|
76
|
+
return value
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
print(run_source(source).value)
|
|
80
|
+
print(build_pipeline(source).to_json())
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The runtime supports functions, assignments, integer literals, variables,
|
|
84
|
+
arithmetic, returns, deterministic traces, tokenization, source digests, and
|
|
85
|
+
execution manifests. Use `explain()` when you want to understand what happened,
|
|
86
|
+
not only get a value back.
|
|
87
|
+
|
|
88
|
+
## A Small ML Experiment
|
|
89
|
+
|
|
90
|
+
The executable reference implementation is Python:
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from silverlang import build_pipeline
|
|
94
|
+
|
|
95
|
+
artifacts = build_pipeline(source)
|
|
96
|
+
print(artifacts.to_json())
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Inspectable ML
|
|
100
|
+
|
|
101
|
+
The native ML implementation includes deterministic dense layers, ReLU,
|
|
102
|
+
sigmoid and linear activations, softmax classifier output, single-sample SGD,
|
|
103
|
+
cross-entropy training, tensor operations, reverse-mode autodiff, neuron
|
|
104
|
+
inspection, model graphs, tensor graph metadata, gradient checks, named
|
|
105
|
+
datasets, deterministic TinyGPT generation, and virtual large-model profiles.
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from silverlang.ml.tensor import Tensor
|
|
109
|
+
|
|
110
|
+
tensor = Tensor.vector_grad(1, -2, 3).relu().sum()
|
|
111
|
+
tensor.backward()
|
|
112
|
+
print(tensor.inspect())
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The package also has blueprints for Transformer, recurrent, CNN, autoencoder,
|
|
116
|
+
GAN, diffusion, mixture-of-experts, retrieval-augmented, and hybrid systems.
|
|
117
|
+
These describe components, dimensions, estimated scale, and composition
|
|
118
|
+
boundaries. They do not allocate or train those large architectures yet.
|
|
119
|
+
|
|
120
|
+
For a model-level explanation, use the computed inspection and translation
|
|
121
|
+
helpers:
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
from silverlang import teach_network
|
|
125
|
+
|
|
126
|
+
study = teach_network()
|
|
127
|
+
print(study.summary)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Try the CLI
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
silver run program.sv
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The CLI prints a deterministic execution manifest as JSON, which makes a small
|
|
137
|
+
Silver program easy to inspect in a terminal or CI job.
|
|
138
|
+
|
|
139
|
+
## Test Before Publishing
|
|
140
|
+
|
|
141
|
+
Friends can test the exact package artifacts without publication:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
python -m pip install -e '.[dev]'
|
|
145
|
+
python -m pytest
|
|
146
|
+
python -m build
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The companion packages are built from their own directories:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
python build_packages.py
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
The generated wheels and source archives can then be installed by a separate
|
|
156
|
+
Python project.
|
|
157
|
+
|
|
158
|
+
## Develop Silver
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
python -m pip install -e '.[dev]'
|
|
162
|
+
python -m pytest
|
|
163
|
+
python -m build
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
The test suite exercises the Python compiler, VM, runtime, and ML paths. See
|
|
167
|
+
[CONTRIBUTING.md](CONTRIBUTING.md) for the contributor workflow and
|
|
168
|
+
[docs/index.md](docs/index.md) for topic-focused guides.
|
|
169
|
+
|
|
170
|
+
## Publish the Package Family
|
|
171
|
+
|
|
172
|
+
The root checkout is an umbrella repository. Export the six standalone package
|
|
173
|
+
repositories with:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
python scripts/export_repositories.py --owner YOUR_GITHUB_OWNER
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
The script creates local repositories with package-specific CI and PyPI release
|
|
180
|
+
workflows. It never creates remotes or pushes credentials. Follow
|
|
181
|
+
[docs/publishing.md](docs/publishing.md) for the exact GitHub and PyPI steps.
|
|
182
|
+
|
|
183
|
+
## Public API
|
|
184
|
+
|
|
185
|
+
The root `silverlang` package exports the lexer, parser, compiler pipeline,
|
|
186
|
+
stack VM, runtime traces, visualization helpers, agent/workbench helpers, and
|
|
187
|
+
the inspectable tensor and neural-network teaching modules. Lower-level
|
|
188
|
+
modules include `silverlang.frontend`, `silverlang.ir`, `silverlang.bytecode`,
|
|
189
|
+
`silverlang.vm`, and `silverlang.ml`.
|
|
190
|
+
|
|
191
|
+
Read [docs/api.md](docs/api.md) for examples, [docs/language/syntax.md](docs/language/syntax.md)
|
|
192
|
+
for the language surface, and [docs/ml/tiny-gpt.md](docs/ml/tiny-gpt.md) for a
|
|
193
|
+
small model walkthrough. See [docs/ecosystem.md](docs/ecosystem.md) for the
|
|
194
|
+
separate-package roadmap.
|
|
195
|
+
|
|
196
|
+
## Project Boundaries
|
|
197
|
+
|
|
198
|
+
Silver favors a small reference implementation with visible contracts over a
|
|
199
|
+
large dependency graph. The package includes language execution, compiler and
|
|
200
|
+
bytecode inspection, a stack VM, memory utilities, graph and package models,
|
|
201
|
+
replayable agent workflows, application planning, module loading, IDE models,
|
|
202
|
+
and the native ML paths described above.
|
|
203
|
+
|
|
204
|
+
Specialized ML estimators such as Adam, unsupervised learning, reinforcement
|
|
205
|
+
learning, regression, and full executable CNN, Transformer, GAN, and diffusion
|
|
206
|
+
backends are future work. Contributions that make one of those paths real,
|
|
207
|
+
tested, and explainable are especially valuable.
|
|
208
|
+
|
|
209
|
+
## License
|
|
210
|
+
|
|
211
|
+
Silver is distributed under the [Apache License 2.0](LICENSE).
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# Silver
|
|
2
|
+
|
|
3
|
+
Silver is a small, inspectable language and machine-learning toolkit for
|
|
4
|
+
Python.
|
|
5
|
+
|
|
6
|
+
The Silver ecosystem also includes lightweight Python packages for datasets,
|
|
7
|
+
training lifecycles, diagnostics, and bridges to PyTorch, TensorFlow, Keras,
|
|
8
|
+
notebooks, and remote jobs. Start with [Choose your Silver path](docs/choose-your-path.md)
|
|
9
|
+
to install only what your project needs.
|
|
10
|
+
|
|
11
|
+
It is for people who want to see what a program, model, compiler, or agent is
|
|
12
|
+
doing instead of handing the important parts to opaque infrastructure. Silver
|
|
13
|
+
keeps source structure, intermediate representations, tensor operations,
|
|
14
|
+
execution traces, and model metadata available to the caller.
|
|
15
|
+
|
|
16
|
+
Silver is useful for:
|
|
17
|
+
|
|
18
|
+
- teaching language runtimes, compilers, autodiff, and neural networks;
|
|
19
|
+
- building deterministic experiments and replayable agent workflows;
|
|
20
|
+
- inspecting a model while it runs, not only reading its final prediction;
|
|
21
|
+
- prototyping small Python tools without a large native ML dependency;
|
|
22
|
+
- explaining how a larger architecture is organized before choosing a heavy
|
|
23
|
+
production backend.
|
|
24
|
+
|
|
25
|
+
It is not a replacement for PyTorch, TensorFlow, or a hosted model service.
|
|
26
|
+
Some larger architecture APIs are deliberately inspectable blueprints. The
|
|
27
|
+
executable reference path currently focuses on the language runtime, tensors,
|
|
28
|
+
autodiff, dense classifiers, ML source compilation, and TinyGPT.
|
|
29
|
+
|
|
30
|
+
## Install From PyPI
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
python -m pip install silver-lang
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Requirements: Python 3.9 or newer.
|
|
37
|
+
|
|
38
|
+
## First Program
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from silverlang import build_pipeline, run_source
|
|
42
|
+
|
|
43
|
+
source = """
|
|
44
|
+
fn main():
|
|
45
|
+
value = 6 * 7
|
|
46
|
+
return value
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
print(run_source(source).value)
|
|
50
|
+
print(build_pipeline(source).to_json())
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The runtime supports functions, assignments, integer literals, variables,
|
|
54
|
+
arithmetic, returns, deterministic traces, tokenization, source digests, and
|
|
55
|
+
execution manifests. Use `explain()` when you want to understand what happened,
|
|
56
|
+
not only get a value back.
|
|
57
|
+
|
|
58
|
+
## A Small ML Experiment
|
|
59
|
+
|
|
60
|
+
The executable reference implementation is Python:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from silverlang import build_pipeline
|
|
64
|
+
|
|
65
|
+
artifacts = build_pipeline(source)
|
|
66
|
+
print(artifacts.to_json())
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Inspectable ML
|
|
70
|
+
|
|
71
|
+
The native ML implementation includes deterministic dense layers, ReLU,
|
|
72
|
+
sigmoid and linear activations, softmax classifier output, single-sample SGD,
|
|
73
|
+
cross-entropy training, tensor operations, reverse-mode autodiff, neuron
|
|
74
|
+
inspection, model graphs, tensor graph metadata, gradient checks, named
|
|
75
|
+
datasets, deterministic TinyGPT generation, and virtual large-model profiles.
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from silverlang.ml.tensor import Tensor
|
|
79
|
+
|
|
80
|
+
tensor = Tensor.vector_grad(1, -2, 3).relu().sum()
|
|
81
|
+
tensor.backward()
|
|
82
|
+
print(tensor.inspect())
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The package also has blueprints for Transformer, recurrent, CNN, autoencoder,
|
|
86
|
+
GAN, diffusion, mixture-of-experts, retrieval-augmented, and hybrid systems.
|
|
87
|
+
These describe components, dimensions, estimated scale, and composition
|
|
88
|
+
boundaries. They do not allocate or train those large architectures yet.
|
|
89
|
+
|
|
90
|
+
For a model-level explanation, use the computed inspection and translation
|
|
91
|
+
helpers:
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from silverlang import teach_network
|
|
95
|
+
|
|
96
|
+
study = teach_network()
|
|
97
|
+
print(study.summary)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Try the CLI
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
silver run program.sv
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The CLI prints a deterministic execution manifest as JSON, which makes a small
|
|
107
|
+
Silver program easy to inspect in a terminal or CI job.
|
|
108
|
+
|
|
109
|
+
## Test Before Publishing
|
|
110
|
+
|
|
111
|
+
Friends can test the exact package artifacts without publication:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
python -m pip install -e '.[dev]'
|
|
115
|
+
python -m pytest
|
|
116
|
+
python -m build
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The companion packages are built from their own directories:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
python build_packages.py
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
The generated wheels and source archives can then be installed by a separate
|
|
126
|
+
Python project.
|
|
127
|
+
|
|
128
|
+
## Develop Silver
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
python -m pip install -e '.[dev]'
|
|
132
|
+
python -m pytest
|
|
133
|
+
python -m build
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The test suite exercises the Python compiler, VM, runtime, and ML paths. See
|
|
137
|
+
[CONTRIBUTING.md](CONTRIBUTING.md) for the contributor workflow and
|
|
138
|
+
[docs/index.md](docs/index.md) for topic-focused guides.
|
|
139
|
+
|
|
140
|
+
## Publish the Package Family
|
|
141
|
+
|
|
142
|
+
The root checkout is an umbrella repository. Export the six standalone package
|
|
143
|
+
repositories with:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
python scripts/export_repositories.py --owner YOUR_GITHUB_OWNER
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The script creates local repositories with package-specific CI and PyPI release
|
|
150
|
+
workflows. It never creates remotes or pushes credentials. Follow
|
|
151
|
+
[docs/publishing.md](docs/publishing.md) for the exact GitHub and PyPI steps.
|
|
152
|
+
|
|
153
|
+
## Public API
|
|
154
|
+
|
|
155
|
+
The root `silverlang` package exports the lexer, parser, compiler pipeline,
|
|
156
|
+
stack VM, runtime traces, visualization helpers, agent/workbench helpers, and
|
|
157
|
+
the inspectable tensor and neural-network teaching modules. Lower-level
|
|
158
|
+
modules include `silverlang.frontend`, `silverlang.ir`, `silverlang.bytecode`,
|
|
159
|
+
`silverlang.vm`, and `silverlang.ml`.
|
|
160
|
+
|
|
161
|
+
Read [docs/api.md](docs/api.md) for examples, [docs/language/syntax.md](docs/language/syntax.md)
|
|
162
|
+
for the language surface, and [docs/ml/tiny-gpt.md](docs/ml/tiny-gpt.md) for a
|
|
163
|
+
small model walkthrough. See [docs/ecosystem.md](docs/ecosystem.md) for the
|
|
164
|
+
separate-package roadmap.
|
|
165
|
+
|
|
166
|
+
## Project Boundaries
|
|
167
|
+
|
|
168
|
+
Silver favors a small reference implementation with visible contracts over a
|
|
169
|
+
large dependency graph. The package includes language execution, compiler and
|
|
170
|
+
bytecode inspection, a stack VM, memory utilities, graph and package models,
|
|
171
|
+
replayable agent workflows, application planning, module loading, IDE models,
|
|
172
|
+
and the native ML paths described above.
|
|
173
|
+
|
|
174
|
+
Specialized ML estimators such as Adam, unsupervised learning, reinforcement
|
|
175
|
+
learning, regression, and full executable CNN, Transformer, GAN, and diffusion
|
|
176
|
+
backends are future work. Contributions that make one of those paths real,
|
|
177
|
+
tested, and explainable are especially valuable.
|
|
178
|
+
|
|
179
|
+
## License
|
|
180
|
+
|
|
181
|
+
Silver is distributed under the [Apache License 2.0](LICENSE).
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
Silver is alpha software. Do not run untrusted Silver programs or agent tools in
|
|
4
|
+
privileged environments.
|
|
5
|
+
|
|
6
|
+
## Supported Versions
|
|
7
|
+
|
|
8
|
+
| Version | Supported |
|
|
9
|
+
| ------- | ------------------------- |
|
|
10
|
+
| 0.1.x | Security reports accepted |
|
|
11
|
+
|
|
12
|
+
## Reporting
|
|
13
|
+
|
|
14
|
+
Please report security issues through the repository issue tracker:
|
|
15
|
+
|
|
16
|
+
https://github.com/adfgdartec/silver.sv/issues
|
|
17
|
+
|
|
18
|
+
Include:
|
|
19
|
+
|
|
20
|
+
- affected commit or release;
|
|
21
|
+
- operating system and Python version;
|
|
22
|
+
- proof of concept or reproduction steps;
|
|
23
|
+
- expected and actual behavior;
|
|
24
|
+
- whether the issue can affect deterministic replay, trace integrity, package
|
|
25
|
+
builds, or agent tool execution.
|
|
26
|
+
|
|
27
|
+
## Security Principles
|
|
28
|
+
|
|
29
|
+
- No hidden runtime execution.
|
|
30
|
+
- No network access in the reference compiler/runtime path.
|
|
31
|
+
- No parser generators or dynamic reflection dispatch in the language core.
|
|
32
|
+
- Agent tool calls must be explicit, bounded, logged, and replayable.
|
|
33
|
+
- Build outputs must be reproducible from source files.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Silver Agent Contracts
|
|
2
|
+
|
|
3
|
+
Silver agents are replayable graph nodes in the native Python runtime.
|
|
4
|
+
|
|
5
|
+
Each agent has a name, bounded execution loop, ordered tool registry, workspace
|
|
6
|
+
memory, messages, append-only trace events, and replay digests.
|
|
7
|
+
|
|
8
|
+
```js
|
|
9
|
+
import { Agent, AgentWorkflow } from "silver-lang/platform";
|
|
10
|
+
|
|
11
|
+
const researcher = new Agent(
|
|
12
|
+
"researcher",
|
|
13
|
+
async (value, context) => context.tool("memory.lookup", value),
|
|
14
|
+
{ "memory.lookup": async (value) => ({ value, source: "workspace" }) },
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
const workflow = new AgentWorkflow();
|
|
18
|
+
workflow.add(researcher);
|
|
19
|
+
const result = await workflow.run("protein");
|
|
20
|
+
console.log(result.replay(), result.verifyReplay());
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Each step records the selected tool, inputs, outputs, workspace writes, message
|
|
24
|
+
traffic, and stable payload digests. This makes workflows inspectable and
|
|
25
|
+
repeatable without hiding execution behind a framework.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Public API
|
|
2
|
+
|
|
3
|
+
Silver is distributed as the `silver-lang` Python package on PyPI. Its import
|
|
4
|
+
package is `silverlang`.
|
|
5
|
+
|
|
6
|
+
## Language Runtime
|
|
7
|
+
|
|
8
|
+
```python
|
|
9
|
+
from silverlang import Lexer, build_pipeline, run_source
|
|
10
|
+
|
|
11
|
+
source = "fn main():\n return 2 + 3\n"
|
|
12
|
+
tokens = Lexer(source).lex()
|
|
13
|
+
artifacts = build_pipeline(source)
|
|
14
|
+
value = run_source(source)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The root API exposes tokenization, compilation, execution, deterministic traces,
|
|
18
|
+
source digests, and execution manifests.
|
|
19
|
+
|
|
20
|
+
## ML
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from silverlang.ml.tensor import Tensor
|
|
24
|
+
|
|
25
|
+
tensor = Tensor.vector_grad(1, -2, 3).relu().sum()
|
|
26
|
+
tensor.backward();
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Platform Modules
|
|
30
|
+
|
|
31
|
+
The package also exposes `silverlang.platform`, `silverlang.ir`,
|
|
32
|
+
`silverlang.pipeline`, and `silverlang.vm` for package management, graphs,
|
|
33
|
+
agents/workflows, compiler/bytecode inspection, and deterministic stack-machine
|
|
34
|
+
execution.
|
|
35
|
+
|
|
36
|
+
## Inspection and Model Families
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from silverlang import teach_network
|
|
40
|
+
|
|
41
|
+
study = teach_network()
|
|
42
|
+
print(study.summary)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The model-family blueprints are metadata and graph contracts, not claims that
|
|
46
|
+
the package allocates a trillion-parameter model in memory. They make the
|
|
47
|
+
attention pattern, component boundaries, estimated scale, and composition
|
|
48
|
+
choices inspectable before an execution backend is selected.
|
|
49
|
+
|
|
50
|
+
## CLI
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
silver run program.sv
|
|
54
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Silver Diamond Design
|
|
2
|
+
|
|
3
|
+
Silver exists for people building AI systems that need to be understood, not
|
|
4
|
+
just executed.
|
|
5
|
+
|
|
6
|
+
## System Shape
|
|
7
|
+
|
|
8
|
+
```text
|
|
9
|
+
source.sv
|
|
10
|
+
-> handwritten lexer
|
|
11
|
+
-> recursive-descent parser
|
|
12
|
+
-> AST
|
|
13
|
+
-> explicit IR
|
|
14
|
+
-> optimizer
|
|
15
|
+
-> bytecode
|
|
16
|
+
-> deterministic VM
|
|
17
|
+
-> trace log
|
|
18
|
+
-> agent/model/deployment evidence
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Diamond Principles
|
|
22
|
+
|
|
23
|
+
1. AI systems are graphs, so Silver stores computation as visible graph events.
|
|
24
|
+
2. Agents are deterministic workflows by default, not opaque loops.
|
|
25
|
+
3. Models can be trained elsewhere later, but the reference path must be
|
|
26
|
+
inspectable from scratch.
|
|
27
|
+
4. Native Python modules share trace contracts instead of hiding
|
|
28
|
+
implementation details behind external runtimes.
|
|
29
|
+
5. Every optimization must preserve observable traces or explain why not.
|
|
30
|
+
|
|
31
|
+
## Non-Goals For The Initial Rewrite
|
|
32
|
+
|
|
33
|
+
- No dependency on LLVM, parser generators, PyTorch, TensorFlow, or NumPy.
|
|
34
|
+
- No claim that the tiny GPT reference model is competitive.
|
|
35
|
+
- No hidden tool execution or nondeterministic agent behavior by default.
|