<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://akshay326.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://akshay326.com/" rel="alternate" type="text/html" /><updated>2026-01-14T19:53:05+00:00</updated><id>https://akshay326.com/feed.xml</id><title type="html">Akshay Sharma</title><subtitle>Welcome to Akshay Sharma&apos;s personal blog. Here you will find my publications, resume, posts/blogs. You can review my open source  contributions, follow my twitter handle, and get my book reading updates. </subtitle><author><name>Akshay Sharma</name></author><entry><title type="html">Chaiverse: Quick Start Guide</title><link href="https://akshay326.com/2024/01/30/submitting-model-chaiverse.html" rel="alternate" type="text/html" title="Chaiverse: Quick Start Guide" /><published>2024-01-30T15:00:00+00:00</published><updated>2024-01-30T15:00:00+00:00</updated><id>https://akshay326.com/2024/01/30/submitting-model-chaiverse</id><content type="html" xml:base="https://akshay326.com/2024/01/30/submitting-model-chaiverse.html"><![CDATA[<h1 id="chaiverse-quick-start-guide">Chaiverse: Quick Start Guide</h1>

<p>Welcome fellow explorer! Today we’ll dive into how as an Machine Learning Engineer, I submitted a fine-tuned model via the revolutionary AI crowdsourcing platform - the Chaiverse. Hold onto your hats, here we go!
Here’s the colab notebook: https://colab.research.google.com/drive/1iBopRkUnF5_R0VUZpxICvgOThAoQP3UR?authuser=3#scrollTo=M4rauAXbTWI1</p>

<h2 id="welcome-to-chaiverse-">Welcome to Chaiverse! 🚀</h2>

<p>Throughout this post, we’re going to walk you through submitting a Huggingface model to Chai, gather real-time user feedback, browse through the Chaiverse leaderboard, retrieve a lost model submission, and deactivate your model(this is for when you’re ready to make your own submission). Buckle up!</p>

<h2 id="installation-and-login-">Installation and Login 👋</h2>

<p>First, we need to install and login to the Chaiverse. For this, you’ll need your developer key, you can obtain this by joining the Chaiverse Discord. Don’t worry about remembering it, your terminal will keep track.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="err">!</span><span class="n">pip</span> <span class="n">install</span> <span class="o">-</span><span class="n">U</span> <span class="n">chaiverse</span>
</code></pre></div></div>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">chaiverse</span> <span class="k">as</span> <span class="n">chai</span>

<span class="n">chai</span><span class="p">.</span><span class="n">developer_login</span><span class="p">()</span>
</code></pre></div></div>

<h2 id="submitting-your-first-model-">Submitting Your First Model 🧑‍🚀</h2>

<p>So, you’re ready to submit your model? Great! To do this, you first need to push your model to Huggingface. In tandem, also push the tokenizer and your model’s architecture configuration. This helps us verify your model type.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">chaiverse</span> <span class="k">as</span> <span class="n">chai</span>

<span class="n">model_url</span> <span class="o">=</span> <span class="s">"ChaiML/phase2_winner_13b2"</span> <span class="c1"># Your model URL
</span>
<span class="n">generation_params</span> <span class="o">=</span> <span class="p">{</span>
    <span class="s">'temperature'</span><span class="p">:</span> <span class="mf">0.99</span><span class="p">,</span>
    <span class="s">'top_p'</span><span class="p">:</span> <span class="mf">0.2</span><span class="p">,</span>
    <span class="s">"top_k"</span><span class="p">:</span> <span class="mi">40</span><span class="p">,</span>
    <span class="s">"stopping_words"</span><span class="p">:</span> <span class="p">[</span><span class="s">'</span><span class="se">\n</span><span class="s">'</span><span class="p">],</span>
    <span class="s">"presence_penalty"</span><span class="p">:</span> <span class="mf">0.5</span><span class="p">,</span>
    <span class="s">"frequency_penalty"</span><span class="p">:</span> <span class="mf">0.5</span><span class="p">,</span>
    <span class="s">"max_input_tokens"</span><span class="p">:</span> <span class="mi">1024</span><span class="p">,</span>
    <span class="s">"best_of"</span><span class="p">:</span> <span class="mi">4</span>
    <span class="p">}</span>
<span class="n">submission_parameters</span> <span class="o">=</span> <span class="p">{</span><span class="s">'model_repo'</span><span class="p">:</span> <span class="n">model_url</span><span class="p">,</span> <span class="s">'generation_params'</span><span class="p">:</span> <span class="n">generation_params</span><span class="p">,</span> <span class="s">'model_name'</span><span class="p">:</span> <span class="s">'my-awesome-llama'</span><span class="p">}</span>

