Sponsored by
Vmake Labs Video Enhancer
-Vmake Labs Video Enhancer uses AI to improve video quality, restore details, reduce blur, and upscale videos to 8K.
Patram-7B-Instruct by BharatGen is a 7B parameter vision-language model trained from scratch for visual document understanding. As India’s first document foundation model, it is built to tackle complex document analysis.
The model was trained on a carefully curated instruction-tuned dataset, combining diverse public and custom synthetic data designed to support a broad spectrum of document understanding tasks.
Training Data:
BharatDocs-v1, a dataset of diverse Indian documents + Other Open Source Document Datasets
Supported I/O Formats:
The model currently accepts English-language instructions and image files (e.g., PNG, JPEG) as input. The output is provided in text format.
Language:
English (Indian language support upcoming)
import torch
from transformers import AutoProcessor, AutoModelForCausalLM, GenerationConfig
from PIL import Image
import requests
# Model ID and device setup
model_id = "bharatgenai/patram-7b-instruct"
device = "cuda"if torch.cuda.is_available() else"cpu"# Load processor and model
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id,
trust_remote_code=True
).to(device)
defget_patram_response(image_path_or_url, question):
try:
# Load imageif image_path_or_url.startswith("http"):
image = Image.open(requests.get(image_path_or_url, stream=True).raw).convert("RGB")
else:
image = Image.open(image_path_or_url).convert("RGB")
except Exception as e:
print(f"Error loading image: {e}")
returnNone# Format the prompt as expected
prompt = f"Question: {question} Answer based on the image."try:
# Preprocess image and text using the processor
inputs = processor.process(images=[image], text=prompt)
inputs = {k: v.to(device).unsqueeze(0) for k, v in inputs.items()}
# Generate output using model's generate_from_batch method (Patram-specific)
output = model.generate_from_batch(
inputs,
GenerationConfig(max_new_tokens=200, stop_strings="<|endoftext|>"),
tokenizer=processor.tokenizer
)
# Extract generated tokens (excluding input tokens) and decode
generated_tokens = output[0, inputs['input_ids'].size(1):]
response = processor.tokenizer.decode(generated_tokens, skip_special_tokens=True).strip()
return response
except Exception as e:
print(f"Error during inference: {e}")
returnNone# Example usage:# image_input = "https://knowscope.in/wp-content/uploads/2025/05/cghd-nag.png"# question = "Who issued this notice?"# answer = get_patram_response(image_input, question)# if answer:# print("Answer:", answer)
Note
: If you're trying this on an Apple Silicon (M1/M2/M3/M4/...) chip, please follow the official documentation by PyTorch and Hugging Face for installing dependencies:
patram-7b-instruct huggingface.co is an AI model on huggingface.co that provides patram-7b-instruct's model effect (), which can be used instantly with this bharatgenai patram-7b-instruct model. huggingface.co supports a free trial of the patram-7b-instruct model, and also provides paid use of the patram-7b-instruct. Support call patram-7b-instruct model through api, including Node.js, Python, http.
patram-7b-instruct huggingface.co is an online trial and call api platform, which integrates patram-7b-instruct's modeling effects, including api services, and provides a free online trial of patram-7b-instruct, you can try patram-7b-instruct online for free by clicking the link below.
bharatgenai patram-7b-instruct online free url in huggingface.co:
patram-7b-instruct is an open source model from GitHub that offers a free installation service, and any user can find patram-7b-instruct on GitHub to install. At the same time, huggingface.co provides the effect of patram-7b-instruct install, users can directly use patram-7b-instruct installed effect in huggingface.co for debugging and trial. It also supports api for free installation.