--- language: - en - tr license: cc-by-4.0 task_categories: - text-generation - question-answering task_ids: - language-modeling - open-domain-qa tags: - code - programming - sql - python - javascript - php - shell - devops - typescript - system-design - instruction-tuning - alpaca - sft - stackoverflow size_categories: - 10K 🇬🇧 English  |  🇹🇷 Türkçe

--- # Code & Programming Q&A — SFT Dataset A curated instruction-tuning dataset of **47,190** high-quality programming question-answer pairs, collected from StackOverflow and GitHub, cleaned through a multi-stage quality pipeline, and formatted in Alpaca style for supervised fine-tuning (SFT) of large language models. --- ## Dataset Summary | Property | Value | |---|---| | Records | 47,190 | | Format | Alpaca (`instruction` / `output` / `system`) | | Total tokens | ~23.0 Million | | Avg tokens / record | 486 | | Min quality score | 5.00 / 10 | | Avg quality score | 7.71 / 10 | | High quality (≥ 7.0) | 31,486 records (66.7%) | | Primary language | English | | Primary source | StackOverflow (99.8%) | --- ## Supported Tasks - **Supervised Fine-Tuning (SFT):** Direct use with TRL `SFTTrainer`, Unsloth, LLaMA-Factory, or Axolotl — no preprocessing required. - **Instruction Following:** Model learns to answer technical questions with explanation and code examples. - **Code Generation:** 65%+ of records contain at least one code block in the output. --- ## Data Collection ### Sources | Source | Records | % | |---|---|---| | StackOverflow (via API) | 47,119 | 99.8% | | GitHub Issues / Discussions | 71 | 0.2% | Data was collected using a custom async pipeline with the official **StackOverflow API v2.3** and **GitHub REST API v3**. ### StackOverflow Collection Rules - Only questions with **at least one accepted or upvoted answer** were collected. - `question_score + answer_score` used as raw quality signal. - Questions tagged with target technology domains (SQL, Python, JavaScript, PHP, Shell, DevOps, TypeScript, System Design, WordPress). - Collected answers: accepted answer preferred; fallback to highest-voted answer. - API quota managed with exponential back-off on rate limits. ### GitHub Collection Rules - Issues and discussions with substantive responses only. - Comment pagination handled to capture full thread context (100+ comment issues). - Dismissal patterns filtered out (*"please provide a repro"*, *"closing as duplicate"*, etc.). --- ## Processing Pipeline Every raw record passes through a **4-stage pipeline** before entering the dataset: ``` Raw API Response │ ▼ ┌────────────────────────────────────┐ │ Stage 1: clean() │ │ • Whitespace normalization │ │ • Empty block removal │ │ • Within-record code dedup │ ← same code block repeated → keep first └──────────────┬─────────────────────┘ │ ▼ ┌────────────────────────────────────┐ │ Stage 2: dedup() │ │ • SHA-256 hash of all content │ │ • Cross-record exact dedup │ └──────────────┬─────────────────────┘ │ ▼ ┌────────────────────────────────────┐ │ Stage 3: quality() │ │ • Fusion scoring (0–10) │ │ • signal_score (SO votes) │ │ • length_score (content size) │ │ • code_score (has code block) │ │ • Records < 5.0 dropped │ └──────────────┬─────────────────────┘ │ ▼ ┌────────────────────────────────────┐ │ Stage 4: Indexer filters │ │ • Link-only answers filtered │ │ • GitHub dismissal filtered │ │ • Content dedup (SHA-1 Q+A) │ └──────────────┬─────────────────────┘ │ ▼ dataset.jsonl ``` ### Quality Scoring Formula Scores are on a **0–10 scale**, computed as a weighted fusion: **When source signal exists** (SO votes, GH reactions): ``` score = (0.6 × signal_score + 0.3 × length_score + 0.1 × code_score) × 10 ``` **When no source signal** (file sources): ``` score = (0.7 × length_score + 0.3 × code_score) × 10 ``` Where: - `signal_score = min(1.0, log1p(raw_votes) / log1p(1000))` — 1000 votes → 1.0, 100 votes → 0.67 - `length_score = min(1.0, total_chars / 500)` — 500+ chars → full score - `code_score = 1.0 if code present else 0.3` Only records with `quality_score >= 5.0` are exported to this dataset. --- ## Dataset Structure ### Data Fields | Field | Type | Description | |---|---|---| | `id` | `string` | Unique record identifier (source-prefixed, e.g. `so_12345678`) | | `instruction` | `string` | The question / prompt (from user role) | | `output` | `string` | The answer with optional code blocks in markdown | | `system` | `string` | System prompt — always empty string `""` in this dataset | | `technology` | `string` | Domain label: `python`, `sql`, `javascript`, `php`, `shell_scripting`, `devops`, `typescript`, `system_design`, `wordpress` | | `quality_score` | `float` | Quality score 5.01–10.0 | | `source` | `string` | Data source: `stackoverflow` or `github` | | `meta.tier` | `string` | Complexity tier: `short`, `medium`, or `deep_reasoning` | | `meta.total_tokens` | `int` | Approximate token count (chars / 4) | ### Example Record ```json { "id": "so_53927460", "instruction": "How do I merge two dictionaries in a single expression in Python?\n\nI want to merge two dictionaries into a new dictionary. If both dicts have the same key, the second dict's value should take precedence.", "output": "In Python 3.9+, you can use the merge operator:\n\n```python\nz = x | y\n```\n\nFor older Python versions:\n\n```python\nz = {**x, **y}\n```\n\nThis creates a new dictionary. Values from `y` overwrite values from `x` when keys overlap.", "system": "", "technology": "python", "quality_score": 9.87, "source": "stackoverflow", "meta": { "tier": "medium", "total_tokens": 312 } } ``` ### Tier Distribution The `meta.tier` field classifies records by approximate token length, designed for hardware-aware SFT sampling: | Tier | Token Range | Records | % | Purpose | |---|---|---|---|---| | `short` | 0–256 tokens | 15,582 | 33.0% | Quick Q&A, definitions | | `medium` | 256–768 tokens | 24,421 | 51.8% | Explained answers with code | | `deep_reasoning` | 768+ tokens | 7,187 | 15.2% | Complex multi-step solutions | ### Technology Distribution | Technology | Records | |---|---| | SQL | 8,730 | | Shell Scripting | 8,355 | | Python | 7,540 | | PHP | 6,377 | | JavaScript | 6,058 | | System Design | 4,429 | | DevOps | 3,255 | | TypeScript | 1,909 | | WordPress | 537 | ### Quality Distribution | Score Range | Records | % | |---|---|---| | 9.0 – 10.0 | 8,666 | 18.4% | | 7.0 – 9.0 | 22,820 | 48.4% | | 5.0 – 7.0 | 15,704 | 33.3% | --- ## Usage ### Load with 🤗 Datasets ```python from datasets import load_dataset ds = load_dataset("hadilenya/AI-Trainer-Studio", split="train") print(ds[0]) ``` ### SFT with TRL ```python from datasets import load_dataset from trl import SFTTrainer, SFTConfig ds = load_dataset("hadilenya/AI-Trainer-Studio", split="train") def formatting_func(example): return f"### Instruction:\n{example['instruction']}\n\n### Response:\n{example['output']}" trainer = SFTTrainer( model=model, train_dataset=ds, formatting_func=formatting_func, args=SFTConfig(max_seq_length=2048, ...), ) trainer.train() ``` ### Mistral / Llama-3 Chat Format ```python def to_mistral(example): return f"[INST] {example['instruction']} [/INST] {example['output']}" def to_llama3(example): return ( f"<|begin_of_text|>" f"<|start_header_id|>user<|end_header_id|>\n{example['instruction']}<|eot_id|>" f"<|start_header_id|>assistant<|end_header_id|>\n{example['output']}<|eot_id|>" ) ``` ### Hardware-Aware Sampling (with `meta.tier`) ```python # RTX 2060 (6GB) — VRAM-safe sampling short = ds.filter(lambda x: x["meta"]["tier"] == "short") medium = ds.filter(lambda x: x["meta"]["tier"] == "medium") deep = ds.filter(lambda x: x["meta"]["tier"] == "deep_reasoning") # Ratio: short 60% · medium 35% · deep 5% from datasets import concatenate_datasets n = 8000 sampled = concatenate_datasets([ short.shuffle(seed=42).select(range(min(int(n*0.60), len(short)))), medium.shuffle(seed=42).select(range(min(int(n*0.35), len(medium)))), deep.shuffle(seed=42).select(range(min(int(n*0.05), len(deep)))), ]) ``` ### Filter by Technology ```python python_ds = ds.filter(lambda x: x["technology"] == "python") sql_ds = ds.filter(lambda x: x["technology"] == "sql") ``` ### Filter by Quality ```python # High quality only (≥ 7.0 — 69.4% of dataset) high_quality = ds.filter(lambda x: x["quality_score"] >= 7.0) ``` --- ## Data Splits This dataset is released as a single `train` split. For training, we recommend creating your own train/validation/test split: ```python split = ds.train_test_split(test_size=0.08, seed=42) train_ds = split["train"] eval_ds = split["test"] ``` --- ## Limitations & Considerations - **Language:** All records are in **English**. Not suitable for multilingual fine-tuning without translation. - **Source bias:** 99.8% StackOverflow — answers reflect Stack Overflow community norms (concise, code-first). - **Time range:** Data collected in 2026. May not reflect very recent library versions or deprecations. - **Domain scope:** Focused on web development, scripting, databases, and DevOps. Not suitable for domain-specific fine-tuning in medicine, law, finance, etc. - **Code correctness:** Code blocks are sourced from community answers. While high-vote answers are generally correct, no automated code execution or test verification was performed. - **GitHub records (0.2%):** Very small fraction — 70 records from GitHub Issues. Treat as supplementary. --- ## License This dataset is released under the **Creative Commons Attribution 4.0 (CC BY 4.0)** license. StackOverflow content is licensed under [CC BY-SA 4.0](https://stackoverflow.com/help/licensing). Attribution is preserved via the `id` field (e.g., `so_12345678` links to `https://stackoverflow.com/q/12345678`). --- ## Citation If you use this dataset in your research or project, please cite: ```bibtex @dataset{code_qa_sft_2026, title = {Code \& Programming Q\&A — SFT Dataset}, author = {Muharrem}, year = {2026}, publisher = {HuggingFace}, url = {https://huggingface.co/datasets/hadilenya/AI-Trainer-Studio} } ``` --- ## Changelog | Version | Date | Description | |---|---|---| | v1.0 | 2026-05-17 | Initial release — 47,190 records, Alpaca format, meta.tier annotation | --- --- # Kod & Programlama Soru-Cevap — SFT Veri Seti

