CodeI/O
CodeI/O
소개
CodeI/O는 코드 기반의 추론 패턴을 자연어 형식으로 변환하여 대형 언어 모델(LLM)의 추론 능력을 향상시키는 새로운 접근 방식입니다. 기존 방법이 특정 기술에 집중하는 반면, CodeI/O는 보편적인 추론 패턴을 체계적으로 추출하여 논리적 구조를 유지하면서도 다양한 추론 작업에서 성능을 향상시킵니다.
주요 특징
- 범용 변환: 다양한 코드 패턴을 자연어 Chain-of-Thought(CoT) 방식으로 변환
- 문법 독립: 코드 문법에 의존하지 않으면서도 논리적 구조 유지
- 멀티태스킹 성능 향상: 논리, 수학, 과학, 상식, 코드 추론 성능 개선
- 완전 검증 가능: 실제 코드 실행을 통한 정확성 검증 지원
- 고급 버전(CodeI/O++): 다중 회차 수정 및 재검증으로 정확도 향상
공개된 리소스
CodeI/O 프로젝트는 다음과 같은 리소스를 제공합니다: hkust-nlp/CodeIO
시작하기
설치
CodeI/O 환경을 설정하는 방법은 두 가지가 있습니다.
📌 Option 1: requirements.txt 이용
conda create -n codeio_exec python=3.11 conda activate codeio_exec pip install -r requirements.txt 📌 Option 2: environment.yaml 이용
conda env create -f environment.yaml --name codeio_exec conda activate codeio_exec ⚠️ 특정 코드 실행에는 환경 업데이트가 필요할 수 있습니다.
데이터 처리
CodeI/O 데이터 처리는 6단계로 구성됩니다.
1단계: 코드 변환
python ./src/build_transform_msg.py \ --raw_code_file data/rawcode_1k.jsonl \ --raw_code_msg_file data/rawcode_1k_msg.jsonl 2단계: 코드 I/O 쌍 생성
python ./src/parse_gen_ios.py \ --input_file data/rawcode_1k_unified.jsonl \ --output_file data/rawcode_1k_parsed.jsonl \ --python_path "python" \ --run_path "./temp/temp/temp" 3단계: 입출력 예측 인스턴스 생성
python ./src/build_codeio_msg.py \ --input_file data/rawcode_1k_parsed.jsonl \ --output_file data/codeio_1k_msg.jsonl 4단계: 모델 추론
python ./src/batched_api_inference.py \ --input data/codeio_1k_msg.jsonl \ --output data/codeio_1k_gens.jsonl \ --model deepseek-chat \ --num_process 10 \ --num_thread 10 \ --key <your key> \ --temperature 0.7 \ --max_tokens 4096 5단계: 검증
bash ./scripts/pipeline_check.sh \ data/rawcode_1k_parsed.jsonl \ data/codeio_1k_gens.jsonl \ data/codeio_1k_gens_verified.jsonl\ 6단계: 다중 회차 수정 및 재검증
python ./src/build_codeio_rev_msg.py \ --input_file data/codeio_1k_gens_verified.jsonl \ --output_file data/codeio_1k_msg_rev.jsonl bash 복사 편집 python ./src/batched_api_inference.py \ --input data/codeio_1k_msg_rev.jsonl \ --output data/codeio_1k_gens_rev.jsonl \ --model deepseek-chat \ --num_process 10 \ --num_thread 10 \ --key <your key> \ --temperature 0.7 \ --max_tokens 4096`` bash ./scripts/pipeline_check.sh \ data/rawcode_1k_parsed.jsonl \ data/codeio_1k_gens_rev.jsonl \ data/codeio_1k_gens_rev_verified.jsonl python ./src/assemble_codeio_demo.py \ --result_file_turn1 data/codeio_1k_gens_verified.jsonl \ --result_file_turn2 data/codeio_1k_gens_rev_verified.jsonl \ --output_file codeio_demo_final.jsonl This post is licensed under CC BY 4.0 by the author.