Skip to content

NeuralBlitz/Goainglys

Repository files navigation

image

Native Go ML Projects Collection

A comprehensive collection of machine learning and deep learning implementations written in pure Go with no external dependencies.

πŸš€ Projects Overview

Project Description Status
Transformer Complete Transformer architecture (Vaswani et al., 2017) βœ… Complete
Vector Database HNSW-based vector similarity search βœ… Complete
ASR Library Automatic Speech Recognition with MFCC & LSTM βœ… Complete
RAG Evaluation Comprehensive RAG/LLM evaluation toolkit βœ… Complete
Training Dashboard Real-time ML training metrics visualization βœ… Complete
Model Registry Model versioning and management system βœ… Complete
Agents Framework AI agent framework with native transformers βœ… Complete
Fine-tuning Neural network fine-tuning with LoRA support βœ… Complete
GPT/BERT Native Go GPT and BERT transformer models βœ… Complete
MCP Marketplace MCP apps marketplace with REST API and web UI βœ… Complete
LRS-Agents-NBX Learning Rate Scheduler agents with NBX integration βœ… Complete

πŸ“ Project Structure

/workspace/
β”œβ”€β”€ tensor/              # Core tensor operations library
β”‚   β”œβ”€β”€ tensor.go       # Tensor data structure
β”‚   └── ops.go          # Mathematical operations
β”œβ”€β”€ transformer/         # Transformer architecture implementation
β”‚   β”œβ”€β”€ layer.go        # Multi-head attention, FFN, positional encoding
β”‚   β”œβ”€β”€ model.go        # Encoder/Decoder, embeddings, full model
β”‚   β”œβ”€β”€ backward.go     # Backpropagation through layers
β”‚   └── train.go        # Training utilities
β”œβ”€β”€ vector_db/          # Native vector database
β”‚   β”œβ”€β”€ main.go         # VectorDB with CRUD operations
β”‚   β”œβ”€β”€ hnsw.go         # HNSW index for ANN search
β”‚   β”œβ”€β”€ types.go        # Type definitions
β”‚   └── README.md       # Documentation
β”œβ”€β”€ asr/                # Automatic Speech Recognition
β”‚   β”œβ”€β”€ audio.go        # Audio loading & preprocessing
β”‚   β”œβ”€β”€ features.go     # MFCC feature extraction
β”‚   β”œβ”€β”€ model.go        # LSTM acoustic model
β”‚   β”œβ”€β”€ pipeline.go     # End-to-end ASR pipeline
β”‚   β”œβ”€β”€ README.md       # Documentation
β”‚   └── cmd/main.go     # Demo application
β”œβ”€β”€ rag_eval/           # RAG/LLM Evaluation Toolkit
β”‚   β”œβ”€β”€ main.go         # Evaluation metrics & pipeline
β”‚   β”œβ”€β”€ rag_evaluation.json  # JSON export
β”‚   └── README.md       # Documentation
β”œβ”€β”€ dashboard/          # Training Dashboard
β”‚   β”œβ”€β”€ main.go         # HTTP server & UI
β”‚   └── README.md       # Documentation
β”œβ”€β”€ model_registry/     # Model Registry
β”‚   β”œβ”€β”€ main.go        # HTTP server
β”‚   β”œβ”€β”€ registry.go    # Core registry logic
β”‚   β”œβ”€β”€ server.go      # API endpoints
β”‚   β”œβ”€β”€ index.html     # Web UI
β”‚   └── README.md      # Documentation
β”œβ”€β”€ agents/            # Agents Framework
β”‚   β”œβ”€β”€ framework/    # Core framework
β”‚   β”‚   β”œβ”€β”€ core/     # Core types
β”‚   β”‚   β”œβ”€β”€ agents/   # Agent implementations
β”‚   β”‚   β”œβ”€β”€ testing/  # Testing utilities
β”‚   β”‚   └── main.go  # Demo
β”‚   └── README.md     # Documentation
β”œβ”€β”€ finetune/         # Fine-tuning Architecture
β”‚   β”œβ”€β”€ config/      # Configuration
β”‚   β”œβ”€β”€ data/        # Dataset and DataLoader
β”‚   β”œβ”€β”€ models/      # Neural network layers
β”‚   β”œβ”€β”€ losses/      # Loss functions
β”‚   β”œβ”€β”€ optimizers/  # AdamW, SGD, Lion, etc.
β”‚   β”œβ”€β”€ training/    # Training loop
β”‚   β”œβ”€β”€ main.go      # Demo
β”‚   └── README.md    # Documentation
β”œβ”€β”€ transformers/    # GPT/BERT Transformers
β”‚   β”œβ”€β”€ core/       # Tensor operations
β”‚   β”œβ”€β”€ gpt/        # GPT model
β”‚   β”œβ”€β”€ bert/       # BERT model
β”‚   β”œβ”€β”€ tokenizer/   # Tokenizers
β”‚   β”œβ”€β”€ training/   # Training utilities
β”‚   β”œβ”€β”€ main.go     # Demo
β”‚   └── README.md   # Documentation
β”œβ”€β”€ marketplace/    # MCP Apps Marketplace
β”‚   β”œβ”€β”€ api/       # REST API server
β”‚   β”œβ”€β”€ apps/      # App registry and models
β”‚   β”œβ”€β”€ mcp/       # MCP protocol implementation
β”‚   β”œβ”€β”€ web/       # Web UI
β”‚   β”œβ”€β”€ main.go    # Entry point
β”‚   └── README.md  # Documentation
β”œβ”€β”€ main.go             # Transformer demo
β”œβ”€β”€ go.mod              # Go module definition
└── README.md           # This file

πŸ“ˆ 5. Training Dashboard

Directory: dashboard/

Real-time ML training metrics visualization with SVG charts.

Features

  • βœ… Real-time metrics (loss, accuracy, learning rate)
  • βœ… SVG-based charts (server-side rendered)
  • βœ… Dark-themed web interface
  • βœ… Auto-refresh every 2 seconds

Quick Start

cd dashboard && go run main.go
# Open http://localhost:8080

πŸ“¦ 6. Model Registry

Directory: model_registry/

Native Go model registry and versioning system for ML models.

Features

  • βœ… Model versioning with stages (REGISTERED β†’ STAGING β†’ PRODUCTION β†’ ARCHIVED)
  • βœ… Metrics and parameters tracking
  • βœ… Artifact storage
  • βœ… REST API
  • βœ… Web UI

Quick Start

cd model_registry && go run main.go
# Open http://localhost:8081

πŸ€– 7. Agents Framework (LRS-Agents-NBX)

Directory: agents/framework/

Comprehensive framework for building and testing AI agents with native Go transformers.

Features

  • βœ… Multiple agent types (ReAct, Plan-Execute, etc.)
  • βœ… Standard LLM Interface: OpenAI, Anthropic, Ollama, LocalAI
  • βœ… Native Go Transformers: Built-in GPT-2 and BERT support
  • βœ… Tool system with easy integration
  • βœ… Memory management (Conversation, Vector, Sliding Window)
  • βœ… Built-in testing framework
  • βœ… Mock LLM for testing
  • βœ… Multimodal: Image, Audio, Video, Document processing
  • βœ… Git Integration: Clone, commit, push, pull, status, log
  • βœ… GitHub Integration: Issues, PRs, repos, releases, search
  • βœ… HuggingFace Integration: Model search, datasets, inference

Native Transformer LLM

// Use native Go GPT-2/BERT in agents
nativeLLM, _ := llm.NewNativeLLMProvider("gpt2")
agent := agents.NewReActAgent(config, nativeLLM)
result := agent.Run(ctx, "Explain transformers")

Quick Start

cd agents/framework && go run main.go

πŸ”₯ 1. Transformer Architecture

Directory: tensor/ & transformer/

Complete implementation of "Attention Is All You Need" (Vaswani et al., 2017).

