Web Analytics

FAC-Synthesis

⭐ 97 stars Traditional Chinese by Zhongzhi660

🌐 語言

少即是多:在LLMs特徵空間中合成多樣化數據

這是論文《少即是多:在LLMs特徵空間中合成多樣化數據》的官方實現。


核心洞見

聰明工作,而非辛苦工作。

在大型語言模型(LLMs)後訓練階段,與其盲目地添加大量表層多樣的文本,不如精確識別並合成那些真正缺失的關鍵特徵。僅需少量有針對性的合成樣本,即可顯著提升特徵啟用覆蓋率(FAC)的不足,從而帶來下游任務的明顯性能提升。

為什麼這個洞見簡單卻強大?

傳統的數據合成注重數量和表層多樣性(詞彙、句型、主題分布),但這些往往只是薄弱的代理指標。真正決定模型下游表現的是目標任務所需關鍵特徵的覆蓋情況

我們的工作揭示:

圖 1: 指令遵循數據集的效率前緣。我們提出的方法僅用 2K 合成樣本(對比 MAGPIE 的 300K),即可在 AlpacaEval 2.0 上達到與 MAGPIE 相當的 Win Rate。


快速開始

安裝

git clone https://github.com/Zhongzhi660/FAC-Synthesis.git
cd FAC-Synthesis
pip install -r requirements.txt


Repository Structure

FAC-Synthesis/
├── LICENSE
├── README.md
├── requirements.txt
│
├── sae_pretrain/                 # SAE pretraining
│   ├── datasets/                 # pretraining corpora (constructed from public sources)
│   └── outputs/                  # SAE pre-trained weights
│
├── sae_feature_analysis/         # SAE feature analysis pipeline
│   ├── interpret_features/       # feature interpretation (span collection + annotation)
│   ├── identify_task_relevant_features/   # task-relevant feature identification
│   └── identify_missing_features/         # missing-feature discovery (coverage gap)
│
├── fac_synthesis/                # FAC synthesis pipeline
│   ├── step1_contrastive_pair_construction/      # Step-1: contrastive pair construction
│   └── step2_feature_covered_sample_synthesis/   # Step-2: feature-covered synthesis
│
└── training_scripts/             # Downstream training / evaluation scripts
    ├── toxicity_detection/
    ├── reward_modeling/
    ├── instruction_following/
    └── behavior_steering/

預訓練稀疏自編碼器

大部分用於SAE預訓練的腳本位於 sae_pretrain/。我們在 Hugging Face 提供了預訓練好的SAE檢查點: 要預訓練SAE,請執行以下命令:

# Step-1: Collect hidden activations from the backbone LLM (e.g., layer 16)
python create_actvs_uni.py 0 0 1 meta-llama/Llama-3.1-8B-Instruct 16

Step-2: Train SAEs on the target layer (e.g., layer 16)

python train_SAEs.py 0 16 meta-llama/Llama-3.1-8B-Instruct /sae_input/prompt_actvs_l16

分析SAE的特徵

特徵分析腳本位於 sae_feature_analysis/。若要分組激活範圍並生成易於理解的特徵解釋,請執行:

# Step-1: Group extracted activation spans
python groupby_textspans.py /xxx/threshold_0.0

Step-2: Annotate feature explanations based on grouped spans

python annotate_explanations.py /xxx/threshold_0.0.tsv

Step-3: Identify task-relevant features from the explanations

python annotate_toxicity.py /xxx/threshold_0.0_explained.tsv

Step-4: Identify missing features via FAC analysis

python identify_fac.py anchor_features.tsv (complete) task_features.tsv (currently available)

覆蓋率導向的資料合成

覆蓋率導向的合成腳本位於 fac_synthesis/。要生成合成查詢,請執行

# Step-1 (1): Contrastive Pair Construction
python generate_data_llama_r1.py \
  --features xxx.tsv \
  --out xxx \
  --temperature 0.8

Step-1 (2): Feature-Covered Sample Synthesis

python analyze_step1_synthetic_data.py python merge_step1_failed_cases.py

Step-2: Feature-Covered Sample Synthesis

python generate_data_llama_r2.py \ --features xxx.tsv \ --out xxx \ --temperature 0.8


致謝

在評估階段,我們的下游訓練與測試腳本皆改編自以下開源資料庫:

引用

如果您覺得本研究對您的研究有所幫助,請引用我們的論文 🤩:

@article{li2026less,
  title={Less is Enough: Synthesizing Diverse Data in Feature Space of LLMs},
  author={Li, Zhongzhi and Wu, Xuansheng and Li, Yijiang and Hu, Lijie and Liu, Ninghao},
  journal={arXiv preprint arXiv:2602.10388},
  year={2026}
}

--- Tranlated By Open Ai Tx | Last indexed: 2026-05-27 ---