Metadata-Version: 2.4
Name: tensorless
Version: 0.7.0
Summary: ML with maximum automation and minimum setup.
Author: Tensorless Contributors
License: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.24
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Provides-Extra: jax
Requires-Dist: jax>=0.4.30; extra == "jax"
Provides-Extra: cuda
Requires-Dist: jax[cuda12]>=0.4.30; extra == "cuda"
Provides-Extra: tpu
Requires-Dist: jax[tpu]>=0.4.30; extra == "tpu"
Provides-Extra: mps
Requires-Dist: mlx>=0.18; extra == "mps"
Provides-Extra: accelerators
Requires-Dist: jax[cuda12]>=0.4.30; extra == "accelerators"
Requires-Dist: jax[tpu]>=0.4.30; extra == "accelerators"
Requires-Dist: mlx>=0.18; extra == "accelerators"
Dynamic: license-file

# Tensorless

Tensorless trains small custom models with sensible defaults. It uses a native
NumPy engine on CPU and optional JAX or MLX backends for accelerator execution.
It supports
text generation, text classification, tabular classification, and regression.

## Install

```bash
pip install -e .
```

Optional accelerator backends:

```bash
pip install -e '.[cuda]'   # JAX CUDA
pip install -e '.[tpu]'    # JAX TPU
pip install -e '.[mps]'    # Apple Silicon MLX
```

CUDA and TPU backends currently accelerate transformer text tasks. Tabular
tasks and unsupported platforms use the native CPU engine.

## Train on your data

```python
import tensorless as tl

model = tl.train("./corpus.txt", task="text-generation")
print(model.generate("The", max_new_tokens=40))
```

Text files are trained as next-token language models. BPE is the default
tokenizer; use `tokenizer="char"` for a character-level model. Tensorless
derives model size, batch size, epochs, validation, device, and BPE vocabulary
size from the data, while every setting can be overridden.

Long text is tokenized lazily and fed through the native engine in fixed-size batches.
The automatic batch size uses a token budget; reduce `batch_size` if your
available memory is limited.

## English starter pretraining

```python
import tensorless as tl

model = tl.pretrain(out="english.tl", epochs=20, max_seq_len=128)
print(model.generate("A complete sentence", max_new_tokens=30))
```

This offline starter corpus contains English prose and grammar examples. It is
for demos and smoke tests, not a replacement for a large language dataset. For
real pretraining, pass your own `.txt` corpus to `tl.train()` and increase the
training settings as your hardware allows.

## Other tasks

```python
tl.train("reviews/", task="text-classification")
tl.train("housing.csv", task="regression")
```

Tabular preprocessing automatically handles numeric values, ISO dates, and
high-cardinality categories. Missing and rare values are handled using the
fitted training data, and the same preprocessing is stored in the `.tl` file.

Models are saved as `.tl` files and can be loaded later:

```python
model = tl.load("model.tl")
print(model.info())
```

The native extension API is in `tensorless.engine`: `Module`, `Parameter`,
`Adam`, and `SGD` provide model parameters, gradients, and optimization
without a PyTorch dependency. Accelerator cache helpers are available as
`tensorless.devices.clear_memory()` and `tensorless.devices.memory_stats()`.

See the [documentation](docs/quickstart.md) for data formats, configuration,
checkpointing, and the command-line interface.
