Edit model card
logo

English

🎉 Introducing TraVisionLM: The First of Its Kind! 🚀

🌟 This is a very fast and small (only 875M parameters) visual language model on Hugging Face that responds to Turkish instructions given an image input! 🌟

✨ Developed compatible with the Transformers library, TRaVisionLM is a breeze to load, fine-tune, and use for lightning-fast inferences—all without needing any external libraries! ⚡️

Ready to experience the Turkish visual language model? Let's go! 🇹🇷🖼️🤖

Türkçe

🎉 TraVisionLM: Türünün İlk Örneği! 🚀

🌟 Çok hızlı ve küçük boyutlu (sadece 875M parametre) Türkçe görsel dil modeli! Bir görüntü ve Türkçe talimat verildiğinde Türkçe yanıt üretir! 🌟

✨ Transformers kütüphanesi ile uyumlu olarak geliştirilen TraVisionLM modeli ile, yükleme, eğitme ve dış kütüphaneler kullanmadan hızlı sonuçlar almak çok kolay! ⚡️

Türkçe görsel dil modelini deneyimlemeye hazır mısınız? Hadi başlayalım! 🇹🇷🖼️🤖

Modeli buradan deneyebilirsiniz: TRaVisionLM-Demo


Model Details

English

This model is a multimodal large language model that combines SigLIP as its vision encoder with GPT2-large as its language model. The vision projector connects the two modalities together. Its architecture closely resembles PaliGemma, with some refined adjustments to the vision projector and the causal language modeling.

Here's the summary of the development process:

  1. Unimodal pretraining
  2. Feature Alignment
    • Following the LLaVA training recipe, I train only the vision projector using 500K image-text pairs to align visual and textual features.
  3. Task Specific Training
    • The aligned model undergoes further training for tasks such as short captioning, detailed captioning, and simple visual question answering, using over 1M image-prompt-completion triplets.
  4. Finetuning on Downstream Tasks
    • Finally, the model is fine-tuned for object detection to demonstrate its versatility in various downstream tasks. Explore the fine-tuned model for object detection at ucsahin/TraVisionLM-Object-Detection-ft for more details.

Türkçe

Bu model, SigLIP görsel kodlayıcısını ve GPT2-large dil modelini birleştiren çok modlu büyük bir dil modelidir. Görsel projektör, iki modaliteyi bir araya getirir. Mimarisi, PaliGemma ile yakından benzerlik gösterir, ancak görsel projektör ve neden-sonuç dil modellemesinde bazı uyarlamalar yapılmıştır.

Geliştirme sürecinin özeti:

  1. Tek Modalite Ön Eğitimi
  2. Özellik Uyarlama
    • LLaVA eğitim tarifesi izlenerek, sadece görsel projektörü 500K görüntü-metin çiftleri ile eğiterek görsel ve metin özelliklerini uyumlu hale getiriyorum.
  3. Görev Spesifik Eğitim
    • Bu adımda, uyumlulaştırılmış model, kısa açıklama, detaylı açıklama ve basit görsel soru cevaplama gibi görevler için daha fazla eğitilmiştir; 1M'den fazla resim-istek-tamamlanma üçlüsünden oluşan veri seti kullanılmıştır.
  4. İndirgeme Görevlerinde İnce Ayar
    • Son olarak, modelin çeşitli görevlerdeki çok yönlülüğünü göstermek amacıyla nesne tespiti için ince ayarı yapılmıştır. Nesne tespiti için ince ayar yapılmış modele detaylar için ucsahin/TraVisionLM-Object-Detection-ft adresinden ulaşabilirsiniz.

Model Description


Uses

Below are the scenarios where the TraVisionLM visual language model can be used directly or indirectly for various tasks. Also, don't forget to check out the section on out-of-scope uses.

Direct Use

  • Short Captioning

You can give the model task instructions like "Açıkla", "Kısaca açıkla", "Görseli özetle", "Çok kısa özetle" etc., for this task. The model will generate a short description of the image you provide. Below, the usage code with the Transformer library is shared.

Important reminder: The model tends to hallucinate less for this task. You can try adjusting the generation parameters to produce the most useful answer for your needs.

  • Detailed Captioning

You can give the model task instructions like "Detaylı açıkla", "Çok detaylı açıkla", "Görseli detaylı anlat", "Görseli çok detaylı anlat" etc., for this task. The model will generate a very detailed description of the image you provide.

Important reminder: The model tends to hallucinate more for this task. Although it generally produces responses related to the image, it may provide details and information that are not present in the image. You can try adjusting the generation parameters to produce the most useful answer for your needs.

  • Visual Question Answering

