Skip to content

myeghaneh/ArgStanceNRC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ArgStance

ArgStance is a research project focused on Argumentative Stance Classification using emotion lexicons, with a particular emphasis on the extended NRC Emotion Lexicon. The project lies at the intersection of Argumentation Mining (AM) and Emotion Analysis, with a specific focus on the stance classification subtask within AM.

Extensive preprocessing was conducted to prepare the corpora. The results can be found in the data folder.

Table of Contents

Environment Setup

Prerequisites

  • Conda or Anaconda
  • Python 3.11+
  • CUDA-compatible GPU (optional, but recommended for faster training)

Installation Steps

  1. Clone the repository

    git clone <repository-url>
    cd ArgStanceNRC
  2. Create conda environment from environment.yml

    conda env create -f environment.yml
  3. Activate the environment

    conda activate enrc

Data

The preprocessed datasets are located in the data/ directory:

  • dfIBM_stance-v1.json
  • dfMT1_stance-v1.json
  • dfMT2_stance-v1.json
  • dfMT3_stance.json
  • dfPE_stance-v2.json
  • dfUKB_stance-v1.json

Usage

Training Stance Classifier

The main training script is src/train_stance_classifier.py. It supports various configurations:

Basic Training

# Train on UKB dataset with default settings
cd src
python train_stance_classifier.py --dataset UKB

# Train on PE dataset
python train_stance_classifier.py --dataset PE

Training with NRC Emotion Features

# Train with standard NRC features
python train_stance_classifier.py --dataset PE --use-nrc

# Train with expandNRC features
python train_stance_classifier.py --dataset PE --use-enrc --threshold 0.8

Training without NRC Features

# Train without emotion features (baseline BERT)
python train_stance_classifier.py --dataset PE --no-nrc

Advanced Training Options

# Full configuration example
python train_stance_classifier.py \
    --dataset PE \
    --use-enrc \
    --threshold 0.8 \
    --batch-size 16 \
    --epochs 50 \
    --lr 2e-5 \
    --test-size 0.1 \
    --val-size 0.1 \
    --use-focal-loss \
    --use-data-augmentation \
    --include-topic-in-text

# Freeze BERT weights (train only classifier head)
python train_stance_classifier.py --dataset PE --freeze-bert

# Disable wandb logging
python train_stance_classifier.py --dataset PE --no-wandb

Command-line Arguments

Argument Type Default Description
--dataset str UKB Dataset to use: IBM, IBM_v2, MT1, MT2, MT3, PE, UKB
--use-nrc flag False Use standard NRC emotion features
--use-enrc flag False Use expandNRC emotion features (enhanced)
--no-nrc flag False Disable NRC features (baseline)
--threshold float 0.8 Threshold for expandNRC features
--batch-size int 8 Batch size for training
--epochs int 50 Number of training epochs
--lr float 1e-5 Learning rate
--test-size float 0.1 Test set size (fraction)
--val-size float 0.1 Validation set size (fraction)
--device str auto Device: cpu, cuda, or mps
--freeze-bert flag False Freeze BERT weights
--use-focal-loss flag False Use focal loss for class imbalance
--use-data-augmentation flag False Enable data augmentation
--include-topic-in-text flag False Include topic in input text
--no-wandb flag False Disable wandb logging

Output

Training results are saved in results/<experiment_name>/:

  • model_<timestamp>.pt - Trained model checkpoint
  • model_<timestamp>_predictions.csv - Test set predictions
  • training_history.json - Training metrics history
  • training_plots.png - Loss and F1 score plots
  • experiment_config.json - Experiment configuration

Qwen-based Classification

For LLM-based stance classification using Qwen:

cd src

# Evaluate on all datasets
python qwen_stance_classification.py --dataset all

# Evaluate on specific dataset
python qwen_stance_classification.py --dataset PE

# With NRC features
python qwen_stance_classification.py --dataset PE --use-nrc

# With expandNRC features
python qwen_stance_classification.py --dataset PE --use-enrc --threshold 0.8

# Custom results directory
python qwen_stance_classification.py --dataset all --results-dir ./my_qwen_results

Note: Qwen classification requires significant GPU memory (recommended: 16GB+ VRAM for 7B model).

Results are saved in qwen_results/:

  • qwen_<dataset>_predictions_<timestamp>.csv - Predictions
  • qwen_<dataset>_metrics_<timestamp>.json - Metrics
  • qwen_<dataset>_report_<timestamp>.txt - Classification report
  • qwen_summary_<timestamp>.csv - Summary across all datasets

License

[Specify your license here]

Contact

[Your contact information]

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages