Neuva — A working ML programming language with lexer, parser, AST and interpreter
Project description
███╗ ██╗███████╗██╗ ██╗██╗ ██╗ █████╗ ████╗ ██║██╔════╝██║ ██║██║ ██║██╔══██╗ ██╔██╗ ██║█████╗ ██║ ██║██║ ██║███████║ ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██╔══██║ ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝
A programming language built purely for Machine Learning.
Simple like Python. Clear like Rust. Made for ML.
What is Neuva?
Neuva (NOO-vah) is an open source programming language designed from the ground up for Machine Learning. No boilerplate. No imports. No configuration. Just describe your model and train it.
# Train a digit classifier — the entire program
let data = load("examples/data/iris.csv")
let train_data, test_data = data.split(0.8)
model DigitNet {
layer dense(4 -> 16, relu)
layer dense(16 -> 3, softmax)
}
train DigitNet on train_data for 20 epochs, lr = 0.001, loss = crossentropy
print "Accuracy:", accuracy(DigitNet, test_data)
That is it. No import torch. No nn.Module. No training loop. Neuva handles it all.
What's New in v1.0.0
Neuva started as a single .lark grammar file and a stub interpreter. Over 34 days of public development — one commit per day — it grew into a complete ML language with a real PyTorch backend.
The journey in short:
- Days 5–9: grammar, parser, and first AST tests
- Days 10–11: working interpreter; Neuva ran its first program
- Days 12–17: real PyTorch backend; neural networks actually trained
- Days 20–21: real CSV data loading, train/test splits, 93% accuracy on Iris
- Days 22–25: VS Code extension, documentation, Rust-style error messages
- Days 27–30:
else ifchains, string concatenation,--versionflag - Days 31–33: interactive REPL, GPU detection, mini-batch training
- Day 34: f-strings, lists,
and/or, dropout layers, model summary printing - v1.0.0: 54 tests, 13 runnable examples, stable release
Why Neuva?
Most ML code looks like this:
import torch
import torch.nn as nn
import torch.optim as optim
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.fc1 = nn.Linear(784, 128)
self.fc2 = nn.Linear(128, 10)
def forward(self, x):
x = torch.relu(self.fc1(x))
return torch.softmax(self.fc2(x), dim=1)
model = Net()
optimizer = optim.Adam(model.parameters(), lr=0.001)
criterion = nn.CrossEntropyLoss()
for epoch in range(20):
for batch_x, batch_y in train_loader:
optimizer.zero_grad()
output = model(batch_x)
loss = criterion(output, batch_y)
loss.backward()
optimizer.step()
Neuva code looks like this:
model DigitNet {
layer dense(784 -> 128, relu)
layer dense(128 -> 10, softmax)
}
train DigitNet on train_data for 20 epochs, lr = 0.001
Same result. A fraction of the code.
Features
- ML-first keywords —
model,layer,train,predict,saveare built into the language - No boilerplate — no imports, no class definitions, no training loops
- PyTorch backend — compiles to PyTorch under the hood, fast and compatible
- GPU support — automatically detects and uses CUDA if available
- Mini-batch training — shuffled batches each epoch, averaged loss reporting
- F-string interpolation —
print "Accuracy: {acc}%"substitutes variables inline - List support —
let scores = [85, 90, 78],scores[0],len(scores) - Boolean logic —
and/orwith short-circuit evaluation - Dropout layers —
layer dropout(0.3)maps directly tonn.Dropout - Model summary —
print MyModelshows layers and total parameter count - Interactive REPL —
neuva shellfor live exploration with persistent state - Rust-style errors — line numbers, column pointers, did-you-mean suggestions
- Simple types —
tensor,matrix,int,float,bool,string - Open source — AGPL v3 licensed, built in public, contributions welcome
Install
pip install neuva-lang
Run a .nva file:
neuva my_model.nva
Start the interactive shell:
neuva shell
Check the version:
neuva --version
Language Overview
Variables
let name = "Neuva" # string (inferred)
let layers = 3 # int (inferred)
let rate: float = 0.001 # float (explicit)
let ready: bool = true # bool (explicit)
F-String Interpolation
let acc = 93
print "Accuracy: {acc}%" # prints: Accuracy: 93%
let model_name = "DigitNet"
print "Training {model_name}..."
Lists
let scores = [85, 90, 78, 92]
print scores[0] # 85
let n = len(scores) # 4
Boolean Logic
if score > 50 and score < 100 {
print "valid score"
}
if passed or bonus {
print "you qualify"
}
Models
model MyNet {
layer dense(784 -> 128, relu)
layer dropout(0.3)
layer dense(128 -> 10, softmax)
}
print MyNet # prints layer summary and parameter count
Supported layer types: dense, conv, pool, dropout, flatten
Supported activations: relu, sigmoid, softmax, tanh, linear
Loading Data
let data = load("examples/data/iris.csv")
let train_data, test_data = data.split(0.8) # 80/20 split
data = data.normalize() # normalize values
data = data.shuffle() # shuffle rows
Training
# one-liner
train MyNet on train_data for 10 epochs, lr = 0.001
# multi-line (more readable)
train MyNet
on train_data
for 50 epochs
lr = 0.0005
loss = crossentropy
Supported loss functions: crossentropy, mse, mae, binary_crossentropy
Predict and Evaluate
let acc = accuracy(MyNet, test_data)
print "Accuracy: {acc}"
Save and Load
save MyNet to "my_model.nva"
let loaded = load("my_model.nva")
Functions
fn welcome(name: string) {
print "Hello from Neuva, {name}"
}
fn square(x: float) -> float {
return x * x
}
Control Flow
if acc > 0.95 {
print "Excellent model!"
} else if acc > 0.80 {
print "Good model."
} else {
print "Keep training."
}
for i in range(10) {
print "Epoch {i}"
}
let count = 0
while count < 5 {
let count = count + 1
}
Interactive REPL
$ neuva shell
Neuva 1.0.0 — interactive shell. Type 'exit' to quit.
>>> let x = 42
>>> print "The answer is {x}"
The answer is 42
>>> exit
Examples
| File | Description |
|---|---|
examples/hello.nva |
Hello world |
examples/digit_classifier.nva |
Iris classification, 93% accuracy |
examples/linear_regression.nva |
House price regression |
examples/spam_classifier.nva |
Binary spam detection |
examples/house_price.nva |
Multi-layer regression |
examples/cnn_classifier.nva |
CNN layer definitions |
examples/control_flow_demo.nva |
if, for, while, functions |
examples/elif_demo.nva |
Chained else if |
examples/fstring_demo.nva |
F-string interpolation |
examples/list_demo.nva |
Lists and indexing |
examples/logical_demo.nva |
and / or operators |
examples/dropout_demo.nva |
Dropout layer and model summary |
examples/string_concat_demo.nva |
String concatenation |
Project Status
| Phase | Status | Description |
|---|---|---|
| 1 — Design | ✅ Done | Language syntax and keywords |
| 2 — GitHub Setup | ✅ Done | Repo, license, structure |
| 3 — Lexer | ✅ Done | Tokenizer with full terminal set |
| 4 — Parser | ✅ Done | Lark Earley parser, full AST |
| 5 — Interpreter | ✅ Done | Tree-walking interpreter, 54 tests |
| 6 — PyTorch backend | ✅ Done | Mini-batch training, GPU support |
| 7 — PyPI release | ✅ Done | pip install neuva-lang |
Documentation
| Document | Description |
|---|---|
| Getting Started | Install, hello world, running .nva files |
| Language Reference | Every keyword with syntax and examples |
| Examples | Line-by-line walkthrough of the iris classifier |
| Changelog | Full version history |
| Roadmap | What's planned post-1.0 |
Contributing
Neuva is open source and we welcome all contributors — beginners and experts alike.
git clone https://github.com/Ankit-Mahadani/neuva.git
cd neuva
pip install -e ".[dev]"
pytest tests/
See CONTRIBUTING.md for the full guide.
Look for issues labelled good first issue to get started: github.com/Ankit-Mahadani/neuva/issues
Built With
- Python 3.10+ — the interpreter is written in Python
- PyTorch ≥ 2.0 — ML execution backend
- Lark ≥ 1.1 — grammar and parser
- NumPy + Pandas — data loading and preprocessing
License
This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).
This means:
- You can use, study, modify, and distribute Neuva freely
- If you use Neuva in a product or service (including over a network), you must release your source code under the same license
- Any modifications must also be open source
See the full LICENSE file for details.
Copyright © 2026 Ankit Mahadani and Neuva Contributors
Built in public. Day by day. v1.0.0.
Star the repo to follow the journey.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file neuva_lang-1.0.0.tar.gz.
File metadata
- Download URL: neuva_lang-1.0.0.tar.gz
- Upload date:
- Size: 63.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
757c1d9ddf3874bd2ca524468d5064a644c84b76a459763922f0b63b95f21b30
|
|
| MD5 |
da1957b760f47a3663e3fbc123e8838e
|
|
| BLAKE2b-256 |
986d848ef21411d0b0442ed4fbaa6ee2050acb7d106ba605d2d02e549ef4e6f6
|
File details
Details for the file neuva_lang-1.0.0-py3-none-any.whl.
File metadata
- Download URL: neuva_lang-1.0.0-py3-none-any.whl
- Upload date:
- Size: 47.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b01186667c960b0a9fe3f7151928f313ffe73b9c7e64c5ef2a806934ffa73d4
|
|
| MD5 |
f87919f8a3e0223ea8866f702e6eb40e
|
|
| BLAKE2b-256 |
4c2ebcd7bf93bc1e19aa64356dc95e84d510d5088572d243e2caa19a145520b3
|