You can ask the model open-ended questions like "Resmin odağında ne var?", "Görselde adam ne yapıyor?", "Kaç zürafa var?", "Görselle ilgili ne söylenir?", "Görseldeki *obje* ne renk?" etc., for this task. The model will generate responses that complement your question.

Important reminder: The model tends to hallucinate more for this task. Although it generally produces responses related to the image and the question, it may provide details and information that are not present in the image. You can try adjusting the generation parameters to produce the most useful answer for your needs.

Downstream Use [optional]

  • (Video-Text-to-Text) The model can be adapted for a question-answering task related to your videos. By sampling video frames and generating answers for each frame, the model can be used without any changes to the architecture.
  • (Image/Text Retrieval conditioned on Text/Image) For the task of most relevant image retrieval conditioned on text or vice versa, the model can be used directly without any modifications.
  • (Fine-tuning) For all other tasks that support the model's architecture, such as visual classification, the model can be fine-tuned using the Transformers library. For an example, check out ucsahin/TraVisionLM-Object-Detection-ft.

As time permits, I plan to share more applications for these indirect uses. Meanwhile, I eagerly await support or collaboration requests from the community 🤝💪

Out-of-Scope Use

This model is not suitable for the following scenarios:

  • Although the model can answer simple questions related to your images, it is not suitable for multi-turn complex chat scenarios. Past information is not retained; the model does not use previously asked questions as context. However, you can easily train the model for this task by preparing a chat template accordingly.
  • The model does not accept multiple image inputs. For instance, it is not suitable for answering questions that compare two different images. Modifications to the architecture would be necessary to add this feature. For such a model, you can check HuggingFaceM4/idefics2-8b (English only).
  • The model has not been trained for tasks such as character and text recognition (OCR), segmentation, and multi-object detection. To achieve acceptable performance in these tasks, visual language models like google/paligemma-3b-pt-224 and microsoft/Florence-2-large have been trained on billions of documents and images.

Türkçe: Kullanım Alanları

Aşağıda TraVisionLM görsel dil modelinin, hangi görevler için doğrudan ve dolaylı kullanılabileceği durumlar verilmiştir. Ayrıca alan dışı kullanımlar kısmına da göz atmayı unutmayın.

Doğrudan Kullanım Alanları

  • Kısa Açıklama

Bu görev için modele "Açıkla", "Kısaca açıkla", "Görseli özetle", "Çok kısa özetle" ve benzeri görev talimatları verebilirsiniz. Model verdiğiniz resmin kısa bir açıklamasını yapacaktır. Aşağıda modelin Transformer kütüphanesiyle kullanım kodları paylaşılmıştır.

Önemli hatırlatma: Model bu görev için daha az halüsinasyon görmektedir. Kullanırken üretim parametrelerini değiştirerek işinize en çok yarayacak cevabı ürettirmeyi deneyebilirsiniz.

  • Detaylı Açıklama

Bu görev için modele "Detaylı açıkla", "Çok detaylı açıkla", "Görseli detaylı anlat", "Görseli çok detaylı anlat" ve benzeri görev talimatları verebilirsiniz. Model verdiğiniz resmin çok detaylı bir açıklamasını yapacaktır. Aşağıda modelin Transformer kütüphanesiyle kullanım kodları paylaşılmıştır.

Önemli hatırlatma: Model bu görev için genellikle fazla halüsinasyon görmektedir. Genel olarak resimle alakalı cevaplar üretse de, resimde olmayan detaylar ve bilgiler verebilmektedir. Kullanırken üretim parametrelerini değiştirerek işinize en çok yarayacak cevabı ürettirmeyi deneyebilirsiniz.

  • Görsel Soru Cevaplama

Bu görev için modele "Resmin odağında ne var?", "Görselde adam ne yapıyor?", "Kaç zürafa var?", "Görselle ilgili ne söylenir?", "Görseldeki *obje* ne renk?" ve benzeri ucu açık sorular sorabilirsiniz. Model sorunuzu tamamlayacak cevaplar üretecektir. Aşağıda modelin Transformer kütüphanesiyle kullanım kodları paylaşılmıştır.

Önemli hatırlatma: Model bu görev için genellikle fazla halüsinasyon görebilmektedir. Genel olarak resimle ve sorulan soruyla alakalı cevaplar üretse de, resimde olmayan detaylar ve bilgiler verebilmektedir. Kullanırken üretim parametrelerini değiştirerek işinize en çok yarayacak cevabı ürettirmeyi deneyebilirsiniz.

