I am using GPT2 for text generation.
However, for any given prompt, the response is always the same.
For example, for the prompt: āThe answer to the universe isā ⦠the response is always: "The answer to the universe is not in the right directions to set an orbit around, but instead on a flat platform with plenty of space to spread Earthly planets and other planets. You still find the answer here at the end of the article of lifeā¦
How can I change this each time I run my code?
import json
import requests
headers = {āAuthorizationā: f"Bearer MYAPI"}
API_URL = āhttps://api-inference.huggingface.co/models/gpt2ā
def query(payload):
data = json.dumps(payload)
response = requests.request(āPOSTā, API_URL, headers=headers, data=data)
return json.loads(response.content.decode(āutf-8ā))
data = query({āinputsā: āThe answer to the universe isā})
print(data[0][āgenerated_textā])