Morphik Core
repository·main·Indexed 25 days ago
https://github.com/morphik-org/morphik-coreAn 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.
What's inside morphik-core
- 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.
Self-host Morphik Core
mainMorphik Core can be self-hosted via direct installation or Docker. Detailed instructions for self-hosting can be found in the official documentation at https://dev.morphik.ai/docs/getting-started. Note that full support is not guaranteed for self-hosted deployments.Evaluate a knowledge graph with evaluate_result.py
mainUse the
evaluate_result.pyscript to evaluate a previously created graph against the SciER ground truth. You must provide the--graph-nameproduced during the creation step.python evaluate_result.py --graph-name scier_gpt4o_12345678Format Python code manually
mainTo manually format all Python files in the project using the project's standard toolchain (
isort,black, andruff), execute theformat.shscript located in thescripts/directory. This ensures consistency with the automated pre-commit hooks../scripts/format.shDisable Morphik Telemetry
mainMorphik logs operational metadata (operation name, status, duration, and token counts) tologs/telemetry/and periodically uploads JSONL files tohttps://logs.morphik.ai. To disable telemetry in your local environment, set theTELEMETRYenvironment variable tofalse.Develop with @morphik/ui locally
mainTo run the
@morphik/uiproject in development mode:- Install dependencies:
npm install- Start the development server:
npm run devOpen http://localhost:3000 in your browser.
Connect to your Morphik server using a URI obtained from the
/local/generate_uriendpoint.
npm install npm run devInstall and run Morphik Core via Docker Compose
mainTo 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:
- Clone the repository and enter the directory.
- Run the build command to initialize all services, including PostgreSQL (with pgvector) and Ollama (with
nomic-embed-textandllama3.2models). - Use standard compose commands for lifecycle management.
Note: If you use the
uiprofile, you must include--profile uiwhen 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 -vUse a custom morphik.toml in Docker
mainTo apply a custom configuration file to the
morphikservice, mount your local file into the container via thedocker-compose.ymlvolumes section.services: morphik: volumes: - ./my-custom-morphik.toml:/app/morphik.tomlRun the Financial Document RAG Evaluation
mainTo evaluate a RAG system using the framework, follow these three steps:
- Run Evaluation: Execute the system implementation to generate raw answers. For the Morphik implementation, run
python morphik_eval.py. This producesmorphik_results.csv. - 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). - 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- Run Evaluation: Execute the system implementation to generate raw answers. For the Morphik implementation, run
Create a knowledge graph with scier_evaluation.py
mainRun the
scier_evaluation.pyscript to generate a knowledge graph. Upon completion, the script will output a specific graph name (e.g.,scier_gpt4o_12345678) which is required for the evaluation step.python scier_evaluation.py --model-name gpt4oInitialize the Morphik client
mainYou can initialize theMorphikclient for synchronous usage orAsyncMorphikfor asynchronous usage. By default, it connects tolocalhost:8000. For self-hosted or production environments, provide a direct HTTP(S) URL or an authentication URI.Build @morphik/ui for production
mainTo build and start the
@morphik/uiapplication for a production environment, use the following commands:npm run build npm start