跳到正文
DEV Community· Mayur·· 3 小時前AI 評分35

Phantom Files:以本地開放權重 AI 揭示機器幽靈

Phantom Files: Uncovering the Machine Ghost with Local Open-Weight AI

AI 導讀

Phantom Files 是一款開源、本地優先的 AI 應用程式,可分析用戶提供的 .txt、.log 和 .md 檔案,並生成以檔案事實為依據的虛構超自然案件檔案。它透過 Ollama 使用 Qwen2.5 等開放權重模型推理,並以逐字摘錄和行號核實證據,避免把虛構解讀冒充事實。

正文

Cover image for Phantom Files: Uncovering the Machine Ghost with Local Open-Weight AI

Mayur

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

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine

What I Built

"Every file has a story. Some should never have been opened."

Phantom Files is an open-source, local-first paranormal forensic workbench that analyzes text files (.txt, .log, .md) and crafts fictional, suspenseful case dossiers inspired by their contents.

Computing terminology is steeped in occult and supernatural lore: we spawn daemons, terminate zombie processes, diagnose fatal memory corruptions, and debug deadlocks at 03:33:00 UTC. For Week 4's "Ghost in the Machine" theme, Phantom Files takes this metaphor literally. It treats everyday technical failures, legacy documentation, and intercepted transmissions as potential digital hauntings—relics of an algorithmic spirit trapped in the machine.

Key Capabilities:

  • Three Investigation Personas:
    1. Haunted Logs: Analyzes server crashes and daemon monitors for techno-spectral residue.
    2. Cursed README: Performs digital archaeology on abandoned documentation, deprecation warnings, and cryptic commit traces.
    3. Unknown Transmission: Deciphers intercepted telemetry, signal drops, and cosmic radio static.
  • Strict Evidence Grounding: To avoid AI hallucinations masquerading as reality, the engine deterministically extracts verbatim substrings from the source file with exact line numbers. The narrative is forced to ground its paranormal theory in these verified facts.
  • Horror Intensity Dial: Ranges from Mild Mystery (subtle, twilight atmosphere) to Atmospheric Horror (creeping psychological dread) and Dark Sci-Fi (cosmic void / machine ghost).
  • Retro-Terminal UI: A nostalgic cathode-ray phosphor green and purple Streamlit interface complete with an ASCII ghost banner, side-by-side evidence inspection, and one-click dossier export (.md and .txt).

Demo

+-----------------------------------------------------------------------------------+
|  .---.                                                                            |
| /     \     PHANTOM FILES BUREAU // PROTOCOL 2026                                 |
|| () () |    "Every file has a story. Some should never have been opened."          |
| \  .  /     -------------------------------------------------------------         |
|  |||||      LOCAL-FIRST AI PARANORMAL INVESTIGATION WORKBENCH                     |
+-----------------------------------------------------------------------------------+
| [1] EVIDENCE INGESTION       | [2] DISPATCH CONSOLE        | [3] CASE DOSSIER     |
| - sample_server_crash.log    | Mode: Haunted Logs          | Case: Daemon Specter |
| - 12 anomalies flagged       | Intensity: Atmospheric      | Interpretation: ...  |
| - Excerpt line mapping       | Model: qwen2.5:3b (Ollama)  | Verified Evidence:   |
|                              | [RUN INVESTIGATION]         | Line 5: 0xDEADBEEF   |
+-----------------------------------------------------------------------------------+

Code

👻 Phantom Files

"Every file has a story. Some should never have been opened."

License: MIT Python 3.11+ Streamlit Ollama Tests: pytest

Phantom Files is an open-source, local-first AI application that analyzes user-supplied text files (.txt, .log, .md) and generates fictional, atmospheric paranormal case dossiers grounded strictly in the factual text of the files.

Built for the Hacktoberfest 2026 DEV Open-Source AI Challenge, Week 4: “Ghost in the Machine”.


📸 Interface Preview

