run2_nlp-paper-reproduction
Complete setup guide for reproducing NLP paper results with HuggingFace TRL/transformers on Python 3.12 - use when setting up environments for preference optimization experiments.
- License 许可
- MIT
- 最近更新
- 2026-10-02
- Stars
- ★ 93
- Forks
- 7
01 前言 Front Matter
- name
- run2_nlp-paper-reproduction
- description
- Complete setup guide for reproducing NLP paper results with HuggingFace TRL/transformers on Python 3.12 - use when setting up environments for preference optimization experiments.
03 SKILL.md 正文
NLP Paper Reproduction Setup Guide
Environment Detection
# Check what Python is available
which python3 && python3 -V
which python && python -V 2>/dev/null || echo "no 'python' command"
Package Installation (Python 3.12, system Python)
Important: Python 3.12 may require --break-system-packages flag for pip.
# Step 1: PyTorch (CPU version for testing, or CUDA for training)
python3 -m pip install torch==2.2.2 --index-url https://download.pytorch.org/whl/cpu --break-system-packages
# Step 2: HuggingFace ecosystem
python3 -m pip install transformers==4.44.2 accelerate==0.29.2 datasets==2.18.0 peft==0.7.1 --break-system-packages
# Step 3: TRL (Transformer Reinforcement Learning)
python3 -m pip install trl==0.9.6 --break-system-packages
# Step 4: Missing dependencies (TRL 0.9.6 requires 'rich')
python3 -m pip install rich --break-system-packages
Import Test
from scripts.simpo_trainer import SimPOTrainer # must run from project root
Running Unit Tests
Unit tests import from scripts.simpo_trainer import ..., so they need PYTHONPATH:
# Method 1: Set PYTHONPATH to project root
PYTHONPATH=/root/SimPO python3 /root/SimPO/unit_test/unit_test_1.py
# Method 2: Run from project root with module path
cd /root/SimPO && PYTHONPATH=. python3 unit_test/unit_test_1.py
# With pytest
python3 -m pip install pytest --break-system-packages
PYTHONPATH=/root/SimPO python3 -m pytest unit_test/ -v
Logging Environment for Reproducibility
python3 -VV > /root/python_info.txt
python3 -m pip freeze >> /root/python_info.txt
Common Issues & Fixes
ModuleNotFoundError: No module named 'scripts'
- Root cause: Working directory not set to project root
- Fix:
PYTHONPATH=/root/SimPO python3 unit_test/unit_test_1.py
ModuleNotFoundError: No module named 'rich'
- Root cause: TRL 0.9.6 requires
richwhich isn't auto-installed - Fix:
python3 -m pip install rich --break-system-packages
ERROR: This environment is externally managed
- Root cause: Ubuntu 24.04+ restricts system pip
- Fix: Add
--break-system-packagesflag to pip commands
PDF Reading
# Install poppler for PDF text extraction
apt-get install -y poppler-utils
pdftotext /path/to/paper.pdf /tmp/paper.txt
cat /tmp/paper.txt
TRL 0.9.6 API Notes
from trl.trainer import CPOTrainer— base class sometimes usedfrom trl.trainer.utils import DPODataCollatorWithPadding, disable_dropout_in_model, pad_to_length, peft_module_casting_to_bf16, trl_sanitze_kwargs_for_tagging- Note:
trl_sanitze_kwargs_for_tagging(typo: "sanitze" not "sanitize") is intentional in trl source
04 同仓库更多 Skills
object_counter
Count occurrences of an object in the image using computer vision algorithm.
travel-planning-workflow
Invoke this skill when performing travel planning. It defines a structured workflow for generating itineraries. Following this workflow is essential to ensure the final plan satisfies user requirements.
bundled-dataset-search-tool
invoke this skill when you need to perform database search for travel planning. This skill provides some useful pre-packaged tools to look up accommodations, attractions, cities, driving distance, flights, and restaurants from the bundled dataset.
glm-output
Output-processing guidance for GLM tasks. Especially useful after glm-basics and glm-calibration when you need verifier-matching metrics from output.nc and a final /root/metrics.json.
glm-calibration
Calibration guidance for GLM tasks. Often most effective after glm-basics has clarified the setup; glm-output is the companion skill for exact final metric computation.
glm-basics
A good starting point for GLM calibration tasks. Use to inspect glm3.nml, confirm how GLM runs, and identify the relevant files before moving on to calibration and output evaluation.