{"id":5662,"library":"model-index","title":"Papers with Code Model Index","description":"The model-index library helps machine learning researchers and engineers maintain a single source of truth for their ML model metadata. It allows storing metadata flexibly in JSONs, YAMLs, or markdown annotations, and enables browsing and comparing models on Papers with Code. The library is currently at version 0.1.11 and appears to have an active, though not rapid, release cadence.","status":"active","version":"0.1.11","language":"en","source_language":"en","source_url":"https://github.com/paperswithcode/model-index","tags":["machine-learning","metadata","papers-with-code","research","mlops"],"install":[{"cmd":"pip install model-index","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"Based on common Python package structure for data models. Explicit `models` submodule is standard for classes representing data schemas.","wrong":"from modelindex.index import ModelIndex","symbol":"ModelIndex","correct":"from modelindex.models import ModelIndex"}],"quickstart":{"code":"import os\nfrom pathlib import Path\nfrom modelindex.models import ModelIndex\n\n# 1. Create a dummy model-index.yml file for demonstration\nmodel_index_content = '''\nModels:\n  - Name: MyAwesomeModelV1\n    Metadata:\n      Task: Image Classification\n      Dataset: CIFAR-10\n      Metrics:\n        Accuracy: 0.92\n      Paper: https://arxiv.org/abs/2301.00001\n      Code: https://github.com/myuser/myawesomemodel\n      Weights: https://example.com/weights.pth\n      License: MIT\n  - Name: MyAwesomeModelV2\n    Metadata:\n      Task: Image Classification\n      Dataset: CIFAR-10\n      Metrics:\n        Accuracy: 0.94\n      Paper: https://arxiv.org/abs/2302.00002\n      Code: https://github.com/myuser/myawesomemodel\n      Weights: https://example.com/weights_v2.pth\n      License: Apache-2.0\n'''\n\nindex_file_path = \"model-index.yml\"\nPath(index_file_path).write_text(model_index_content)\n\nprint(f\"Created dummy {index_file_path}\")\n\ntry:\n    # 2. Load the model index from the YAML file\n    # Note: The exact loading method might vary; .load_from_file() is a common pattern.\n    # The library's core is parsing these files.\n    model_index = ModelIndex.load_from_file(index_file_path)\n\n    print(f\"\\nSuccessfully loaded {len(model_index.models)} model(s).\")\n\n    # 3. Access data from the loaded index\n    for i, model in enumerate(model_index.models):\n        print(f\"\\n--- Model {i+1} ---\")\n        print(f\"Name: {model.name}\")\n        print(f\"Task: {model.metadata['Task']}\")\n        print(f\"Accuracy: {model.metadata['Metrics']['Accuracy']}\")\n        print(f\"Paper: {model.metadata['Paper']}\")\n\nexcept Exception as e:\n    print(f\"An error occurred during loading or processing: {e}\")\nfinally:\n    # Clean up the dummy file\n    if Path(index_file_path).exists():\n        os.remove(index_file_path)\n        print(f\"\\nCleaned up {index_file_path}\")\n","lang":"python","description":"This quickstart demonstrates how to define a `model-index.yml` file and then programmatically load and inspect its contents using the `model-index` Python library. It highlights how the library facilitates reading structured model metadata into Python objects."},"warnings":[{"fix":"Ensure installation is `pip install model-index` and not `pip install modelindex`.","message":"The package name on PyPI is `model-index` (with a hyphen). An alias package `modelindex` (without a hyphen) exists but primarily serves as a dependency for `model-index`. Always use `pip install model-index` to ensure you get the correct, maintained library.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Carefully review the official `model-index` documentation and examples for required YAML schema and file linking conventions. Utilize the `mi` command-line tool (if available) for validation.","message":"The `model-index` library relies heavily on the correct structure and syntax of `model-index.yml` and referenced metadata files (YAML, JSON, Markdown). Incorrect formatting, broken relative paths, or non-adherence to the Papers with Code schema can lead to parsing errors or validation failures.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For basic usage, consider starting with the `model-index.yml` file approach and CLI tools. If programmatic generation or complex manipulation is needed, consult the library's source code or advanced documentation for API specifics.","message":"While a Python API exists for programmatic interaction (e.g., loading the index), much of the official documentation and usage examples emphasize defining metadata via `model-index.yml` files and processing them with the provided command-line interface (CLI) tool (`mi`). Explicit Python API quickstart examples for building an index programmatically from scratch are less prevalent.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}