<span class="n">submitter</span> <span class="o">=</span> <span class="n">chai</span><span class="p">.</span><span class="n">ModelSubmitter</span><span class="p">(</span><span class="n">verbose</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">submission_id</span> <span class="o">=</span> <span class="n">submitter</span><span class="p">.</span><span class="n">submit</span><span class="p">(</span><span class="n">submission_parameters</span><span class="p">)</span>
</code></pre></div></div>

<h2 id="chat-with-your-submission-">Chat with Your Submission 💬</h2>

<p>Once submitted, let’s verify your model by chatting with the deployed bots. Choose a bot and start up a conversation.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">chatbot</span> <span class="o">=</span> <span class="n">chai</span><span class="p">.</span><span class="n">SubmissionChatbot</span><span class="p">(</span><span class="n">submission_id</span><span class="p">)</span>
<span class="n">chatbot</span><span class="p">.</span><span class="n">show_available_bots</span><span class="p">()</span>

<span class="n">chatbot</span><span class="p">.</span><span class="n">chat</span><span class="p">(</span><span class="s">'leo'</span><span class="p">,</span> <span class="n">show_model_input</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
</code></pre></div></div>

<h2 id="getting-model-feedback-from-real-life-users-">Getting Model Feedback From Real Life Users 📖</h2>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">model_feedback</span> <span class="o">=</span> <span class="n">chai</span><span class="p">.</span><span class="n">get_feedback</span><span class="p">(</span><span class="n">submission_id</span><span class="p">)</span>
<span class="n">model_feedback</span><span class="p">.</span><span class="n">sample</span><span class="p">()</span>

<span class="n">df</span> <span class="o">=</span> <span class="n">model_feedback</span><span class="p">.</span><span class="n">df</span>
<span class="n">df</span><span class="p">.</span><span class="n">head</span><span class="p">()</span>

<span class="n">raw_data</span> <span class="o">=</span> <span class="n">model_feedback</span><span class="p">.</span><span class="n">raw_data</span>
</code></pre></div></div>
<h2 id="getting-chaiverse-leaderboard-">Getting Chaiverse Leaderboard 🥇</h2>

<p>Wondering how your model is performing? Check the leaderboard.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">leaderboard</span> <span class="o">=</span> <span class="n">chai</span><span class="p">.</span><span class="n">display_leaderboard</span><span class="p">()</span>

<span class="n">leaderboard</span> <span class="o">=</span> <span class="n">chai</span><span class="p">.</span><span class="n">display_leaderboard</span><span class="p">(</span><span class="n">detailed</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
</code></pre></div></div>

<h2 id="retrieving-your-submission-ids--deactivating-models-️">Retrieving Your Submission IDs + Deactivating Models 😶‍🌫️</h2>

<p>Just in case you’ve misplaced your submission IDs, it’s easy to retrieve them.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">submission_ids</span> <span class="o">=</span> <span class="n">chai</span><span class="p">.</span><span class="n">get_my_submissions</span><span class="p">()</span>
<span class="n">submission_ids</span>
</code></pre></div></div>

<h2 id="conclusion">Conclusion</h2>

<p>That wraps up our walkthrough. We’ve covered everything from installations to submitting and evaluating your model. All the best on your journey!</p>

<p>Happy AI building!</p>]]></content><author><name>Akshay Sharma</name></author><summary type="html"><![CDATA[Chaiverse: Quick Start Guide]]></summary></entry><entry><title type="html">Fine-tuning Microsoft’s Phi-2 Machine Learning Model with DPO</title><link href="https://akshay326.com/2024/01/23/microsoft-phi-2-dpo-finetuned.html" rel="alternate" type="text/html" title="Fine-tuning Microsoft’s Phi-2 Machine Learning Model with DPO" /><published>2024-01-23T15:00:00+00:00</published><updated>2024-01-23T15:00:00+00:00</updated><id>https://akshay326.com/2024/01/23/microsoft-phi-2-dpo-finetuned</id><content type="html" xml:base="https://akshay326.com/2024/01/23/microsoft-phi-2-dpo-finetuned.html"><![CDATA[<h1 id="fine-tuning-microsofts-phi-2-machine-learning-model-with-dpo">Fine-tuning Microsoft’s Phi-2 Machine Learning Model with DPO</h1>

<h3 id="introduction">Introduction</h3>
<p>In this blog, we’ll focus on fine-tuning a cutting-edge language model from Microsoft, known as Phi-2, with Differential Privacy Optimization (DPO). We’ll do this using an open-source dataset, modern Python libraries and the power of Google’s Colaboratory. Our code examples are in Python and are designed for simplicity and clarity.</p>

<h3 id="tldr">TL;DR</h3>
<ul>
  <li>Try the model here: https://huggingface.co/akshay326/akshay326-dpo-finetuned-phi-2</li>
  <li>Finetune the model on your own on Google Colab: https://colab.research.google.com/drive/1nwpBZQQGjYjzWpQdBaf3xhk4S8CDpVM4#scrollTo=YpdkZsMNylvp</li>
</ul>

<h3 id="import-necessary-libraries">Import Necessary Libraries</h3>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1"># -*- coding: utf-8 -*-
</span><span class="s">"""Fine-tune Phi-2 model with DPO.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1nwpBZQQGjYjzWpQdBaf3xhk4S8CDpVM4
"""</span>

<span class="err">!</span><span class="n">pip</span> <span class="n">uninstall</span> <span class="o">-</span><span class="n">y</span> <span class="n">transformers</span>
<span class="err">!</span><span class="n">pip</span> <span class="n">install</span> <span class="n">git</span><span class="o">+</span><span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="p">.</span><span class="n">com</span><span class="o">/</span><span class="n">huggingface</span><span class="o">/</span><span class="n">transformers</span>

<span class="err">!</span><span class="n">pip</span> <span class="n">install</span> <span class="o">-</span><span class="n">q</span> <span class="n">datasets</span> <span class="n">trl</span> <span class="n">peft</span> <span class="n">bitsandbytes</span> <span class="n">sentencepiece</span> <span class="n">wandb</span>

<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">gc</span>
<span class="kn">import</span> <span class="nn">torch</span>

<span class="kn">import</span> <span class="nn">transformers</span>
<span class="kn">from</span> <span class="nn">transformers</span> <span class="kn">import</span> <span class="n">AutoModelForCausalLM</span><span class="p">,</span> <span class="n">AutoTokenizer</span><span class="p">,</span> <span class="n">TrainingArguments</span><span class="p">,</span> <span class="n">BitsAndBytesConfig</span>
<span class="kn">from</span> <span class="nn">datasets</span> <span class="kn">import</span> <span class="n">load_dataset</span>
<span class="kn">from</span> <span class="nn">peft</span> <span class="kn">import</span> <span class="n">LoraConfig</span><span class="p">,</span> <span class="n">PeftModel</span><span class="p">,</span> <span class="n">get_peft_model</span><span class="p">,</span> <span class="n">prepare_model_for_kbit_training</span>
<span class="kn">from</span> <span class="nn">trl</span> <span class="kn">import</span> <span class="n">DPOTrainer</span>
<span class="kn">import</span> <span class="nn">bitsandbytes</span> <span class="k">as</span> <span class="n">bnb</span>
<span class="kn">from</span> <span class="nn">google.colab</span> <span class="kn">import</span> <span class="n">userdata</span>
<span class="kn">import</span> <span class="nn">wandb</span>
</code></pre></div></div>
<p>Here, we import an array of deep learning and language modeling libraries, such as Transformers, datasets, and TRL (for DPO-based training).</p>

<h3 id="setup-tokens-and-model-names">Setup Tokens and Model Names</h3>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1"># Defined in the secrets tab in Google Colab
</span><span class="n">hf_token</span> <span class="o">=</span> <span class="n">userdata</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="s">'HF_TOKEN'</span><span class="p">)</span>
<span class="n">wb_token</span> <span class="o">=</span> <span class="n">userdata</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="s">'WANDB_API_KEY'</span><span class="p">)</span>
<span class="n">wandb</span><span class="p">.</span><span class="n">login</span><span class="p">(</span><span class="n">key</span><span class="o">=</span><span class="n">wb_token</span><span class="p">)</span>

