Skip to content

✨ feat: generate snippet titles with Gemma 4 26B-A4B - #38

Merged
martinezharo merged 1 commit into
mainfrom
t3/compare-gemma-title-quality
Oct 20, 2026
Merged

martinezharo merged 1 commit into
mainfrom
t3/compare-gemma-title-quality

Conversation

@martinezharo

Copy link
Copy Markdown
Owner

Summary

Switch AI title generation from @cf/meta/llama-3.2-3b-instruct to @cf/google/gemma-4-26b-a4b-it.

Benchmark (16 snippets, same prompt, same sampling)

Snippet Llama 3.2 3B Gemma 4 26B-A4B
TSX UserCard component UserCardComponent UserCard
Java EventEmitter class emit-event EventEmitter
TS retry w/ backoff retryFunction retryWithBackoff
ESLint JSON config next-config eslint-config
GitHub Actions YAML ci-deploy github-actions-ci
Go health handler handleHealthResponse health-check-handler
Spanish relative-time fn format_date relativeTime
SQL orders per user user_orders user-order-count

The rest were equivalent (useDebounce, fetch_user_data, define-port, red-background, deploy-checklist, square_even_numbers).

Cost / latency

  • Llama 3.2 3B: $0.051/M in, $0.335/M out → ~$0.000024 per title
  • Gemma 4 26B-A4B: $0.10/M in, $0.30/M out → ~$0.000045 per title (~430 in / ~5 out tokens)
  • Latency typically 400–700 ms vs ~250 ms (occasional spikes seen). Fine for a background title.

Notes

  • Gemma reasons by default and spent all 24 max_tokens thinking (empty output) → chat_template_kwargs.enable_thinking: false.
  • Gemma returns an OpenAI-style choices[0].message.content payload (confirmed through the real env.AI binding), so the route reads that and falls back to response.

Test plan

  • tsc, eslint, vitest pass
  • Verified the binding response shape with a temporary worker using remote AI

Benchmarked on 16 varied snippets against llama-3.2-3b-instruct: Gemma names
noticeably better (UserCard vs UserCardComponent, EventEmitter vs emit-event,
retryWithBackoff vs retryFunction, github-actions-ci vs ci-deploy,
eslint-config vs next-config).

Cost is negligible either way (~$0.00004 vs ~$0.00002 per title, ~430 input /
~5 output tokens). Latency is typically 400-700ms vs ~250ms.

Gemma reasons by default and burns the whole 24-token budget thinking, so
thinking is disabled. It also returns an OpenAI-style `choices` payload
instead of `response`, so the route now reads both shapes.
@cloudflare-workers-and-pages

Copy link
Copy Markdown
Contributor

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
klipcode 40853d2 Commit Preview URL

Branch Preview URL
Oct 20 2026, 10:37 AM

@oli-review oli-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Switches snippet-title generation from the Llama 3.2 3B model to Gemma 4 26B-A4B, disables Gemma's default thinking budget, and adds a normalizer that accepts either the legacy { response } or OpenAI-style { choices[0].message.content } Workers AI payload before passing the text to the existing sanitizer. No other routes or callers change.

Risk: low


Automated review — opencode-go/deepseek-v4.1-flash · 0 comment(s)

@martinezharo
martinezharo merged commit 165729a into main Oct 20, 2026
2 checks passed
@martinezharo
martinezharo deleted the t3/compare-gemma-title-quality branch October 20, 2026 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant