From MIKAI to PydxAI: The Evolution of Intelligent Medicine

Artificial intelligence in medicine has moved beyond the experimental stage. It now sits at the heart of modern diagnostics, research, and patient care — quietly reshaping how physicians access knowledge, process data, and make decisions.

From this transformation came MIKAI — a local, privacy-first medical AI built to reason, learn, and assist clinicians. Today, that system is evolving into something more capable, modular, and forward-looking: PydxAI.

The Beginning: MIKAI’s Mission

The journey began with MIKAI (Medical Intelligence + Kijakarn’s AI) — a local large language model system designed for doctors who wanted autonomy, security, and precision. MIKAI ran on local hardware (Tesla P40 + RX580), processed medical texts, learned from new journals, and integrated with a Retrieval-Augmented Generation (RAG) pipeline to provide evidence-based answers.

Its purpose was simple yet powerful:

  • To understand complex clinical questions.
  • To retrieve verified knowledge from curated sources.
  • To reason based on established medical logic.
  • And to learn continually from new data.

Unlike cloud-based AI assistants, MIKAI never sent data outside the user’s network. Every medical conversation, every analysis, stayed secure — an important principle for healthcare professionals who handle sensitive patient information.

Why Evolve? The Birth of PydxAI

As MIKAI matured, new challenges appeared. Medicine is not static; new drugs, diseases, and discoveries emerge daily. The model needed to evolve beyond being a “local assistant” — it needed to become a dynamic diagnostic intelligence.

Hence, PydxAI was born.

The name PydxAI combines three core ideas:

  • Py → the Python ecosystem that powers flexibility and open development.
  • Dx → the universal shorthand for “diagnosis,” symbolizing clinical reasoning.
  • AI → the intelligence layer that bridges computation and care.

PydxAI represents not just a rebrand, but a new architecture — a system built for self-learning, multi-modal reasoning, and open research collaboration.

Core Philosophy: Intelligence with Integrity

Healthcare demands trust, and that means every AI system must be transparent, explainable, and secure. PydxAI is built on three pillars:

1. 

Local Intelligence, Not Cloud Dependency

All models, embeddings, and RAG databases run locally or on secure servers under full user control. Physicians or institutions can deploy PydxAI without sending any patient data to third-party APIs.

2. 

Explainable Diagnostic Reasoning

Every inference, every answer, and every decision can be traced back to the supporting evidence. PydxAI’s reasoning engine doesn’t just give results — it explains why and how those results were generated.

3. 

Adaptive Medical Learning

PydxAI continuously refines its knowledge through structured ingestion pipelines — adding new clinical studies, guidelines, and textbooks. This allows it to evolve in real-time without retraining from scratch.

Architectural Evolution

MIKAI laid the foundation — a system that combined LLM inference with RAG-based retrieval and MariaDB knowledge management.

PydxAI extends that architecture into a more robust, modular structure:

This modular approach allows each layer to evolve independently — new embeddings, better fine-tunes, or secure federated updates — without disrupting the rest of the system.

The Technology Stack

PydxAI is grounded in open technologies that support long-term scalability:

  • Core Engine: Python 3.11 with FastAPI backend
  • Inference Models: Magistral 24B, Mistral 7B, and custom medical LoRA layers
  • Database: MariaDB for structured medical knowledge
  • Document Storage: Encrypted RAG-based vector store
  • Hardware: Optimized for hybrid setups (NVIDIA + AMD)
  • Frontend: Responsive chat interface with iframe support and cloudflare tunnel

This setup ensures the system can operate efficiently even on affordable GPU hardware — empowering clinics and researchers to run private AI without massive cloud costs.

From Chatbot to Clinical Companion

MIKAI started as a medical chatbot. PydxAI becomes a clinical companion.

It doesn’t just answer — it collaborates.

Imagine a physician uploading a scanned medical record. PydxAI extracts structured fields (name, DOB, diagnosis, medication), analyzes lab trends, and generates a brief summary for documentation — all offline.

