Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registering experimaestro IR library #622

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions docs/hub/experimaestro-ir.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Using experimaestro-IR at Hugging Face

`experimaestro-IR` is an open-source toolkit for neural information retrieval models. It allows using and building experiments around those models, with a focus on reusable components. More up-to-date documentation can be found on the [experimaestro-IR pre-trained model documentation page](https://experimaestro-ir.readthedocs.io/en/latest/pretrained.html).

## Exploring experimaestro-IR in the Hub

You can find `experimaestro-IR` models by filtering at the left of the [models page](https://huggingface.co/models?library=xpmir).

All models on the Hub come up with useful features:
1. An automatically generated model card with a description and metrics on IR datasets;
2. Metadata tags that help for discoverability.


## Install the library
To install the `experimaestro-IR` library, you can use pip:

```sh
pip install experimaestro-ir
```

## Using existing models

You can simply download a model from the Hub using `xpmir.models.AutoModel`.
Thanks to the [experimaestro framework](https://github.com/experimaestro/experimaestro-python),
you can either use models in your own experiments or in pure inference mode.

### As experimental models

In this mode, you can reuse the model in your experiments -- e.g. to compare this model
with your own, or using it in a complex IR pipeline (e.g. distillation). Please
refer to the [experimaestro-IR documentation](https://experimaestro-ir.readthedocs.io/)
for more details.

```py
from xpmir.models import AutoModel

# Model that can be re-used in experiments
model = AutoModel.load_from_hf_hub("xpmir/monobert")
```

### Pure inference mode

In this mode, the model can be used right away to score documents

```py
from xpmir.models import AutoModel

# Use this if you want to actually use the model
model = AutoModel.load_from_hf_hub("xpmir/monobert", as_instance=True)
model.initialize(None)
model.rsv("walgreens store sales average", "The average Walgreens salary ranges...")
```


## Sharing your models

You can easily upload your models using `AutoModel.push_to_hf_hub`:

```
from xpmir.models import AutoModel

AutoModel.push_to_hf_hub(model, readme=readme_md)
```

## Additional resources

* Experimaestro-IR [documentation](https://experimaestro-ir.readthedocs.io/en/latest/pretrained.html)
* Experimaestro-IR [huggingface integration documentation](https://experimaestro-ir.readthedocs.io/en/latest/pretrained.html)
1 change: 1 addition & 0 deletions docs/hub/models-libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The table below summarizes the supported libraries and their level of integratio
| [Asteroid](https://github.com/asteroid-team/asteroid) | Pytorch-based audio source separation toolkit | ✅ | ✅ | ✅ | ❌ |
| [docTR](https://github.com/mindee/doctr) | Models and datasets for OCR-related tasks in PyTorch & TensorFlow | ✅ | ✅ | ✅ | ❌ |
| [ESPnet](https://github.com/espnet/espnet) | End-to-end speech processing toolkit (e.g. TTS) | ✅ | ✅ | ✅ | ❌ |
| [experimaestro IR](https://github.com/experimaestro/experimaestro-ir) | Library for (neural) information retrieval | ❌ | ❌ | ✅ | ✅ |
| [fastai](https://github.com/fastai/fastai) | Library to train fast and accurate models with state-of-the-art outputs. | ✅ | ✅ | ✅ | ✅ |
| [Keras](https://huggingface.co/docs/hub/keras) | Library that uses a consistent and simple API to build models leveraging TensorFlow and its ecosystem. | ❌ | ❌ | ✅ | ✅ |
| [Flair](https://github.com/flairNLP/flair) | Very simple framework for state-of-the-art NLP. | ✅ | ✅ | ✅ | ❌ |
Expand Down
22 changes: 22 additions & 0 deletions js/src/lib/interfaces/Libraries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export enum ModelLibrary {
"stable-baselines3" = "Stable-Baselines3",
"ml-agents" = "ML-Agents",
"pythae" = "Pythae",
"xpmir" = "Experimaestro IR"
}

export type ModelLibraryKey = keyof typeof ModelLibrary;
Expand Down Expand Up @@ -425,6 +426,21 @@ const pythae = (model: ModelData) =>

model = AutoModel.load_from_hf_hub("${model.id}")`;

const xpmir = (model: ModelData) => {
if (model.config?.variants?.length > 0) {
return `from xpmir.models import AutoModel

// Use a variant among:
// ${model.config.variants.join(", ")}
model = AutoModel.load_from_hf_hub("${model.id}", variant)`;
}

return `from xpmir.models import AutoModel

model = AutoModel.load_from_hf_hub("${model.id}")`;

}

//#endregion


Expand Down Expand Up @@ -587,5 +603,11 @@ export const MODEL_LIBRARIES_UI_ELEMENTS: Partial<Record<ModelLibraryKey, Librar
repoUrl: "https://github.com/clementchadebec/benchmark_VAE",
snippet: pythae,
},
"xpmir": {
btnLabel: "xpmir",
repoName: "xpmir",
repoUrl: "https://github.com/experimaestro/experimaestro-ir",
snippet: xpmir,
}
} as const;