Spaces:
Running
Running
zhangxiyi.amos
commited on
Commit
·
cd36f51
1
Parent(s):
dab847f
feat: remove hidden_state
Browse files
app.py
CHANGED
@@ -38,8 +38,8 @@ def generate(query1, query2, source_code):
|
|
38 |
# 特殊处理 Salesforce/codet5p-110m-embedding 模型
|
39 |
inputs = tokenizer([query1, query2, source_code], padding=True, truncation=True, return_tensors="pt")
|
40 |
with torch.no_grad():
|
41 |
-
|
42 |
-
embeddings =
|
43 |
|
44 |
score1 = cos_sim(embeddings[0], embeddings[2])
|
45 |
score2 = cos_sim(embeddings[1], embeddings[2])
|
|
|
38 |
# 特殊处理 Salesforce/codet5p-110m-embedding 模型
|
39 |
inputs = tokenizer([query1, query2, source_code], padding=True, truncation=True, return_tensors="pt")
|
40 |
with torch.no_grad():
|
41 |
+
embeddings = model6(**inputs) # 这里直接返回嵌入向量
|
42 |
+
embeddings = embeddings.cpu().numpy() # 转换为 NumPy 数组
|
43 |
|
44 |
score1 = cos_sim(embeddings[0], embeddings[2])
|
45 |
score2 = cos_sim(embeddings[1], embeddings[2])
|