Compare commits
3
Commits
f3f1e8c6b7
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b584742c4 | ||
|
|
069f891ceb | ||
|
|
90b7fd5e9d |
@@ -32,3 +32,7 @@ wandb/
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
.vscode/
|
.vscode/
|
||||||
.idea/
|
.idea/
|
||||||
|
|
||||||
|
# Retained local artifacts: keep on disk, never commit
|
||||||
|
model_training/retained_training_logs/
|
||||||
|
evaluation_reporting/retained_reports/
|
||||||
|
|||||||
@@ -16,16 +16,50 @@ dataset_building/generated/
|
|||||||
|
|
||||||
That directory is ignored by git.
|
That directory is ignored by git.
|
||||||
|
|
||||||
## Kept Dataset
|
## Kept Datasets
|
||||||
|
|
||||||
Only the latest public heldout 2K set is versioned here:
|
The latest public heldout 2K set is versioned here:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
heldout_public_mcq_2k_20260607/heldout_public_mcq_2k.jsonl
|
heldout_public_mcq_2k_20260607/heldout_public_mcq_2k.jsonl
|
||||||
heldout_public_mcq_2k_20260607/heldout_public_mcq_2k_stats.json
|
heldout_public_mcq_2k_20260607/heldout_public_mcq_2k_stats.json
|
||||||
```
|
```
|
||||||
|
|
||||||
Older in-domain heldout and earlier ratio-imbalanced 2K heldout datasets are intentionally not included.
|
The 2.8K in-domain SFT heldout is kept as a reproducible build recipe rather
|
||||||
|
than checked-in generated data. It contains seven ability dimensions with 400
|
||||||
|
examples each:
|
||||||
|
|
||||||
|
```text
|
||||||
|
science_reasoning
|
||||||
|
logic
|
||||||
|
code
|
||||||
|
chinese_exam
|
||||||
|
math
|
||||||
|
chinese_dialogue
|
||||||
|
english_dialogue
|
||||||
|
```
|
||||||
|
|
||||||
|
Build it with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bash dataset_building/build_sft_heldout_2p8k_20260611.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
By default this writes:
|
||||||
|
|
||||||
|
```text
|
||||||
|
dataset_building/generated/training_mix_v4_train1m_test2p8k_noupsample_nobbh_20260611/
|
||||||
|
heldout_2p8k.jsonl
|
||||||
|
heldout_exclusion_hashes.jsonl
|
||||||
|
train_1m.jsonl
|
||||||
|
build_stats.json
|
||||||
|
```
|
||||||
|
|
||||||
|
Use `OUT=/path/to/output` and `TOKENIZER=/path/to/tokenizer` to place the
|
||||||
|
validation set outside the repo or build it with a specific tokenizer. For
|
||||||
|
Laoyao custom BPE tokenizers, set `LAOYAO_MODEL_ROOT=/path/to/laoyao/repo` so
|
||||||
|
the builder can import `laoyaomodel.tokenization.bpe`. Generated outputs stay
|
||||||
|
ignored by git.
|
||||||
|
|
||||||
## SFT Builders
|
## SFT Builders
|
||||||
|
|
||||||
|
|||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
cd "$ROOT_DIR"
|
||||||
|
|
||||||
|
export HF_ENDPOINT="${HF_ENDPOINT:-https://hf-mirror.com}"
|
||||||
|
export HF_HOME="${HF_HOME:-$ROOT_DIR/dataset_building/generated/.hf_home}"
|
||||||
|
export HF_DATASETS_CACHE="${HF_DATASETS_CACHE:-$ROOT_DIR/dataset_building/generated/.hf_datasets_cache}"
|
||||||
|
|
||||||
|
OUT="${OUT:-$ROOT_DIR/dataset_building/generated/training_mix_v4_train1m_test2p8k_noupsample_nobbh_20260611}"
|
||||||
|
TOKENIZER="${TOKENIZER:-$ROOT_DIR/model_building/generated_models/Qwen3-0.6B-DSV4-tokenizer-remap-v2}"
|
||||||
|
TRAIN_TOTAL="${TRAIN_TOTAL:-1000000}"
|
||||||
|
TEST_PER_GROUP="${TEST_PER_GROUP:-400}"
|
||||||
|
SEED="${SEED:-20260611}"
|
||||||
|
MAX_SEEN_PER_SOURCE="${MAX_SEEN_PER_SOURCE:-300000}"
|
||||||
|
|
||||||
|
mkdir -p "$OUT" "$HF_HOME" "$HF_DATASETS_CACHE"
|
||||||
|
|
||||||
|
python dataset_building/build_training_and_test_mix_v3.py \
|
||||||
|
--out "$OUT" \
|
||||||
|
--tokenizer "$TOKENIZER" \
|
||||||
|
--train-total "$TRAIN_TOTAL" \
|
||||||
|
--test-per-group "$TEST_PER_GROUP" \
|
||||||
|
--seed "$SEED" \
|
||||||
|
--hf-endpoint "$HF_ENDPOINT" \
|
||||||
|
--use-hf \
|
||||||
|
--allow-shortfall \
|
||||||
|
--trust-metadata-lengths \
|
||||||
|
--max-seen-per-source "$MAX_SEEN_PER_SOURCE"
|
||||||
|
|
||||||
|
echo "Wrote SFT heldout and train mix to: $OUT"
|
||||||
|
echo "Heldout: $OUT/heldout_2p8k.jsonl"
|
||||||
|
echo "Exclusion hashes: $OUT/heldout_exclusion_hashes.jsonl"
|
||||||
@@ -7,6 +7,7 @@ import json
|
|||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
from collections import Counter, defaultdict
|
from collections import Counter, defaultdict
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
@@ -145,15 +146,30 @@ def prompt_hash(user):
|
|||||||
|
|
||||||
|
|
||||||
def load_tokenizer(path):
|
def load_tokenizer(path):
|
||||||
|
path_obj = Path(path)
|
||||||
try:
|
try:
|
||||||
return AutoTokenizer.from_pretrained(path, trust_remote_code=True)
|
return AutoTokenizer.from_pretrained(path, trust_remote_code=True)
|
||||||
except Exception:
|
except Exception:
|
||||||
return Tokenizer.from_file(str(Path(path) / "tokenizer.json"))
|
tokenizer_path = path_obj if path_obj.is_file() else path_obj / "tokenizer.json"
|
||||||
|
try:
|
||||||
|
return Tokenizer.from_file(str(tokenizer_path))
|
||||||
|
except Exception:
|
||||||
|
payload = json.loads(tokenizer_path.read_text(encoding="utf-8"))
|
||||||
|
if payload.get("implementation") != "laoyaomodel.bytes_bpe":
|
||||||
|
raise
|
||||||
|
model_root = os.environ.get("LAOYAO_MODEL_ROOT")
|
||||||
|
if model_root:
|
||||||
|
sys.path.insert(0, model_root)
|
||||||
|
from laoyaomodel.tokenization.bpe import BPETokenizer
|
||||||
|
|
||||||
|
return BPETokenizer.from_tokenizer_json(tokenizer_path)
|
||||||
|
|
||||||
|
|
||||||
def token_len(tok, text):
|
def token_len(tok, text):
|
||||||
if isinstance(tok, Tokenizer):
|
if isinstance(tok, Tokenizer):
|
||||||
return len(tok.encode(text, add_special_tokens=False).ids)
|
return len(tok.encode(text, add_special_tokens=False).ids)
|
||||||
|
if tok.__class__.__name__ == "BPETokenizer":
|
||||||
|
return len(tok.encode(text))
|
||||||
return len(tok(text, add_special_tokens=False)["input_ids"])
|
return len(tok(text, add_special_tokens=False)["input_ids"])
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user