Two very easy ways to sense low filament:

1) Weight. Have a scale that beeps when you hit a certain minimum weight. Since you already know the base weight of the holder and spool, a low weight threshold is easy to calculate.

2) A hall sensor on the spool measuring rotation of the spool vs the linear travel of the filament (another wheel with a hall sensor). When the ratio hits a certain level, you about how much filament is left on the spool.