Downloads · 30 days
29
7% of all-time downloads
CaaLM/CaaLM-v1
CaaLM-v1 is a text generation model from CaaLM. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
Downloads · 30 days
29
7% of all-time downloads
All-time downloads
420
Public
Parameters
1.5B
3.1 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors3.1 GB · 100%
From the Hugging Face model README

CaaLM (Code as a Language Model) is a 1.5B parameter model that predicts the output of code — without a compiler, runtime, or interpreter.
You give it code. It tells you what it would print.
The interesting part: it was never trained on a fixed set of languages. Instead, it was trained on real languages (Python, JavaScript, Lua, COBOL) alongside 200 synthetically generated fake programming languages — each with randomized syntax but consistent semantics. The goal was to teach the model what execution means, not what any specific language looks like.
This means it can predict the output of languages it has never seen before.


Overall: 96.2% (50/52 tests)
| Category | Accuracy | Passed/Total |
|---|---|---|
| Real: Python | 100% | 10/10 |
| Real: JavaScript | 100% | 8/8 |
| Real: Lua | 100% | 6/6 |
| Real: COBOL | 75% | 3/4 |
| Novel Fake: Tier 1 (assign + print) | 100% | 8/8 |
| Novel Fake: Tier 2 (conditionals) | 86% | 6/7 |
| Novel Fake: Tier 3 (loops) | 100% | 4/4 |
| Edge Cases | 100% | 5/5 |
The novel fake language tests use languages that were never seen during training — completely invented syntax like SCRIBBLE @x BECOMES 7 or WONDER n > 10. The model infers semantics from context and gets them right.
Two failures in the benchmark, both explainable:
08 instead of 0008. Got the value right, missed the PIC 9(4) padding format. Data consistency issue.NO, hallucinating an else branch. Most training data had if/else pairs so it defaulted to that pattern.Input format:
Code:
<your code here>
Output:
The model completes the Output: section with the predicted stdout.
Code:
a = 10
b = 20
print(a + b)
Output:
30
Code:
SCRIBBLE @x BECOMES 7
SCRIBBLE @y BECOMES 3
YELL @x + @y
Output:
10
Code:
BIND n TO 15
WONDER n > 10
SHOUT YES
STOP
Output:
YES
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model = AutoModelForCausalLM.from_pretrained(
"CaaLM/CaaLM-v1",
torch_dtype=torch.bfloat16,
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("CaaLM/CaaLM-v1")
model.eval()
def predict_output(code: str) -> str:
prompt = f"Code:\n{code}\n\nOutput:\n"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=128,
do_sample=False,
pad_token_id=tokenizer.eos_token_id,
)
return tokenizer.decode(
outputs[0][inputs.input_ids.shape[1]:],
skip_special_tokens=True
).strip()
# Real language
print(predict_output("a = 6\nb = 7\nprint(a * b)"))
# → 42
# Novel fake language
print(predict_output("STORE X := 10\nSTORE Y := 5\nSPEAK X + Y"))
# → 15

Training data was split between real and synthetic languages:
Real languages (8,000 examples total, 2,000 each):
Synthetic languages (120,000 examples total):
The spec for each fake language is discarded after data generation. The model only ever sees (code, output) pairs — it never gets a syntax guide.
The model reliably handles:
It does not handle: functions, recursion, file I/O, complex data structures, pipes, or multi-line string manipulation. These may work in real languages due to Qwen's pretraining knowledge but are not guaranteed.
The original motivation was to ask: can a language model learn what execution means as an abstract concept, independent of any specific language's syntax?
The novel fake language results suggest yes, at least for basic programs. The model sees WONDER x > 10 for the first time and figures out it's a conditional. It sees SCRIBBLE @x BECOMES 7 and figures out it's assignment. It doesn't know these keywords — it infers them from the structure of the code and the patterns it learned during training.
Whether this scales to more complex programs, more alien execution models, or larger languages is an open question.
CaaLM-v1 is the first model in the CaaLM series, and a spiritual successor to the LaaLM project.
Apache 2.0 (inherited from Qwen 2.5 base model)