<span class="n">model_name</span> <span class="o">=</span> <span class="s">"microsoft/phi-2"</span>
<span class="n">new_model</span> <span class="o">=</span> <span class="s">"akshay326-dpo-finetuned-phi-2"</span>
</code></pre></div></div>
<p>For security purposes, we retrieve the Hugging Face and Weights &amp; Biases tokens from Google Colab’s secrets tab.</p>

<h3 id="load-and-format-the-dataset">Load and Format the Dataset</h3>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">chatml_format</span><span class="p">(</span><span class="n">example</span><span class="p">):</span>
    <span class="c1"># Format system
</span>    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">example</span><span class="p">[</span><span class="s">'system'</span><span class="p">])</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
        <span class="n">message</span> <span class="o">=</span> <span class="p">{</span><span class="s">"role"</span><span class="p">:</span> <span class="s">"system"</span><span class="p">,</span> <span class="s">"content"</span><span class="p">:</span> <span class="n">example</span><span class="p">[</span><span class="s">'system'</span><span class="p">]}</span>
        <span class="n">system</span> <span class="o">=</span> <span class="n">tokenizer</span><span class="p">.</span><span class="n">apply_chat_template</span><span class="p">([</span><span class="n">message</span><span class="p">],</span> <span class="n">tokenize</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="n">system</span> <span class="o">=</span> <span class="s">""</span>

    <span class="k">return</span> <span class="p">{</span>
        <span class="s">"prompt"</span><span class="p">:</span> <span class="n">system</span> <span class="o">+</span> <span class="n">prompt</span><span class="p">,</span>
        <span class="s">"chosen"</span><span class="p">:</span> <span class="n">chosen</span><span class="p">,</span>
        <span class="s">"rejected"</span><span class="p">:</span> <span class="n">rejected</span><span class="p">,</span>
    <span class="p">}</span>

<span class="c1"># Load dataset
</span><span class="n">dataset</span> <span class="o">=</span> <span class="n">load_dataset</span><span class="p">(</span><span class="s">"Intel/orca_dpo_pairs"</span><span class="p">)[</span><span class="s">'train'</span><span class="p">]</span>

<span class="c1"># Tokenizer
</span><span class="n">tokenizer</span> <span class="o">=</span> <span class="n">AutoTokenizer</span><span class="p">.</span><span class="n">from_pretrained</span><span class="p">(</span><span class="n">model_name</span><span class="p">,</span> <span class="n">trust_remote_code</span><span class="o">=</span><span class="bp">True</span><span class="p">,)</span>
<span class="n">tokenizer</span><span class="p">.</span><span class="n">pad_token</span> <span class="o">=</span> <span class="n">tokenizer</span><span class="p">.</span><span class="n">eos_token</span>
<span class="n">tokenizer</span><span class="p">.</span><span class="n">padding_side</span> <span class="o">=</span> <span class="s">"left"</span>

<span class="c1"># Format dataset
</span><span class="n">dataset</span> <span class="o">=</span> <span class="n">dataset</span><span class="p">.</span><span class="nb">map</span><span class="p">(</span>
    <span class="n">chatml_format</span><span class="p">,</span>
    <span class="n">remove_columns</span><span class="o">=</span><span class="n">original_columns</span>
<span class="p">)</span>

<span class="c1"># Print sample
</span><span class="n">dataset</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
</code></pre></div></div>
<p>In this block, we load our training dataset and format it so that it suits our model’s requirements.</p>

<h3 id="training-the-model-with-dpo">Training the Model with DPO</h3>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1"># Training arguments
</span><span class="n">training_args</span> <span class="o">=</span> <span class="n">TrainingArguments</span><span class="p">(</span>
    <span class="n">per_device_train_batch_size</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
    <span class="n">gradient_accumulation_steps</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span>
    <span class="n">gradient_checkpointing</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span>
    <span class="n">learning_rate</span><span class="o">=</span><span class="mf">5e-5</span><span class="p">,</span>
    <span class="n">lr_scheduler_type</span><span class="o">=</span><span class="s">"cosine"</span><span class="p">,</span>
    <span class="n">max_steps</span><span class="o">=</span><span class="mi">200</span><span class="p">,</span>
    <span class="n">save_strategy</span><span class="o">=</span><span class="s">"no"</span><span class="p">,</span>
    <span class="n">logging_steps</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
    <span class="n">output_dir</span><span class="o">=</span><span class="n">new_model</span><span class="p">,</span>
    <span class="n">optim</span><span class="o">=</span><span class="s">"paged_adamw_32bit"</span><span class="p">,</span>
    <span class="n">warmup_steps</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span>
    <span class="n">fp16</span><span class="o">=</span><span class="ow">not</span> <span class="n">HAS_BFLOAT16</span><span class="p">,</span>
    <span class="n">bf16</span><span class="o">=</span><span class="n">HAS_BFLOAT16</span><span class="p">,</span>
    <span class="n">report_to</span><span class="o">=</span><span class="s">"wandb"</span><span class="p">,</span>
<span class="p">)</span>

<span class="c1"># Fine-tune model with DPO
</span><span class="n">dpo_trainer</span><span class="p">.</span><span class="n">train</span><span class="p">()</span>
</code></pre></div></div>
<p>This code chunk contains the main logic to fine-tune the Phi-2 model using Differential Privacy Optimization (DPO). We train the model using various hyperparameters.</p>

<h3 id="saving-uploading-and-inferencing">Saving, Uploading, and Inferencing</h3>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1"># Save artifacts
</span><span class="n">dpo_trainer</span><span class="p">.</span><span class="n">model</span><span class="p">.</span><span class="n">save_pretrained</span><span class="p">(</span><span class="s">"final_checkpoint"</span><span class="p">)</span>
<span class="n">tokenizer</span><span class="p">.</span><span class="n">save_pretrained</span><span class="p">(</span><span class="s">"final_checkpoint"</span><span class="p">)</span>

<span class="c1"># Flush memory
</span><span class="k">del</span> <span class="n">dpo_trainer</span><span class="p">,</span> <span class="n">model</span><span class="p">,</span> <span class="n">ref_model</span>
<span class="n">gc</span><span class="p">.</span><span class="n">collect</span><span class="p">()</span>
<span class="n">torch</span><span class="p">.</span><span class="n">cuda</span><span class="p">.</span><span class="n">empty_cache</span><span class="p">()</span>

<span class="c1"># Merge base model with the adapter
</span><span class="n">model</span> <span class="o">=</span> <span class="n">PeftModel</span><span class="p">.</span><span class="n">from_pretrained</span><span class="p">(</span><span class="n">base_model</span><span class="p">,</span> <span class="s">"final_checkpoint"</span><span class="p">)</span>
<span class="n">model</span> <span class="o">=</span> <span class="n">model</span><span class="p">.</span><span class="n">merge_and_unload</span><span class="p">()</span>

<span class="c1"># Save model and tokenizer
</span><span class="n">model</span><span class="p">.</span><span class="n">save_pretrained</span><span class="p">(</span><span class="n">new_model</span><span class="p">)</span>
<span class="n">tokenizer</span><span class="p">.</span><span class="n">save_pretrained</span><span class="p">(</span><span class="n">new_model</span><span class="p">)</span>

<span class="c1"># Push them to the HF Hub
</span><span class="n">model</span><span class="p">.</span><span class="n">push_to_hub</span><span class="p">(</span><span class="n">new_model</span><span class="p">,</span> <span class="n">use_temp_dir</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">token</span><span class="o">=</span><span class="n">hf_token</span><span class="p">)</span>
<span class="n">tokenizer</span><span class="p">.</span><span class="n">push_to_hub</span><span class="p">(</span><span class="n">new_model</span><span class="p">,</span> <span class="n">use_temp_dir</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">token</span><span class="o">=</span><span class="n">hf_token</span><span class="p">)</span>

<span class="c1"># Generate text
</span><span class="n">sequences</span> <span class="o">=</span> <span class="n">pipeline</span><span class="p">(</span>
    <span class="n">prompt</span><span class="p">,</span>
    <span class="n">do_sample</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span>
    <span class="n">temperature</span><span class="o">=</span><span class="mf">0.7</span><span class="p">,</span>
    <span class="n">top_p</span><span class="o">=</span><span class="mf">0.9</span><span class="p">,</span>
    <span class="n">num_return_sequences</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
    <span class="n">max_length</span><span class="o">=</span><span class="mi">200</span><span class="p">,</span>
<span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="n">sequences</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s">'generated_text'</span><span class="p">])</span>
</code></pre></div></div>
<p>Once the fine-tuning is complete, we save and upload the model using the <code class="language-plaintext highlighter-rouge">push_to_hub</code> method. Then we leverage the <code class="language-plaintext highlighter-rouge">pipeline</code> utility for inferencing and print the resulting text.</p>

<p>That’s it! This post covered how to fine-tune Microsoft’s Phi-2 model using Differential Privacy Optimization. Happy coding!</p>]]></content><author><name>Akshay Sharma</name></author><summary type="html"><![CDATA[Fine-tuning Microsoft’s Phi-2 Machine Learning Model with DPO]]></summary></entry><entry><title type="html">Mistral 7B Document Chat: Your Casual PDF Companion</title><link href="https://akshay326.com/2024/01/11/RAG-mistral-huggingface.html" rel="alternate" type="text/html" title="Mistral 7B Document Chat: Your Casual PDF Companion" /><published>2024-01-11T15:00:00+00:00</published><updated>2024-01-11T15:00:00+00:00</updated><id>https://akshay326.com/2024/01/11/RAG-mistral-huggingface</id><content type="html" xml:base="https://akshay326.com/2024/01/11/RAG-mistral-huggingface.html"><![CDATA[<h1 id="unleashing-mistral-7b-pdf-conversations-made-easy">Unleashing Mistral 7B: PDF Conversations Made Easy!</h1>

<p>Hey, document enthusiasts! 📄 Ready to level up your PDF game? Meet Mistral 7B Document Chat – the coolest sidekick for all your PDF queries.</p>

<p><img width="706" alt="Screenshot 2024-01-11 at 7 44 09 PM" src="https://github.com/akshay326/akshay326.github.io/assets/20796893/6691d7a3-59a3-4993-8060-485acf27d118" /></p>

<h2 id="whats-the-buzz">What’s the Buzz?</h2>

<h3 id="quick-and-casual-pdf-convos">Quick and Casual PDF Convos</h3>

<p>Mistral 7B is all about easy-breezy PDF interactions. Ask questions, throw in follow-ups – this chat gets it! 🚀</p>

<h3 id="references-got-em">References? Got ‘Em!</h3>

<p>Worried about clarity? Fear not! Mistral 7B drops document references in its responses. So, you know where the magic info is stored.</p>

<h2 id="how-to-dive-in">How to Dive In</h2>

<ol>
  <li><strong>Ask Away</strong>: Hit Mistral 7B with your burning PDF questions.</li>
  <li><strong>Chill for Answers</strong>: The AI will cook up responses using its retrieval-augmented magic. 🔮</li>
  <li><strong>Follow-Up Banter</strong>: Keep the convo flowing with follow-up questions.</li>
</ol>

<h2 id="get-your-hands-dirty">Get Your Hands Dirty</h2>

<p>Wanna see it in action? Check out the <a href="https://huggingface.co/spaces/akshay326/Mistral-7B-Doc-Chat">Live Demo</a>. Feeling adventurous? Dive into the <a href="https://github.com/akshay326/Mistral-7B-Doc-Chat">Code</a> and see the behind-the-scenes wizardry.</p>

<h2 id="wrapping-it-up">Wrapping it Up</h2>

<p>Mistral 7B Document Chat is your laid-back PDF buddy. No formalities, just the info you need, when you need it. Try it out and embrace a new era of PDF coolness!</p>

<p>Ready to chat? Head over to the <a href="https://huggingface.co/spaces/akshay326/Mistral-7B-Doc-Chat">Live Demo</a> or peek at the <a href="https://github.com/akshay326/Mistral-7B-Doc-Chat">Code</a>. Let the PDF party begin! 🎉</p>]]></content><author><name>Akshay Sharma</name></author><summary type="html"><![CDATA[Unleashing Mistral 7B: PDF Conversations Made Easy!]]></summary></entry><entry><title type="html">Vertical and Horizontal Scaling in databases</title><link href="https://akshay326.com/2022/01/26/nosql-vs-sql.html" rel="alternate" type="text/html" title="Vertical and Horizontal Scaling in databases" /><published>2022-01-26T19:00:00+00:00</published><updated>2022-01-26T19:00:00+00:00</updated><id>https://akshay326.com/2022/01/26/nosql-vs-sql</id><content type="html" xml:base="https://akshay326.com/2022/01/26/nosql-vs-sql.html"><![CDATA[<p>Before we delve into nature of scaling, let’s dig the history of databases.</p>

