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 reasoningstring
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 thedata/ 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
Thesetup_dataset() function (defined in src/nl_to_fol.py:389) loads and prepares datasets:
Available Dataset Types
- logic
- logicclimate
- nli
- folio
General logical fallacies datasetLoads 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 folioOutput 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
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
