# Attribution Style Classification System

This system performs attributional style classification on textual inputs. It supports multiple attribution dimensions, including Internal–External, Stable–Unstable, and Global–Specific.

---

## 📁 Directory Structure

```
Classification/
├── config/                 # Configuration files
│   ├── prompts/           # Prompt templates
│   │   ├── __init__.py
│   │   ├── ias_eas_neu.py    # Internal–External attribution prompts
│   │   ├── sas_uas_neu.py    # Stable–Unstable attribution prompts
│   │   └── gas_sas_neu.py    # Global–Specific attribution prompts
│   ├── domains/           # Attribution domain definitions
│   ├── models/            # Model mappings
├── classifiers/           # Core classification logic
│   └── core.py
├── datasets/              # Input data
├── logs/                  # Output logs
├── LLMs_result/           # Model predictions
├── main.py                # Entry point
├── sbatch.sh              # SLURM batch submission script
└── nohup.sh               # Background execution script
```

---

## 🎯 Supported Attribution Dimensions

### 1. Internal–External Attribution (IAS–EAS–NEU)
- **IAS**: Internal Attribution Style — cause lies within the individual.
- **EAS**: External Attribution Style — cause lies in the external environment.
- **NEU**: Neutral — no causal statement detected.

### 2. Stable–Unstable Attribution (SAS–UAS–NEU)
- **SAS**: Stable Attribution Style — cause is seen as persistent or long-term.
- **UAS**: Unstable Attribution Style — cause is transient or situational.
- **NEU**: Neutral — no causal attribution made.

### 3. Global–Specific Attribution (GAS–SPAS–NEU)
- **GAS**: Global Attribution Style — cause generalizes across many aspects of life.
- **SPAS**: Specific Attribution Style — cause pertains to a specific context.
- **NEU**: Neutral — no overgeneralization or attributional judgment.

---

## 🧠 Supported Models

- `LLAMA3.2_1B`
- `LLAMA3.2_3B`
- `LLAMA3.2_70B`

Other models can be added via `config/models/`.

---

## 🚀 How to Use

### 1. Set up the environment

Install dependencies:
```bash
pip install langchain tqdm
```

### 2. Run classification

Choose one of the following modes:

**a. Direct execution**
```bash
python main.py
```

**b. Background execution**
```bash
bash nohup.sh
```

**c. SLURM job submission**
```bash
sbatch sbatch.sh
```

---

## 📄 Output Format

Results will be saved in:
```
{domain}_{model}_{shot}_{timestamp}.json
```

### Examples:
- `IAS2EAS2NEU_LLAMA3.2_1B_fewshot_20240315_143022.json`
- `GAS2SPAS2NEU_LLAMA3.2_70B_zeroshot_20240315_143022.json`

Each output file includes:
- Overall accuracy
- Per-class accuracy
- Confusion matrix
- Logs per run
- Misclassified examples

---

## ⚙️ Custom Configuration

### 1. Add a new attribution domain:
- Create a new `.py` file under `config/prompts/`
- Register it in `config/prompts/__init__.py`

### 2. Modify existing prompts:
- Edit the corresponding prompt file
- Supports both `zeroshot` and `fewshot` settings

### 3. Configure runtime settings:
- Modify `main.py` to set model, shot type, index range, etc.

---

## ✅ Notes

- **Dataset Format**:
  - Each entry must include a `text` and a `label` field

- **Model Output Format**:
  - Only output the label string (no reasoning, no explanation)

- **Resource Requirements**:
  - Adjust resource needs based on model size
  - When using SLURM, configure GPU/memory/time accordingly