Dolaylı Kullanım Alanları

  • (Video-Text-to-Text) Model videolarınızla ilgili soru cevap görevi için adapte edilebilir. Mimariye hiçbir değişiklik yapmadan, video kareleri örneklenerek, her bir kare üzerinden modele cevap ürettirilebilir.
  • (Retrieval) Metne dayalı en uygun görüntü alma görevi için model, herhangi bir değişiklik yapılmadan doğrudan kullanılabilir.
  • (Finetuning) Model mimarisini destekleyen görsel sınıflandırma gibi geri kalan bütün görevler için model Transformers kütüphanesiyle uyumlu bir şekilde eğitilebilir. Bir örnek için ucsahin/TraVisionLM-Object-Detection-ft adresine bakabilirsiniz.

Zaman buldukça bu dolaylı kullanım uygulamaları ile paylaşımlar yapmayı planlıyorum. Bu sürede topluluktan da destek ya da işbirliği isteklerini dört gözle bekliyorum 🤝💪

Alan-dışı Kullanımlar

Bu modelin aşağıdaki senaryolar için kullanımı uygun değildir:

  • Model, resimlerinizle ilgili basit sorulara cevap verse de, çok turlu kompleks chat senaryoları için uygun değildir. Geçmiş bilgisi tutulmamaktadır, model daha önce sorduğunuz soruları kontekst olarak kullanmamaktadır. Fakat bu görev için, bir chat şablonu hazırlayıp bu doğrultuda kolayca eğitebilirsiniz.
  • Model çoklu görsel girdi kabul etmemektedir. Örneğin, iki farklı resmi karşılaştıran sorulara cevap vermeye uygun değildir. Bu özelliği kazandırmak için mimariye değişiklikler yapmak gerekmektedir. Bu tarz bir model için HuggingFaceM4/idefics2-8b (sadece ingilizce) modeline bakabilirsiniz.
  • Model, karakter ve yazı tanıma (OCR), segmentasyon ve çoklu obje tespit etme görevleri için eğitilmemiştir. Bu görevlerde kabul edilebilir başarılar alabilmek için google/paligemma-3b-pt-224 ve microsoft/Florence-2-large gibi görsel dil modelleri milyarlarca doküman ve resimle eğitilmiştir.

How to Get Started with the Model

In Transformers, you can load the model and do inference as follows:

IMPORTANT NOTE: TraVisionLM model is not yet integrated natively into the Transformers library. So you need to set trust_remote_code=True when loading the model. It will download the configuration_travisionlm.py, modeling_travisionlm.py and processing_travisionlm.py files from the repo. You can check out the content of these files under the Files and Versions tab and pin the specific versions if you have any concerns regarding malicious code.

from transformers import AutoModelForCausalLM, AutoProcessor
import torch
import requests 
from PIL import Image

model = AutoModelForCausalLM.from_pretrained('ucsahin/TraVisionLM-base', trust_remote_code=True, device_map="cuda")
# you can also load the model in bfloat16 or float16
# model = AutoModelForCausalLM.from_pretrained('ucsahin/TraVisionLM-base', trust_remote_code=True, torch_dtype=torch.bfloat16, device_map="cuda")
processor = AutoProcessor.from_pretrained('ucsahin/TraVisionLM-base', trust_remote_code=True)

url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg"
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")

prompt = "Açıkla"  # short caption
# prompt = "Detaylı açıkla"  # detailed caption
# prompt = "Araba ne renktir?" # visual qa
# prompt = "Resmin odak noktası nedir?" # visual qa
# prompt = "Araba nerede duruyor?" # visual qa

inputs = processor(text=prompt, images=image, return_tensors="pt").to("cuda")

outputs = model.generate(**inputs, max_new_tokens=512, do_sample=True, temperature=0.6, top_p=0.9, top_k=50, repetition_penalty=1.2)

output_text = processor.batch_decode(outputs, skip_special_tokens=True)[0]
print("Model response: ", output_text)

You can also perform batch inference as follows (make sure that all images have a prompt text associated with them):

from transformers import AutoModelForCausalLM, AutoProcessor
import torch
import requests 
from PIL import Image

model = AutoModelForCausalLM.from_pretrained('ucsahin/TraVisionLM-base', trust_remote_code=True, device_map="cuda")
# you can also load the model in bfloat16 or float16
# model = AutoModelForCausalLM.from_pretrained('ucsahin/TraVisionLM-base', trust_remote_code=True, torch_dtype=torch.bfloat16, device_map="cuda")
processor = AutoProcessor.from_pretrained('ucsahin/TraVisionLM-base', trust_remote_code=True)

url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg"
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")

prompt_list = [
  'Açıkla',
  'Detaylı açıkla',
  'Araba nerede duruyor?',
  'Arabanın rengi nedir?',
]

inputs = processor(text=prompt_list, images=len(prompt_list)*[image], padding="longest", return_tensors="pt").to("cuda")

outputs = model.generate(**inputs, max_new_tokens=512, do_sample=True, temperature=0.6, top_p=0.9, top_k=50, repetition_penalty=1.2)

output_text_list = processor.batch_decode(outputs, skip_special_tokens=True)

for output_text in output_text_list:
  print(f"Model response: {output_text}\n\n\n")

The output will look like this:

"""
Model response: Açıkla
Bir binanın önünde, sokakta park halindeki mavi bir Volkswagen Beetle.



Model response: Detaylı açıkla
Bu görüntüde, bir taş döşeli sokakta park edilmiş yeşil ve mavi bir Volkswagen Beetle bulunmaktadır. Arka planda iki sarı bina vardır. Araba kameraya doğru bakmaktadır. Görüntü net odaklanmıştır ve renkler canlıdır. Görsel tarzı gerçekçidir.



Model response: Araba nerede duruyor?
Araba, sarı bir binanın yanında sokakta park edilmiş.



Model response: Arabanın rengi nedir?
Araba turkuaz veya limon yeşili renktedir.
"""

Friendly Reminder:

First off, thank you for your interest if you're planning to use this model. I developed it to demonstrate that you can create your own multimodal transformer-based model in a low-resource language like Turkish using only the open-source tools available in the Hugging Face ecosystem. This task would have been nearly impossible without such a platform that supports open-source research and community, so I owe a big thanks 🙏🙏.

As for the model itself, it’s not as powerful as the VLM models developed by companies like Google, Microsoft, or Meta AI.

I worked alone in an environment with limited access to high-quality, diverse multimodal Turkish data. My computing resources were also limited, relying mainly on cloud GPU providers like Colab and Runpod.

So, why create a Turkish Vision Language Model?

My answer is simple, and I’ll break it down into three points:

  1. Large unimodal language models for low-resource languages like Turkish are advancing much faster than their multimodal counterparts. For Turkish, there’s a leaderboard for text models at Turkish LLM-Leaderboard, but nothing similar exists for multimodal models.
  2. On Hugging Face, there isn’t any Image-Text-to-Text model that primarily works in Turkish.
  3. When you use TraVisionLM, you’ll notice it will make many mistakes and hallucinate. But if you ask questions in Turkish to the VLM models from big companies, the answers will often disappoint you. These models are mostly trained on English data, and while they’re multilingual, their performance in languages other than English drops significantly after alignment.

In closing, I hope this model makes a valuable contribution to the open-source Turkish community, and I welcome all your feedback 🤘🤘.

Kullanıcılar için Önemli Bir Hatırlatma:

Öncelikle, bu modeli kullanmayı düşünüyorsanız ilginiz için teşekkür ederim. Bu modeli, Hugging Face ekosisteminde mevcut olan açık kaynak araçları kullanarak, düşük kaynaklı bir dilde (Türkçe gibi) kendi çok modlu transformer tabanlı modelinizi oluşturabileceğinizi göstermek amacıyla geliştirdim. Böyle bir platform olmasaydı, bu iş neredeyse imkansız olurdu, bu yüzden büyük bir teşekkür borçluyum 🙏🙏.

Modelin kendisine gelince, Google, Microsoft veya Meta AI gibi büyük şirketlerin geliştirdiği VLM modelleri kadar güçlü değil.

Modeli geliştirirken, GPU kaynaklarının ve kaliteli, çeşitli çok modlu Türkçe veriye erişimin sınırlı olduğu bir ortamda çalıştım.

Peki, neden Türkçe bir Görsel Dil Modeli geliştirmek gerekiyor?

