Skip to main content

Overview

NL2FOL provides utilities to process datasets of natural language statements for logical fallacy detection. This guide shows you how to work with built-in datasets and create your own.

Dataset Structure

Datasets in NL2FOL use a simple CSV format with the following columns:
string
required
The natural language statement or argument to analyze
integer
required
Binary label: 0 for logical fallacy, 1 for valid logical reasoning
string
Alternative field name for the text content (merged with articles)
string
Alternative field name for the text content (merged with articles)

Built-in Datasets

NL2FOL includes several pre-configured datasets in the data/ directory:

Logic Fallacies

File: data/fallacies.csvGeneral logical fallacies from various domains with labeled fallacy types.

Climate Fallacies

File: data/fallacies_climate.csvClimate change-related arguments with identified logical fallacies.

NLI Fallacies

File: data/nli_fallacies_test.csvNatural Language Inference-based fallacious reasoning examples.

NLI Entailments

File: data/nli_entailments_test.csvValid logical entailments for comparison and evaluation.

Using Built-in Datasets

The setup_dataset() function (defined in src/nl_to_fol.py:389) loads and prepares datasets:

Available Dataset Types

General logical fallacies dataset
Loads from data/fallacies.csv and data/nli_entailments_test.csv, creating a balanced dataset with:
  • 100 fallacious arguments (label=0)
  • 100 valid arguments (label=1)

Processing a Dataset

Here’s a complete example of processing a dataset:
process_dataset.py
The setup_dataset() function automatically balances the dataset by sampling an equal number of fallacies and valid arguments.

Creating Custom Datasets

1

Prepare your CSV file

Create a CSV file with the required columns:
custom_fallacies.csv
2

Load your dataset

Use pandas to load and prepare your data:
3

Process your dataset

Use the same processing loop as shown above:

Batch Processing with Command Line

For large datasets, use the command-line interface:

Command-Line Arguments

string
required
Model name for text generation (gpt-4o, meta-llama/Llama-2-13b-hf, etc.)
string
required
HuggingFace model name for NLI (e.g., microsoft/deberta-large-mnli)
string
required
Name for the output CSV file (saved to results/{run_name}.csv)
integer
required
Number of examples to process from each class (total will be 2x this)
string
required
Dataset type: logic, logicclimate, nli, or folio

Output Format

Processed datasets are saved with the following additional columns:

Example Output

Dataset Statistics

Analyze your processed dataset:

Working with Multiple Datasets

Combine multiple datasets for comprehensive analysis:

Performance Considerations

Processing large datasets can be time-consuming:
  • GPT-4: ~15-20 seconds per example (API rate limits apply)
  • Llama 13B: ~5-10 seconds per example (GPU-dependent)
For a 1000-example dataset:
  • GPT-4: ~4-6 hours
  • Llama 13B: ~2-3 hours

Optimization Tips

1

Batch processing

Process datasets in smaller batches and save intermediate results:
2

Enable multiprocessing

For Llama models, process multiple examples in parallel if you have multiple GPUs.
3

Cache results

Store intermediate results to avoid reprocessing on failures:
4

Use debug mode selectively

Only enable debug=True for troubleshooting, not production runs.

Next Steps

SMT Solving

Convert logical forms to SMT and verify with CVC5

Evaluation

Measure accuracy and performance metrics

Model Backends

Choose the right model for your dataset

API Reference

Explore advanced configuration options