<h2 id="nosql-vs-sql">NoSQL v/s SQL</h2>
<p>SQL databases were developed in 1970’s to reduce data duplication since data storage was costly compared to developer/maintaince costs then. NoSQL (or ‘not SQL’) databases were an alternative developed after the internet boom in 2000’s to allow faster scaling, low database maintainence costs, and making schema changes easy.</p>

<h2 id="vertical-vs-horizontal-scaling">Vertical v/s Horizontal Scaling</h2>
<blockquote>
  <p>SQL databases require vertical scaling</p>
</blockquote>

<p>Vertical scaling refers to manipulating resources (compute, storage, etc) built on a rigid base or architecture - schema in the case of a database - to achieve scaling. On the other hand, horizontal scaling means manipulating (adding or removing) replicas of a system to achieve. Advances in semiconductor technology resulted in affordable and larger storage solutions. This was followed in tandem by rapid adoption of cloud technologies.</p>

<h2 id="but-how-scaling-affects-sql-databases">But how scaling affects SQL databases?</h2>
<p>Consider a hypothetical social media company that has a SQL database worth ~100GB in size (on RAM) stored on cloud, say an EC2 instance. If the platform suddenly experienced a ten-fold increase in traffic, it would require increasing the RAM of EC2 instance to 1TB roughly (or a lower value if platform developers come up with a way to optimize database schema in real-time). This might be a costly operation considering that a typical platform with over a million users can garner databases in petabytes!</p>

