模型:

q3fer/distilbert-base-fallacy-classification

英文

distilbert-base-fallacy-classification

这个模型是对 distilbert-base-uncased 在 Logical Fallacy Dataset 上进行微调的版本。

模型描述

这个模型是用于逻辑谬误的文本分类的微调模型。总共有14个类别:ad hominem、ad populum、appeal to emotion、circular reasoning、equivocation、fallacy of credibility、fallacy of extension、fallacy of logic、fallacy of relevance、false causality、false dilemma、faulty generalization、intentional和miscellaneous。

示例流程

from transformers import pipeline

text = "We know that the earth is flat because it looks and feels flat."
model_path = "q3fer/distilbert-base-fallacy-classification"
pipe = pipeline("text-classification", model=model_path, tokenizer=model_path)
pipe(text)
[{'label': 'circular reasoning', 'score': 0.951125979423523}]

完整分类示例

import torch
from transformers import AutoTokenizer
from transformers import AutoModelForSequenceClassification

model = AutoModelForSequenceClassification.from_pretrained("q3fer/distilbert-base-fallacy-classification")
tokenizer = AutoTokenizer.from_pretrained("q3fer/distilbert-base-fallacy-classification")

text = "We know that the earth is flat because it looks and feels flat."
inputs = tokenizer(text, return_tensors='pt')

with torch.no_grad():
  logits = model(**inputs)
  scores = logits[0][0]
  scores = torch.nn.Softmax(dim=0)(scores)

  _, ranking = torch.topk(scores, k=scores.shape[0])
  ranking = ranking.tolist()

results = [f"{i+1}) {model.config.id2label[ranking[i]]} {scores[ranking[i]]:.4f}" for i in range(scores.shape[0])]
print('\n'.join(results))
1) circular reasoning 0.9511
2) fallacy of logic 0.0154
3) equivocation 0.0080
4) fallacy of credibility 0.0069
5) ad populum 0.0028
6) fallacy of extension 0.0025
7) intentional 0.0024
8) faulty generalization 0.0021
9) appeal to emotion 0.0021
10) fallacy of relevance 0.0019
11) false dilemma 0.0017
12) ad hominem 0.0013
13) false causality 0.0012
14) miscellaneous 0.0004

训练和评估数据

用 Logical Fallacy Dataset 进行训练和评估。

Jin, Z., Lalwani, A., Vaidhya, T., Shen, X., Ding, Y., Lyu, Z., ... Schölkopf, B. (2022). Logical Fallacy Detection. arXiv. https://doi.org/10.48550/arxiv.2202.13758

训练过程

在微调期间使用了以下超参数:

  • learning_rate: 2e-5
  • warmup steps: 0
  • batch_size: 16
  • num_epochs: 8
  • batches_per_epoch: 122
  • total_train_steps: 976