Skip to content

Commit

Permalink
add fastembed
Browse files Browse the repository at this point in the history
  • Loading branch information
baniasbaabe committed Oct 22, 2024
1 parent 6d04301 commit 49b0819
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions book/llm/Chapter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,57 @@
"\n",
"results = ranker.rank(query=\"I love you\", docs=[\"I hate you\", \"I really like you\"], doc_ids=[0,1])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Create Embeddings on your CPU with `fastembed`"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"My favourite library for creating embeddings:\n",
"\n",
"`fastembed`, developed by Qdrant.\n",
"\n",
"`fastembed` is a lightweight and fast library for using popular embedding models.\n",
"\n",
"Without using your GPU.\n",
"\n",
"It also integrates seamlessly with Qdrant's vector database.\n",
"\n",
"I would like to see more supported models though, as `fastembed` has so much potential."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pip install fastembed"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from fastembed import TextEmbedding\n",
"\n",
"documents = [\n",
" \"This is some\",\n",
" \"example document\",\n",
"]\n",
"\n",
"embedding_model = TextEmbedding(model_name=\"jinaai/jina-embeddings-v2-small-en\")\n",
"\n",
"embeddings = list(embedding_model.embed(documents))"
]
}
],
"metadata": {
Expand Down

0 comments on commit 49b0819

Please sign in to comment.