Edge Function CPU Timeouts when generating embeddings #21345
-
Hey folks, Firstly, thanks for the great tutorial! Amazing content. I'm running into an issue with the "embed" edge function both locally and when deployed. When running local I was unable to embed more than ~5 1000 character sections before running into CPU hard limits. This seems to be even worse when deployed. Most of the time the function will crash after the first section. Playing around with the chunk sizes seemed to have no affect. Each invocation is taking around 5 seconds as well. Is there anything that can be done about this? I've done a ton of digging and I'm not seeing anyone else with this issue so i'm wondering if i'm doing something wrong. But I'm running virtually a 1:1 with this repo other than processing sections by characters instead of markdown headings in the process function. export function processText(content: string, document_id: number, chunk_size = 1000): Section[] {
const numChunks = Math.ceil(content.length / chunk_size);
const chunks = new Array(numChunks);
for (let i = 0, o = 0; i < numChunks; ++i, o += chunk_size) {
chunks[i] = content.substring(o, o + chunk_size);
}
return chunks.map((content: string) => ({ document_id, content }))
} Example invocation failure: Log ID Log Timestamp (UTC) Log Event Message Log Metadata Any pointers here would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Beta Was this translation helpful? Give feedback.
-
In the last Launch Week, we announced native embedding generation in Edge Functions, which should solve these CPUTime limits https://supabase.com/blog/ai-inference-now-available-in-supabase-edge-functions Check this guide on how to use this new API within your Edge Functions https://supabase.com/docs/guides/functions/ai-models#how-to-generate-text-embeddings |
Beta Was this translation helpful? Give feedback.
In the last Launch Week, we announced native embedding generation in Edge Functions, which should solve these CPUTime limits https://supabase.com/blog/ai-inference-now-available-in-supabase-edge-functions
Check this guide on how to use this new API within your Edge Functions https://supabase.com/docs/guides/functions/ai-models#how-to-generate-text-embeddings