Morphik Core

repository·main·Indexed 25 days ago

https://github.com/morphik-org/morphik-core

An AI-native multimodal retrieval engine for visually rich documents (PDFs, images, videos) that preserves visual context like charts and tables using techniques such as ColPali. It includes a Python SDK for document ingestion and RAG queries, a React-based UI component (@morphik/ui), and support for the Model Context Protocol (MCP). The suite provides tools for building retrieval and document understanding, including evaluation frameworks for financial document RAG and SciER scientific entity recognition.

Tokens
13.2K
Snippets
28
Records
140
Agent score
87%

What's inside morphik-core

  1. Access Morphik Core via Morphik Console

    main
    The Morphik Console is a web-based interface for users who prefer a GUI. It allows you to upload files, connect to various data sources, and chat with your data (ingest, search, and query) in a single interface.
  2. Format Python code manually

    main

    To manually format all Python files in the project using the project's standard toolchain (isort, black, and ruff), execute the format.sh script located in the scripts/ directory. This ensures consistency with the automated pre-commit hooks.

    ./scripts/format.sh
  3. Disable Morphik Telemetry

    main
    Morphik logs operational metadata (operation name, status, duration, and token counts) to logs/telemetry/ and periodically uploads JSONL files to https://logs.morphik.ai. To disable telemetry in your local environment, set the TELEMETRY environment variable to false.
  4. Install and run Morphik Core via Docker Compose

    main

    To set up Morphik Core locally, ensure you have Docker and Docker Compose installed, with at least 10GB of free disk space and 8GB+ RAM recommended.

    Follow these steps:

    1. Clone the repository and enter the directory.
    2. Run the build command to initialize all services, including PostgreSQL (with pgvector) and Ollama (with nomic-embed-text and llama3.2 models).
    3. Use standard compose commands for lifecycle management.

    Note: If you use the ui profile, you must include --profile ui when stopping services.

    # Clone and enter directory
    git clone https://github.com/morphik-org/morphik-core.git
    cd morphik-core
    
    # First-time setup (builds containers and downloads models)
    docker compose up --build
    
    # Subsequent runs
    docker compose up
    docker compose down
    
    # Completely reset (deletes all data and models)
    docker compose down -v
  5. Use a custom morphik.toml in Docker

    main

    To apply a custom configuration file to the morphik service, mount your local file into the container via the docker-compose.yml volumes section.

    services:
      morphik:
        volumes:
          - ./my-custom-morphik.toml:/app/morphik.toml
  6. Run the Financial Document RAG Evaluation

    main

    To evaluate a RAG system using the framework, follow these three steps:

    1. Run Evaluation: Execute the system implementation to generate raw answers. For the Morphik implementation, run python morphik_eval.py. This produces morphik_results.csv.
    2. Judge Results: Use an LLM judge to compare system answers against golden answers. Run python evaluate.py <results_file>.csv. This produces a judged CSV file (e.g., morphik_results_judged.csv).
    3. Analyze Results: Perform accuracy and error pattern analysis using python analyze_eval.py <judged_results_file>.csv.
    # 1. Run Morphik evaluation
    python morphik_eval.py
    
    # 2. Judge Results
    python evaluate.py morphik_results.csv
    
    # 3. Analyze Results
    python analyze_eval.py morphik_results_judged.csv