Text Generation
Transformers
PyTorch
prajna-crn
prajna-v2
cehri
licensing-exam
exam-passing
cognitive-resonance-network
crn
memory-augmented-generation
retrieval-augmented
small-language-model
adapter
efficient-ai
edge-ai
on-device-ai
fine-tuning
gemma
question-answering
facts
arithmetic
implicit-goal-reasoning
Eval Results (legacy)
Instructions to use eulogik/Prajna-V2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use eulogik/Prajna-V2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="eulogik/Prajna-V2")# Load model directly from transformers import PrajnaStudentMultiLayer model = PrajnaStudentMultiLayer.from_pretrained("eulogik/Prajna-V2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use eulogik/Prajna-V2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "eulogik/Prajna-V2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "eulogik/Prajna-V2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/eulogik/Prajna-V2
- SGLang
How to use eulogik/Prajna-V2 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 "eulogik/Prajna-V2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "eulogik/Prajna-V2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "eulogik/Prajna-V2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "eulogik/Prajna-V2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use eulogik/Prajna-V2 with Docker Model Runner:
docker model run hf.co/eulogik/Prajna-V2
File size: 2,034 Bytes
5574408 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | #!/usr/bin/env python3
"""CEHRI exam eval for the v2 CRN checkpoint (dpo_v2_final.pt)."""
import os, sys, json, torch
os.environ.setdefault("TRANSFORMERS_NO_ADVISORY_WARNINGS", "1")
sys.path.insert(0, os.path.join(os.path.dirname(__file__)))
from crn_components import PrajnaStudentMultiLayer
CKPT = os.environ.get("CEHRI_CKPT", "prajna/checkpoints/dpo_v2_final.pt")
MEM = os.environ.get("CEHRI_MEM", "prajna/checkpoints/memory_v2_final.json")
EXAM = os.environ.get("CEHRI_EXAM", "prajna/data/cehri_exam.json")
DEV = "mps"
student = PrajnaStudentMultiLayer(device=DEV, inject_every=4, max_length=96, crn_mix_init=2.0)
student = student.to(DEV)
sd = torch.load(CKPT, map_location=DEV, weights_only=False)
student.load_state_dict(sd["crn"], strict=False)
if os.path.exists(MEM):
student.load_memory(MEM)
student.eval()
tok = student.tok
print("reflection_gate:", [f"{x:.3f}" for x in torch.sigmoid(student.reflection_gate).tolist()], flush=True)
@torch.no_grad()
def gen_crn(prompt, max_new=30):
input_text = prompt + ": "
ids = tok(input_text, return_tensors="pt").input_ids.to(DEV)
g = ids.clone()
gen_tokens = []
for _ in range(max_new):
o = student._collect_hidden(g)
lg, _ = student._apply_crn(o, training=False)
logits = lg[:, -1, :]
for t in gen_tokens:
logits[0, t] /= 1.15
nt = logits.argmax(-1).reshape(1, 1)
gen_tokens.append(nt.item())
g = torch.cat([g, nt], dim=1)
if nt.item() == tok.eos_token_id:
break
out = tok.decode(g[0], skip_special_tokens=True)
return out[len(input_text):].strip()
exam = json.load(open(EXAM))
passed = 0
for q in exam:
out = gen_crn(q["prompt"], max_new=30)
ok = q["answer"].strip().lower() in out.strip().lower()
passed += ok
print(f" {q['id']}: {'PASS' if ok else 'FAIL'} {out[:60]!r}", flush=True)
frac = passed / len(exam)
print(f"\nCEHRI RESULT: {passed}/{len(exam)} = {frac*100:.1f}% -> {'PASS' if frac >= 0.9 else 'FAIL (<0.9)'}", flush=True)
|