Features

  • βœ… Multi-head scaled dot-product attention
  • βœ… Positional encoding (sinusoidal)
  • βœ… Feed-forward networks with ReLU
  • βœ… Encoder and decoder layers
  • βœ… Full backpropagation through all layers
  • βœ… Cross-entropy loss with gradient computation
  • βœ… Learning rate scheduler with warmup
  • βœ… Attention visualization

Performance

  • Small model (2 layers, 256 dim): ~2.5s per epoch
  • Full backpropagation: ~8-9s per epoch

πŸ—„οΈ 2. Vector Database

Directory: vector_db/

Native vector database with HNSW (Hierarchical Navigable Small World) index.

Features

  • βœ… HNSW graph index for efficient ANN search
  • βœ… Multiple similarity metrics (Cosine, Euclidean, Dot Product)
  • βœ… CRUD operations: Insert, Update, Delete, Get
  • βœ… Metadata support and filtering
  • βœ… Thread-safe operations

Performance

  • 10,000 vectors (128 dim): Insert in ~290ms
  • Search (10 results): ~20Β΅s
  • 82x faster than brute force

🎀 3. ASR Library

Directory: asr/

Complete speech recognition pipeline with MFCC features and LSTM acoustic model.

Features

  • βœ… Audio loading (WAV format)
  • βœ… MFCC feature extraction
  • βœ… LSTM acoustic model
  • βœ… CTC decoding
  • βœ… End-to-end pipeline

Performance

  • 5 seconds of audio: ~66ms processing
  • 75x realtime speed

πŸ“Š 4. RAG Evaluation Tool

Directory: rag_eval/

Comprehensive evaluation toolkit for Retrieval-Augmented Generation systems.

Features

  • βœ… Retrieval Metrics: Recall, Precision, F1, MRR, MAP, NDCG
  • βœ… Generation Metrics: BLEU-1/2/3, ROUGE-1/2/L, Jaccard
  • βœ… RAG Quality: Context Relevancy, Answer Relevancy, Faithfulness
  • βœ… Batch Evaluation: Multiple test cases
  • βœ… JSON Export: For analysis and dashboards

Example Output

=== Average Retrieval Metrics ===
Recall@5:     0.7374 | Precision@5:  0.9333 | F1 Score:     0.7983
=== Average Generation Metrics ===
BLEU-1:       0.5500 | ROUGE-1:      0.7333 | ROUGE-L:      0.5722
=== RAG Quality ===
Context Relevancy:  0.2142 | Answer Relevancy:   0.6297 | Faithfulness:       0.2618
Overall Score:      0.6593

πŸ”§ 8. Fine-tuning Architecture

Directory: finetune/

Pure Go machine learning fine-tuning library with LoRA support.

Features

  • βœ… Neural Network Layers: Linear, Embedding, LayerNorm, Attention, Transformer
  • βœ… LoRA Support: Low-rank adaptation for efficient fine-tuning
  • βœ… Optimizers: AdamW, Adam, SGD, Lion, RMSprop
  • βœ… Learning Rate Schedulers: Linear, Cosine, Constant with warmup
  • βœ… Training Loop: Full training pipeline with evaluation and metrics

Quick Start

cd finetune && GOWORK=off go run main.go

Example

cfg := config.DefaultConfig()
cfg.Lora.Enabled = true
cfg.Lora.Rank = 8

model := models.NewModelWrapper(*cfg)
trainer := training.NewTrainer(model, cfg, trainLoader, devLoader)
trainer.Train()

πŸ”§ 9. GPT/BERT Transformers

Directory: transformers/

Native Go implementation of GPT and BERT transformer architectures.

Features

  • βœ… GPT Model: GPT-2 architecture (105M+ parameters)
  • βœ… BERT Model: BERT-Base and BERT-Large
  • βœ… Core Operations: Tensor math, attention, layer norm
  • βœ… Tokenizers: BasicTokenizer, BPETokenizer, WordPiece
  • βœ… Training: AdamW, Adam, SGD optimizers, LR schedulers

Quick Start

cd transformers && GOWORK=off go run main.go

Example

// Create GPT model
gptConfig := gpt.GPT2Config()
gptModel := gpt.NewGPTModel(gptConfig)