Or a researcher querying for the latest insights on thyroid cancer genetics. PydxAI searches, summarizes, and cites verified medical literature.

In both cases, the AI acts as an intelligent partner, not just a language model.

Privacy by Design

In healthcare, security isn’t optional — it’s foundational.

That’s why PydxAI inherits MIKAI’s strict privacy standards:

  • All patient data is processed locally.
  • No cloud logging or telemetry.
  • Full control over encryption keys and access permissions.

For hospital deployment, PydxAI can integrate with existing EHR or PACS systems through secure APIs, ensuring compliance with data protection laws like HIPAA and Thailand PDPA.

Learning from the Field

One of MIKAI’s most successful experiments was RAG-based medical summarization — using a curated corpus of peer-reviewed sources to generate structured medical knowledge. PydxAI builds upon this by adding feedback learning, where user validation improves its accuracy over time.

For instance, if a doctor marks an answer as “verified,” that context is prioritized in future retrievals. Over weeks, the model learns the preferences, style, and reasoning habits of its users — becoming more aligned with their clinical workflow.

Toward the Future of Intelligent Healthcare

The long-term roadmap for PydxAI includes several ambitious goals:

  • Multimodal Intelligence: integrating radiology images, lab data, and EHR text.
  • Voice-to-Text Integration: real-time clinical dictation with structured summaries.
  • Federated Training: enabling hospitals to contribute to shared model improvements without sharing raw data.
  • Explainable Visual Output: flowcharts, lab graphs, and pathophysiological reasoning trees.

Each goal moves toward a central vision: a learning system that grows with medicine, understands context, and supports every clinician, researcher, and student.

A Message from the Developer

“MIKAI was my first step toward building an AI that truly understands medicine — not as data, but as care. PydxAI is the next evolution of that dream: to make intelligent diagnosis, adaptive reasoning, and continuous learning part of everyday medical life.”

— Dr. Kijakarn Junda, Developer of PydxAI

The Evolution of MIKAI: How We Built a Smarter RAG-Powered AI Assistant

When I first set out to build MIKAI, my goal was simple: a personal AI assistant capable of managing medical knowledge, learning from interactions, and providing intelligent responses in Thai and English. But achieving that goal demanded more than just a large language model — it required memory, context, reasoning, and the ability to pull in external knowledge when needed. That’s where the Retrieval-Augmented Generation (RAG) methodology came in.

The Early Days: Memory Without Structure

In the beginning, MIKAI relied on basic local memory and a single LLM. The model could answer questions based on its training, but it struggled with continuity across sessions and nuanced technical queries. I realized that without a structured way to recall prior conversations and integrate external sources, MIKAI would hallucinate or repeat mistakes.

The first iteration used a Postgres database with pgvector for storing embeddings of past interactions. Every user query was embedded, and cosine similarity was used to pull semantically similar prior exchanges. This approach gave MIKAI a sense of continuity — it could “remember” previous sessions — but there were limitations. Embeddings alone cannot capture subtle medical nuances, and context retrieval often included irrelevant or redundant information.

Introducing the RAG Pipeline

To address these challenges, we implemented a full RAG pipeline. At its core, MIKAI now uses a hybrid system: a combination of local memory (Postgres/pgvector) and external knowledge bases (via Qdrant) to provide answers grounded in both past experience and curated content.

The pipeline begins with Query Preprocessing. Using front_llm.sharpen_query(query), MIKAI cleans and rewrites incoming questions while detecting the user’s language. This ensures that ambiguous queries are clarified before retrieval.

Next comes Embedding + Memory Retrieval. The sharpened query is converted into a vector embedding (self.embeddings.embed_query) and compared against session and global memory using memory_manager.retrieve_similar(). This allows MIKAI to fetch the most semantically relevant past interactions.

For external knowledge, Retriever Manager queries Qdrant collections based on keywords and context. For instance, if a user asks about a rare endocrine disorder, MIKAI identifies the appropriate collection (data_kb, hospital guidelines, research articles) and retrieves top-matching documents. Deduplication ensures that the top-3 documents are formatted into concise snippets for context fusion.

