svelte-text-generator Svelte Themes

Svelte Text Generator

A modern, client-side web application built with Svelte 5 and TensorFlow.js that uses a trained LSTM Neural Network for real-time, browser-based text generation.

LSTM Text Generator

A web application for text generation using LSTM neural networks, built with Svelte 5 and TensorFlow.js.

Features

  • 🧠 Train LSTM model on custom text input
  • ✨ Generate text based on trained model
  • šŸš€ GPU acceleration support (WebGL) for faster training
  • šŸ’» Simple and responsive user interface
  • šŸ“Š Real-time training progress display

Technologies

  • Svelte 5 - Reactive framework
  • TypeScript - Type safety
  • TensorFlow.js - Machine learning in the browser
  • Vite - Fast build tool and dev server

Installation

# Install dependencies
npm install

# Run development server
npm run dev

# Build for production
npm run build

# Preview production build
npm run preview

Usage

  1. Enter your training text in the "Training Data" section (minimum 10 characters)
  2. Click "Train Model" and wait for training to complete
  3. Enter a seed text in the "Prediction" section
  4. Click "Generate Text" to generate new text

Project Structure

src/
ā”œā”€ā”€ lib/
│   ā”œā”€ā”€ modelService.ts      # Training and generation logic
│   ā”œā”€ā”€ modelUtils.ts        # Utility functions
│   ā”œā”€ā”€ tfConfig.ts          # TensorFlow configuration
│   ā”œā”€ā”€ TrainingSection.svelte
│   ā”œā”€ā”€ PredictionSection.svelte
│   └── OutputDisplay.svelte
ā”œā”€ā”€ App.svelte               # Main component
└── main.ts                  # Entry point

Notes

  • For better results, use longer training texts (multiple paragraphs)
  • The model uses two LSTM layers with dropout to prevent overfitting
  • GPU acceleration is automatically used if available

Top categories

Loading Svelte Themes