메뉴
HN
Hacker News 55일 전

브라우저 내장형 AI 'Gemma Gem' 오픈소스 공개

IMP
8/10
핵심 요약

해커뉴스에 구글의 'Gemma 4' 모델을 브라우저 내에서 직접 구동하는 크롬 확장 프로그램 'Gemma Gem'이 공개되었습니다. WebGPU를 활용해 별도의 API 키나 클라우드 없이 기기 내에서 AI가 작동하며, 사용자의 데이터를 외부로 전송하지 않아 프라이버시가 강력하게 보호됩니다. 특히 웹페이지 내용 읽기, 버튼 클릭, 폼 작성, 자바스크립트 실행 등 브라우저 상에서의 에이전트(Agent) 작업 수행이 가능하다는 점이 가장 큰 특징입니다.

번역된 본문

Gemma Gem 브라우저 안에 상주하는 당신만의 개인 AI 비서입니다. Gemma Gem은 구글의 Gemma 4 모델을 WebGPU를 통해 기기 내에서 완벽하게 구동합니다. API 키도, 클라우드 연결도 필요 없으며 사용자의 데이터가 컴퓨터 외부로 유출되지 않습니다. 방문하는 모든 사이트의 페이지를 읽고, 버튼을 클릭하고, 양식을 채우고, 자바스크립트를 실행하며 질문에 답변할 수 있습니다.

요구 사항

  • WebGPU를 지원하는 Chrome 브라우저
  • E2B 모델의 경우 약 500MB 디스크 공간, E4B 모델의 경우 약 1.5GB (최초 실행 후 캐시됨)

설정 (Setup)

  • pnpm install
  • pnpm build
  • 크롬 브라우저에서 chrome://extensions (개발자 모드) 페이지를 열고, .output/chrome-mv3-dev/ 폴더를 통해 확장 프로그램을 로드합니다.

사용 방법 (Usage)

  • 아무 웹페이지로 이동합니다.
  • 우측 하단의 gem 아이콘을 클릭하여 채팅창을 엽니다.
  • 모델이 로드될 때까지 대기합니다. (진행률은 아이콘과 채팅창에 표시됨)
  • 페이지에 대한 질문을 하거나 특정 동작(Action)을 요청합니다.

아키텍처 (Architecture) 오프스크린 문서(Offscreen Document) | 서비스 워커(Service Worker) | 콘텐츠 스크립트(Content Script) (Gemma 4 + 에이전트 루프) <-> (메시지 라우터) <-> (채팅 UI + DOM 도구)

오프스크린 문서 서비스 워커
WebGPU 추론 스크린샷 캡처
토큰 스트리밍 자바스크립트 실행
  • 오프스크린 문서 (Offscreen document): @huggingface/transformers 및 WebGPU를 통해 모델을 호스팅하고 에이전트 루프(Agent Loop)를 실행합니다.
  • 서비스 워커 (Service worker): 콘텐츠 스크립트와 오프스크린 문서 간의 메시지를 라우팅하며, take_screenshotrun_javascript를 처리합니다.
  • 콘텐츠 스크립트 (Content script): Gem 아이콘 및 Shadow DOM 기반의 채팅 오버레이를 주입합니다. DOM 도구(read_page_content, click_element, type_text, scroll_page)를 실행합니다.

도구 (Tools)

  • read_page_content (실행 위치: 콘텐츠 스크립트): 페이지의 텍스트/HTML이나 특정 CSS 선택자의 내용을 읽어옵니다.
  • take_screenshot (실행 위치: 서비스 워커): 화면에 보이는 페이지를 PNG로 캡처합니다.
  • click_element (실행 위치: 콘텐츠 스크립트): CSS 선택자를 통해 특정 요소를 클릭합니다.
  • type_text (실행 위치: 콘텐츠 스크립트): CSS 선택자를 통해 입력란에 텍스트를 입력합니다.
  • scroll_page (실행 위치: 콘텐츠 스크립트): 지정한 픽셀 수만큼 페이지를 위아래로 스크롤합니다.
  • run_javascript (실행 위치: 서비스 워커): 전체 DOM 접근 권한을 가지고 페이지 컨텍스트에서 자바스크립트를 실행합니다.

설정 (Settings) 채팅창 상단의 톱니바퀴 아이콘을 클릭하여 설정을 변경할 수 있습니다:

  • Model: Gemma 4 E2B(약 500MB)와 E4B(약 1.5GB) 사이에서 모델을 전환할 수 있습니다. 선택한 모델은 세션 간에 유지됩니다.
  • Thinking: Gemma 4의 자체적인 사고(Thinking) 모드를 켜거나 끕니다.
  • Max iterations: 요청 당 도구 호출 루프의 최대 횟수를 제한합니다.
  • Clear context: 현재 페이지의 대화 기록을 초기화합니다.
  • Disable on this site: 특정 호스트네임 단위로 확장 프로그램을 비활성화합니다. (설정 유지)