Cevabım basit, ve bunu üç madde ile açıklamak istiyorum:

  1. Türkçe gibi düşük kaynaklı diller için büyük tek modlu dil modelleri, çok modlu muadillerine göre çok daha hızlı gelişiyor. Türkçe için Turkish LLM-Leaderboard adlı metin modellerinin karşılaştırılmasını içeren bir liderlik tablosu var, ancak çok modlu modeller için böyle bir şey yok.
  2. Hugging Face'te, Transformers kütüphanesiyle uyumlu ve özellikle Türkçe dili için özelleştirilmiş bir Image-Text-to-Text modeli yok.
  3. TraVisionLM'i kullanmaya başladığınızda, fazlaca hatalar yaptığını ve halüsinasyonlar gördüğünü fark edeceksiniz. Ancak, büyük şirketlerin VLM modellerine Türkçe sorular sorduğunuzda, cevaplar çoğu zaman sizi hayal kırıklığına uğratabilmektedir. Bu modeller çoğunlukla İngilizce verilerle eğitilmiştir ve her ne kadar çok dilli olsalar da, hizalama aşamasından sonra İngilizce dışındaki dillerde metin üretme performansları önemli ölçüde düşmektedir.

Daha fazla uzatmadan, bu modelin açık kaynak Türkçe topluluğuna iyi bir katkı sağlayacağını umuyorum ve tüm geri bildirimlerinizi bekliyorum 🤘🤘.

Açık Kaynaklı Diğer Türkçe VLM Modelleri

Bu kısımda benim de daha önce rast geldiğim bu alandaki birkaç çalışmaya kredi vermek istiyorum. Unuttuklarım varsa, haber vermeniz halinde eklenecektir.

  • 99eren99/Turkish-BakLLaVa1.5-Mistral LLaVA eğitim çerçevesinde geliştirilmiş bir Türkçe görsel dil modelidir.
    • Dil modeli olarak Trendyol Mistral v1.0 Chat kullanılmış.
    • TraVisionLM modeline kıyasla 8-10 kat daha fazla parametreli bir model.
    • Model yükleme ve cevap üretme için Transformers kütüphanesi ile doğrudan uyumlu değil.
    • Zaman buldukça iki modelin benzer görevlerdeki performans karşılaştırması yapılabilir.

Training Details

Training Data

I plan to release the multimodal Turkish data used during the training of the model. But, the data in its current format is not ready for publication.

Until then, in order to provide some details regarding the dataset and to contribute to the open-source community, I am releasing the evaluation portion of the dataset at ucsahin/Turkish-VLM-Mix-Benchmark.

The dataset consists of predominantly translated versions of the well-known multimodal datasets from English to Turkish. More information on this will be shared in the future.

Training Procedure

The following training hyperparameters are used in feature alignment and task specific training stages respectively:

  • Feature Alignment
Data size Global Batch Size Learning Rate Epochs Max Length Weight Decay
500K 128 1e-3 1 1024 0
  • Task Specific Training
Data size Global Batch Size Learning Rate Epochs Max Length Weight Decay
1.1M 128 2e-5 3 1024 0

Evaluation

This section will be updated after I get some evaluation results on the ucsahin/Turkish-VLM-Mix-Benchmark.

Testing Data, Factors & Metrics

More on this later...

Compute Infrastructure

The following compute resources are used in feature alignment and task specific training stages respectively:

  • Feature Alignment

1xA100(40GB), took approximately 4 GPU hours.

  • Task Specific Training

1xH100(80GB), took approximately 18 GPU hours.

License and Citation

I am releasing TraVisionLM under the Apache 2.0 License. To the best of my knowledge after through research, this should comply with the datasets and unimodal vision and language models used during development.

However, if I receive any notification indicating otherwise, I will promptly update the licensing information as needed.

If you use the TraVisionLM model in your research, work, or personal projects, please acknowledge this repository. 🙏

Finally, I may plan to publish this work in an academic setting if it reaches a mature state. In that case, I will provide the appropriate citations here so that any future work can appropriately cite it.

Model Card Contact

If you have questions or suggestions regarding the model, I prefer if you would reach me directly via Hugging Face (e.g. opening an issue). But if you have specific things in your mind or any ideas for collaboration on future projects, reach me at sahin.umitcan@gmail.com

Modelle ilgili sorularınız veya önerileriniz varsa, doğrudan bana Hugging Face üzerinden (örneğin, bir issue açarak) ulaşmanızı tercih ederim. Diğer konular veya gelecekteki projelerde işbirliği için herhangi bir fikriniz varsa, bana sahin.umitcan@gmail.com adresinden ulaşabilirsiniz.

Downloads last month
544
Safetensors
Model size
875M params
Tensor type
F32
·
Inference API
Inference API (serverless) does not yet support model repos that contain custom code.

Model tree for ucsahin/TraVisionLM-base

Finetunes
9 models
Quantizations
1 model

Dataset used to train ucsahin/TraVisionLM-base

Space using ucsahin/TraVisionLM-base 1

Collection including ucsahin/TraVisionLM-base