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

[Question]: UTC 微調後,使用 Taskflow 與 PromptModelForSequenceClassification 結果不一樣 #9063

Open
hsiehbocheng opened this issue Aug 31, 2024 · 0 comments
Assignees
Labels
question Further information is requested

Comments

@hsiehbocheng
Copy link

hsiehbocheng commented Aug 31, 2024

请提出你的问题

使用 PromptModelForSequenceClassification 微調了 utc
後續用兩種方法做預測
分別為 1. 參考 train 使用PromptModelForSequenceClassification 與 2. 參考文件使用 Taskflow 結果不一樣

# 微調後的路徑
task_path = "fine-tuned-checkpoint


tokenizer = AutoTokenizer.from_pretrained("utc-base")
model = UTC.from_pretrained("utc-base")
template = UTCTemplate(tokenizer, training_args.max_seq_length)

prompt_model = PromptModelForSequenceClassification(
    model, template, None, freeze_plm=True, freeze_dropout=True
)

model_state = paddle.load(os.path.join(task_path, "model_state.pdparams"))
prompt_model.set_state_dict(model_state)

trainer = PromptTrainer(
        model=prompt_model,
        tokenizer=tokenizer,
        args=infer_args,
        criterion=UTCLoss(),
        train_dataset=None,
        eval_dataset=None,
        callbacks=None,
    )

trainer.predict(test_ds)
# 2. 
cls = Taskflow("zero_shot_text_classification", 
               model="utc-base", 
               schema=choices, 
               task_path=task_path, 
               precision="fp32")

cls("my_text")

兩者結果不一樣,
其中 test_ds 格式為 {"text_a": "my_text", "text_b": "", choices: [a, b, c]}

@hsiehbocheng hsiehbocheng added the question Further information is requested label Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants