Files
AXIS-Sovereign-Logic-Engine/expand_knowledge.py
ModelHub XC 3b917f3b8b 初始化项目,由ModelHub XC社区提供模型
Model: kofdai/AXIS-Sovereign-Logic-Engine
Source: Original Platform
2026-04-21 20:34:02 +08:00

43 lines
1.8 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ======================================================================
# AXIS: Knowledge Expansion Tool (V1.2)
# This script converts raw text into AXIS-compatible Semantic Lattices.
# ======================================================================
import json
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
MODEL_ID = "kofdai/AXIS-Sovereign-Logic-Engine"
def extract_to_lattice(text):
print(f"🧐 [AXIS] 知識抽出中: {text[:30]}...")
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForCausalLM.from_pretrained(MODEL_ID, torch_dtype=torch.bfloat16, device_map="auto")
prompt = f"以下のテキストをAXIS立体十字形式JSONに変換せよ。論理矛盾があればconflictsに記載せよ。\n入力: {text}\nFormat: {{'nodes':[], 'edges':[], 'conflicts':[]}}"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(**inputs, max_new_tokens=512)
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
return result
if __name__ == "__main__":
# 拡張したい知識の例
raw_knowledge = [
"意味は計算の結果ではなく、計算が走るための初期構造である。",
"AXISの物理パージは、知能の純粋性を保つための儀式である。"
]
knowledge_base = []
for k in raw_knowledge:
lattice_piece = extract_to_lattice(k)
knowledge_base.append(lattice_piece)
# local_massive_data.json として保存
with open("local_massive_data.json", "w", encoding="utf-8") as f:
json.dump(knowledge_base, f, ensure_ascii=False, indent=4)
print("✅ [SUCCESS] 知識拡張完了。local_massive_data.json を生成しました。")