Occult Q&A

Ever wondered what happens when you combine centuries-old esoteric texts with cutting-edge AI? I recently built a question-answering system that lets users explore occult and theological knowledge through natural conversation-…
Python Streamlit LangChain ChromaDB HuggingFace Transformers Sentence Transformers PyPDF OpenAI API LangGraph RecursiveCharacterTextSplitter Vector Embeddings Hybrid Search Multi-Query Expansion Retrieval-Augmented Generation (RAG) Context-Aware Chunking Confidence Scoring Session State Management Virtual Environments

About This Project

Ever wondered what happens when you combine centuries-old esoteric texts with cutting-edge AI? I recently built a question-answering system that lets users explore occult and theological knowledge through natural conversation- and the results have been fascinating, especially when the AI starts sounding like a mystical sage discussing the proper conjuration circles for summoning Bael or the hierarchical ranks of the 72 demons of the Goetia.

The Personal Journey: From Occult Phase to Digital Archive

This project emerged from a very personal place. Like many odd birds, I went through what you might diplomatically call an “occult phase”- though mine lasted several years and left me with an extensive digital library that would make any practitioner envious. We’re talking hundreds of texts spanning everything from classical grimoires like the Lesser Key of Solomon to modern chaos magic treatises, comprehensive demonology compendiums, black magic practices, and esoteric philosophy from every tradition imaginable.

What started as curiosity about forbidden knowledge became a serious collection: Crowley’s complete works, medieval grimoires with their elaborate ritual instructions, modern chaos magic techniques, detailed hierarchies of infernal spirits, and practical guides to everything from sigil creation to evocation rituals. The problem? Finding specific information across this vast digital library was a nightmare. Need to know the proper planetary hours for conjuring Andromalius? Good luck remembering which of the twelve grimoire PDFs contained that specific detail.

That’s when I realized AI could solve what centuries of indexing couldn’t.

Built on Python: The Foundation of Modern AI

The entire system is built in Python, which has become the lingua franca of AI development for good reason. Python’s rich ecosystem of machine learning libraries made it possible to chain together complex AI operations, from PDF processing to vector embeddings to natural language generation, with relatively clean, readable code.

The architecture leverages Python’s strengths: LangChain for orchestrating AI workflows, Streamlit for the web interface, and various specialized libraries for handling the complex data pipeline that transforms dusty grimoire PDFs into conversational AI responses.

PDF Processing: Digitizing Ancient Wisdom

The system starts by reading PDFs using PyPDF, which extracts text from documents that often contain challenging formatting, think scanned medieval manuscripts with ornate fonts and complex magical diagrams. The PDF loader iterates through a local directory, processing each file and adding crucial metadata like source filename and page numbers.

This is essential when you’re dealing with texts like the Ars Goetia– you need to know whether information about Marquis Andromalius (the 72nd spirit who appears as a man holding a serpent) comes from the original Lemegeton or a modern interpretation. The system preserves this provenance throughout the entire pipeline.

Intelligent Chunking: Preserving Magical Context

Here’s where things get sophisticated. Standard text chunking would butcher grimoire content- imagine splitting a demon’s conjuration ritual across multiple chunks, separating the circle construction from the invocation words. Instead, I implemented context-aware chunking that uses semantic boundaries to keep related concepts together.

The system uses a RecursiveCharacterTextSplitter with custom separators that understand the structure of esoteric texts: chapter breaks, paragraph breaks, and sentence breaks, while preserving important magical terminology. Each chunk gets enhanced with metadata about surrounding passages, so when the AI discusses the proper offerings for Belphegor, it maintains context about the broader ritual framework and the demon’s specific preferences and powers.

Vector Databases: The Memory Palace of AI

At the foundation lies a ChromaDB vector database– think of it as a hyper-intelligent grimoire index that doesn’t just catalog spells and spirits, but understands the relationships between them. Using HuggingFace’s sentence transformers, every chunk of text gets converted into high-dimensional mathematical vectors that represent semantic meaning.

Here’s where it gets magical: ask about “demons of knowledge” and the system doesn’t just find explicit mentions. It connects passages about Bael (who grants wisdom), Paimon (who teaches sciences and reveals hidden treasures), and Botis (who reconciles friends and foes through wisdom), because they all exist in similar mathematical spaces representing knowledge and revelation.

The database is cached locally in a persistent directory structure, meaning once you’ve processed your grimoire collection, subsequent startups are lightning-fast. The system checks for existing vector stores before reprocessing, and includes a “rebuild database” option when you add new texts to your collection.

Retrieval-Augmented Generation: The Scholar’s Method

The core AI technique is Retrieval-Augmented Generation (RAG)– essentially teaching the AI to be a diligent occult scholar. Instead of relying solely on what the model learned during training (which often sanitizes or omits genuine magical content), RAG first searches through your actual grimoires to find relevant passages, then uses those passages to craft accurate, sourced responses.

