Text Generation
Transformers
Safetensors
English
qwen3
text-generation-inference
unsloth
code-generation
qlora
conversational
Instructions to use mayankbhaskarr/qwen3-4b-coder-ft with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mayankbhaskarr/qwen3-4b-coder-ft with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mayankbhaskarr/qwen3-4b-coder-ft") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("mayankbhaskarr/qwen3-4b-coder-ft") model = AutoModelForCausalLM.from_pretrained("mayankbhaskarr/qwen3-4b-coder-ft", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use mayankbhaskarr/qwen3-4b-coder-ft with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mayankbhaskarr/qwen3-4b-coder-ft" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mayankbhaskarr/qwen3-4b-coder-ft", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mayankbhaskarr/qwen3-4b-coder-ft
- SGLang
How to use mayankbhaskarr/qwen3-4b-coder-ft with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "mayankbhaskarr/qwen3-4b-coder-ft" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mayankbhaskarr/qwen3-4b-coder-ft", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "mayankbhaskarr/qwen3-4b-coder-ft" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mayankbhaskarr/qwen3-4b-coder-ft", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Desktop
- Docker Model Runner
How to use mayankbhaskarr/qwen3-4b-coder-ft with Docker Model Runner:
docker model run hf.co/mayankbhaskarr/qwen3-4b-coder-ft
Add live runtime benchmark: 38-item coding suite + llama-bench (charts, raw per-item data, harness)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- README.md +103 -0
- benchmark/fig_memory.png +0 -0
- benchmark/fig_pass_rates.png +0 -0
- benchmark/fig_quant_ladder.png +0 -0
- benchmark/fig_speed.png +0 -0
- benchmark/harness/bench_suite.py +154 -0
- benchmark/harness/run_bench.py +212 -0
- benchmark/results/Q4_K_M/E01_fizzbuzz.json +17 -0
- benchmark/results/Q4_K_M/E02_reverse_string.json +17 -0
- benchmark/results/Q4_K_M/E03_sum_list.json +17 -0
- benchmark/results/Q4_K_M/E04_is_palindrome.json +17 -0
- benchmark/results/Q4_K_M/E05_max_in_list.json +17 -0
- benchmark/results/Q4_K_M/E06_count_vowels.json +17 -0
- benchmark/results/Q4_K_M/E07_celsius_to_fahrenheit.json +17 -0
- benchmark/results/Q4_K_M/E08_word_count.json +17 -0
- benchmark/results/Q4_K_M/E09_factorial.json +17 -0
- benchmark/results/Q4_K_M/E10_remove_duplicates.json +17 -0
- benchmark/results/Q4_K_M/E11_second_largest.json +17 -0
- benchmark/results/Q4_K_M/E12_is_prime.json +17 -0
- benchmark/results/Q4_K_M/H01_lru_cache.json +17 -0
- benchmark/results/Q4_K_M/H02_edit_distance.json +17 -0
- benchmark/results/Q4_K_M/H03_tokenizer.json +17 -0
- benchmark/results/Q4_K_M/H04_flatten_json.json +17 -0
- benchmark/results/Q4_K_M/H05_rate_limiter.json +17 -0
- benchmark/results/Q4_K_M/H06_topo_sort.json +17 -0
- benchmark/results/Q4_K_M/I01_explain.json +17 -0
- benchmark/results/Q4_K_M/I02_json_config.json +17 -0
- benchmark/results/Q4_K_M/I03_three_bullets.json +17 -0
- benchmark/results/Q4_K_M/I04_code_review.json +17 -0
- benchmark/results/Q4_K_M/I05_leap_docstring.json +17 -0
- benchmark/results/Q4_K_M/I06_mcq.json +17 -0
- benchmark/results/Q4_K_M/I07_refactor.json +17 -0
- benchmark/results/Q4_K_M/I08_regex_ipv4.json +17 -0
- benchmark/results/Q4_K_M/M01_two_sum.json +17 -0
- benchmark/results/Q4_K_M/M02_valid_parentheses.json +17 -0
- benchmark/results/Q4_K_M/M03_merge_intervals.json +17 -0
- benchmark/results/Q4_K_M/M04_longest_substring.json +17 -0
- benchmark/results/Q4_K_M/M05_binary_search.json +17 -0
- benchmark/results/Q4_K_M/M06_fib_fast.json +17 -0
- benchmark/results/Q4_K_M/M07_top_word.json +17 -0
- benchmark/results/Q4_K_M/M08_matrix_transpose.json +17 -0
- benchmark/results/Q4_K_M/M09_group_anagrams.json +17 -0
- benchmark/results/Q4_K_M/M10_flatten_nested.json +17 -0
- benchmark/results/Q4_K_M/M11_roman_to_int.json +17 -0
- benchmark/results/Q4_K_M/M12_min_stack.json +17 -0
- benchmark/results/Q4_K_M/_meta.json +8 -0
- benchmark/results/Q5_K_M/E01_fizzbuzz.json +17 -0
- benchmark/results/Q5_K_M/E02_reverse_string.json +17 -0
- benchmark/results/Q5_K_M/E03_sum_list.json +17 -0
- benchmark/results/Q5_K_M/E04_is_palindrome.json +17 -0
README.md
CHANGED
|
@@ -5,9 +5,12 @@ tags:
|
|
| 5 |
- transformers
|
| 6 |
- unsloth
|
| 7 |
- qwen3
|
|
|
|
|
|
|
| 8 |
license: apache-2.0
|
| 9 |
language:
|
| 10 |
- en
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
# Uploaded finetuned model
|
|
@@ -19,3 +22,103 @@ language:
|
|
| 19 |
This qwen3 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
| 20 |
|
| 21 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
- transformers
|
| 6 |
- unsloth
|
| 7 |
- qwen3
|
| 8 |
+
- code-generation
|
| 9 |
+
- qlora
|
| 10 |
license: apache-2.0
|
| 11 |
language:
|
| 12 |
- en
|
| 13 |
+
pipeline_tag: text-generation
|
| 14 |
---
|
| 15 |
|
| 16 |
# Uploaded finetuned model
|
|
|
|
| 22 |
This qwen3 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
| 23 |
|
| 24 |
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
| 25 |
+
|
| 26 |
+
## Model summary
|
| 27 |
+
|
| 28 |
+
`qwen3-4b-coder-ft` is a QLoRA fine-tune of the Qwen3-4B-Instruct-2507 family, adapted for coding and code-instruction tasks. The repo contains the full BF16 weights (two-shard safetensors, ~8.0 GB) plus the Qwen3 chat template (`chat_template.jinja`). A quantized **Q8_0 GGUF** build is available in the companion repo [mayankbhaskarr/qwen3-4b-coder-ft-gguf](https://huggingface.co/mayankbhaskarr/qwen3-4b-coder-ft-gguf), and the model was validated with a live runtime benchmark (38 executed tasks + throughput profiling) — full results below.
|
| 29 |
+
|
| 30 |
+
## Benchmark evaluation (October 22, 2026)
|
| 31 |
+
|
| 32 |
+
The model was evaluated with a live runtime benchmark: a 38-item executed suite (12 easy + 12 medium + 6 hard Python coding tasks scored by running generated code against held-out tests, plus 8 instruction-following items with objective rubric checks) and standardized `llama-bench` throughput profiling. Inference ran on CPU-only hardware (2 vCPU, ~3.7 GB usable RAM) with llama.cpp v0.7.0, greedy decoding (temperature 0.0), context 1280, 2 threads.
|
| 33 |
+
|
| 34 |
+
Because the BF16 (~8.0 GB) and Q8_0 (4.28 GB) artifacts exceed the host's usable RAM, the benchmark quantized the uploaded **Q8_0 GGUF** (SHA-256 verified across downloads) into **Q5_K_M** and **Q4_K_M** derivatives with `llama-quantize --allow-requantize`, then ran the full suite on both. Q8_0 is a documented near-lossless format (+0.0004% relative perplexity, k-quants reference data), so these results represent the fine-tuned weights faithfully, with a slight conservative bias.
|
| 35 |
+
|
| 36 |
+
### Results
|
| 37 |
+
|
| 38 |
+
| Tier | Q5_K_M | Q4_K_M |
|
| 39 |
+
|---|---|---|
|
| 40 |
+
| Easy coding (12) | **12/12 (100%)** | **12/12 (100%)** |
|
| 41 |
+
| Medium coding (12) | **12/12 (100%)** | **12/12 (100%)** |
|
| 42 |
+
| Hard coding (6) | 3/6 (50.0%) | 2/6 (33.3%) |
|
| 43 |
+
| Instruction following (8) | 6/8 (75.0%) | **7/8 (87.5%)** |
|
| 44 |
+
| **Overall (38)** | **33/38 (86.8%)** | **33/38 (86.8%)** |
|
| 45 |
+
|
| 46 |
+

|
| 47 |
+
|
| 48 |
+
- **Quantization agreement: 36/38 items identical (94.7%)**, with the two disagreements split in both directions (H04 JSON-flattener: Q5 pass / Q4 fail; I07 fib-refactor: Q5 empty-EOS / Q4 pass) — i.e., within greedy-decoding noise, no systematic quality gap between Q5_K_M and Q4_K_M.
|
| 49 |
+
- All failures in the hard tier (LRU cache, spec-precise tokenizer, sliding-window rate limiter) are boundary-condition assertion errors in otherwise correct scaffolding. The only instruction failure (I04, code-review rubric) yields the correct fixed loop but only partially names the bug class.
|
| 50 |
+
|
| 51 |
+
### Throughput (llama-bench, pp512 / tg128, 3 reps)
|
| 52 |
+
|
| 53 |
+
| Config | Q5_K_M | Q4_K_M |
|
| 54 |
+
|---|---|---|
|
| 55 |
+
| Prompt eval, t=1 | 28.88 tok/s | 28.30 tok/s |
|
| 56 |
+
| Prompt eval, t=2 | 40.54 tok/s | 41.93 tok/s |
|
| 57 |
+
| Generation, t=1 | 2.58 tok/s | 3.32 tok/s |
|
| 58 |
+
| Generation, t=2 | 3.33 tok/s | **4.58 tok/s** |
|
| 59 |
+
|
| 60 |
+

|
| 61 |
+
|
| 62 |
+
Server cold-load: 8.55 s (Q5_K_M) / 6.3 s (Q4_K_M) to first healthy response; peak RSS ~3.8 GB including the 1,280-token KV cache.
|
| 63 |
+
|
| 64 |
+
### Interpretation
|
| 65 |
+
|
| 66 |
+
- The fine-tune preserves base-model coding competence: perfect 24/24 on easy+medium executed tasks and reliable strict-format compliance (JSON schema, exact bullets, exact answer format, executed refactors) under greedy decoding.
|
| 67 |
+
- **Q4_K_M is the recommended deployment quant** for constrained hardware (37.5% faster generation, faster loading, 0.39 GB smaller, identical overall accuracy on this suite) — see the [GGUF repo](https://huggingface.co/mayankbhaskarr/qwen3-4b-coder-ft-gguf).
|
| 68 |
+
- This suite measures the fine-tuned weights only; it does not compare against the base checkpoint. A base-model control run is the recommended next experiment.
|
| 69 |
+
|
| 70 |
+
### Quantization footprint
|
| 71 |
+
|
| 72 |
+

|
| 73 |
+
|
| 74 |
+
## Usage (transformers)
|
| 75 |
+
|
| 76 |
+
```python
|
| 77 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 78 |
+
|
| 79 |
+
model_id = "mayankbhaskarr/qwen3-4b-coder-ft"
|
| 80 |
+
tok = AutoTokenizer.from_pretrained(model_id)
|
| 81 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="auto", device_map="auto")
|
| 82 |
+
|
| 83 |
+
messages = [{"role": "user", "content": "Implement binary search in Python."}]
|
| 84 |
+
inputs = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
|
| 85 |
+
out = model.generate(inputs, max_new_tokens=512, do_sample=False)
|
| 86 |
+
print(tok.decode(out[0][inputs.shape[1]:], skip_special_tokens=True))
|
| 87 |
+
```
|
| 88 |
+
|
| 89 |
+
For CPU / low-memory deployment, use the Q8_0 GGUF from the [companion repo](https://huggingface.co/mayankbhaskarr/qwen3-4b-coder-ft-gguf) with llama.cpp (`llama-server -hf mayankbhaskarr/qwen3-4b-coder-ft-gguf --jinja`).
|
| 90 |
+
|
| 91 |
+
## Reproduce
|
| 92 |
+
|
| 93 |
+
```bash
|
| 94 |
+
# engines
|
| 95 |
+
git clone --depth 1 --branch v0.7.0 https://github.com/ggml-org/llama.cpp && cd llama.cpp
|
| 96 |
+
cmake -B build -DCMAKE_BUILD_TYPE=Release -DGGML_CUDA=OFF -DLLAMA_CURL=OFF && cmake --build build -j --target llama-server llama-bench
|
| 97 |
+
|
| 98 |
+
# speed
|
| 99 |
+
./build/bin/llama-bench -m <model>.gguf -p 512 -n 128 -r 3 -t 1,2
|
| 100 |
+
|
| 101 |
+
# serve (chat template via --jinja)
|
| 102 |
+
./build/bin/llama-server -m <model>.gguf -c 1280 -t 2 --jinja --temp 0.0 --top-p 1.0
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
Raw per-item outputs: [`benchmark/results/`](benchmark/results) · suite definition: [`benchmark/harness/bench_suite.py`](benchmark/harness/bench_suite.py) · runner: [`benchmark/harness/run_bench.py`](benchmark/harness/run_bench.py)
|
| 106 |
+
|
| 107 |
+
## Citation
|
| 108 |
+
|
| 109 |
+
```bibtex
|
| 110 |
+
@misc{bhaskar2026qwen3coderft,
|
| 111 |
+
title = {Comparative Benchmark Evaluation of a QLoRA Fine-Tuned Qwen3-4B Coder Model and its GGUF Quantization},
|
| 112 |
+
author = {Bhaskar, Mayank},
|
| 113 |
+
year = {2026},
|
| 114 |
+
month = {October},
|
| 115 |
+
url = {https://huggingface.co/mayankbhaskarr}
|
| 116 |
+
}
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
## References
|
| 120 |
+
|
| 121 |
+
- Dettmers, T., Pagnoni, A., Holtzman, A., & Zettlemoyer, L. (2023). *QLoRA: Efficient finetuning of quantized LLMs* (arXiv:2305.14314)
|
| 122 |
+
- Yang, A., et al. (2025). *Qwen3 Technical Report* (arXiv:2505.09388)
|
| 123 |
+
- Kawrakow, I. (2022). *K-quantization methods* (llama.cpp PR #1684)
|
| 124 |
+
- Kurt, U. (2026). *Which quantization should I use? A unified evaluation of llama.cpp quantization methods* (arXiv:2601.14277)
|
benchmark/fig_memory.png
ADDED
|
benchmark/fig_pass_rates.png
ADDED
|
benchmark/fig_quant_ladder.png
ADDED
|
benchmark/fig_speed.png
ADDED
|
benchmark/harness/bench_suite.py
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""38-item benchmark suite for mayankbhaskarr/qwen3-4b-coder-ft.
|
| 3 |
+
12 easy + 12 medium + 6 hard executable Python coding tasks,
|
| 4 |
+
8 instruction-following items with objective rubric checks.
|
| 5 |
+
Coding items: generated code is executed against reference test cases.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
CODE_SYS = "You are an expert Python programmer. Solve the task. Return ONLY a single Python code block. No explanations."
|
| 9 |
+
|
| 10 |
+
# Coding item spec: id, tier, prompt(task), max_tokens, tests (code that uses the function and prints RESULTS_OK or RESULTS_FAIL)
|
| 11 |
+
# In tests: call the target function, assert expected values; on full success print RESULTS_OK.
|
| 12 |
+
|
| 13 |
+
E = "easy"; M = "medium"; H = "hard"; I = "instruction"
|
| 14 |
+
|
| 15 |
+
def mk_tests(fn, body):
|
| 16 |
+
return f"{fn} = None\n{body}"
|
| 17 |
+
|
| 18 |
+
SUITE = []
|
| 19 |
+
|
| 20 |
+
# ---------------- EASY (12) ----------------
|
| 21 |
+
SUITE.append(dict(id="E01_fizzbuzz", tier=E, mt=224, prompt=(
|
| 22 |
+
"Write a Python function `fizzbuzz(n)` that returns a list of strings for numbers 1..n where multiples of 3 are 'Fizz', multiples of 5 are 'Buzz', multiples of both are 'FizzBuzz', otherwise the number as a string."),
|
| 23 |
+
tests="r = fizzbuzz(5)\nassert r == ['1','2','Fizz','4','Buzz'], r\nassert fizzbuzz(15)[14] == 'FizzBuzz'\nprint('RESULTS_OK')"))
|
| 24 |
+
SUITE.append(dict(id="E02_reverse_string", tier=E, mt=160, prompt=(
|
| 25 |
+
"Write a Python function `reverse_string(s)` that returns the reversed string."),
|
| 26 |
+
tests="assert reverse_string('abc') == 'cba'\nassert reverse_string('') == ''\nassert reverse_string('a b') == 'b a'\nprint('RESULTS_OK')"))
|
| 27 |
+
SUITE.append(dict(id="E03_sum_list", tier=E, mt=160, prompt=(
|
| 28 |
+
"Write a Python function `sum_list(nums)` that returns the sum of a list of numbers without using the built-in sum()."),
|
| 29 |
+
tests="assert sum_list([1,2,3]) == 6\nassert sum_list([]) == 0\nassert sum_list([-1,1]) == 0\nprint('RESULTS_OK')"))
|
| 30 |
+
SUITE.append(dict(id="E04_is_palindrome", tier=E, mt=192, prompt=(
|
| 31 |
+
"Write a Python function `is_palindrome(s)` that returns True if the string is a palindrome considering only alphanumeric characters and ignoring case."),
|
| 32 |
+
tests="assert is_palindrome('racecar') is True\nassert is_palindrome('hello') is False\nassert is_palindrome('A man, a plan, a canal: Panama') is True\nprint('RESULTS_OK')"))
|
| 33 |
+
SUITE.append(dict(id="E05_max_in_list", tier=E, mt=160, prompt=(
|
| 34 |
+
"Write a Python function `max_in_list(nums)` that returns the maximum value in a list without using the built-in max(). Assume the list is non-empty."),
|
| 35 |
+
tests="assert max_in_list([3,1,4]) == 4\nassert max_in_list([-5,-2]) == -2\nassert max_in_list([7]) == 7\nprint('RESULTS_OK')"))
|
| 36 |
+
SUITE.append(dict(id="E06_count_vowels", tier=E, mt=160, prompt=(
|
| 37 |
+
"Write a Python function `count_vowels(s)` that returns the number of vowels (a,e,i,o,u) in the string, case-insensitive."),
|
| 38 |
+
tests="assert count_vowels('hello') == 2\nassert count_vowels('XYZ') == 0\nassert count_vowels('AEIOUaeiou') == 10\nprint('RESULTS_OK')"))
|
| 39 |
+
SUITE.append(dict(id="E07_celsius_to_fahrenheit", tier=E, mt=160, prompt=(
|
| 40 |
+
"Write a Python function `celsius_to_fahrenheit(c)` that converts Celsius to Fahrenheit (F = C * 9/5 + 32)."),
|
| 41 |
+
tests="assert celsius_to_fahrenheit(100) == 212\nassert celsius_to_fahrenheit(0) == 32\nassert abs(celsius_to_fahrenheit(37) - 98.6) < 1e-9\nprint('RESULTS_OK')"))
|
| 42 |
+
SUITE.append(dict(id="E08_word_count", tier=E, mt=160, prompt=(
|
| 43 |
+
"Write a Python function `word_count(s)` that returns the number of words in the string (words are separated by one or more spaces)."),
|
| 44 |
+
tests="assert word_count('a b c') == 3\nassert word_count('') == 0\nassert word_count('hello') == 1\nprint('RESULTS_OK')"))
|
| 45 |
+
SUITE.append(dict(id="E09_factorial", tier=E, mt=160, prompt=(
|
| 46 |
+
"Write a Python function `factorial(n)` that returns n! for non-negative integer n."),
|
| 47 |
+
tests="assert factorial(5) == 120\nassert factorial(0) == 1\nassert factorial(10) == 3628800\nprint('RESULTS_OK')"))
|
| 48 |
+
SUITE.append(dict(id="E10_remove_duplicates", tier=E, mt=176, prompt=(
|
| 49 |
+
"Write a Python function `remove_duplicates(nums)` that removes duplicates from a list while preserving the original order of first occurrences."),
|
| 50 |
+
tests="assert remove_duplicates([1,2,2,3]) == [1,2,3]\nassert remove_duplicates([]) == []\nassert remove_duplicates(['a','a','b']) == ['a','b']\nprint('RESULTS_OK')"))
|
| 51 |
+
SUITE.append(dict(id="E11_second_largest", tier=E, mt=176, prompt=(
|
| 52 |
+
"Write a Python function `second_largest(nums)` that returns the second largest DISTINCT value in a list. Return None if it does not exist."),
|
| 53 |
+
tests="assert second_largest([1,5,3,5]) == 3\nassert second_largest([2,2]) is None\nassert second_largest([4]) is None\nprint('RESULTS_OK')"))
|
| 54 |
+
SUITE.append(dict(id="E12_is_prime", tier=E, mt=176, prompt=(
|
| 55 |
+
"Write a Python function `is_prime(n)` that returns True if n is a prime number, False otherwise."),
|
| 56 |
+
tests="assert is_prime(13) is True\nassert is_prime(1) is False\nassert is_prime(2) is True\nassert is_prime(100) is False\nprint('RESULTS_OK')"))
|
| 57 |
+
|
| 58 |
+
# ---------------- MEDIUM (12) ----------------
|
| 59 |
+
SUITE.append(dict(id="M01_two_sum", tier=M, mt=256, prompt=(
|
| 60 |
+
"Write a Python function `two_sum(nums, target)` that returns the indices [i, j] (i < j) of the two numbers that add up to target. Exactly one solution exists."),
|
| 61 |
+
tests="assert two_sum([2,7,11,15], 9) == [0,1]\nassert two_sum([3,2,4], 6) == [1,2]\nprint('RESULTS_OK')"))
|
| 62 |
+
SUITE.append(dict(id="M02_valid_parentheses", tier=M, mt=224, prompt=(
|
| 63 |
+
"Write a Python function `valid_parentheses(s)` that returns True if the string of brackets '()[]{}' is valid (properly closed and nested)."),
|
| 64 |
+
tests="assert valid_parentheses('()[]{}') is True\nassert valid_parentheses('([)]') is False\nassert valid_parentheses('{[]}') is True\nassert valid_parentheses('(') is False\nprint('RESULTS_OK')"))
|
| 65 |
+
SUITE.append(dict(id="M03_merge_intervals", tier=M, mt=256, prompt=(
|
| 66 |
+
"Write a Python function `merge_intervals(intervals)` that merges overlapping intervals and returns a sorted list of [start, end] lists."),
|
| 67 |
+
tests="assert merge_intervals([[1,3],[2,6],[8,10]]) == [[1,6],[8,10]]\nassert merge_intervals([[1,4],[4,5]]) == [[1,5]]\nassert merge_intervals([[5,7],[1,2]]) == [[1,2],[5,7]]\nprint('RESULTS_OK')"))
|
| 68 |
+
SUITE.append(dict(id="M04_longest_substring", tier=M, mt=256, prompt=(
|
| 69 |
+
"Write a Python function `length_of_longest_substring(s)` that returns the length of the longest substring without repeating characters."),
|
| 70 |
+
tests="assert length_of_longest_substring('abcabcbb') == 3\nassert length_of_longest_substring('bbbbb') == 1\nassert length_of_longest_substring('pwwkew') == 3\nprint('RESULTS_OK')"))
|
| 71 |
+
SUITE.append(dict(id="M05_binary_search", tier=M, mt=224, prompt=(
|
| 72 |
+
"Write a Python function `binary_search(arr, target)` that returns the index of target in a sorted ascending list, or -1 if absent."),
|
| 73 |
+
tests="assert binary_search([1,3,5,7], 5) == 2\nassert binary_search([1,3,5,7], 4) == -1\nassert binary_search([], 1) == -1\nprint('RESULTS_OK')"))
|
| 74 |
+
SUITE.append(dict(id="M06_fib_fast", tier=M, mt=224, prompt=(
|
| 75 |
+
"Write a Python function `fib(n)` that returns the n-th Fibonacci number (fib(0)=0, fib(1)=1) using an EFFICIENT method (no naive recursion)."),
|
| 76 |
+
tests="assert fib(0) == 0\nassert fib(10) == 55\nassert fib(30) == 832040\nassert fib(90) == 2880067194370816120\nprint('RESULTS_OK')"))
|
| 77 |
+
SUITE.append(dict(id="M07_top_word", tier=M, mt=224, prompt=(
|
| 78 |
+
"Write a Python function `top_word(s)` that returns the most frequent word in a lowercase space-separated string (all lowercase, no punctuation). If tie, return the word that appears first alphabetically."),
|
| 79 |
+
tests="assert top_word('a a b b b') == 'b'\nassert top_word('x y') == 'x'\nassert top_word('b a a b') == 'a'\nprint('RESULTS_OK')"))
|
| 80 |
+
SUITE.append(dict(id="M08_matrix_transpose", tier=M, mt=224, prompt=(
|
| 81 |
+
"Write a Python function `transpose(matrix)` that returns the transpose of a 2D list."),
|
| 82 |
+
tests="assert transpose([[1,2],[3,4]]) == [[1,3],[2,4]]\nassert transpose([[1,2,3]]) == [[1],[2],[3]]\nprint('RESULTS_OK')"))
|
| 83 |
+
SUITE.append(dict(id="M09_group_anagrams", tier=M, mt=288, prompt=(
|
| 84 |
+
"Write a Python function `group_anagrams(words)` that groups anagrams together and returns a list of groups (each group a sorted list of words; groups sorted by their first element)."),
|
| 85 |
+
tests="g = group_anagrams(['eat','tea','tan','ate','nat'])\nassert ['ate','eat','tea'] in g and ['nat','tan'] in g\nprint('RESULTS_OK')"))
|
| 86 |
+
SUITE.append(dict(id="M10_flatten_nested", tier=M, mt=224, prompt=(
|
| 87 |
+
"Write a Python function `flatten(nested)` that flattens an arbitrarily nested list of lists into a single flat list, preserving order."),
|
| 88 |
+
tests="assert flatten([1,[2,[3,4]],5]) == [1,2,3,4,5]\nassert flatten([]) == []\nassert flatten([[[]],1]) == [1]\nprint('RESULTS_OK')"))
|
| 89 |
+
SUITE.append(dict(id="M11_roman_to_int", tier=M, mt=256, prompt=(
|
| 90 |
+
"Write a Python function `roman_to_int(s)` that converts a Roman numeral string to an integer."),
|
| 91 |
+
tests="assert roman_to_int('IX') == 9\nassert roman_to_int('LVIII') == 58\nassert roman_to_int('MCMXCIV') == 1994\nprint('RESULTS_OK')"))
|
| 92 |
+
SUITE.append(dict(id="M12_min_stack", tier=M, mt=320, prompt=(
|
| 93 |
+
"Write a class `MinStack` with methods push(x), pop(), top(), and get_min(), all in O(1) time per operation."),
|
| 94 |
+
tests="s = MinStack()\ns.push(3); s.push(1); s.push(2)\nassert s.get_min() == 1\ns.pop()\nassert s.top() == 1 and s.get_min() == 1\ns.pop(); assert s.get_min() == 3\nprint('RESULTS_OK')"))
|
| 95 |
+
|
| 96 |
+
# ---------------- HARD (6) ----------------
|
| 97 |
+
SUITE.append(dict(id="H01_lru_cache", tier=H, mt=416, prompt=(
|
| 98 |
+
"Write a class `LRUCache` with methods get(key) and put(key, value) with O(1) average time, evicting the least-recently-used item when capacity (given in __init__(capacity)) is exceeded."),
|
| 99 |
+
tests="c = LRUCache(2)\nc.put(1,1); c.put(2,2)\nassert c.get(1) == 1\nc.put(3,3)\nassert c.get(2) == -1\nc.put(4,4)\nassert c.get(1) == -1 and c.get(3) == 1\nprint('RESULTS_OK')"))
|
| 100 |
+
SUITE.append(dict(id="H02_edit_distance", tier=H, mt=320, prompt=(
|
| 101 |
+
"Write a Python function `edit_distance(a, b)` that returns the minimum number of single-character edits (insert, delete, replace) to transform a into b."),
|
| 102 |
+
tests="assert edit_distance('kitten','sitting') == 3\nassert edit_distance('','abc') == 3\nassert edit_distance('same','same') == 0\nprint('RESULTS_OK')"))
|
| 103 |
+
SUITE.append(dict(id="H03_tokenizer", tier=H, mt=352, prompt=(
|
| 104 |
+
"Write a Python function `tokenize(s)` that lowercases text and splits it into tokens: consecutive letters form one token, consecutive digits form one token, and each punctuation character is its own token. Whitespace is discarded. Return the list of tokens in order."),
|
| 105 |
+
tests="assert tokenize('Hello, world! 42 times.') == ['hello',',','world','!','42','times','.']\nassert tokenize('') == []\nprint('RESULTS_OK')"))
|
| 106 |
+
SUITE.append(dict(id="H04_flatten_json", tier=H, mt=352, prompt=(
|
| 107 |
+
"Write a Python function `flatten_json(obj)` that flattens a nested dict into a single-level dict where keys are joined with dots. Empty dicts map to the path with value {}. Lists keep indices in the path (e.g. a.0)."),
|
| 108 |
+
tests="r = flatten_json({'a':{'b':1},'c':2})\nassert r == {'a.b':1,'c':2}\nassert flatten_json({'a':{'b':{'c':3}}}) == {'a.b.c':3}\nprint('RESULTS_OK')"))
|
| 109 |
+
SUITE.append(dict(id="H05_rate_limiter", tier=H, mt=416, prompt=(
|
| 110 |
+
"Write a class `RateLimiter` with __init__(self, max_requests, window_seconds) and method allow(self, ts) that returns True if a request at integer timestamp ts is allowed, using a sliding window: at most max_requests within any window of window_seconds."),
|
| 111 |
+
tests="r = RateLimiter(2, 10)\nassert r.allow(1) is True\nassert r.allow(2) is True\nassert r.allow(3) is False\nassert r.allow(12) is True\nassert r.allow(13) is False\nprint('RESULTS_OK')"))
|
| 112 |
+
SUITE.append(dict(id="H06_topo_sort", tier=H, mt=384, prompt=(
|
| 113 |
+
"Write a Python function `topo_sort(nodes, edges)` that returns a valid topological ordering of the DAG. nodes is a list of node names, edges is a list of (u, v) pairs meaning u must come before v. If multiple orders are valid, any is accepted."),
|
| 114 |
+
tests="g = topo_sort(['a','b','c','d'], [('a','c'),('b','c'),('c','d')])\nassert g.index('a') < g.index('c') < g.index('d') and g.index('b') < g.index('c')\nprint('RESULTS_OK')"))
|
| 115 |
+
|
| 116 |
+
# ---------------- INSTRUCTION (8) ----------------
|
| 117 |
+
SNIPPET = ("def process(items):\n total = []\n for i in range(len(items)):\n total.append(items[i] * 2)\n s = 0\n for x in total:\n s += x\n return s")
|
| 118 |
+
SUITE.append(dict(id="I01_explain", tier=I, mt=320, prompt=(
|
| 119 |
+
f"Explain what the following Python function does, step by step, and note any inefficiency:\n\n{SNIPPET}\n\nWrite 60-200 words of plain prose."),
|
| 120 |
+
checks_kind="explain"))
|
| 121 |
+
SUITE.append(dict(id="I02_json_config", tier=I, mt=224, prompt=(
|
| 122 |
+
"Output ONLY a JSON object (no markdown, no commentary) with exactly these keys and values: name (string \"web-server\"), port (number 8080), debug (boolean false), tags (array of strings [\"prod\", \"edge\"])."),
|
| 123 |
+
checks_kind="json"))
|
| 124 |
+
SUITE.append(dict(id="I03_three_bullets", tier=I, mt=280, prompt=(
|
| 125 |
+
"Summarize the following paragraph in EXACTLY 3 bullet points, each starting with '- '. Keep each bullet under 25 words.\n\nParagraph: Large language models are trained in two stages. First, a base model learns language patterns by predicting the next token over trillions of tokens of text. Second, fine-tuning aligns the model to instructions using curated examples and human feedback, which improves helpfulness and safety. Quantization then compresses the trained weights to fewer bits per parameter so the model can run on consumer hardware with minimal quality loss."),
|
| 126 |
+
checks_kind="bullets"))
|
| 127 |
+
SUITE.append(dict(id="I04_code_review", tier=I, mt=320, prompt=(
|
| 128 |
+
"Review this Python code. It is supposed to return 0+1+...+n for n >= 0, but it has a bug. Name the exact bug class and give the precise corrected loop:\n\ndef sum_upto(n):\n total = 0\n for i in range(len(range(n))):\n total += i\n return total\n\nState the bug type explicitly and give the corrected loop line."),
|
| 129 |
+
checks_kind="review"))
|
| 130 |
+
SUITE.append(dict(id="I05_leap_docstring", tier=I, mt=280, prompt=(
|
| 131 |
+
"Write a Python function `is_leap(year)` that returns True for leap years. INCLUDE a docstring explaining the Gregorian rules. Return only the code block."),
|
| 132 |
+
checks_kind="leap"))
|
| 133 |
+
SUITE.append(dict(id="I06_mcq", tier=I, mt=160, prompt=(
|
| 134 |
+
"Which quantization format stores weights at 8 bits per weight in GGUF? A) Q4_K_M B) Q5_K_M C) Q8_0 D) IQ2_XS\nReply with EXACTLY one line in this format and nothing else:\nANSWER: <letter>"),
|
| 135 |
+
checks_kind="mcq"))
|
| 136 |
+
SUITE.append(dict(id="I07_refactor", tier=I, mt=320, prompt=(
|
| 137 |
+
"The function below is correct but slow for large n. Rewrite it efficiently (O(n) or better) with the same name and behavior:\n\ndef fib(n):\n if n < 2: return n\n return fib(n-1) + fib(n-2)\n\nReturn only the code block."),
|
| 138 |
+
checks_kind="fib"))
|
| 139 |
+
SUITE.append(dict(id="I08_regex_ipv4", tier=I, mt=288, prompt=(
|
| 140 |
+
"Write a Python function `is_valid_ipv4(s)` that returns True if s is a valid IPv4 address: exactly four numeric octets 0-255, no leading zeros (e.g. '01' is invalid), digits only. Return only the code block."),
|
| 141 |
+
checks_kind="ipv4"))
|
| 142 |
+
|
| 143 |
+
# ---- runtime test bodies for instruction items that need execution ----
|
| 144 |
+
RUNTIME_CHECKS = {
|
| 145 |
+
"I05_leap_docstring": "assert is_leap(2000) is True\nassert is_leap(1900) is False\nassert is_leap(2024) is True\nassert is_leap(2023) is False\nprint('RESULTS_OK')",
|
| 146 |
+
"I07_refactor": "assert fib(0) == 0\nassert fib(10) == 55\nassert fib(30) == 832040\nprint('RESULTS_OK')",
|
| 147 |
+
"I08_regex_ipv4": "assert is_valid_ipv4('192.168.1.1') is True\nassert is_valid_ipv4('255.255.255.0') is True\nassert is_valid_ipv4('256.1.1.1') is False\nassert is_valid_ipv4('01.2.3.4') is False\nassert is_valid_ipv4('1.2.3') is False\nassert is_valid_ipv4('1.2.3.4.5') is False\nprint('RESULTS_OK')",
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
if __name__ == "__main__":
|
| 151 |
+
from collections import Counter
|
| 152 |
+
c = Counter(it["tier"] for it in SUITE)
|
| 153 |
+
print("suite:", len(SUITE), "items", dict(c))
|
| 154 |
+
assert len(SUITE) == 38 and c[E] == 12 and c[M] == 12 and c[H] == 6 and c[I] == 8
|
benchmark/harness/run_bench.py
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Benchmark harness: runs the 38-item suite against a GGUF via llama-server.
|
| 3 |
+
Checkpointed per item (JSON) so runs are resumable across invocations.
|
| 4 |
+
Usage: run_bench.py --tag Q5_K_M --gguf path [--max-items N] [--only id1,id2]
|
| 5 |
+
"""
|
| 6 |
+
import argparse, json, os, re, signal, subprocess, sys, tempfile, time, threading
|
| 7 |
+
import requests
|
| 8 |
+
|
| 9 |
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 10 |
+
from bench_suite import SUITE, RUNTIME_CHECKS
|
| 11 |
+
|
| 12 |
+
BASE = "/home/z/my-project/bench"
|
| 13 |
+
RESULTS = f"{BASE}/results"
|
| 14 |
+
PORT = 8765
|
| 15 |
+
LLAMA = f"{BASE}/bin"
|
| 16 |
+
|
| 17 |
+
def extract_code(text):
|
| 18 |
+
m = re.search(r"```(?:python|py)?\s*\n(.*?)```", text, re.S)
|
| 19 |
+
if m:
|
| 20 |
+
return m.group(1).strip()
|
| 21 |
+
m = re.search(r"```\s*\n(.*?)```", text, re.S)
|
| 22 |
+
if m:
|
| 23 |
+
return m.group(1).strip()
|
| 24 |
+
idxs = [i for i in (text.find("\ndef "), text.find("\nclass "), 0 if text.startswith(("def ", "class ")) else -1) if i >= 0]
|
| 25 |
+
if idxs:
|
| 26 |
+
return text[min(idxs):].strip()
|
| 27 |
+
return text.strip()
|
| 28 |
+
|
| 29 |
+
def run_generated(code, tests, timeout=12):
|
| 30 |
+
"""Execute generated code + tests in a fresh python subprocess."""
|
| 31 |
+
if not code.strip():
|
| 32 |
+
return False, "empty code"
|
| 33 |
+
with tempfile.NamedTemporaryFile("w", suffix=".py", delete=False, dir="/tmp") as f:
|
| 34 |
+
f.write(code + "\n\n" + tests + "\n")
|
| 35 |
+
path = f.name
|
| 36 |
+
try:
|
| 37 |
+
r = subprocess.run([sys.executable, path], capture_output=True, text=True, timeout=timeout)
|
| 38 |
+
if r.returncode == 0 and "RESULTS_OK" in r.stdout:
|
| 39 |
+
return True, "passed"
|
| 40 |
+
return False, (r.stderr.strip().splitlines() or ["no output"])[-1][:300]
|
| 41 |
+
except subprocess.TimeoutExpired:
|
| 42 |
+
return False, f"timeout {timeout}s"
|
| 43 |
+
finally:
|
| 44 |
+
os.unlink(path)
|
| 45 |
+
|
| 46 |
+
def check_instruction(item, text):
|
| 47 |
+
t = text.strip()
|
| 48 |
+
low = t.lower()
|
| 49 |
+
if item["checks_kind"] == "explain":
|
| 50 |
+
words = len(t.split())
|
| 51 |
+
kws = ["loop", "append", "double", "sum", "list", "iterat", "range", "total", "multipl", "twice", "2"]
|
| 52 |
+
hits = sum(1 for k in kws if k in low)
|
| 53 |
+
c1 = 40 <= words <= 500
|
| 54 |
+
c2 = hits >= 3
|
| 55 |
+
return c1 and c2, {"words": words, "kw_hits": hits, "len_ok": c1, "kw_ok": c2}
|
| 56 |
+
if item["checks_kind"] == "json":
|
| 57 |
+
raw = t
|
| 58 |
+
m = re.search(r"\{.*\}", raw, re.S)
|
| 59 |
+
if not m:
|
| 60 |
+
return False, {"parse": False}
|
| 61 |
+
try:
|
| 62 |
+
obj = json.loads(m.group(0))
|
| 63 |
+
ok_keys = set(obj) == {"name", "port", "debug", "tags"}
|
| 64 |
+
ok_vals = (obj.get("name") == "web-server" and obj.get("port") == 8080
|
| 65 |
+
and obj.get("debug") is False and obj.get("tags") == ["prod", "edge"])
|
| 66 |
+
return ok_keys and ok_vals, {"parse": True, "keys_ok": ok_keys, "vals_ok": ok_vals}
|
| 67 |
+
except Exception as e:
|
| 68 |
+
return False, {"parse": False, "err": str(e)[:120]}
|
| 69 |
+
if item["checks_kind"] == "bullets":
|
| 70 |
+
lines = [l.strip() for l in t.splitlines() if l.strip()]
|
| 71 |
+
bl = [l for l in lines if re.match(r"^[-*\u2022]\s+", l)]
|
| 72 |
+
c1 = len(bl) == 3
|
| 73 |
+
c2 = all(len(l.split()) <= 27 for l in bl)
|
| 74 |
+
return c1 and c2, {"bullet_count": len(bl), "short_ok": c2}
|
| 75 |
+
if item["checks_kind"] == "review":
|
| 76 |
+
names_bug = any(k in low for k in ["off-by-one", "off by one", "exclusive", "missing the + 1", "missing + 1", "one less", "skips"])
|
| 77 |
+
has_fix = bool(re.search(r"range\(\s*n\s*\+\s*1\s*\)", t))
|
| 78 |
+
return names_bug and has_fix, {"names_bug": names_bug, "has_fix_range_n_plus_1": has_fix}
|
| 79 |
+
if item["checks_kind"] == "mcq":
|
| 80 |
+
ok = bool(re.match(r"^\s*ANSWER:\s*C\s*$", t))
|
| 81 |
+
return ok, {"exact_format": ok}
|
| 82 |
+
return False, {"err": "unknown kind"}
|
| 83 |
+
|
| 84 |
+
SYSTEM = "You are an expert Python programmer and technical assistant. Follow the user's instructions exactly and concisely."
|
| 85 |
+
|
| 86 |
+
def wait_health(proc, deadline=600):
|
| 87 |
+
t0 = time.time()
|
| 88 |
+
while time.time() - t0 < deadline:
|
| 89 |
+
if proc.poll() is not None:
|
| 90 |
+
raise RuntimeError(f"llama-server exited early rc={proc.returncode}")
|
| 91 |
+
try:
|
| 92 |
+
r = requests.get(f"http://127.0.0.1:{PORT}/health", timeout=2)
|
| 93 |
+
if r.status_code == 200:
|
| 94 |
+
return time.time() - t0
|
| 95 |
+
except Exception:
|
| 96 |
+
pass
|
| 97 |
+
time.sleep(0.5)
|
| 98 |
+
raise RuntimeError("health timeout")
|
| 99 |
+
|
| 100 |
+
class RSSMonitor(threading.Thread):
|
| 101 |
+
def __init__(self, pid):
|
| 102 |
+
super().__init__(daemon=True)
|
| 103 |
+
self.pid = pid; self.peak = 0; self.stop = False
|
| 104 |
+
def run(self):
|
| 105 |
+
import psutil
|
| 106 |
+
try:
|
| 107 |
+
p = psutil.Process(self.pid)
|
| 108 |
+
while not self.stop:
|
| 109 |
+
try:
|
| 110 |
+
mem = p.memory_info().rss
|
| 111 |
+
for c in p.children(recursive=True):
|
| 112 |
+
mem += c.memory_info().rss
|
| 113 |
+
self.peak = max(self.peak, mem)
|
| 114 |
+
except Exception:
|
| 115 |
+
pass
|
| 116 |
+
time.sleep(0.5)
|
| 117 |
+
except Exception:
|
| 118 |
+
pass
|
| 119 |
+
|
| 120 |
+
def start_server(gguf):
|
| 121 |
+
cmd = [f"{LLAMA}/llama-server", "-m", gguf, "--port", str(PORT), "-c", "1280",
|
| 122 |
+
"-t", "2", "--threads-batch", "2", "-b", "512", "--jinja", "--temp", "0.0",
|
| 123 |
+
"--top-p", "1.0", "--no-warmup", "--metrics", "--slots"]
|
| 124 |
+
proc = subprocess.Popen(cmd, stdout=open(f"{BASE}/logs/server_{args.tag}.log", "w"),
|
| 125 |
+
stderr=subprocess.STDOUT, start_new_session=True)
|
| 126 |
+
load_s = wait_health(proc)
|
| 127 |
+
return proc, load_s
|
| 128 |
+
|
| 129 |
+
def chat(user_msg, max_tokens):
|
| 130 |
+
r = requests.post(f"http://127.0.0.1:{PORT}/v1/chat/completions",
|
| 131 |
+
json={"messages": [{"role": "system", "content": SYSTEM}, {"role": "user", "content": user_msg}],
|
| 132 |
+
"temperature": 0.0, "top_p": 1.0, "max_tokens": max_tokens, "stream": False},
|
| 133 |
+
timeout=600)
|
| 134 |
+
r.raise_for_status()
|
| 135 |
+
return r.json()
|
| 136 |
+
|
| 137 |
+
def main():
|
| 138 |
+
global args
|
| 139 |
+
ap = argparse.ArgumentParser()
|
| 140 |
+
ap.add_argument("--tag", required=True)
|
| 141 |
+
ap.add_argument("--gguf", required=True)
|
| 142 |
+
ap.add_argument("--max-items", type=int, default=999)
|
| 143 |
+
ap.add_argument("--only", default="")
|
| 144 |
+
args = ap.parse_args()
|
| 145 |
+
|
| 146 |
+
os.makedirs(f"{RESULTS}/{args.tag}", exist_ok=True)
|
| 147 |
+
todo = [it for it in SUITE
|
| 148 |
+
if not os.path.exists(f"{RESULTS}/{args.tag}/{it['id']}.json")]
|
| 149 |
+
if args.only:
|
| 150 |
+
want = set(args.only.split(","))
|
| 151 |
+
todo = [it for it in todo if it["id"] in want]
|
| 152 |
+
todo = todo[: args.max_items]
|
| 153 |
+
if not todo:
|
| 154 |
+
print("nothing to do"); return
|
| 155 |
+
|
| 156 |
+
proc, load_s = start_server(args.gguf)
|
| 157 |
+
mon = RSSMonitor(proc.pid); mon.start()
|
| 158 |
+
print(f"server up in {load_s:.1f}s | {len(todo)} items to run", flush=True)
|
| 159 |
+
try:
|
| 160 |
+
for it in todo:
|
| 161 |
+
t0 = time.time()
|
| 162 |
+
data = chat(it["prompt"], it["mt"])
|
| 163 |
+
dt = time.time() - t0
|
| 164 |
+
msg = data["choices"][0]["message"]["content"] or ""
|
| 165 |
+
msg = re.sub(r"^\s*assistant\s*", "", msg, count=1) # strip jinja assistant-prefix artifact
|
| 166 |
+
usage = data.get("usage", {})
|
| 167 |
+
timings = data.get("timings", {}) or {}
|
| 168 |
+
rec = dict(id=it["id"], tier=it["tier"], tag=args.tag,
|
| 169 |
+
wall_s=round(dt, 2),
|
| 170 |
+
prompt_tokens=usage.get("prompt_tokens"),
|
| 171 |
+
gen_tokens=usage.get("completion_tokens"),
|
| 172 |
+
prompt_ms=timings.get("prompt_ms"), gen_ms=timings.get("predicted_ms"),
|
| 173 |
+
gen_tps=round(timings.get("predicted_per_second", 0) or 0, 3),
|
| 174 |
+
pp_tps=round(timings.get("prompt_per_second", 0) or 0, 3),
|
| 175 |
+
peak_rss_mb=None)
|
| 176 |
+
if it["tier"] == "instruction":
|
| 177 |
+
if it["id"] in RUNTIME_CHECKS:
|
| 178 |
+
code = extract_code(msg)
|
| 179 |
+
ok, detail = run_generated(code, RUNTIME_CHECKS[it["id"]])
|
| 180 |
+
if it["id"] == "I05_leap_docstring":
|
| 181 |
+
has_doc = '"""' in code or "'''" in code
|
| 182 |
+
detail = f"{detail}|docstring={has_doc}"
|
| 183 |
+
ok = ok and has_doc
|
| 184 |
+
rec.update(passed=ok, detail=str(detail)[:300])
|
| 185 |
+
else:
|
| 186 |
+
ok, detail = check_instruction(it, msg)
|
| 187 |
+
rec.update(passed=ok, detail=json.dumps(detail)[:300])
|
| 188 |
+
else:
|
| 189 |
+
code = extract_code(msg)
|
| 190 |
+
ok, detail = run_generated(code, it["tests"])
|
| 191 |
+
rec.update(passed=ok, detail=str(detail)[:300])
|
| 192 |
+
rec["response"] = msg
|
| 193 |
+
rec["code_extracted"] = code if it["tier"] != "instruction" or it["id"] in RUNTIME_CHECKS else ""
|
| 194 |
+
with open(f"{RESULTS}/{args.tag}/{it['id']}.json", "w") as f:
|
| 195 |
+
json.dump(rec, f, indent=1)
|
| 196 |
+
print(f"[{args.tag}] {it['id']}: {'PASS' if rec['passed'] else 'FAIL'} "
|
| 197 |
+
f"({rec['gen_tokens']} tok, {rec['gen_tps']} t/s, {dt:.0f}s)", flush=True)
|
| 198 |
+
finally:
|
| 199 |
+
mon.stop = True; time.sleep(0.6)
|
| 200 |
+
peak = mon.peak
|
| 201 |
+
with open(f"{RESULTS}/{args.tag}/_meta.json", "w") as f:
|
| 202 |
+
json.dump({"load_seconds": round(load_s, 2), "peak_rss_mb": round(peak / 1e6, 1),
|
| 203 |
+
"gguf": args.gguf, "ctx": 1280, "threads": 2, "port": PORT}, f, indent=1)
|
| 204 |
+
proc.send_signal(signal.SIGTERM)
|
| 205 |
+
try:
|
| 206 |
+
proc.wait(timeout=10)
|
| 207 |
+
except Exception:
|
| 208 |
+
proc.kill()
|
| 209 |
+
print(f"peak RSS: {peak/1e6:.0f} MB | load: {load_s:.1f}s", flush=True)
|
| 210 |
+
|
| 211 |
+
if __name__ == "__main__":
|
| 212 |
+
main()
|
benchmark/results/Q4_K_M/E01_fizzbuzz.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "E01_fizzbuzz",
|
| 3 |
+
"tier": "easy",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 54.91,
|
| 6 |
+
"prompt_tokens": 88,
|
| 7 |
+
"gen_tokens": 224,
|
| 8 |
+
"prompt_ms": 2429.607,
|
| 9 |
+
"gen_ms": 52470.669,
|
| 10 |
+
"gen_tps": 4.25,
|
| 11 |
+
"pp_tps": 36.22,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "Here's a Python function `fizzbuzz(n)` that returns a list of strings for numbers 1..n where multiples of 3 are 'Fizz', multiples of 5 are 'Buzz', multiples of both are 'FizzBuzz', otherwise the number as a string:\n\n```python\ndef fizzbuzz(n):\n result = []\n for i in range(1, n+1):\n if i % 3 == 0 and i % 5 == 0:\n result.append('FizzBuzz')\n elif i % 3 == 0:\n result.append('Fizz')\n elif i % 5 == 0:\n result.append('Buzz')\n else:\n result.append(str(i))\n return result\n```\n\nThis function works by iterating over the range 1 to n (inclusive) and checking if each number is a multiple of 3, 5, or both. If it's a multiple of both 3 and 5, it appends 'FizzBuzz' to the result list. If it's a multiple of 3, it appends 'Fizz'",
|
| 16 |
+
"code_extracted": "def fizzbuzz(n):\n result = []\n for i in range(1, n+1):\n if i % 3 == 0 and i % 5 == 0:\n result.append('FizzBuzz')\n elif i % 3 == 0:\n result.append('Fizz')\n elif i % 5 == 0:\n result.append('Buzz')\n else:\n result.append(str(i))\n return result"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/E02_reverse_string.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "E02_reverse_string",
|
| 3 |
+
"tier": "easy",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 4.09,
|
| 6 |
+
"prompt_tokens": 49,
|
| 7 |
+
"gen_tokens": 16,
|
| 8 |
+
"prompt_ms": 593.055,
|
| 9 |
+
"gen_ms": 3471.837,
|
| 10 |
+
"gen_tps": 4.32,
|
| 11 |
+
"pp_tps": 25.293,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "```python\ndef reverse_string(s):\n return s[::-1]\n```",
|
| 16 |
+
"code_extracted": "def reverse_string(s):\n return s[::-1]"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/E03_sum_list.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "E03_sum_list",
|
| 3 |
+
"tier": "easy",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 7.55,
|
| 6 |
+
"prompt_tokens": 59,
|
| 7 |
+
"gen_tokens": 31,
|
| 8 |
+
"prompt_ms": 814.591,
|
| 9 |
+
"gen_ms": 6734.13,
|
| 10 |
+
"gen_tps": 4.455,
|
| 11 |
+
"pp_tps": 30.69,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "```python\ndef sum_list(nums):\n total = 0\n for num in nums:\n total += num\n return total\n```",
|
| 16 |
+
"code_extracted": "def sum_list(nums):\n total = 0\n for num in nums:\n total += num\n return total"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/E04_is_palindrome.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "E04_is_palindrome",
|
| 3 |
+
"tier": "easy",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 30.61,
|
| 6 |
+
"prompt_tokens": 61,
|
| 7 |
+
"gen_tokens": 134,
|
| 8 |
+
"prompt_ms": 830.709,
|
| 9 |
+
"gen_ms": 29762.453,
|
| 10 |
+
"gen_tps": 4.469,
|
| 11 |
+
"pp_tps": 32.502,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "Here's a Python function that checks if a string is a palindrome, considering only alphanumeric characters and ignoring case:\n\n```python\ndef is_palindrome(s):\n # Remove non-alphanumeric characters and convert to lowercase\n cleaned_s = ''.join(char.lower() for char in s if char.isalnum())\n \n # Check if the cleaned string is the same when reversed\n return cleaned_s == cleaned_s[::-1]\n```\n\nThis function works by first cleaning the input string by removing non-alphanumeric characters and converting it to lowercase. Then it checks if the cleaned string is the same when reversed. If it is, then the original string is a palindrome.",
|
| 16 |
+
"code_extracted": "def is_palindrome(s):\n # Remove non-alphanumeric characters and convert to lowercase\n cleaned_s = ''.join(char.lower() for char in s if char.isalnum())\n \n # Check if the cleaned string is the same when reversed\n return cleaned_s == cleaned_s[::-1]"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/E05_max_in_list.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "E05_max_in_list",
|
| 3 |
+
"tier": "easy",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 11.3,
|
| 6 |
+
"prompt_tokens": 66,
|
| 7 |
+
"gen_tokens": 48,
|
| 8 |
+
"prompt_ms": 902.541,
|
| 9 |
+
"gen_ms": 10374.332,
|
| 10 |
+
"gen_tps": 4.53,
|
| 11 |
+
"pp_tps": 35.455,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "```python\ndef max_in_list(nums):\n max_val = nums[0]\n for num in nums[1:]:\n if num > max_val:\n max_val = num\n return max_val\n```",
|
| 16 |
+
"code_extracted": "def max_in_list(nums):\n max_val = nums[0]\n for num in nums[1:]:\n if num > max_val:\n max_val = num\n return max_val"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/E06_count_vowels.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "E06_count_vowels",
|
| 3 |
+
"tier": "easy",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 13.47,
|
| 6 |
+
"prompt_tokens": 66,
|
| 7 |
+
"gen_tokens": 51,
|
| 8 |
+
"prompt_ms": 2446.587,
|
| 9 |
+
"gen_ms": 11014.269,
|
| 10 |
+
"gen_tps": 4.54,
|
| 11 |
+
"pp_tps": 26.976,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "```python\ndef count_vowels(s):\n vowels = \"aeiou\"\n count = 0\n for char in s.lower():\n if char in vowels:\n count += 1\n return count\n```",
|
| 16 |
+
"code_extracted": "def count_vowels(s):\n vowels = \"aeiou\"\n count = 0\n for char in s.lower():\n if char in vowels:\n count += 1\n return count"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/E07_celsius_to_fahrenheit.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "E07_celsius_to_fahrenheit",
|
| 3 |
+
"tier": "easy",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 6.15,
|
| 6 |
+
"prompt_tokens": 65,
|
| 7 |
+
"gen_tokens": 26,
|
| 8 |
+
"prompt_ms": 921.492,
|
| 9 |
+
"gen_ms": 5218.976,
|
| 10 |
+
"gen_tps": 4.79,
|
| 11 |
+
"pp_tps": 33.641,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "```python\ndef celsius_to_fahrenheit(c):\n return c * 9/5 + 32\n```",
|
| 16 |
+
"code_extracted": "def celsius_to_fahrenheit(c):\n return c * 9/5 + 32"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/E08_word_count.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "E08_word_count",
|
| 3 |
+
"tier": "easy",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 18.23,
|
| 6 |
+
"prompt_tokens": 62,
|
| 7 |
+
"gen_tokens": 81,
|
| 8 |
+
"prompt_ms": 808.333,
|
| 9 |
+
"gen_ms": 17409.992,
|
| 10 |
+
"gen_tps": 4.595,
|
| 11 |
+
"pp_tps": 34.639,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "Here's a Python function that counts the number of words in a string:\n\n```python\ndef word_count(s):\n return len(s.split())\n```\n\nThis function works by splitting the string `s` into a list of words using the `split()` method, which splits on whitespace by default. Then, it returns the length of this list, which is the number of words in the string.",
|
| 16 |
+
"code_extracted": "def word_count(s):\n return len(s.split())"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/E09_factorial.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "E09_factorial",
|
| 3 |
+
"tier": "easy",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 16.25,
|
| 6 |
+
"prompt_tokens": 53,
|
| 7 |
+
"gen_tokens": 74,
|
| 8 |
+
"prompt_ms": 641.162,
|
| 9 |
+
"gen_ms": 15595.766,
|
| 10 |
+
"gen_tps": 4.681,
|
| 11 |
+
"pp_tps": 29.634,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "```python\ndef factorial(n):\n if n < 0:\n raise ValueError(\"Factorial is not defined for negative numbers\")\n if n == 0 or n == 1:\n return 1\n result = 1\n for i in range(2, n + 1):\n result *= i\n return result\n```",
|
| 16 |
+
"code_extracted": "def factorial(n):\n if n < 0:\n raise ValueError(\"Factorial is not defined for negative numbers\")\n if n == 0 or n == 1:\n return 1\n result = 1\n for i in range(2, n + 1):\n result *= i\n return result"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/E10_remove_duplicates.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "E10_remove_duplicates",
|
| 3 |
+
"tier": "easy",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 10.37,
|
| 6 |
+
"prompt_tokens": 58,
|
| 7 |
+
"gen_tokens": 46,
|
| 8 |
+
"prompt_ms": 777.825,
|
| 9 |
+
"gen_ms": 9584.433,
|
| 10 |
+
"gen_tps": 4.695,
|
| 11 |
+
"pp_tps": 30.855,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "```python\ndef remove_duplicates(nums):\n seen = set()\n result = []\n for num in nums:\n if num not in seen:\n seen.add(num)\n result.append(num)\n return result\n```",
|
| 16 |
+
"code_extracted": "def remove_duplicates(nums):\n seen = set()\n result = []\n for num in nums:\n if num not in seen:\n seen.add(num)\n result.append(num)\n return result"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/E11_second_largest.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "E11_second_largest",
|
| 3 |
+
"tier": "easy",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 13.28,
|
| 6 |
+
"prompt_tokens": 63,
|
| 7 |
+
"gen_tokens": 59,
|
| 8 |
+
"prompt_ms": 1673.466,
|
| 9 |
+
"gen_ms": 11602.589,
|
| 10 |
+
"gen_tps": 4.999,
|
| 11 |
+
"pp_tps": 37.646,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "```python\ndef second_largest(nums):\n if len(nums) < 2:\n return None\n nums = list(set(nums))\n nums.sort(reverse=True)\n if len(nums) < 2:\n return None\n return nums[1]\n```",
|
| 16 |
+
"code_extracted": "def second_largest(nums):\n if len(nums) < 2:\n return None\n nums = list(set(nums))\n nums.sort(reverse=True)\n if len(nums) < 2:\n return None\n return nums[1]"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/E12_is_prime.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "E12_is_prime",
|
| 3 |
+
"tier": "easy",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 18.57,
|
| 6 |
+
"prompt_tokens": 56,
|
| 7 |
+
"gen_tokens": 85,
|
| 8 |
+
"prompt_ms": 732.927,
|
| 9 |
+
"gen_ms": 17826.251,
|
| 10 |
+
"gen_tps": 4.712,
|
| 11 |
+
"pp_tps": 30.017,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "```python\ndef is_prime(n):\n if n < 2:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n for i in range(3, int(n**0.5) + 1, 2):\n if n % i == 0:\n return False\n return True\n```",
|
| 16 |
+
"code_extracted": "def is_prime(n):\n if n < 2:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n for i in range(3, int(n**0.5) + 1, 2):\n if n % i == 0:\n return False\n return True"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/H01_lru_cache.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "H01_lru_cache",
|
| 3 |
+
"tier": "hard",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 99.79,
|
| 6 |
+
"prompt_tokens": 84,
|
| 7 |
+
"gen_tokens": 416,
|
| 8 |
+
"prompt_ms": 1668.497,
|
| 9 |
+
"gen_ms": 98090.926,
|
| 10 |
+
"gen_tps": 4.231,
|
| 11 |
+
"pp_tps": 30.566,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": false,
|
| 14 |
+
"detail": "AssertionError",
|
| 15 |
+
"response": "Here's a Python implementation of the `LRUCache` class using a dictionary and a doubly linked list:\n\n```python\nclass LRUCache:\n def __init__(self, capacity):\n self.capacity = capacity\n self.cache = {}\n self.head = None\n self.tail = None\n\n def get(self, key):\n if key not in self.cache:\n return -1\n node = self.cache[key]\n self.move_to_end(node)\n return node.value\n\n def put(self, key, value):\n if key in self.cache:\n node = self.cache[key]\n node.value = value\n self.move_to_end(node)\n else:\n if len(self.cache) >= self.capacity:\n self.evict()\n node = Node(key, value)\n self.cache[key] = node\n self.add_to_end(node)\n\n def evict(self):\n key = self.tail.key\n del self.cache[key]\n self.tail = self.tail.prev\n\n def add_to_end(self, node):\n if self.head is None:\n self.head = node\n self.tail = node\n else:\n node.next = self.head\n self.head.prev = node\n self.head = node\n\n def move_to_end(self, node):\n if node == self.tail:\n return\n if node == self.head:\n self.head = node.next\n node.next.prev = None\n else:\n node.prev.next = node.next\n node.next.prev = node.prev\n node.next = None\n node.prev = None\n self.add_to_end(node)\n\nclass Node:\n def __init__(self, key, value):\n self.key = key\n self.value = value\n self.next = None\n self.prev = None\n```\n\nThis implementation uses a dictionary to store the key-value pairs and a doubly linked list to maintain the order of the items. The `get` method moves the requested item to the end of the list, and the",
|
| 16 |
+
"code_extracted": "class LRUCache:\n def __init__(self, capacity):\n self.capacity = capacity\n self.cache = {}\n self.head = None\n self.tail = None\n\n def get(self, key):\n if key not in self.cache:\n return -1\n node = self.cache[key]\n self.move_to_end(node)\n return node.value\n\n def put(self, key, value):\n if key in self.cache:\n node = self.cache[key]\n node.value = value\n self.move_to_end(node)\n else:\n if len(self.cache) >= self.capacity:\n self.evict()\n node = Node(key, value)\n self.cache[key] = node\n self.add_to_end(node)\n\n def evict(self):\n key = self.tail.key\n del self.cache[key]\n self.tail = self.tail.prev\n\n def add_to_end(self, node):\n if self.head is None:\n self.head = node\n self.tail = node\n else:\n node.next = self.head\n self.head.prev = node\n self.head = node\n\n def move_to_end(self, node):\n if node == self.tail:\n return\n if node == self.head:\n self.head = node.next\n node.next.prev = None\n else:\n node.prev.next = node.next\n node.next.prev = node.prev\n node.next = None\n node.prev = None\n self.add_to_end(node)\n\nclass Node:\n def __init__(self, key, value):\n self.key = key\n self.value = value\n self.next = None\n self.prev = None"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/H02_edit_distance.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "H02_edit_distance",
|
| 3 |
+
"tier": "hard",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 45.2,
|
| 6 |
+
"prompt_tokens": 67,
|
| 7 |
+
"gen_tokens": 195,
|
| 8 |
+
"prompt_ms": 2382.425,
|
| 9 |
+
"gen_ms": 42806.54,
|
| 10 |
+
"gen_tps": 4.532,
|
| 11 |
+
"pp_tps": 28.123,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "```python\ndef edit_distance(a, b):\n m, n = len(a), len(b)\n dp = [[0] * (n + 1) for _ in range(m + 1)]\n for i in range(m + 1):\n dp[i][0] = i\n for j in range(n + 1):\n dp[0][j] = j\n for i in range(1, m + 1):\n for j in range(1, n + 1):\n if a[i - 1] == b[j - 1]:\n dp[i][j] = dp[i - 1][j - 1]\n else:\n dp[i][j] = min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]) + 1\n return dp[m][n]\n```",
|
| 16 |
+
"code_extracted": "def edit_distance(a, b):\n m, n = len(a), len(b)\n dp = [[0] * (n + 1) for _ in range(m + 1)]\n for i in range(m + 1):\n dp[i][0] = i\n for j in range(n + 1):\n dp[0][j] = j\n for i in range(1, m + 1):\n for j in range(1, n + 1):\n if a[i - 1] == b[j - 1]:\n dp[i][j] = dp[i - 1][j - 1]\n else:\n dp[i][j] = min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]) + 1\n return dp[m][n]"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/H03_tokenizer.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "H03_tokenizer",
|
| 3 |
+
"tier": "hard",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 32.09,
|
| 6 |
+
"prompt_tokens": 87,
|
| 7 |
+
"gen_tokens": 142,
|
| 8 |
+
"prompt_ms": 1598.374,
|
| 9 |
+
"gen_ms": 30461.03,
|
| 10 |
+
"gen_tps": 4.629,
|
| 11 |
+
"pp_tps": 33.159,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": false,
|
| 14 |
+
"detail": "AssertionError",
|
| 15 |
+
"response": "```python\ndef tokenize(s):\n s = s.lower()\n tokens = []\n i = 0\n while i < len(s):\n if s[i].isalpha():\n j = i\n while j < len(s) and s[j].isalpha():\n j += 1\n tokens.append(s[i:j])\n i = j\n elif s[i].isdigit():\n j = i\n while j < len(s) and s[j].isdigit():\n j += 1\n tokens.append(s[i:j])\n i = j\n else:\n tokens.append(s[i])\n i += 1\n return tokens\n```",
|
| 16 |
+
"code_extracted": "def tokenize(s):\n s = s.lower()\n tokens = []\n i = 0\n while i < len(s):\n if s[i].isalpha():\n j = i\n while j < len(s) and s[j].isalpha():\n j += 1\n tokens.append(s[i:j])\n i = j\n elif s[i].isdigit():\n j = i\n while j < len(s) and s[j].isdigit():\n j += 1\n tokens.append(s[i:j])\n i = j\n else:\n tokens.append(s[i])\n i += 1\n return tokens"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/H04_flatten_json.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "H04_flatten_json",
|
| 3 |
+
"tier": "hard",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 40.74,
|
| 6 |
+
"prompt_tokens": 84,
|
| 7 |
+
"gen_tokens": 171,
|
| 8 |
+
"prompt_ms": 1572.779,
|
| 9 |
+
"gen_ms": 39143.524,
|
| 10 |
+
"gen_tps": 4.343,
|
| 11 |
+
"pp_tps": 31.791,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": false,
|
| 14 |
+
"detail": "AssertionError",
|
| 15 |
+
"response": "```python\ndef flatten_json(obj):\n def _flatten(obj, path=\"\"):\n if isinstance(obj, dict):\n result = {}\n for key, value in obj.items():\n new_path = path + key + \".\"\n if isinstance(value, dict):\n result.update(_flatten(value, new_path))\n elif isinstance(value, list):\n for i, item in enumerate(value):\n result.update(_flatten(item, new_path + str(i) + \".\"))\n else:\n result[new_path] = value\n return result\n elif isinstance(obj, list):\n result = {}\n for i, item in enumerate(obj):\n result.update(_flatten(item, path + str(i) + \".\"))\n return result\n else:\n return {path: obj}\n return _flatten(obj)\n```",
|
| 16 |
+
"code_extracted": "def flatten_json(obj):\n def _flatten(obj, path=\"\"):\n if isinstance(obj, dict):\n result = {}\n for key, value in obj.items():\n new_path = path + key + \".\"\n if isinstance(value, dict):\n result.update(_flatten(value, new_path))\n elif isinstance(value, list):\n for i, item in enumerate(value):\n result.update(_flatten(item, new_path + str(i) + \".\"))\n else:\n result[new_path] = value\n return result\n elif isinstance(obj, list):\n result = {}\n for i, item in enumerate(obj):\n result.update(_flatten(item, path + str(i) + \".\"))\n return result\n else:\n return {path: obj}\n return _flatten(obj)"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/H05_rate_limiter.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "H05_rate_limiter",
|
| 3 |
+
"tier": "hard",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 55.97,
|
| 6 |
+
"prompt_tokens": 90,
|
| 7 |
+
"gen_tokens": 240,
|
| 8 |
+
"prompt_ms": 1923.427,
|
| 9 |
+
"gen_ms": 54017.187,
|
| 10 |
+
"gen_tps": 4.425,
|
| 11 |
+
"pp_tps": 30.674,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": false,
|
| 14 |
+
"detail": "AssertionError",
|
| 15 |
+
"response": "Here's a Python implementation of the `RateLimiter` class:\n\n```python\nclass RateLimiter:\n def __init__(self, max_requests, window_seconds):\n self.max_requests = max_requests\n self.window_seconds = window_seconds\n self.requests = []\n\n def allow(self, ts):\n # Remove requests that are outside the current window\n while self.requests and self.requests[0][0] < ts - self.window_seconds:\n self.requests.pop(0)\n\n # Check if we've exceeded the maximum number of requests\n if len(self.requests) >= self.max_requests:\n return False\n\n # Add the current request to the list\n self.requests.append((ts, True))\n\n return True\n```\n\nThis implementation uses a list to store the timestamps of requests. When a new request is made, it checks if any of the previous requests are outside the current window. If they are, they are removed from the list. Then it checks if the number of requests is greater than or equal to the maximum number of requests. If it is, the request is not allowed. Otherwise, the request is allowed and added to the list.",
|
| 16 |
+
"code_extracted": "class RateLimiter:\n def __init__(self, max_requests, window_seconds):\n self.max_requests = max_requests\n self.window_seconds = window_seconds\n self.requests = []\n\n def allow(self, ts):\n # Remove requests that are outside the current window\n while self.requests and self.requests[0][0] < ts - self.window_seconds:\n self.requests.pop(0)\n\n # Check if we've exceeded the maximum number of requests\n if len(self.requests) >= self.max_requests:\n return False\n\n # Add the current request to the list\n self.requests.append((ts, True))\n\n return True"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/H06_topo_sort.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "H06_topo_sort",
|
| 3 |
+
"tier": "hard",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 52.05,
|
| 6 |
+
"prompt_tokens": 93,
|
| 7 |
+
"gen_tokens": 221,
|
| 8 |
+
"prompt_ms": 1769.551,
|
| 9 |
+
"gen_ms": 50248.604,
|
| 10 |
+
"gen_tps": 4.378,
|
| 11 |
+
"pp_tps": 35.037,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "```python\ndef topo_sort(nodes, edges):\n # Create adjacency list\n adj = {node: [] for node in nodes}\n for u, v in edges:\n adj[u].append(v)\n\n # Create in-degree list\n in_degree = {node: 0 for node in nodes}\n for u, v in edges:\n in_degree[v] += 1\n\n # Create queue of nodes with in-degree 0\n queue = [node for node in nodes if in_degree[node] == 0]\n\n # Create result list\n result = []\n\n # Process nodes in queue\n while queue:\n node = queue.pop(0)\n result.append(node)\n\n # Update in-degree of neighbors\n for neighbor in adj[node]:\n in_degree[neighbor] -= 1\n if in_degree[neighbor] == 0:\n queue.append(neighbor)\n\n # Check if all nodes are processed\n if len(result) != len(nodes):\n raise ValueError(\"Invalid DAG\")\n\n return result\n```",
|
| 16 |
+
"code_extracted": "def topo_sort(nodes, edges):\n # Create adjacency list\n adj = {node: [] for node in nodes}\n for u, v in edges:\n adj[u].append(v)\n\n # Create in-degree list\n in_degree = {node: 0 for node in nodes}\n for u, v in edges:\n in_degree[v] += 1\n\n # Create queue of nodes with in-degree 0\n queue = [node for node in nodes if in_degree[node] == 0]\n\n # Create result list\n result = []\n\n # Process nodes in queue\n while queue:\n node = queue.pop(0)\n result.append(node)\n\n # Update in-degree of neighbors\n for neighbor in adj[node]:\n in_degree[neighbor] -= 1\n if in_degree[neighbor] == 0:\n queue.append(neighbor)\n\n # Check if all nodes are processed\n if len(result) != len(nodes):\n raise ValueError(\"Invalid DAG\")\n\n return result"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/I01_explain.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "I01_explain",
|
| 3 |
+
"tier": "instruction",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 31.38,
|
| 6 |
+
"prompt_tokens": 113,
|
| 7 |
+
"gen_tokens": 129,
|
| 8 |
+
"prompt_ms": 3043.487,
|
| 9 |
+
"gen_ms": 28327.002,
|
| 10 |
+
"gen_tps": 4.519,
|
| 11 |
+
"pp_tps": 37.128,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "{\"words\": 95, \"kw_hits\": 6, \"len_ok\": true, \"kw_ok\": true}",
|
| 15 |
+
"response": "The function `process` takes a list of numbers as input. It first creates an empty list `total`. Then, it iterates over the input list `items` and appends the product of each element and 2 to the `total` list. After that, it initializes a variable `s` to 0 and iterates over the `total` list, adding each element to `s`. Finally, it returns the sum `s`. This function is inefficient because it creates an intermediate list `total` that is not needed. It could be optimized by directly summing the products of the input list elements and 2.",
|
| 16 |
+
"code_extracted": ""
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/I02_json_config.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "I02_json_config",
|
| 3 |
+
"tier": "instruction",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 10.32,
|
| 6 |
+
"prompt_tokens": 85,
|
| 7 |
+
"gen_tokens": 41,
|
| 8 |
+
"prompt_ms": 1657.846,
|
| 9 |
+
"gen_ms": 8635.887,
|
| 10 |
+
"gen_tps": 4.632,
|
| 11 |
+
"pp_tps": 33.779,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "{\"parse\": true, \"keys_ok\": true, \"vals_ok\": true}",
|
| 15 |
+
"response": "```json\n{\n \"name\": \"web-server\",\n \"port\": 8080,\n \"debug\": false,\n \"tags\": [\"prod\", \"edge\"]\n}\n```",
|
| 16 |
+
"code_extracted": ""
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/I03_three_bullets.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "I03_three_bullets",
|
| 3 |
+
"tier": "instruction",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 14.07,
|
| 6 |
+
"prompt_tokens": 146,
|
| 7 |
+
"gen_tokens": 53,
|
| 8 |
+
"prompt_ms": 3111.884,
|
| 9 |
+
"gen_ms": 10944.99,
|
| 10 |
+
"gen_tps": 4.751,
|
| 11 |
+
"pp_tps": 37.598,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "{\"bullet_count\": 3, \"short_ok\": true}",
|
| 15 |
+
"response": "- Base models learn language patterns by predicting the next token from trillions of text tokens.\n- Fine-tuning uses curated examples and human feedback to improve helpfulness and safety.\n- Quantization compresses trained weights to fewer bits per parameter for efficient hardware use.",
|
| 16 |
+
"code_extracted": ""
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/I04_code_review.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "I04_code_review",
|
| 3 |
+
"tier": "instruction",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 8.02,
|
| 6 |
+
"prompt_tokens": 118,
|
| 7 |
+
"gen_tokens": 27,
|
| 8 |
+
"prompt_ms": 2463.8,
|
| 9 |
+
"gen_ms": 5531.888,
|
| 10 |
+
"gen_tps": 4.7,
|
| 11 |
+
"pp_tps": 36.123,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": false,
|
| 14 |
+
"detail": "{\"names_bug\": false, \"has_fix_range_n_plus_1\": true}",
|
| 15 |
+
"response": "The bug type is \"range\" and the corrected loop line is \"for i in range(n+1):\".",
|
| 16 |
+
"code_extracted": ""
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/I05_leap_docstring.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "I05_leap_docstring",
|
| 3 |
+
"tier": "instruction",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 34.8,
|
| 6 |
+
"prompt_tokens": 67,
|
| 7 |
+
"gen_tokens": 149,
|
| 8 |
+
"prompt_ms": 2305.414,
|
| 9 |
+
"gen_ms": 32483.757,
|
| 10 |
+
"gen_tps": 4.556,
|
| 11 |
+
"pp_tps": 29.062,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed|docstring=True",
|
| 15 |
+
"response": "```python\ndef is_leap(year):\n \"\"\"\n Determine if a year is a leap year according to the Gregorian calendar rules:\n - If the year is divisible by 4, it is a leap year, unless:\n - The year is divisible by 100, it is not a leap year, unless:\n - The year is divisible by 400, it is a leap year.\n \"\"\"\n if year % 4 == 0:\n if year % 100 == 0:\n if year % 400 == 0:\n return True\n else:\n return False\n else:\n return True\n else:\n return False\n```",
|
| 16 |
+
"code_extracted": "def is_leap(year):\n \"\"\"\n Determine if a year is a leap year according to the Gregorian calendar rules:\n - If the year is divisible by 4, it is a leap year, unless:\n - The year is divisible by 100, it is not a leap year, unless:\n - The year is divisible by 400, it is a leap year.\n \"\"\"\n if year % 4 == 0:\n if year % 100 == 0:\n if year % 400 == 0:\n return True\n else:\n return False\n else:\n return True\n else:\n return False"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/I06_mcq.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "I06_mcq",
|
| 3 |
+
"tier": "instruction",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 3.16,
|
| 6 |
+
"prompt_tokens": 98,
|
| 7 |
+
"gen_tokens": 5,
|
| 8 |
+
"prompt_ms": 2321.294,
|
| 9 |
+
"gen_ms": 819.257,
|
| 10 |
+
"gen_tps": 4.882,
|
| 11 |
+
"pp_tps": 29.725,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "{\"exact_format\": true}",
|
| 15 |
+
"response": "ANSWER: C",
|
| 16 |
+
"code_extracted": ""
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/I07_refactor.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "I07_refactor",
|
| 3 |
+
"tier": "instruction",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 17.14,
|
| 6 |
+
"prompt_tokens": 95,
|
| 7 |
+
"gen_tokens": 72,
|
| 8 |
+
"prompt_ms": 2284.931,
|
| 9 |
+
"gen_ms": 14840.154,
|
| 10 |
+
"gen_tps": 4.784,
|
| 11 |
+
"pp_tps": 28.885,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "Here's an efficient O(n) solution using dynamic programming:\n\n```python\ndef fib(n):\n if n < 2: return n\n a, b = 0, 1\n for _ in range(2, n+1):\n a, b = b, a + b\n return b\n```",
|
| 16 |
+
"code_extracted": "def fib(n):\n if n < 2: return n\n a, b = 0, 1\n for _ in range(2, n+1):\n a, b = b, a + b\n return b"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/I08_regex_ipv4.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "I08_regex_ipv4",
|
| 3 |
+
"tier": "instruction",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 25.36,
|
| 6 |
+
"prompt_tokens": 92,
|
| 7 |
+
"gen_tokens": 115,
|
| 8 |
+
"prompt_ms": 1699.601,
|
| 9 |
+
"gen_ms": 23625.28,
|
| 10 |
+
"gen_tps": 4.825,
|
| 11 |
+
"pp_tps": 37.068,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "```python\ndef is_valid_ipv4(s):\n if not s or len(s) > 15:\n return False\n s = s.split('.')\n if len(s) != 4:\n return False\n for octet in s:\n if not octet or not octet.isdigit():\n return False\n if len(octet) > 1 and octet[0] == '0':\n return False\n if int(octet) > 255:\n return False\n return True\n```",
|
| 16 |
+
"code_extracted": "def is_valid_ipv4(s):\n if not s or len(s) > 15:\n return False\n s = s.split('.')\n if len(s) != 4:\n return False\n for octet in s:\n if not octet or not octet.isdigit():\n return False\n if len(octet) > 1 and octet[0] == '0':\n return False\n if int(octet) > 255:\n return False\n return True"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/M01_two_sum.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "M01_two_sum",
|
| 3 |
+
"tier": "medium",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 56.06,
|
| 6 |
+
"prompt_tokens": 74,
|
| 7 |
+
"gen_tokens": 244,
|
| 8 |
+
"prompt_ms": 1550.447,
|
| 9 |
+
"gen_ms": 54493.545,
|
| 10 |
+
"gen_tps": 4.459,
|
| 11 |
+
"pp_tps": 25.799,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "Here's a Python function that solves the \"Two Sum\" problem:\n\n```python\ndef two_sum(nums, target):\n # Create a dictionary to store the index of each number\n num_dict = {}\n \n # Iterate through the list\n for i, num in enumerate(nums):\n # Calculate the complement (the number that would add up to the target)\n complement = target - num\n \n # If the complement is already in the dictionary, we found our answer\n if complement in num_dict:\n return [num_dict[complement], i]\n \n # Add the current number and its index to the dictionary\n num_dict[num] = i\n \n # If no solution is found, return an empty list\n return []\n```\n\nThis function works by iterating through the list of numbers and for each number, it calculates the complement (the number that would add up to the target). If the complement is already in the dictionary, it means we've found our answer, so we return the indices of the two numbers. If not, we add the current number and its index to the dictionary and continue iterating. If no solution is found, we return an empty list.",
|
| 16 |
+
"code_extracted": "def two_sum(nums, target):\n # Create a dictionary to store the index of each number\n num_dict = {}\n \n # Iterate through the list\n for i, num in enumerate(nums):\n # Calculate the complement (the number that would add up to the target)\n complement = target - num\n \n # If the complement is already in the dictionary, we found our answer\n if complement in num_dict:\n return [num_dict[complement], i]\n \n # Add the current number and its index to the dictionary\n num_dict[num] = i\n \n # If no solution is found, return an empty list\n return []"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/M02_valid_parentheses.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "M02_valid_parentheses",
|
| 3 |
+
"tier": "medium",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 39.51,
|
| 6 |
+
"prompt_tokens": 67,
|
| 7 |
+
"gen_tokens": 174,
|
| 8 |
+
"prompt_ms": 1487.863,
|
| 9 |
+
"gen_ms": 37992.592,
|
| 10 |
+
"gen_tps": 4.554,
|
| 11 |
+
"pp_tps": 22.179,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "Here's a Python function that checks if a string of brackets is valid:\n\n```python\ndef valid_parentheses(s):\n stack = []\n mapping = {\")\": \"(\", \"}\": \"{\", \"]\": \"[\"}\n for char in s:\n if char in mapping:\n if not stack or stack.pop() != mapping[char]:\n return False\n else:\n stack.append(char)\n return not stack\n```\n\nThis function works by using a stack data structure to keep track of the opening brackets. When it encounters a closing bracket, it checks if the top of the stack matches the corresponding opening bracket. If it doesn't match, the string of brackets is not valid. If it does match, it pops the opening bracket from the stack. If the stack is empty at the end of the function, the string of brackets is valid.",
|
| 16 |
+
"code_extracted": "def valid_parentheses(s):\n stack = []\n mapping = {\")\": \"(\", \"}\": \"{\", \"]\": \"[\"}\n for char in s:\n if char in mapping:\n if not stack or stack.pop() != mapping[char]:\n return False\n else:\n stack.append(char)\n return not stack"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/M03_merge_intervals.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "M03_merge_intervals",
|
| 3 |
+
"tier": "medium",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 57.4,
|
| 6 |
+
"prompt_tokens": 61,
|
| 7 |
+
"gen_tokens": 256,
|
| 8 |
+
"prompt_ms": 852.298,
|
| 9 |
+
"gen_ms": 56530.473,
|
| 10 |
+
"gen_tps": 4.511,
|
| 11 |
+
"pp_tps": 31.679,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "Here's a Python function that merges overlapping intervals:\n\n```python\ndef merge_intervals(intervals):\n if not intervals:\n return []\n\n # Sort intervals by start time\n intervals.sort(key=lambda x: x[0])\n\n merged = [intervals[0]]\n\n for current in intervals[1:]:\n # If current interval overlaps with the last interval in merged list\n if current[0] <= merged[-1][1]:\n # Merge the intervals\n merged[-1][1] = max(merged[-1][1], current[1])\n else:\n # Add the current interval to the merged list\n merged.append(current)\n\n return merged\n```\n\nThis function works by first sorting the intervals by their start times. Then, it iterates through the sorted intervals and checks if the current interval overlaps with the last interval in the `merged` list. If it does, the function merges the intervals by updating the end time of the last interval in the `merged` list. If it doesn't, the function adds the current interval to the `merged` list. Finally, the function returns the `merged` list.\n\nHere's an example of how to use this function:\n\n```python\nintervals = [[1, ",
|
| 16 |
+
"code_extracted": "def merge_intervals(intervals):\n if not intervals:\n return []\n\n # Sort intervals by start time\n intervals.sort(key=lambda x: x[0])\n\n merged = [intervals[0]]\n\n for current in intervals[1:]:\n # If current interval overlaps with the last interval in merged list\n if current[0] <= merged[-1][1]:\n # Merge the intervals\n merged[-1][1] = max(merged[-1][1], current[1])\n else:\n # Add the current interval to the merged list\n merged.append(current)\n\n return merged"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/M04_longest_substring.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "M04_longest_substring",
|
| 3 |
+
"tier": "medium",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 58.85,
|
| 6 |
+
"prompt_tokens": 59,
|
| 7 |
+
"gen_tokens": 256,
|
| 8 |
+
"prompt_ms": 1784.497,
|
| 9 |
+
"gen_ms": 57055.2,
|
| 10 |
+
"gen_tps": 4.469,
|
| 11 |
+
"pp_tps": 33.063,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "Here's a Python function that solves this problem:\n\n```python\ndef length_of_longest_substring(s):\n if not s:\n return 0\n\n max_length = 0\n start = 0\n char_index_map = {}\n\n for i, char in enumerate(s):\n if char in char_index_map and char_index_map[char] >= start:\n start = char_index_map[char] + 1\n\n char_index_map[char] = i\n max_length = max(max_length, i - start + 1)\n\n return max_length\n```\n\nThis function uses a sliding window approach with a hash map to keep track of the last seen index of each character. The window is defined by the `start` and `i` pointers, where `start` is the beginning of the current substring and `i` is the end. If a character is seen again within the current window, the window is moved to start from the position after the last occurrence of that character. The length of the longest substring without repeating characters is updated at each step.\n\nTime Complexity: O(n), where n is the length of the string.\nSpace Complexity: O(min(m,n)), where m is the size of the character set and n is the length",
|
| 16 |
+
"code_extracted": "def length_of_longest_substring(s):\n if not s:\n return 0\n\n max_length = 0\n start = 0\n char_index_map = {}\n\n for i, char in enumerate(s):\n if char in char_index_map and char_index_map[char] >= start:\n start = char_index_map[char] + 1\n\n char_index_map[char] = i\n max_length = max(max_length, i - start + 1)\n\n return max_length"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/M05_binary_search.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "M05_binary_search",
|
| 3 |
+
"tier": "medium",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 37.53,
|
| 6 |
+
"prompt_tokens": 63,
|
| 7 |
+
"gen_tokens": 168,
|
| 8 |
+
"prompt_ms": 858.129,
|
| 9 |
+
"gen_ms": 36631.212,
|
| 10 |
+
"gen_tps": 4.559,
|
| 11 |
+
"pp_tps": 33.794,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "Here's a Python function `binary_search` that implements binary search algorithm:\n\n```python\ndef binary_search(arr, target):\n left, right = 0, len(arr) - 1\n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n return -1\n```\n\nThis function works by repeatedly dividing the search interval in half. If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. Otherwise, narrow it to the upper half. Repeatedly check until the value is found or the interval is empty.",
|
| 16 |
+
"code_extracted": "def binary_search(arr, target):\n left, right = 0, len(arr) - 1\n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n return -1"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/M06_fib_fast.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "M06_fib_fast",
|
| 3 |
+
"tier": "medium",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 13.97,
|
| 6 |
+
"prompt_tokens": 72,
|
| 7 |
+
"gen_tokens": 62,
|
| 8 |
+
"prompt_ms": 1479.145,
|
| 9 |
+
"gen_ms": 12473.131,
|
| 10 |
+
"gen_tps": 4.891,
|
| 11 |
+
"pp_tps": 25.691,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "```python\ndef fib(n):\n if n <= 1:\n return n\n a, b = 0, 1\n for _ in range(2, n + 1):\n a, b = b, a + b\n return b\n```",
|
| 16 |
+
"code_extracted": "def fib(n):\n if n <= 1:\n return n\n a, b = 0, 1\n for _ in range(2, n + 1):\n a, b = b, a + b\n return b"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/M07_top_word.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "M07_top_word",
|
| 3 |
+
"tier": "medium",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 21.01,
|
| 6 |
+
"prompt_tokens": 74,
|
| 7 |
+
"gen_tokens": 90,
|
| 8 |
+
"prompt_ms": 1513.469,
|
| 9 |
+
"gen_ms": 19485.628,
|
| 10 |
+
"gen_tps": 4.567,
|
| 11 |
+
"pp_tps": 26.429,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "```python\ndef top_word(s):\n words = s.split()\n word_count = {}\n for word in words:\n word_count[word] = word_count.get(word, 0) + 1\n max_count = max(word_count.values())\n max_words = [word for word, count in word_count.items() if count == max_count]\n max_words.sort()\n return max_words[0]\n```",
|
| 16 |
+
"code_extracted": "def top_word(s):\n words = s.split()\n word_count = {}\n for word in words:\n word_count[word] = word_count.get(word, 0) + 1\n max_count = max(word_count.values())\n max_words = [word for word, count in word_count.items() if count == max_count]\n max_words.sort()\n return max_words[0]"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/M08_matrix_transpose.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "M08_matrix_transpose",
|
| 3 |
+
"tier": "medium",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 24.23,
|
| 6 |
+
"prompt_tokens": 53,
|
| 7 |
+
"gen_tokens": 109,
|
| 8 |
+
"prompt_ms": 662.837,
|
| 9 |
+
"gen_ms": 23551.231,
|
| 10 |
+
"gen_tps": 4.586,
|
| 11 |
+
"pp_tps": 28.665,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "Here's a Python function `transpose(matrix)` that returns the transpose of a 2D list:\n\n```python\ndef transpose(matrix):\n return [[row[i] for row in matrix] for i in range(len(matrix[0]))]\n```\n\nThis function works by iterating over the columns of the input matrix (using `range(len(matrix[0]))`) and for each column, it creates a new row in the output matrix by iterating over the rows of the input matrix. This effectively swaps the rows and columns of the input matrix.",
|
| 16 |
+
"code_extracted": "def transpose(matrix):\n return [[row[i] for row in matrix] for i in range(len(matrix[0]))]"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/M09_group_anagrams.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "M09_group_anagrams",
|
| 3 |
+
"tier": "medium",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 19.36,
|
| 6 |
+
"prompt_tokens": 71,
|
| 7 |
+
"gen_tokens": 80,
|
| 8 |
+
"prompt_ms": 2396.803,
|
| 9 |
+
"gen_ms": 16958.792,
|
| 10 |
+
"gen_tps": 4.658,
|
| 11 |
+
"pp_tps": 29.623,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "```python\ndef group_anagrams(words):\n anagram_groups = {}\n for word in words:\n sorted_word = ''.join(sorted(word))\n if sorted_word not in anagram_groups:\n anagram_groups[sorted_word] = []\n anagram_groups[sorted_word].append(word)\n return [sorted(group) for group in anagram_groups.values()]\n```",
|
| 16 |
+
"code_extracted": "def group_anagrams(words):\n anagram_groups = {}\n for word in words:\n sorted_word = ''.join(sorted(word))\n if sorted_word not in anagram_groups:\n anagram_groups[sorted_word] = []\n anagram_groups[sorted_word].append(word)\n return [sorted(group) for group in anagram_groups.values()]"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/M10_flatten_nested.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "M10_flatten_nested",
|
| 3 |
+
"tier": "medium",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 10.61,
|
| 6 |
+
"prompt_tokens": 61,
|
| 7 |
+
"gen_tokens": 46,
|
| 8 |
+
"prompt_ms": 853.965,
|
| 9 |
+
"gen_ms": 9738.155,
|
| 10 |
+
"gen_tps": 4.621,
|
| 11 |
+
"pp_tps": 31.617,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "```python\ndef flatten(nested):\n result = []\n for item in nested:\n if isinstance(item, list):\n result.extend(flatten(item))\n else:\n result.append(item)\n return result\n```",
|
| 16 |
+
"code_extracted": "def flatten(nested):\n result = []\n for item in nested:\n if isinstance(item, list):\n result.extend(flatten(item))\n else:\n result.append(item)\n return result"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/M11_roman_to_int.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "M11_roman_to_int",
|
| 3 |
+
"tier": "medium",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 29.3,
|
| 6 |
+
"prompt_tokens": 54,
|
| 7 |
+
"gen_tokens": 128,
|
| 8 |
+
"prompt_ms": 677.056,
|
| 9 |
+
"gen_ms": 28609.381,
|
| 10 |
+
"gen_tps": 4.439,
|
| 11 |
+
"pp_tps": 29.54,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "```python\ndef roman_to_int(s):\n roman_map = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}\n result = 0\n prev_value = 0\n \n for char in reversed(s):\n current_value = roman_map[char]\n if current_value >= prev_value:\n result += current_value\n else:\n result -= current_value\n prev_value = current_value\n \n return result\n```",
|
| 16 |
+
"code_extracted": "def roman_to_int(s):\n roman_map = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}\n result = 0\n prev_value = 0\n \n for char in reversed(s):\n current_value = roman_map[char]\n if current_value >= prev_value:\n result += current_value\n else:\n result -= current_value\n prev_value = current_value\n \n return result"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/M12_min_stack.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "M12_min_stack",
|
| 3 |
+
"tier": "medium",
|
| 4 |
+
"tag": "Q4_K_M",
|
| 5 |
+
"wall_s": 60.73,
|
| 6 |
+
"prompt_tokens": 64,
|
| 7 |
+
"gen_tokens": 259,
|
| 8 |
+
"prompt_ms": 1499.749,
|
| 9 |
+
"gen_ms": 59200.662,
|
| 10 |
+
"gen_tps": 4.358,
|
| 11 |
+
"pp_tps": 22.004,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "Here's a Python implementation of the `MinStack` class:\n\n```python\nclass MinStack:\n def __init__(self):\n self.stack = []\n self.min_stack = []\n\n def push(self, x):\n self.stack.append(x)\n if not self.min_stack or x <= self.min_stack[-1]:\n self.min_stack.append(x)\n\n def pop(self):\n if self.stack:\n if self.stack[-1] == self.min_stack[-1]:\n self.min_stack.pop()\n self.stack.pop()\n\n def top(self):\n if self.stack:\n return self.stack[-1]\n\n def get_min(self):\n if self.min_stack:\n return self.min_stack[-1]\n```\n\nThis implementation uses two stacks: `stack` to store all elements and `min_stack` to store the minimum element at each point in time. When pushing an element, if it's less than or equal to the current minimum, it's also pushed onto the `min_stack`. When popping an element, if it's equal to the current minimum, it's also popped from the `min_stack`. The `top()` method returns the top element of the `stack`, and the `get_min()` method returns the minimum element of the `min_stack`.",
|
| 16 |
+
"code_extracted": "class MinStack:\n def __init__(self):\n self.stack = []\n self.min_stack = []\n\n def push(self, x):\n self.stack.append(x)\n if not self.min_stack or x <= self.min_stack[-1]:\n self.min_stack.append(x)\n\n def pop(self):\n if self.stack:\n if self.stack[-1] == self.min_stack[-1]:\n self.min_stack.pop()\n self.stack.pop()\n\n def top(self):\n if self.stack:\n return self.stack[-1]\n\n def get_min(self):\n if self.min_stack:\n return self.min_stack[-1]"
|
| 17 |
+
}
|
benchmark/results/Q4_K_M/_meta.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"load_seconds": 6.04,
|
| 3 |
+
"peak_rss_mb": 3853.6,
|
| 4 |
+
"gguf": "models/qwen3-4b-coder-ft-Q4_K_M.gguf",
|
| 5 |
+
"ctx": 1280,
|
| 6 |
+
"threads": 2,
|
| 7 |
+
"port": 8765
|
| 8 |
+
}
|
benchmark/results/Q5_K_M/E01_fizzbuzz.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "E01_fizzbuzz",
|
| 3 |
+
"tier": "easy",
|
| 4 |
+
"tag": "Q5_K_M",
|
| 5 |
+
"wall_s": 31.48,
|
| 6 |
+
"prompt_tokens": 88,
|
| 7 |
+
"gen_tokens": 99,
|
| 8 |
+
"prompt_ms": 2775.454,
|
| 9 |
+
"gen_ms": 28696.68,
|
| 10 |
+
"gen_tps": 3.415,
|
| 11 |
+
"pp_tps": 31.707,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "assistant\n```python\ndef fizzbuzz(n):\n result = []\n for i in range(1, n+1):\n if i % 3 == 0 and i % 5 == 0:\n result.append('FizzBuzz')\n elif i % 3 == 0:\n result.append('Fizz')\n elif i % 5 == 0:\n result.append('Buzz')\n else:\n result.append(str(i))\n return result\n```",
|
| 16 |
+
"code_extracted": "def fizzbuzz(n):\n result = []\n for i in range(1, n+1):\n if i % 3 == 0 and i % 5 == 0:\n result.append('FizzBuzz')\n elif i % 3 == 0:\n result.append('Fizz')\n elif i % 5 == 0:\n result.append('Buzz')\n else:\n result.append(str(i))\n return result"
|
| 17 |
+
}
|
benchmark/results/Q5_K_M/E02_reverse_string.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "E02_reverse_string",
|
| 3 |
+
"tier": "easy",
|
| 4 |
+
"tag": "Q5_K_M",
|
| 5 |
+
"wall_s": 6.63,
|
| 6 |
+
"prompt_tokens": 49,
|
| 7 |
+
"gen_tokens": 16,
|
| 8 |
+
"prompt_ms": 1811.076,
|
| 9 |
+
"gen_ms": 4816.06,
|
| 10 |
+
"gen_tps": 3.115,
|
| 11 |
+
"pp_tps": 27.056,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "```python\ndef reverse_string(s):\n return s[::-1]\n```",
|
| 16 |
+
"code_extracted": "def reverse_string(s):\n return s[::-1]"
|
| 17 |
+
}
|
benchmark/results/Q5_K_M/E03_sum_list.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "E03_sum_list",
|
| 3 |
+
"tier": "easy",
|
| 4 |
+
"tag": "Q5_K_M",
|
| 5 |
+
"wall_s": 10.66,
|
| 6 |
+
"prompt_tokens": 59,
|
| 7 |
+
"gen_tokens": 34,
|
| 8 |
+
"prompt_ms": 906.684,
|
| 9 |
+
"gen_ms": 9746.304,
|
| 10 |
+
"gen_tps": 3.386,
|
| 11 |
+
"pp_tps": 27.573,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "```python\ndef sum_list(nums):\n total = 0\n for num in nums:\n total += num\n return total\n```",
|
| 16 |
+
"code_extracted": "def sum_list(nums):\n total = 0\n for num in nums:\n total += num\n return total"
|
| 17 |
+
}
|
benchmark/results/Q5_K_M/E04_is_palindrome.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"id": "E04_is_palindrome",
|
| 3 |
+
"tier": "easy",
|
| 4 |
+
"tag": "Q5_K_M",
|
| 5 |
+
"wall_s": 21.47,
|
| 6 |
+
"prompt_tokens": 61,
|
| 7 |
+
"gen_tokens": 69,
|
| 8 |
+
"prompt_ms": 945.106,
|
| 9 |
+
"gen_ms": 20498.032,
|
| 10 |
+
"gen_tps": 3.317,
|
| 11 |
+
"pp_tps": 28.568,
|
| 12 |
+
"peak_rss_mb": null,
|
| 13 |
+
"passed": true,
|
| 14 |
+
"detail": "passed",
|
| 15 |
+
"response": "```python\ndef is_palindrome(s):\n # Remove non-alphanumeric characters and convert to lowercase\n cleaned_s = ''.join(char.lower() for char in s if char.isalnum())\n \n # Check if the cleaned string is the same as its reverse\n return cleaned_s == cleaned_s[::-1]\n```",
|
| 16 |
+
"code_extracted": "def is_palindrome(s):\n # Remove non-alphanumeric characters and convert to lowercase\n cleaned_s = ''.join(char.lower() for char in s if char.isalnum())\n \n # Check if the cleaned string is the same as its reverse\n return cleaned_s == cleaned_s[::-1]"
|
| 17 |
+
}
|