An interactive domain-specific language (DSL) for defining, training, and evaluating machine learning models with real neural network capabilities.
ModelScript now features a complete interactive development environment with:
- π₯ Interactive REPL: Build and test models in real-time
- π§ Neural Network Training: Actual TensorFlow models, not simulations
- π¬ Text Classification: Language detection and sentiment analysis
- π Live Predictions: Interactive prediction with confidence scores
- π― Multiple Model Types: MNIST, language detection, sentiment analysis
./start-repl.sh
modelscript> load language_classifier
modelscript> predict
Enter text to classify> Bonjour comment allez vous
π― Prediction: French (87% confidence)
Enter text to classify> Hello how are you today
π― Prediction: English (92% confidence)ModelScript/
βββ modelscript/ # Core language engine
βββ examples/ # Model definitions (.ms files)
β βββ language_classifier.ms
β βββ sentiment_classifier.ms
β βββ mnist_classifier.ms
βββ data/ # Training datasets
β βββ language_data.csv
β βββ sentiment_data.csv
βββ generated/ # Generated Python code
βββ scripts/ # Utility scripts
βββ repl.py # Interactive REPL launcher
βββ start-repl.sh # Easy startup script
# Clone and navigate
git clone https://github.com/rsbryan/modelscript.git
cd modelscript
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install dependencies
pip install -r modelscript/requirements.txt./start-repl.shLanguage Detection:
modelscript> load language_classifier
modelscript> predict
# Test with French, Spanish, or English text!Sentiment Analysis:
modelscript> load sentiment_classifier
modelscript> predict
# Test with positive or negative text!View Model Structure:
modelscript> show
modelscript> generate # See generated Python code| Command | Description |
|---|---|
examples |
Show available model examples |
load <model> |
Load a model definition |
show |
Display current model structure |
predict |
π₯ Interactive prediction with neural training |
generate |
Show generated Python code |
run |
Train and execute model |
help |
Show all commands |
quit |
Exit REPL |
1. Language Classifier (language_classifier)
- Detects English, French, Spanish
- Uses LSTM neural network
- Trained on real multilingual data
- Interactive text classification
2. Sentiment Analyzer (sentiment_classifier)
- Positive/negative sentiment detection
- LSTM-based architecture
- Real-time confidence scoring
- Interactive text analysis
3. MNIST Classifier (mnist_classifier)
- Handwritten digit recognition
- Dense neural network
- Standard computer vision benchmark
python3 modelscript/modelscript.py examples/language_classifier.ms -o my_model.pypython3 modelscript/modelscript.py examples/sentiment_classifier.ms --runmodel MyModel {
dataset {
source: "language" // Built-in: "mnist", "language", "sentiment"
max_sequence_length: 100
vocab_size: 10000
num_classes: 3
}
architecture {
layer Embedding {
input_dim: 10000
output_dim: 128
input_length: 100
}
layer LSTM {
units: 64
}
layer Dense {
units: 3
activation: "softmax"
}
}
training {
batch_size: 32
epochs: 5
optimizer: "adam"
loss: "sparse_categorical_crossentropy"
metrics: ["accuracy"]
}
}| Dataset | Description | Use Case |
|---|---|---|
"mnist" |
Handwritten digits | Image classification |
"language" |
Multilingual text samples | Language detection |
"sentiment" |
Positive/negative text | Sentiment analysis |
"custom" |
Your own data | Custom classification |
- Text Processing:
Embedding,LSTM,Bidirectional - Core Layers:
Dense,Dropout,Flatten - CNN Layers:
Conv2D,MaxPooling2D - Activation:
"relu","softmax","sigmoid"
- Actual TensorFlow Models: Not simulations - real neural networks
- Live Data Processing: Tokenization, preprocessing, training
- Model Persistence: Trained models saved for reuse
- Confidence Scoring: Prediction probabilities
- Fallback Systems: Rule-based backup if training fails
Language Detection (data/language_data.csv):
- 30 text samples in English, French, Spanish
- Labeled for supervised learning
- Preprocessed automatically
Sentiment Analysis (data/sentiment_data.csv):
- 30 positive and negative text samples
- Binary classification dataset
- Real-world sentiment examples
python3 integration_test.pyExpected output:
π ModelScript Integration Test
π Results: 5/5 tests passed
π All tests passed! ModelScript upgrade successful!
# Test basic functionality
python3 test_interactive.py
# Test model parsing
python3 modelscript/modelscript/modelscript.py examples/language_classifier.ms- Create a
.msfile inexamples/ - Add training data to
data/(if needed) - Test with
load <your_model>in REPL
Add new dataset support in modelscript/modelscript.py:
- Update
generate_python_code()function - Add data loading logic
- Update REPL prediction methods
modelscript> load language_classifier
modelscript> predict
Enter text to classify> Hola como estas
π― Prediction: Spanish (78% confidence)
Enter text to classify> Je suis très heureux
π― Prediction: French (91% confidence)modelscript> load sentiment_classifier
modelscript> predict
Enter text to analyze> This movie is absolutely amazing!
π― Prediction: π Positive (94% confidence)
Enter text to analyze> This is the worst experience ever
π― Prediction: π Negative (89% confidence)Replace data files with your own:
data/language_data.csv- For language modelsdata/sentiment_data.csv- For sentiment models
Format: text,label with proper headers
View the generated TensorFlow code:
modelscript> generateThis shows the actual Python/TensorFlow code that ModelScript creates from your .ms definition.
# Recreate virtual environment
rm -rf venv
python3 -m venv venv
source venv/bin/activate
pip install -r modelscript/requirements.txtchmod +x start-repl.shEnsure you're in the correct directory and virtual environment is activated.
MIT License - see LICENSE file for details.
This is now a complete interactive ML development platform that:
β
Parses declarative model definitions
β
Generates executable TensorFlow/Keras code
β
Trains real neural networks interactively
β
Provides live text classification with confidence
β
Supports multiple model types and datasets
β
Includes comprehensive examples and testing
From simple DSL to production-ready interactive ML environment!