{
  "id": 581063,
  "title": "Best outputs solution?",
  "content": "<p>I've tried several solutions for this competition, but let's start with my selected submission.</p>\n<h3>Fine-tuned Diffusion model + Vtracer + SVG optimization + multithreading (10 samples per description)…</h3>\n<p>First, I tried fine-tuning SSD both LoRA and full-finetuning, but I couldn't get good results. Then I tried  <a href=\"https://huggingface.co/ostris/Flex.1-alpha\" target=\"_blank\">ostris/Flex.1-alpha</a> an 8B model based on FLUX.1-schnell, and fine-tuned it on 8.5k rasterized svg images. I did a few iterations and got good results, but not good enough. And the model was big and slow.<br>\nThen I fine-tuned <a href=\"https://huggingface.co/Alpha-VLLM/Lumina-Image-2.0\" target=\"_blank\">Alpha-VLLM/Lumina-Image-2.0</a> a 2B DiT model like flux. After a few attempts, I started getting the results I wanted (Fully flat images with minimum details). However the model wasn't fast enough at 1024x1024 and it wasn't producing good results below 768x768. So I adapted the dataset and trained the model to generate from 256x256 and up.</p>\n<p>I used multithreading (I've found a way to avoid the <a href=\"https://www.kaggle.com/competitions/drawing-with-llms/discussion/578877#3201519\" target=\"_blank\">multithreading issue</a> in Kaggle packages) to run inference in parallel on the 2 GPUs and generate 5 images on each at 320x320, used VTracer to convert the image to SVG, and a Node.js local server to optimize the SVG. I repeat the Vtracer + NodeJs optimization iteratively until I get &lt;10K SVG with the least deterioration possible. I then used <a href=\"https://huggingface.co/zhibinlan/LLaVE-2B\" target=\"_blank\">zhibinlan/LLaVE-2B</a> to score prompt alignment and the aesthetic scorer from the metric code and pick the highest scoring output. I also applied a small circle as OCR decoy (from <a href=\"https://www.kaggle.com/richolson\" target=\"_blank\">@richolson</a>'s notebook). Here are a few samples:</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13994348%2Ff64c89e40d1ef8ef9fc2e170325536cf%2FScreenshot%202025-05-28%20at%205.39.17AM.png?generation=1748413441106273&amp;alt=media\"></p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13994348%2F7bf50c7a37473585af14555e5d49c7c2%2FScreenshot%202025-05-28%20at%205.40.36AM.png?generation=1748413489656163&amp;alt=media\"></p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13994348%2F04db032180706bcc75f0dee6572baa3d%2FScreenshot%202025-05-28%20at%205.42.05AM.png?generation=1748413504761566&amp;alt=media\"></p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13994348%2F4903d7ed46e9126940bc311808c15b1b%2FScreenshot%202025-05-28%20at%205.40.46AM.png?generation=1748413539987661&amp;alt=media\"></p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13994348%2F3f06f43e630a5b338cefa391dec2ddc1%2FScreenshot%202025-05-28%20at%205.42.38AM.png?generation=1748413553566975&amp;alt=media\"></p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13994348%2F9217cba822701050e5b5962a22b4ab27%2FScreenshot%202025-05-28%20at%205.43.16AM.png?generation=1748413572751121&amp;alt=media\"></p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13994348%2F0f8b961a2fa56ee78799be81812ee128%2FScreenshot%202025-05-28%20at%205.42.52AM.png?generation=1748413605203746&amp;alt=media\"></p>\n<p>I tried many different methods like generating vqa on the fly and using the metric code to score, removing the OCR decoy, (which affect the aesthetic score) for images that score 1 for OCR, for images that score &lt;0.99, place  the decoy at different corners and get the highest scoring images…. But none helped.<br>\nI also tried a fine-tuned Flux-dev which produced excellent results, better than lumina (the images above), but for some reason I got a lower score 🤷.</p>\n<p>Here is the <a href=\"https://www.kaggle.com/code/sitaberete/new-fork-of-last-730-score-drawing-svg-with-sv?scriptVersionId=242050046\" target=\"_blank\">notebook</a>, but the code is super messy and you will notice that all the methods are defined in the <strong>init</strong> method to avoid the multithreading issue I mentioned above.</p>\n<h3>Qwen 2.5 VL 3B</h3>\n<p>The first solution I tried, and honestly, the one I had the most fun with, was fine-tuning qwen-2.5-VL-3B model. I started by a 2M+ samples dataset from <a href=\"https://huggingface.co/datasets/starvector/text2svg-stack\" target=\"_blank\">starvector/text2svg-stack</a> and spent a few days cleaning, simplifying, and formating the SVG using a specific format that should facilitate learning for LLMs. But the dataset was too noisy and I didn't have the time, resources, and experience to efficiently filter it. And the majority of the SVG where icons and black and white with horrible aesthetic. So I collected a dataset of 8.5k SVG with a decent aesthetic level and that are 10Kb or less (These are the SVGs I rasterized to train the diffusion models). I spent nearly 2 weeks trying to fine-tune it but couldn't get good results. The model was too small from my understanding, at the beginning of the training, see improvements at each checkpoint, but later on it starts to degradate always around the same step count.<br>\nI had the intention when the model learn to generate good enough SVGs to fine-tune it again to teach it to \"think\" with GRPO so that when the initial LLM generates an initial SVG I will feed it to the thinking model to analyze it and refine it iteratively withing it thinking process until it get a good result.</p>\n<p>Although the VLLM approach didn't work, it was what made joining this competition worth it for me, because for the diffusion solution, I spent more time trying to find a way around the issues of the metrics than improving the model.</p>\n<h3>About the Metric code</h3>\n<p>It turned out that the issue isn't only the OCR, after I got stuck at a score of 730 in the public LB, I intentionally decreased the quality of my outputs by aggressively optimizing them to the point where the shapes are almost not noticeable, only the colors where clearly visible, but still got similar scores locally and for some samples even higher score despite the OCR score being 1.0 for all of them.</p>\n<p>Anyways, congrats to all the winners, enjoy it!<br>\nAlso, congrats to <a href=\"https://www.kaggle.com/ryanholbrook\" target=\"_blank\">@ryanholbrook</a> for making the most mediocre competition metrics and sticking to it despite being reported by many (some almost 2 months ago).</p>",
  "comments": [
    {
      "id": 3214161,
      "author_name": "Luiz Henrique Souza Egito",
      "author_url": "",
      "post_date": "2025-05-31T03:53:20.567000",
      "content": "<p>Congratulations, man!! With no disrespect to the other competitors, I saw most of the medalists' notebooks and yours was the best for me in the sense that I wanted to actually create something that would be used and not just find opportunities in the metrics and cheat on them to increase the score, generating something useless later.</p>\n<p>Congratulations!</p>",
      "votes": 1,
      "replies": [
        {
          "id": 3215019,
          "author_name": "sita berete",
          "author_url": "",
          "post_date": "2025-06-01T13:11:38.363000",
          "content": "<p>Thanks man, I think they neglected the robustness of metric and maintained the solutions that used Adversarial attacks because this competition was just to test and get feedback for the new Kaggle package feature, they don't really care about the SVG generation.</p>\n<p>The solutions that won by fulling the VQA model are still interesting, but the competition overview said: </p>\n<blockquote>\n  <p>Given a text prompt describing an image, your task is to generate Scalable Vector Graphics (SVG) code that renders it as an image <strong>as closely as possible</strong>.</p>\n</blockquote>\n<p>But since Kaggle got what they wanted from the competition, I suppose the rest doesn't matter.</p>",
          "votes": 1,
          "replies": []
        }
      ]
    }
  ],
  "comment_count": 2,
  "messages": [
    {
      "id": 3211196,
      "postDate": "2025-05-28T07:22:20.570Z",
      "content": "<p>I've tried several solutions for this competition, but let's start with my selected submission.</p>\n<h3>Fine-tuned Diffusion model + Vtracer + SVG optimization + multithreading (10 samples per description)…</h3>\n<p>First, I tried fine-tuning SSD both LoRA and full-finetuning, but I couldn't get good results. Then I tried  <a href=\"https://huggingface.co/ostris/Flex.1-alpha\" target=\"_blank\">ostris/Flex.1-alpha</a> an 8B model based on FLUX.1-schnell, and fine-tuned it on 8.5k rasterized svg images. I did a few iterations and got good results, but not good enough. And the model was big and slow.<br>\nThen I fine-tuned <a href=\"https://huggingface.co/Alpha-VLLM/Lumina-Image-2.0\" target=\"_blank\">Alpha-VLLM/Lumina-Image-2.0</a> a 2B DiT model like flux. After a few attempts, I started getting the results I wanted (Fully flat images with minimum details). However the model wasn't fast enough at 1024x1024 and it wasn't producing good results below 768x768. So I adapted the dataset and trained the model to generate from 256x256 and up.</p>\n<p>I used multithreading (I've found a way to avoid the <a href=\"https://www.kaggle.com/competitions/drawing-with-llms/discussion/578877#3201519\" target=\"_blank\">multithreading issue</a> in Kaggle packages) to run inference in parallel on the 2 GPUs and generate 5 images on each at 320x320, used VTracer to convert the image to SVG, and a Node.js local server to optimize the SVG. I repeat the Vtracer + NodeJs optimization iteratively until I get &lt;10K SVG with the least deterioration possible. I then used <a href=\"https://huggingface.co/zhibinlan/LLaVE-2B\" target=\"_blank\">zhibinlan/LLaVE-2B</a> to score prompt alignment and the aesthetic scorer from the metric code and pick the highest scoring output. I also applied a small circle as OCR decoy (from <a href=\"https://www.kaggle.com/richolson\" target=\"_blank\">@richolson</a>'s notebook). Here are a few samples:</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13994348%2Ff64c89e40d1ef8ef9fc2e170325536cf%2FScreenshot%202025-05-28%20at%205.39.17AM.png?generation=1748413441106273&amp;alt=media\"></p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13994348%2F7bf50c7a37473585af14555e5d49c7c2%2FScreenshot%202025-05-28%20at%205.40.36AM.png?generation=1748413489656163&amp;alt=media\"></p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13994348%2F04db032180706bcc75f0dee6572baa3d%2FScreenshot%202025-05-28%20at%205.42.05AM.png?generation=1748413504761566&amp;alt=media\"></p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13994348%2F4903d7ed46e9126940bc311808c15b1b%2FScreenshot%202025-05-28%20at%205.40.46AM.png?generation=1748413539987661&amp;alt=media\"></p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13994348%2F3f06f43e630a5b338cefa391dec2ddc1%2FScreenshot%202025-05-28%20at%205.42.38AM.png?generation=1748413553566975&amp;alt=media\"></p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13994348%2F9217cba822701050e5b5962a22b4ab27%2FScreenshot%202025-05-28%20at%205.43.16AM.png?generation=1748413572751121&amp;alt=media\"></p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13994348%2F0f8b961a2fa56ee78799be81812ee128%2FScreenshot%202025-05-28%20at%205.42.52AM.png?generation=1748413605203746&amp;alt=media\"></p>\n<p>I tried many different methods like generating vqa on the fly and using the metric code to score, removing the OCR decoy, (which affect the aesthetic score) for images that score 1 for OCR, for images that score &lt;0.99, place  the decoy at different corners and get the highest scoring images…. But none helped.<br>\nI also tried a fine-tuned Flux-dev which produced excellent results, better than lumina (the images above), but for some reason I got a lower score 🤷.</p>\n<p>Here is the <a href=\"https://www.kaggle.com/code/sitaberete/new-fork-of-last-730-score-drawing-svg-with-sv?scriptVersionId=242050046\" target=\"_blank\">notebook</a>, but the code is super messy and you will notice that all the methods are defined in the <strong>init</strong> method to avoid the multithreading issue I mentioned above.</p>\n<h3>Qwen 2.5 VL 3B</h3>\n<p>The first solution I tried, and honestly, the one I had the most fun with, was fine-tuning qwen-2.5-VL-3B model. I started by a 2M+ samples dataset from <a href=\"https://huggingface.co/datasets/starvector/text2svg-stack\" target=\"_blank\">starvector/text2svg-stack</a> and spent a few days cleaning, simplifying, and formating the SVG using a specific format that should facilitate learning for LLMs. But the dataset was too noisy and I didn't have the time, resources, and experience to efficiently filter it. And the majority of the SVG where icons and black and white with horrible aesthetic. So I collected a dataset of 8.5k SVG with a decent aesthetic level and that are 10Kb or less (These are the SVGs I rasterized to train the diffusion models). I spent nearly 2 weeks trying to fine-tune it but couldn't get good results. The model was too small from my understanding, at the beginning of the training, see improvements at each checkpoint, but later on it starts to degradate always around the same step count.<br>\nI had the intention when the model learn to generate good enough SVGs to fine-tune it again to teach it to \"think\" with GRPO so that when the initial LLM generates an initial SVG I will feed it to the thinking model to analyze it and refine it iteratively withing it thinking process until it get a good result.</p>\n<p>Although the VLLM approach didn't work, it was what made joining this competition worth it for me, because for the diffusion solution, I spent more time trying to find a way around the issues of the metrics than improving the model.</p>\n<h3>About the Metric code</h3>\n<p>It turned out that the issue isn't only the OCR, after I got stuck at a score of 730 in the public LB, I intentionally decreased the quality of my outputs by aggressively optimizing them to the point where the shapes are almost not noticeable, only the colors where clearly visible, but still got similar scores locally and for some samples even higher score despite the OCR score being 1.0 for all of them.</p>\n<p>Anyways, congrats to all the winners, enjoy it!<br>\nAlso, congrats to <a href=\"https://www.kaggle.com/ryanholbrook\" target=\"_blank\">@ryanholbrook</a> for making the most mediocre competition metrics and sticking to it despite being reported by many (some almost 2 months ago).</p>",
      "rawMarkdown": "I've tried several solutions for this competition, but let's start with my selected submission.\n\n### Fine-tuned Diffusion model + Vtracer + SVG optimization + multithreading (10 samples per description)...\nFirst, I tried fine-tuning SSD both LoRA and full-finetuning, but I couldn't get good results. Then I tried  [ostris/Flex.1-alpha](https://huggingface.co/ostris/Flex.1-alpha) an 8B model based on FLUX.1-schnell, and fine-tuned it on 8.5k rasterized svg images. I did a few iterations and got good results, but not good enough. And the model was big and slow.\nThen I fine-tuned [Alpha-VLLM/Lumina-Image-2.0](https://huggingface.co/Alpha-VLLM/Lumina-Image-2.0) a 2B DiT model like flux. After a few attempts, I started getting the results I wanted (Fully flat images with minimum details). However the model wasn't fast enough at 1024x1024 and it wasn't producing good results below 768x768. So I adapted the dataset and trained the model to generate from 256x256 and up.\n\nI used multithreading (I've found a way to avoid the [multithreading issue](https://www.kaggle.com/competitions/drawing-with-llms/discussion/578877#3201519) in Kaggle packages) to run inference in parallel on the 2 GPUs and generate 5 images on each at 320x320, used VTracer to convert the image to SVG, and a Node.js local server to optimize the SVG. I repeat the Vtracer + NodeJs optimization iteratively until I get <10K SVG with the least deterioration possible. I then used [zhibinlan/LLaVE-2B](https://huggingface.co/zhibinlan/LLaVE-2B) to score prompt alignment and the aesthetic scorer from the metric code and pick the highest scoring output. I also applied a small circle as OCR decoy (from @richolson's notebook). Here are a few samples:\n\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13994348%2Ff64c89e40d1ef8ef9fc2e170325536cf%2FScreenshot%202025-05-28%20at%205.39.17AM.png?generation=1748413441106273&alt=media\" width=\"300px\"/>\n\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13994348%2F7bf50c7a37473585af14555e5d49c7c2%2FScreenshot%202025-05-28%20at%205.40.36AM.png?generation=1748413489656163&alt=media\" width=\"300px\"/>\n\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13994348%2F04db032180706bcc75f0dee6572baa3d%2FScreenshot%202025-05-28%20at%205.42.05AM.png?generation=1748413504761566&alt=media\" width=\"300px\"/>\n\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13994348%2F4903d7ed46e9126940bc311808c15b1b%2FScreenshot%202025-05-28%20at%205.40.46AM.png?generation=1748413539987661&alt=media\" width=\"300px\"/>\n\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13994348%2F3f06f43e630a5b338cefa391dec2ddc1%2FScreenshot%202025-05-28%20at%205.42.38AM.png?generation=1748413553566975&alt=media\" width=\"300px\"/>\n\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13994348%2F9217cba822701050e5b5962a22b4ab27%2FScreenshot%202025-05-28%20at%205.43.16AM.png?generation=1748413572751121&alt=media\" width=\"300px\"/>\n\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F13994348%2F0f8b961a2fa56ee78799be81812ee128%2FScreenshot%202025-05-28%20at%205.42.52AM.png?generation=1748413605203746&alt=media\" width=\"300px\"/>\n\nI tried many different methods like generating vqa on the fly and using the metric code to score, removing the OCR decoy, (which affect the aesthetic score) for images that score 1 for OCR, for images that score <0.99, place  the decoy at different corners and get the highest scoring images.... But none helped.\nI also tried a fine-tuned Flux-dev which produced excellent results, better than lumina (the images above), but for some reason I got a lower score 🤷.\n\nHere is the [notebook](https://www.kaggle.com/code/sitaberete/new-fork-of-last-730-score-drawing-svg-with-sv?scriptVersionId=242050046), but the code is super messy and you will notice that all the methods are defined in the __init__ method to avoid the multithreading issue I mentioned above.\n\n### Qwen 2.5 VL 3B\nThe first solution I tried, and honestly, the one I had the most fun with, was fine-tuning qwen-2.5-VL-3B model. I started by a 2M+ samples dataset from [starvector/text2svg-stack](https://huggingface.co/datasets/starvector/text2svg-stack) and spent a few days cleaning, simplifying, and formating the SVG using a specific format that should facilitate learning for LLMs. But the dataset was too noisy and I didn't have the time, resources, and experience to efficiently filter it. And the majority of the SVG where icons and black and white with horrible aesthetic. So I collected a dataset of 8.5k SVG with a decent aesthetic level and that are 10Kb or less (These are the SVGs I rasterized to train the diffusion models). I spent nearly 2 weeks trying to fine-tune it but couldn't get good results. The model was too small from my understanding, at the beginning of the training, see improvements at each checkpoint, but later on it starts to degradate always around the same step count.\nI had the intention when the model learn to generate good enough SVGs to fine-tune it again to teach it to \"think\" with GRPO so that when the initial LLM generates an initial SVG I will feed it to the thinking model to analyze it and refine it iteratively withing it thinking process until it get a good result.\n\nAlthough the VLLM approach didn't work, it was what made joining this competition worth it for me, because for the diffusion solution, I spent more time trying to find a way around the issues of the metrics than improving the model.\n\n### About the Metric code\nIt turned out that the issue isn't only the OCR, after I got stuck at a score of 730 in the public LB, I intentionally decreased the quality of my outputs by aggressively optimizing them to the point where the shapes are almost not noticeable, only the colors where clearly visible, but still got similar scores locally and for some samples even higher score despite the OCR score being 1.0 for all of them.\n\nAnyways, congrats to all the winners, enjoy it!\nAlso, congrats to @ryanholbrook for making the most mediocre competition metrics and sticking to it despite being reported by many (some almost 2 months ago).",
      "votes": 9
    },
    {
      "id": 3214161,
      "postDate": "2025-05-31T03:53:20.567Z",
      "content": "<p>Congratulations, man!! With no disrespect to the other competitors, I saw most of the medalists' notebooks and yours was the best for me in the sense that I wanted to actually create something that would be used and not just find opportunities in the metrics and cheat on them to increase the score, generating something useless later.</p>\n<p>Congratulations!</p>",
      "rawMarkdown": "Congratulations, man!! With no disrespect to the other competitors, I saw most of the medalists' notebooks and yours was the best for me in the sense that I wanted to actually create something that would be used and not just find opportunities in the metrics and cheat on them to increase the score, generating something useless later.\n\nCongratulations!",
      "votes": 1,
      "replies": [
        {
          "id": 3215019,
          "postDate": "2025-06-01T13:11:38.363Z",
          "content": "<p>Thanks man, I think they neglected the robustness of metric and maintained the solutions that used Adversarial attacks because this competition was just to test and get feedback for the new Kaggle package feature, they don't really care about the SVG generation.</p>\n<p>The solutions that won by fulling the VQA model are still interesting, but the competition overview said: </p>\n<blockquote>\n  <p>Given a text prompt describing an image, your task is to generate Scalable Vector Graphics (SVG) code that renders it as an image <strong>as closely as possible</strong>.</p>\n</blockquote>\n<p>But since Kaggle got what they wanted from the competition, I suppose the rest doesn't matter.</p>",
          "rawMarkdown": "Thanks man, I think they neglected the robustness of metric and maintained the solutions that used Adversarial attacks because this competition was just to test and get feedback for the new Kaggle package feature, they don't really care about the SVG generation.\n\nThe solutions that won by fulling the VQA model are still interesting, but the competition overview said: \n>Given a text prompt describing an image, your task is to generate Scalable Vector Graphics (SVG) code that renders it as an image **as closely as possible**.\n\nBut since Kaggle got what they wanted from the competition, I suppose the rest doesn't matter.",
          "votes": 1
        }
      ]
    }
  ],
  "complete": true,
  "source": "live",
  "fetched_at": "2026-10-20T09:09:27Z",
  "competition_id": 89659,
  "competition_slug": "drawing-with-llms",
  "team_id": 13616718,
  "solution_url": "/competitions/drawing-with-llms/writeups/phoenix-2-best-outputs-solution"
}