xmc.dspy  by KarelDO

In-context learning for extreme multi-label classification

created 1 year ago
434 stars

Top 69.6% on sourcepulse

GitHubView on GitHub
Project Summary

This repository provides Infer-Retrieve-Rank (IReRa), a modular program for extreme multi-label classification (XMC) using in-context learning with large language models (LLMs) and retrievers. It targets researchers and practitioners needing to classify text into thousands or millions of categories with minimal labeled data, achieving state-of-the-art performance without fine-tuning.

How It Works

IReRa employs a novel "Infer-Retrieve-Rank" strategy, leveraging a teacher LLM to generate demonstrations for a student LLM. This approach optimizes a student model's performance on XMC tasks using only a few labeled examples. The system is built on the DSPy programming model, allowing users to customize components like LLMs, retrievers, and optimization strategies to balance cost and performance. LM calls are cached for reproducibility.

Quick Start & Requirements

  • Installation: Requires Python 3.10 and an experimental branch of DSPy. Clone DSPy, checkout a specific commit (802f2d5f26c1a64d8aad6adbd8b4394b9c4bb743), and install it, followed by pip install -r requirements.txt.
  • Prerequisites: OpenAI API key for OpenAI models. For local models, set up a Text Generation Interface (TGI) server and configure lm_config.json.
  • Data: Run bash scripts/load_data.sh and bash scripts/load_cache.sh.
  • Running: Use bash scripts/compile_left_to_right.sh or bash scripts/run_left_to_right.sh for pre-compiled results. Evaluate with python run_irera.py or compile and run with python compile_irera.py.
  • Resources: Official paper: arxiv.org/pdf/2401.12178.pdf.

Highlighted Details

  • Achieves state-of-the-art performance on XMC tasks with minimal labeled examples (≈50).
  • Modular design allows customization of LLMs, retrievers, and optimization strategies.
  • Caches LM calls to avoid re-inference costs for reproducibility.
  • Supports applying to new tasks by adding data loaders and custom signatures.

Maintenance & Community

The project is maintained by Karel D'Oosterlinck. Users can follow @KarelDoostrlnck on Twitter for updates. Contributions are welcomed via issues or pull requests.

Licensing & Compatibility

The repository does not explicitly state a license in the README. Compatibility for commercial use or closed-source linking is not specified.

Limitations & Caveats

The README notes that results from run_irera.py may differ slightly from compile_irera.py due to potential bugs in model loading/saving. The Optimizer class's awareness of program implementation details needs to be resolved for more flexible strategy application.

Health Check
Last commit

1 year ago

Responsiveness

1 week

Pull Requests (30d)
0
Issues (30d)
0
Star History
14 stars in the last 90 days

Explore Similar Projects

Starred by Stas Bekman Stas Bekman(Author of Machine Learning Engineering Open Book; Research Engineer at Snowflake).

HALOs by ContextualAI

0.2%
873
Library for aligning LLMs using human-aware loss functions
created 1 year ago
updated 2 weeks ago
Starred by Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems), Alex Cheema Alex Cheema(Cofounder of EXO Labs), and
1 more.

recurrent-pretraining by seal-rg

0.1%
806
Pretraining code for depth-recurrent language model research
created 5 months ago
updated 2 weeks ago
Starred by Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems), Georgios Konstantopoulos Georgios Konstantopoulos(CTO, General Partner at Paradigm), and
2 more.

maestro by roboflow

0.1%
3k
CLI/SDK for fine-tuning multimodal models
created 1 year ago
updated 5 days ago
Starred by Stas Bekman Stas Bekman(Author of Machine Learning Engineering Open Book; Research Engineer at Snowflake) and Travis Fischer Travis Fischer(Founder of Agentic).

lingua by facebookresearch

0.1%
5k
LLM research codebase for training and inference
created 9 months ago
updated 2 weeks ago
Feedback? Help us improve.