Multimodal Graph retrieval
Project description
Example Usage
from multimodal_rag import MultimodalRAG
# Initialize MultimodalRAG instance
mm_rag = MultimodalRAG(pdf_directory="/path/to/pdf_directory", output_directory="/path/to/output_directory")
# Preprocess documents
mm_rag.preprocess(directory="/path/to/pdf_directory", use_multiprocessing=True)
# Perform a multimodal query
query = "example query text"
search_results, result_paths = mm_rag.multimodal_query(query, k=5)
# Display results
print("Search Results:", search_results)
print("Result Paths:", result_paths)
Multimodal Retrieval (with captioning and image and graph linkage)
from multimodal_rag import MultimodalRetrieval
from langchain_core.documents.base import Document
# Prepare text documents
text_documents = [
Document(page_content="That car was on fire.", metadata={"source": "doc1.pdf", "page": 1}),
Document(page_content="That vehicle is called lava", metadata={"source": "doc2.pdf", "page": 1})
]
# Prepare image paths
image_paths = [
"/content/car.jpg",
"/content/fire.jpg",
]
# Initialize and preprocess
rag = MultimodalRetrieval()
rag.preprocess(text_documents, image_paths, similarity_threshold=0.2)
# Perform a query
query = "that car is fire"
results = rag.query(query, k=3, use_multi_hop=True)
results = rag.query_balanced(query, k_text=3, k_image=3, use_multi_hop=True)
# Print the results
print("Text Results:")
for doc, score in results["text_results"]:
print(f"Content: {doc.page_content}")
print(f"Metadata: {doc.metadata}")
print(f"Score: {score}")
print()
print("Image Results:")
for metadata, score in results["image_results"]:
print(f"Image Path: {metadata['path']}")
print(f"Caption: {metadata['caption']}")
print(f"Score: {score}")
print()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file multimodalgraphretrieval-0.0.1b0.tar.gz
.
File metadata
- Download URL: multimodalgraphretrieval-0.0.1b0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f9c0ef0a116fb85a5ff30d207e8951903fb8e848b9255d24063c8978d9c55b9 |
|
MD5 | 19630ef6701e93b8c926f2d0eebe2a40 |
|
BLAKE2b-256 | 3743ba770cc2caa1ce81263fa47abfd48fa1da7c4fbcea37e5d859088c28d3b6 |
File details
Details for the file MultimodalGraphRetrieval-0.0.1b0-py3-none-any.whl
.
File metadata
- Download URL: MultimodalGraphRetrieval-0.0.1b0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd512f59863e6c2329d46976414fc29edf1469cccd0ec426975fe7b876e02607 |
|
MD5 | 004c16b490d35513580b9c9a49fc2a5a |
|
BLAKE2b-256 | 97f18bc0540c5f67e03c6e99da8a02d4993bfab6264cd8249d88844fb995dd2a |