Skip to content

Commit db00587

Browse files
committed
update test embebdding
1 parent 3a37457 commit db00587

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tests/test_openai_embedding.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
# 新版本 opnai
66
client = OpenAI(api_key="EMPTY", base_url="http://localhost:8082/v1")
77
# model: acge_text_embedding yinka zpoint
8-
response = client.embeddings.create(model="bge-m3", input=["我喜欢你", "我也喜欢你"])
8+
response = client.embeddings.create(
9+
model="Conan-embedding-v1", input=["我喜欢你", "我也喜欢你"]
10+
)
911
print(response.data)
1012
embeddings = [np.array(item.embedding) for item in response.data] # 转为NumPy数组
13+
1114
v_a = embeddings[0].reshape(1, -1) # 向量a
1215
v_b = embeddings[1].reshape(-1, 1) # 向量b
16+
print(v_a.shape)
1317
# 计算余弦相似度
1418
similarity = np.dot(v_a, v_b)[0][0]
1519
print(f"余弦相似度: {similarity:.4f}")

0 commit comments

Comments
 (0)