|
823 | 823 | " print(doc[\"text\"], doc[\"vector_distance\"])" |
824 | 824 | ] |
825 | 825 | }, |
| 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 | + }, |
826 | 863 | { |
827 | 864 | "cell_type": "code", |
828 | 865 | "execution_count": null, |
|
836 | 873 | ], |
837 | 874 | "metadata": { |
838 | 875 | "kernelspec": { |
839 | | - "display_name": "Python 3.8.13 ('redisvl2')", |
| 876 | + "display_name": "redisvl-dev", |
840 | 877 | "language": "python", |
841 | 878 | "name": "python3" |
842 | 879 | }, |
|
852 | 889 | "pygments_lexer": "ipython3", |
853 | 890 | "version": "3.12.2" |
854 | 891 | }, |
855 | | - "orig_nbformat": 4, |
856 | | - "vscode": { |
857 | | - "interpreter": { |
858 | | - "hash": "9b1e6e9c2967143209c2f955cb869d1d3234f92dc4787f49f155f3abbdfb1316" |
859 | | - } |
860 | | - } |
| 892 | + "orig_nbformat": 4 |
861 | 893 | }, |
862 | 894 | "nbformat": 4, |
863 | 895 | "nbformat_minor": 2 |
|
0 commit comments