LlamaIndex Multi_Modal_Llms Integration: Huggingface
This project integrates Hugging Face's multimodal language models into the LlamaIndex framework, enabling advanced multimodal capabilities for various AI applications.
Features
- Seamless integration of Hugging Face multimodal models with LlamaIndex
- Support for multiple state-of-the-art vision-language models and their finetunes:
- Easy-to-use interface for multimodal tasks like image captioning and visual question answering
- Configurable model parameters for fine-tuned performance
Author of that Integration GitHub | LinkedIn | Email
Installation
pip install llama-index-multi-modal-llms-huggingface
Make sure to set your Hugging Face API token as an environment variable:
export HF_TOKEN=your_huggingface_token_here
Usage
Here's a basic example of how to use the Hugging Face multimodal integration:
from llama_index.multi_modal_llms.huggingface import HuggingFaceMultiModal
from llama_index.core.schema import ImageDocument
# Initialize the model
model = HuggingFaceMultiModal.from_model_name("Qwen/Qwen2-VL-2B-Instruct")
# Prepare your image and prompt
image_document = ImageDocument(image_path="path/to/your/image.jpg")
prompt = "Describe this image in detail."
# Generate a response
response = model.complete(prompt, image_documents=[image_document])
print(response.text)
Streaming
from llama_index.multi_modal_llms.huggingface import HuggingFaceMultiModal
from llama_index.core.schema import ImageDocument
# Initialize the model
model = HuggingFaceMultiModal.from_model_name("Qwen/Qwen2-VL-2B-Instruct")
# Prepare your image and prompt
image_document = ImageDocument(image_path="downloaded_image.jpg")
prompt = "Describe this image in detail."
import nest_asyncio
import asyncio
nest_asyncio.apply()
async def stream_output():
for chunk in model.stream_complete(
prompt, image_documents=[image_document]
):
print(chunk.delta, end="", flush=True)
await asyncio.sleep(0)
asyncio.run(stream_output())
You can also refer to this Colab notebook
Supported Models
- Qwen2 Vision
- Florence2
- Phi3.5 Vision
- PaliGemma
- Mllama
Each model has its unique capabilities and can be selected based on your specific use case.
Configuration
You can configure various parameters when initializing a model:
model = HuggingFaceMultiModal(
model_name="Qwen/Qwen2-VL-2B-Instruct",
device="cuda", # or "cpu"
torch_dtype=torch.float16,
max_new_tokens=100,
temperature=0.7,
)
Limitations
- Async streaming is not supported for any of the models.
- Some models have specific requirements or limitations. Please refer to the individual model classes for details.
Author of that Integration GitHub | LinkedIn | Email
Metadata
Release files for llama-index-multi-modal-llms-huggingface 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llama_index_multi_modal_llms_huggingface-0.5.1.tar.gz | 8.1 kB | Without provenance | Details for llama_index_multi_modal_llms_huggingface-0.5.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llama_index_multi_modal_llms_huggingface-0.5.1-py3-none-any.whl | Python 3 | none | any | Details for llama_index_multi_modal_llms_huggingface-0.5.1-py3-none-any.whl |
Total release size: 16.7 kB
Release files / llama_index_multi_modal_llms_huggingface-0.5.1.tar.gz
| Download URL | llama_index_multi_modal_llms_huggingface-0.5.1.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e84871da7dc3c6ecffc18afb10bee086ee872481a08dcb494adc947617751f8f
|
|
BLAKE2b-256 checksum How to use checksums |
40fc945fc36129ee39a91559c433b0b202e053b11b3a2a2379f42b18452b7acd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.13
|
Release files / llama_index_multi_modal_llms_huggingface-0.5.1-py3-none-any.whl
| Download URL | llama_index_multi_modal_llms_huggingface-0.5.1-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9867c4f3ff4ee0548e809f3cb5038e3afedf7461c4d47953e26546be9fa7c857
|
|
BLAKE2b-256 checksum How to use checksums |
99df020892fc16a2741a410b3f6e97d854b50302bb4b39dba2b6a8d92590d9ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.13
|
Security for llama-index-multi-modal-llms-huggingface 0.5.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.