Database / LanceDB Interview questions
Define the embedding function registry in LanceDB?
The embedding function registry is LanceDB's mechanism for attaching an embedding model directly to a table's schema, so that inserting raw data (like text) automatically generates and stores the corresponding vector, without the application needing to call an embedding model explicitly before every insert.
from lancedb.embeddings import get_registry from lancedb.pydantic import LanceModel, Vector registry = get_registry() func = registry.get("sentence-transformers").create() class Document(LanceModel): text: str = func.SourceField() vector: Vector(func.ndims()) = func.VectorField() table = db.create_table("documents", schema=Document) table.add([{"text": "hello world"}]) # vector generated automatically
The registry ships with built-in support for many popular embedding providers — OpenAI, Cohere, sentence-transformers, and multimodal models like CLIP — and a table's schema marks which field is the SourceField (the raw input, like text) and which is the VectorField (the generated embedding), so both query-time and insert-time embedding generation are handled consistently.
The trade-off is that if the underlying embedding function later changes, the table generally needs to be reconfigured and its embeddings regenerated to stay consistent, since old rows were embedded with a different model or set of weights than new ones would be.
More Related questions...