import numpy as np
import matplotlib.pyplot as plt
import chromadb
from chromadb.config import Settings
from chromadb.utils import embedding_functions
persist_directory= "./chroma_data"
# 使用本地Qwen3-Embedding-0.6B嵌入模型
custom_embedding = embedding_functions.SentenceTransformerEmbeddingFunction(
model_name="d:\\小说创作\\Qwen3-Embedding-0___6B",
device="cuda" # 若无有GPU则改为"cpu"
)
client = chromadb.PersistentClient(
path=persist_directory,
settings=Settings(anonymized_telemetry=False)
)
# 创建集合时指定自定义嵌入函数
collection = client.get_or_create_collection(
name="tests",
embedding_function=custom_embedding
)
import matplotlib.pyplot as plt
import chromadb
from chromadb.config import Settings
from chromadb.utils import embedding_functions
persist_directory= "./chroma_data"
# 使用本地Qwen3-Embedding-0.6B嵌入模型
custom_embedding = embedding_functions.SentenceTransformerEmbeddingFunction(
model_name="d:\\小说创作\\Qwen3-Embedding-0___6B",
device="cuda" # 若无有GPU则改为"cpu"
)
client = chromadb.PersistentClient(
path=persist_directory,
settings=Settings(anonymized_telemetry=False)
)
# 创建集合时指定自定义嵌入函数
collection = client.get_or_create_collection(
name="tests",
embedding_function=custom_embedding
)

