diff --git a/frontend/src/store/settingsStore.ts b/frontend/src/store/settingsStore.ts
index ecbb628..6c49eb2 100644
--- a/frontend/src/store/settingsStore.ts
+++ b/frontend/src/store/settingsStore.ts
@@ -28,8 +28,8 @@ export const useSettingsStore = create()(
apiBaseUrl: defaultApiBaseUrl,
maxTokens: 200,
temperature: 1.0,
- modelLabel: "quadtrix-v1.0 - cpu",
- modelBackend: "cpp",
+ modelLabel: "quadtrix-v1.0 - PyTorch",
+ modelBackend: "torch",
settingsOpen: false,
statsOpen: false,
setApiBaseUrl: (value) => set({ apiBaseUrl: value }),
@@ -40,6 +40,14 @@ export const useSettingsStore = create()(
setSettingsOpen: (value) => set({ settingsOpen: value }),
setStatsOpen: (value) => set({ statsOpen: value }),
}),
- { name: "quadtrix-settings" },
+ {
+ name: "quadtrix-settings",
+ version: 1,
+ migrate: (persistedState) => ({
+ ...(persistedState as Partial),
+ modelLabel: "quadtrix-v1.0 - PyTorch",
+ modelBackend: "torch",
+ }),
+ },
),
);
diff --git a/model/export_tokenizer.py b/model/export_tokenizer.py
deleted file mode 100644
index 206359f..0000000
--- a/model/export_tokenizer.py
+++ /dev/null
@@ -1,116 +0,0 @@
-"""
-Export tiktoken GPT-2 vocabulary for C++ inference
-
-This script creates vocabulary files that can be used with C++ tokenizers
-like sentencepiece or BPE implementations.
-"""
-
-import tiktoken
-import json
-
-print("-"*60)
-print(" Tokenizer Vocabulary Exporter for C++ Inference ")
-print("-"*60)
-print()
-
-# Initialize GPT-2 tokenizer
-enc = tiktoken.get_encoding("gpt2")
-vocab_size = enc.n_vocab
-
-print(f"Tokenizer: GPT-2 (tiktoken)")
-print(f"Vocabulary size: {vocab_size:,}")
-print()
-# Export 1: Token to ID mapping (JSON)
-
-
-print(" → Exporting token-to-id mapping...")
-
-# Get the encoder's vocabulary
-# tiktoken doesn't expose the full vocabulary directly, so we reconstruct it
-vocab_dict = {}
-
-# Try to decode each token ID to get its string representation
-for token_id in range(vocab_size):
- try:
- token_bytes = enc.decode_single_token_bytes(token_id)
- # Store as both hex and string representation
- vocab_dict[token_id] = {
- "hex": token_bytes.hex(),
- "str": token_bytes.decode('utf-8', errors='replace')
- }
- except Exception as e:
- vocab_dict[token_id] = {"hex": "", "str": f""}
-
-with open('gpt2_vocab.json', 'w', encoding='utf-8') as f:
- json.dump(vocab_dict, f, indent=2, ensure_ascii=False)
-
-print(f"Saved: gpt2_vocab.json ({len(vocab_dict)} tokens)")
-
-
-# Export 2: Merges file (for BPE)
-
-print("Exporting BPE merges...")
-
-# tiktoken uses a different approach than traditional BPE, but we can try
-# to approximate by analyzing common patterns
-try:
- # This is a simplified version - for production use, you'd need
- # to extract the actual BPE merge rules from tiktoken
-
- # For now, just create a placeholder
- with open('gpt2_merges.txt', 'w', encoding='utf-8') as f:
- f.write("# GPT-2 BPE Merges (approximation)\n")
- f.write("# For full compatibility, use tiktoken's actual merge rules\n")
-
- print(f" ⚠ Saved: gpt2_merges.txt (placeholder)")
- print(f" Note: Full BPE merge extraction requires tiktoken internals")
-except Exception as e:
- print(f" ✗ Could not export merges: {e}")
-
-# Export 3: Simple byte-pair mapping
-
-print(" Creating token lookup table...")
-
-token_strings = []
-for token_id in range(vocab_size):
- try:
- token_bytes = enc.decode_single_token_bytes(token_id)
- token_strings.append(token_bytes.decode('utf-8', errors='replace'))
- except:
- token_strings.append(f"")
-
-with open('gpt2_tokens.txt', 'w', encoding='utf-8') as f:
- for token in token_strings:
- # Escape special characters
- escaped = token.replace('\\', '\\\\').replace('\n', '\\n').replace('\t', '\\t')
- f.write(f"{escaped}\n")
-
-print(f" Saved: gpt2_tokens.txt ({len(token_strings)} tokens)")
-
-
-# Example encoding/decoding
-
-print()
-print(" Testing tokenization...")
-test_text = "Hello, how are you?"
-test_tokens = enc.encode(test_text)
-decoded = enc.decode(test_tokens)
-
-print(f" Text: '{test_text}'")
-print(f" Tokens: {test_tokens}")
-print(f" Decoded: '{decoded}'")
-
-
-# Summary
-print()
-print("Export Complete")
-print()
-print("Files created:")
-print(" gpt2_vocab.json - Full vocabulary with hex representations")
-print(" gpt2_tokens.txt - Simple token list (one per line)")
-print("gpt2_merges.txt - BPE merges (placeholder)")
-print()
-print("for C++ integration:")
-print("Use sentencepiece with gpt2_vocab.json")
-print("Or implement a custom tokenizer using gpt2_tokens.txt")
-print("Or use a library like tokenizers (HuggingFace) with C++ bindings")
diff --git a/src/torch_example.cpp b/model/src/torch_example.cpp
similarity index 100%
rename from src/torch_example.cpp
rename to model/src/torch_example.cpp
diff --git a/src/torch_main.cpp b/model/src/torch_main.cpp
similarity index 100%
rename from src/torch_main.cpp
rename to model/src/torch_main.cpp
diff --git a/package-lock.json b/package-lock.json
deleted file mode 100644
index 28be669..0000000
--- a/package-lock.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "name": "quadtrix",
- "version": "1.0.0",
- "lockfileVersion": 3,
- "requires": true,
- "packages": {
- "": {
- "name": "quadtrix",
- "version": "1.0.0",
- "license": "MIT",
- "bin": {
- "quadtrix": "bin/quadtrix.js"
- },
- "engines": {
- "node": ">=18"
- }
- }
- }
-}
diff --git a/package.json b/package.json
deleted file mode 100644
index a4a24c5..0000000
--- a/package.json
+++ /dev/null
@@ -1,54 +0,0 @@
-{
- "name": "quadtrix",
- "version": "1.0.2",
- "description": "CLI for running Quadtrix.cpp chat and local training.",
- "license": "MIT",
- "author": "Eamon",
- "repository": {
- "type": "git",
- "url": "https://github.com/Eamon2009/Quadtrix.cpp.git"
- },
- "bugs": {
- "url": "https://github.com/Eamon2009/Quadtrix.cpp/issues"
- },
- "homepage": "https://github.com/Eamon2009/Quadtrix.cpp#readme",
- "bin": {
- "quadtrix": "bin/quadtrix.js"
- },
- "files": [
- "bin/",
- "backend/**/*.py",
- "backend/requirements.txt",
- "backend/README.md",
- "backend/.env.example",
- "config/",
- "data/data_set.py",
- "engine/*.py",
- "engine/engine.c",
- "frontend/dist/",
- "iGPU/*.py",
- "include/",
- "src/",
- "main.cpp",
- "LICENSE",
- "README.md",
- "PUBLISHING.md",
- "run.md"
- ],
- "scripts": {
- "build:frontend": "npm --prefix frontend run build",
- "prepack": "npm run build:frontend"
- },
- "keywords": [
- "quadtrix",
- "llm",
- "transformer",
- "chat",
- "machine-learning",
- "cpp",
- "pytorch"
- ],
- "engines": {
- "node": ">=18"
- }
-}
\ No newline at end of file
diff --git a/supervisord.conf b/supervisord.conf
new file mode 100644
index 0000000..3e13710
--- /dev/null
+++ b/supervisord.conf
@@ -0,0 +1,31 @@
+[supervisord]
+nodaemon=true
+logfile=/var/log/supervisor/supervisord.log
+pidfile=/var/run/supervisord.pid
+loglevel=info
+[program:fastapi]
+command=/venv/bin/uvicorn main:app --host 0.0.0.0 --port 3001
+directory=/app/backend
+autostart=true
+autorestart=true
+startretries=5
+stdout_logfile=/var/log/supervisor/fastapi.stdout.log
+stderr_logfile=/var/log/supervisor/fastapi.stderr.log
+stdout_logfile_maxbytes=10MB
+stderr_logfile_maxbytes=10MB
+environment=
+ TORCH_CHECKPOINT_PATH="%(ENV_TORCH_CHECKPOINT_PATH)s",
+ GPT_MODEL_PATH="%(ENV_GPT_MODEL_PATH)s",
+ CORS_ORIGINS="%(ENV_CORS_ORIGINS)s",
+ LOG_LEVEL="%(ENV_LOG_LEVEL)s",
+ MAX_SESSIONS="%(ENV_MAX_SESSIONS)s",
+ SESSION_TTL_HOURS="%(ENV_SESSION_TTL_HOURS)s"
+[program:frontend]
+command=serve -s /app/frontend/dist -l 8080
+autostart=true
+autorestart=true
+startretries=5
+stdout_logfile=/var/log/supervisor/frontend.stdout.log
+stderr_logfile=/var/log/supervisor/frontend.stderr.log
+stdout_logfile_maxbytes=5MB
+stderr_logfile_maxbytes=5MB