Safetensors
English
qwen2
chain-of-thought
cot-reasoning
step-by-step-reasoning
systematic-analysis
problem-decomposition
structured-output
structured-thinking
reasoning-model
gmsh-scripting
mesh-generation
computational-geometry
finite-element-analysis
engineering-simulation
cad-mesh-automation
geometric-modeling
numerical-methods
engineering-research
computational-engineering
mesh-optimization
geometry-processing
simulation-preprocessing
technical-code-generation
domain-specific-reasoning
engineering-assistant
8b-parameters
dense-decoder-model
open-source-model
GMeshNet-OSS-8B
GMeshNet-OSS
GMeshNet
Update README.md
Browse files
README.md
CHANGED
|
@@ -2,4 +2,224 @@
|
|
| 2 |
license: apache-2.0
|
| 3 |
language:
|
| 4 |
- en
|
| 5 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
license: apache-2.0
|
| 3 |
language:
|
| 4 |
- en
|
| 5 |
+
---
|
| 6 |
+
# GMeshNet-OSS-8B
|
| 7 |
+
|
| 8 |
+
**GMeshNet-OSS-8B** is a dense, decoder-only 8B parameter language model distilled from **DeepSeek V3**, specialized in **reasoning about geometry** and generating **high-quality Gmsh meshing scripts** with step-by-step analysis.
|
| 9 |
+
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
## Quickstart
|
| 14 |
+
|
| 15 |
+
### Install Dependencies
|
| 16 |
+
```
|
| 17 |
+
pip install -U torch transformers accelerate
|
| 18 |
+
```
|
| 19 |
+
|
| 20 |
+
### Run Inference
|
| 21 |
+
|
| 22 |
+
```python
|
| 23 |
+
import torch
|
| 24 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 25 |
+
|
| 26 |
+
# Input your prompt here
|
| 27 |
+
USER_INPUT = """
|
| 28 |
+
Generate a GMSH script to create a 2D rectangular mesh with a circular hole at the center, applying finer mesh refinement near the hole and coarser mesh at the boundaries.
|
| 29 |
+
"""
|
| 30 |
+
|
| 31 |
+
def load_model(model_path):
|
| 32 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 33 |
+
model_path,
|
| 34 |
+
torch_dtype=torch.float16,
|
| 35 |
+
device_map="auto",
|
| 36 |
+
trust_remote_code=True
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 40 |
+
model_path,
|
| 41 |
+
trust_remote_code=True
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
with open(f"{model_path}/chat_template.jinja", "r") as f:
|
| 45 |
+
tokenizer.chat_template = f.read()
|
| 46 |
+
|
| 47 |
+
return model, tokenizer
|
| 48 |
+
|
| 49 |
+
def generate_response(model, tokenizer, user_input):
|
| 50 |
+
|
| 51 |
+
formatted_input = f"<gmsh_instruction>{user_input.strip()}</gmsh_instruction>"
|
| 52 |
+
messages = [{"role": "user", "content": formatted_input}]
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 56 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 57 |
+
|
| 58 |
+
outputs = model.generate(
|
| 59 |
+
**inputs,
|
| 60 |
+
max_new_tokens=2000,
|
| 61 |
+
temperature=0.7,
|
| 62 |
+
do_sample=True,
|
| 63 |
+
pad_token_id=tokenizer.eos_token_id
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=False)
|
| 67 |
+
return response.split("<|im_start|>assistant\n")[-1].replace("<|im_end|>", "").strip()
|
| 68 |
+
|
| 69 |
+
def run_inference():
|
| 70 |
+
model_path = "./" # Path to your model weights
|
| 71 |
+
|
| 72 |
+
model, tokenizer = load_model(model_path)
|
| 73 |
+
result = generate_response(model, tokenizer, USER_INPUT)
|
| 74 |
+
|
| 75 |
+
print(result)
|
| 76 |
+
|
| 77 |
+
if __name__ == "__main__":
|
| 78 |
+
run_inference()
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
---
|
| 82 |
+
|
| 83 |
+
## Example Output
|
| 84 |
+
|
| 85 |
+
```
|
| 86 |
+
<think>
|
| 87 |
+
I need to analyze this meshing task step by step to create an effective GMSH script.
|
| 88 |
+
|
| 89 |
+
1. Geometry Requirements:
|
| 90 |
+
- Main domain: Rectangular plate (let's assume 10x10 units)
|
| 91 |
+
- Internal feature: Circular hole at center (radius 1 unit)
|
| 92 |
+
- Mesh requirements: Finer elements near hole, coarser elements at boundaries
|
| 93 |
+
|
| 94 |
+
2. Meshing Approach:
|
| 95 |
+
- Unstructured triangular mesh for flexibility around complex features
|
| 96 |
+
- Size field to control element gradation from fine near hole to coarse at boundaries
|
| 97 |
+
- Boundary layer not strictly necessary but could be added if flow simulation is intended
|
| 98 |
+
|
| 99 |
+
3. Construction Steps:
|
| 100 |
+
- Define rectangle points (4 corners)
|
| 101 |
+
- Define circle points (center + 4 quadrant points)
|
| 102 |
+
- Create line loops for both shapes
|
| 103 |
+
- Create surface with hole using Plane Surface command
|
| 104 |
+
- Set up size field for gradation control
|
| 105 |
+
- Generate mesh
|
| 106 |
+
</think>
|
| 107 |
+
<response>
|
| 108 |
+
1. High-level overview:
|
| 109 |
+
- Create 10x10 rectangular domain centered at origin
|
| 110 |
+
- Add circular hole of radius 1 at center
|
| 111 |
+
- Use distance-based size field to refine mesh near hole
|
| 112 |
+
- Generate unstructured triangular mesh with smooth gradation
|
| 113 |
+
|
| 114 |
+
2. Step-by-step instructions:
|
| 115 |
+
a) Create rectangle points (4 corners)
|
| 116 |
+
b) Create circle points (center + 4 quadrants)
|
| 117 |
+
c) Connect points with lines/arcs
|
| 118 |
+
d) Form line loops
|
| 119 |
+
e) Create surface with hole
|
| 120 |
+
f) Set up size field
|
| 121 |
+
g) Generate mesh
|
| 122 |
+
|
| 123 |
+
3. Complete GMSH script:
|
| 124 |
+
|
| 125 |
+
\`\`\`
|
| 126 |
+
// Rectangle with circular hole - graded mesh example
|
| 127 |
+
|
| 128 |
+
// Geometry parameters
|
| 129 |
+
rect_size = 5; // Half-width/height of rectangle
|
| 130 |
+
hole_radius = 1; // Radius of central hole
|
| 131 |
+
|
| 132 |
+
// Points for rectangle
|
| 133 |
+
Point(1) = {-rect_size, -rect_size, 0};
|
| 134 |
+
Point(2) = {rect_size, -rect_size, 0};
|
| 135 |
+
Point(3) = {rect_size, rect_size, 0};
|
| 136 |
+
Point(4) = {-rect_size, rect_size, 0};
|
| 137 |
+
|
| 138 |
+
// Points for circle (center + 4 quadrants)
|
| 139 |
+
Point(5) = {0, 0, 0}; // Center
|
| 140 |
+
Point(6) = {hole_radius, 0, 0};
|
| 141 |
+
Point(7) = {0, hole_radius, 0};
|
| 142 |
+
Point(8) = {-hole_radius, 0, 0};
|
| 143 |
+
Point(9) = {0, -hole_radius, 0};
|
| 144 |
+
|
| 145 |
+
// Lines for rectangle
|
| 146 |
+
Line(1) = {1, 2};
|
| 147 |
+
Line(2) = {2, 3};
|
| 148 |
+
Line(3) = {3, 4};
|
| 149 |
+
Line(4) = {4, 1};
|
| 150 |
+
|
| 151 |
+
// Circle arcs
|
| 152 |
+
Circle(5) = {6, 5, 7};
|
| 153 |
+
Circle(6) = {7, 5, 8};
|
| 154 |
+
Circle(7) = {8, 5, 9};
|
| 155 |
+
Circle(8) = {9, 5, 6};
|
| 156 |
+
|
| 157 |
+
// Line loops
|
| 158 |
+
Line Loop(1) = {1, 2, 3, 4}; // Outer rectangle
|
| 159 |
+
Line Loop(2) = {5, 6, 7, 8}; // Inner circle
|
| 160 |
+
|
| 161 |
+
// Surface with hole
|
| 162 |
+
Plane Surface(1) = {1, 2};
|
| 163 |
+
|
| 164 |
+
// Mesh size control - fine near hole, coarse at boundaries
|
| 165 |
+
Field[1] = Distance;
|
| 166 |
+
Field[1].NodesList = {5}; // Measure distance from center point
|
| 167 |
+
Field[1].NNodesByEdge = 100;
|
| 168 |
+
|
| 169 |
+
Field[2] = Threshold;
|
| 170 |
+
Field[2].InField = 1;
|
| 171 |
+
Field[2].SizeMin = 0.05; // Fine mesh near hole
|
| 172 |
+
Field[2].SizeMax = 0.5; // Coarse mesh far away
|
| 173 |
+
Field[2].DistMin = hole_radius;
|
| 174 |
+
Field[2].DistMax = 2*hole_radius;
|
| 175 |
+
|
| 176 |
+
Background Field = 2;
|
| 177 |
+
|
| 178 |
+
// Physical groups for boundaries
|
| 179 |
+
Physical Curve("OuterBoundary", 1) = {1, 2, 3, 4};
|
| 180 |
+
Physical Curve("InnerBoundary", 2) = {5, 6, 7, 8};
|
| 181 |
+
Physical Surface("Domain", 1) = {1};
|
| 182 |
+
|
| 183 |
+
// Mesh settings
|
| 184 |
+
Mesh.Algorithm = 6; // Frontal-Delaunay
|
| 185 |
+
Mesh.Smoothing = 5;
|
| 186 |
+
Mesh.CharacteristicLengthExtendFromBoundary = 1;
|
| 187 |
+
|
| 188 |
+
// Generate 2D mesh
|
| 189 |
+
Mesh 2;
|
| 190 |
+
\`\`\`
|
| 191 |
+
|
| 192 |
+
4. Implementation Notes:
|
| 193 |
+
- To run: Open in GMSH → Mesh → 2D
|
| 194 |
+
- Adjust parameters as needed:
|
| 195 |
+
* rect_size: Change rectangle dimensions
|
| 196 |
+
* hole_radius: Modify hole size
|
| 197 |
+
* SizeMin/SizeMax: Control mesh density
|
| 198 |
+
* DistMin/DistMax: Control refinement region extent
|
| 199 |
+
- For structured mesh option, add Transfinite lines/surface commands
|
| 200 |
+
- Visualize geometry first (Geometry tab) before meshing
|
| 201 |
+
- Common errors to avoid:
|
| 202 |
+
* Missing line loops
|
| 203 |
+
* Incorrect point references in curves
|
| 204 |
+
* Overlapping or intersecting geometries
|
| 205 |
+
</response>
|
| 206 |
+
```
|
| 207 |
+
|
| 208 |
+
---
|
| 209 |
+
|
| 210 |
+
## License
|
| 211 |
+
|
| 212 |
+
Apache 2.0
|
| 213 |
+
|
| 214 |
+
---
|
| 215 |
+
|
| 216 |
+
## Citation
|
| 217 |
+
|
| 218 |
+
```bibtex
|
| 219 |
+
@misc{gmeshnet_oss_8b_2025,
|
| 220 |
+
title={GMeshNet-OSS-8B: Open-Source Meshing Assistant},
|
| 221 |
+
author={Raymond Lee, Rehaan Kadhar, Areen Patil},
|
| 222 |
+
year={2025},
|
| 223 |
+
howpublished={\url{https://huggingface.co/Callimesh/GMeshNet-OSS-8B}}
|
| 224 |
+
}
|
| 225 |
+
```
|