Skip to content

Commit 8ae07d1

Browse files
updates vectorizer notebook to include setting dtype example
1 parent 9de0c41 commit 8ae07d1

File tree

1 file changed

+39
-7
lines changed

1 file changed

+39
-7
lines changed

docs/user_guide/vectorizers_04.ipynb

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,43 @@
823823
" print(doc[\"text\"], doc[\"vector_distance\"])"
824824
]
825825
},
826+
{
827+
"cell_type": "markdown",
828+
"metadata": {},
829+
"source": [
830+
"## Selecting your float data type\n",
831+
"When embedding text as byte arrays RedisVL supports 4 different floating point data types, `float16`, `float32`, `float64` and `bfloat16`.\n",
832+
"Your dtype set for your vectorizer must match what is defined in your search index. If one is not explicitly set the default is `float32`."
833+
]
834+
},
835+
{
836+
"cell_type": "code",
837+
"execution_count": null,
838+
"metadata": {},
839+
"outputs": [
840+
{
841+
"data": {
842+
"text/plain": [
843+
"True"
844+
]
845+
},
846+
"execution_count": 4,
847+
"metadata": {},
848+
"output_type": "execute_result"
849+
}
850+
],
851+
"source": [
852+
"vectorizer = HFTextVectorizer(dtype=\"float16\")\n",
853+
"\n",
854+
"# subsequent calls to embed('', as_buffer=True) and embed_many('', as_buffer=True) will now encode as float16\n",
855+
"float16_bytes = vectorizer.embed('test sentence', as_buffer=True)\n",
856+
"\n",
857+
"# you can override this setting on each individual method call\n",
858+
"float64_bytes = vectorizer.embed('test sentence', as_buffer=True, dtype=\"float64\")\n",
859+
"\n",
860+
"float16_bytes != float64_bytes"
861+
]
862+
},
826863
{
827864
"cell_type": "code",
828865
"execution_count": null,
@@ -836,7 +873,7 @@
836873
],
837874
"metadata": {
838875
"kernelspec": {
839-
"display_name": "Python 3.8.13 ('redisvl2')",
876+
"display_name": "redisvl-dev",
840877
"language": "python",
841878
"name": "python3"
842879
},
@@ -852,12 +889,7 @@
852889
"pygments_lexer": "ipython3",
853890
"version": "3.12.2"
854891
},
855-
"orig_nbformat": 4,
856-
"vscode": {
857-
"interpreter": {
858-
"hash": "9b1e6e9c2967143209c2f955cb869d1d3234f92dc4787f49f155f3abbdfb1316"
859-
}
860-
}
892+
"orig_nbformat": 4
861893
},
862894
"nbformat": 4,
863895
"nbformat_minor": 2

0 commit comments

Comments
 (0)