Task vector skill is a research codebase for static Chain-of-Thought transfer and evaluation.
The current default workflow in this repo is:
- use a source LLM to generate self-CoT
- extract static CoT vectors from correct samples
- inject those vectors back into the same or another LLM
- evaluate
baseline,base,ffn, orattnbehavior
The most stable path in this repo today is the unimodal Qwen pipeline:
- model:
qwen2.5-7b-instruct - datasets:
gsm8k,commonsenseqa,strategyqa - workflow:
baseline -> generate -> extract -> eval
This repo also contains earlier multimodal and training-oriented code, but the shared demo path we currently recommend is the static pipeline above.
Core capabilities:
- self-CoT generation with src/generate_self_cot.py
- static vector extraction with src/extract_cot_vector.py
- baseline evaluation with src/eval_baseline.py
- base-vector evaluation with src/eval_base.py
- FFN / LIVE-style evaluation with src/eval_licv.py
- attention / MimIC evaluation with src/eval_mimic.py
- end-to-end automation with scripts/run_static_pipeline.py
- layerwise sweeps with scripts/run_eval_layers_base.py, scripts/run_eval_layers_licv.py, and scripts/run_eval_layers_mimic.py
The shared environment file is environment.yml.
It creates an environment named licv.
conda env create -f environment.yml
conda activate licvWhat environment.yml is intended to cover:
- the default
licvConda environment name - the core runtime for the shared static pipeline
- PyTorch
2.5.1with CUDA12.1 - the main Hugging Face stack such as
transformers,datasets,accelerate, andpeft - config and evaluation packages such as
hydra-core,omegaconf, andevaluate - repo-specific utility dependencies such as
deepspeed,sentencepiece,safetensors,bytecode,xxhash, andpython-Levenshtein
The current shared default setup in this repo only supports:
- model:
qwen2.5-7b-instruct - datasets:
strategyqa,commonsenseqa,gsm8k
This means anyone using the shared static pipeline should prepare:
- a local path to the
qwen2.5-7b-instructmodel weights - a local path to the
strategyqadataset - a local path to the
commonsenseqadataset - a local path to the
gsm8kdataset
These local paths are machine-specific. When sharing this repo, do not keep your own server paths hardcoded in commands or configs. Instead, replace the example paths below with the actual paths on your own machine.
This repo uses four method names during evaluation:
baseline: no extracted CoT vector is injected. This is the plain reference run.base: inject a static hidden-state style vector with src/eval_base.py. In practice, this is the simplest "add the extracted vector back into the model" setting.ffn: inject the extracted vector through the FFN / MLP path with src/eval_licv.py. In this repo, this corresponds to the LIVE-style / LICV-style FFN shift path.attn: inject the extracted vector through the attention path with src/eval_mimic.py. In this repo, this is the MimIC-style attention shift path.
Run the default full StrategyQA attention pipeline on one visible GPU:
python scripts/run_static_pipeline.py \
--model-name qwen2.5-7b-instruct \
--dataset strategyqa \
--method attn \
--devices 0What this does by default:
- runs
baseline - generates self-CoT on
500training-side samples - extracts a run-local
.ptvector - runs the requested eval method
- for
base,ffn, andattn, uses layerwise evaluation unless--no-layerwiseis given
Useful variants:
# single eval instead of layerwise sweep
python scripts/run_static_pipeline.py \
--model-name qwen2.5-7b-instruct \
--dataset gsm8k \
--method ffn \
--devices 0 \
--no-layerwise \
--single-layer 15
# baseline only
python scripts/run_static_pipeline.py \
--model-name qwen2.5-7b-instruct \
--dataset commonsenseqa \
--method baseline \
--devices 0
# preview commands without executing
python scripts/run_static_pipeline.py \
--model-name qwen2.5-7b-instruct \
--dataset strategyqa \
--method attn \
--dry-runEach pipeline run writes into:
results/static_pipeline/<run_tag>/
Typical contents:
logs/records/self_cot_data.jsonself_cot_data_correct_only.json<run_tag>.ptrun_summary.json
The shared Codex skill for this workflow is:
Use this skill when you want Codex to:
- switch datasets between
gsm8k,commonsenseqa, andstrategyqa - switch methods between
baseline,base,ffn, andattn - update Hydra overrides automatically
- run the full static pipeline end to end
- recover from small runtime/config errors during long jobs
What this skill does for you:
- chooses the matching eval entrypoint automatically
- keeps the recommended order
baseline -> generate -> extract -> eval - uses the method-matched layerwise runner for
base,ffn, andattn - updates
model_name,data.name,self_cot_path, andextracted_cot_vector_pathwhen the task is clear
How to use the skill with Codex:
- mention the pipeline skill and state the dataset, model, and method you want
- for full runs, ask for the whole pipeline from
baselineto extraction and evaluation - for analysis-only runs, ask for a single method or a single layer
- if you already have
self_cot_data_correct_only.jsonor a.ptvector, say so and Codex can skip earlier stages
Example prompts for Codex:
Use the pipeline skill to run the full static pipeline on strategyqa with qwen2.5-7b-instruct and method attn.
Use the pipeline skill to run baseline and then an ffn layerwise sweep on gsm8k.
Use the pipeline skill to evaluate the existing extracted vector at results/static_pipeline/my_run/my_run.pt with method base on layer 15 only.
Use the pipeline skill to switch the current setup from commonsenseqa + ffn to strategyqa + attn and keep the same model.
A practical mapping from user intent to method:
- choose
baselinewhen you want the no-vector reference - choose
basewhen you want the simplest direct vector injection baseline - choose
ffnwhen you want FFN / MLP-path injection - choose
attnwhen you want attention-path injection
Main directories:
- src: core pipeline logic, eval entrypoints, vector extraction, model helpers
- src/config: Hydra config files
- src/dataset_utils: dataset loaders and prompt formatting
- scripts: automation helpers and layerwise runners
- skills: Codex skills for shared usage
- results: generated outputs and evaluation records
-
This contains the main shift implementations, including MimIC-style attention shifts and FFN-based variants.
-
This centralizes model resolution, runtime device selection, and several shared helpers used by the eval and extraction scripts.
-
scripts/run_static_pipeline.py
This is the recommended shared controller for static experiments. It handles stage ordering, logging, cache setup, dataset/model path overrides, and run summaries.