-
-
Notifications
You must be signed in to change notification settings - Fork 11.8k
[doc] Add RAG Integration example #17692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7ab9942
[doc] Add RAG Integration example
reidliu41 dbe5db5
update llamaindex with config
reidliu41 0306fb6
auto generate help
reidliu41 d0ba49e
Merge remote-tracking branch 'upstream/main' into add-rag
reidliu41 ef033cc
add mock imports
reidliu41 7acaf4a
add missing mock imports
reidliu41 9370c3d
correct the name
reidliu41 0ab9508
remove help text
reidliu41 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ helm | |
| lws | ||
| modal | ||
| open-webui | ||
| retrieval-augmented-generation | ||
| skypilot | ||
| streamlit | ||
| triton | ||
|
|
||
148 changes: 148 additions & 0 deletions
148
docs/source/deployment/frameworks/retrieval_augmented_generation.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| (deployment-retrieval-augmented-generation)= | ||
|
|
||
| # Retrieval-Augmented Generation | ||
|
|
||
| [Retrieval-augmented generation (RAG)](https://en.wikipedia.org/wiki/Retrieval-augmented_generation) is a technique that enables generative artificial intelligence (Gen AI) models to retrieve and incorporate new information. It modifies interactions with a large language model (LLM) so that the model responds to user queries with reference to a specified set of documents, using this information to supplement information from its pre-existing training data. This allows LLMs to use domain-specific and/or updated information. Use cases include providing chatbot access to internal company data or generating responses based on authoritative sources. | ||
|
|
||
| Here are the integrations: | ||
| - vLLM + [langchain](https://github.com/langchain-ai/langchain) + [milvus](https://github.com/milvus-io/milvus) | ||
| - vLLM + [llamaindex](https://github.com/run-llama/llama_index) + [milvus](https://github.com/milvus-io/milvus) | ||
|
|
||
| ## vLLM + langchain | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - Setup vLLM and langchain environment | ||
|
|
||
| ```console | ||
| pip install -U vllm \ | ||
| langchain_milvus langchain_openai \ | ||
| langchain_community beautifulsoup4 \ | ||
| langchain-text-splitters | ||
| ``` | ||
|
|
||
| ### Deploy | ||
|
|
||
| - Start the vLLM server with the supported embedding model, e.g. | ||
|
|
||
| ```console | ||
| # Start embedding service (port 8000) | ||
| vllm serve ssmits/Qwen2-7B-Instruct-embed-base | ||
| ``` | ||
|
|
||
| - Start the vLLM server with the supported chat completion model, e.g. | ||
|
|
||
| ```console | ||
| # Start chat service (port 8001) | ||
| vllm serve qwen/Qwen1.5-0.5B-Chat --port 8001 | ||
| ``` | ||
|
|
||
| - Use the script: <gh-file:examples/online_serving/retrieval_augmented_generation_with_langchain.py> | ||
|
|
||
| ```python | ||
| python retrieval_augmented_generation_with_langchain.py --help | ||
| usage: retrieval_augmented_generation_with_langchain.py [-h] [--vllm-api-key VLLM_API_KEY] | ||
| [--vllm-embedding-endpoint VLLM_EMBEDDING_ENDPOINT] | ||
| [--vllm-chat-endpoint VLLM_CHAT_ENDPOINT] | ||
| [--uri URI] [--url URL] | ||
| [--embedding-model EMBEDDING_MODEL] | ||
| [--chat-model CHAT_MODEL] [-i] [-k TOP_K] | ||
| [-c CHUNK_SIZE] [-o CHUNK_OVERLAP] | ||
|
|
||
| RAG Demo with vLLM and langchain | ||
|
|
||
| options: | ||
| -h, --help show this help message and exit | ||
| --vllm-api-key VLLM_API_KEY | ||
| API key for vLLM compatible services | ||
| --vllm-embedding-endpoint VLLM_EMBEDDING_ENDPOINT | ||
| Base URL for embedding service | ||
| --vllm-chat-endpoint VLLM_CHAT_ENDPOINT | ||
| Base URL for chat service | ||
| --uri URI URI for Milvus database | ||
| --url URL URL of the document to process | ||
| --embedding-model EMBEDDING_MODEL | ||
| Model name for embeddings | ||
| --chat-model CHAT_MODEL | ||
| Model name for chat | ||
| -i, --interactive Enable interactive Q&A mode | ||
| -k TOP_K, --top-k TOP_K | ||
| Number of top results to retrieve | ||
| -c CHUNK_SIZE, --chunk-size CHUNK_SIZE | ||
| Chunk size for document splitting | ||
| -o CHUNK_OVERLAP, --chunk-overlap CHUNK_OVERLAP | ||
| Chunk overlap for document splitting | ||
| ``` | ||
|
|
||
| - Run the script | ||
|
|
||
| ```python | ||
| python retrieval_augmented_generation_with_langchain.py | ||
| ``` | ||
|
|
||
| ## vLLM + llamaindex | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - Setup vLLM and llamaindex environment | ||
|
|
||
| ```console | ||
| pip install vllm \ | ||
| llama-index llama-index-readers-web \ | ||
| llama-index-llms-openai-like \ | ||
| llama-index-embeddings-openai-like \ | ||
| llama-index-vector-stores-milvus \ | ||
| ``` | ||
|
|
||
| ### Deploy | ||
|
|
||
| - Start the vLLM server with the supported embedding model, e.g. | ||
|
|
||
| ```console | ||
| # Start embedding service (port 8000) | ||
| vllm serve ssmits/Qwen2-7B-Instruct-embed-base | ||
| ``` | ||
|
|
||
| - Start the vLLM server with the supported chat completion model, e.g. | ||
|
|
||
| ```console | ||
| # Start chat service (port 8001) | ||
| vllm serve qwen/Qwen1.5-0.5B-Chat --port 8001 | ||
| ``` | ||
|
|
||
| - Use the script: <gh-file:examples/online_serving/retrieval_augmented_generation_with_llamaindex.py> | ||
|
|
||
| ```python | ||
| python retrieval_augmented_generation_with_llamaindex.py --help | ||
| usage: retrieval_augmented_generation_with_llamaindex.py [-h] [--url URL] | ||
| [--embedding-model EMBEDDING_MODEL] | ||
| [--chat-model CHAT_MODEL] | ||
| [--vllm-api-key VLLM_API_KEY] | ||
| [--embedding-endpoint EMBEDDING_ENDPOINT] | ||
| [--chat-endpoint CHAT_ENDPOINT] | ||
| [--db-path DB_PATH] [-i] | ||
|
|
||
| RAG with vLLM and LlamaIndex | ||
|
|
||
| options: | ||
| -h, --help show this help message and exit | ||
| --url URL URL of the document to process | ||
| --embedding-model EMBEDDING_MODEL | ||
| Model name for embeddings | ||
| --chat-model CHAT_MODEL | ||
| Model name for chat | ||
| --vllm-api-key VLLM_API_KEY | ||
| API key for vLLM compatible services | ||
| --embedding-endpoint EMBEDDING_ENDPOINT | ||
| Base URL for embedding service | ||
| --chat-endpoint CHAT_ENDPOINT | ||
| Base URL for chat service | ||
| --db-path DB_PATH Path to Milvus database | ||
| -i, --interactive Enable interactive Q&A mode | ||
| ``` | ||
|
|
||
| - Run the script | ||
|
|
||
| ```python | ||
| python retrieval_augmented_generation_with_llamaindex.py | ||
| ``` | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.