DouDou commited on
Upload README.md with huggingface_hub
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207# Dataset Builder
This project contains the complete source code for building three domain-specific datasets for scientific computing code intelligence research.
## Project Structure
```dataset_builder/βββ README.md # This fileββββ data1/ # DATA1: Domain-Specific Code Datasetβ βββ main.py # Step 0-1: Keyword expansion + GitHub repo searchβ βββ main_v2.py # Step 0-4: Full pipeline (search β check β clone β filter)β βββ util.py # Shared utilities (logger, LLM calls, code extensions)β βββ download_dataset.py # Download ChemPile code dataset from HuggingFaceβ βββ merge_dataset.py # Merge crawled repos with ChemPile data, deduplicateβ βββ analysis.py # Code-level analysis (comments, functions, tokens)β βββ compute_stars_keywords.py # Compute stars/keyword statisticsβ βββ compute_statistics.py # Compute code statistics from JSONL analysis filesβ βββ rename.py # Rename repo directories to owner___repo formatβ βββ rename2.py # Rename ChemPile files with zero-padded numberingβ βββ pyproject.toml # Python project configβ βββ scripts/β β βββ export_files_to_csv.py # Export repo files to CSV grouped by keywordβ βββ reporting/ # Statistical reporting and visualizationβ β βββ __init__.pyβ β βββ main.py # Reporting entry pointβ β βββ visualization.py # Generate figures (funnel, distributions, etc.)β β βββ repo_meta_scan.py # Scan repo-level metadataβ β βββ code_file_stats.py # File-level code statisticsβ β βββ code_file_stats_fast.py # Optimized file-level statisticsβ β βββ stage_a_stats.py # Stage A (search/check) statisticsβ β βββ stage_b_stats.py # Stage B (clone/filter) statisticsβ β βββ join_insights.py # Join and cross-analyze insightsβ βββ README.md # DATA1 dataset documentationββββ data2/ # DATA2: Code-Documentation Alignment Datasetβ βββ instruction_generation/ # README summarization pipelineβ β βββ pipeline.py # Unified entry (summarize + parse modes)β β βββ summarize_repo_readme.py # Summarize repo READMEs using LLMβ β βββ extract_repo_functions.py # Extract functions from reposβ β βββ schemas.py # Pydantic data schemasβ β βββ prompts/β β βββ function_extract.txt # Prompt for function extractionβ β βββ readme_summary.txt # Prompt for README summarizationβ βββ step22/ # Function scoring, generation, alignmentβ β βββ build.py # Build tree-sitter language parsersβ β βββ func_stat.py # Extract functions using tree-sitterβ β βββ md_stat.py # Extract & save README summariesβ β βββ emb_qwen_func.py # Score functions using Qwen embedding modelβ β βββ emb_qwen_md.py # Score READMEs using Qwen embedding modelβ β βββ function_req.py # Filter functions by score thresholdβ β βββ gemini_generation.py # Generate docstrings using Gemini APIβ β βββ alignment.py # Align functions with generated docstringsβ β βββ prompt.txt # Prompt template for docstring generationβ β βββ depend_analysis.py # Dependency/call-graph analysisβ β βββ find_none_score_func.py # Find functions missing scoresβ β βββ folder_stat.py # Repository folder statisticsβ β βββ ppt.py # Visualization of alignment dataβ β βββ debug_parser.py # Debug tree-sitter parser loadingβ βββ README.md # DATA2 dataset documentationββββ data3/ # DATA3: Programming Problems Generation Datasetβ βββ main.py # RepoAgent: generate docs for reposβ βββ gemini.py # Gemini API connectivity testβ βββ load_dataset.py # Load and inspect datasetsβ βββ instruct_generation.py # Score functions for scientific relevanceβ βββ extract_functions.py # Extract functions from enhanced_dataset.csvβ βββ extract_functions_v2.py # Extract functions v2 (better CSV/JSON handling)β βββ merge_datasets.py # Merge res2.csv with dataset_all.csvβ βββ generate_programming_problems.py # Generate problems using Gemini APIβ βββ generate_problems_batch.py # Batch problem generation (OpenAI batch API)β βββ generate_problems_openai.py # Problem generation via OpenAI APIβ βββ enrich_programming_problems.py # Enrich problems with source code contextβ βββ vllm_high.py # VLLM-based high-throughput inferenceβ βββ vllm_qwen_batch.py # Qwen model batch inference via VLLMβ βββ show_pricing.py # Display API pricing informationβ βββ check_enhanced.py # Validate enhanced datasetβ βββ check_index_distribution.py # Check index distributionβ βββ check_match.py # Check data matchingβ βββ check_relationship.py # Check data relationshipsβ βββ is_sci_prompt.txt # Prompt: classify code as scientific computingβ βββ is_sci_prompt1.txt # Prompt variant for scientific classificationβ βββ score_prompt.txt # Prompt: score function relevanceβ βββ *.sh # Various shell scripts for batch processingβ βββ README.md # DATA3 dataset documentation```
## Dataset Building Pipelines
### DATA1: Domain-Specific Code Dataset
**Goal**: Collect, filter, and export domain-specific code from GitHub repositories.
**Pipeline** (executed in order):
1. **Keyword Expansion & Search** (`main.py` / `main_v2.py`) - Expand scientific keywords using LLM - Search GitHub API for repositories matching keywords - Check relevance using LLM (reads READMEs) - Clone relevant repos (shallow clone) - Filter to keep only code files
2. **External Data** (`download_dataset.py`) - Download ChemPile code dataset from HuggingFace
3. **Merge & Deduplicate** (`merge_dataset.py`) - Merge crawled repos with ChemPile data - Deduplicate by content hash
4. **Analysis** (`analysis.py`, `compute_*.py`) - Analyze code metrics (lines, comments, functions, tokens) - Compute keyword and stars statistics
5. **Export** (`scripts/export_files_to_csv.py`) - Export final dataset to CSV files grouped by keyword
6. **Reporting** (`reporting/`) - Generate statistical reports and visualizations
### DATA2: Code-Documentation Alignment Dataset
**Goal**: Generate high-quality docstrings for scientific code functions.
**Pipeline** (executed in order):
1. **README Summarization** (`instruction_generation/`) - Summarize repository READMEs using LLM - Extract structured information from repos
2. **Function Extraction** (`step22/func_stat.py`) - Parse code using tree-sitter to extract functions - Multi-language support (Python, C, C++, Java, Go, Rust, Julia)
3. **README Processing** (`step22/md_stat.py`) - Copy README summaries to function dataset directories
4. **Embedding Scoring** (`step22/emb_qwen_func.py`, `emb_qwen_md.py`) - Score function quality using Qwen embedding model - Score README quality using Qwen embedding model
5. **Function Filtering** (`step22/function_req.py`) - Filter functions by combined quality score
6. **Docstring Generation** (`step22/gemini_generation.py`) - Generate docstrings using Gemini API - Budget monitoring with circuit breaker - Checkpoint/resume support
7. **Alignment** (`step22/alignment.py`) - Merge function data with generated docstrings
### DATA3: Programming Problems Generation Dataset
**Goal**: Generate programming problems inspired by scientific code.
**Pipeline** (executed in order):
1. **Documentation Generation** (`main.py`) - Use RepoAgent to generate documentation for repositories
2. **Function Extraction** (`extract_functions.py`, `extract_functions_v2.py`) - Extract individual functions from enhanced dataset
3. **Scientific Relevance Scoring** (`instruct_generation.py`) - Score functions for scientific computing relevance - Use `is_sci_prompt.txt` and `score_prompt.txt` as prompts
4. **Dataset Merge** (`merge_datasets.py`) - Merge function scores with source code data
5. **Problem Generation** (`generate_programming_problems.py`) - Generate programming problems using Gemini API - Filter by relevance score - Budget monitoring and cost control
6. **Enrichment** (`enrich_programming_problems.py`) - Enrich generated problems with source code context
## Dependencies
### Common- `pandas`, `tqdm`, `jsonlines`- `python-dotenv`
### DATA1- `langchain`, `langchain-openai`, `pydantic`, `loguru`- `requests` (GitHub API)- `matplotlib`, `seaborn`, `wordcloud` (reporting)- `datasets` (HuggingFace)
### DATA2- `tree-sitter`, `tree-sitter-python`, `tree-sitter-c`, etc.- `vllm`, `transformers`, `torch` (embedding scoring)- `google-cloud-aiplatform`, `vertexai` (Gemini API)
### DATA3- `google-cloud-aiplatform`, `vertexai` (Gemini API)- `openai` (OpenAI API)- `vllm`, `transformers`, `torch` (local inference)
## Notes
- Scripts contain hardcoded paths that need to be updated for your environment- API credentials (GitHub token, Gemini, OpenAI) need to be configured separately- Large datasets require significant storage and compute resources- Most scripts support checkpoint/resume for long-running processesREADME.mdAdded+207