Skip to main content

Precompute the Semantic Index with vg embed

vg embed precomputes the semantic index so the next vg ask is instant. A local ONNX model downloads once into a shared cache, then runs fully offline with no account needed.

Difficulty
Intermediate
Duration
15 minutes
Steps
5

Semantic search makes vg ask smart, but computing embeddings on the fly costs time. vg embed precomputes the semantic index up front so your next vg ask is instant.

Prerequisites

  • A built code graph from vg build

Steps

1. Build the graph

vg build

2. Precompute embeddings

vg embed

vg embed builds the semantic index over your code map ahead of time.

3. Understand the local model

The first run downloads a local ONNX model once into a shared cache. After that, embedding runs fully offline — nothing leaves your machine and no account is required.

4. Run an instant ask

With the index precomputed, queries return immediately:

vg "where do we validate user input"

vg ask now uses the prebuilt index instead of computing embeddings on demand.

5. Refresh after big changes

After substantial code changes, rebuild and re-embed to keep semantic results accurate:

vg build
vg embed

Verification

Confirm vg embed completes without error and that a subsequent vg ask returns results noticeably faster. The shared model cache means later runs skip the download.

Next Steps

  • Ask natural-language questions with vg ask
  • Serve the index to your assistant with vg serve
  • Wire it into your AI tool with vg install

Prerequisites

  • A built code graph (vg build)

Steps

  • 1
    Build the graph
  • 2
    Precompute embeddings
  • 3
    Understand the local model
  • 4
    Run an instant ask
  • 5
    Refresh after big changes

Category

Vibgrate