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

对于eval 的疑问 #181

Open
yangliuIOC opened this issue Jul 15, 2024 · 0 comments
Open

对于eval 的疑问 #181

yangliuIOC opened this issue Jul 15, 2024 · 0 comments

Comments

@yangliuIOC
Copy link

def preprocess_function_eval(examples):
    inputs, targets = [], []
    for i in range(len(examples[prompt_column])):
        if examples[prompt_column][i] and examples[response_column][i]:
            query = examples[prompt_column][i]
            history = examples[history_column][i] if history_column is not None else None
            prompt = tokenizer.build_prompt(query, history)
            inputs.append(prompt)
            targets.append(examples[response_column][i])

    inputs = [prefix + inp for inp in inputs]
    model_inputs = tokenizer(
        inputs, max_length=data_args.max_source_length, truncation=True, padding=True)
    labels = tokenizer(text_target=targets,
                       max_length=max_target_length, truncation=True)

    if data_args.ignore_pad_token_for_loss:
        labels["input_ids"] = [
            [(l if l != tokenizer.pad_token_id else -100) for l in label] for label in labels["input_ids"]
        ]
    model_inputs["labels"] = labels["input_ids"]

    return model_inputs

我按照您的写法(上述代码)的逻辑写了一个自己的,但是我发现,会报错,显示target和input的batch size的维度必须一样,简单来说就是必须一样长,我的eval的input是instruction +input ,label是 output,这样是否能eval,还是说 input和output都得是instruction+input+output

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

1 participant