ArcLM
A compact language-model toolkit you can actually read.
ArcLM covers the full local LLM workflow — data → tokenize → train → checkpoint → evaluate → generate → inspect — with a light core install and optional PyTorch for model work.
pip install arclm # ~50 MB: data, tokenizers, agents, security, search
pip install "arclm[train]" # + torch: models, training, inference, evaluation
- Light by default — core has no PyTorch; train only when you need to
- Native-first — tiny GPT-style model in pure PyTorch, no serving stack required
- Educational — small modules, clear APIs, inspectable pipeline traces
- Safe defaults — security helpers, bounded agent runtime, trusted checkpoint loading
Full documentation: docs/guide.md · Migrating from 1.x: docs/migration-1-to-2.md
30-second quickstart
Train a tiny model on a few sentences (requires arclm[train]):
Install the package and run the following in a Python shell:
# run this after `pip install arclm`
pip install "arclm[train]"
then run:
from arclm.configs import create_config
from arclm.training import train_model
config = create_config(embed_dim=32, block_size=16, num_blocks=1, num_epochs=3)
result = train_model(
mode="pre_training",
data="data.txt", # plain text file
output="models/tiny.pth",
config=config,
)
print("final loss:", result.history["train_losses"][-1])
Generate from the checkpoint:
from arclm.inference import load_model
model = load_model("models/tiny.pth")
print(model.predict("the future of", max_new_tokens=20))
Feature tour
Every area in one snippet — details in the guide.
Datasets — load, validate, clean, dedupe
from arclm.datasets import load_dataset, validate_records, deduplicate
records = load_dataset([{"text": "ArcLM loads local records."}])
issues = validate_records(records)
clean, report = deduplicate(records)
Tokenizers — word-level and SentencePiece
from arclm.tokenizers import Tokenizer, AutoTokenizer
tok = Tokenizer(max_vocab=512)
tok.build("arc lm trains tiny models")
ids = tok.encode_text("arc lm")
# or from a config
tok2 = AutoTokenizer.from_config(config) # uses config.tokenizer_type
Models — native ArcLM GPT
from arclm.models import ArcLM, AutoModel
model = ArcLM(vocab_size=512, embed_dim=64, block_size=32, num_blocks=2)
# or
model = AutoModel.from_config(config)
Training — Trainer + callbacks
from arclm.training import Trainer, TrainingConfig
trainer = Trainer(model=model, config=TrainingConfig(epochs=5, batch_size=8))
history = trainer.train_dataset(train_loader, val_loader=val_loader)
Fine-tuning / SFT
from arclm.finetuning import train_sft
result = train_sft(
model="Qwen/Qwen3-0.6B",
dataset="sft.jsonl", # {"messages": [...]} or prompt/completion
output_dir="out/sft",
backend="huggingface",
)
Inference & chat — native + Hugging Face
from arclm.inference import load_model, load_any_model
# Native ArcLM checkpoint
model = load_model("models/tiny.pth")
print(model.predict("the future is", max_new_tokens=20))
# Any Hugging Face model — uses the model's own chat template
hf = load_any_model("Qwen/Qwen3-0.6B", device="cpu")
reply = hf.chat([
{"role": "system", "content": "Be concise."},
{"role": "user", "content": "What is an LLM?"},
])
Checkpoints — safe load, smart adapt
from arclm.checkpoints import SmartLoader, safe_load_training_checkpoint, atomic_save_checkpoint
ckpt = safe_load_training_checkpoint("models/tiny.pth")
plan = SmartLoader("path/to/weights").plan()
Evaluation — metrics + diagnostics
from arclm.evaluation import Evaluator, Accuracy, Perplexity, predict_top_k
report = Evaluator(model, metrics=[Accuracy(), Perplexity()]).evaluate(loader)
top = predict_top_k(model, tokenizer, "machine learning", k=5)
PEFT / LoRA
from arclm.peft import LoRAConfig, apply_lora, merge_lora
apply_lora(model, LoRAConfig(r=8, alpha=16, target_modules=["attn"]))
# ... train ...
merge_lora(model)
Agents — bounded tool-calling runtime
from arclm.agents import Agent, tool
@tool
def add(a: int, b: int) -> int:
"""Add two integers."""
return a + b
agent = Agent(model=my_model_adapter, tools=[add])
result = agent.run("What is 2 + 3?")
Security — encrypt, sign, redact
from arclm.security import encrypt_bytes, decrypt_bytes, redact_text, security_status
blob = encrypt_bytes(b"secret", key=key)
plain = decrypt_bytes(blob, key=key)
print(security_status())
Search & tracking
from arclm.tracking import create_run, set_reproducible_seed
from arclm.search import create_search
set_reproducible_seed(42)
run = create_run(name="baseline", config={...})
search = create_search(space={...}, objective="min_loss")
CLI
arclm train --config config.yaml --data data.txt --output model.pth
arclm eval --model model.pth --data test.txt
arclm generate --model model.pth --prompt "hello"
arclm chat --model Qwen/Qwen2.5-0.5B-Instruct
arclm doctor # runtime diagnostics (no torch needed)
arclm security status
python -m arclm web-api # local Studio backend
Optional extras
| Extra | Adds | Install |
|---|---|---|
train |
PyTorch (models, training, inference) | arclm[train] |
web |
FastAPI Studio + torch | arclm[web] |
hf |
transformers, accelerate, datasets, peft | arclm[hf] |
peft |
torch + peft (LoRA) | arclm[peft] |
qlora |
torch + transformers + bitsandbytes | arclm[qlora] |
security |
cryptography | arclm[security] |
all |
train + web + hf + peft + security | arclm[all] |
CPU-only torch: pip install torch --index-url https://download.pytorch.org/whl/cpu first.
Need only a subset? Install an ArcLM Block —
trimmed editions (core, training, agents, security, …) generated from the same
source. pip install "git+https://github.com/ahmad-al-dibo/arclm.git#subdirectory=distributions/core"
Learn more
| Resource | What |
|---|---|
| docs/guide.md | Complete framework guide — every subpackage with examples |
| docs/migration-1-to-2.md | Upgrading from 1.x |
| docs/agent-runtime.md | Agent runtime deep dive |
| examples/ | Runnable examples, python examples/run_examples.py run-verified |
| lab/ | Hands-on curriculum: build the framework yourself |
| docs/project-status.md | Support matrix |
License
Apache-2.0 · Author: Ahmad Al Dibo
Metadata
Release files for arclm 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| arclm-2.0.0.tar.gz | 378.0 kB | Without provenance | Details for arclm-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| arclm-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for arclm-2.0.0-py3-none-any.whl |
Total release size: 827.0 kB
Release files / arclm-2.0.0.tar.gz
| Download URL | arclm-2.0.0.tar.gz |
|---|---|
| Size | 378.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f1fe0473613e962ee96baa785bf2f930c3401f643edff24560f3a416533a94dd
|
|
BLAKE2b-256 checksum How to use checksums |
96d918c3b57388f343f2f39a8e2362f5c0b3bfc489e58aacc26ea99c72f5af1c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Release files / arclm-2.0.0-py3-none-any.whl
| Download URL | arclm-2.0.0-py3-none-any.whl |
|---|---|
| Size | 449.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
069cc7010e46e3d25b021a50172187eae4ddda467be1a7b447f9e237aa0ec0ba
|
|
BLAKE2b-256 checksum How to use checksums |
670baeb154d3e00ce2a7079d20ae667af4a179588be72e213b855aaa6c14d77a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Security for arclm 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.