⬆️ Back to English

StackOverflow ve GitHub'dan derlenen, çok aşamalı bir kalite boru hattından geçirilmiş **47.190** yüksek kaliteli programlama soru-cevap çiftinden oluşan, büyük dil modellerinin ince ayarı (SFT) için Alpaca formatında hazırlanmış bir veri setidir. --- ## Özet | Özellik | Değer | |---|---| | Kayıt sayısı | 47.190 | | Format | Alpaca (`instruction` / `output` / `system`) | | Toplam token | ~23,0 Milyon | | Ortalama token / kayıt | 486 | | Min kalite skoru | 5,00 / 10 | | Ort kalite skoru | 7,71 / 10 | | Yüksek kalite (≥ 7,0) | 31.486 kayıt (%66,7) | | Ana dil | İngilizce | | Ana kaynak | StackOverflow (%99,8) | --- ## Veri Toplama ### Kaynaklar | Kaynak | Kayıt | % | |---|---|---| | StackOverflow (resmi API v2.3) | 47.119 | %99,8 | | GitHub Issues / Discussions | 71 | %0,2 | Veriler, özel bir asenkron pipeline ile **StackOverflow API v2.3** ve **GitHub REST API v3** üzerinden toplanmıştır. ### StackOverflow Toplama Kuralları - Yalnızca **kabul edilmiş veya yüksek oy almış en az bir cevabı olan** sorular alındı. - `soru_oyu + cevap_oyu` toplamı ham kalite sinyali olarak kullanıldı. - Hedef teknoloji etiketleri: SQL, Python, JavaScript, PHP, Shell, DevOps, TypeScript, Sistem Tasarımı, WordPress. - Önce kabul edilmiş cevap; yoksa en yüksek oylanan cevap. - Rate limit aşımlarında üstel geri çekilme (exponential back-off) ile kota yönetimi. ### GitHub Toplama Kuralları - Yalnızca gerçek içerik barındıran yanıtlı issue ve tartışmalar. - 100+ yorum içeren issue'larda sayfalama ile tam içerik çekildi. - *"Lütfen repro ekleyin"*, *"duplicate olarak kapatılıyor"* gibi reddedici kalıplar otomatik filtrelendi. --- ## İşleme Boru Hattı Her ham kayıt veri setine girmeden önce **4 aşamalı bir pipeline**'dan geçer: ``` Ham API Yanıtı │ ▼ ┌────────────────────────────────────┐ │ Aşama 1: clean() │ │ • Boşluk normalleştirme │ │ • Boş blok temizleme │ │ • Kayıt içi kod bloğu dedup │ ← aynı blok tekrar ediyorsa ilki korunur └──────────────┬─────────────────────┘ │ ▼ ┌────────────────────────────────────┐ │ Aşama 2: dedup() │ │ • SHA-256 içerik hash'i │ │ • Kayıtlar arası tam eşleşme │ └──────────────┬─────────────────────┘ │ ▼ ┌────────────────────────────────────┐ │ Aşama 3: quality() │ │ • Füzyon skoru (0–10) │ │ • signal_score (SO oyu) │ │ • length_score (içerik uzunl.) │ │ • code_score (kod bloğu var?) │ │ • 5,0 altı kayıtlar elenir │ └──────────────┬─────────────────────┘ │ ▼ ┌────────────────────────────────────┐ │ Aşama 4: İndeksleyici filtresl.│ │ • Sadece link olan cevap elenir│ │ • GitHub reddedici yorum elenir│ │ • İçerik dedup (SHA-1 S+C) │ └──────────────┬─────────────────────┘ │ ▼ dataset.jsonl ``` ### Kalite Skoru Formülü (0–10) **Kaynak sinyali varsa** (SO oyu, GH reaksiyonu): ``` skor = (0,6 × sinyal_skoru + 0,3 × uzunluk_skoru + 0,1 × kod_skoru) × 10 ``` **Kaynak sinyali yoksa:** ``` skor = (0,7 × uzunluk_skoru + 0,3 × kod_skoru) × 10 ``` - `sinyal_skoru = min(1,0, log1p(ham_oy) / log1p(1000))` — 1000 oy → 1,0 · 100 oy → 0,67 - `uzunluk_skoru = min(1,0, toplam_karakter / 500)` — 500+ karakter → tam puan - `kod_skoru = 1,0 (kod varsa) | 0,3 (kod yoksa)` Yalnızca `kalite_skoru >= 5,0` olan kayıtlar dışa aktarılır. --- ## Veri Seti Yapısı ### Alanlar | Alan | Tür | Açıklama | |---|---|---| | `id` | `string` | Benzersiz kayıt kimliği (örn. `so_12345678`) | | `instruction` | `string` | Soru / prompt (kullanıcı rolünden) | | `output` | `string` | Markdown içinde opsiyonel kod bloklarıyla cevap | | `system` | `string` | Sistem prompt'u — bu veri setinde her zaman boş `""` | | `technology` | `string` | Domain etiketi: `python`, `sql`, `javascript`, `php`, `shell_scripting`, `devops`, `typescript`, `system_design`, `wordpress` | | `quality_score` | `float` | Kalite skoru 5,01–10,0 | | `source` | `string` | Kaynak: `stackoverflow` veya `github` | | `meta.tier` | `string` | Karmaşıklık kademesi: `short`, `medium`, `deep_reasoning` | | `meta.total_tokens` | `int` | Yaklaşık token sayısı (karakter / 4) | ### Kademe (Tier) Dağılımı `meta.tier` alanı, donanıma göre akıllı örnekleme için kayıtları uzunluklarına göre sınıflandırır: | Kademe | Token Aralığı | Kayıt | % | Temsil Ettiği İçerik | |---|---|---|---|---| | `short` | 0–256 token | 15.582 | %33,0 | Kısa S&C, tanımlar | | `medium` | 256–768 token | 24.421 | %51,8 | Kodlu açıklamalı cevaplar | | `deep_reasoning` | 768+ token | 7.187 | %15,2 | Karmaşık çok adımlı çözümler | ### Kalite Dağılımı | Skor Aralığı | Kayıt | % | |---|---|---| | 9,0 – 10,0 | 8.666 | %18,4 | | 7,0 – 9,0 | 22.820 | %48,4 | | 5,0 – 7,0 | 15.704 | %33,3 | ### Teknoloji Dağılımı | Teknoloji | Kayıt | |---|---| | SQL | 8.730 | | Shell Scripting | 8.355 | | Python | 7.540 | | PHP | 6.377 | | JavaScript | 6.058 | | Sistem Tasarımı | 4.429 | | DevOps | 3.255 | | TypeScript | 1.909 | | WordPress | 537 | --- ## Kullanım ### 🤗 Datasets ile Yükleme ```python from datasets import load_dataset ds = load_dataset("hadilenya/AI-Trainer-Studio", split="train") print(ds[0]) ``` ### TRL ile SFT Eğitimi ```python from datasets import load_dataset from trl import SFTTrainer, SFTConfig ds = load_dataset("hadilenya/AI-Trainer-Studio", split="train") def formatting_func(example): return f"### Instruction:\n{example['instruction']}\n\n### Response:\n{example['output']}" trainer = SFTTrainer( model=model, train_dataset=ds, formatting_func=formatting_func, args=SFTConfig(max_seq_length=2048, ...), ) trainer.train() ``` ### Donanıma Göre Örnekleme (`meta.tier` ile) ```python # RTX 2060 (6 GB VRAM) — güvenli örnekleme short = ds.filter(lambda x: x["meta"]["tier"] == "short") medium = ds.filter(lambda x: x["meta"]["tier"] == "medium") deep = ds.filter(lambda x: x["meta"]["tier"] == "deep_reasoning") # Oran: short %60 · medium %35 · deep %5 from datasets import concatenate_datasets n = 8000 sampled = concatenate_datasets([ short.shuffle(seed=42).select(range(min(int(n*0.60), len(short)))), medium.shuffle(seed=42).select(range(min(int(n*0.35), len(medium)))), deep.shuffle(seed=42).select(range(min(int(n*0.05), len(deep)))), ]) ``` ### Teknoloji veya Kaliteye Göre Filtreleme ```python python_ds = ds.filter(lambda x: x["technology"] == "python") yuksek_kal = ds.filter(lambda x: x["quality_score"] >= 7.0) ``` --- ## Kısıtlamalar - **Dil:** Tüm kayıtlar **İngilizce**'dir. Çok dilli ince ayar için çeviri gerekir. - **Kaynak yanlılığı:** %99,8 StackOverflow — cevaplar SO topluluğu normlarını yansıtır (özlü, kod öncelikli). - **Zaman aralığı:** Veriler 2026 yılında toplandı. Çok yeni kütüphane sürümleri veya kullanımdan kalkmış API'lar yansıtılmayabilir. - **Kapsam:** Web geliştirme, betik yazımı, veritabanları ve DevOps odaklıdır. Tıp, hukuk, finans gibi uzmanlık alanları için uygun değildir. - **Kod doğruluğu:** Kod blokları topluluk cevaplarından alınmıştır. Yüksek oylu cevaplar genellikle doğru olsa da otomatik kod çalıştırma veya test doğrulaması yapılmamıştır. --- ## Lisans Bu veri seti **Creative Commons Attribution 4.0 (CC BY 4.0)** lisansı altında yayımlanmıştır. StackOverflow içeriği [CC BY-SA 4.0](https://stackoverflow.com/help/licensing) kapsamındadır. Atıf, `id` alanı aracılığıyla korunmaktadır (örn. `so_12345678` → `https://stackoverflow.com/q/12345678`). --- ## Değişiklik Günlüğü | Sürüm | Tarih | Açıklama | |---|---|---| | v1.0 | 17 Mayıs 2026 | İlk yayın — 47.190 kayıt, Alpaca format, meta.tier anotasyonu |