Run this model with HF Jobs

Run xiain/SwiftCypher-4B-LoRA on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/xiain/SwiftCypher-4B-LoRA. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/xiain/SwiftCypher-4B-LoRA on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/xiain/SwiftCypher-4B-LoRA. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.

Quantize for lower memory use

Use HF Jobs to create a 4-bit version of https://huggingface.co/xiain/SwiftCypher-4B-LoRA. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.

⚡ SwiftCypher-4B (PEFT LoRA Adapter)

#1 Ranked Lightweight Bilingual Text-to-Cypher & GraphRAG Adapter (bf16, r=32) for Qwen/Qwen3-4B-Instruct-2507

GitHub Repo GGUF Weights LoRA Adapter Base Model

This repository contains the official bf16 PEFT LoRA adapter (r=32, lora_alpha=64) for SwiftCypher-4B, trained on Qwen/Qwen3-4B-Instruct-2507 for vLLM multi-LoRA serving, Transformers inference, and secondary domain fine-tuning. Ready-to-run quantized GGUF weights (Q8_0 and Q4_K_M) are available at xiain/SwiftCypher-4B-GGUF.

🇨🇳 点击展开简体中文完整说明与六冠王排行榜 (Simplified Chinese Overview & Rankings)

为什么选择 SwiftCypher-4B?

SwiftCypher-4B 基于纯指令无思考废话的 Qwen/Qwen3-4B-Instruct-2507 微调,专为 Neo4j、Memgraph、FalkorDB、Kùzu 与 GraphRAG 知识图谱问答打造。采用 “70% 中英多格式生成 + 20% 报错 1-Shot 自修复 + 10% 缺字段防幻觉拒答” 三合一训练配方,配合 <2ms openCypher AST 语法树 + (起点)-[:关系]->(终点) 方向白名单护栏,彻底解决传统小模型“关系箭头写反”和“遇到不存在属性强行瞎编”两大顽疾。

核心评测维度(3B~4B 轻量级赛道) 同级排名 SwiftCypher-4B Neo4j 官方 4B (2025.04) 原始基座 Qwen3-4B 相比官方专用模型提升
真实图库执行准确率 (EX, 中英综合) 🥇 #1 70.83% 70.42% 51.67% **+0.41%**(较基座 +19.16%)
中文 GraphRAG 真实图库执行率 (ZH EX) 🥇 #1 79.17% 76.67% 56.67% **+2.50%**(较基座 +22.50%)
不对称关系箭头方向陷阱执行率 🥇 #1 60.00% 50.00% 38.33% **+10.00%**(较基座 +21.67%)
缺字段防幻觉拒答 (Refusal F1) 🥇 #1 (专用模型) 88.00% 0.00% (零拒答全瞎编) 88.89% +88.00%
Neo4j 2025v1 官方集方向+白名单合规率 🥇 #1 95.40% 94.80% 65.40% **+0.60%**(较基座 +30.00%)
严格 JSON 契约合规率与长尾延迟 (p95) 🥇 #1 99.33% (2105ms) 0.00% (4081ms) 100.00% (3135ms) 长尾延迟降低 48.4%

一行命令本地开跑 (Ollama)

ollama run hf.co/xiain/SwiftCypher-4B-GGUF:Q8_0
ollama run hf.co/xiain/SwiftCypher-4B-GGUF:Q4_K_M

完整 FastAPI 生产护栏网关、<2ms 零模型 --check 校验工具及中文文档详见 GitHub:**https://github.com/2422725977/swift-cypher**。


🏆 #1 Category Rankings in the 3B–4B Lightweight Class

Evaluation Dimension (3B–4B Class) Rank SwiftCypher-4B Neo4j Official 4B (2025.04) Base Qwen3-4B-2507 Gain vs. Neo4j Official
Live Graph Execution (EX, EN+ZH) 🥇 #1 70.83% 70.42% 51.67% +0.41% (+19.16% vs Base)
Chinese GraphRAG Execution (ZH EX) 🥇 #1 79.17% 76.67% 56.67% +2.50% (+22.50% vs Base)
Asymmetric Direction-Trap EX 🥇 #1 60.00% 50.00% 38.33% +10.00% (+21.67% vs Base)
Missing-Schema Anti-Hallucination (F1) 🥇 #1 (Specialist) 88.00% 0.00% (0% refusal) 88.89% +88.00%
Neo4j 2025v1 Schema + Direction Valid 🥇 #1 95.40% 94.80% 65.40% +0.60% (+30.00% vs Base)
Strict JSON Contract & Tail Latency (p95) 🥇 #1 99.33% (2105ms) 0.00% (4081ms) 100.00% (3135ms) -48.4% faster p95

📊 Full Ranked Two-Track Competitor Leaderboard (800 Zero-Leakage Queries)

