Tutorial: OCADR HF inference
In this tutorial you will run ll_ocadr’s HF-native pipeline: encode a 3D object’s geometry into a language model’s embedding space and have the model describe it. Allow ~15 minutes (first run downloads the chosen LM).
1. Run the CLI
Section titled “1. Run the CLI”The <mesh> placeholder in the prompt marks where the encoded geometry tokens go.
python ll_ocadr/run_ll_ocadr_hf.py \ --model Qwen/Qwen2-1.8B \ --mesh part.stl \ --prompt "Describe this CAD part: <mesh>" \ --max-new-tokens 64--modelis any HF causal LM;n_embedis derived from it automatically.--meshaccepts a mesh (STL/OBJ/PLY) or a STEP file (STEP needspythonocc-core).--no-croppinguses the global view only; otherwise the object is chunked into local tiles plus a global view.
2. Do it programmatically
Section titled “2. Do it programmatically”from ll_ocadr.run_ll_ocadr_hf import build_model_and_tokenizer, run_inference
model, tokenizer, config, processor = build_model_and_tokenizer("Qwen/Qwen2-1.8B")text = run_inference(model, processor, tokenizer, "part.stl", "Describe <mesh>")print(text)build_model_and_tokenizer constructs LatticelabsOCADRForCausalLM, registers
the <mesh> token, and resizes the LM embeddings. run_inference chunks the
geometry, encodes it (GeometryNet PointNet++ local + ShapeNet ViT global →
MLP projector), splices the geometry embeddings into the prompt, and calls the
LM’s generate.
3. Run the test suite (no network)
Section titled “3. Run the test suite (no network)”The fast tests exercise the encoders and chunkers with no model download; the slow tests run an end-to-end forward/generate on a tiny offline LM.
cd ll_ocadrpytest tests/ -m "not slow" # encoders, chunkers, fixturespytest tests/ -m slow # e2e + CLI on a tiny offline LMWhere to next
Section titled “Where to next”- ll_ocadr Usage for the architecture details.
- The reality of AI CAD generation for how geometry-aware LLM input fits the bigger picture.