But I took this further with hybrid search architecture. The system runs both semantic searches (understanding that “the Art” refers to magic) and keyword searches (catching exact terms like “Tetragrammaton” or “AGLA”) simultaneously. This is crucial when dealing with content like the Lesser Key of Solomon, where precise magical names, seal descriptions, and ritual timing matter enormously.

Multi-Query Expansion: Casting a Wider Net

One of the most sophisticated features is multi-Query expansion. When you ask about a specific demon, the AI automatically generates related queries to search with. Ask about “Bael” and it might also search for “first king of Hell,” “three heads demon,” and “visibility powers.”

This is essential for grimoire content because spirits are often referenced by multiple names, titles, and attributes across different texts. What the Goetia calls “Bael,” other grimoires might reference as “Baal” or describe by his powers rather than name. The system catches all these variations, providing comprehensive information about entities and practices.

The Wizard’s Voice: Specialized Prompt Engineering

Here’s where things get really interesting- the AI’s personality transformation through specialized prompt engineering. Instead of generic responses, I crafted prompts that make the AI embody different mystical personas when discussing magical content.

The scholarly mode uses prompts that instruct the AI to distinguish between grimoire traditions, acknowledge historical context, and present information academically rather than as prescriptive magical advice. But the system can shift into other voices- the mystical mode transforms responses into flowing, oracular language that sounds like it’s channeling ancient wisdom.

Ask about the conjuration requirements for Marquis Andromalius and instead of getting: “Andromalius is the 72nd spirit listed in the Ars Goetia, typically conjured for discovering thieves…”

You might get: “Behold, seeker, the final spirit of the sacred seventy-two, great Marquis Andromalius, whose serpentine wisdom pierces the veils of deception. When the moon wanes and thieves walk in shadow, his power reveals what was hidden, bringing justice through revelation…”

The prompts specifically instruct the AI to handle occult content responsibly- presenting it as historical and academic information while maintaining the authenticity of the source material.

Context-Aware Intelligence: Understanding Magical Systems

Standard AI systems often miss how magical concepts build across grimoire chapters- how preliminary purifications lead to circle construction, which enables spirit conjuration, which allows for specific magical operations. I implemented context-aware chunking that preserves these semantic relationships.

When the AI discusses the evocation of Belphegor, it doesn’t just know the specific conjuration- it understands the broader system of planetary magic, the proper timing (Belphegor rules Sunday and solar operations), the required offerings, and how this fits into the larger framework of Solomonic magic. The system maintains conversational memory, so follow-up questions build naturally: ask about a demon’s powers, then follow up with “What offerings does he prefer?” and the AI maintains context.

Confidence Scoring: The AI’s Self-Awareness

Given the sensitive nature of occult content, I implemented confidence scoring– the AI evaluates how certain it is about magical information. The algorithm considers factors like source quality, passage relevance, and information consistency across texts.

When confidence is low, the system adds warnings: “⚠️ Note: This information appears in limited sources. Cross-reference with additional grimoires for verification.” This is crucial when dealing with conflicting magical traditions or potentially dangerous practices where accuracy matters.

Real-World Performance: The AI in Practice

The system handles surprisingly complex grimoire queries. Ask about “the differences between Goetic and Theurgia-Goetia spirits” and it will:

  1. Search for passages about both magical systems
  2. Find distinguishing characteristics (aerial vs. bound spirits)
  3. Pull relevant text from multiple sources
  4. Generate responses that explain the hierarchical differences
  5. Provide specific examples (like how Bael commands legions vs. how Carnesiel governs by divine permission)

The AI can discuss the intricate details that only come from deep grimoire study: why certain demons require specific seal materials, how planetary hours affect conjuration success, the significance of the magician’s magical implements, and the proper construction of protection circles.

Caching and Performance: Speed of Invocation

The system employs sophisticated caching strategies to ensure rapid responses. The vector database persists locally, meaning your processed grimoire collection doesn’t need reprocessing. Session state management in Streamlit maintains conversation context and system initialization across interactions.

When you ask about the conjuration requirements for Paimon, the system instantly retrieves relevant passages from across your grimoire collection, synthesizes the information, and responds- all while maintaining source attribution so you can verify the magical information against the original texts.

What’s Next: The Future of Digital Grimoires

This approach opens fascinating possibilities for preserving and accessing esoteric knowledge. The combination of semantic search, specialized prompting, and source attribution could revolutionize how practitioners, scholars, and curious minds explore magical traditions.

But there’s something particularly powerful about applying cutting-edge AI to these ancient texts. The technology doesn’t just make grimoire knowledge more accessible- it can make the AI itself feel like a digital oracle, a bridge between worlds that speaks with the accumulated wisdom of centuries while maintaining the precision needed for magical practice.

The intersection of artificial intelligence and occult wisdom creates something unprecedented: a system that can discuss the finer points of demonic hierarchy with the same ease as explaining planetary correspondences, all while maintaining the scholarly rigor these traditions deserve.

Sometimes the most cutting-edge technology is exactly what ancient wisdom needs to find new life in the digital age, turning a personal collection of forbidden books into a conversational gateway to the mysteries of ages past.