Fairness Protocol: Raw Cypher specialists (Neo4j-Gemma-3-4B-2025.04 (Official) and Qwen2.5-Coder-3B-Instruct) are evaluated in Track 1 (NativeRaw) using Neo4j's official prompt and markdown fence stripping so they are never penalized for not emitting our JSON schema.

Rank System / Model Track Kuzu Live EX EN EX ZH EX Direction-Trap EX Refusal F1 Neo4j 2025v1 Schema+Dir Structural F1 Strict JSON % p50 (bs=1)
🥇 #1 SwiftCypher-4B (+Guardrail+1Shot) Track 2 (JSON) 70.83% 62.50% 79.17% 60.00% 88.00% 95.40% 90.64% 99.33% 1768 ms
🥈 #2 SwiftCypher-4B (Standalone) Track 2 (JSON) 70.83% 62.50% 79.17% 60.00% 87.10% 95.40% 91.59% 99.33% 1768 ms
🥉 #3 Neo4j-Gemma-3-4B-2025.04 (Official) Track 1 (NativeRaw) 70.42% 64.17% 76.67% 50.00% 0.00% 94.80% 92.55% 0.00% (T2) 2249 ms
#4 Qwen2.5-Coder-3B-Instruct Track 1 (NativeRaw) 51.67% 54.17% 49.17% 41.67% 78.79% 55.60% 79.60% 100.00% (T2) 913 ms
#5 Qwen3-4B-Instruct-2507 (Base) Track 1 (NativeRaw) 51.67% 46.67% 56.67% 38.33% 88.89% 65.40% 81.14% 100.00% (T2) 1695 ms
🔬 Post-Training Pareto Ablation (SFT vs. RPO-DPO vs. WARP) & Reproducible Audit Files
Variant Kuzu Live EX Direction-Trap EX Refusal F1 False Refusal Rate Neo4j 2025v1 Schema+Dir Structural F1 p50 Latency Composite Pareto Score
SFT (Selected) 70.83% 60.00% 87.10% 4.17% 95.40% 91.59% 1768 ms 0.7690
DPO 33.75% 35.00% 51.08% 46.67% 83.40% 77.94% 1909 ms 0.2722
WARP 65.42% 50.00% 81.08% 11.67% 91.80% 87.78% 2751 ms 0.6713

Hosted Reproducible Ranking & Evaluation Artifacts (In This Repo)

🚀 Quickstart (Transformers + PEFT & vLLM Serving)

import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer

base_id = "Qwen/Qwen3-4B-Instruct-2507"
lora_id = "xiain/SwiftCypher-4B-LoRA"

tok = AutoTokenizer.from_pretrained(base_id)
base = AutoModelForCausalLM.from_pretrained(base_id, torch_dtype=torch.bfloat16, device_map="auto")
model = PeftModel.from_pretrained(base, lora_id).eval()

system_prompt = (
    "You are SwiftCypher, a read-only openCypher generator for Neo4j, Memgraph, FalkorDB, and Kuzu.\n"
    "Output ONLY one JSON object matching:\n"
    '{"plan": string, "answerable": boolean, "cypher": string, "labels": string[], '
    '"rel_types": string[], "missing_info": string[]}\n'
    "Rules:\n"
    "1. Use ONLY labels, relationship types, relationship directions (-> / <-), and properties present in the Schema.\n"
    '2. Keep "plan" empty ("") for 1-2 hop queries; use <=60 chars only for 3+ hops or error repair.\n'
    '3. Emit read-only Cypher only (MATCH, OPTIONAL MATCH, WHERE, WITH, UNWIND, RETURN, ORDER BY, SKIP, LIMIT, UNION). Never emit write/admin clauses.\n'
    '4. If required labels, relationships, properties, or target entities are missing from the Schema, set "answerable": false, "cypher": "", and list missing items in "missing_info".'
)
msgs = [
    {"role": "system", "content": system_prompt},
    {"role": "user", "content": "Schema:\n(:Person {name: STRING})-[:ACTED_IN]->(:Movie {title: STRING})\n\nQuestion:\n查询参演过 The Matrix 的演员姓名。"},
]
prompt = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True)
inputs = tok(prompt, return_tensors="pt").to(model.device)
out_ids = model.generate(**inputs, max_new_tokens=192, do_sample=False)
print(tok.decode(out_ids[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
# Serve directly with vLLM dynamic LoRA adapter loading
vllm serve Qwen/Qwen3-4B-Instruct-2507 \
  --enable-lora \
  --lora-modules swiftcypher=xiain/SwiftCypher-4B-LoRA \
  --max-lora-rank 64

Full <2ms AST/Direction Guardrail, FastAPI gateway, and benchmark suite: https://github.com/2422725977/swift-cypher.

Downloads last month
28
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for xiain/SwiftCypher-4B-LoRA

Adapter
(5,910)
this model

Datasets used to train xiain/SwiftCypher-4B-LoRA

Space using xiain/SwiftCypher-4B-LoRA 1

Collection including xiain/SwiftCypher-4B-LoRA

Evaluation results