Downloads · 30 days
24
26% of all-time downloads
aiexplorations/vidai
vidai is a text generation model from aiexplorations. Use it when you need the model to write or continue text. It is set up for pytorch. The card lists the license as mit.
Work in Progress: This is an early release demonstrating a novel architecture. The model requires more diverse training data to handle complex expressions reliably. We welcome contributions and feedback.
Downloads · 30 days
24
26% of all-time downloads
All-time downloads
91
Public
Repo size
1.1 GB
Likes
0
Public
Click a slice to open those files.
.pt1.1 GB · 100%
From the Hugging Face model README
Work in Progress: This is an early release demonstrating a novel architecture. The model requires more diverse training data to handle complex expressions reliably. We welcome contributions and feedback.
Transformers excel at sequence-to-sequence transformation and pattern recognition. Vidai uses them for exactly that: converting mathematical notation into structured tree representations. We don't ask the model to "learn" arithmetic facts like 7 × 8 = 56 from text tokens alone.
The key insight: Mathematical expressions have inherent tree structure. x^2 + 3*y is not just a sequence of characters; it's a tree where + is the root with x^2 and 3*y as children. Vidai's encoder learns to recognize this structure and output prefix notation (+ ** x 2 * 3 y), which explicitly encodes the tree.
The architecture:
This separation means the transformer does what it's good at (pattern recognition, sequence transformation) while symbolic engines handle what they're good at (exact computation).
Read more: Teaching Machines Arithmetic: The Vidai Journey
Vidai (Tamil for "answer") is a neuro-symbolic system that parses mathematical notation into prefix notation trees, then delegates computation to symbolic engines (SymPy).
| Component | Parameters |
|---|---|
| ContextEncoder | 19M |
| SymbolicParserDecoder | 25M |
| TreeComputeModule | 0 |
import torch
from vidai.model.tree_compute import TreeComputeTransformer, TreeComputeConfig
from vidai.data.tokenizer import ParserTokenizer
# Load model
ckpt = torch.load('parser_v4_best.pt', map_location='cpu', weights_only=False)
config = TreeComputeConfig(**ckpt['config']['model_config'])
model = TreeComputeTransformer(config)
model.load_state_dict(ckpt['model_state_dict'])
model.eval()
# Parse expression
tokenizer = ParserTokenizer()
text = "x^2 + 3*y"
input_ids = torch.tensor([tokenizer.encode_input(text)])
input_mask = (input_ids != 0).bool()
with torch.no_grad():
output_ids = model.parse(input_ids, input_mask, max_len=64)
prefix = tokenizer.decode_output(output_ids[0].tolist())
print(f"{text} -> {prefix}")
# Output: x^2 + 3*y -> + ** x 2 * 3 y
pip install vidai
vidai parse "x^2 + 3*y"
vidai parse "3 + 5 * 2" --eval
vidai parse "x^2 + y" --eval x=3 y=4
Trained on 2M synthetic examples with mixed notation formats:
| Category | Accuracy |
|---|---|
| Basic arithmetic | 100% |
| Parenthesized expressions | 100% |
| Trig functions (sin, cos, tan) | 100% |
| Unicode sqrt | 100% |
| Left associativity | 100% |
| Operator precedence (no parens) | 86% |
| Extended variables (r, c, d, v, g) | 91% |
| Overall on targeted patterns | 90.8% |
For 100% accuracy, always use explicit parentheses around:
(sqrt(16)) + 2 not sqrt(16) + 2(x^2) + y not x^2 + y((a + b)) * (c - d) not a + b * c - dExamples:
| Expression | Reliable? | Recommendation |
|---|---|---|
sqrt(16) + 2^3 | ❌ May fail | (sqrt(16)) + (2^3) |
x^2 - 3*y + pi | ❌ May fail | ((x^2) - (3*y)) + pi |
(sqrt(16)) + (2^3) | ✅ Works | Already parenthesized |
3 + 5 | ✅ Works | Simple expressions are fine |
This model needs more training data. The architecture is sound, but the training dataset lacks diversity.
| What Works | What Doesn't (Yet) |
|---|---|
Simple expressions: 3 + 5 * 2 | Deep nesting: sqrt(sqrt(sqrt(x))) |
Parenthesized: (x^2) + (3*y) | Long polynomials (4+ terms) |
Single functions: sin(x), sqrt(16) | Chained functions: log(exp(sqrt(x))) |
| Basic precedence | Complex precedence without parens |
Known Issues:
sqrt(x) + y may be misparsedThe architecture can handle complex expressions, but needs:
Contributing: If you'd like to help improve Vidai, see our GitHub repository for data generation scripts.
parser_v4_best.pt - Best V4 checkpoint (pre-training)finetune_v1_step3500.pt - Fine-tuned on targeted patternsconfig.json - Model configurationtokenizer.json - Output vocabulary@software{vidai2026,
author = {Sampathkumar, Rajesh},
title = {Vidai: Neural Mathematical Parsing with Deterministic Computation},
year = {2026},
url = {https://github.com/aiexplorations/vidai}
}
MIT License