Upload 55 files
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +2 -0
- data/.gitignore +1 -0
- data/finetune_distilbert.py +186 -0
- data/load_huffpost.py +15 -0
- data/load_jigsaw.py +55 -0
- data/load_reddit.py +49 -0
- data/load_social_media.py +9 -0
- data/processed/combined_meta.parquet +3 -0
- data/processed/faiss_index.bin +3 -0
- data/processed/faiss_index_v2.bin +3 -0
- data/processed/faiss_v2_manifest.json +8 -0
- data/processed/huffpost_embeddings.npy +3 -0
- data/processed/huffpost_with_meta.parquet +3 -0
- data/processed/reddit_embeddings.npy +3 -0
- data/processed/reddit_meta.parquet +3 -0
- data/raw/HuffPost.py +129 -0
- data/raw/News_Category_Dataset_v2.json +3 -0
- data/raw/huffpost.parquet +3 -0
- data/raw/jigsaw.parquet +3 -0
- data/raw/jigsaw_train_hate_annotationprob.csv +3 -0
- data/raw/reddit.parquet +3 -0
- data/raw/sentimentdataset.csv +0 -0
- data/raw/social_media.parquet +3 -0
- data/run_inference_demo.py +71 -0
- models/distilbert_huffpost/checkpoint-250/config.json +52 -0
- models/distilbert_huffpost/checkpoint-250/model.safetensors +3 -0
- models/distilbert_huffpost/checkpoint-250/optimizer.pt +3 -0
- models/distilbert_huffpost/checkpoint-250/rng_state.pth +3 -0
- models/distilbert_huffpost/checkpoint-250/scheduler.pt +3 -0
- models/distilbert_huffpost/checkpoint-250/tokenizer.json +0 -0
- models/distilbert_huffpost/checkpoint-250/tokenizer_config.json +15 -0
- models/distilbert_huffpost/checkpoint-250/trainer_state.json +56 -0
- models/distilbert_huffpost/checkpoint-250/training_args.bin +3 -0
- models/distilbert_huffpost/checkpoint-500/config.json +52 -0
- models/distilbert_huffpost/checkpoint-500/model.safetensors +3 -0
- models/distilbert_huffpost/checkpoint-500/optimizer.pt +3 -0
- models/distilbert_huffpost/checkpoint-500/rng_state.pth +3 -0
- models/distilbert_huffpost/checkpoint-500/scheduler.pt +3 -0
- models/distilbert_huffpost/checkpoint-500/tokenizer.json +0 -0
- models/distilbert_huffpost/checkpoint-500/tokenizer_config.json +15 -0
- models/distilbert_huffpost/checkpoint-500/trainer_state.json +85 -0
- models/distilbert_huffpost/checkpoint-500/training_args.bin +3 -0
- models/distilbert_huffpost/checkpoint-750/config.json +52 -0
- models/distilbert_huffpost/checkpoint-750/model.safetensors +3 -0
- models/distilbert_huffpost/checkpoint-750/optimizer.pt +3 -0
- models/distilbert_huffpost/checkpoint-750/rng_state.pth +3 -0
- models/distilbert_huffpost/checkpoint-750/scheduler.pt +3 -0
- models/distilbert_huffpost/checkpoint-750/tokenizer.json +0 -0
- models/distilbert_huffpost/checkpoint-750/tokenizer_config.json +15 -0
- models/distilbert_huffpost/checkpoint-750/trainer_state.json +107 -0
.gitattributes
CHANGED
|
@@ -58,3 +58,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 58 |
# Video files - compressed
|
| 59 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 60 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 58 |
# Video files - compressed
|
| 59 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 60 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
| 61 |
+
data/raw/jigsaw_train_hate_annotationprob.csv filter=lfs diff=lfs merge=lfs -text
|
| 62 |
+
data/raw/News_Category_Dataset_v2.json filter=lfs diff=lfs merge=lfs -text
|
data/.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
processed/
|
data/finetune_distilbert.py
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import json
|
| 3 |
+
import torch
|
| 4 |
+
import pandas as pd
|
| 5 |
+
import numpy as np
|
| 6 |
+
from datasets import Dataset
|
| 7 |
+
from transformers import (
|
| 8 |
+
DistilBertTokenizer,
|
| 9 |
+
DistilBertForSequenceClassification,
|
| 10 |
+
Trainer,
|
| 11 |
+
TrainingArguments,
|
| 12 |
+
DataCollatorWithPadding
|
| 13 |
+
)
|
| 14 |
+
from sklearn.preprocessing import LabelEncoder
|
| 15 |
+
import warnings
|
| 16 |
+
warnings.filterwarnings('ignore')
|
| 17 |
+
|
| 18 |
+
# Set random seeds for reproducibility
|
| 19 |
+
np.random.seed(42)
|
| 20 |
+
torch.manual_seed(42)
|
| 21 |
+
|
| 22 |
+
print("=" * 60)
|
| 23 |
+
print("DistilBERT Fine-tuning on News Category Data")
|
| 24 |
+
print("=" * 60)
|
| 25 |
+
|
| 26 |
+
# Step 1: Load data from local JSON file
|
| 27 |
+
print("\n[1/5] Loading dataset from local file...")
|
| 28 |
+
data_path = './backend/data/raw/News_Category_Dataset_v2.json'
|
| 29 |
+
|
| 30 |
+
try:
|
| 31 |
+
# Load JSON file
|
| 32 |
+
articles = []
|
| 33 |
+
with open(data_path, 'r') as f:
|
| 34 |
+
for line in f:
|
| 35 |
+
articles.append(json.loads(line))
|
| 36 |
+
|
| 37 |
+
df = pd.DataFrame(articles)
|
| 38 |
+
print(f"✓ Loaded from {data_path}")
|
| 39 |
+
print(f" Columns: {list(df.columns)}")
|
| 40 |
+
except FileNotFoundError:
|
| 41 |
+
print(f"✗ File not found: {data_path}")
|
| 42 |
+
raise
|
| 43 |
+
except Exception as e:
|
| 44 |
+
print(f"✗ Error loading file: {e}")
|
| 45 |
+
raise
|
| 46 |
+
|
| 47 |
+
# Prepare data
|
| 48 |
+
print(f" Dataset size: {len(df)} samples")
|
| 49 |
+
|
| 50 |
+
# Identify text and category columns
|
| 51 |
+
if 'headline' in df.columns:
|
| 52 |
+
text_col = 'headline'
|
| 53 |
+
else:
|
| 54 |
+
text_col = df.columns[0]
|
| 55 |
+
|
| 56 |
+
if 'category' in df.columns:
|
| 57 |
+
category_col = 'category'
|
| 58 |
+
elif 'Category' in df.columns:
|
| 59 |
+
category_col = 'Category'
|
| 60 |
+
else:
|
| 61 |
+
category_col = df.columns[-1]
|
| 62 |
+
|
| 63 |
+
# Create text column combining headline and description if available
|
| 64 |
+
if 'short_description' in df.columns:
|
| 65 |
+
df['text'] = df[text_col].fillna('') + " " + df['short_description'].fillna('')
|
| 66 |
+
elif 'description' in df.columns:
|
| 67 |
+
df['text'] = df[text_col].fillna('') + " " + df['description'].fillna('')
|
| 68 |
+
else:
|
| 69 |
+
df['text'] = df[text_col].fillna('')
|
| 70 |
+
|
| 71 |
+
# Use category column
|
| 72 |
+
df['category'] = df[category_col]
|
| 73 |
+
print(f" Categories found: {df['category'].nunique()}")
|
| 74 |
+
|
| 75 |
+
# Clean data
|
| 76 |
+
print("\n[2/5] Cleaning data...")
|
| 77 |
+
df = df.dropna(subset=['text', 'category'])
|
| 78 |
+
df = df[df['text'].str.len() > 10] # Remove very short texts
|
| 79 |
+
df = df[df['category'].str.len() > 0] # Remove empty categories
|
| 80 |
+
|
| 81 |
+
# Limit to top categories for faster training (optional)
|
| 82 |
+
top_categories = df['category'].value_counts().head(10).index
|
| 83 |
+
df = df[df['category'].isin(top_categories)]
|
| 84 |
+
|
| 85 |
+
# Sample data for faster training
|
| 86 |
+
if len(df) > 5000:
|
| 87 |
+
df = df.sample(n=5000, random_state=42)
|
| 88 |
+
print(f" Sampled to 5000 articles")
|
| 89 |
+
|
| 90 |
+
print(f"✓ Cleaned dataset: {len(df)} samples")
|
| 91 |
+
|
| 92 |
+
# Encode labels
|
| 93 |
+
print("\n[3/5] Encoding labels...")
|
| 94 |
+
le = LabelEncoder()
|
| 95 |
+
df['label'] = le.fit_transform(df['category'])
|
| 96 |
+
# id2label: index -> category name (string keys for id)
|
| 97 |
+
id2label = {str(i): label for i, label in enumerate(le.classes_)}
|
| 98 |
+
# label2id: category name -> index (string keys for label)
|
| 99 |
+
label2id = {label: i for i, label in enumerate(le.classes_)}
|
| 100 |
+
num_labels = len(le.classes_)
|
| 101 |
+
print(f"✓ {num_labels} categories: {list(le.classes_[:5])}{'...' if num_labels > 5 else ''}")
|
| 102 |
+
|
| 103 |
+
# Step 2: Split data
|
| 104 |
+
print("\n[4/5] Splitting data (80/20 train/test)...")
|
| 105 |
+
train_size = int(0.8 * len(df))
|
| 106 |
+
train_df = df[:train_size]
|
| 107 |
+
test_df = df[train_size:]
|
| 108 |
+
print(f"✓ Train: {len(train_df)} samples")
|
| 109 |
+
print(f"✓ Test: {len(test_df)} samples")
|
| 110 |
+
|
| 111 |
+
# Step 3: Create Hugging Face datasets and tokenize
|
| 112 |
+
print("\n[5/5] Preparing datasets and tokenizing...")
|
| 113 |
+
train_dataset = Dataset.from_pandas(train_df[['text', 'label']])
|
| 114 |
+
test_dataset = Dataset.from_pandas(test_df[['text', 'label']])
|
| 115 |
+
|
| 116 |
+
tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-uncased')
|
| 117 |
+
|
| 118 |
+
def tokenize_function(examples):
|
| 119 |
+
return tokenizer(
|
| 120 |
+
examples['text'],
|
| 121 |
+
padding='max_length',
|
| 122 |
+
truncation=True,
|
| 123 |
+
max_length=128
|
| 124 |
+
)
|
| 125 |
+
|
| 126 |
+
train_tokenized = train_dataset.map(tokenize_function, batched=True, remove_columns=['text'])
|
| 127 |
+
test_tokenized = test_dataset.map(tokenize_function, batched=True, remove_columns=['text'])
|
| 128 |
+
print(f"✓ Tokenization complete")
|
| 129 |
+
|
| 130 |
+
# Step 4: Fine-tune the model
|
| 131 |
+
print("\n" + "=" * 60)
|
| 132 |
+
print("Fine-tuning DistilBERT...")
|
| 133 |
+
print("=" * 60)
|
| 134 |
+
model = DistilBertForSequenceClassification.from_pretrained(
|
| 135 |
+
'distilbert-base-uncased',
|
| 136 |
+
num_labels=num_labels,
|
| 137 |
+
id2label=id2label,
|
| 138 |
+
label2id=label2id
|
| 139 |
+
)
|
| 140 |
+
|
| 141 |
+
training_args = TrainingArguments(
|
| 142 |
+
output_dir='./models/distilbert_huffpost',
|
| 143 |
+
num_train_epochs=3,
|
| 144 |
+
per_device_train_batch_size=16,
|
| 145 |
+
per_device_eval_batch_size=16,
|
| 146 |
+
warmup_steps=500,
|
| 147 |
+
weight_decay=0.01,
|
| 148 |
+
logging_dir='./logs',
|
| 149 |
+
logging_steps=100,
|
| 150 |
+
eval_strategy='epoch',
|
| 151 |
+
save_strategy='epoch',
|
| 152 |
+
load_best_model_at_end=True,
|
| 153 |
+
metric_for_best_model='loss',
|
| 154 |
+
)
|
| 155 |
+
|
| 156 |
+
data_collator = DataCollatorWithPadding(tokenizer)
|
| 157 |
+
|
| 158 |
+
trainer = Trainer(
|
| 159 |
+
model=model,
|
| 160 |
+
args=training_args,
|
| 161 |
+
train_dataset=train_tokenized,
|
| 162 |
+
eval_dataset=test_tokenized,
|
| 163 |
+
data_collator=data_collator,
|
| 164 |
+
)
|
| 165 |
+
|
| 166 |
+
trainer.train()
|
| 167 |
+
|
| 168 |
+
# Step 5: Save the model
|
| 169 |
+
print("\n" + "=" * 60)
|
| 170 |
+
print("Saving fine-tuned model...")
|
| 171 |
+
model_save_path = './models/distilbert_huffpost_final'
|
| 172 |
+
os.makedirs(model_save_path, exist_ok=True)
|
| 173 |
+
model.save_pretrained(model_save_path)
|
| 174 |
+
tokenizer.save_pretrained(model_save_path)
|
| 175 |
+
print(f"✓ Model saved to: {model_save_path}")
|
| 176 |
+
|
| 177 |
+
# Save label encoding for later use
|
| 178 |
+
import json
|
| 179 |
+
with open(os.path.join(model_save_path, 'label_mapping.json'), 'w') as f:
|
| 180 |
+
json.dump({'id2label': {str(k): v for k, v in id2label.items()},
|
| 181 |
+
'label2id': {k: v for k, v in label2id.items()}}, f)
|
| 182 |
+
print(f"✓ Label mapping saved")
|
| 183 |
+
|
| 184 |
+
print("\n" + "=" * 60)
|
| 185 |
+
print("Fine-tuning completed successfully!")
|
| 186 |
+
print("=" * 60)
|
data/load_huffpost.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datasets import load_dataset
|
| 2 |
+
import pandas as pd
|
| 3 |
+
|
| 4 |
+
# Load the test split specifically
|
| 5 |
+
ds = load_dataset("khalidalt/HuffPost", split="test", trust_remote_code=True)
|
| 6 |
+
df = ds.to_pandas()
|
| 7 |
+
|
| 8 |
+
# Garder seulement les colonnes utiles
|
| 9 |
+
df = df[["headline","short_description","category","date"]].dropna()
|
| 10 |
+
df["text"] = df["headline"] + " " + df["short_description"]
|
| 11 |
+
|
| 12 |
+
print(f"Loaded: {len(df)} articles, {df['category'].nunique()} categories")
|
| 13 |
+
print(df["category"].value_counts().head(10))
|
| 14 |
+
|
| 15 |
+
df.to_parquet("data/raw/huffpost.parquet", index=False)
|
data/load_jigsaw.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
+
import pandas as pd
|
| 4 |
+
from datasets import load_dataset
|
| 5 |
+
|
| 6 |
+
RAW_CSV_PATH = "data/raw/jigsaw_train_hate_annotationprob.csv"
|
| 7 |
+
PARQUET_PATH = "data/raw/jigsaw.parquet"
|
| 8 |
+
HF_COLS = [
|
| 9 |
+
"comment_text",
|
| 10 |
+
"toxic",
|
| 11 |
+
"severe_toxic",
|
| 12 |
+
"obscene",
|
| 13 |
+
"threat",
|
| 14 |
+
"insult",
|
| 15 |
+
"identity_hate",
|
| 16 |
+
]
|
| 17 |
+
CSV_COLS = [
|
| 18 |
+
"text",
|
| 19 |
+
"toxic",
|
| 20 |
+
"severe_toxic",
|
| 21 |
+
"obscene",
|
| 22 |
+
"threat",
|
| 23 |
+
"insult",
|
| 24 |
+
"identity_hate",
|
| 25 |
+
]
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def _load_from_csv() -> pd.DataFrame:
|
| 29 |
+
df = pd.read_csv(RAW_CSV_PATH)
|
| 30 |
+
df = df[CSV_COLS].dropna()
|
| 31 |
+
return df.rename(columns={"text": "comment_text"})
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def _load_from_hf() -> pd.DataFrame:
|
| 35 |
+
dataset = load_dataset("jigsaw_toxicity_pred", split="train")
|
| 36 |
+
dataset = dataset.select_columns(HF_COLS)
|
| 37 |
+
return dataset.to_pandas().dropna()
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def main() -> None:
|
| 41 |
+
if os.path.exists(RAW_CSV_PATH):
|
| 42 |
+
df = _load_from_csv()
|
| 43 |
+
source = RAW_CSV_PATH
|
| 44 |
+
else:
|
| 45 |
+
df = _load_from_hf()
|
| 46 |
+
source = "jigsaw_toxicity_pred"
|
| 47 |
+
|
| 48 |
+
print(f"Loaded: {len(df)} comments from {source}")
|
| 49 |
+
print(f"Toxic rate: {df['toxic'].mean():.1%}")
|
| 50 |
+
|
| 51 |
+
df.to_parquet(PARQUET_PATH, index=False)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
if __name__ == "__main__":
|
| 55 |
+
main()
|
data/load_reddit.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datasets import load_dataset
|
| 2 |
+
import pandas as pd
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def _resolve_score_column(df: pd.DataFrame) -> str | None:
|
| 6 |
+
for name in ["score", "upvotes", "ups", "upvote_ratio"]:
|
| 7 |
+
if name in df.columns:
|
| 8 |
+
return name
|
| 9 |
+
return None
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def main() -> None:
|
| 13 |
+
dataset = load_dataset(
|
| 14 |
+
"reddit_tifu",
|
| 15 |
+
"short",
|
| 16 |
+
split="train",
|
| 17 |
+
trust_remote_code=True,
|
| 18 |
+
)
|
| 19 |
+
df = dataset.to_pandas()
|
| 20 |
+
|
| 21 |
+
if "title" not in df.columns:
|
| 22 |
+
raise ValueError("Missing required column: title")
|
| 23 |
+
|
| 24 |
+
if "tldr" not in df.columns:
|
| 25 |
+
df["tldr"] = ""
|
| 26 |
+
|
| 27 |
+
df["text"] = (df["title"].fillna("") + " " + df["tldr"].fillna("")).str.strip()
|
| 28 |
+
if "subreddit" in df.columns:
|
| 29 |
+
df["category"] = df["subreddit"]
|
| 30 |
+
elif "subreddit_name_prefixed" in df.columns:
|
| 31 |
+
df["category"] = df["subreddit_name_prefixed"]
|
| 32 |
+
else:
|
| 33 |
+
df["category"] = "tifu"
|
| 34 |
+
|
| 35 |
+
score_col = _resolve_score_column(df)
|
| 36 |
+
if score_col is None:
|
| 37 |
+
df["score"] = 0
|
| 38 |
+
else:
|
| 39 |
+
df["score"] = df[score_col]
|
| 40 |
+
|
| 41 |
+
df = df[df["text"].str.len() >= 20].copy()
|
| 42 |
+
out_df = df[["text", "category", "score"]]
|
| 43 |
+
|
| 44 |
+
out_df.to_parquet("data/raw/reddit.parquet", index=False)
|
| 45 |
+
print(f"Loaded {len(out_df)} rows, {out_df['category'].nunique()} subreddits")
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
if __name__ == "__main__":
|
| 49 |
+
main()
|
data/load_social_media.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
|
| 3 |
+
df = pd.read_csv("data/raw/sentimentdataset.csv")
|
| 4 |
+
# Normaliser les colonnes
|
| 5 |
+
df.columns = [c.strip().lower().replace(" ","_") for c in df.columns]
|
| 6 |
+
print(df.columns.tolist())
|
| 7 |
+
print(df.head(2))
|
| 8 |
+
|
| 9 |
+
df.to_parquet("data/raw/social_media.parquet", index=False)
|
data/processed/combined_meta.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2ebd175bf7eb19108c76d85bc037d02449fc7b5462d9186fa9443ac63a63df11
|
| 3 |
+
size 30137616
|
data/processed/faiss_index.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:38bd97f2ab1e60e05ed59c83c28ecb853ca6e4bb259e2f878faedda3be6cab77
|
| 3 |
+
size 308510253
|
data/processed/faiss_index_v2.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9a3665e0226ce50aab1ec71cae83805af8e3b83e2d163fc2e309fa2112f1f868
|
| 3 |
+
size 425236267
|
data/processed/faiss_v2_manifest.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"n_huffpost": 200853,
|
| 3 |
+
"n_reddit": 74459,
|
| 4 |
+
"n_total": 275312,
|
| 5 |
+
"dim": 384,
|
| 6 |
+
"nlist": 100,
|
| 7 |
+
"nprobe": 10
|
| 8 |
+
}
|
data/processed/huffpost_embeddings.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:01d63b58c29ebff7197d9001556be221913606c479c6002ee2a6c50fe31f8015
|
| 3 |
+
size 308510336
|
data/processed/huffpost_with_meta.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0dab6c5bce2c2a141b813e4cdb331f33f0182c78af467c6f3525d4667c34a68a
|
| 3 |
+
size 50014899
|
data/processed/reddit_embeddings.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:565efc57ef15e37af48237a600ae0c277e451958c42546389b7ba1bb88bf84ab
|
| 3 |
+
size 114369152
|
data/processed/reddit_meta.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8ed3f1583eef4ce7d71c622ca828068c372e944168c31ebaa44eed38e925516f
|
| 3 |
+
size 5109199
|
data/raw/HuffPost.py
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
"""HuffPost Dataset."""
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
import csv
|
| 19 |
+
import json
|
| 20 |
+
import os
|
| 21 |
+
|
| 22 |
+
import datasets
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
_CITATION = """\
|
| 27 |
+
@book{book,
|
| 28 |
+
author = {Misra, Rishabh and Grover, Jigyasa},
|
| 29 |
+
year = {2021},
|
| 30 |
+
month = {01},
|
| 31 |
+
pages = {},
|
| 32 |
+
title = {Sculpting Data for ML: The first act of Machine Learning},
|
| 33 |
+
isbn = {978-0-578-83125-1}
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
@dataset{dataset,
|
| 37 |
+
author = {Misra, Rishabh},
|
| 38 |
+
year = {2018},
|
| 39 |
+
month = {06},
|
| 40 |
+
pages = {},
|
| 41 |
+
title = {News Category Dataset},
|
| 42 |
+
doi = {10.13140/RG.2.2.20331.18729}
|
| 43 |
+
}
|
| 44 |
+
"""
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
_DESCRIPTION = """\
|
| 48 |
+
A dataset of approximately 200K news headlines from the year 2012 to 2018 collected from HuffPost."""
|
| 49 |
+
|
| 50 |
+
_HOMEPAGE = "https://www.kaggle.com/datasets/rmisra/news-category-dataset"
|
| 51 |
+
|
| 52 |
+
_LICENSE = "CC0: Public Domain"
|
| 53 |
+
|
| 54 |
+
_URLS = "https://huggingface.co/datasets/khalidalt/HuffPost/resolve/main/News_Category_Dataset_v2.json"
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
class HuffPost(datasets.GeneratorBasedBuilder):
|
| 59 |
+
"""HuffPost Dataset."""
|
| 60 |
+
|
| 61 |
+
VERSION = datasets.Version("1.1.0")
|
| 62 |
+
|
| 63 |
+
# This is an example of a dataset with multiple configurations.
|
| 64 |
+
# If you don't want/need to define several sub-sets in your dataset,
|
| 65 |
+
# just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
|
| 66 |
+
|
| 67 |
+
# If you need to make complex sub-parts in the datasets with configurable options
|
| 68 |
+
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
|
| 69 |
+
# BUILDER_CONFIG_CLASS = MyBuilderConfig
|
| 70 |
+
|
| 71 |
+
# You will be able to load one or the other configurations in the following list with
|
| 72 |
+
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
| 73 |
+
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
| 74 |
+
BUILDER_CONFIGS = [
|
| 75 |
+
datasets.BuilderConfig(name="default", version=VERSION, description="Default config"),
|
| 76 |
+
]
|
| 77 |
+
|
| 78 |
+
DEFAULT_CONFIG_NAME = "default"
|
| 79 |
+
|
| 80 |
+
def _info(self):
|
| 81 |
+
|
| 82 |
+
features = datasets.Features(
|
| 83 |
+
{
|
| 84 |
+
"category": datasets.Value("string"),
|
| 85 |
+
"headline": datasets.Value("string"),
|
| 86 |
+
"authors": datasets.Value("string"),
|
| 87 |
+
"link": datasets.Value("string"),
|
| 88 |
+
"short_description": datasets.Value("string"),
|
| 89 |
+
"date": datasets.Value("string"),
|
| 90 |
+
"label": datasets.ClassLabel(names=["POLITICS","WELLNESS","ENTERTAINMENT","TRAVEL","STYLE & BEAUTY",
|
| 91 |
+
"PARENTING","HEALTHY LIVING","QUEER VOICES","FOOD & DRINK",
|
| 92 |
+
"BUSINESS","COMEDY","SPORTS","BLACK VOICES","HOME & LIVING","PARENTS",
|
| 93 |
+
"THE WORLDPOST","WEDDINGS","WOMEN","IMPACT","DIVORCE","CRIME","MEDIA",
|
| 94 |
+
"WEIRD NEWS","GREEN","WORLDPOST","RELIGION","STYLE","SCIENCE",
|
| 95 |
+
"WORLD NEWS","TASTE","TECH","MONEY","ARTS","FIFTY","GOOD NEWS",
|
| 96 |
+
"ARTS & CULTURE","ENVIRONMENT","COLLEGE","LATINO VOICES","CULTURE & ARTS",
|
| 97 |
+
"EDUCATION"]),
|
| 98 |
+
}
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
+
return datasets.DatasetInfo(
|
| 102 |
+
|
| 103 |
+
description=_DESCRIPTION,
|
| 104 |
+
features=features,
|
| 105 |
+
homepage=_HOMEPAGE,
|
| 106 |
+
# License for the dataset if available
|
| 107 |
+
license=_LICENSE,
|
| 108 |
+
# Citation for the dataset
|
| 109 |
+
citation=_CITATION,
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
+
def _split_generators(self, dl_manager):
|
| 113 |
+
|
| 114 |
+
data_dir = dl_manager.download_and_extract(_URLS)
|
| 115 |
+
return [
|
| 116 |
+
datasets.SplitGenerator(
|
| 117 |
+
name=datasets.Split.TEST,
|
| 118 |
+
gen_kwargs={"filepath": data_dir},
|
| 119 |
+
),
|
| 120 |
+
]
|
| 121 |
+
|
| 122 |
+
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 123 |
+
def _generate_examples(self, filepath):
|
| 124 |
+
with open(filepath, encoding="utf-8") as f:
|
| 125 |
+
for key, row in enumerate(f):
|
| 126 |
+
data = json.loads(row)
|
| 127 |
+
data['label'] = data['category']
|
| 128 |
+
# Yields examples as (key, example) tuples
|
| 129 |
+
yield key, data
|
data/raw/News_Category_Dataset_v2.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fc5d8d34bd4ba55206cd715aa5fdf6d52b6e5e8e32fcac8684d941a9c5cbef95
|
| 3 |
+
size 83917554
|
data/raw/huffpost.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:018a4395f395983cde66d000c4ce05d2a4aedc09a02afdfdcc9699b21ace3dfe
|
| 3 |
+
size 50020916
|
data/raw/jigsaw.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:98ae1bee440b4c68e5f76a3930fedb72fddc9753e9aafce848d7a4e1421e858a
|
| 3 |
+
size 39889670
|
data/raw/jigsaw_train_hate_annotationprob.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9bb4c9e5eab5a8011e782ff0da2e75db94153013bd68845a2f3fa54ec69d214f
|
| 3 |
+
size 81192106
|
data/raw/reddit.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8ed3f1583eef4ce7d71c622ca828068c372e944168c31ebaa44eed38e925516f
|
| 3 |
+
size 5109199
|
data/raw/sentimentdataset.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/raw/social_media.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a8cdce6acaa375d3ffdf82885cd06e0512b5bf1e431e24e5294b3d477a7feb8a
|
| 3 |
+
size 89377
|
data/run_inference_demo.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
|
| 4 |
+
import torch
|
| 5 |
+
from torch.nn.functional import softmax
|
| 6 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def load_id2label(model_dir: Path, model: AutoModelForSequenceClassification) -> dict:
|
| 10 |
+
label_map_path = model_dir / "label_mapping.json"
|
| 11 |
+
if label_map_path.exists():
|
| 12 |
+
with label_map_path.open("r", encoding="utf-8") as f:
|
| 13 |
+
mapping = json.load(f)
|
| 14 |
+
return {int(k): v for k, v in mapping.get("id2label", {}).items()}
|
| 15 |
+
|
| 16 |
+
# Fallback to the model config if a separate mapping is missing.
|
| 17 |
+
config_map = getattr(model.config, "id2label", {})
|
| 18 |
+
return {int(k): v for k, v in config_map.items()}
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def main() -> None:
|
| 22 |
+
repo_root = Path(__file__).resolve().parents[2]
|
| 23 |
+
model_dir = repo_root / "models" / "distilbert_huffpost_final"
|
| 24 |
+
|
| 25 |
+
if not model_dir.exists():
|
| 26 |
+
raise FileNotFoundError(f"Model directory not found: {model_dir}")
|
| 27 |
+
|
| 28 |
+
tokenizer = AutoTokenizer.from_pretrained(model_dir)
|
| 29 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_dir)
|
| 30 |
+
model.eval()
|
| 31 |
+
|
| 32 |
+
id2label = load_id2label(model_dir, model)
|
| 33 |
+
|
| 34 |
+
texts = [
|
| 35 |
+
"Just booked a weekend trip to Lisbon and need food recommendations.",
|
| 36 |
+
"Homemade pasta night with fresh basil and garlic was a win.",
|
| 37 |
+
"Our kid starts kindergarten next week and we are excited and nervous.",
|
| 38 |
+
"The new skincare routine finally cleared up my dry patches.",
|
| 39 |
+
"Company earnings beat expectations and the stock jumped this morning.",
|
| 40 |
+
"The election debate last night felt chaotic and unproductive.",
|
| 41 |
+
"Trying to build a healthier sleep routine and cut screen time.",
|
| 42 |
+
"Weekend hike with friends was refreshing and low key.",
|
| 43 |
+
"Just watched a hilarious stand-up special and laughed nonstop.",
|
| 44 |
+
"Looking for tips on keeping a travel budget under control.",
|
| 45 |
+
]
|
| 46 |
+
|
| 47 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 48 |
+
model.to(device)
|
| 49 |
+
|
| 50 |
+
with torch.no_grad():
|
| 51 |
+
inputs = tokenizer(
|
| 52 |
+
texts,
|
| 53 |
+
return_tensors="pt",
|
| 54 |
+
padding=True,
|
| 55 |
+
truncation=True,
|
| 56 |
+
max_length=128,
|
| 57 |
+
)
|
| 58 |
+
inputs = {k: v.to(device) for k, v in inputs.items()}
|
| 59 |
+
logits = model(**inputs).logits
|
| 60 |
+
probs = softmax(logits, dim=-1)
|
| 61 |
+
|
| 62 |
+
for text, prob in zip(texts, probs):
|
| 63 |
+
topk = torch.topk(prob, k=min(3, prob.numel()))
|
| 64 |
+
print("\nText:", text)
|
| 65 |
+
for score, idx in zip(topk.values.tolist(), topk.indices.tolist()):
|
| 66 |
+
label = id2label.get(idx, f"LABEL_{idx}")
|
| 67 |
+
print(f" {label}: {score:.3f}")
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
if __name__ == "__main__":
|
| 71 |
+
main()
|
models/distilbert_huffpost/checkpoint-250/config.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation": "gelu",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"DistilBertForSequenceClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_dropout": 0.1,
|
| 7 |
+
"bos_token_id": null,
|
| 8 |
+
"dim": 768,
|
| 9 |
+
"dropout": 0.1,
|
| 10 |
+
"dtype": "float32",
|
| 11 |
+
"eos_token_id": null,
|
| 12 |
+
"hidden_dim": 3072,
|
| 13 |
+
"id2label": {
|
| 14 |
+
"0": "BUSINESS",
|
| 15 |
+
"1": "ENTERTAINMENT",
|
| 16 |
+
"2": "FOOD & DRINK",
|
| 17 |
+
"3": "HEALTHY LIVING",
|
| 18 |
+
"4": "PARENTING",
|
| 19 |
+
"5": "POLITICS",
|
| 20 |
+
"6": "QUEER VOICES",
|
| 21 |
+
"7": "STYLE & BEAUTY",
|
| 22 |
+
"8": "TRAVEL",
|
| 23 |
+
"9": "WELLNESS"
|
| 24 |
+
},
|
| 25 |
+
"initializer_range": 0.02,
|
| 26 |
+
"label2id": {
|
| 27 |
+
"BUSINESS": 0,
|
| 28 |
+
"ENTERTAINMENT": 1,
|
| 29 |
+
"FOOD & DRINK": 2,
|
| 30 |
+
"HEALTHY LIVING": 3,
|
| 31 |
+
"PARENTING": 4,
|
| 32 |
+
"POLITICS": 5,
|
| 33 |
+
"QUEER VOICES": 6,
|
| 34 |
+
"STYLE & BEAUTY": 7,
|
| 35 |
+
"TRAVEL": 8,
|
| 36 |
+
"WELLNESS": 9
|
| 37 |
+
},
|
| 38 |
+
"max_position_embeddings": 512,
|
| 39 |
+
"model_type": "distilbert",
|
| 40 |
+
"n_heads": 12,
|
| 41 |
+
"n_layers": 6,
|
| 42 |
+
"pad_token_id": 0,
|
| 43 |
+
"problem_type": "single_label_classification",
|
| 44 |
+
"qa_dropout": 0.1,
|
| 45 |
+
"seq_classif_dropout": 0.2,
|
| 46 |
+
"sinusoidal_pos_embds": false,
|
| 47 |
+
"tie_weights_": true,
|
| 48 |
+
"tie_word_embeddings": true,
|
| 49 |
+
"transformers_version": "5.6.2",
|
| 50 |
+
"use_cache": false,
|
| 51 |
+
"vocab_size": 30522
|
| 52 |
+
}
|
models/distilbert_huffpost/checkpoint-250/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e7b574553eb5ddfbf497dea0e96751aed5d632f7f28528674501ed4e7476e636
|
| 3 |
+
size 267857176
|
models/distilbert_huffpost/checkpoint-250/optimizer.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:93dcff147ee8144023ea92007916b2998f5f8022315f34ed48caa2e4a5a70e2b
|
| 3 |
+
size 535774027
|
models/distilbert_huffpost/checkpoint-250/rng_state.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:40369c04e08c428531511f5b54c9e15a5e2d2059e0621d8b9291ea1ead7254cd
|
| 3 |
+
size 14455
|
models/distilbert_huffpost/checkpoint-250/scheduler.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:44fe47abc05ed755b5d3cea9bbc0d07c2cabe39d84d9fa0d39c48b3073793eb6
|
| 3 |
+
size 1465
|
models/distilbert_huffpost/checkpoint-250/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
models/distilbert_huffpost/checkpoint-250/tokenizer_config.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"cls_token": "[CLS]",
|
| 4 |
+
"do_lower_case": true,
|
| 5 |
+
"is_local": false,
|
| 6 |
+
"local_files_only": false,
|
| 7 |
+
"mask_token": "[MASK]",
|
| 8 |
+
"model_max_length": 512,
|
| 9 |
+
"pad_token": "[PAD]",
|
| 10 |
+
"sep_token": "[SEP]",
|
| 11 |
+
"strip_accents": null,
|
| 12 |
+
"tokenize_chinese_chars": true,
|
| 13 |
+
"tokenizer_class": "DistilBertTokenizer",
|
| 14 |
+
"unk_token": "[UNK]"
|
| 15 |
+
}
|
models/distilbert_huffpost/checkpoint-250/trainer_state.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"best_global_step": 250,
|
| 3 |
+
"best_metric": 0.963435173034668,
|
| 4 |
+
"best_model_checkpoint": "./models/distilbert_huffpost/checkpoint-250",
|
| 5 |
+
"epoch": 1.0,
|
| 6 |
+
"eval_steps": 500,
|
| 7 |
+
"global_step": 250,
|
| 8 |
+
"is_hyper_param_search": false,
|
| 9 |
+
"is_local_process_zero": true,
|
| 10 |
+
"is_world_process_zero": true,
|
| 11 |
+
"log_history": [
|
| 12 |
+
{
|
| 13 |
+
"epoch": 0.4,
|
| 14 |
+
"grad_norm": 3.125596284866333,
|
| 15 |
+
"learning_rate": 9.900000000000002e-06,
|
| 16 |
+
"loss": 2.199267578125,
|
| 17 |
+
"step": 100
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"epoch": 0.8,
|
| 21 |
+
"grad_norm": 7.727860450744629,
|
| 22 |
+
"learning_rate": 1.9900000000000003e-05,
|
| 23 |
+
"loss": 1.5030784606933594,
|
| 24 |
+
"step": 200
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"epoch": 1.0,
|
| 28 |
+
"eval_loss": 0.963435173034668,
|
| 29 |
+
"eval_runtime": 67.1554,
|
| 30 |
+
"eval_samples_per_second": 14.891,
|
| 31 |
+
"eval_steps_per_second": 0.938,
|
| 32 |
+
"step": 250
|
| 33 |
+
}
|
| 34 |
+
],
|
| 35 |
+
"logging_steps": 100,
|
| 36 |
+
"max_steps": 750,
|
| 37 |
+
"num_input_tokens_seen": 0,
|
| 38 |
+
"num_train_epochs": 3,
|
| 39 |
+
"save_steps": 500,
|
| 40 |
+
"stateful_callbacks": {
|
| 41 |
+
"TrainerControl": {
|
| 42 |
+
"args": {
|
| 43 |
+
"should_epoch_stop": false,
|
| 44 |
+
"should_evaluate": false,
|
| 45 |
+
"should_log": false,
|
| 46 |
+
"should_save": true,
|
| 47 |
+
"should_training_stop": false
|
| 48 |
+
},
|
| 49 |
+
"attributes": {}
|
| 50 |
+
}
|
| 51 |
+
},
|
| 52 |
+
"total_flos": 132486297600000.0,
|
| 53 |
+
"train_batch_size": 16,
|
| 54 |
+
"trial_name": null,
|
| 55 |
+
"trial_params": null
|
| 56 |
+
}
|
models/distilbert_huffpost/checkpoint-250/training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4185c8b11316e95a8fcb6662765cb290e6693bb413bfbbc95f5c908cf8f75785
|
| 3 |
+
size 5265
|
models/distilbert_huffpost/checkpoint-500/config.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation": "gelu",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"DistilBertForSequenceClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_dropout": 0.1,
|
| 7 |
+
"bos_token_id": null,
|
| 8 |
+
"dim": 768,
|
| 9 |
+
"dropout": 0.1,
|
| 10 |
+
"dtype": "float32",
|
| 11 |
+
"eos_token_id": null,
|
| 12 |
+
"hidden_dim": 3072,
|
| 13 |
+
"id2label": {
|
| 14 |
+
"0": "BUSINESS",
|
| 15 |
+
"1": "ENTERTAINMENT",
|
| 16 |
+
"2": "FOOD & DRINK",
|
| 17 |
+
"3": "HEALTHY LIVING",
|
| 18 |
+
"4": "PARENTING",
|
| 19 |
+
"5": "POLITICS",
|
| 20 |
+
"6": "QUEER VOICES",
|
| 21 |
+
"7": "STYLE & BEAUTY",
|
| 22 |
+
"8": "TRAVEL",
|
| 23 |
+
"9": "WELLNESS"
|
| 24 |
+
},
|
| 25 |
+
"initializer_range": 0.02,
|
| 26 |
+
"label2id": {
|
| 27 |
+
"BUSINESS": 0,
|
| 28 |
+
"ENTERTAINMENT": 1,
|
| 29 |
+
"FOOD & DRINK": 2,
|
| 30 |
+
"HEALTHY LIVING": 3,
|
| 31 |
+
"PARENTING": 4,
|
| 32 |
+
"POLITICS": 5,
|
| 33 |
+
"QUEER VOICES": 6,
|
| 34 |
+
"STYLE & BEAUTY": 7,
|
| 35 |
+
"TRAVEL": 8,
|
| 36 |
+
"WELLNESS": 9
|
| 37 |
+
},
|
| 38 |
+
"max_position_embeddings": 512,
|
| 39 |
+
"model_type": "distilbert",
|
| 40 |
+
"n_heads": 12,
|
| 41 |
+
"n_layers": 6,
|
| 42 |
+
"pad_token_id": 0,
|
| 43 |
+
"problem_type": "single_label_classification",
|
| 44 |
+
"qa_dropout": 0.1,
|
| 45 |
+
"seq_classif_dropout": 0.2,
|
| 46 |
+
"sinusoidal_pos_embds": false,
|
| 47 |
+
"tie_weights_": true,
|
| 48 |
+
"tie_word_embeddings": true,
|
| 49 |
+
"transformers_version": "5.6.2",
|
| 50 |
+
"use_cache": false,
|
| 51 |
+
"vocab_size": 30522
|
| 52 |
+
}
|
models/distilbert_huffpost/checkpoint-500/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2baf54b8e6517f5c8ea1b4c0e0780d26f835917b1904a2b3e786c9883c8a8874
|
| 3 |
+
size 267857176
|
models/distilbert_huffpost/checkpoint-500/optimizer.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:983d23046ef332b60af8827819e18235c80cef06eac85fcc3827d099c49d552e
|
| 3 |
+
size 535774027
|
models/distilbert_huffpost/checkpoint-500/rng_state.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8719609e9719f2699224a5891f5681856439f326f55d85181d9abbd508d9a3b6
|
| 3 |
+
size 14455
|
models/distilbert_huffpost/checkpoint-500/scheduler.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:62659da226873706f7984ebf4b570bcda9a0ce985c520412ce2598e66627e55c
|
| 3 |
+
size 1465
|
models/distilbert_huffpost/checkpoint-500/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
models/distilbert_huffpost/checkpoint-500/tokenizer_config.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"cls_token": "[CLS]",
|
| 4 |
+
"do_lower_case": true,
|
| 5 |
+
"is_local": false,
|
| 6 |
+
"local_files_only": false,
|
| 7 |
+
"mask_token": "[MASK]",
|
| 8 |
+
"model_max_length": 512,
|
| 9 |
+
"pad_token": "[PAD]",
|
| 10 |
+
"sep_token": "[SEP]",
|
| 11 |
+
"strip_accents": null,
|
| 12 |
+
"tokenize_chinese_chars": true,
|
| 13 |
+
"tokenizer_class": "DistilBertTokenizer",
|
| 14 |
+
"unk_token": "[UNK]"
|
| 15 |
+
}
|
models/distilbert_huffpost/checkpoint-500/trainer_state.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"best_global_step": 500,
|
| 3 |
+
"best_metric": 0.7529695630073547,
|
| 4 |
+
"best_model_checkpoint": "./models/distilbert_huffpost/checkpoint-500",
|
| 5 |
+
"epoch": 2.0,
|
| 6 |
+
"eval_steps": 500,
|
| 7 |
+
"global_step": 500,
|
| 8 |
+
"is_hyper_param_search": false,
|
| 9 |
+
"is_local_process_zero": true,
|
| 10 |
+
"is_world_process_zero": true,
|
| 11 |
+
"log_history": [
|
| 12 |
+
{
|
| 13 |
+
"epoch": 0.4,
|
| 14 |
+
"grad_norm": 3.125596284866333,
|
| 15 |
+
"learning_rate": 9.900000000000002e-06,
|
| 16 |
+
"loss": 2.199267578125,
|
| 17 |
+
"step": 100
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"epoch": 0.8,
|
| 21 |
+
"grad_norm": 7.727860450744629,
|
| 22 |
+
"learning_rate": 1.9900000000000003e-05,
|
| 23 |
+
"loss": 1.5030784606933594,
|
| 24 |
+
"step": 200
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"epoch": 1.0,
|
| 28 |
+
"eval_loss": 0.963435173034668,
|
| 29 |
+
"eval_runtime": 67.1554,
|
| 30 |
+
"eval_samples_per_second": 14.891,
|
| 31 |
+
"eval_steps_per_second": 0.938,
|
| 32 |
+
"step": 250
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"epoch": 1.2,
|
| 36 |
+
"grad_norm": 10.762837409973145,
|
| 37 |
+
"learning_rate": 2.9900000000000002e-05,
|
| 38 |
+
"loss": 0.8936661529541016,
|
| 39 |
+
"step": 300
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"epoch": 1.6,
|
| 43 |
+
"grad_norm": 12.36496353149414,
|
| 44 |
+
"learning_rate": 3.99e-05,
|
| 45 |
+
"loss": 0.7169620513916015,
|
| 46 |
+
"step": 400
|
| 47 |
+
},
|
| 48 |
+
{
|
| 49 |
+
"epoch": 2.0,
|
| 50 |
+
"grad_norm": 15.652347564697266,
|
| 51 |
+
"learning_rate": 4.99e-05,
|
| 52 |
+
"loss": 0.6252112197875976,
|
| 53 |
+
"step": 500
|
| 54 |
+
},
|
| 55 |
+
{
|
| 56 |
+
"epoch": 2.0,
|
| 57 |
+
"eval_loss": 0.7529695630073547,
|
| 58 |
+
"eval_runtime": 204.5829,
|
| 59 |
+
"eval_samples_per_second": 4.888,
|
| 60 |
+
"eval_steps_per_second": 0.308,
|
| 61 |
+
"step": 500
|
| 62 |
+
}
|
| 63 |
+
],
|
| 64 |
+
"logging_steps": 100,
|
| 65 |
+
"max_steps": 750,
|
| 66 |
+
"num_input_tokens_seen": 0,
|
| 67 |
+
"num_train_epochs": 3,
|
| 68 |
+
"save_steps": 500,
|
| 69 |
+
"stateful_callbacks": {
|
| 70 |
+
"TrainerControl": {
|
| 71 |
+
"args": {
|
| 72 |
+
"should_epoch_stop": false,
|
| 73 |
+
"should_evaluate": false,
|
| 74 |
+
"should_log": false,
|
| 75 |
+
"should_save": true,
|
| 76 |
+
"should_training_stop": false
|
| 77 |
+
},
|
| 78 |
+
"attributes": {}
|
| 79 |
+
}
|
| 80 |
+
},
|
| 81 |
+
"total_flos": 264972595200000.0,
|
| 82 |
+
"train_batch_size": 16,
|
| 83 |
+
"trial_name": null,
|
| 84 |
+
"trial_params": null
|
| 85 |
+
}
|
models/distilbert_huffpost/checkpoint-500/training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4185c8b11316e95a8fcb6662765cb290e6693bb413bfbbc95f5c908cf8f75785
|
| 3 |
+
size 5265
|
models/distilbert_huffpost/checkpoint-750/config.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation": "gelu",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"DistilBertForSequenceClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_dropout": 0.1,
|
| 7 |
+
"bos_token_id": null,
|
| 8 |
+
"dim": 768,
|
| 9 |
+
"dropout": 0.1,
|
| 10 |
+
"dtype": "float32",
|
| 11 |
+
"eos_token_id": null,
|
| 12 |
+
"hidden_dim": 3072,
|
| 13 |
+
"id2label": {
|
| 14 |
+
"0": "BUSINESS",
|
| 15 |
+
"1": "ENTERTAINMENT",
|
| 16 |
+
"2": "FOOD & DRINK",
|
| 17 |
+
"3": "HEALTHY LIVING",
|
| 18 |
+
"4": "PARENTING",
|
| 19 |
+
"5": "POLITICS",
|
| 20 |
+
"6": "QUEER VOICES",
|
| 21 |
+
"7": "STYLE & BEAUTY",
|
| 22 |
+
"8": "TRAVEL",
|
| 23 |
+
"9": "WELLNESS"
|
| 24 |
+
},
|
| 25 |
+
"initializer_range": 0.02,
|
| 26 |
+
"label2id": {
|
| 27 |
+
"BUSINESS": 0,
|
| 28 |
+
"ENTERTAINMENT": 1,
|
| 29 |
+
"FOOD & DRINK": 2,
|
| 30 |
+
"HEALTHY LIVING": 3,
|
| 31 |
+
"PARENTING": 4,
|
| 32 |
+
"POLITICS": 5,
|
| 33 |
+
"QUEER VOICES": 6,
|
| 34 |
+
"STYLE & BEAUTY": 7,
|
| 35 |
+
"TRAVEL": 8,
|
| 36 |
+
"WELLNESS": 9
|
| 37 |
+
},
|
| 38 |
+
"max_position_embeddings": 512,
|
| 39 |
+
"model_type": "distilbert",
|
| 40 |
+
"n_heads": 12,
|
| 41 |
+
"n_layers": 6,
|
| 42 |
+
"pad_token_id": 0,
|
| 43 |
+
"problem_type": "single_label_classification",
|
| 44 |
+
"qa_dropout": 0.1,
|
| 45 |
+
"seq_classif_dropout": 0.2,
|
| 46 |
+
"sinusoidal_pos_embds": false,
|
| 47 |
+
"tie_weights_": true,
|
| 48 |
+
"tie_word_embeddings": true,
|
| 49 |
+
"transformers_version": "5.6.2",
|
| 50 |
+
"use_cache": false,
|
| 51 |
+
"vocab_size": 30522
|
| 52 |
+
}
|
models/distilbert_huffpost/checkpoint-750/model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:39ade959b0b9ce417813e5b5cd62b52f760f75762809ced59838b1e7a60e2567
|
| 3 |
+
size 267857176
|
models/distilbert_huffpost/checkpoint-750/optimizer.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2874df39ac8daf131339d68c132e287b9f866ae6054be9be090922de52b7c82c
|
| 3 |
+
size 535774027
|
models/distilbert_huffpost/checkpoint-750/rng_state.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:75db7a28a5cb615ac952da5ae661b5a98f5495ed56a63bda0e2a39f6b57107af
|
| 3 |
+
size 14455
|
models/distilbert_huffpost/checkpoint-750/scheduler.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6a5beb23cfb3bc04aecca9478e7bd700ebee5cbe3be7be1f25f89c385e115798
|
| 3 |
+
size 1465
|
models/distilbert_huffpost/checkpoint-750/tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
models/distilbert_huffpost/checkpoint-750/tokenizer_config.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"cls_token": "[CLS]",
|
| 4 |
+
"do_lower_case": true,
|
| 5 |
+
"is_local": false,
|
| 6 |
+
"local_files_only": false,
|
| 7 |
+
"mask_token": "[MASK]",
|
| 8 |
+
"model_max_length": 512,
|
| 9 |
+
"pad_token": "[PAD]",
|
| 10 |
+
"sep_token": "[SEP]",
|
| 11 |
+
"strip_accents": null,
|
| 12 |
+
"tokenize_chinese_chars": true,
|
| 13 |
+
"tokenizer_class": "DistilBertTokenizer",
|
| 14 |
+
"unk_token": "[UNK]"
|
| 15 |
+
}
|
models/distilbert_huffpost/checkpoint-750/trainer_state.json
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"best_global_step": 750,
|
| 3 |
+
"best_metric": 0.7524415254592896,
|
| 4 |
+
"best_model_checkpoint": "./models/distilbert_huffpost/checkpoint-750",
|
| 5 |
+
"epoch": 3.0,
|
| 6 |
+
"eval_steps": 500,
|
| 7 |
+
"global_step": 750,
|
| 8 |
+
"is_hyper_param_search": false,
|
| 9 |
+
"is_local_process_zero": true,
|
| 10 |
+
"is_world_process_zero": true,
|
| 11 |
+
"log_history": [
|
| 12 |
+
{
|
| 13 |
+
"epoch": 0.4,
|
| 14 |
+
"grad_norm": 3.125596284866333,
|
| 15 |
+
"learning_rate": 9.900000000000002e-06,
|
| 16 |
+
"loss": 2.199267578125,
|
| 17 |
+
"step": 100
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"epoch": 0.8,
|
| 21 |
+
"grad_norm": 7.727860450744629,
|
| 22 |
+
"learning_rate": 1.9900000000000003e-05,
|
| 23 |
+
"loss": 1.5030784606933594,
|
| 24 |
+
"step": 200
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"epoch": 1.0,
|
| 28 |
+
"eval_loss": 0.963435173034668,
|
| 29 |
+
"eval_runtime": 67.1554,
|
| 30 |
+
"eval_samples_per_second": 14.891,
|
| 31 |
+
"eval_steps_per_second": 0.938,
|
| 32 |
+
"step": 250
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"epoch": 1.2,
|
| 36 |
+
"grad_norm": 10.762837409973145,
|
| 37 |
+
"learning_rate": 2.9900000000000002e-05,
|
| 38 |
+
"loss": 0.8936661529541016,
|
| 39 |
+
"step": 300
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"epoch": 1.6,
|
| 43 |
+
"grad_norm": 12.36496353149414,
|
| 44 |
+
"learning_rate": 3.99e-05,
|
| 45 |
+
"loss": 0.7169620513916015,
|
| 46 |
+
"step": 400
|
| 47 |
+
},
|
| 48 |
+
{
|
| 49 |
+
"epoch": 2.0,
|
| 50 |
+
"grad_norm": 15.652347564697266,
|
| 51 |
+
"learning_rate": 4.99e-05,
|
| 52 |
+
"loss": 0.6252112197875976,
|
| 53 |
+
"step": 500
|
| 54 |
+
},
|
| 55 |
+
{
|
| 56 |
+
"epoch": 2.0,
|
| 57 |
+
"eval_loss": 0.7529695630073547,
|
| 58 |
+
"eval_runtime": 204.5829,
|
| 59 |
+
"eval_samples_per_second": 4.888,
|
| 60 |
+
"eval_steps_per_second": 0.308,
|
| 61 |
+
"step": 500
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"epoch": 2.4,
|
| 65 |
+
"grad_norm": 10.981303215026855,
|
| 66 |
+
"learning_rate": 3.02e-05,
|
| 67 |
+
"loss": 0.3609377670288086,
|
| 68 |
+
"step": 600
|
| 69 |
+
},
|
| 70 |
+
{
|
| 71 |
+
"epoch": 2.8,
|
| 72 |
+
"grad_norm": 9.517579078674316,
|
| 73 |
+
"learning_rate": 1.02e-05,
|
| 74 |
+
"loss": 0.35755828857421873,
|
| 75 |
+
"step": 700
|
| 76 |
+
},
|
| 77 |
+
{
|
| 78 |
+
"epoch": 3.0,
|
| 79 |
+
"eval_loss": 0.7524415254592896,
|
| 80 |
+
"eval_runtime": 88.3806,
|
| 81 |
+
"eval_samples_per_second": 11.315,
|
| 82 |
+
"eval_steps_per_second": 0.713,
|
| 83 |
+
"step": 750
|
| 84 |
+
}
|
| 85 |
+
],
|
| 86 |
+
"logging_steps": 100,
|
| 87 |
+
"max_steps": 750,
|
| 88 |
+
"num_input_tokens_seen": 0,
|
| 89 |
+
"num_train_epochs": 3,
|
| 90 |
+
"save_steps": 500,
|
| 91 |
+
"stateful_callbacks": {
|
| 92 |
+
"TrainerControl": {
|
| 93 |
+
"args": {
|
| 94 |
+
"should_epoch_stop": false,
|
| 95 |
+
"should_evaluate": false,
|
| 96 |
+
"should_log": false,
|
| 97 |
+
"should_save": true,
|
| 98 |
+
"should_training_stop": true
|
| 99 |
+
},
|
| 100 |
+
"attributes": {}
|
| 101 |
+
}
|
| 102 |
+
},
|
| 103 |
+
"total_flos": 397458892800000.0,
|
| 104 |
+
"train_batch_size": 16,
|
| 105 |
+
"trial_name": null,
|
| 106 |
+
"trial_params": null
|
| 107 |
+
}
|