Skip to content

Private AI meeting notes that stay on your computer. No meeting bot. Free and open source for Mac, Windows and Linux. An alternative to Granola, Otter and Fireflies.

Notes on a Mac under 28 GB: whisper goes before the notes model loads, half the context, and the model goes a minute after its last job (a 24 GB Mac froze with both loaded)

christianmat01a5b5d2b05d
diff --git a/app/src/main/asr/index.ts b/app/src/main/asr/index.ts
index c3b63b08..1c6ffecf 100644
--- a/app/src/main/asr/index.ts
+++ b/app/src/main/asr/index.ts
@@ -333,4 +333,16 @@ export async function settleTranscription(capMs = 20_000): Promise<void> {
}
/** Quitting: whisper-server goes with the app */
+/**
+ * A Mac with little memory: whisper-server goes now, not ten minutes after the last meeting, so the notes model does not
+ * load next to it (a 24 GB Mac froze with both loaded). Never while a meeting or a saved recording is being transcribed.
+ */
+export async function releaseIdleSpeech(): Promise<void> {
+ if (sessions.size || !server) return
+ clearTimeout(idleTimer)
+ const s = server
+ server = undefined; serverKey = undefined
+ await s.stop().catch((e) => console.error('stopping whisper-server failed', e))
+}
+
export function stopTranscriptionServer() { clearTimeout(idleTimer); server?.kill(); server = undefined; serverKey = undefined }
diff --git a/app/src/main/index.ts b/app/src/main/index.ts
index 350a32b2..1da088da 100644
--- a/app/src/main/index.ts
+++ b/app/src/main/index.ts
@@ -51,7 +51,7 @@ import { isId, text, rewriteNote } from './ipcArgs'
import { hookMics } from './mics'
import { activeCapture, audioHelperPath, hookCapture, joinParts, onCaptureStart, onRecordingEvent, prepareAppend, recordingFinished, recordingPaused, recordingSettled, rejoinInterrupted, setRecordingPaused, settleRecording, tell, type WarnCode } from './capture'
import { createWidget } from './widget'
-import { hookTranscription, transcribeRecorded, onWhisperGpuOff, meetingLanguage, settleTranscription, speechLocaleFor, spokenChanged, transcriptionBacklogMs, stopTranscriptionServer, transcriptFinished, transcriptPartials } from './asr'
+import { hookTranscription, transcribeRecorded, onWhisperGpuOff, meetingLanguage, settleTranscription, speechLocaleFor, spokenChanged, transcriptionBacklogMs, stopTranscriptionServer, releaseIdleSpeech, transcriptFinished, transcriptPartials } from './asr'
import { hookCallNames, type Watch } from './callNames'
import { helperWatch, killAllWatches } from './callNames/watch'
import { macFullName } from './user'
@@ -64,7 +64,7 @@ import { createNotesModel } from './notes/model'
import { FakeEngine } from './notes/fake'
import { hookNotes } from './notes'
import { hookReadAhead, readAheadAllowed } from './notes/readAhead'
-import { createQueue, isSmallMac } from './notes/queue'
+import { createQueue, isSmallMac, notesMemory } from './notes/queue'
import type { ContextChip } from '../shared/askContext'
import { Library } from './library/store'
import { createEmbedder } from './library/embedder'
@@ -576,11 +576,12 @@ app.whenReady().then(() => {
}, (e) => { console.warn("couldn't check the graphics", e); return null })
// fake mode: the fixed Mac (a bigger one) unless a test asks for a 16 GB one
const smallMac = isFake() ? process.env.YOGURT_FAKE_SMALL_MAC === '1' : isSmallMac(os.totalmem())
- const model = createNotesModel({ engine, modelPath: () => setup.notesPath(), onLoaded: path => setup.notesModelLoaded(path) })
+ const memory = notesMemory(smallMac)
+ const model = createNotesModel({ engine, modelPath: () => setup.notesPath(), onLoaded: path => setup.notesModelLoaded(path), contextSize: memory.contextSize, ...(memory.releaseSpeech ? { beforeLoad: releaseIdleSpeech } : {}) })
// first run: the notes model lands after recording already works; jobs wait in the queue for it
// the embedding model (meaning search across meetings) runs in the same worker and is let go with the notes model
const embedder = createEmbedder({ engine, modelPath: () => setup.installed()?.embed, id: bundledCatalog.embedding.id, dims: bundledCatalog.embedding.dims })
- const queue = createQueue({ recording: () => !!activeMeeting(), smallMac, backlogMs: transcriptionBacklogMs, onIdle: () => { void model.unload().catch(e => console.error('letting the notes model go failed', e)); void embedder.unload() }, modelReady: () => !!setup.notesPath() })
+ const queue = createQueue({ recording: () => !!activeMeeting(), smallMac, idleMs: memory.idleMs, backlogMs: transcriptionBacklogMs, onIdle: () => { void model.unload().catch(e => console.error('letting the notes model go failed', e)); void embedder.unload() }, modelReady: () => !!setup.notesPath() })
ipcMain.handle('setup:remove-upgrade', () => setup.removeUpgrade(remove => queue.enqueue(async () => {
await model.unload()
remove()
diff --git a/app/src/main/notes/model.ts b/app/src/main/notes/model.ts
index ae89cc42..a6c958a8 100644
--- a/app/src/main/notes/model.ts
+++ b/app/src/main/notes/model.ts
@@ -24,7 +24,12 @@ const before = (pairs: string[] = []): EngineMessage[] => pairs.map((content, i)
* one sequence for its whole life, let go when the queue says so. It remembers what the sequence starts with, so a
* read ahead only sends what is new.
*/
-export function createNotesModel(o: { engine: Engine; modelPath: () => string | undefined; onLoaded?: (path: string) => void }) {
+export function createNotesModel(o: { engine: Engine; modelPath: () => string | undefined; onLoaded?: (path: string) => void
+ /** the context to load with (smaller on a Mac with little memory; notes split a long meeting into parts to fit) */
+ contextSize?: number
+ /** let go of what must not sit in memory next to the model (whisper-server on a Mac with little memory) */
+ beforeLoad?: () => Promise<void>
+}) {
let loaded: { path: string; contextSize: number } | undefined
let loading: Promise<{ path: string; contextSize: number }> | undefined
/** the text the model's sequence starts with (the first message of what it last read): what a read ahead builds on */
@@ -38,7 +43,7 @@ export function createNotesModel(o: { engine: Engine; modelPath: () => string |
held = ''
loaded = undefined
const t0 = performance.now()
- loading ??= o.engine.load(path, CONTEXT, MIN_CONTEXT).then((r) => {
+ loading ??= (async () => { await o.beforeLoad?.().catch((e) => console.error('letting go before the notes model loads failed', e)) })().then(() => o.engine.load(path, o.contextSize ?? CONTEXT, MIN_CONTEXT)).then((r) => {
console.info('TIMING', `load ${((performance.now() - t0) / 1000).toFixed(1)} s`)
o.onLoaded?.(path)
return (loaded = { path, contextSize: r.contextSize })
diff --git a/app/src/main/notes/queue.ts b/app/src/main/notes/queue.ts
index 6706700b..90a70e39 100644
--- a/app/src/main/notes/queue.ts
+++ b/app/src/main/notes/queue.ts
@@ -1,3 +1,4 @@
+import { CONTEXT } from '../../shared/engine-protocol'
/**
* readahead: reading a meeting into the model ahead of what will ask about it (while it is recorded, readAhead.ts; when
* its Ask opens, chat.ts warm); it comes late, never while a small Mac records, and is never run again.
@@ -19,6 +20,15 @@ export const IDLE_UNLOAD_MS = 10 * 60_000
*/
export const isSmallMac = (totalBytes: number): boolean => totalBytes < 28 * 2 ** 30
+/**
+ * How the notes model shares memory. A small Mac (under 28 GB) froze with whisper-server and the 26B model loaded
+ * together: there whisper goes before the model loads, the model loads with half the context (long meetings are written
+ * in parts), and it goes a minute after the last job instead of ten.
+ */
+export function notesMemory(smallMac: boolean): { contextSize: number; idleMs: number; releaseSpeech: boolean } {
+ return smallMac ? { contextSize: 16_384, idleMs: 60_000, releaseSpeech: true } : { contextSize: CONTEXT, idleMs: IDLE_UNLOAD_MS, releaseSpeech: false }
+}
+
/** On a bigger Mac, audio waiting for transcription past this stops model work; it starts again under RESUME_MS */
export const BACKLOG_MS = 30_000
export const RESUME_MS = 10_000
diff --git a/app/test/notesModelMemory.test.ts b/app/test/notesModelMemory.test.ts
new file mode 100644
index 00000000..93665167
--- /dev/null
+++ b/app/test/notesModelMemory.test.ts
@@ -0,0 +1,34 @@
+import { describe, expect, it, vi } from 'vitest'
+import { createNotesModel } from '../src/main/notes/model'
+import { notesMemory, IDLE_UNLOAD_MS } from '../src/main/notes/queue'
+import { CONTEXT } from '../src/shared/engine-protocol'
+import type { Engine } from '../src/main/engine'
+
+function rig(o: { contextSize?: number; beforeLoad?: () => Promise<void> }) {
+ const calls: string[] = []
+ const engine: Engine = {
+ load: vi.fn(async (_p: string, ctx: number) => { calls.push(`load ${ctx}`); return { contextSize: ctx } }),
+ unload: async () => {}, count: async (t) => t.map(() => 1), preload: async () => 0, embed: async () => [], unloadEmbed: async () => {}, dispose: () => {},
+ onExit: () => {}, chat: vi.fn(async () => 'x'),
+ }
+ const model = createNotesModel({ engine, modelPath: () => '/m.gguf', ...o, beforeLoad: o.beforeLoad && (async () => { calls.push('before'); await o.beforeLoad!() }) })
+ return { calls, model }
+}
+
+describe('the notes model on a Mac with little memory (a 24 GB Mac froze with whisper and the 26B model loaded together)', () => {
+ it('loads with the context it is given, after letting go of what it is told to first, once', async () => {
+ const r = rig({ contextSize: 16_384, beforeLoad: async () => {} })
+ await expect(r.model.llm()).resolves.toMatchObject({ contextSize: 16_384 })
+ await r.model.llm()
+ expect(r.calls).toEqual(['before', 'load 16384'])
+ })
+ it('a bigger Mac keeps the full context and lets nothing go', async () => {
+ const r = rig({})
+ await r.model.llm()
+ expect(r.calls).toEqual([`load ${CONTEXT}`])
+ })
+ it('the plan: a small Mac uses half the context, lets whisper go first and the notes model go after a minute idle', () => {
+ expect(notesMemory(true)).toEqual({ contextSize: 16_384, idleMs: 60_000, releaseSpeech: true })
+ expect(notesMemory(false)).toEqual({ contextSize: CONTEXT, idleMs: IDLE_UNLOAD_MS, releaseSpeech: false })
+ })
+})
diff --git a/app/test/transcription.test.ts b/app/test/transcription.test.ts
index 3b2ca633..b4018fc5 100644
--- a/app/test/transcription.test.ts
+++ b/app/test/transcription.test.ts
@@ -2,7 +2,7 @@ import { EventEmitter } from 'node:events'
import { PassThrough } from 'node:stream'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { Capture, encodeFrame, hookCapture, recordingFinished, type CaptureProc } from '../src/main/capture'
-import { hookTranscription, transcribeRecorded, settleTranscription, speechLocaleFor, spokenChanged, stopTranscriptionServer, transcribing } from '../src/main/asr'
+import { hookTranscription, transcribeRecorded, settleTranscription, speechLocaleFor, spokenChanged, stopTranscriptionServer, transcribing, releaseIdleSpeech } from '../src/main/asr'
import type { Spoken } from '../src/shared/spoken'
import type { TranscriptPartial } from '../src/shared/types'
import { openStore, type Meeting, type Store } from '../src/main/store'
@@ -262,6 +262,29 @@ describe('whisper-server between meetings', () => {
expect(s.made[1].urls).toBe(1)
await h.end(b)
})
+ it('a small Mac lets an idle whisper-server go at once, before the notes model loads next to it (a 24 GB Mac froze)', async () => {
+ const s = fakeServers()
+ const h = hooks(s.make, 60_000)
+ const a = meeting()
+ h.begin(a); await h.end(a)
+ expect(s.made[0].stops).toBe(0)
+ await releaseIdleSpeech()
+ expect(s.made[0].stops).toBe(1)
+ // the next meeting starts a new one
+ const b = meeting()
+ h.begin(b)
+ expect(s.made).toHaveLength(2)
+ await h.end(b)
+ })
+ it('never while a meeting is still being transcribed', async () => {
+ const s = fakeServers()
+ const h = hooks(s.make, 60_000)
+ const a = meeting()
+ h.begin(a)
+ await releaseIdleSpeech()
+ expect(s.made[0].stops).toBe(0)
+ await h.end(a)
+ })
it('a meeting starting before the wait is up keeps the same server running', async () => {
const s = fakeServers()
const h = hooks(s.make, 60)