|
1 | | -[](LICENSE) |
| 1 | +[](LICENCE) |
2 | 2 | [](https://central.sonatype.com/artifact/sk.ainet.core/skainet-lang-core) |
3 | 3 |
|
4 | 4 | # SKaiNET |
5 | 5 |
|
6 | | -**SKaiNET** is an open-source deep learning framework written in Kotlin, designed with developers in mind to enable the creation modern AI powered applications with ease. |
| 6 | +**SKaiNET** is an open-source deep learning framework written in Kotlin Mutliplatform, designed with developers in mind to enable the creation modern AI powered applications with ease. |
7 | 7 |
|
8 | | -## Quick example: training/eval phases with context wrappers |
| 8 | +## Use it |
9 | 9 |
|
10 | | -SKaiNET provides small helper scopes to override the execution phase for a given call without mutating your base context: |
| 10 | +- From Kotlin code in apps, libraries, CLIs |
| 11 | +- In Kotlin Notebooks for quick exploration |
| 12 | +- With sample projects to learn patterns |
11 | 13 |
|
12 | | -- train(ctx) { ... } — runs the block with phase = TRAIN |
13 | | -- eval(ctx) { ... } — runs the block with phase = EVAL |
| 14 | +See also CHANGELOG for what’s new in 0.2.0. |
14 | 15 |
|
15 | | -This is useful for modules that behave differently in training vs evaluation (e.g., Dropout, BatchNorm). |
| 16 | +## Quick start |
16 | 17 |
|
17 | | -Kotlin |
| 18 | +Gradle (Kotlin DSL): |
18 | 19 |
|
19 | | -import sk.ainet.context.train |
20 | | -import sk.ainet.context.eval |
21 | | -import sk.ainet.lang.nn.DefaultNeuralNetworkExecutionContext |
22 | | -// import your model class that defines forward(x, ctx) |
23 | | - |
24 | | -val base = DefaultNeuralNetworkExecutionContext() // default phase is EVAL |
25 | | -val x = /* prepare your input tensor */ |
26 | | -val model = /* construct your model */ |
27 | | - |
28 | | -// Force TRAIN phase for this call only |
29 | | -val yTrain = train(base) { ctx -> |
30 | | - model.forward(x, ctx) |
| 20 | +```kotlin |
| 21 | +dependencyResolutionManagement { |
| 22 | + repositories { |
| 23 | + mavenCentral() |
| 24 | + } |
31 | 25 | } |
32 | 26 |
|
33 | | -// Force EVAL phase for this call only |
34 | | -val yEval = eval(base) { ctx -> |
35 | | - model.forward(x, ctx) |
| 27 | +dependencies { |
| 28 | + // minimal dependency with simple CPU backend |
| 29 | + implementation("sk.ainet.core:skainet-lang-core:0.2.0") |
| 30 | + implementation("sk.ainet.core:skainet-backend-cpu:0.2.0") |
| 31 | + |
| 32 | + // simple model zoo |
| 33 | + implementation("sk.ainet.core:skainet-lang-models:0.2.0") |
| 34 | + |
| 35 | + // Optional I/O (e.g., GGUF loader, JSON) |
| 36 | + implementation("sk.ainet.core:skainet-io-core:0.2.0") |
| 37 | + implementation("sk.ainet.core:skainet-io-gguf:0.2.0") |
36 | 38 | } |
| 39 | +``` |
37 | 40 |
|
38 | | -// You can still call with the base context directly (uses its phase) |
39 | | -val yBase = model.forward(x, base) |
| 41 | +Maven: |
40 | 42 |
|
41 | | -## Development Practices |
| 43 | +```xml |
| 44 | +<dependency> |
| 45 | + <groupId>sk.ainet.core</groupId> |
| 46 | + <artifactId>skainet-lang-core</artifactId> |
| 47 | + <version>0.2.0</version> |
| 48 | +</dependency> |
| 49 | +``` |
42 | 50 |
|
43 | | -This project follows established development practices for maintaining code quality and release management: |
| 51 | +## Samples and notebooks |
44 | 52 |
|
45 | | -* **Branching Model**: We use [GitFlow](https://nvie.com/posts/a-successful-git-branching-model/) as our branching strategy for managing feature development, releases, and hotfixes. |
46 | | -* **Versioning**: We follow [Semantic Versioning (SemVer)](https://semver.org/) for all releases, ensuring predictable version numbering based on the nature of changes. |
| 53 | +- Sample app: https://github.com/sk-ai-net/skainet-samples/tree/feature/MNIST/SinusApproximator |
| 54 | +- Kotlin Notebook: https://github.com/sk-ai-net/skainet-notebook |
47 | 55 |
|
48 | | -## Reflective Documentation (short overview) |
49 | 56 |
|
50 | | -SKaiNET includes a reflective documentation system that keeps docs in sync with the code. During the build, a KSP processor extracts operator metadata (signatures, parameters, backend availability, implementation status) into a JSON file. A small DocGen tool then converts this JSON into AsciiDoc fragments and pages. |
| 57 | +## 0.2.0 highlights (with tiny snippets) |
51 | 58 |
|
52 | | -- Source of truth (generated): skainet-lang/skainet-lang-core/build/generated/ksp/metadata/commonMain/resources/operators.json |
53 | | -- Generated docs output: docs/modules/operators/_generated_/ |
54 | | -- Asciidoctor site output: build/docs/asciidoc/ (if you run an Asciidoctor task locally) |
| 59 | +- Training/Eval phases made easy |
55 | 60 |
|
56 | | -### Quick start: generate reflective docs |
| 61 | +```kotlin |
| 62 | +val base = DefaultNeuralNetworkExecutionContext() // default = EVAL |
| 63 | +val yTrain = train(base) { ctx -> model.forward(x, ctx) } |
| 64 | +val yEval = eval(base) { ctx -> model.forward(x, ctx) } |
| 65 | +``` |
57 | 66 |
|
58 | | -Use any of the following Gradle tasks from the project root: |
| 67 | +- Dropout and BatchNorm layers |
59 | 68 |
|
60 | | -1) Full pipeline (recommended) |
61 | | - ./gradlew generateDocs |
62 | | - - Runs KSP to produce operators.json (if needed) |
63 | | - - Generates AsciiDoc files under docs/modules/operators/_generated_ |
64 | | - - Optionally, you can run an Asciidoctor task to build an HTML site locally (output under build/docs/asciidoc) |
| 69 | +```kotlin |
| 70 | +val y = x |
| 71 | + .let { dropout(p = 0.1).forward(it, ctx) } |
| 72 | + .let { batchNorm(numFeatures = 64).forward(it, ctx) } |
| 73 | +``` |
65 | 74 |
|
66 | | -2) Operators documentation only |
67 | | - ./gradlew generateOperatorDocs |
68 | | - - Depends on KSP; runs the built-in generateDocs task and then Asciidoctor |
| 75 | +- Conv2D + MaxPool in the NN DSL |
| 76 | + |
| 77 | +```kotlin |
| 78 | +val model = nn { |
| 79 | + conv2d(outChannels = 16, kernel = 3) |
| 80 | + maxPool2d(kernel = 2) |
| 81 | + dense(out = 10) |
| 82 | +} |
| 83 | +``` |
69 | 84 |
|
70 | | -Open the generated AsciiDoc sources in docs/modules/operators/_generated_ with your preferred AsciiDoc viewer. If you build an HTML site locally with Asciidoctor, open build/docs/asciidoc. |
| 85 | +- Data API with MNIST loader and JSON dataset support |
71 | 86 |
|
72 | | -### Documentation tooling |
| 87 | +```kotlin |
| 88 | +val ds = MNIST.load(train = true) // platform-aware loader |
| 89 | +val (batchX, batchY) = ds.nextBatch(64) |
| 90 | +``` |
73 | 91 |
|
74 | | -We now use the Gradle plugin (buildSrc) only. The former skainet-lang-export-ops module has been removed. All everyday workflows are covered by: |
75 | | -- generateDocs — converts KSP JSON to AsciiDoc |
76 | | -- validateOperatorSchema — validates generated operators.json against the JSON schema |
| 92 | +- GGUF model loading (initial) |
77 | 93 |
|
78 | | -Run from the project root, for example: |
79 | | -- ./gradlew generateDocs |
80 | | -- ./gradlew validateOperatorSchema |
| 94 | +```kotlin |
| 95 | +val gguf = GGUF.read("/path/to/model.gguf") |
| 96 | +println("Tensors: ${gguf.tensors.size}") |
| 97 | +``` |
81 | 98 |
|
82 | | ---- |
| 99 | +- SIMD/Vector API acceleration on JVM; MatMul, tril, pooling ops; forward hooks and simple tape recording; unified tensor creation contexts; nested data blocks returning tensors. |
83 | 100 |
|
84 | | -## Development Practices |
| 101 | +See CHANGELOG.md for the full list. |
85 | 102 |
|
86 | | -This project follows established development practices for maintaining code quality and release management: |
| 103 | +## License |
87 | 104 |
|
88 | | -* Branching Model: We use GitFlow as our branching strategy for managing feature development, releases, and hotfixes. |
89 | | -* Versioning: We follow Semantic Versioning (SemVer) for all releases, ensuring predictable version numbering based on the nature of changes. |
| 105 | +MIT — see LICENSE. |
0 commit comments