{"cells": [{"cell_type": "markdown", "metadata": {}, "source": ["\"在\n"]}, {"cell_type": "markdown", "metadata": {}, "source": ["# Fireworks嵌入\n", "\n", "本指南将向您展示如何通过[Fireworks端点](https://readme.fireworks.ai/)使用Fireworks嵌入。\n"]}, {"cell_type": "markdown", "metadata": {}, "source": ["首先,让我们安装LlamaIndex和Fireworks的依赖项。\n"]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": ["%pip install llama-index-embeddings-fireworks"]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": ["!pip install llama-index"]}, {"cell_type": "markdown", "metadata": {}, "source": ["然后我们可以在Fireworks上查询嵌入。\n"]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": ["from llama_index.embeddings.fireworks import FireworksEmbedding\n", "\n", "embed_model = FireworksEmbedding(api_key=\"YOUR API KEY\", embed_batch_size=10)"]}, {"cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [{"name": "stdout", "output_type": "stream", "text": ["768 [-0.67973792552948, 1.5226128101348877, -3.9547336101531982, 0.3112764358520508, -0.19723102450370789, 1.8839401006698608, -1.1595842838287354, -0.20612922310829163, 0.16740809381008148, -0.9071207046508789]\n"]}], "source": ["# 基本嵌入示例\n", "embeddings = embed_model.get_text_embedding(\"How do I sail to the moon?\")\n", "print(len(embeddings), embeddings[:10])"]}], "metadata": {"kernelspec": {"display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3"}, "language_info": {"codemirror_mode": {"name": "ipython", "version": 3}, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3"}}, "nbformat": 4, "nbformat_minor": 4}