marker icon indicating copy to clipboard operation
marker copied to clipboard

marker_server should support --use_llm and related arguments

Open gahoo opened this issue 6 months ago • 3 comments

It would be great if marker_server could support --use_llm --llm_service and other arguments.

gahoo avatar May 28 '25 09:05 gahoo

Has this been added yet? or is there any workaround to get the llm feature to run with marker_server as of now?

AshishRam7 avatar Jul 04 '25 06:07 AshishRam7

You might be able to monkey patch it until the change lands in master:

#!/usr/bin/env python3
"""
Patched marker_server with --use_llm support
Run this instead of marker_server to get LLM support
"""

import sys
import click

# Monkey patch before importing marker modules
def patch_config_parser():
    """Patch ConfigParser to add use_llm option"""
    from marker.config import parser
    
    original_common_options = parser.ConfigParser.common_options
    
    @staticmethod  
    def patched_common_options(fn):
        # Apply original options
        fn = original_common_options(fn)
        
        # Add use_llm option
        fn = click.option(
            "--use_llm",
            is_flag=True,
            default=False,
            help="Use LLM to improve marker quality. Requires LLM backend configuration."
        )(fn)
        
        fn = click.option(
            "--redo_inline_math", 
            is_flag=True,
            default=False,
            help="Use LLM to redo inline math (requires --use_llm)."
        )(fn)
        
        fn = click.option(
            "--force_ocr",
            is_flag=True,
            default=False,
            help="Force OCR on all pages."
        )(fn)
        
        return fn
    
    parser.ConfigParser.common_options = patched_common_options

# Apply the patch
patch_config_parser()

# Now import and run the server with patched config
from marker.scripts.server import server_cli

if __name__ == "__main__":
    # Add use_llm to the CLI arguments if needed
    # This allows the server_cli to accept the new options
    server_cli()

gardner avatar Aug 23 '25 04:08 gardner

replaced content of marker_server.py with your code but

didn't work for me still

Usage: marker_server.py [OPTIONS] Try 'marker_server.py --help' for help.

Error: No such option: --use_llm

smartmindkw avatar Aug 23 '25 19:08 smartmindkw