Context Fusion and Professor Mode

A crucial innovation in MIKAI is Context Fusion. Instead of simply concatenating memory and external documents, the system merges:

  • Previous bot responses and user turns from local memory.
  • Retrieved documents from Qdrant.
  • Optional condensed summaries generated via memory_manager.condense_memory().

This combined context then enters Professor Mode, an extra reasoning layer (llm_manager.run_professor_mode()) where the model structures and interprets the context before generating a final answer. This step ensures that MIKAI doesn’t just regurgitate text but synthesizes a coherent response grounded in all available knowledge.

Finally, LLM Answer Generation (llm_manager.generate_rag_response) produces the answer. Clean-up steps remove repeated phrases, and optional back-translation ensures consistency if the query is not in English. If local memory or external knowledge fails to provide sufficient context, MIKAI can run a Web Search Fallback via DuckDuckGo, integrating the results into a regenerated answer.

Strengths of MIKAI’s RAG Approach

This pipeline has several notable strengths:

  • Dual Memory System: By combining local memory with external knowledge bases, MIKAI balances continuity with factual accuracy.
  • Condensation Step: Reduces irrelevant context and prevents context overflow in long conversations.
  • Professor Mode: Adds reasoning and structure, transforming raw data into coherent, context-aware answers.
  • Web Fallback: Ensures coverage even when the knowledge base lacks specific information.
  • Importance Scoring & Scopes: Allows prioritization of critical knowledge over less relevant information.

These features make MIKAI more robust than a standard LLM and help maintain reliability in medical or technical domains.

Challenges and Limitations

Despite these strengths, the current system isn’t perfect:

  • Embedding-Only Retrieval: Cosine similarity can drift for nuanced queries, potentially retrieving partially relevant memories.
  • Echoing Past Mistakes: Using prior bot answers as context can propagate errors.
  • Context Injection Gaps: generate_rag_response() currently seems to receive only the query, not the fully curated context, which may bypass context fusion benefits.
  • Shallow Deduplication: Only compares first 200 characters of documents, risking subtle repetition.
  • No Re-Ranking Across Sources: Memory and KB results are joined but not scored against each other for relevance.

Addressing these limitations will require passing the final fused context into the generation step, adding a re-ranking layer (e.g., BM25 or cross-encoder), and separating bot memory from external documents to prevent hallucinations.

MIKAI RAG in Practice

In practical use, MIKAI’s RAG system allows multiturn medical consultations, Thai-English language support, and intelligent reasoning over both past interactions and curated external knowledge. A patient can ask about leg edema, for example, and MIKAI retrieves previous session history, relevant hospital documents, and research articles, fusing them into a coherent explanation. If needed, it can augment its answer with a web search.

This pipeline has also enabled continuous learning. Every interaction is stored with embeddings and metadata (session/global/correction), allowing MIKAI to refine its memory, track repetition, and avoid redundant or low-quality responses over time.

The Road Ahead

Looking forward, the next steps for MIKAI involve:

  • Ensuring final context injection into the generation step.
  • Adding cross-source re-ranking to select the most relevant information.
  • Improving deduplication and similarity scoring.
  • Expanding external knowledge integration beyond Qdrant to include specialized medical databases and real-time research feeds.

The goal is to make MIKAI a fully reliable, continuously learning assistant that synthesizes knowledge across multiple modalities and timeframes.

Conclusion

From its early days as a simple memory-enabled LLM to today’s RAG-powered, professor-mode-enhanced assistant, MIKAI’s journey reflects the evolution of AI beyond static knowledge. By combining embeddings, vector databases, context fusion, reasoning layers, and web fallback, MIKAI demonstrates how a thoughtful RAG system can transform an LLM into a domain-aware, multiturn, multilingual assistant.

While challenges remain — especially around context injection and re-ranking — the framework is robust enough to provide continuity, accuracy, and intelligent reasoning in complex domains like medicine. As MIKAI continues to evolve, it promises to become an indispensable companion for knowledge work, patient consultation, and dynamic learning.