개발 (Development)

  • pnpm build # 로깅 및 소스 맵이 포함된 개발 빌드
  • pnpm build:prod # 로깅이 무음 처리되고 경량화된 프로덕션 빌드

기술 스택 (Tech Stack)

  • WXT: Vite 기반의 Chrome 확장 프로그램 프레임워크
  • @huggingface/transformers: 브라우저 ML 추론 라이브러리
  • marked: 채팅창 내 마크다운 렌더링
  • Gemma 4 E2B / E4B (onnx-community/gemma-4-E2B-it-ONNX, onnx-community/gemma-4-E4B-it-ONNX): q4f16 양자화, 128K 컨텍스트 지원

디버깅 (Debugging) 모든 로그는 [Gemma Gem] 접두사가 붙습니다. 개발 빌드에서는 info/debug/warn 로그가 활성화되며, 프로덕션 빌드에서는 오류 로그만 출력됩니다.

  • 서비스 워커 로그: chrome://extensions → Gemma Gem → "뷰 검사: service worker"
  • 오프스크린 문서 로그: chrome://extensions → Gemma Gem → "뷰 검사: offscreen.html"
  • 콘텐츠 스크립트 로그: 아무 페이지에서 DevTools 열기 → 콘솔 탭
  • 모든 확장 프로그램 페이지: chrome://inspect#other에서 검사 가능한 모든 확장 프로그램 컨텍스트(서비스 워커, 오프스크린 문서 등)를 확인할 수 있습니다.

오프스크린 문서 로그가 가장 유용합니다. 이 로그에는 모델 로딩, 프롬프트 구성, 토큰 수, 원시 모델 출력 및 도구 실행 내역이 표시됩니다.

참고 사항 (Notes) agent/ 디렉토리는 종속성이 전혀 없습니다. 이 디렉토리는 인터페이스(ModelBackend, ToolExecutor)를 정의하며, 독립 실행형 라이브러리로 분리하여 사용할 수 있습니다.

원문 보기
원문 보기 (영어)
Gemma Gem Your personal AI assistant living right inside the browser. Gemma Gem runs Google's Gemma 4 model entirely on-device via WebGPU — no API keys, no cloud, no data leaving your machine. It can read pages, click buttons, fill forms, run JavaScript, and answer questions about any site you visit. Requirements Chrome with WebGPU support ~500MB disk for E2B model, ~1.5GB for E4B (cached after first run) Setup pnpm install pnpm build Load the extension in chrome://extensions (developer mode) from .output/chrome-mv3-dev/ . Usage Navigate to any page Click the gem icon (bottom-right corner) to open the chat Wait for model to load (progress shown on icon + chat) Ask questions about the page or request actions Architecture Offscreen Document Service Worker Content Script (Gemma 4 + Agent Loop) <-> (Message Router) <-> (Chat UI + DOM Tools) | | WebGPU inference Screenshot capture Token streaming JS execution Offscreen document : Hosts the model via @huggingface/transformers + WebGPU. Runs the agent loop. Service worker : Routes messages between content scripts and offscreen document. Handles take_screenshot and run_javascript . Content script : Injects gem icon + shadow DOM chat overlay. Executes DOM tools ( read_page_content , click_element , type_text , scroll_page ). Tools Tool Description Runs in read_page_content Read text/HTML of the page or a CSS selector Content script take_screenshot Capture visible page as PNG Service worker click_element Click an element by CSS selector Content script type_text Type into an input by CSS selector Content script scroll_page Scroll up/down by pixel amount Content script run_javascript Execute JS in the page context with full DOM access Service worker Settings Click the gear icon in the chat header: Model : Switch between Gemma 4 E2B (~500MB) and E4B (~1.5GB). Selection persists across sessions. Thinking : Toggle native Gemma 4 thinking Max iterations : Cap on tool call loops per request Clear context : Reset conversation history for the current page Disable on this site : Disable the extension per-hostname (persisted) Development pnpm build # Development build (with logging, source maps) pnpm build:prod # Production build (logging silenced, minified) Tech Stack WXT — Chrome extension framework (Vite-based) @huggingface/transformers — Browser ML inference marked — Markdown rendering in chat Gemma 4 E2B / E4B ( onnx-community/gemma-4-E2B-it-ONNX , onnx-community/gemma-4-E4B-it-ONNX ) — q4f16 quantization, 128K context Debugging All logs are prefixed with [Gemma Gem] . In development builds, info/debug/warn logs are active. Production builds only log errors. Service worker logs : chrome://extensions → Gemma Gem → "Inspect views: service worker" Offscreen document logs : chrome://extensions → Gemma Gem → "Inspect views: offscreen.html" Content script logs : Open DevTools on any page → Console All extension pages : chrome://inspect#other lists all inspectable extension contexts (service worker, offscreen document, etc.) The offscreen document logs are the most useful — they show model loading, prompt construction, token counts, raw model output, and tool execution. Notes The agent/ directory has zero dependencies. It defines interfaces ( ModelBackend , ToolExecutor ) and can be extracted to a standalone library.
관련 소식