| --- |
| license: mit |
| tags: |
| - regression |
| - latency |
| - triton |
| - leetcode |
| - kernel |
| - text regression |
| task_categories: |
| - text-generation |
| --- |
| |
| # Code-Regression |
|
|
| [Paper](https://huggingface.co/papers/2509.26476) | [GitHub Repository](https://github.com/google-deepmind/regress-lm/tree/main) | [Project Page](https://research.google/blog/simulating-large-systems-with-regression-language-models/) |
|
|
| A unified regression dataset collated from three sources (APPS, KBSS, CDSS) along with our own custom profiling for training and evaluating regression models that map code strings to a target metric. This dataset supports "code-to-metric regression," which involves predicting numeric outcomes of code executions using Regression Language Models (RLM), as described in the linked paper. |
|
|
| **Link for Graph-Regression dataset**: https://huggingface.co/datasets/akhauriyash/GraphArch-Regression |
|
|
| **Link for Base Gemma-Adapted RLM model**: https://huggingface.co/akhauriyash/RLM-GemmaS-Code-v0 |
|
|
| ## Schema |
| - **identifier** *(string)*: Source key for the example, e.g. `APPS_0`, `KBSS_1`, `CDSS_42`. |
| - **space** *(string)*: Logical dataset split/source (`APPS`, `KBSS`, or `CDSS`). |
| - **input** *(string)*: The input string (`shortest_onnx`). |
| - **target_metric** *(string)*: Always `val_accuracy`. |
| - **val_accuracy** *(number | null)*: The regression target. |
| - **metric_type** *(string)*: Auxiliary metric family for this row: |
| - `memory_bytes` for APPS and CDSS |
| - `latency_ms` for KBSS |
| - **metadata** *(string)*: A Python-dict-like string with source-specific information: |
| - APPS: `problem_metainformation` cast to string. |
| - KBSS: `{'stddev_ms': <value>}`. |
| - CDSS: subset of fields `{s_id, p_id, u_id, date, language, original_language, filename_ext, status, cpu_time, memory, code_size}`. |
|
|
| This dataset has 7502559 rows: |
| - APPS: 98932 |
| - CDSS (CodeNets): 7391012 |
| - KBSS (Triton Kernels): 12615 |
|
|
| > Tip: turn `metadata` back into a dict with: |
| > ```python |
| > from ast import literal_eval |
| > meta = literal_eval(row["metadata"]) |
| > ``` |
|
|
| ## How to load with 🤗 Datasets |
| ```python |
| from datasets import load_dataset |
| ds = load_dataset("akhauriyash/Code-Regression") |
| ``` |
|
|
| ## Sample Usage with `RegressLM` |
|
|
| The `regress_lm` library provides the `RegressLM` class for decoding floating-point predictions from a given input and fine-tuning against new data. Below is an example of how to instantiate `RegressLM` and use it for inference. |
|
|
| ```python |
| from regress_lm import core |
| from regress_lm import rlm |
| |
| # Create RegressLM from scratch. Optionally, use `from_t5gemma_encoder`. |
| reg_lm = rlm.RegressLM.from_scratch(max_input_len=2048) |
| |
| # Example (x,y) pairs, which can be fine-tuned against. |
| examples = [core.Example(x='hello', y=0.3), core.Example(x='world', y=-0.3)] |
| reg_lm.fine_tune(examples) |
| |
| # Query inputs. |
| query1, query2 = core.ExampleInput(x='hi'), core.ExampleInput(x='bye') |
| samples1, samples2 = reg_lm.sample([query1, query2], num_samples=128) |
| ``` |
|
|
| ## Testing Code-Regression with a basic Gemma RLM model |
|
|
| Use the code below as reference for evaluating a basic RegressLM model ( better, more models to come! :) ) |
|
|
| ``` |
| import torch |
| import numpy as np |
| from datasets import load_dataset |
| from transformers import AutoTokenizer, AutoModelForSeq2SeqLM |
| from scipy.stats import spearmanr |
| from tqdm import tqdm |
| |
| REPO_ID = "akhauriyash/RLM-GemmaS-Code-v0" |
| DATASET = "akhauriyash/Code-Regression" |
| dataset = load_dataset(DATASET, split="train") |
| tok = AutoTokenizer.from_pretrained(REPO_ID, trust_remote_code=True) |
| device = torch.device("cuda" if torch.cuda.is_available() else "cpu") |
| model = AutoModelForSeq2SeqLM.from_pretrained(REPO_ID, trust_remote_code=True).to(device).eval() |
| MAX_ITEMS, BATCH_SIZE, spaces, results = 512, 16, ["KBSS", "CDSS", "APPS"], {} |
| language = None # Specify language for CDSS, e.g. "python" |
| n_out_tokens = getattr(model.config, "num_tokens_per_obj", 8) * getattr(model.config, "max_num_objs", 1) |
| n_out_tokens = model.config.num_tokens_per_obj * model.config.max_num_objs |
| |
| for SPACE in spaces: |
| inputs, targets = [], [] |
| for row in tqdm(dataset, desc=f"Processing {SPACE} till {MAX_ITEMS} items"): |
| if row.get("space") == SPACE and "input" in row and "target" in row: |
| try: |
| lang = eval(row['metadata'])['language'] if SPACE == "CDSS" else None |
| if SPACE != "CDSS" or language is None or lang == language: |
| targets.append(float(row["target"])) |
| if SPACE == "CDSS": |
| inputs.append(f"# {SPACE} |
| # Language: {lang} |
| {row['input']}") |
| else: |
| inputs.append(f"{SPACE} |
| {row['input']}") |
| except: continue |
| if len(inputs) >= MAX_ITEMS: break |
| preds = [] |
| for i in tqdm(range(0, len(inputs), BATCH_SIZE)): |
| enc = tok(inputs[i:i+BATCH_SIZE], return_tensors="pt", truncation=True, padding=True, max_length=2048).to(device) |
| batch_preds = [] |
| for _ in range(8): |
| out = model.generate(**enc, max_new_tokens=n_out_tokens, min_new_tokens=n_out_tokens, do_sample=True, top_p=0.95, temperature=1.0) |
| decoded = [tok.token_ids_to_floats(seq.tolist()) for seq in out] |
| decoded = [d[0] if isinstance(d, list) and d else float("nan") for d in decoded] |
| batch_preds.append(decoded) |
| preds.extend(torch.tensor(batch_preds).median(dim=0).values.tolist()) |
| spear, _ = spearmanr(np.array(targets), np.array(preds)) |
| results[SPACE] = spear; print(f"Spearman ρ for {SPACE}: {spear:.3f}") |
| |
| print("Spearman ρ | KBSS | CDSS | APPS") |
| print(f"{REPO_ID} | " + " | ".join(f"{results[s]:.3f}" for s in spaces)) |
| |
| ``` |
|
|
|
|
| We got the following results when testing on a random subset of the Code-Regression dataset. |
|
|
| ``` |
| Model ID | KBSS | CDSS | APPS |
| akhauriyash/RegressLM-gemma-s-RLM-table3 | 0.527 | 0.787 | 0.926 |
| ``` |
|
|
| # Credits |
|
|
| This dataset was collated from several sources, along with our own latency and memory profiling. We thank the authors for their efforts. |
|
|
| APPS: |
| Hendrycks, D., Basart, S., Kadavath, S., Mazeika, M., Arora, A., Guo, E., Burns, C., Puranik, S., He, H., Song, D., & Steinhardt, J. (2021). Measuring Coding Challenge Competence With APPS. NeurIPS. |
|
|
| CDSS (CodeNet): |
| Puri, R., Kung, D. S., Janssen, G., Zhang, W., Domeniconi, G., Zolotov, V., Dolby, J., Chen, J., Choudhury, M., Decker, L., & others. (2021). Codenet: A large-scale ai for code dataset for learning a diversity of coding tasks. |
|
|
| KBSS (KernelBook): |
| Paliskara, S., & Saroufim, M. (2025). KernelBook. https://huggingface.co/datasets/GPUMODE/KernelBook |
|
|
| ## Citations |
|
|
| If you found this dataset useful for your research, please cite the original sources above as well as: |
|
|
| ```bibtex |
| @article{akhauri2025regressionlanguagemodelscode, |
| title={Regression Language Models for Code}, |
| author={Yash Akhauri and Xingyou Song and Arissa Wongpanich and Bryan Lewandowski and Mohamed S. Abdelfattah}, |
| journal={arXiv preprint arXiv:2509.26476}, |
| year={2025} |
| } |
| |
| @article{akhauri2025performance, |
| title={Performance Prediction for Large Systems via Text-to-Text Regression}, |
| author={Akhauri, Yash and Lewandowski, Bryan and Lin, Cheng-Hsi and Reyes, Adrian N and Forbes, Grant C and Wongpanich, Arissa and Yang, Bangding and Abdelfattah, Mohamed S and Perel, Sagi and Song, Xingyou}, |
| journal={arXiv preprint arXiv:2506.21718}, |
| year={2025} |
| } |
| ``` |