Skip to content

Examples and guides for using the OpenAI API

normalizes averaged embeddings to length 1

Ted Sandersd1165a77574a
diff --git a/examples/Embedding_long_inputs.ipynb b/examples/Embedding_long_inputs.ipynb
index 33be8212..fe6b5fab 100644
--- a/examples/Embedding_long_inputs.ipynb
+++ b/examples/Embedding_long_inputs.ipynb
@@ -205,6 +205,7 @@
"\n",
" if average:\n",
" chunk_embeddings = np.average(chunk_embeddings, axis=0, weights=[len(c) for c in chunk_embeddings]).tolist()\n",
+ " chunk_embeddings = chunk_embeddings / np.linalg.norm(chunk_embeddings) # normalizes length to 1\n",
" return chunk_embeddings"
]
},