Text Classification
Transformers
Safetensors
English
cross-encoder
pairwise-classification
course-project
Instructions to use Qriuc/AIAA3102_SuperAgent_task_2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Qriuc/AIAA3102_SuperAgent_task_2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Qriuc/AIAA3102_SuperAgent_task_2")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Qriuc/AIAA3102_SuperAgent_task_2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download prepare_data.py from Qriuc/AIAA3102_SuperAgent_task_2: direct link, hf CLI and curl.
- Browser
- Download file 1.58 kB
-
https://huggingface.co/Qriuc/AIAA3102_SuperAgent_task_2/resolve/main/prepare_data.py
- Command line
-
hf download hf://Qriuc/AIAA3102_SuperAgent_task_2/prepare_data.py
-
curl -L -o prepare_data.py https://huggingface.co/Qriuc/AIAA3102_SuperAgent_task_2/resolve/main/prepare_data.py
1.58 kB
| #!/usr/bin/env python3 | |
| """Prepare the headline pairwise CTR dataset for modeling.""" | |
| import sys | |
| from pathlib import Path | |
| import pandas as pd | |
| REQUIRED_COLUMNS = ["headline_A", "headline_B", "label_pairwise"] | |
| TEXT_COLUMNS = ["headline_A", "headline_B"] | |
| def load_and_standardize(path: Path) -> pd.DataFrame: | |
| df = pd.read_csv( | |
| path, | |
| dtype={col: "string" for col in TEXT_COLUMNS}, | |
| ) | |
| missing = [col for col in REQUIRED_COLUMNS if col not in df.columns] | |
| if missing: | |
| raise ValueError(f"Missing required columns in {path.name}: {missing}") | |
| out = df[TEXT_COLUMNS + ["label_pairwise"]].copy() | |
| out = out.rename(columns={"label_pairwise": "__label__"}) | |
| return out | |
| def save_split(df: pd.DataFrame, out_path: Path) -> None: | |
| pd.to_pickle(df, out_path) | |
| print(f"{out_path.name}: shape={df.shape}, columns={list(df.columns)}") | |
| def main() -> None: | |
| if len(sys.argv) != 3: | |
| raise SystemExit("Usage: python prepare_data.py <RAW_DIR> <OUT_DIR>") | |
| raw_dir = Path(sys.argv[1]) | |
| out_dir = Path(sys.argv[2]) | |
| out_dir.mkdir(parents=True, exist_ok=True) | |
| train_df = load_and_standardize(raw_dir / "train.csv") | |
| save_split(train_df, out_dir / "train.pkl") | |
| val_path = raw_dir / "val.csv" | |
| if val_path.exists(): | |
| val_df = load_and_standardize(val_path) | |
| save_split(val_df, out_dir / "val.pkl") | |
| test_df = load_and_standardize(raw_dir / "test.csv") | |
| save_split(test_df, out_dir / "test.pkl") | |
| if __name__ == "__main__": | |
| main() | |