# Multi-word mask filling with inference API?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmulti-word-mask-filling-with-inference-api%2F17963%3E%5C
**Category:** Beginners\
**Created:** [May 14, 2022, 8:08pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmulti-word-mask-filling-with-inference-api%2F17963 "2022-05-14T20:08:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![latitude](https://avatars.discourse-cdn.com/v4/letter/l/41988e/32.png) [@latitude](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Flatitude)%5C
**Post date:** [May 14, 2022, 8:08pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmulti-word-mask-filling-with-inference-api%2F17963%2F1 "2022-05-14T20:08:11Z")

</div>

I’m trying to use the Inference API to fill in multiple words in a mask at once. I have done this in the past in Python with the T5 model, where you have to specify the maximum number of tokens that may fill in the mask:

```auto
outputs = t5_mlm.generate(input_ids=input_ids, 
                          num_beams=200, num_return_sequences=20,
                          max_length=5)

```

But I don’t see any way to do that in the Inference API. I can generate single-word mask fills with bert-base-uncased:

```auto
import fetch from "node-fetch";
async function query(data) {
    const response = await fetch(
        "/static-proxy?url=https%3A%2F%2Fapi-inference.huggingface.co%2Fmodels%2Fbert-base-uncased",
        {
            headers: { Authorization: `Bearer ${API_TOKEN}` },
            method: "POST",
            body: JSON.stringify(data),
        }
    );
    const result = await response.json();
    return result;
}
query({inputs:"The answer to the universe is [MASK]."}).then((response) => {
    console.log(JSON.stringify(response));
});

```

But I don’t see how to put in max\_length, if it is possible at all.  
I also considered T0pp, which has an Inference API endpoint, but I can’t get it to generate anything that makes sense for filling in a mask at all.

---

<div class="post-metadata">

**Author:** ![franfram](https://avatars.discourse-cdn.com/v4/letter/f/c6cbf5/32.png) [@franfram](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ffranfram)%5C
**Post date:** [October 17, 2022, 2:34pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmulti-word-mask-filling-with-inference-api%2F17963%2F2 "2022-10-17T14:34:58Z")

</div>

Hey, I have the same problem. Did you manage to solve it?
