Views
No views yet
lamm-mit/Graph-Preflexor-8b_12292025) was trained in two sequential stages to produce graph-native scientific reasoning with structured intermediate representations.git clone https://github.com/lamm-mit/graph-preflexor-grpo.git
cd graph-preflexor-grpo1python ./src/run_orpo_graph.py
2--base_model Qwen/Qwen3-8B
3--dataset lamm-mit/graph_reasoning_1K
4--output_dir ./orpo-graph_v40
5--epochs 1 --lr 5e-5 --batch_size 2
6--save_steps 100 --max_length 2048
7--eval_steps 100
8--push_to_hub
9--hub_model_id lamm-mit/orpo-graph
10--hf_token $HF_TOKENpython ./src/test_model.py --model ./orpo-graph1python ./src/run_grpo_graph.py
2--base_model_dir lamm-mit/orpo-graph
3--dataset lamm-mit/graph_reasoning_1K
4--output_dir ./lamm-mit/Graph-Preflexor-8b_12292025
5--judge_model grok-4-1-fast-non-reasoning
6--judge_api_key $GROK_API_KEY
7--judge_base_url https://api.x.ai/v1
8--weight_correctness 0.30
9--weight_format 0.15
10--weight_graph_utility 0.25
11--weight_graph_networkx 0.10
12--weight_graph_diversity 0.10
13--weight_graph_structure 0.10
14--num_generations 8 --per_device_train_batch_size 1 --gradient_accumulation_steps 8
15--learning_rate 5e-6 --epochs 3
16--max_completion_length 3500
17--push_to_hub
18--hub_model_id lamm-mit/lamm-mit/Graph-Preflexor-8b_12292025
19--hf_token $HF_TOKEN --use_vllm --vllm_gpu_memory_utilization 0.41User Prompt
2 |
3 v
4<think> (internal reasoning container; not meant as final answer)
5 |
6 +--> <brainstorm>
7 | Purpose: generate hypotheses, mechanisms, candidate factors,
8 | and possible causal stories (broad search; divergent).
9 |
10 +--> <graph>
11 | Purpose: sketch the conceptual graph verbally (entities + relations).
12 | Think of it as the draft blueprint.
13 |
14 +--> <graph_json>
15 | Purpose: emit a machine-readable knowledge graph:
16 | nodes = concepts; edges = relations (source, relation, target).
17 | This is the canonical structured representation.
18 |
19 +--> <patterns>
20 | Purpose: compress the graph into reusable motifs:
21 | invariants, abstractions, multi-scale regularities,
22 | analogies, and “design rules”.
23 |
24 +--> <synthesis>
25 | Purpose: assemble the final narrative by reading from the graph:
26 | coherent, ordered explanation and (optionally) next steps.
27 |
28</think>
29 |
30 v
31Final Answer (post-</think>, user-facing)
32 - concise, coherent prose derived from the graph + synthesis
33 - should remain consistent with the <graph_json> content1<think> ... </think>
2 - Container for all internal work.
3 - May include intermediate calculations, choices, and planning.
4
5<brainstorm> ... </brainstorm>
6 - Rapid hypothesis generation.
7 - Lists candidate mechanisms, variables, constraints, tradeoffs.
8 - “Wide exploration” mode.
9
10<graph> ... </graph>
11 - Human-readable graph sketch.
12 - Names the concepts and how they connect (often as bullet edges).
13
14<graph_json> ... </graph_json>
15 - Machine-readable knowledge graph:
16 {
17 "nodes": [{"id": "ConceptA"}, ...],
18 "edges": [{"source": "A", "relation": "causes", "target": "B"}, ...]
19 }
20 - Intended to be parseable and reusable for downstream tooling.
21
22<patterns> ... </patterns>
23 - Extracts higher-level structure:
24 - causal motifs (feedforward/feedback loops)
25 - modularity / hierarchy (micro→meso→macro)
26 - bottlenecks, bridges, invariants
27 - “principles” that generalize beyond the single example
28
29<synthesis> ... </synthesis>
30 - Turns structure into explanation:
31 - ordered narrative aligned with the graph
32 - explicit causal chain(s)
33 - checks for coherence / missing links
34 - may propose experiments, predictions, or design implications<graph_json> enables programmatic extraction, visua_
Qwen/Qwen3-8B.<think>, <graph>, <graph_json>, <patterns>, <synthesis>)lamm-mit/graph_reasoning_v3num_generations = 8). These were scored using an external LLM judge (grok-4-1-fast-non-reasoning) via a multi-component reward function.1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
3
4token= 'hf_...'
5
6# ------------------------------------------------------------------------------
7# Configuration
8# ------------------------------------------------------------------------------
9MODEL_NAME = "lamm-mit/Graph-Preflexor-8b_12292025"
10PROMPT = "Give me a short introduction to materiomics."
11MAX_NEW_TOKENS = 32_768
12THINK_END_TOKEN_ID = 151668 # </think>
13
14# ------------------------------------------------------------------------------
15# Model & Tokenizer Loading
16# ------------------------------------------------------------------------------
17tokenizer = AutoTokenizer.from_pretrained(
18 MODEL_NAME,
19 token=token,
20)
21model = AutoModelForCausalLM.from_pretrained(
22 MODEL_NAME,
23 torch_dtype="auto",
24 device_map="auto",
25 token=token,
26)
27model.eval()
28
29# ------------------------------------------------------------------------------
30# Prompt Construction
31# ------------------------------------------------------------------------------
32messages = [
33 {"role": "user", "content": PROMPT}
34]
35
36prompt_text = tokenizer.apply_chat_template(
37 messages,
38 tokenize=False,
39 add_generation_prompt=True,
40 enable_thinking=True, # toggles chain-of-thought mode
41)
42
43model_inputs = tokenizer(
44 prompt_text,
45 return_tensors="pt",
46).to(model.device)
47
48# ------------------------------------------------------------------------------
49# Generation
50# ------------------------------------------------------------------------------
51gen_config = GenerationConfig(
52 max_new_tokens=MAX_NEW_TOKENS,
53 do_sample=True, # sample
54 temperature=0.2,
55)
56
57with torch.no_grad():
58 generated = model.generate(
59 **model_inputs,
60 generation_config=gen_config,
61 )
62
63# Slice off the prompt tokens
64output_ids = generated[0, model_inputs.input_ids.shape[1]:].tolist()
65
66# ------------------------------------------------------------------------------
67# Thinking / Content Parsing
68# ------------------------------------------------------------------------------
69def split_thinking(output_ids, tokenizer, think_end_id):
70 """
71 Split generated tokens into (thinking, final_content) based on </think>.
72 Falls back gracefully if no thinking block is present.
73 """
74 try:
75 split_idx = len(output_ids) - output_ids[::-1].index(think_end_id)
76 except ValueError:
77 split_idx = 0
78
79 thinking = tokenizer.decode(
80 output_ids[:split_idx],
81 skip_special_tokens=True,
82 ).strip()
83
84 content = tokenizer.decode(
85 output_ids[split_idx:],
86 skip_special_tokens=True,
87 ).strip()
88
89 return thinking, content
90
91
92thinking, content = split_thinking(
93 output_ids,
94 tokenizer,
95 THINK_END_TOKEN_ID,
96)
97
98# ------------------------------------------------------------------------------
99# Output
100# ------------------------------------------------------------------------------
101print("\n" + "=" * 80)
102print("THINKING")
103print("=" * 80)
104print(thinking or "[**no thinking content detected**]")
105
106print("\n" + "=" * 80)
107print("FINAL OUTPUT")
108print("=" * 80)
109print(content)1================================================================================
2THINKING
3================================================================================
4<think>
5<brainstorm>
6Materiomics is an emerging interdisciplinary field that bridges materials science with omics approaches like genomics, proteomics, and metabolomics. Key concepts: it uses high-throughput, data-driven methods to analyze materials at atomic/molecular scales, enabling predictive design and discovery. Relevant phenomena include self-assembly, phase transitions, defect engineering, and property-structure relationships. Hypotheses: materiomics can accelerate material innovation by mimicking biological systems' efficiency (e.g., protein folding). Interactions: data from omics informs computational models (e.g., machine learning for property prediction), while materials synthesis validates these models. Broader context: part of materials informatics, relevant to nanotechnology, sustainable materials, and AI-driven R&D. Key variables: material composition, processing conditions, scale (nano/micro), omics data quality, computational power.
7</brainstorm>
8
9<graph>
10Core entities: Materiomics, Materials Science, Omics (Genomics/Proteomics/Metabolomics), High-Throughput Analysis, Predictive Modeling, Material Properties, Self-Assembly, Phase Transitions, Defect Engineering, Computational Models, Data-Driven Design, Biological Inspiration.
11Relationships: Materiomics integrates Materials Science with Omics → enables High-Throughput Analysis → feeds Predictive Modeling → predicts Material Properties. Self-Assembly, Phase Transitions, Defect Engineering → influence Material Properties. Computational Models → refine Predictive Modeling. Biological Inspiration → guides Data-Driven Design in Materiomics. High-Throughput Analysis → validates Computational Models.
12</graph>
13
14<graph_json>
15{
16 "nodes": [
17 {"id": "Materiomics"},
18 {"id": "MaterialsScience"},
19 {"id": "Omics"},
20 {"id": "HighThroughput"},
21 {"id": "PredictiveModeling"},
22 {"id": "MaterialProperties"},
23 {"id": "SelfAssembly"},
24 {"id": "PhaseTransitions"},
25 {"id": "DefectEngineering"},
26 {"id": "ComputationalModels"},
27 {"id": "DataDrivenDesign"},
28 {"id": "BiologicalInspiration"}
29 ],
30 "edges": [
31 {"source": "Materiomics", "relation": "integrates", "target": "MaterialsScience"},
32 {"source": "Materiomics", "relation": "integrates", "target": "Omics"},
33 {"source": "Omics", "relation": "enables", "target": "HighThroughput"},
34 {"source": "HighThroughput", "relation": "feeds", "target": "PredictiveModeling"},
35 {"source": "PredictiveModeling", "relation": "predicts", "target": "MaterialProperties"},
36 {"source": "SelfAssembly", "relation": "influences", "target": "MaterialProperties"},
37 {"source": "PhaseTransitions", "relation": "influences", "target": "MaterialProperties"},
38 {"source": "DefectEngineering", "relation": "influences", "target": "MaterialProperties"},
39 {"source": "ComputationalModels", "relation": "refines", "target": "PredictiveModeling"},
40 {"source": "HighThroughput", "relation": "validates", "target": "ComputationalModels"},
41 {"source": "BiologicalInspiration", "relation": "guides", "target": "DataDrivenDesign"},
42 {"source": "DataDrivenDesign", "relation": "applies", "target": "Materiomics"}
43 ]
44}
45</graph_json>
46
47<patterns>
48Materiomics: MaterialsScience + Omics → HighThroughput → PredictiveModeling → MaterialProperties (predictive pipeline).
49BiologicalInspiration → DataDrivenDesign → Materiomics (inspiration loop).
50</patterns>
51
52<synthesis>
53The graph reveals materiomics as a predictive pipeline integrating materials science with omics data, validated by high-throughput analysis and computational models to design materials with desired properties. Key insight: this data-driven approach, inspired by biological systems, accelerates discovery by quantifying structure-property relationships at atomic scales, enabling efficient self-assembly, phase control, and defect engineering. Coherent picture: materiomics transforms materials innovation from trial-and-error to informed, scalable design, leveraging omics for high-dimensional data and AI for modeling.
54</synthesis>
55</think>
56
57================================================================================
58FINAL OUTPUT
59================================================================================
60Materiomics is an interdisciplinary field that merges materials science with omics methodologies—such as genomics, proteomics, and metabolomics—to systematically analyze, design, and predict the properties of materials at atomic and molecular scales. At its core, materiomics leverages high-throughput experimental techniques and advanced computational models to generate vast datasets on material composition, structure, processing conditions, and resulting properties. These data are then used to build predictive models that can forecast material behavior under various stimuli, enabling the rational design of novel materials with tailored functionalities. Key phenomena underpinning materiomics include self-assembly processes where molecules spontaneously form ordered structures, phase transitions that dictate stability and transformation under thermal or mechanical stress, and defect engineering that manipulates imperfections to enhance properties like strength or conductivity. By drawing inspiration from biological systems—where complex materials like proteins and cell membranes emerge from simple building blocks—materiomics adopts data-driven, systems-level approaches to accelerate discovery. This field is pivotal in advancing nanotechnology, sustainable materials, and AI-driven R&D, offering a scalable framework to move beyond traditional trial-and-error methods, thereby revolutionizing industries from electronics to energy storage.
1python graph_reasoning.py \
2 --model lamm-mit/Graph-Preflexor-8b_12292025 \
3 --prompt "Explain dragline silk toughness."1@article{Buehler2025PRefLexOR,
2 author = {Buehler, Markus J.},
3 title = {PRefLexOR: preference-based recursive language modeling for exploratory optimization of reasoning and agentic thinking},
4 journal = {npj Artificial Intelligence},
5 volume = {1},
6 number = {4},
7 year = {2025},
8 publisher = {Springer Nature},
9 doi = {10.1038/s44387-025-00003-z},
10 url = {https://doi.org/10.1038/s44387-025-00003-z},
11 issn = {2731-990X},
12 received = {2024-11-01},
13 accepted = {2025-03-22},
14 published = {2025-05-14},
15 keywords = {Complex networks, Computational biology and bioinformatics}
16}
17
18@article{Buehler2025GraphPRefLexOR,
19 author = {Buehler, Markus J.},
20 title = {In Situ Graph Reasoning and Knowledge Expansion Using Graph-PRefLexOR},
21 journal = {Advanced Intelligent Discovery},
22 year = {2025},
23 publisher = {Wiley},
24 doi = {10.1002/aidi.202500006},
25 url = {https://doi.org/10.1002/aidi.202500006},
26 note = {Research Article, Open Access},
27 published = {2025-06-09}
28}
29
30@misc{pal2026graphnativereinforcementlearningenables,
31 title={Graph-Native Reinforcement Learning Enables Traceable Scientific Hypothesis Generation through Conceptual Recombination},
32 author={Subhadeep Pal and Shashwat Sourav and Tirthankar Ghosal and Markus J. Buehler},
33 year={2026},
34 eprint={2607.00924},
35 archivePrefix={arXiv},
36 primaryClass={cs.AI},
37 url={https://arxiv.org/abs/2607.00924},
38}