Upload train_qwen3_8b_hf.py with huggingface_hub
Browse files- train_qwen3_8b_hf.py +22 -15
train_qwen3_8b_hf.py
CHANGED
|
@@ -6,7 +6,8 @@
|
|
| 6 |
# "accelerate>=0.24.0",
|
| 7 |
# "trackio",
|
| 8 |
# "bitsandbytes",
|
| 9 |
-
# "datasets"
|
|
|
|
| 10 |
# ]
|
| 11 |
# ///
|
| 12 |
|
|
@@ -15,25 +16,31 @@ Fine-tune Qwen3-8B on Vyvo Life CoPilot conversations dataset.
|
|
| 15 |
"""
|
| 16 |
|
| 17 |
import json
|
| 18 |
-
from datasets import
|
| 19 |
from peft import LoraConfig
|
| 20 |
from trl import SFTTrainer, SFTConfig
|
|
|
|
| 21 |
|
| 22 |
-
print("📦
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
#
|
| 27 |
-
print("🔄
|
| 28 |
conversations = []
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
messages
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
| 37 |
|
| 38 |
dataset = Dataset.from_list(conversations)
|
| 39 |
print(f"✅ Converted {len(dataset)} conversations")
|
|
|
|
| 6 |
# "accelerate>=0.24.0",
|
| 7 |
# "trackio",
|
| 8 |
# "bitsandbytes",
|
| 9 |
+
# "datasets",
|
| 10 |
+
# "huggingface_hub"
|
| 11 |
# ]
|
| 12 |
# ///
|
| 13 |
|
|
|
|
| 16 |
"""
|
| 17 |
|
| 18 |
import json
|
| 19 |
+
from datasets import Dataset
|
| 20 |
from peft import LoraConfig
|
| 21 |
from trl import SFTTrainer, SFTConfig
|
| 22 |
+
from huggingface_hub import hf_hub_download
|
| 23 |
|
| 24 |
+
print("📦 Downloading dataset from Hub...")
|
| 25 |
+
data_path = hf_hub_download(
|
| 26 |
+
repo_id="Codyfederer/vyvo-text-conversations",
|
| 27 |
+
filename="text_conversations.jsonl",
|
| 28 |
+
repo_type="dataset"
|
| 29 |
+
)
|
| 30 |
|
| 31 |
+
# Load JSONL manually to avoid schema inference issues
|
| 32 |
+
print("🔄 Loading and converting to messages format...")
|
| 33 |
conversations = []
|
| 34 |
+
with open(data_path, 'r', encoding='utf-8') as f:
|
| 35 |
+
for line in f:
|
| 36 |
+
item = json.loads(line)
|
| 37 |
+
messages = []
|
| 38 |
+
for turn in item['turns']:
|
| 39 |
+
messages.append({
|
| 40 |
+
'role': turn['role'],
|
| 41 |
+
'content': turn['content']
|
| 42 |
+
})
|
| 43 |
+
conversations.append({'messages': messages})
|
| 44 |
|
| 45 |
dataset = Dataset.from_list(conversations)
|
| 46 |
print(f"✅ Converted {len(dataset)} conversations")
|