Skip to content

Instantly share code, notes, and snippets.

View freckletonj's full-sized avatar
🎯
Focusing

neurallambda freckletonj

🎯
Focusing
View GitHub Profile
@freckletonj
freckletonj / kv_cache_generate.py
Created August 30, 2024 00:53
Generate tokens using past_key_values/kv-cache in transformers
def generate_with_cache(model, model_inputs, max_new_tokens):
''' Use past_key_values for a theoretical speedup. '''
generated_tokens = []
past_key_values = None
next_token = None
input_ids = model_inputs['input_ids']
attention_mask = model_inputs['attention_mask']
for i in range(max_new_tokens):
@freckletonj
freckletonj / freecad_venv.sh
Created October 12, 2025 06:48
FreeCAD venv environment
# If you want to develop for FreeCAD in an environment that is aware of all the baked-in imports, simply do this!
FreeCAD...AppImage --appimage-extract # create squashfs-root/ dir
# create venv using appimage's python
squashfs-root/usr/bin/python -m venv .env
# Add this to `.env/bin/activate`
export FREECAD_ROOT=<SQUASHFS_LOCATION>/usr
export PYTHONPATH=$FREECAD_ROOT/lib:$FREECAD_ROOT/lib/python3.11/site-packages:$FREECAD_ROOT/lib/python3.11:$FREECAD_ROOT/Mod:$PYTHONPATH
@freckletonj
freckletonj / freecad_cam_simulation.py
Created October 14, 2025 19:12
Custom FreeCAD CAM Simulation
'''
Use the new CAM simulator with custom stock and custom cutting paths
'''
import FreeCAD as App
import FreeCADGui as Gui
import Part
import CAMSimulator
from PathScripts import PathUtils
import Path.Dressup.Utils as PathDressup