<p>On the other hand, if the company had a NoSQL database of the same size and experienced a ten-fold increase in traffic, it would require adding nine more EC2 instances with similar instances, orchestrated by Kubernetes or AWS Fargate.</p>

<h2 id="references">References</h2>
<ul>
  <li>https://blog.teamtreehouse.com/should-you-go-beyond-relational-databases</li>
  <li>http://nickcraver.com/blog/2013/11/22/what-it-takes-to-run-stack-overflow</li>
  <li>http://highscalability.com/blog/2010/12/6/what-the-heck-are-you-actually-using-nosql-for.html</li>
</ul>]]></content><author><name>Akshay Sharma</name></author><summary type="html"><![CDATA[Before we delve into nature of scaling, let’s dig the history of databases.]]></summary></entry><entry><title type="html">GSoC’20 - A summer full of optimization and Julia</title><link href="https://akshay326.com/2020/08/23/gsoc2-final.html" rel="alternate" type="text/html" title="GSoC’20 - A summer full of optimization and Julia" /><published>2020-08-23T19:00:00+00:00</published><updated>2020-08-23T19:00:00+00:00</updated><id>https://akshay326.com/2020/08/23/gsoc2-final</id><content type="html" xml:base="https://akshay326.com/2020/08/23/gsoc2-final.html"><![CDATA[<h1 id="latest-updates-on-the-work-done-post-gsoc-tasks">Latest updates on the work done. Post-GSoC tasks</h1>

<p>Hi all! This is the final blog in the series marking my progress in <a href="https://summerofcode.withgoogle.com/projects/#5232064888045568">Differentiable Optimization Problems</a>. You may enjoy:</p>

<ol>
  <li>Reading <a href="http://www.imakshay.com/post/8">my first blog</a>.</li>
  <li>Checking the <a href="http://github.com/AKS1996/DiffOpt.jl">code repository here</a>.</li>
  <li>Reading the docs @ https://aks1996.github.io/DiffOpt.jl/dev/.</li>
</ol>

<h3 id="the-project---progress">The project - progress</h3>
<p>Milestones completed:</p>

<ol>
  <li>Using <a href="https://github.com/jump-dev/MatrixOptInterface.jl">MatrixOptInterface.jl</a> as a dependency in DiffOpt.jl - <a href="https://github.com/AKS1996/DiffOpt.jl/pull/37">PR#37</a></li>
  <li>Fix MathOptSetDistances.jl dependency - <a href="https://github.com/AKS1996/DiffOpt.jl/pull/35">PR#35</a></li>
  <li>Support sparse structures in DiffOpt - <a href="https://github.com/AKS1996/DiffOpt.jl/pull/41">PR#47</a>.  The biggest bottleneck in inducing sparsity was matrix <code class="language-plaintext highlighter-rouge">A</code>; thanks to <a href="https://github.com/blegat">@blegat</a>, I drew inspiration from an <a href="https://github.com/jump-dev/SCS.jl/pull/192">SCS.jl PR</a></li>
  <li>Minor updates in converting MOI model to <a href="https://github.com/jump-dev/MatrixOptInterface.jl">MatrixOptInterface.jl</a> model - <a href="https://github.com/jump-dev/MatrixOptInterface.jl/pull/7">PR#7</a></li>
  <li>Updated docs with manual and examples</li>
</ol>

<h2 id="what-do-we-mean-by-differentiating-a-program">What do we mean by differentiating a program?</h2>
<p>For a primer on differentiable optimization, refer to <a href="https://aks1996.github.io/DiffOpt.jl/dev/intro/">the introduction page</a> in the documentation or this <a href="https://www.youtube.com/watch?v=NrcaNnEXkT8&amp;t=37s">TF Dev Summit’20 video</a>.</p>

<h2 id="what-have-we-achieved-how-can-you-use-it">What have we achieved? How can you use it?</h2>
<p>As of now, one can differentiate:</p>

<ul>
  <li>convex conic programs (with linear objectives), and</li>
  <li>convex quadratic programs (with affine constraints)</li>
</ul>

<p>written in MOI, and the theoretical models rely, respectively, on:</p>

<ul>
  <li><a href="https://arxiv.org/abs/1904.09043">Differentiating Through a Cone Program</a> - Akshay Agrawal, Shane Barratt, Stephen Boyd, Enzo Busseti, Walaa M. Moursi, 2019</li>
  <li><a href="https://arxiv.org/abs/1703.00443">OptNet: Differentiable Optimization as a Layer in Neural Networks</a> = Brandon Amos and J. Zico Kolter, 2017</li>
</ul>

<p>I’ve included some examples (for both the methods) in the documentation, plus plenty of examples (with reference CVXPY code) in <a href="https://github.com/AKS1996/DiffOpt.jl/blob/master/test/MOI_wrapper.jl">the tests folder</a>. For a primer on matrix inversion, I would <a href="https://aks1996.github.io/DiffOpt.jl/dev/matrix-inversion-manual/">suggest this example</a>. If you face any problem, feel free to <a href="https://github.com/AKS1996/DiffOpt.jl/issues">create an issue</a>.</p>

<h2 id="post-gsoc-improvements">Post-GSoC improvements</h2>
<p>Although we’ve almost approached the last week for GSoC, I’ll make sure to improve on the following things post-GSoC too.</p>

