How to use from the
Use from the
Transformers library
# Use a pipeline as a high-level helper
from transformers import pipeline

pipe = pipeline("text-generation", model="RetrO21/agrofinetune")
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
            {"type": "text", "text": "What animal is on the candy?"}
        ]
    },
]
pipe(text=messages)
# Load model directly
from transformers import AutoProcessor, AutoModelForImageTextToText

processor = AutoProcessor.from_pretrained("RetrO21/agrofinetune")
model = AutoModelForImageTextToText.from_pretrained("RetrO21/agrofinetune")
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
            {"type": "text", "text": "What animal is on the candy?"}
        ]
    },
]
inputs = processor.apply_chat_template(
	messages,
	add_generation_prompt=True,
	tokenize=True,
	return_dict=True,
	return_tensors="pt",
).to(model.device)

outputs = model.generate(**inputs, max_new_tokens=40)
print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:]))
Quick Links

Model Card for output

This model is a fine-tuned version of Qwen/Qwen2-VL-2B-Instruct.
It has been trained using TRL and PEFT LoRA.

Quick start

from transformers import pipeline

question = "If you had a time machine, but could only go to the past or the future once and never return, which would you choose and why?"

generator = pipeline(
    "text-generation", 
    model="RetrO21/agrofinetune",  # replace with your repo
    device="cuda"
)

output = generator(
    [{"role": "user", "content": question}],
    max_new_tokens=128,
    return_full_text=False
)[0]

print(output["generated_text"])
Downloads last month
1
Safetensors
Model size
8B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for RetrO21/agrofinetune

Base model

Qwen/Qwen2-VL-2B
Adapter
(154)
this model