kofdai commited on
Commit
57840be
·
verified ·
1 Parent(s): 9541538

Upload expand_knowledge.py

Browse files
Files changed (1) hide show
  1. expand_knowledge.py +43 -0
expand_knowledge.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ======================================================================
2
+ # AXIS: Knowledge Expansion Tool (V1.2)
3
+ # This script converts raw text into AXIS-compatible Semantic Lattices.
4
+ # ======================================================================
5
+
6
+ import json
7
+ import torch
8
+ from transformers import AutoTokenizer, AutoModelForCausalLM
9
+
10
+ MODEL_ID = "kofdai/AXIS-Sovereign-Logic-Engine"
11
+
12
+ def extract_to_lattice(text):
13
+ print(f"🧐 [AXIS] 知識抽出中: {text[:30]}...")
14
+
15
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
16
+ model = AutoModelForCausalLM.from_pretrained(MODEL_ID, torch_dtype=torch.bfloat16, device_map="auto")
17
+
18
+ prompt = f"以下のテキストをAXIS立体十字形式(JSON)に変換せよ。論理矛盾があればconflictsに記載せよ。\n入力: {text}\nFormat: {{'nodes':[], 'edges':[], 'conflicts':[]}}"
19
+
20
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
21
+ with torch.no_grad():
22
+ outputs = model.generate(**inputs, max_new_tokens=512)
23
+
24
+ result = tokenizer.decode(outputs[0], skip_special_tokens=True)
25
+ return result
26
+
27
+ if __name__ == "__main__":
28
+ # 拡張したい知識の例
29
+ raw_knowledge = [
30
+ "意味は計算の結果ではなく、計算が走るための初期構造である。",
31
+ "AXISの物理パージは、知能の純粋性を保つための儀式である。"
32
+ ]
33
+
34
+ knowledge_base = []
35
+ for k in raw_knowledge:
36
+ lattice_piece = extract_to_lattice(k)
37
+ knowledge_base.append(lattice_piece)
38
+
39
+ # local_massive_data.json として保存
40
+ with open("local_massive_data.json", "w", encoding="utf-8") as f:
41
+ json.dump(knowledge_base, f, ensure_ascii=False, indent=4)
42
+
43
+ print("✅ [SUCCESS] 知識拡張完了。local_massive_data.json を生成しました。")