# Using Bloom with detailed parameters?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-bloom-with-detailed-parameters%2F20171%3E%5C
**Category:** Models\
**Created:** [July 9, 2022, 7:08am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-bloom-with-detailed-parameters%2F20171 "2022-07-09T07:08:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![YagCed](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/yagced/32/5207_2.png) [@YagCed](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FYagCed)%5C
**Post date:** [July 9, 2022, 7:08am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-bloom-with-detailed-parameters%2F20171%2F1 "2022-07-09T07:08:31Z")

</div>

Hello,

Newbie here, so my apologies if this is a stupid question or if i post in the wrong section.

I’m trying to use the bloom model through inference api and it works well, but when i try to add some parameters (from the detailed parameters list in the text generation category), i get this error:  
{‘error’: ‘Parameters are not accepted for this specific model’}

```auto
import requests

API_URL = "/static-proxy?url=https%3A%2F%2Fapi-inference.huggingface.co%2Fmodels%2Fbigscience%2Fbloom"
#API_URL = "/static-proxy?url=https%3A%2F%2Fapi-inference.huggingface.co%2Fmodels%2Fgpt2"

headers = {"Authorization": " ****"}

def query(payload):
    response = requests.post(API_URL, headers=headers, json=payload)
    return response.json()

prompt = "Hi i am an AI and "

output = query({
    "inputs": prompt,
    "parameters": {"max_new_tokens": 50, "return_full_text": False}
})

print(output)
#print(output[0]["generated_text"])

```

This code works well (and the parameters are taken into account) when tried on gpt2, but fails on Bloom.

Am i doing anything wrong ?

Thanks  
Cedric

---

<div class="post-metadata">

**Author:** ![roschmid](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/roschmid/32/5358_2.png) [@roschmid](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Froschmid)%5C
**Post date:** [July 13, 2022, 7:45pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-bloom-with-detailed-parameters%2F20171%2F2 "2022-07-13T19:45:46Z")

</div>

It worked for me.

```auto
import requests

TOKEN = "Bearer <INSERT YOUR TOKEN HERE>"

API_URL = "/static-proxy?url=https%3A%2F%2Fapi-inference.huggingface.co%2Fmodels%2Fbigscience%2Fbloom"
headers = {"Authorization": TOKEN}

def query(payload):
	response = requests.post(API_URL, headers=headers, json=payload)
	return response.json()

while True:

    text_input = input("Insert your input: ")
            
    output = query({
            "inputs": text_input,
            "parameters": {"max_new_tokens": 10,
                           "return_full_text": False}
    })

    print(output)

```

---

<div class="post-metadata">

**Author:** ![RylanSchaeffer](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@RylanSchaeffer](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FRylanSchaeffer)%5C
**Post date:** [July 13, 2022, 8:27pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-bloom-with-detailed-parameters%2F20171%2F3 "2022-07-13T20:27:41Z")

</div>

@roschmid , when I try this, I receive `{'error': "Authorization header is invalid, use 'Bearer API_TOKEN'"}`

Maybe you meant `headers = {"Authorization": f"Bearer {API_TOKEN}"}?`

---

<div class="post-metadata">

**Author:** ![roschmid](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/roschmid/32/5358_2.png) [@roschmid](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Froschmid)%5C
**Post date:** [July 13, 2022, 10:18pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-bloom-with-detailed-parameters%2F20171%2F4 "2022-07-13T22:18:56Z")

</div>

@RylanSchaeffer You’re probably typing wrong your API Token.

It has to go with the “Bearer” part.

E.g. TOKEN = “Bearer 4EgJlma91939” (this is a made up Token, btw).

---

<div class="post-metadata">

**Author:** ![RylanSchaeffer](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@RylanSchaeffer](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FRylanSchaeffer)%5C
**Post date:** [July 14, 2022, 1:47am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-bloom-with-detailed-parameters%2F20171%2F5 "2022-07-14T01:47:32Z")

</div>

I don’t think `TOKEN = “Bearer 4EgJlma91939”` is a token. Rather, you’ve preappended `Bearer` to the actual token (in your example, the actual token is `4EgJlma91939`).

---

<div class="post-metadata">

**Author:** ![YagCed](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/yagced/32/5207_2.png) [@YagCed](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FYagCed)%5C
**Post date:** [July 14, 2022, 5:26am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-bloom-with-detailed-parameters%2F20171%2F6 "2022-07-14T05:26:49Z")

</div>

Hi @roschmid

Thanks for your answer.  
I wanted to try your code and first relaunched my script to ensure the error was still occuring with my code before trying yours, but it didn’t: now my old code works too !  
I guess they must have fixed something internally.  
Anyway, thanks a lot for taking the time to answer me, i marked you answer as a solution, although, for anyone bumping here, the code from the initial post works too.

Rgds  
Cedric

---

<div class="post-metadata">

**Author:** ![roschmid](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/roschmid/32/5358_2.png) [@roschmid](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Froschmid)%5C
**Post date:** [July 14, 2022, 1:09pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-bloom-with-detailed-parameters%2F20171%2F7 "2022-07-14T13:09:15Z")

</div>

I got your point. Fixed it.

---

<div class="post-metadata">

**Author:** ![ahomosapiens](https://avatars.discourse-cdn.com/v4/letter/a/b5e925/32.png) [@ahomosapiens](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fahomosapiens)%5C
**Post date:** [August 21, 2022, 10:37am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-bloom-with-detailed-parameters%2F20171%2F8 "2022-08-21T10:37:19Z")

</div>

Thanks for the posts. I’m trying to add some parameters to a cURL request. Somehow it seems the parameters I’m trying to add are getting mixed up into the input string. It could be some kind of syntax error but I can’t see where I’m doing it wrong.

This works:

```auto
curl /static-proxy?url=https%3A%2F%2Fapi-inference.huggingface.co%2Fmodels%2Fbigscience%2Fbloom \
-X POST \
-d '{"inputs": "Two plus two equals "}' \
-H "Authorization: Bearer TOKEN"

```

yielding the output

`[{"generated_text":"Two plus two equals four.\nTwo plus two equals four.\nTwo plus two equals four.\nTwo plus two equals"}]`

However, when adding parameters, it seems that this code results in the attempted parameters being mixes up into the input text:

```auto
curl /static-proxy?url=https%3A%2F%2Fapi-inference.huggingface.co%2Fmodels%2Fbigscience%2Fbloom \
-X POST \
-d '{"inputs": "Two plus two equals", "parameters": {"max_new_tokens": 50, "return_full_text": False} }' \
-H "Authorization: Bearer TOKEN"

```

Resulting in this output:

```auto
[{"generated_text":"{\"inputs\": \"Two plus two equals\", \"parameters\": {\"max_new_tokens\": 50, \"return_full_text\": False} }\n# }\n# return json.dumps(json_data)\n\n# def get_tokens"}]

```

Maybe I just need a delimiter somewhere or the like?

If someone can help me fix this I would be really appreciative. Thanks.

---

<div class="post-metadata">

**Author:** ![AFischer1985](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@AFischer1985](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FAFischer1985)%5C
**Post date:** [February 18, 2023, 1:11pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-bloom-with-detailed-parameters%2F20171%2F9 "2023-02-18T13:11:12Z")

</div>

This way the request seems to work:

```auto
model_id="bigscience/bloom" 
payload="Two plus two equals"
params='{"max_new_tokens": 50, "return_full_text":false}'
url="/static-proxy?url=https%3A%2F%2Fapi-inference.huggingface.co%2Fmodels%2F"$model_id
data='{"inputs":"'$payload'","parameters":'$params'}'
post=$(curl -X POST $url -H "Content-Type: application/json" --data-raw "$data")
echo $post

```
