The H2OVL-Mississippi-800M is a compact yet powerful vision-language model from H2O.ai, featuring 0.8 billion parameters. Despite its small size, it delivers state-of-the-art performance in text recognition, excelling in the Text Recognition segment of OCRBench and outperforming much larger models in this domain. Built upon the robust architecture of our H2O-Danube language models, the Mississippi-800M extends their capabilities by seamlessly integrating vision and language tasks.
Mississippi-2B Benchmarks
Key Features:
0.8 Billion Parameters: Balance between performance and efficiency, making it suitable for OCR and document processing.
Trained on 19 million image-text pairs, with a focus on OCR, document comprehension, and chart, figure, and table interpretation, the model is optimized for superior OCR performance.
Mississippi-2B Benchmarks
Benchmarks
Performance Comparison of Similar Sized Models Across Multiple Benchmarks - OpenVLM Leaderboard
1import torch
2from transformers import AutoConfig, AutoModel, AutoTokenizer
345# Set up the model and tokenizer6model_path ='h2oai/h2ovl-mississippi-800m'7config = AutoConfig.from_pretrained(model_path, trust_remote_code=True)8config.llm_config._attn_implementation ='flash_attention_2'9model = AutoModel.from_pretrained(10 model_path,11 torch_dtype=torch.bfloat16,12 config=config,13 low_cpu_mem_usage=True,14 trust_remote_code=True).eval().cuda()15tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True, use_fast=False)16generation_config =dict(max_new_tokens=2048, do_sample=True)1718# pure-text conversation19question ='Hello, how are you?'20response, history = model.chat(tokenizer,None, question, generation_config, history=None, return_history=True)21print(f'User: {question}\nAssistant: {response}')222324# Example for single image25image_file ='./examples/image.jpg'26question ='<image>\nRead the text in the image.'27response, history = model.chat(tokenizer, image_file, question, generation_config, history=None, return_history=True)28print(f'User: {question}\nAssistant: {response}')2930
Prompt Engineering for JSON Extraction
Overview
This guide demonstrates how to create prompts for extracting information and converting it into structured JSON outputs. It starts with basic examples and progresses to more complex JSON structures, including handling data from images of tables and charts. The objective is to help users design effective prompts that can be used in various applications, such as natural language processing, chatbots, or data extraction from visual inputs.
To get started with JSON extraction from images, it's essential to have a clear understanding of the visual content you want to extract and the structure of the desired JSON output. The following examples will guide you through crafting prompts to achieve this.
Example 1: Extracting Simple Information from an Image
Hypothetical Scenario:
You have an image of a form that contains basic details like "Name," "Date of Birth," and "Address."
Prompt:
Extract the details from the form image and structure them into JSON format:
{
"name": "",
"date_of_birth": "",
"address": ""
}
Expected Output:
json
1{2"name":"John Doe",3"date_of_birth":"1990-01-01",4"address":"1234 Elm Street, Springfield"5}
Example 2: Extracting Nested Information from an Image
Hypothetical Scenario:
You have an image of a form that contains detailed personal information, including contact details and emergency contacts.
Prompt:
Extract the information from the form and format it as follows:
{
"personal_details": {
"name": "",
"age": 0,
"gender": ""
},
"contact": {
"phone": "",
"email": ""
},
"emergency_contact": {
"name": "",
"relation": "",
"phone": ""
}
}
Images of tables often contain structured data that needs to be parsed and converted to JSON. The following example demonstrates how to handle tabular data extraction.
Hypothetical Scenario:
You have an image of a table listing product names, prices, and quantities.
Prompt:
Extract the data from the table image and format it as JSON:
{
"products": [
{
"product_name": "",
"price": "",
"quantity": 0
}
]
}
Charts include metadata and data points that need to be accurately extracted. Here's how to structure prompts to extract chart data from images.
Hypothetical Scenario:
You have an image of a bar chart that shows monthly sales figures.
Prompt:
Extract the details of the bar chart from the image, including the title, axis labels, and data points and format it as JSON:
{
"chart": {
"title": "",
"x_axis": "",
"y_axis": "",
"data_points": [
{
"label": "",
"value": 0
}
]
}
}
Expected Output:
json
1{2"chart":{3"title":"Monthly Sales Report",4"x_axis":"Months",5"y_axis":"Sales (in $)",6"data_points":[7{8"label":"January",9"value":50010},11{12"label":"February",13"value":60014},15{16"label":"March",17"value":70018}19]20}21}
Best Practices
Be Explicit: Clearly define the desired keys and structure in your prompt to avoid ambiguity.
Use Examples: Provide sample outputs so that the system can understand the expected format.
Anticipate Variations: Consider possible variations in the visual data and ensure the prompt can accommodate them.
Start Simple: Begin with simple structures, and progressively increase complexity as needed.
Test and Iterate: Refine your prompts through testing to ensure accuracy and consistency in outputs.
Acknowledgments
We would like to express our gratitude to the InternVL team at OpenGVLab for their research and codebases, upon which we have built and expanded. We also acknowledge the work of the LLaVA team and the Monkey team for their insights and techniques used in improving multimodal models.
Disclaimer
Please read this disclaimer carefully before using the large language model provided in this repository. Your use of the model signifies your agreement to the following terms and conditions.
Biases and Offensiveness: The large language model is trained on a diverse range of internet text data, which may contain biased, racist, offensive, or otherwise inappropriate content. By using this model, you acknowledge and accept that the generated content may sometimes exhibit biases or produce content that is offensive or inappropriate. The developers of this repository do not endorse, support, or promote any such content or viewpoints.
Limitations: The large language model is an AI-based tool and not a human. It may produce incorrect, nonsensical, or irrelevant responses. It is the user's responsibility to critically evaluate the generated content and use it at their discretion.
Use at Your Own Risk: Users of this large language model must assume full responsibility for any consequences that may arise from their use of the tool. The developers and contributors of this repository shall not be held liable for any damages, losses, or harm resulting from the use or misuse of the provided model.
Ethical Considerations: Users are encouraged to use the large language model responsibly and ethically. By using this model, you agree not to use it for purposes that promote hate speech, discrimination, harassment, or any form of illegal or harmful activities.
Reporting Issues: If you encounter any biased, offensive, or otherwise inappropriate content generated by the large language model, please report it to the repository maintainers through the provided channels. Your feedback will help improve the model and mitigate potential issues.
Changes to this Disclaimer: The developers of this repository reserve the right to modify or update this disclaimer at any time without prior notice. It is the user's responsibility to periodically review the disclaimer to stay informed about any changes.
By using the large language model provided in this repository, you agree to accept and comply with the terms and conditions outlined in this disclaimer. If you do not agree with any part of this disclaimer, you should refrain from using the model and any content generated by it.