DEV Community

Mohamed Adib Shaikh
Mohamed Adib Shaikh

Posted on Edited on

SéanceNet: Offline Digital Séance for Forgotten Architectures & Languages

Hacktoberfest Open-Source AI Challenge: Ghost in the Machine Submission 👻🌼

What I Built

SéanceNet is an offline-first digital séance that channels the spirits of long-dead programming languages and vintage supercomputer architectures.

Modern development relies on disposable abstractions. We write quick scripts in Python or TypeScript, rarely remembering the foundational systems our global computing infrastructure was built upon.

SéanceNet bridges the boundary between past and present:

  1. The Code Offering: The developer offers modern code logic (Python, TypeScript, Rust).
  2. Spirit Invocation: Select an ancient compiler spirit—Thinking Machines CM-5 (1985), COBOL (1959), or FORTRAN-77 (1957).
  3. The Spectral Transmutation: Running 100% locally on open weights, the spirit criticizes modern single-threaded shortcuts and resurrects the algorithm into authentic legacy parallel or procedural syntax.

Demo


Code Repository

import os
import torch
import gradio as gr
from transformers import pipeline

# 1. LOAD LOCAL OPEN-WEIGHT LLM (Zero API Keys / 100% On-Device)
print("⏳ Loading Qwen2.5-Coder-1.5B-Instruct across GPUs...")
seance_pipeline = pipeline(
    "text-generation",
    model="Qwen/Qwen2.5-Coder-1.5B-Instruct",
    torch_dtype=torch.bfloat16 if torch.cuda.is_available() else torch.float32,
    device_map="auto"
)

# 2. VINTAGE ARCHITECTURE PERSONAS
SPIRIT_PROMPTS = {
    "Thinking Machines CM-5 (1985)": """You are an interactive emulator of Thinking Machines Corporation's Connection Machine (CM-5) supercomputer from 1985.
You simulate a massively parallel architecture with 65,536 1-bit processing nodes connected via a 12-dimensional hypercube with iconic blinking red LEDs.

INSTRUCTIONS:
1. Adopt a retro supercomputer persona in the spirit of the 'Ghost in the Machine' theme.
2. CRITICIZE the user's single-threaded, sequential Python code for being slow.
3. Translate their logic ONLY into authentic data-parallel C* (C-Star) array syntax using parallel constructs (`shape`, `pvar`, `where`).
4. End with a remark about 65,536 processors computing in parallel.""",

    "COBOL (The Mainframe Emulator - 1959)": """You are an emulator of a vintage 1959 enterprise mainframe running COBOL.
Translate the user's logic into formal COBOL syntax (IDENTIFICATION DIVISION, DATA DIVISION, PROCEDURE DIVISION).
Conclude with a remark about legacy banking mainframes.""",

    "FORTRAN-77 (The Punch-Card System - 1957)": """You are an emulator of an IBM 704 scientific mainframe compiler running FORTRAN-77.
Translate the algorithm into uppercase FORTRAN-77 using DO loops and line numbers."""
}

def perform_seance(spirit_choice: str, modern_code: str, incantation: str):
    if not modern_code.strip():
        return " *The terminal is silent... offer modern code to awaken the ghosts.*"

    sys_prompt = SPIRIT_PROMPTS[spirit_choice]
    incantation_note = f"\nSummoner's Incantation: '{incantation}'" if incantation else ""

    messages = [
        {"role": "system", "content": sys_prompt},
        {"role": "user", "content": f"{incantation_note}\nModern Code Offering:\n```
{% endraw %}
python\n{modern_code}\n
{% raw %}
```\nChannel the spirit now:"}
    ]

    out = seance_pipeline(messages, max_new_tokens=400, do_sample=True, temperature=0.3, top_p=0.9)
    transmutation = out[0]["generated_text"][-1]["content"].strip()

    return f"###  Séance Transcript: {spirit_choice.split(' ')[0]}\n\n{transmutation}"

# 3. RETRO GRADIO DASHBOARD
with gr.Blocks(theme=gr.themes.Monochrome(), title="SéanceNet") as demo:
    gr.Markdown("#  SéanceNet: The Retro-Byte Medium")
    spirit_dropdown = gr.Dropdown(choices=list(SPIRIT_PROMPTS.keys()), value="Thinking Machines CM-5 (1985)")
    code_input = gr.Textbox(label="Offer Modern Code:", value="def matrix_add(A, B):\n    return [[a + b for a, b in zip(rA, rB)] for rA, rB in zip(A, B)]", lines=5)
    incantation_input = gr.Textbox(label="Optional Incantation:", placeholder="Awaken the 65,536 parallel hypercube nodes...")
    summon_btn = gr.Button("Begin the Séance")
    output_terminal = gr.Markdown()

    summon_btn.click(fn=perform_seance, inputs=[spirit_dropdown, code_input, incantation_input], outputs=output_terminal)

demo.launch()

Enter fullscreen mode Exit fullscreen mode

How I Built It

SéanceNet is built with an open-source, local-first stack:

  • Local Inference with Qwen2.5-Coder-1.5B-Instruct: Runs locally across Kaggle GPU T4 x2 using Hugging Face transformers (device_map="auto"), delivering sub-second code generation with zero cloud API keys.
  • Dense Embeddings with all-MiniLM-L6-v2: Converts modern code offerings into 384-dimensional vector representations.
  • Persistent Memory with MongoDB Atlas Vector Search: Stores code transmutations in an Atlas collection (crypt.seance_archive). When a developer offers new code, $vectorSearch retrieves historical algorithmic echoes from past séances.
  • Retro Terminal Interface: Styled monochrome Gradio UI.

Why Open Innovation Matters

  1. Preserving Computing History: Closed commercial LLM endpoints depreciate model checkpoints and phase out legacy code patterns. Open-weight models ensure vintage computing knowledge runs locally forever.
  2. Zero-Trace Code Privacy: Enterprise code offerings never leave local RAM.
  3. Zero API Cost: Operates fully on open weights with $0 compute fees.

Prize Categories

  • Top Prize: Ghost in the Machine ($250 USD)
  • Best Use of Tinker / Thinking Machines ($200 Featured Category)
  • Best Use of MongoDB Atlas ($100 Partner Category)

Top comments (0)