ruvector/crates/ruvector-tiny-dancer-core/examples
ruv e709718b64 feat(tiny-dancer): real FastGRNN training pipeline (ADR-252)
Closes the three gaps that made tiny-dancer inference-only:

1. Real gradients: FastGRNN::forward_cached + backward implement single-step
   analytic backprop (h0=0); gradient-checked vs central finite differences.
2. Real Adam step: train_batch accumulates mean batch gradients; apply_gradients
   does L2 + global-norm clip + bias-corrected Adam update on the existing
   optimizer state. Model now actually learns (test: loss down, acc>0.9).
3. safetensors persistence: model.rs save/load serialize every tensor (f32 LE)
   with config in __metadata__; round-trip is bit-exact.
4. DRACO adapter: TrainingDataset::from_draco consumes the {embedding, scores}
   + prices shape (same as @metaharness/router) so one dataset trains both.

Runnable example train_from_draco demonstrates DRACO -> train -> save -> load
-> route end to end. 31 core tests green (gradient check, convergence,
round-trip, adapter).

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-06-15 10:50:14 -04:00
..
admin-server.rs fix(ci): Fix formatting and workflow permission issues 2025-12-26 22:11:57 +00:00
full_observability.rs fix(ci): Fix formatting and workflow permission issues 2025-12-26 22:11:57 +00:00
metrics_example.rs fix(ci): Fix formatting and workflow permission issues 2025-12-26 22:11:57 +00:00
OBSERVABILITY_EXAMPLES.md fix: Fix case sensitivity bug preventing native module from loading 2025-11-21 21:34:52 +00:00
README.md fix: Fix case sensitivity bug preventing native module from loading 2025-11-21 21:34:52 +00:00
tracing_example.rs fix: Resolve unresolved imports in ruvector-tiny-dancer-core examples 2025-11-26 22:48:12 +00:00
train-model.rs fix: Resolve CI build failures 2025-11-26 15:25:47 +00:00
train_from_draco.rs feat(tiny-dancer): real FastGRNN training pipeline (ADR-252) 2026-06-15 10:50:14 -04:00

Tiny Dancer Examples

This directory contains example applications demonstrating how to use Tiny Dancer.

Admin Server Example

File: admin-server.rs

A production-ready admin API server with health checks, metrics, and administration endpoints.

Features

  • Health check endpoints (K8s liveness & readiness probes)
  • Prometheus metrics export
  • Hot model reloading
  • Configuration management
  • Circuit breaker monitoring
  • Optional bearer token authentication

Running

cargo run --example admin-server --features admin-api

Testing

Once running, test the endpoints:

# Health check
curl http://localhost:8080/health

# Readiness check
curl http://localhost:8080/health/ready

# Prometheus metrics
curl http://localhost:8080/metrics

# System information
curl http://localhost:8080/info

Admin Endpoints

Admin endpoints support optional authentication:

# Reload model (if auth enabled)
curl -X POST http://localhost:8080/admin/reload \
  -H "Authorization: Bearer your-token-here"

# Get configuration
curl http://localhost:8080/admin/config \
  -H "Authorization: Bearer your-token-here"

# Circuit breaker status
curl http://localhost:8080/admin/circuit-breaker \
  -H "Authorization: Bearer your-token-here"

Configuration

Edit the example to configure:

  • Bind address and port
  • Authentication token
  • CORS settings
  • Router configuration

Production Deployment

For production use:

  1. Enable authentication:

    auth_token: Some("your-secret-token".to_string())
    
  2. Use environment variables:

    let token = std::env::var("ADMIN_AUTH_TOKEN").ok();
    
  3. Deploy behind HTTPS proxy (nginx, Envoy, etc.)

  4. Set up Prometheus scraping:

    scrape_configs:
      - job_name: 'tiny-dancer'
        static_configs:
          - targets: ['localhost:8080']
    
  5. Configure Kubernetes probes:

    livenessProbe:
      httpGet:
        path: /health
        port: 8080
    readinessProbe:
      httpGet:
        path: /health/ready
        port: 8080
    

Documentation

Next Steps

  1. Integrate with your application
  2. Set up monitoring (Prometheus + Grafana)
  3. Configure alerts
  4. Deploy to production

Support

For issues or questions, see the main repository documentation.