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
| #!/usr/bin/env python3 | |
| """Build a prompt->answer retrieval table from training data + frozen base model. | |
| For each unique training prompt, embed it with the frozen base model | |
| (mean-pooled final hidden, L2-normalized) and store the corresponding | |
| chosen answer. Used by eval_cehri_retrieval.py for exact recall of | |
| training-memorized answers (the episodic-memory pillar, done properly). | |
| Usage: | |
| python3 build_retrieval.py [--data prajna/data/error_correction_pairs.json] | |
| """ | |
| import os, sys, json, argparse, time | |
| os.environ.setdefault("TRANSFORMERS_NO_ADVISORY_WARNINGS", "1") | |
| sys.path.insert(0, os.path.dirname(__file__)) | |
| import torch | |
| from crn_components import PrajnaStudentMultiLayer | |
| def main(): | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--data", default="prajna/data/error_correction_pairs.json") | |
| ap.add_argument("--out", default="prajna/data/retrieval_table.npz") | |
| ap.add_argument("--batch", type=int, default=32) | |
| ap.add_argument("--device", default="mps") | |
| args = ap.parse_args() | |
| pairs = json.load(open(args.data)) | |
| print(f"pairs: {len(pairs)}") | |
| # Dedup by prompt text (exam questions appear 100x with identical answers) | |
| uniq = {} | |
| for p in pairs: | |
| if p["prompt"] not in uniq: | |
| uniq[p["prompt"]] = p["chosen"] | |
| prompts = list(uniq.keys()) | |
| answers = [uniq[k] for k in prompts] | |
| print(f"unique prompts: {len(prompts)}") | |
| t0 = time.time() | |
| student = PrajnaStudentMultiLayer(device=args.device, inject_every=4, max_length=96, crn_mix_init=2.0) | |
| student = student.to(args.device) | |
| student.eval() | |
| tok = student.tok | |
| print(f"model ready in {time.time()-t0:.0f}s") | |
| embs = [] | |
| with torch.no_grad(): | |
| for i in range(0, len(prompts), args.batch): | |
| chunk = prompts[i:i + args.batch] | |
| enc = tok(chunk, truncation=True, max_length=64, padding=True, return_tensors="pt") | |
| ids = enc["input_ids"].to(args.device) | |
| mask = enc["attention_mask"].to(args.device) | |
| out = student.base_model(input_ids=ids, attention_mask=mask, | |
| output_hidden_states=True, return_dict=True) | |
| h = out.hidden_states[-1].float() # (B,T,D) | |
| pooled = (h * mask.unsqueeze(-1)).sum(1) / mask.sum(1, keepdim=True).clamp(min=1) | |
| pooled = torch.nn.functional.normalize(pooled, dim=-1) # (B,D) | |
| embs.append(pooled.cpu().half()) # fp16 to halve size | |
| if (i // args.batch) % 25 == 0: | |
| print(f" embedded {min(i+args.batch, len(prompts))}/{len(prompts)} ({time.time()-t0:.0f}s)", flush=True) | |
| emb = torch.cat(embs, dim=0) # (N,D) fp16 | |
| print(f"embeddings: {emb.shape} dtype={emb.dtype}") | |
| meta = {"answers": answers, "prompts": prompts} | |
| torch.save({"emb": emb, "meta": meta}, args.out) | |
| print(f"saved -> {args.out} ({os.path.getsize(args.out)/1e6:.1f} MB)") | |
| if __name__ == "__main__": | |
| main() | |