Krama is a small, offline coding tutor for Python and FastAPI beginners. For a coding task it answers in three short parts: Plan (numbered steps), Code, and Why (plain-language reasons). For a quick question it gives a short, direct answer. It runs on an ordinary laptop CPU with no internet.
"Krama" is Sanskrit for order or sequence.
Preview. This is an early release for trying out and giving feedback. It is not a general-purpose coding model and it is not production-ready. Always run the code it gives you.
Krama is a fine-tune of Qwen2.5-Coder-1.5B-Instruct by the Qwen team (Apache 2.0). All of its coding ability comes from that model. Krama only changes how it answers.
With Ollama:
ollama run hf.co/CoBeDigger/krama-coder-1.5b
The file is 986 MB (4-bit Q4_K_M). On a laptop CPU (Intel Core Ultra 7 155H) the base model runs at about 33-36 tokens per second, and Krama is the same size.
You can also use it from code through Ollama's local API (http://localhost:11434), or in VS Code through an extension that supports Ollama, such as Continue.
To build it yourself from the downloaded file, use the Modelfile in this repo:
ollama create krama -f Modelfile
These are real answers from the release file, at temperature 0.
"Write a Python function safe_divide(a, b) that returns a divided by b. If b is zero, return None instead of crashing."
Plan:
1. Define the function `safe_divide`.
2. Check if `b` is zero.
3. Return `None` if `b` is zero, otherwise return the division result.
Code:
```python
def safe_divide(a, b):
if b == 0:
return None
return a / b
```
Why:
- The function checks if `b` is zero before performing the division to avoid division by zero errors.
- If `b` is zero, the function returns `None`, which can be handled gracefully in the calling code.
"What is the difference between == and is in Python?"
`==` checks if two values are equal, while `is` checks if both variables point to the same object. For example:
```python
x = [1, 2]
y = [1, 2]
print(x == y) # True because they have the same elements
print(x is y) # False because they are two different lists
```
All three systems below are the same 986 MB Q4_K_M file size, run in Ollama at temperature 0. "Base + instruction" is the base model given a written instruction to answer like Krama.
Correctness. 30 tasks of our own (12 Python, 12 FastAPI, 6 quick questions), where the code is run against tests. The 164-task HumanEval benchmark is the standard check.
| System | Python (12) | FastAPI (12) | Quick answers, average length | HumanEval (164) |
|---|---|---|---|---|
| Base model | 9 | 6 | 273 tokens | 120 (73.2%) |
| Base + instruction | 9 | 5 | 218 tokens | 98 (59.8%) |
| Krama v0.1 | 9 | 6 | 121 tokens | 112 (68.3%) |
Runs on a CPU are not exactly repeatable, even at temperature 0. Krama passed 10 Python tasks in its first run and 9 in each of four reruns, so we report 9. The base model passed 9 Python and 6 FastAPI tasks in all three of its runs. HumanEval was run once per system.
Teaching quality. Each answer was scored blind by a different model (Llama 3.1 8B), which never saw which system wrote it. Scoring rules were written before training. Averages are out of 2 per rule.
| System | Plan | Why | Clarity | Length | Coding total (of 8) | Quick answers (of 4) |
|---|---|---|---|---|---|---|
| Base model | 1.08 | 0.67 | 1.04 | 1.58 | 4.38 | 1.33 |
| Base + instruction | 1.83 | 1.17 | 1.17 | 1.79 | 5.96 | 1.33 |
| Krama v0.1 | 1.92 | 1.17 | 1.21 | 1.96 | 6.25 | 2.00 |
What this means, honestly:
system file in this repo sets it for you.krama command-line tool that runs Krama's code against tests on your own machine before showing it.Feedback is very welcome in the Community tab, especially questions where Krama got it wrong.
Apache 2.0, the same as the base model. Built on Qwen2.5-Coder-1.5B-Instruct by the Qwen team.