MCPcopy Index your code
hub / github.com/elena-luo/SODE

github.com/elena-luo/SODE @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
31 symbols 100 edges 6 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

DLCoT

How to reproduce

To run the code, you need to be able to utlize LLM for inference. Most steps generate files in the chatml format, where the data with the key "input" serves as the LLM's input. In the code, we assume that after each step, a new field named "result" is added to the original file, containing the LLM's output.

In the paper, we employ Qwen-2.5-72B-Instruct as the model for steps 1, 2, 3, and 5, while GPT-4o is used for step 4.

Step 1 Extract the pattern of the long chain-of-thought answer

Run inference for the file data/20250209_deepseek_r1_math_26K.jsonl we provide.

Step 2 Further decompose the solution part and the verification part

step 2.1

python pattern_extraction.py --part=basic_structure

This will generate three files:

R1_split_part1.jsonl: The basic structre of long CoTs generated by R1

R1_solution_explore.jsonl: The prompt created for further solution decomposition.

R1_verify_explore.jsonl: The prompt created for further verification decomposition.

You need to run inference for R1_solution_explore.jsonl and R1_verify_explore.jsonl

step 2.2

python pattern_extraction.py --part=solution_verification_explore

This will generate a file named R1_split_part2_filtered.jsonl. This is the intermediate version of long CoT decomposition. You need to run inference for it.

step 2.3

python solution_clustering.py --status=complete_answer

This step improves the division between the solution section and the verification section, making the final solution more complete. A file named R1_split_part2_filtered_complete_answer.jsonl will be generated. You need to run inference for it.

Step 3 Solution labeling

python solution_classification.py

This will generate a file named R1_split_part2_filtered_solution_classification.jsonl: solution(approach) labeling

Step 4 Solution clustering

step 4.1

python solution_clustering.py --status=clustering

This will generate a file named R1_split_part2_filtered_clustering.jsonl: input of solution(approach) clustering

R1_split_part2_filtered_complete_answer_output.json: The final result of decomposition of the long CoT

You need to run LLM inference for R1_split_part2_filtered_clustering.jsonl

step 4.2

python solution_clustering.py --status=clustering_extract

This will generate a file named R1_split_part2_filtered_need_filter.json, which adds clustering information to the final result.

Step 5 Chain-of-thought optimization

There are two seperate strategies we design for solution optimization, redundancy reduction and incorrectness reduction.

step 5.1 Solution optimization by redundancy reduction

python redundancy_deduction.py

This will generate files:

R1_split_part2_filtered_delete_multi_1_need_simplize.jsonl

R1_split_part2_filtered_delete_multi_2_need_simplize.jsonl

R1_split_part2_filtered_delete_multi_all_need_simplize.jsonl

step 5.2 Solution optimization by incorrectness reduction (optional)

python incorrectness_deduction.py

This step will generate a file named R1_split_part2_ablation_keep_one_global_delete_all_need_simplize.jsonl

There are more settings in the code, but they do not yield good performance. You could try on your own data if you are interested.

By running LLM inference using files in step 5, you will be able to get the optimized training data.

Core symbols most depended-on inside this repo

find_str_in_list
called by 6
pattern_extraction.py
jaccard_similarity
called by 3
pattern_extraction.py
split_refine
called by 3
pattern_extraction.py
run
called by 3
solution_clustering.py
find_cluster_by_index
called by 2
incorrectness_deduction.py
part1_split
called by 2
pattern_extraction.py
run
called by 2
pattern_extraction.py
find_first_correct_index
called by 1
incorrectness_deduction.py

Shape

Method 17
Function 10
Class 4

Languages

Python100%

Modules by API surface

pattern_extraction.py9 symbols
solution_clustering.py8 symbols
incorrectness_deduction.py7 symbols
solution_classification.py4 symbols
redundancy_deduction.py3 symbols

For agents

$ claude mcp add SODE \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact