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

context_setting.completion error #9

Open
shivatmica opened this issue Sep 17, 2022 · 4 comments
Open

context_setting.completion error #9

shivatmica opened this issue Sep 17, 2022 · 4 comments

Comments

@shivatmica
Copy link

Hi,

I am getting the following error from context_setting.completion API.
I have tried both basic and adv example but similar issue.

Any pointers on how to resolve this?

Thanks!

/usr/lib/python3.7/json/decoder.py in raw_decode(self, s, idx)
353 obj, end = self.scan_once(s, idx)
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

=================================================================

My code based on your example:

from gpt_j.Basic_api import simple_completion

In the prompt enter something you want to generate

prompt = "def perfect_square(num):"

Max length of completion

Max = 200

Temperature controls the creativity of the model

A low temperature means the model will take less changes when completing a prompt

A high temperature will make the model more creative

Both temperature and top probability must be a float

temperature = 0.6

top probability is an alternative way to control the randomness of the model

top_probability = 1.0

top_k is the number of top responses to return

This is the number of responses the model will return

top_k = 1

Rep is the number of times the model will repeat itself

This is the number of times the model will repeat itself when generating a response

rep = 0.216

Here you set query equal to the desired values

Note values higher that 512 tend to take more time to generate

res = context_setting.completion(prompt,
user=User,
bot=Bot,
max_tokens=max_tokens,
temperature=temperature,
top_p=top_probability,
top_k=top_k,
rep=repetition)

Finally we print the result

print(res)

@shivatmica
Copy link
Author

pls ignore this. I found an alternate way to achieve this.

@TheProtaganist
Copy link
Owner

TheProtaganist commented Sep 21, 2022 via email

@NotJoshy11
Copy link

How did you fix it?

@NamburiSrinath
Copy link

NamburiSrinath commented Nov 3, 2022

Can you update how to fix this issue?

I am working on GPT-J to generate prompts and I am unable to run the code.

During handling of the above exception, another exception occurred:

I am getting the following error when I tried running python basic_usage_template.py and python advanced_usage_template.py

Traceback (most recent call last):
  File "/hdd2/srinath/gpt-j/advanced_usage_template.py", line 58, in <module>
    response = context_setting.completion(prompt,
  File "/hdd2/srinath/anaconda3/envs/SD_Aug/lib/python3.10/site-packages/gpt_j/gptj_api.py", line 67, in completion
    self.response = generate(f"{self.new_prompt} {user}: {self.main_intention}", token_max_length=max_tokens, temperature=temperature, top_p=top_p, top_k=top_k, rep=rep)
  File "/hdd2/srinath/anaconda3/envs/SD_Aug/lib/python3.10/site-packages/gpt_j/Gptj.py", line 12, in generate
    result = URL.json()
  File "/hdd2/srinath/anaconda3/envs/SD_Aug/lib/python3.10/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

My python version is 3.10.6

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

No branches or pull requests

4 participants