向量化模块与自动嵌入
学习 Weaviate 的向量化模块如何在导入时自动将数据对象转换为向量,以及如何针对每个类和属性进行配置。
向量化模块与自动嵌入 是 CoddyKit 上的免费 Vector Databases: Pinecone, Weaviate & pgvector 课时。 这是第 4 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 Vector Databases: Pinecone, Weaviate & pgvector 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 Vector Databases: Pinecone, Weaviate & pgvector 课程共包含 4 节课。
本课时的部分内容尚未翻译,以英文显示。
Who Creates the Vectors?
Vector search needs every object to have a vector. You can compute embeddings yourself, or let Weaviate do it via a vectorizer module that embeds objects automatically on import.
What Is a Vectorizer Module?
A vectorizer is a pluggable module (e.g. text2vec-openai, text2vec-cohere, text2vec-huggingface) that Weaviate calls to convert text into vectors. You choose it when defining a class.
Configuring a Vectorizer
The vectorizer is set in the class schema.
class_def = {
'class': 'Article',
'vectorizer': 'text2vec-openai',
'properties': [
{'name': 'title', 'dataType': ['text']},
{'name': 'body', 'dataType': ['text']}
]
}
print(class_def['vectorizer'])Auto-Embedding on Import
With a vectorizer set, you import plain objects and Weaviate embeds them for you. No need to call an embedding API yourself.
- Send object properties
- Module generates the vector
- Object stored with its vector
Choosing Which Properties to Embed
Not every property should influence the vector. You can skip properties (like IDs or timestamps) so only meaningful text contributes to the embedding.
prop = {
'name': 'sku',
'dataType': ['text'],
'moduleConfig': {'text2vec-openai': {'skip': True}}
}
print('skip embedding:', prop['moduleConfig']['text2vec-openai']['skip'])Including Property Names
By default Weaviate can prepend the property name to its value before embedding. Disabling 'vectorizePropertyName' keeps the vector focused on content rather than field labels.
Bring Your Own Vectors
You can also set vectorizer to 'none' and supply precomputed vectors at import. Useful when you already run a custom embedding pipeline or need a model Weaviate does not host.
Module Configuration
Each vectorizer accepts options in moduleConfig, such as the model name or dimensions. Set them at the class level to control how embeddings are produced.
module_config = {
'text2vec-openai': {'model': 'text-embedding-3-small', 'type': 'text'}
}
print(module_config['text2vec-openai']['model'])Consistency at Query Time
The same vectorizer embeds your query so it lives in the same space as stored objects. This is why mixing models or changing the vectorizer after import breaks search consistency.
Auto vs Manual Trade-offs
When to use each:
- Auto-embedding — simplest, less code, Weaviate manages calls
- Manual vectors — full control, custom models, batch pre-processing
Putting It Together
Pick a vectorizer per class, skip irrelevant properties, configure the model, and let Weaviate auto-embed on import. Or set 'none' to bring your own vectors. Keep the vectorizer consistent between import and query.
Quick Check
Test your understanding of vectorizers.
Recap
You learned that Weaviate vectorizer modules auto-embed objects on import. Configure the module per class, skip non-meaningful properties, set the model in moduleConfig, or use 'none' to bring your own vectors. Keep the vectorizer consistent between import and query for valid search.
常见问题解答
「向量化模块与自动嵌入」课时是免费的吗?
是的 — 「向量化模块与自动嵌入」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 Vector Databases: Pinecone, Weaviate & pgvector 课程的其余内容,请升级到 CoddyKit PRO。 Vector Databases: Pinecone, Weaviate & pgvector 课程共包含 4 节课。
「向量化模块与自动嵌入」这节课中我会学到什么?
学习 Weaviate 的向量化模块如何在导入时自动将数据对象转换为向量,以及如何针对每个类和属性进行配置。 你通过在浏览器中直接运行的动手代码来练习 Vector Databases: Pinecone, Weaviate & pgvector,全天候 AI 导师会在你学习这节课的过程中回答你的问题。
学习 Vector Databases: Pinecone, Weaviate & pgvector 需要有经验吗?
无需任何先前经验。CoddyKit 上的 Vector Databases: Pinecone, Weaviate & pgvector 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 4 节课,共 4 节。
「向量化模块与自动嵌入」课时需要多长时间?
大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。
我能在这节 Vector Databases: Pinecone, Weaviate & pgvector 课中编写并运行代码吗?
能。每节 Vector Databases: Pinecone, Weaviate & pgvector 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。
此课程中的所有课时
- 定义 Weaviate 模式
- 导入数据对象
- Weaviate GraphQL 查询
- 向量化模块与自动嵌入