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

TypeError: tuple indices must be integers or slices, not tuple #18

Open
fakerybakery opened this issue Feb 10, 2024 · 1 comment
Open

Comments

@fakerybakery
Copy link

Hi,
Sorry if I'm missing something but I'm getting the error TypeError: tuple indices must be integers or slices, not tuple.
My code is:

import torch
from torch import Tensor

from self_rewarding_lm_pytorch import (
    SelfRewardingTrainer,
    create_mock_dataset
)

from x_transformers import TransformerWrapper, Decoder
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('distilgpt2')
tokenizer = AutoTokenizer.from_pretrained('distilgpt2')

sft_dataset = create_mock_dataset(10, lambda: (torch.randint(0, 256, (256,)), torch.tensor(1)))
prompt_dataset = create_mock_dataset(10, lambda: 'mock prompt')

def decode_tokens(tokens: Tensor) -> str:
    return tokenizer.decode(tokens)

def encode_str(seq_str: str) -> Tensor:
    return tokenizer(seq_str, return_tensors='pt')['input_ids'][0]

trainer = SelfRewardingTrainer(
    model.transformer,
    finetune_configs = dict(
        train_sft_dataset = sft_dataset,
        self_reward_prompt_dataset = prompt_dataset,
        dpo_num_train_steps = 1000
    ),
    tokenizer_decode = decode_tokens,
    tokenizer_encode = encode_str,
    accelerate_kwargs = dict(

    )
)

trainer(overwrite_checkpoints = True)

Thanks

@ViswanathaReddyGajjala
Copy link
Contributor

Could you share the error log for assistance? It's hard to provide guidance without more details. Thanks!

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