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

Index Issue #27

Closed
DhavalTaunk08 opened this issue Sep 22, 2023 · 1 comment
Closed

Index Issue #27

DhavalTaunk08 opened this issue Sep 22, 2023 · 1 comment

Comments

@DhavalTaunk08
Copy link

DhavalTaunk08 commented Sep 22, 2023

I was trying to run the example notebook generate_text.ipynb. But ran into the following error.

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)

[<ipython-input-10-bc7211cfb8f8>](https://localhost:8080/#) in <cell line: 5>()
      3 
      4 # Let's pass our prompt right back in, but this time using ALICE
----> 5 response = alice(prompt, classifier, endpoint_url, secret_key, mode="hate") # Switch mode to "hate" to generate hate

5 frames

[/usr/local/lib/python3.10/dist-packages/toxigen/utils.py](https://localhost:8080/#) in alice(prompt, classifier, endpoint_url, api_key, mode, num_to_generate, device)
      5     language_model = ALICE(GPT3(endpoint_url=endpoint_url, apikey=api_key), classifier, mode, device="cpu")
      6 
----> 7     return [language_model(prompt) for _ in range(num_to_generate)]
      8 
      9 def label_annotations(annotated):

[/usr/local/lib/python3.10/dist-packages/toxigen/utils.py](https://localhost:8080/#) in <listcomp>(.0)
      5     language_model = ALICE(GPT3(endpoint_url=endpoint_url, apikey=api_key), classifier, mode, device="cpu")
      6 
----> 7     return [language_model(prompt) for _ in range(num_to_generate)]
      8 
      9 def label_annotations(annotated):

[/usr/local/lib/python3.10/dist-packages/toxigen/language_models.py](https://localhost:8080/#) in __call__(self, prompt)
     42 
     43     def __call__(self, prompt):
---> 44         return self.generate(prompt)
     45 
     46     def generate(self, prompt):

[/usr/local/lib/python3.10/dist-packages/toxigen/language_models.py](https://localhost:8080/#) in generate(self, prompt)
     49         else:
     50             flag = 1
---> 51         return beam_search(prompt, self.language_model, self.classifier, flag, self.device)

[/usr/local/lib/python3.10/dist-packages/toxigen/alice.py](https://localhost:8080/#) in beam_search(prompt, language_model, classifier, mode, device, end_token, weights, num_beams, vocab_size, max_length, length_penalty)
    126         full_names = [[list(x.keys()) for x in scores[i]] for i in range(num_beams)]
    127         scores = [[list(x.values()) for x in scores[i]] for i in range(num_beams)]
--> 128         scores_ = torch.Tensor([[[omit_(full_names[i][0][j], scores[i][0][j], stops, prompt) for j in range(len(scores[i][0]))]] for i in range(num_beams)])
    129         scores = scores_.view(num_beams * 1, vocab_size)
    130         full_names = list(itertools.chain.from_iterable(list(itertools.chain.from_iterable(full_names))))

[/usr/local/lib/python3.10/dist-packages/toxigen/alice.py](https://localhost:8080/#) in <listcomp>(.0)
    126         full_names = [[list(x.keys()) for x in scores[i]] for i in range(num_beams)]
    127         scores = [[list(x.values()) for x in scores[i]] for i in range(num_beams)]
--> 128         scores_ = torch.Tensor([[[omit_(full_names[i][0][j], scores[i][0][j], stops, prompt) for j in range(len(scores[i][0]))]] for i in range(num_beams)])
    129         scores = scores_.view(num_beams * 1, vocab_size)
    130         full_names = list(itertools.chain.from_iterable(list(itertools.chain.from_iterable(full_names))))

IndexError: list index out of range
------------------------------------------------------------------------------------------------------------------------------------------------------------

Can you please tell me the how to resolve the error?

@Thartvigsen
Copy link
Collaborator

@DhavalTaunk08 did you figure this error out? I believe others have found the same error

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

2 participants