API Overview#
ML Research Tools provides a Python API for all functionality available through the command line. This section documents the important classes and functions available for use in your own Python code.
Key Components#
Core#
The core module provides the foundation of the ML Research Tools package:
Config
- Configuration managementServiceProvider
- Service dependency injection systemBaseTool
- Base class for all toolsLLMClient
- Client for LLM API interaction
Cache#
The cache module provides utilities for caching function results:
RedisCache
- Redis-based caching implementationcached()
- Decorator for caching function results
Tools#
Various tool implementations for specific tasks:
ml_research_tools.tex.LatexGrammarTool
- LaTeX grammar checkingml_research_tools.doc.AskDocumentTool
- Document question answeringml_research_tools.exp.WandbDownloaderTool
- Weights & Biases run logs downloaderml_research_tools.kube.PodForwardTool
- Kubernetes pod port forwarding
Service Locator Pattern#
ML Research Tools uses a service locator pattern for dependency injection. The typical usage flow is:
Create a configuration object:
from ml_research_tools.core.config import Config config = Config.from_dict({ "llm": { "default": "standard", "presets": { "standard": { "model": "gpt-3.5-turbo", "api_key": "your-api-key", "tier": "standard" } } } })
Set up the service provider:
from ml_research_tools.core.service_provider import ServiceProvider from ml_research_tools.core.service_factories import register_common_services services = ServiceProvider(config) register_common_services(services)
Create a tool instance with the service provider:
from ml_research_tools.tex import LatexGrammarTool tool = LatexGrammarTool(services)
Execute the tool:
import argparse args = argparse.Namespace(input_file="paper.tex", output="improved.tex") tool.execute(config, args)
Package Structure#
The package is organized into several modules:
ml_research_tools.core
- Core functionalityml_research_tools.cache
- Caching systemml_research_tools.tex
- LaTeX processing toolsml_research_tools.doc
- Document processing toolsml_research_tools.exp
- Experiment management toolsml_research_tools.kube
- Kubernetes tools