Move model to CUDA only after embeddings are created, not before.
This avoids NVML assertion failures during batch encoding on Jetson's
unified memory architecture.
fix: add CUDA warmup and memory config for Jetson GPU support
- Add CUDA context warmup before heavy model load to avoid allocator crash
- Set PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True for unified memory
- Make model configurable via THEMATIC_MODEL_NAME env var
- Document smaller model option (all-MiniLM-L6-v2) as fallback
fix: load model on CPU first for Jetson GPU compatibility
- Install sentence-transformers with --no-deps to avoid overwriting
L4T's pre-installed PyTorch with incompatible PyPI version
- Add explicit dependencies (tokenizers, scipy, safetensors, etc.)
- Use --runtime nvidia instead of --gpus all for Jetson
fix: Jetson compatibility for Python 3.10 and GPU access
- Add requirements-jetson.txt with Python 3.10 compatible versions
- Exclude x86 embeddings cache, let Jetson regenerate natively
- Use --gpus all instead of --runtime nvidia for GPU access
- Add test command to verify GPU works in container
fix: update Jetson Dockerfile to use correct L4T r36.4.0 base image
- Use dustynv/l4t-pytorch:r36.4.0 for JetPack 6.x compatibility
- Simplify to single-stage build (no multi-stage needed)
- Add Jetson usage hint to run.sh help text
feat: add Jetson ARM64 support and improve documentation
- Add Dockerfile.jetson for NVIDIA Jetson Orin Nano/Xavier with L4T base
- Add run-jetson.sh build/run script with GPU runtime support
- Update CLAUDE.md: single test command, hack/ scripts section, GPU notes
- Add test_startrek_similarity.py for topic similarity testing
feat: add PyTorch tensor support and GPU optimization
Major refactoring to improve performance and add GPU support:
- Migrate from numpy (.npy) to PyTorch tensors (.pt) for embeddings
- Add automatic GPU detection and device selection (cuda/cpu)
- Unify tensor operations - single tensor works for both CPU and GPU
- Fix argsort error in multi-topic similarity computation
- Add Docker GPU support with --gpus flag in run.sh
- Improve performance with vectorized PyTorch operations (40x speedup)
- Maintain backward compatibility with CPU-only environments
Changes:
- Add cache-dir/embeddings_all-mpnet-base-v2_norvig_100000.pt (238MB)
- Update thematic_word_service.py for unified PyTorch tensors
- Add GPU/CPU mode selection in run.sh and build.sh scripts
- Update .gitattributes to track .pt files with Git LFS
Performance improvements:
- GPU acceleration when available (GTX 1650 tested)
- Vectorized operations for multi-topic similarity
- Direct PyTorch tensor operations without numpy conversions
Signed-off-by: Vimal Kumar <vimal78@gmail.com>
feat: add frontend controls for similarity temperature and difficulty weight
- Add AdvancedSettings component with parameter sliders
- Add API support for parameter overrides in puzzle generation
- Pass advanced params through service layers to ThematicWordService
- Include presets for common parameter combinations (Default, Focused, Varied, Challenging)
- Restore original parameter values after generation to prevent side effects
Signed-off-by: Vimal Kumar <vimal78@gmail.com>
fix: properly track sentence-transformer model files in LFS
- Replace LFS pointers with actual model files from backup
- Properly track in Git LFS for reliable deployment
- Fixes local development JSONDecodeError
- Ensures remote continues working with proper LFS pull
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
docs: update CONFIG.md with current env vars and document transfer learning failure
- Replace deprecated env variables with current ThematicWordService config
- Add detailed explanations for all 16 active environment variables
- Document 9 deprecated variables that can be safely removed from HF Spaces
- Record FLAN-T5 transfer learning approach as failed/discarded in strategy doc
- Preserve theoretical analysis for historical context with clear warnings
Signed-off-by: Vimal Kumar <vimal78@gmail.com>
feat: add essential cache files for WordNet clue generation
- Add norvig embeddings (239MB) for 100k vocabulary
- Add WordNet corpus for clue generation
- Add OMW-1.4 (Open Multilingual WordNet) corpus
- Add averaged_perceptron_tagger for POS tagging
- Include necessary zip archives
- Exclude punkt tokenizers (not used by application)
fix: clean up repository after removing LFS cache files
- Add comprehensive visualization concepts for soft minimum method
- Add detailed analysis of vocabulary alternatives beyond WordFreq
- Add python scripts to analyse word list from peter norvig home page
- Update .gitignore for fine-tuned models and T5 model cache
- Include SUBTLEX dataset and Norvig vocabulary analysis files
Signed-off-by: Vimal Kumar <vimal78@gmail.com>
feat: add multi-topic intersection methods with adaptive beta for word selection
- Add soft minimum method as default for finding true topic intersections
- Implement adaptive beta mechanism with automatic threshold adjustment
- Support geometric/harmonic mean methods as alternatives
- Vectorized implementation for 40x performance improvement
- Default to soft_minimum to avoid problematic words in multi-topic scenarios
Signed-off-by: Vimal Kumar <vimal78@gmail.com>
feat: Add custom topics input and expand predefined topics list
- Add distribution normalization to ensure consistent difficulty across topics
- Support three methods: similarity_range, composite_zscore, percentile_recentering
- Set default to disabled based on analysis showing natural semantic relationships are preferable
- Add comprehensive analysis documentation and test suite
Signed-off-by: Vimal Kumar <vimal78@gmail.com>
- Implement Chart.js probability distribution visualization
- Sort chart by frequency percentile (100% → 0%) to reveal Gaussian targeting
- Add comprehensive probability distribution analysis documentation
- Enable statistical markers (μ, σ) with proper sampling zone visualization
Fixes visualization issue where probability-sorted charts couldn't show
difficulty-based frequency targeting effectiveness.
Signed-off-by: Vimal Kumar <vimal78@gmail.com>
feat: Add debug tab with performance optimizations
- Implement environment-controlled debug data collection (ENABLE_DEBUG_TAB)
- Add frontend debug tab with sortable thematic pool analysis
- Optimize debug performance by removing expensive semantic neighbor computation
- Add comprehensive debug insights: generation params, word scoring, selection algorithm
- Update API response model to include optional debug field
- Create interactive UI for analyzing ML word selection process
Signed-off-by: Vimal Kumar <vimal78@gmail.com>
fix: Improve word selection and clue generation for crosswords
- Remove quality clue filtering to fix hard mode selecting common words
- Reduce thematic pool from 400 to 150 words for better performance
- Add semantic neighbor-based clue generation using embeddings
- Update temperature (0.7→0.2) and difficulty_weight (0.3→0.5) for better selection
- Add comprehensive documentation on embedding limitations
Signed-off-by: Vimal Kumar <vimal78@gmail.com>
fix: Optimize word selection parameters to fix inverse difficulty selection
- Reduce temperature from 0.7 to 0.2 for more deterministic selection
- Increase difficulty_weight from 0.3 to 0.5 for stronger frequency influence
- Fix issue where easy mode selected rare words and hard mode selected common words
- Update documentation with parameter analysis and optimization results
Signed-off-by: Vimal Kumar <vimal78@gmail.com>
feat: implement difficulty-aware word selection with frequency percentiles
- Includes sentence-transformers model (418MB)
- Pre-computed embeddings (293MB)
- NLTK WordNet data
- Configured Docker to use cache at /app/backend-py/cache
- Setup Git LFS for large files (899MB total)
Signed-off-by: Vimal Kumar <vimal78@gmail.com>
- Add session-based tracking to prevent word repetition across puzzles
- Implement quality-tiered randomization for better variety (92% score)
- Fix filtering bug rejecting high-scoring words like TECH(0.793), ICT(0.641)
- Allow meaningful topic variations while blocking exact matches
- Add configurable word exclusion system for inappropriate terms
Resolves issues where valid technology terms were incorrectly rejected
due to substring matching and overly broad abstract word filters.
Signed-off-by: Vimal Kumar <vimal78@gmail.com>
perf(vector-search): implement FAISS index caching
Resolves HF Spaces slow startup by implementing persistent FAISS index caching
and multiple performance optimizations, reducing startup time from 30-60s to 2-5s.
🚀 FAISS Index Caching System:
- Persistent disk cache for vocabulary, embeddings, and FAISS index
- Model-specific cache keys with automatic invalidation
- Environment-aware cache locations (/tmp/faiss_cache for HF Spaces)
- Graceful fallback when cache loading fails
- 6-12x faster startup after initial cache build
Signed-off-by: Vimal Kumar <vimal78@gmail.com>
fix(vector-search): implement adaptive threshold strategy to resolve word generation failure
- Implement FastAPI backend with vector search and machine learning capabilities
- Add comprehensive crossword generation algorithm with bounds checking fixes
- Include multi-layer word caching system with graceful fallback to static words
- Add extensive test suite (unit tests, integration tests, boundary condition tests)
- Update Docker configuration for Python backend deployment
- Add comprehensive documentation and development setup guides
- Integrate sentence-transformers and FAISS for semantic word discovery
- Maintain API compatibility with existing Node.js backend
Signed-off-by: Vimal Kumar <vimal78@gmail.com>
- Integrate HuggingFace sentence-transformers for semantic word selection
- Add AI toggle in frontend with visual feedback and dynamic content badges
- Implement EmbeddingWordService with similarity-based word generation
- Enhance CrosswordGenerator with hybrid AI/static word selection
- Add topic-specific word banks with quality clues for better relevance
- Disable difficulty selector UI while preserving backend logic
- Add comprehensive word→clue mapping logs for debugging
- Suppress verbose HuggingFace API logs for cleaner output
- Update frontend with AI checkbox, improved styling, and state management
- Add security documentation and environment configuration
- Include Docker-ready setup with built frontend assets
Signed-off-by: Vimal Kumar <vimal78@gmail.com>
- Log User-Agent to identify health checks vs real requests
- Add specific logging for asset requests and index.html serving
- Help diagnose why assets aren't loading in HF Spaces
- Bind server to 0.0.0.0 in production for external connections (fixes HF Spaces connectivity)
- Add debug logging for working directory and app location in production
- Remove verbose crossword generation logs, keep only error messages
- Streamline backtracking placement logging for better performance
Signed-off-by: Vimal Kumar <vimal78@gmail.com>
Fix Express trust proxy for Hugging Face Spaces deployment