mirror of
https://github.com/openai/openai-cookbook
synced 2024-11-04 06:00:33 +00:00
Convert back to list only after all np operations
This commit is contained in:
parent
77e104a0c7
commit
1670b76bac
@ -204,8 +204,9 @@
|
||||
" chunk_embeddings.append(get_embedding(chunk, model=model))\n",
|
||||
"\n",
|
||||
" if average:\n",
|
||||
" chunk_embeddings = np.average(chunk_embeddings, axis=0, weights=[len(c) for c in chunk_embeddings]).tolist()\n",
|
||||
" chunk_embeddings = np.average(chunk_embeddings, axis=0, weights=[len(c) for c in chunk_embeddings])\n",
|
||||
" chunk_embeddings = chunk_embeddings / np.linalg.norm(chunk_embeddings) # normalizes length to 1\n",
|
||||
" chunk_embeddings = chunk_embeddings.tolist()\n",
|
||||
" return chunk_embeddings"
|
||||
]
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user