6 days ago

ollama run enghamzasalem77/pyxon-txt2kg

Models

View all →

Readme

pyxon-txt2kg

First Pyxon / Ollama-published specialist for document → Mermaid knowledge graphs
Built by PYXON.AI · published under enghamzasalem77

Turn Arabic (and multilingual) legal / administrative text into a compact graph TD Mermaid knowledge graph — on-device, offline, via Ollama.

Pull ollama run enghamzasalem77/pyxon-txt2kg
Hub ollama.com/enghamzasalem77/pyxon-txt2kg
Base Qwen2.5-Coder-1.5B-Instruct
Method LoRA SFT · teacher = Gemini Mermaid/KG pairs · GGUF q8_0
Size ~1.6 GB (q8_0)
Output Mermaid graph TD only

Why this model

Most small instruct models answer in prose. pyxon-txt2kg is fine-tuned to emit structured knowledge graphs as Mermaid, optimized for:

  • Arabic Diwan al-Mazalim / administrative court decisions
  • Parties, courts, case IDs, laws, claims, and relations
  • Edge / offline use next to OCR + RAG stacks (Pyxon RAG)

It sits alongside other Pyxon edge models on the same account: pyxon-sllm-v0, pyxon-minilm-ar.


Quick start

ollama pull enghamzasalem77/pyxon-txt2kg
ollama run enghamzasalem77/pyxon-txt2kg

Example prompt:

Extract a SMALL knowledge graph as Mermaid only.
First line must be: graph TD
Max 12 nodes, include --> edges, close subgraphs with end.
No JSON, no markdown fences.

### DOCUMENT
رقم القضية ٣٣٤٤/١٠/ق لعام ١٤٣٧ هـ
المدعية: مؤسسة …
المدعى عليها: وزارة التجارة …
المحكمة الإدارية حكمت بعدم الاختصاص الولائي.

Expected shape:

graph TD
  subgraph أطراف
    P1("المدعية")
    P2("وزارة التجارة")
  end
  Court("المحكمة الإدارية") -->|عدم اختصاص| Case("٣٣٤٤/١٠/ق")
  P1 --> Case
  P2 --> Case

HTTP API

curl http://localhost:11434/api/chat -d '{
  "model": "enghamzasalem77/pyxon-txt2kg",
  "stream": false,
  "messages": [
    {"role": "user", "content": "### DOCUMENT\n...arabic text...\n\nOutput Mermaid graph TD only."}
  ],
  "options": {"temperature": 0.2, "num_ctx": 4096, "num_predict": 384}
}'

Training recipe (summary)

  1. OCR scanned Arabic court volumes (vision / HF backends).
  2. Teacher: Gemini produces gold Mermaid + entity/relation JSON per case.
  3. Dataset: txt_to_kg.jsonl (25 Diwan cases; 22 train / 3 holdout).
  4. SFT: LoRA on Qwen2.5-Coder-1.5B-Instruct (r=16, α=32, 5 epochs, seq 4096).
  5. Merge adapters → HF merged weights.
  6. Export llama.cpp q8_0 GGUF → Ollama Modelfile (ChatML).

See the companion technical report in pyxon-txt-kg/paper/ (LaTeX).


Limits (v0.1)

  • Small teacher-distilled set (~25 cases) — expect gaps on unseen domains.
  • Prefer short documents / truncated context (num_ctx 4096).
  • May loop labels on long texts; keep num_predict ≤ 384 and post-validate Mermaid.
  • Not a substitute for lawyer review; KG is an assistive structure only.

License

Apache-2.0 for Pyxon packaging & adapters. Base Qwen weights remain under their upstream license.

Contact: hamzas@pyxon.ai · www.pyxon.ai