Skip to content

Commit

Permalink
Split HuggingFace embeddings in HuggingFace API and TextGenerationInf…
Browse files Browse the repository at this point in the history
…erence packages (run-llama#14013)
  • Loading branch information
fersilva16 authored Jun 12, 2024
1 parent 49d5415 commit 7c512fb
Show file tree
Hide file tree
Showing 65 changed files with 2,583 additions and 27 deletions.
1 change: 0 additions & 1 deletion docs/docs/api_reference/embeddings/huggingface.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
options:
members:
- HuggingFaceEmbedding
- HuggingFaceInferenceAPIEmbedding
4 changes: 4 additions & 0 deletions docs/docs/api_reference/embeddings/huggingface_api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
::: llama_index.embeddings.huggingface_api
options:
members:
- HuggingFaceInferenceAPIEmbedding
1 change: 0 additions & 1 deletion docs/docs/api_reference/llms/huggingface.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
::: llama_index.llms.huggingface
options:
members:
- HuggingFaceInferenceAPI
- HuggingFaceLLM
4 changes: 4 additions & 0 deletions docs/docs/api_reference/llms/huggingface_api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
::: llama_index.llms.huggingface_api
options:
members:
- HuggingFaceInferenceAPI
4 changes: 4 additions & 0 deletions docs/docs/api_reference/llms/text_generation_inference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
::: llama_index.llms.text_generation_inference
options:
members:
- TextGenerationInference
5 changes: 3 additions & 2 deletions docs/docs/examples/cookbooks/llama3_cookbook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"source": [
"!pip install llama-index\n",
"!pip install llama-index-llms-huggingface\n",
"!pip install llama-index-embeddings-huggingface"
"!pip install llama-index-embeddings-huggingface\n",
"!pip install llama-index-embeddings-huggingface-api"
]
},
{
Expand Down Expand Up @@ -166,7 +167,7 @@
"source": [
"## You can deploy the model on HF Inference Endpoint and use it\n",
"\n",
"# from llama_index.llms.huggingface import HuggingFaceInferenceAPI\n",
"# from llama_index.llms.huggingface_api import HuggingFaceInferenceAPI\n",
"\n",
"# llm = HuggingFaceInferenceAPI(\n",
"# model_name=\"<HF Inference Endpoint>\",\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/examples/cookbooks/prometheus2_cookbook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"outputs": [],
"source": [
"!pip install llama-index\n",
"!pip install llama-index-llms-huggingface"
"!pip install llama-index-llms-huggingface-api"
]
},
{
Expand Down Expand Up @@ -145,7 +145,7 @@
"metadata": {},
"outputs": [],
"source": [
"from llama_index.llms.huggingface import HuggingFaceInferenceAPI\n",
"from llama_index.llms.huggingface_api import HuggingFaceInferenceAPI\n",
"\n",
"HF_TOKEN = \"YOUR HF TOKEN\"\n",
"HF_ENDPOINT_URL = \"YOUR HF ENDPOINT URL\"\n",
Expand Down
3 changes: 3 additions & 0 deletions docs/docs/examples/embeddings/jina_embeddings.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"outputs": [],
"source": [
"%pip install llama-index-embeddings-huggingface\n",
"%pip install llama-index-embeddings-huggingface-api\n",
"%pip install llama-index-embeddings-openai"
]
},
Expand Down Expand Up @@ -58,6 +59,8 @@
"source": [
"from llama_index.embeddings.huggingface import (\n",
" HuggingFaceEmbedding,\n",
")\n",
"from llama_index.embeddings.huggingface_api import (\n",
" HuggingFaceInferenceAPIEmbedding,\n",
")\n",
"from llama_index.embeddings.openai import OpenAIEmbedding\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/examples/evaluation/prometheus_evaluation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"outputs": [],
"source": [
"%pip install llama-index-llms-openai\n",
"%pip install llama-index-llms-huggingface"
"%pip install llama-index-llms-huggingface-api"
]
},
{
Expand Down Expand Up @@ -146,7 +146,7 @@
}
],
"source": [
"from llama_index.llms.huggingface import HuggingFaceInferenceAPI\n",
"from llama_index.llms.huggingface_api import HuggingFaceInferenceAPI\n",
"\n",
"HF_TOKEN = \"YOUR HF TOKEN\"\n",
"HF_ENDPOINT_URL = (\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"%pip install llama-index-finetuning\n",
"%pip install llama-index-llms-openai\n",
"%pip install llama-index-finetuning-callbacks\n",
"%pip install llama-index-llms-huggingface"
"%pip install llama-index-llms-huggingface-api"
]
},
{
Expand Down Expand Up @@ -265,7 +265,7 @@
],
"source": [
"from llama_index.core.query_engine import RetrieverQueryEngine\n",
"from llama_index.llms.huggingface import HuggingFaceInferenceAPI\n",
"from llama_index.llms.huggingface_api import HuggingFaceInferenceAPI\n",
"\n",
"llm = HuggingFaceInferenceAPI(\n",
" model_name=\"meta-llama/Llama-2-7b-chat-hf\",\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"%pip install llama-index-finetuning\n",
"%pip install llama-index-llms-openai\n",
"%pip install llama-index-finetuning-callbacks\n",
"%pip install llama-index-llms-huggingface"
"%pip install llama-index-llms-huggingface-api"
]
},
{
Expand Down Expand Up @@ -410,7 +410,7 @@
"outputs": [],
"source": [
"from llama_index.core.query_engine import RetrieverQueryEngine\n",
"from llama_index.llms.huggingface import HuggingFaceInferenceAPI\n",
"from llama_index.llms.huggingface_api import HuggingFaceInferenceAPI\n",
"\n",
"\n",
"def create_query_engine(\n",
Expand Down
21 changes: 15 additions & 6 deletions docs/docs/examples/llm/huggingface.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"metadata": {},
"outputs": [],
"source": [
"%pip install llama-index-llms-huggingface"
"%pip install llama-index-llms-huggingface\n",
"%pip install llama-index-llms-huggingface-api"
]
},
{
Expand Down Expand Up @@ -99,10 +100,8 @@
"import os\n",
"from typing import List, Optional\n",
"\n",
"from llama_index.llms.huggingface import (\n",
" HuggingFaceInferenceAPI,\n",
" HuggingFaceLLM,\n",
")\n",
"from llama_index.llms.huggingface import HuggingFaceLLM\n",
"from llama_index.llms.huggingface_api import HuggingFaceInferenceAPI\n",
"\n",
"# SEE: https://huggingface.co/docs/hub/security-tokens\n",
"# We just need a token with read permissions for this demo\n",
Expand Down Expand Up @@ -227,6 +226,16 @@
"The new `TextGenerationInference` class allows to interface with endpoints running [`text-generation-inference`, TGI](https://huggingface.co/docs/text-generation-inference/index). In addition to blazingly fast inference, it supports `tool` usage starting from version `2.0.1`. "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "46c5c06d",
"metadata": {},
"outputs": [],
"source": [
"%pip install llama-index-llms-text-generation-inference"
]
},
{
"cell_type": "markdown",
"id": "055ddcb1",
Expand All @@ -253,7 +262,7 @@
"import os\n",
"from typing import List, Optional\n",
"\n",
"from llama_index.llms.huggingface import (\n",
"from llama_index.llms.text_generation_inference import (\n",
" TextGenerationInference,\n",
")\n",
"\n",
Expand Down
7 changes: 3 additions & 4 deletions docs/docs/examples/node_postprocessor/rankGPT.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"source": [
"%pip install llama-index-postprocessor-rankgpt-rerank\n",
"%pip install llama-index-llms-huggingface\n",
"%pip install llama-index-llms-huggingface-api\n",
"%pip install llama-index-llms-openai\n",
"%pip install llama-index-llms-ollama"
]
Expand Down Expand Up @@ -484,10 +485,8 @@
"from llama_index.core import QueryBundle\n",
"import pandas as pd\n",
"from IPython.display import display, HTML\n",
"from llama_index.llms.huggingface import (\n",
" HuggingFaceInferenceAPI,\n",
" HuggingFaceLLM,\n",
")\n",
"from llama_index.llms.huggingface_api import HuggingFaceInferenceAPI\n",
"from llama_index.llms.huggingface import HuggingFaceLLM\n",
"\n",
"from llama_index.postprocessor.rankgpt_rerank import RankGPTRerank\n",
"\n",
Expand Down
6 changes: 6 additions & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@ nav:
- ./api_reference/embeddings/google.md
- ./api_reference/embeddings/gradient.md
- ./api_reference/embeddings/huggingface.md
- ./api_reference/embeddings/huggingface_api.md
- ./api_reference/embeddings/huggingface_itrex.md
- ./api_reference/embeddings/huggingface_openvino.md
- ./api_reference/embeddings/huggingface_optimum.md
Expand Down Expand Up @@ -839,6 +840,7 @@ nav:
- ./api_reference/llms/gradient.md
- ./api_reference/llms/groq.md
- ./api_reference/llms/huggingface.md
- ./api_reference/llms/huggingface_api.md
- ./api_reference/llms/index.md
- ./api_reference/llms/ipex_llm.md
- ./api_reference/llms/konko.md
Expand Down Expand Up @@ -877,6 +879,7 @@ nav:
- ./api_reference/llms/rungpt.md
- ./api_reference/llms/sagemaker_endpoint.md
- ./api_reference/llms/solar.md
- ./api_reference/llms/text_generation_inference.md
- ./api_reference/llms/together.md
- ./api_reference/llms/unify.md
- ./api_reference/llms/upstage.md
Expand Down Expand Up @@ -1964,6 +1967,9 @@ plugins:
- ../llama-index-integrations/readers/llama-index-readers-azure-devops
- ../llama-index-integrations/retrievers/llama-index-retrievers-duckdb-retriever
- ../llama-index-packs/llama-index-packs-zenguard
- ../llama-index-integrations/embeddings/llama-index-embeddings-huggingface-api
- ../llama-index-integrations/llms/llama-index-llms-text-generation-inference
- ../llama-index-integrations/llms/llama-index-llms-huggingface-api
- redirects:
redirect_maps:
./api/llama_index.vector_stores.MongoDBAtlasVectorSearch.html: api_reference/storage/vector_store/mongodb.md
Expand Down
2 changes: 1 addition & 1 deletion llama-index-core/llama_index/core/embeddings/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
pass

try:
from llama_index.embeddings.huggingface import (
from llama_index.embeddings.huggingface_api import (
HuggingFaceInferenceAPIEmbedding,
) # pants: no-infer-dep

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def build_configured_transformation(
pass

try:
from llama_index.embeddings.huggingface import (
from llama_index.embeddings.huggingface_api import (
HuggingFaceInferenceAPIEmbedding,
) # pants: no-infer-dep

Expand Down
2 changes: 1 addition & 1 deletion llama-index-core/llama_index/core/llms/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
pass

try:
from llama_index.llms.huggingface import (
from llama_index.llms.huggingface_api import (
HuggingFaceInferenceAPI,
) # pants: no-infer-dep

Expand Down
Loading

0 comments on commit 7c512fb

Please sign in to comment.