// Create BERT model
bertConfig := bert.DefaultBERTConfig()
bertModel := bert.NewBERTModel(bertConfig)

// Tokenize text
tok := tokenizer.NewBasicTokenizer(1000)
ids := tok.Encode("Hello world")

🌐 10. MCP Marketplace

Directory: marketplace/

MCP (Model Context Protocol) apps marketplace with REST API and web UI.

Features

  • βœ… MCP protocol implementation
  • βœ… App registry with categories, ratings, reviews
  • βœ… REST API for app management
  • βœ… Web UI for browsing and searching apps
  • βœ… Built-in MCP tools (search, get details, featured apps)
  • βœ… Sample apps (Code Assistant, Data Analyst, etc.)

Quick Start

cd marketplace && go run main.go
# API: http://localhost:8080/api/
# Web UI: http://localhost:8080/web/index.html

API Endpoints

Method Endpoint Description
GET /api/apps List all apps
GET /api/apps/featured Get featured apps
GET /api/apps/trending Get trending apps
GET /api/apps/search?q= Search apps
GET /api/apps/categories List categories
GET /api/apps/{id} Get app details
POST /api/apps Register new app
GET /api/stats Marketplace statistics

πŸš€ Quick Start

# 1. Transformer Demo
cd /home/runner/workspace && GOWORK=off go run main.go

# 2. Vector Database
cd /home/runner/workspace/vector_db && GOWORK=off go run .

# 3. ASR Demo
cd /home/runner/workspace && GOWORK=off go run asr/cmd/main.go

# 4. RAG Evaluation
cd /home/runner/workspace/rag_eval && GOWORK=off go run main.go

# 5. Training Dashboard
cd /home/runner/workspace/dashboard && GOWORK=off go run main.go

# 6. Model Registry
cd /home/runner/workspace/model_registry && GOWORK=off go run main.go

# 7. Fine-tuning
cd /home/runner/workspace/finetune && GOWORK=off go run main.go

# 8. GPT/BERT Transformers
cd /home/runner/workspace/transformers && GOWORK=off go run main.go

# 9. MCP Marketplace
cd /home/runner/workspace/marketplace && GOWORK=off go run main.go

πŸ“Š Performance Comparison

Project Throughput Latency Use Case
Transformer ~2.5s/epoch ~8s w/ backprop NLP, sequence modeling
Vector DB 10k vectors/s ~20Β΅s search Similarity search, RAG
ASR 75x realtime ~66ms/5s audio Speech recognition
RAG Eval 10k evals/s ~400Β΅s/eval Quality assessment
Dashboard Real-time ~10ms/req Training visualization

πŸ“š References

  • Transformer: "Attention Is All You Need" (Vaswani et al., 2017)
  • HNSW: "Efficient and Robust Approximate Nearest Neighbor Search" (Malkov & Yashunin, 2018)
  • CTC: "Connectionist Temporal Classification" (Graves et al., 2006)
  • BLEU: "A Method for Automatic Evaluation of Machine Translation" (Papineni et al., 2002)

🎯 Roadmap

Completed

  • βœ… Transformer with full backpropagation
  • βœ… HNSW-based vector database
  • βœ… Complete ASR pipeline
  • βœ… RAG evaluation toolkit
  • βœ… Training Dashboard
  • βœ… Backward pass implementation
  • βœ… Quantization (INT8/INT4)
  • βœ… Model serialization
  • βœ… Semantic similarity metrics
  • βœ… Language model integration (ASR)
  • βœ… Beam search decoding
  • βœ… Streaming inference
  • βœ… Distributed training support
  • βœ… RAG evaluation dashboard
  • βœ… ASR beam search decoder
  • βœ… N-gram language model

Future Enhancements

  • GPU acceleration (CUDA/OpenCL) - requires external bindings
  • Full BPTT for ASR (backpropagation through time)
  • Vector database integration with RAG

πŸ“ License

MIT License - Free to use, modify, and distribute.


Built with ❀️ in pure Go image

Packages

 
 
 

Contributors