Skip to content
Open source · Local-first

A spaCy alternative for custom NLP functions

Describe your task in plain English. Compile it into a reusable Python function that runs locally.

No account required.

pip install programasweights
entities.py
import programasweights as paw

fn = paw.compile_and_load(
    "Extract named people, organizations, and locations. "
    "Return JSON with keys PERSON, ORG, and LOC "
    "containing lists of exact text spans or []."
)

fn("Maya Patel works at Microsoft in Seattle.")
# {"PERSON":["Maya Patel"],"ORG":["Microsoft"],"LOC":["Seattle"]}

Define your own entity types

Choose the entities and JSON structure your application needs.

Specification

Extract software products and their versions as JSON objects with "product" and "version" keys in a list. Use exact text. Skip products without a version. Return [] if there are no matches.

Input

PostgreSQL 16.4 is running on server 3.

Output

[{"product": "PostgreSQL", "version": "16.4"}]

Built with ProgramAsWeights

Community program · Finetuned Standard

Translate text into English

Translate into English while preserving names, numbers, and technical terms.

Input

El modelo AX-42 cuesta 79 euros y funciona con Wi-Fi 6.

Output

The AX-42 model costs €79 and works with Wi-Fi 6.
Community program · Finetuned Standard

Decide when text needs translation

Classify text as english or translate using your own language rules.

Input

Wave twice, luego gira a la derecha.

Output

translate

Custom translation: English ↔ Claudish

Translate between plain English and over-engineered prose.

Input

Only owners can merge.

Output

Merge is owner-gated; only owners can land.

More NLP demos

Improve task accuracy with finetuning

Start with Standard for fast compilation. Finetuned Standard generates training examples from your specification and trains your program automatically. No labeled dataset required. Run the result locally with the same small interpreter.

Add compiler="paw-ft-bs48" to your paw.compile_and_load(...) call.

Try Finetuned Standard

ProgramAsWeights vs. spaCy

Define a task

spaCy
Compose an NLP pipeline from pretrained, rule-based, or custom components.
ProgramAsWeights
Describe behavior and output in English, then compile it into reusable weights.

Customize

spaCy
Add rules, train components, or use prompts with spacy-llm.
ProgramAsWeights
Edit your specification and recompile. Use Finetuned Standard to train automatically.

Output

spaCy
A Doc containing tokens, spans, and annotations.
ProgramAsWeights
Text in the format you specify: labels, JSON, extracted values, or rewritten passages.

Run

spaCy
Run pipelines locally. spacy-llm supports local models and hosted model APIs.
ProgramAsWeights
Run the compiled function locally, or use hosted inference.

Frequently asked questions

Do I need a GPU?

No. Standard programs run locally on a CPU. The Python SDK also supports GPU acceleration.

Can I run NLP offline?

Yes. Download the program and interpreter once, then use offline=True to load them from cache and run locally.

Can I use hosted inference instead?

Yes. Run the same program through the Python SDK or HTTP API without downloading a model. Choose local or hosted inference to suit your application.

Do I need to compile every document?

No. Compile your task once, then call the same function on new inputs. Save the program ID to load it again in another session.

Can I use ProgramAsWeights alongside spaCy?

Yes. Use spaCy for tokenization and linguistic annotations, and call PAW functions for custom classification, extraction, or rewriting.

Can I run a program in the browser?

Yes. Choose the Compact compiler and use the JavaScript SDK to run the program locally in the browser through WebAssembly.

Build your own NLP function

Describe your task, compile it once, and run it locally.