<ol>
  <li>Making the code independent of SCS.jl (<a href="https://github.com/AKS1996/DiffOpt.jl/issues/38">Issue#38</a>) - although we did resolve SCS specific code in MatrixOptInterface.jl, but some part of differentiation still relies on SCS specific code. Removing this dependency should generalize differentiation to any available conic solver</li>
  <li>Derivative in terms of ChainRules.jl - this is one of the foremost suggestions by <a href="https://github.com/matbesancon">@matbesancon</a>; although we couldn’t include AD in GSOC timeline well, we’ve begun discussion with <a href="https://github.com/JuliaDiff/ChainRules.jl">ChainRules.jl</a> community</li>
  <li>Time benchmarking - it’ll be really cool to make DiffOpt.jl fast. Started a beginner PR to profile computation time - <a href="https://github.com/AKS1996/DiffOpt.jl/pull/40">PR#40</a></li>
  <li>From MOI to JuMP - since the code is already working with MOI backend, it shouldn’t be hard to differentiate JuMP models too. I’ll be interested in improving the interface and API usage using JuMP</li>
  <li>Many specific improvements in MODistances.jl and MatrixOptInterface.jl</li>
</ol>

<h2 id="final-thoughts">Final thoughts</h2>
<p>I had a really good experience with the GSoC project. As I’ve already mentioned in my previous blog, the JuMP developer community is indeed welcoming and helpful.</p>

<blockquote>
  <p>A shoutout to Julia project maintainers, JuMP developer community, and my mentors!!</p>
</blockquote>

<p>It wouldn’t be wrong to say that at times I was confused with how to make an effective segue from optimization theory to working models. We’ve been able to develop the codebase because of the biweekly GSoC standups, the JuMP developer call, numerous issues/PR discussions, and slack threads.</p>

<blockquote>
  <p>100+ commits, 20+ PRs and 3000+ lines of code and counting</p>
</blockquote>

<p>Finally, I would like to thank Google Summer of Code team for providing us this great learning opportunity amidst the COVID pandemic.</p>]]></content><author><name>Akshay Sharma</name></author><summary type="html"><![CDATA[Latest updates on the work done. Post-GSoC tasks]]></summary></entry><entry><title type="html">GSoC’20 - Create Dependencies and Documentation</title><link href="https://akshay326.com/2020/08/10/gsoc2-w8.html" rel="alternate" type="text/html" title="GSoC’20 - Create Dependencies and Documentation" /><published>2020-08-10T19:00:00+00:00</published><updated>2020-08-10T19:00:00+00:00</updated><id>https://akshay326.com/2020/08/10/gsoc2-w8</id><content type="html" xml:base="https://akshay326.com/2020/08/10/gsoc2-w8.html"><![CDATA[<h1 id="move-diffoptjl-code-to-other-jump-dev-packages-begin-documenting-the-code">Move DiffOpt.jl code to other JuMP-dev packages; Begin documenting the code</h1>

<p>Hi all! This blog is one of a series marking my progress in <a href="https://summerofcode.withgoogle.com/projects/#5232064888045568">Differentiable Optimization Problems</a>. You may enjoy reading <a href="http://www.imakshay.com/post/8">my first blog</a>.</p>

