大家好我是小锋老师最近更新《2027版 1天学会 嵌入模型与Chroma向量数据库 AI大模型应用开发必备知识 视频教程》专辑感谢大家支持。本课程主要介绍和讲解嵌入模型与向量数据库简介Qwen3嵌入模型使用Chroma向量数据库使用Chroma安装Client-Server模式集合添加修改删除查询操作以及自定义Embedding Functions。视频教程课件源码打包下载链接https://pan.baidu.com/s/1Oo7dtFf_Zt7hJyl6aYX6TA?pwd1234提取码1234嵌入模型与Chroma向量数据库 - Chroma安装与简单应用实例 - AI大模型应用开发必备知识我们看下Chroma的快速开始指南可以学习下https://docs.trychroma.com/docs/overview/getting-started安装下ChromaDBpip install chromadb -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com创建ChromDB客户端我们现在用的是默认的内存数据库模式。import chromadb chroma_client chromadb.Client()创建集合集合是用于存储嵌入、文档和任何其他元数据的地方。集合会对嵌入和文档进行索引从而实现高效的检索和过滤。你可以使用以下名称创建一个集合collection chroma_client.create_collection(namemy_collection) # 创建集合添加一些文档数据到集合里去Chroma将自动存储您的文本并处理嵌入和索引。您还可以自定义嵌入模型。您必须为文档提供唯一的字符串ID。collection.add( ids[id1, id2], documents[ This is a document about pineapple, This is a document about oranges ] )查询集合您可以使用一系列查询文本对集合进行查询Chroma将返回n个最相似的结果。就是这么简单results collection.query( query_texts[This is a query document about hawaii], # Chroma will embed this for you n_results2 # how many results to return ) print(results)运行结果默认chroma会自动安装一个all-MiniLM-L6-v2的嵌入模型。C:\Users\caofe\.cache\chroma\onnx_models\all-MiniLM-L6-v2\onnx.tar.gz: 100%|██████████| 79.3M/79.3M [07:1500:00, 191kiB/s] {ids: [[id1, id2]], embeddings: None, documents: [[This is a document about pineapple, This is a document about oranges]], uris: None, included: [metadatas, documents, distances], data: None, metadatas: [[None, None]], distances: [[1.0404009819030762, 1.2430799007415771]]}