Skip to content

Conversation

@zeke
Copy link
Member

@zeke zeke commented May 1, 2025

This PR adds support the new HuggingFace tag mappings feature.

Tag mappings allow you to map multiple Hugging Face models to a single Replicate model based on their tags. This is useful when you have a single Replicate model that can handle multiple variations of a model (like different LoRA adapters).

Companion PR in the inference client:

@zeke zeke requested review from a team, daanelson, fofr, lucataco and zsxkib May 1, 2025 00:20
@zeke zeke changed the title add support tag mappings, starting with flux lora Add support for HF tag mappings, starting with Flux LoRA May 1, 2025
@zeke
Copy link
Member Author

zeke commented May 1, 2025

I ran this locally and it looks like it worked! ⚡

$ npm start

...

Replicate tag mappings:
[
  {
    type: 'tag-filter',
    task: 'text-to-image',
    tags: [ 'flux', 'lora' ],
    providerModel: 'black-forest-labs/flux-dev-lora',
    adapterType: 'lora',
    status: 'live'
  }
]


Adding tag mappings:
flux, lora - live


Done!

Copy link

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/hf.ts Outdated
@@ -1,8 +1,11 @@
interface MappingItem {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit-picking here but an interface like that would better describe the 2 only combinations that should be supported

interface ModelMappingItem {
  task: string;
  hfModel: string;
  providerModel: string;
  status?: 'live' | 'staging';
}

interface TagFilterMappingItem {
  task: string;
  providerModel: string;
  status?: 'live' | 'staging';
  type: 'tag-filter';
  tags: string[];
  adapterType: 'lora';
}

type MappingItem = ModelMappingItem | TagFilterMappingItem;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Updated here: 09e9d7b

@zeke zeke force-pushed the add-support-tag-mappings,-starting-with-flux-lora branch from e73a3cd to 54d23c0 Compare May 1, 2025 23:06
@zeke zeke merged commit 1411409 into main May 1, 2025
hanouticelina added a commit to huggingface/huggingface.js that referenced this pull request May 5, 2025
This PR updates the `ReplicateTextToImageTask` method to support running
arbitrary LoRAs on Replicate.

How it works:

1. Detect LoRAs by their tags before inference.
2. Use https://replicate.com/black-forest-labs/flux-dev-lora for
inference
3. Use the requested LoRA as the `weights_url` input to the
flux-dev-lora model

## Companion PR

- replicate/huggingface-model-mappings#9


## Testing

Remove the `skip` from `describe.skip("InferenceClient" ...` in
InferenceClient.spec.ts

Then: 
```
$ pnpx vitest run --config vitest.config.mts -t "Replicate"
```

---------

Co-authored-by: Simon Brandeis <[email protected]>
Co-authored-by: célina <[email protected]>
Co-authored-by: Lucain <[email protected]>
Deep-unlearning pushed a commit to huggingface/huggingface.js that referenced this pull request May 13, 2025
This PR updates the `ReplicateTextToImageTask` method to support running
arbitrary LoRAs on Replicate.

How it works:

1. Detect LoRAs by their tags before inference.
2. Use https://replicate.com/black-forest-labs/flux-dev-lora for
inference
3. Use the requested LoRA as the `weights_url` input to the
flux-dev-lora model

## Companion PR

- replicate/huggingface-model-mappings#9


## Testing

Remove the `skip` from `describe.skip("InferenceClient" ...` in
InferenceClient.spec.ts

Then: 
```
$ pnpx vitest run --config vitest.config.mts -t "Replicate"
```

---------

Co-authored-by: Simon Brandeis <[email protected]>
Co-authored-by: célina <[email protected]>
Co-authored-by: Lucain <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants