We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3a37457 commit db00587Copy full SHA for db00587
tests/test_openai_embedding.py
@@ -5,11 +5,15 @@
5
# 新版本 opnai
6
client = OpenAI(api_key="EMPTY", base_url="http://localhost:8082/v1")
7
# model: acge_text_embedding yinka zpoint
8
-response = client.embeddings.create(model="bge-m3", input=["我喜欢你", "我也喜欢你"])
+response = client.embeddings.create(
9
+ model="Conan-embedding-v1", input=["我喜欢你", "我也喜欢你"]
10
+)
11
print(response.data)
12
embeddings = [np.array(item.embedding) for item in response.data] # 转为NumPy数组
13
+
14
v_a = embeddings[0].reshape(1, -1) # 向量a
15
v_b = embeddings[1].reshape(-1, 1) # 向量b
16
+print(v_a.shape)
17
# 计算余弦相似度
18
similarity = np.dot(v_a, v_b)[0][0]
19
print(f"余弦相似度: {similarity:.4f}")
0 commit comments