MetaCortex-Dynamics commited on
Commit
5df8b73
Β·
verified Β·
1 Parent(s): 37cfe0e

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -1,5 +1,5 @@
1
  """
2
- Axiom-Ref β€” HuggingFace Space / Gradio App
3
 
4
  Two modes:
5
  1. GENERATE β€” produce governed output with proof
@@ -38,9 +38,9 @@ from pipeline.stages.s4_validate import validate_and_score, TigStatus
38
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
39
 
40
  mdlm = StructureModel(vocab_size=VOCAB_SIZE, d_model=128, nhead=4, num_layers=4, max_len=40).to(device)
41
- mdlm.load_state_dict(torch.load("models/axiom-ref/mdlm_best.pt", weights_only=True, map_location=device))
42
 
43
- tokenizer = Tokenizer.from_file("models/axiom-ref/bpe_tokenizer.json")
44
  bpe_vocab = tokenizer.get_vocab_size()
45
  BPE_BOS = tokenizer.token_to_id("<bos>")
46
  BPE_EOS = tokenizer.token_to_id("<eos>")
@@ -49,7 +49,7 @@ decoder = ConstrainedDecoder(
49
  gov_vocab=VOCAB_SIZE, prose_vocab=bpe_vocab, d_model=256, nhead=8,
50
  num_encoder_layers=3, num_decoder_layers=6, max_struct_len=40, max_prose_len=128,
51
  ).to(device)
52
- _ds = torch.load("models/axiom-ref/decoder_best.pt", weights_only=True, map_location=device)
53
  _ds = {k.replace("triad_embedding", "struct_embedding").replace("triad_pos", "struct_pos"): v for k, v in _ds.items()}
54
  decoder.load_state_dict(_ds)
55
  decoder.eval()
@@ -246,12 +246,12 @@ def verify_governance(output_text, trace_json_str):
246
  # ═══════════════════════════════════════════════════════════════════════════════
247
 
248
  with gr.Blocks(
249
- title="Axiom-Ref: Governed Language Model",
250
  theme=gr.themes.Base(primary_hue="green", neutral_hue="slate"),
251
  ) as app:
252
 
253
  gr.Markdown("""
254
- # Axiom-Ref
255
  **Every output ships its own proof of governance.**
256
  """)
257
 
@@ -305,7 +305,7 @@ with gr.Blocks(
305
 
306
  gr.Markdown("""
307
  ---
308
- *[MetaCortex Dynamics DAO](https://github.com/MetaCortex-Dynamics) Β· [Source](https://github.com/MetaCortex-Dynamics/Axiom-Ref) Β· MIT License*
309
  """)
310
 
311
  if __name__ == "__main__":
 
1
  """
2
+ Axiom β€” HuggingFace Space / Gradio App
3
 
4
  Two modes:
5
  1. GENERATE β€” produce governed output with proof
 
38
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
39
 
40
  mdlm = StructureModel(vocab_size=VOCAB_SIZE, d_model=128, nhead=4, num_layers=4, max_len=40).to(device)
41
+ mdlm.load_state_dict(torch.load("models/axiom/mdlm_best.pt", weights_only=True, map_location=device))
42
 
43
+ tokenizer = Tokenizer.from_file("models/axiom/bpe_tokenizer.json")
44
  bpe_vocab = tokenizer.get_vocab_size()
45
  BPE_BOS = tokenizer.token_to_id("<bos>")
46
  BPE_EOS = tokenizer.token_to_id("<eos>")
 
49
  gov_vocab=VOCAB_SIZE, prose_vocab=bpe_vocab, d_model=256, nhead=8,
50
  num_encoder_layers=3, num_decoder_layers=6, max_struct_len=40, max_prose_len=128,
51
  ).to(device)
52
+ _ds = torch.load("models/axiom/decoder_best.pt", weights_only=True, map_location=device)
53
  _ds = {k.replace("triad_embedding", "struct_embedding").replace("triad_pos", "struct_pos"): v for k, v in _ds.items()}
54
  decoder.load_state_dict(_ds)
55
  decoder.eval()
 
246
  # ═══════════════════════════════════════════════════════════════════════════════
247
 
248
  with gr.Blocks(
249
+ title="Axiom: Governed Language Model",
250
  theme=gr.themes.Base(primary_hue="green", neutral_hue="slate"),
251
  ) as app:
252
 
253
  gr.Markdown("""
254
+ # Axiom
255
  **Every output ships its own proof of governance.**
256
  """)
257
 
 
305
 
306
  gr.Markdown("""
307
  ---
308
+ *[MetaCortex Dynamics DAO](https://github.com/MetaCortex-Dynamics) Β· [Source](https://github.com/MetaCortex-Dynamics/Axiom) Β· MIT License*
309
  """)
310
 
311
  if __name__ == "__main__":