48 Downloads Updated 5 days ago
ollama run chigwel/cevra-reasoning-decisions-4b
A 4-billion-parameter decision model that scores the quality of a candidate answer and its reasoning on a scale from 0 to 1 using a reference answer and reasoning.
ollama pull chigwel/cevra-reasoning-decisions-4b:4b-q4_k_m
Render the decision with the two ordered choices 0 and 1, request token log probabilities from the local Ollama API, and normalize the probabilities for candidate letters A and B. The normalized probability of B is the score.
import json
import math
import os
import urllib.request
model = os.getenv("CEVRA_OLLAMA_MODEL", "chigwel/cevra-reasoning-decisions-4b:4b-q4_k_m")
host = os.getenv("OLLAMA_HOST", "http://127.0.0.1:11434").rstrip("/")
if "://" not in host:
host = "http://" + host
state = (
"Question: What is 2 + 2? Reference answer: 4. "
"Reference reasoning: Adding two and two gives four. "
"Candidate answer: 4. Candidate reasoning: Two plus two equals four."
)
instructions = "Rate the correctness of the candidate's answer and reasoning."
criteria = {"0": "Incorrect", "1": "Correct"}
text = json.dumps({"state": state, "instructions": instructions}, ensure_ascii=False, sort_keys=True)
system = (
"Answer the user's question by picking exactly one of the choices they supply. "
"Reply with the id of your choice, written as `choice#?`, and nothing else."
)
choices = "\n".join(
f'choice#{chr(ord("A") + i)} = "{label}": {description}'
for i, (label, description) in enumerate(criteria.items())
)
prompt = (
f"<|im_start|>system\n{system}<|im_end|>\n"
f"<|im_start|>user\n{text}\n\n"
"Choices (your answer must be exactly one of these):\n"
f"{choices}<|im_end|>\n<|im_start|>assistant\n<think>\n\n</think>\n\nchoice#"
)
request = urllib.request.Request(
host + "/api/generate",
data=json.dumps({
"model": model, "prompt": prompt, "raw": True, "stream": False,
"truncate": False, "shift": False, "logprobs": True, "top_logprobs": 20,
"options": {"num_predict": 1, "num_ctx": 2048, "temperature": 0},
}).encode(),
headers={"Content-Type": "application/json"},
)
with urllib.request.urlopen(request, timeout=300) as response:
result = json.load(response)
scores = {item["token"]: float(item["logprob"]) for item in result["logprobs"][0]["top_logprobs"]}
if not {"A", "B"}.issubset(scores):
raise ValueError("Both decision tokens must be present in top_logprobs")
highest = max(scores["A"], scores["B"])
weights = [math.exp(scores[label] - highest) for label in ("A", "B")]
print("score:", weights[1] / sum(weights))
Fine-tuned from Qwen/Qwen3.5-4B (https://huggingface.co/Qwen/Qwen3.5-4B) with Tinker on synthetic multilingual decision examples derived from HLE Diamond. The merged weights were converted to GGUF and quantized to Q4_K_M with llama.cpp.
A local runtime smoke test succeeded.
Ten complete score distributions were compared with the Tinker references; maximum absolute difference: 0.024934.
License supplied for this model: Apache-2.0.
Cevra Reasoning Decisions 4B System Card: How Does Reference-Based Assessment Compare with Jev?