+-----------------------------------------------------------------------------------+
|  .---.                                                                            |
| /     \     PHANTOM FILES BUREAU // PROTOCOL 2026                                 |
|| () () |    "Every file has a story. Some should never have been opened."          |
| \  .  /     -------------------------------------------------------------         |
|  |||||      LOCAL-FIRST AI PARANORMAL INVESTIGATION WORKBENCH                     |
+-----------------------------------------------------------------------------------+
| [1] EVIDENCE INGESTION       | [2] DISPATCH CONSOLE        | [3] CASE DOSSIER     |
| - sample_server_crash.log    | Mode: Haunted Logs          | Case: Daemon Specter |
| - 12 anomalies flagged       | Intensity: Atmospheric      | Interpretation: ...

…


How I Built It

Phantom Files was built with a modular, security-hardened Python architecture:

  1. Local Open-Weight Model (Qwen2.5):
    • Inference runs via Ollama using open-weight models such as qwen2.5:3b (or qwen2.5:7b), released under the permissive Apache 2.0 license.
    • With an active memory footprint under 3 GB RAM, the model runs smoothly on commodity consumer CPUs and laptops without requiring enterprise cloud GPUs.
  2. Safe File Processing (SafeFileReader):
    • Strictly validates file extensions (.txt, .log, .md), enforces a 1MB size ceiling, rejects binary null bytes (\x00), and sanitizes delimiters to neutralize prompt injection attacks.
    • Files are treated strictly as inert, passive text strings—never executed or evaluated via eval(), exec(), or shell subprocesses.
  3. Verbatim Evidence Verification (EvidenceExtractor):
    • Scans the document using regex pattern heuristics for anomalous markers (e.g., segfaults, midnight time windows, orphan PIDs).
    • Maps each anomaly to its exact line number and uses literal substring validation so the LLM cannot hallucinate false quotes.
  4. Structured JSON Engine (InvestigationEngine):
    • Feeds evidence into mode-specific prompt templates with strict system guardrails.
    • Enforces valid JSON outputs containing: case_title, case_summary, noteworthy_events, unusual_patterns, paranormal_interpretation, investigation_questions, and suspenseful_conclusion.
  5. Dossier Exporter (ReportExporter):
    • Generates downloadable GitHub-Flavored Markdown and retro-terminal formatted Plain Text dossiers with clear safety disclaimers separating fiction from fact.
  6. Testing & Quality Assurance:
    • 22 automated unit tests using pytest cover file validation, prompt injection containment, evidence accuracy, and mocked Ollama responses—passing 100% offline.

Why Does Open Innovation Matter?

When dealing with application logs, system crashes, and internal project documentation, privacy and trust are non-negotiable.

Production logs regularly contain sensitive telemetry: internal hostnames, cluster IP addresses, database schemas, and stack traces. Uploading those logs to commercial, closed-source cloud APIs creates serious data exfiltration risks and vendor lock-in.

Open-weight models and local inference through Ollama make Phantom Files possible by providing:

  1. Absolute Data Privacy: File contents never leave the user's local machine or local loopback (127.0.0.1).
  2. Offline Resilience: The application operates seamlessly in air-gapped server rooms, on flights, or during internet outages.
  3. Zero Marginal Cost: Developers and hobbyists can explore creative storytelling and file forensics without subscriptions or metered API tokens.
  4. Transparency & Contributor Freedom: Open models like Qwen under Apache 2.0 empower anyone to inspect, fine-tune, audit, and distribute AI applications freely.

The Spirit of It

The moment this project truly landed was during testing on our own development logs:

2026-10-31 03:33:00.004 [ERROR] Timeout awaiting response from sub-daemon 4040. Heartbeat lost.
2026-10-31 03:33:01.333 [ALERT] Fatal core dump in memory segment 0x00007FFFDEADBEEF
2026-10-31 03:33:01.999 [WARN] Attempted SIGKILL on PID 4040... Process refused termination (zombie state)

When qwen2.5 analyzed those lines, it diagnosed PID 4040 not as a simple kernel race condition, but as an orphaned digital ghost refusing to leave memory space, silently listening on loopback port 6660 for an instruction from an orchestrator that shut down years ago.

It turned a mundane late-night debugging session into a spooky campfire story. It made staring at a crash dump fun again.


Prize Categories

  • Primary Track: Hacktoberfest Open-Source AI Challenge — Week 4: "Ghost in the Machine"

來源:DEV Community · dev.to