Upload train_memory_agent.py with huggingface_hub
Browse files- train_memory_agent.py +11 -8
train_memory_agent.py
CHANGED
|
@@ -10,22 +10,24 @@
|
|
| 10 |
# ]
|
| 11 |
# ///
|
| 12 |
|
|
|
|
|
|
|
| 13 |
import trackio
|
| 14 |
from datasets import load_dataset
|
| 15 |
from peft import LoraConfig
|
| 16 |
from trl import SFTTrainer, SFTConfig
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
print("Loading dataset...")
|
| 19 |
dataset = load_dataset("erik1988/way2agi-memory-agent-sft", data_files="memory-agent-sft-v3-merged.jsonl", split="train")
|
| 20 |
print(f"Dataset loaded: {len(dataset)} examples")
|
| 21 |
-
print(f"Columns: {dataset.column_names}")
|
| 22 |
-
|
| 23 |
-
# Pre-process: convert messages column from JSON extension to plain format
|
| 24 |
-
# This avoids pyarrow extension type issues with TRL truncation
|
| 25 |
-
def preprocess(example):
|
| 26 |
-
return example
|
| 27 |
-
|
| 28 |
-
dataset = dataset.map(preprocess)
|
| 29 |
|
| 30 |
dataset_split = dataset.train_test_split(test_size=0.1, seed=42)
|
| 31 |
train_dataset = dataset_split["train"]
|
|
@@ -46,6 +48,7 @@ config = SFTConfig(
|
|
| 46 |
push_to_hub=True,
|
| 47 |
hub_model_id="erik1988/elias-memory-agent-v1",
|
| 48 |
hub_strategy="every_save",
|
|
|
|
| 49 |
max_length=None,
|
| 50 |
num_train_epochs=5,
|
| 51 |
per_device_train_batch_size=2,
|
|
|
|
| 10 |
# ]
|
| 11 |
# ///
|
| 12 |
|
| 13 |
+
import os
|
| 14 |
+
import huggingface_hub
|
| 15 |
import trackio
|
| 16 |
from datasets import load_dataset
|
| 17 |
from peft import LoraConfig
|
| 18 |
from trl import SFTTrainer, SFTConfig
|
| 19 |
|
| 20 |
+
# Explicit login with token from secrets
|
| 21 |
+
token = os.environ.get("HF_TOKEN")
|
| 22 |
+
if token:
|
| 23 |
+
huggingface_hub.login(token=token)
|
| 24 |
+
print("Logged in to HF Hub")
|
| 25 |
+
else:
|
| 26 |
+
print("WARNING: No HF_TOKEN found!")
|
| 27 |
+
|
| 28 |
print("Loading dataset...")
|
| 29 |
dataset = load_dataset("erik1988/way2agi-memory-agent-sft", data_files="memory-agent-sft-v3-merged.jsonl", split="train")
|
| 30 |
print(f"Dataset loaded: {len(dataset)} examples")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
dataset_split = dataset.train_test_split(test_size=0.1, seed=42)
|
| 33 |
train_dataset = dataset_split["train"]
|
|
|
|
| 48 |
push_to_hub=True,
|
| 49 |
hub_model_id="erik1988/elias-memory-agent-v1",
|
| 50 |
hub_strategy="every_save",
|
| 51 |
+
hub_token=token,
|
| 52 |
max_length=None,
|
| 53 |
num_train_epochs=5,
|
| 54 |
per_device_train_batch_size=2,
|