<h3 id="the-project---progress">The project - progress</h3>
<p>Milestones completed:</p>
<ol>
  <li>Adding projections on cones and their derivatives to <a href="https://github.com/matbesancon/MathOptSetDistances.jl">MathOptSetDistances.jl</a> (<a href="https://github.com/matbesancon/MathOptSetDistances.jl/pull/5">PR#5</a>) and using it as a dependency in DiffOpt.jl (<a href="https://github.com/AKS1996/DiffOpt.jl/pull/35">PR#35</a>)</li>
  <li>Moving the matrix builder code to <a href="https://github.com/jump-dev/MatrixOptInterface.jl">MatrixOptInterface.jl</a> - <a href="https://github.com/jump-dev/MatrixOptInterface.jl/pull/7">PR#7</a></li>
  <li>Initial version of documentation - https://aks1996.github.io/DiffOpt.jl/dev/</li>
</ol>

<blockquote>
  <p>Minor contribution (<a href="https://github.com/jump-dev/MathOptInterface.jl/pull/1132">PR#1098</a>) in JuMP Development Sprint :)</p>
</blockquote>

<h2 id="whats-next">What’s next?</h2>
<p>Finaly we arrive at the last two weeks of the summer program. We’ll focus on</p>
<ol>
  <li>Supporting sparse structures to speed up computations - <a href="https://github.com/AKS1996/DiffOpt.jl/issues/31">Issue#31</a></li>
  <li>Comprehensively document the codebase developed</li>
</ol>

<h3 id="staying-in-touch">Staying in touch</h3>
<p>If you’re interested in knowing more about the project, join the <code class="language-plaintext highlighter-rouge">#opt-diff-gsoc</code> channel on <a href="https://discourse.julialang.org/t/announcing-a-julia-slack/4866">julia slack</a>.</p>]]></content><author><name>Akshay Sharma</name></author><summary type="html"><![CDATA[Move DiffOpt.jl code to other JuMP-dev packages; Begin documenting the code]]></summary></entry><entry><title type="html">GSoC’20 - Support Semidefinite constraints</title><link href="https://akshay326.com/2020/07/27/gsoc2-w6.html" rel="alternate" type="text/html" title="GSoC’20 - Support Semidefinite constraints" /><published>2020-07-27T19:00:00+00:00</published><updated>2020-07-27T19:00:00+00:00</updated><id>https://akshay326.com/2020/07/27/gsoc2-w6</id><content type="html" xml:base="https://akshay326.com/2020/07/27/gsoc2-w6.html"><![CDATA[<h1 id="support-sdp-constraints-add-windows-appveyor-build-make-diffoptjl-robust">Support SDP constraints, add windows appveyor build, make DiffOpt.jl robust</h1>

<p>Hi all! This blog is one of a series marking my progress in <a href="https://summerofcode.withgoogle.com/projects/#5232064888045568">Differentiable Optimization Problems</a>.
You may enjoy reading <a href="http://www.imakshay.com/post/8">my first blog</a>.</p>

<h3 id="the-project---progress">The project - progress</h3>
<p>Milestones completed:</p>
<ol>
  <li>Adding appveyor build to CI - <a href="https://github.com/AKS1996/DiffOpt.jl/pull/29">PR #29</a></li>
  <li>Testing the whole <code class="language-plaintext highlighter-rouge">contconic.jl</code> test suite and supporting the latest Julia version on CI - <a href="https://github.com/AKS1996/DiffOpt.jl/pull/28">PR #28</a></li>
  <li>Extracting matrices dynamically and supporting SDP constraints - <a href="https://github.com/AKS1996/DiffOpt.jl/pull/30">PR #30</a></li>
</ol>

<blockquote>
  <p>Bonus: Had JuMP Developer call on July 24th - find the <a href="https://github.com/AKS1996/jump-gsoc-2020/blob/master/JuMP_devcall_24July2020.ipynb">related notebook here</a></p>
</blockquote>

<h2 id="whats-next">What’s next?</h2>
<p>For the next two weeks, we’ll focus on</p>
<ol>
  <li>Adding matrix builder code to <a href="https://github.com/jump-dev/MatrixOptInterface.jl">MatrixOptInterface.jl</a> and using it as a dependency in DiffOpt.jl</li>
  <li>Adding projections on cones and their derivatives to <a href="https://github.com/matbesancon/MathOptSetDistances.jl">MathOptSetDistances.jl</a> and and using it as a dependency in DiffOpt.jl</li>
</ol>

<h3 id="staying-in-touch">Staying in touch</h3>
<p>If you’re interested in knowing more about the project, join the <code class="language-plaintext highlighter-rouge">#opt-diff-gsoc</code> channel on <a href="https://discourse.julialang.org/t/announcing-a-julia-slack/4866">julia slack</a>.</p>]]></content><author><name>Akshay Sharma</name></author><summary type="html"><![CDATA[Support SDP constraints, add windows appveyor build, make DiffOpt.jl robust]]></summary></entry><entry><title type="html">GSoC’20 - Differentiating conic programs</title><link href="https://akshay326.com/2020/07/10/gsoc2-w4.html" rel="alternate" type="text/html" title="GSoC’20 - Differentiating conic programs" /><published>2020-07-10T19:00:00+00:00</published><updated>2020-07-10T19:00:00+00:00</updated><id>https://akshay326.com/2020/07/10/gsoc2-w4</id><content type="html" xml:base="https://akshay326.com/2020/07/10/gsoc2-w4.html"><![CDATA[<h1 id="solving-and-differentiating-convex-conic-programs-wrt-problem-data-improving-solver-interface-and-benchmarking-with-diffcp">Solving and differentiating convex conic programs w.r.t. problem data, improving solver interface, and benchmarking with diffcp</h1>

<p>Hi all! This blog is one of a series marking my progress in <a href="https://summerofcode.withgoogle.com/projects/#5232064888045568">Differentiable Optimization Problems</a>.
You may enjoy reading <a href="http://www.imakshay.com/post/8">my first blog</a>. In this post, I will briefly describe how we enabled <a href="https://github.com/AKS1996/DiffOpt.jl">DiffOpt.jl</a> to differentiate a conic program with an <a href="https://en.wikipedia.org/wiki/Second-order_cone_programming">SOCP constraint</a> and improved the interface by adding more tests.</p>

<h2 id="the-project---progress">The project - progress</h2>
<p>Milestones completed:</p>
<ol>
  <li>Testing solver for quadratic programs <a href="https://github.com/jump-dev/MathOptInterface.jl/blob/master/src/Test/contquadratic.jl">contquadratic.jl</a> - <a href="https://github.com/AKS1996/DiffOpt.jl/pull/19">PR#19</a></li>
  <li>Find projections (and derivatives) on dual cones. Differentiate a simple conic program with an SOCP constraint <a href="https://github.com/AKS1996/DiffOpt.jl/issues/24">Issue#24</a> - <a href="https://github.com/AKS1996/DiffOpt.jl/pull/26">PR#26</a></li>
  <li>Add several MOI tests to improve solver interface - <a href="https://github.com/AKS1996/DiffOpt.jl/pull/28">PR#28</a></li>
</ol>

<h2 id="whats-next">What’s next?</h2>
<p>For the next two weeks, we’ll focus on</p>
<ol>
  <li>Differentating conic programs with <a href="https://en.wikipedia.org/wiki/Semidefinite_programming">SDP constraints</a></li>
  <li>Benchmark differentiation of conic programs with <a href="https://github.com/cvxgrp/diffcp">diffcp</a></li>
</ol>

<h3 id="staying-in-touch">Staying in touch</h3>
<p>If you’re interested in knowing more about the project, join the <code class="language-plaintext highlighter-rouge">#opt-diff-gsoc</code> channel on <a href="https://discourse.julialang.org/t/announcing-a-julia-slack/4866">julia slack</a>.</p>]]></content><author><name>Akshay Sharma</name></author><summary type="html"><![CDATA[Solving and differentiating convex conic programs w.r.t. problem data, improving solver interface, and benchmarking with diffcp]]></summary></entry><entry><title type="html">GSoC’20 - Differentiating LPs and QPs</title><link href="https://akshay326.com/2020/06/29/gsoc2-w2.html" rel="alternate" type="text/html" title="GSoC’20 - Differentiating LPs and QPs" /><published>2020-06-29T19:00:00+00:00</published><updated>2020-06-29T19:00:00+00:00</updated><id>https://akshay326.com/2020/06/29/gsoc2-w2</id><content type="html" xml:base="https://akshay326.com/2020/06/29/gsoc2-w2.html"><![CDATA[<h1 id="creating-an-optimizer-layer-implementing-moi-tests-and-benchmarking-with-qpth-cvxpy">Creating an optimizer layer, implementing MOI tests, and benchmarking with QPTH, CVXPY</h1>

<p>Hi all! This blog is one of a series marking my progress in <a href="https://summerofcode.withgoogle.com/projects/#5232064888045568">Differentiable Optimization Problems</a>.</p>

<p>You may enjoy reading <a href="http://www.imakshay.com/post/8">my first blog</a>. In this post, I will briefly describe the MOI layer we’ve created over <a href="https://github.com/AKS1996/DiffOpt.jl">DiffOpt.jl</a> and how we’be made it more robust by adding more tests - both testing interface usage and benchmarking against existing <a href="https://github.com/locuslab/qpth">QPTH</a> and <a href="https://github.com/cvxgrp/cvxpylayers">CVXPYLayers</a> projects.</p>

<h2 id="the-project---progress">The project - progress</h2>
<p>Milestones completed:</p>
<ol>
  <li>Making DiffOpt robust - Implementing <a href="https://github.com/jump-dev/MathOptInterface.jl/blob/master/src/Test/contlinear.jl">contlinear.jl</a> MOI tests  for linear programs - <a href="https://github.com/AKS1996/DiffOpt.jl/pull/19">PR#19</a></li>
  <li>Turning DiffOpt to a MOI optimization layer <a href="https://github.com/AKS1996/DiffOpt.jl/issues/12">Issue#12</a> - <a href="https://github.com/AKS1996/DiffOpt.jl/pull/18">PR#18</a></li>
</ol>

<h2 id="whats-next">What’s next?</h2>
<p>For the next two weeks, we’ll focus on</p>
<ol>
  <li>Implementing	tests from <a href="https://github.com/jump-dev/MathOptInterface.jl/blob/master/src/Test/contquadratic.jl">contquadratic.jl</a></li>
  <li>Supporting conic programs in DiffOpt</li>
</ol>

<h3 id="staying-in-touch">Staying in touch</h3>
<p>If you’re interested in knowing more about the project, join the <code class="language-plaintext highlighter-rouge">#opt-diff-gsoc</code> channel on <a href="https://discourse.julialang.org/t/announcing-a-julia-slack/4866">julia slack</a>.</p>]]></content><author><name>Akshay Sharma</name></author><summary type="html"><![CDATA[Creating an optimizer layer, implementing MOI tests, and benchmarking with QPTH, CVXPY]]></summary></entry><entry><title type="html">GSoC’20 begins - Differentiable Optimization problems</title><link href="https://akshay326.com/2020/06/13/gsoc2-intro.html" rel="alternate" type="text/html" title="GSoC’20 begins - Differentiable Optimization problems" /><published>2020-06-13T19:00:00+00:00</published><updated>2020-06-13T19:00:00+00:00</updated><id>https://akshay326.com/2020/06/13/gsoc2-intro</id><content type="html" xml:base="https://akshay326.com/2020/06/13/gsoc2-intro.html"><![CDATA[<h1 id="learn-more-about-initial-steps-while-developing-diffoptjl-to-differentiate-some-optimization-problems">Learn more about initial steps while developing DiffOpt.jl to differentiate some optimization problems</h1>

<p>Hi all! I am excited about my project <strong>Differentiable Optimization problems</strong> in Google Summer of Code 2020. This is the 1st blog in a series, which was encouraged by our mentors at NumFOCUS. In this blog, I will share progress about the project and my involvement in the <a href="https://www.juliaopt.org/JuMP.jl/stable/">JuMP.jl</a> community so far. You can find the proposal and more about <a href="https://summerofcode.withgoogle.com/dashboard/project/5232064888045568/details/">the GSoC project here</a>.</p>

<h2 id="all-about-gsoc">All about GSOC</h2>
<p>This is my 2nd time doing a GSoC Project. Before drafting this blog, I reflected upon my previous GSoC project and how I shared my experiences then. If you’re interested in how to apply for GSoC, you can find <a href="http://www.imakshay.com/post/1">all about it here</a>.</p>

<h2 id="why-i-chose-this-project">Why I chose this project?</h2>
<p>At the inception of COVID-19 crises and beginning of a nationwide lockdown in our country, one of my batchmates suggested this project to me. It was enticing to me in first sight as I was pursuing my Master’s project in large scale convex optimization. I began finding more about the project, JuMP, and Julia. As I went through the details of the project - the requirements, deliverables - it became clear to me that it perfectly aligns with my interests. Also, this was a great learning opportunity for me as I was not well versed in Julia and had almost no experience in differentiable optimization.</p>

<h2 id="a-shoutout-to-the-julia-community">A shoutout to the Julia community</h2>
<p>While drafting the GSoC proposal and making initial contributions, I had a excellent experience. Specifically, Julia is a really good language - just after my first few Julia/JuMP scripts, I enjoyed writing models in <em>pure</em> symbolic mathematics. And, the Julia community is welcoming, and I received help from several Julia project maintainers, contributors and my prospective mentors (cheers to Benoît, Joaquim, Mathieu, Mario). It wouldn’t be wrong to say that such a warm experience propelled me to contribute more to this great community!</p>

<h2 id="why-are-differentiable-optimization-problems-important">Why are Differentiable optimization problems important?</h2>
<p>Differentiable optimization is a promising field of convex optimization and has many potential applications in game theory, control theory and machine learning (specifically deep learning - refer <a href="https://www.youtube.com/watch?v=NrcaNnEXkT8">this video</a> for more). Recent work has shown how to differentiate specific subclasses of convex optimization problems. But several applications remain unexplored (refer section 8 of this <a href="https://github.com/bamos/thesis">really good thesis</a>). With the help of automatic differentiation, differentiable optimization can a significant impact on creating end-to-end systems for modelling a neural network, stochastic process, or a game.</p>

<h2 id="the-project---overview">The project - overview</h2>
<p>JuMP is a modeling language for mathematical optimization embedded in Julia. It supports many solvers for a variety of problem classes and has many features. The project aims at equipping JuMP with the ability to differentiate specific convex optimization problems in Julia. In conjunction with <a href="https://summerofcode.withgoogle.com/projects/#5934581011709952">another concurrent GSoC project</a>, we will enable JuMP to differentiate an optimization problem with respect to parameters (for instance, its problem data).</p>

<h2 id="the-project---progress">The project - progress</h2>
<p>The GSoC community bonding period and first two weeks of the GSoC coding period have passed at the time of writing this blog. You can find the <a href="https://github.com/AKS1996/DiffOpt.jl">project repository here (DiffOpt.jl)</a>. Currently, <code class="language-plaintext highlighter-rouge">DiffOpt.jl</code> is able to differentiate LPs and QPs written in MOI, taking references largely <a href="https://locuslab.github.io/qpth/">from QPTH</a>. We are continuous discussion on the slack channel (refer the next section). We are having a bi-weekly catchup call for discussing issues, setting objectives (plus I’m attending JuMP monthly developer call too!)</p>

<p>Our objectives for the next 2 weeks:</p>
<ol>
  <li>Making DiffOpt robust - improving testing on several optimization problems</li>
  <li>Turning DiffOpt to a MOI optimization layer</li>
  <li>Supporting conic programs in DiffOpt</li>
</ol>

<h3 id="staying-in-touch">Staying in touch</h3>
<p>If you’re interested in knowing more about the project, join the <code class="language-plaintext highlighter-rouge">#opt-diff-gsoc</code> channel on <a href="https://discourse.julialang.org/t/announcing-a-julia-slack/4866">julia slack</a>.</p>]]></content><author><name>Akshay Sharma</name></author><summary type="html"><![CDATA[Learn more about initial steps while developing DiffOpt.jl to differentiate some optimization problems]]></summary></entry></feed>