Research Project | Maturaarbeit

Neural Predictive Calculator

Evaluating the Arithmetic Capabilities of Neural Networks

An in-depth investigation into why neural networks struggle with simple arithmetic expressions. This project builds and evaluates various neural network architecturesโ€”including FNNs, RNNs, attention-based RNNs, and Transformersโ€”to assess their performance on arithmetic tasks.

5+
Architectures
3
GitHub Stars
Open Source
Research

About the Project

Understanding Neural Networks' Arithmetic Limitations

๐ŸŽฏ

Research Goal

Investigate why neural networks often struggle with simple arithmetic expressions and evaluate the capabilities of different architectures.

๐Ÿ”ฌ

Methodology

Build and test various neural network models on arithmetic problems, comparing their performance and understanding their limitations.

๐Ÿ“Š

Scientific Approach

Comprehensive evaluation with statistical analysis, p-values, and detailed findings documented in research papers.

Neural Network Architectures

Exploring Different Approaches to Arithmetic Tasks

๐Ÿ“ก

Feed-Forward Neural Networks

Best Performance

Basic neural network architecture with multiple layers. FNN2 demonstrated the best performance among all tested models.

  • โœ“ FNN1: Initial implementation
  • โœ“ FNN2: Optimized version (best model)
  • โœ“ Simple and efficient architecture
Key Files: FNN1.ipynb, FNN2.ipynb, NPC-final.py
๐Ÿ”„

Recurrent Neural Networks

Sequential Processing

Networks with loops that allow information persistence, suitable for sequence-based arithmetic operations.

  • โœ“ RNN0: Basic implementation
  • โœ“ RNN2: Enhanced version
  • โœ“ Handles sequential data effectively
Key Files: RNN0.ipynb, RNN2.ipynb
๐Ÿ‘๏ธ

Attentional RNN

With Attention

LSTM-based RNN with attention mechanism to focus on relevant parts of the input sequence.

  • โœ“ LSTM architecture
  • โœ“ Attention mechanism
  • โœ“ Enhanced context awareness
Key Files: g4gLSTM.ipynb
โšก

Transformer Architecture

State-of-the-art

Modern transformer architecture with self-attention mechanisms for parallel processing.

  • โœ“ Multiple iterations (0, 4, 5)
  • โœ“ Self-attention mechanisms
  • โœ“ Parallel processing capabilities
Key Files: transformer0.ipynb, transformer4.ipynb, transformer5.ipynb
๐Ÿš€

Pre-trained Transformers

Fine-tuned

Fine-tuned pre-trained models including Gemma (270M & 1B parameters) and Gemini via Vertex AI.

  • โœ“ Gemma 270M (Hugging Face)
  • โœ“ Gemma 1B (Hugging Face)
  • โœ“ Gemini (Vertex AI)
Key Files: gemma_huggingface.ipynb, big_gemma_huggingface.ipynb, gemini_vertex.ipynb

Try It Yourself

Experience the Neural Predictive Calculator

๐Ÿ’ป

Live Interactive Calculator

Try the FNN2 model right here! Enter an arithmetic expression and see how the neural network computes it.

Or Run Locally

Download and run the model on your own machine:

Terminal
# Install dependencies
pip install -r requirements.txt

# Run the demo
python FNN/NPC-final.py
View Demo Script

๐Ÿ“ฆ Installation

All required Python packages are listed in requirements.txt. The models will run on CPU.

๐ŸŽฎ Usage

The demonstration script allows you to input arithmetic expressions and see how the neural network computes the results.

โš™๏ธ GPU Support

If you have an NVIDIA Jetson device, use requirements_GPU.txt for GPU-accelerated inference.

Documentation

Comprehensive Research Materials

๐Ÿ“Œ Post-Submission Updates: A new branch with minor adjustments, MIT license, and documentation corrections is available at github.com/AntonStantan/matura/tree/post-submission

Repository Structure

Organized and well-documented codebase

๐Ÿ“ FNN/
Feed-Forward Neural Networks implementation
๐Ÿ“ RNN/
Recurrent Neural Networks implementation
๐Ÿ“ attentional-RNN/
RNNs with attention mechanisms
๐Ÿ“ transformer/
Transformer-based models
๐Ÿ“ pre-trained-transformers/
Fine-tuned pre-trained models
๐Ÿ“ documentation/
Research documentation and findings
๐Ÿ“„ GetXY.py
Dataset generation script
๐Ÿ“„ get_p-value.py
Statistical analysis script
๐Ÿ“„ requirements.txt
Python dependencies