Skip to content

Commit

Permalink
Change MM Docs and examples (run-llama#9321)
Browse files Browse the repository at this point in the history
  • Loading branch information
hatianzhang authored Dec 5, 2023
1 parent 386b3e7 commit 1f8355e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 16 deletions.
16 changes: 11 additions & 5 deletions docs/examples/multi_modal/gpt4v_multi_modal_retrieval.ipynb

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions docs/examples/multi_modal/image_to_image_retrieval.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,15 @@
"image_store = QdrantVectorStore(\n",
" client=client, collection_name=\"image_collection\"\n",
")\n",
"storage_context = StorageContext.from_defaults(vector_store=text_store)\n",
"storage_context = StorageContext.from_defaults(\n",
" vector_store=text_store, image_store=image_store\n",
")\n",
"\n",
"# Create the MultiModal index\n",
"documents = SimpleDirectoryReader(\"./mixed_wiki/\").load_data()\n",
"index = MultiModalVectorStoreIndex.from_documents(\n",
" documents, storage_context=storage_context, image_vector_store=image_store\n",
" documents,\n",
" storage_context=storage_context,\n",
")"
]
},
Expand Down
5 changes: 3 additions & 2 deletions docs/examples/multi_modal/multi_modal_pdf_tables.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,14 @@
"image_store = QdrantVectorStore(\n",
" client=client, collection_name=\"image_collection\"\n",
")\n",
"storage_context = StorageContext.from_defaults(vector_store=text_store)\n",
"storage_context = StorageContext.from_defaults(\n",
" vector_store=text_store, image_store=image_store\n",
")\n",
"\n",
"# Create the MultiModal index\n",
"index = MultiModalVectorStoreIndex.from_documents(\n",
" documents_images,\n",
" storage_context=storage_context,\n",
" image_vector_store=image_store,\n",
")\n",
"\n",
"retriever_engine = index.as_retriever(image_similarity_top_k=2)"
Expand Down
7 changes: 5 additions & 2 deletions docs/examples/multi_modal/multi_modal_retrieval.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,15 @@
"image_store = QdrantVectorStore(\n",
" client=client, collection_name=\"image_collection\"\n",
")\n",
"storage_context = StorageContext.from_defaults(vector_store=text_store)\n",
"storage_context = StorageContext.from_defaults(\n",
" vector_store=text_store, image_store=image_store\n",
")\n",
"\n",
"# Create the MultiModal index\n",
"documents = SimpleDirectoryReader(\"./data_wiki/\").load_data()\n",
"index = MultiModalVectorStoreIndex.from_documents(\n",
" documents, storage_context=storage_context, image_vector_store=image_store\n",
" documents,\n",
" storage_context=storage_context,\n",
")"
]
},
Expand Down
14 changes: 9 additions & 5 deletions docs/module_guides/models/multi_modal.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ image_store = QdrantVectorStore(
client=client, collection_name="image_collection"
)

# if you only need image_store for image retrieval,
# don't need to pass text_store for StorageContext
storage_context = StorageContext.from_defaults(vector_store=text_store)
# storage_context = StorageContext.from_defaults()
storage_context = StorageContext.from_defaults(
vector_store=text_store, image_store=image_store
)

# Load text and image documents from local folder
documents = SimpleDirectoryReader("./data_folder/").load_data()
# Create the MultiModal index
index = MultiModalVectorStoreIndex.from_documents(
documents, storage_context=storage_context, image_vector_store=image_store
documents,
storage_context=storage_context,
)
```

Expand All @@ -83,6 +83,10 @@ retriever_engine = index.as_retriever(
# retrieve more information from the GPT4V response
retrieval_results = retriever_engine.retrieve(response)

# if you only need image retrieval without text retrieval
# you can use `text_to_image_retrieve`
# retrieval_results = retriever_engine.text_to_image_retrieve(response)

qa_tmpl_str = (
"Context information is below.\n"
"---------------------\n"
Expand Down

0 comments on commit 1f8355e

Please sign in to comment.