Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

EmbeddingService: use flutter_gemma batch API (generateEmbeddings) for sync-burst throughput

オープン
#125 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

この issue はまだ評価されていません。

説明

enhancement P0-Critical

Problem

EmbeddingService.embed (lib/features/shiv/rag/embedding/embedding_service.dart) calls EmbeddingModel.generateEmbedding(text) once per note. Every call
pays the full LiteRT per-invocation overhead (input/output tensor marshalling, GPU dispatch setup/teardown). The actual model math on Gecko-110M is
tiny — overhead dominates.

This is invisible when a user adds one note at a time, but becomes visible during sync bursts:

  • First app open after install / restore (relay backfills 100s of notes)
  • Returning online after a few days
  • Joining / catching up on a busy channel or long thread

In those windows the embedder lane saturates EmbeddingQueue(Semaphore(2)) for ~tens of seconds, RAG context lags behind the visible feed (Shiv answers
are "incomplete" until the index catches up), and the phone stays warm.

Proposal

Wire flutter_gemma's batch entry point through the service:

Future<List<List>> embedBatch(
List texts, {
bool isDocument = false,
});

Internally calls _model!.generateEmbeddings(texts, taskType: ...) — one native dispatch for the whole list — then L2-normalises each vector. Keep the
existing single-text embed() as a thin wrapper around embedBatch([text]).first so call sites that genuinely embed one string at a time don't change.

Call sites to migrate

  • The note-ingest path that embeds inbound Kind 1 events as the Gateway writes them to Isar. Currently iterates and calls embed(...) per note; should
    accumulate a small list (e.g. up to N=16 or whatever flushes a Gateway batch) and call embedBatch.
  • Saved-note / reference-note backfill jobs.

Out of scope — explicitly NOT changing

  • The embedding model itself (stay on bundled Gecko-1024 — offline-first, ~25 MB).
  • The 1-hop GraphRAG expansion. Edges come from e/t tags, not from the embedder.
  • The EmbeddingQueue(Semaphore(2)) parallelism cap — that stays as a backpressure guard.
  • Shiv chat query embedding — already single-string, no batching opportunity.

Expected user-visible improvements

Image

No change to single-add latency or retrieval quality.

Acceptance

  • New embedBatch(List) lands on EmbeddingService with GPU→CPU fallback preserved.
  • Inbound note handler in the Gateway batches embed calls.
  • Device test (one app install, integration_test/) ingests N≈100 notes and asserts wall-clock time drops by ≥5× vs. current per-note path on the same
    device.
  • No regression on chat first-token latency or single-note add.

References

主要言語
Dart
スター
2
フォーク
2
平均マージ
18時間 53分
マージ済み PR(30日)
35

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

basictech01/uniun のほかの issue

basictech01/uniun の issue をすべて見る

似ている issue

Dart の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。