<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>LLM - Tag - Xiaopeng Xu</title><link>https://xu-xp.com/tags/llm/</link><description>LLM - Tag - Xiaopeng Xu</description><generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>xiaopeng.xu@kaust.edu.sa (Xiaopeng Xu)</managingEditor><webMaster>xiaopeng.xu@kaust.edu.sa (Xiaopeng Xu)</webMaster><lastBuildDate>Sat, 24 Feb 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://xu-xp.com/tags/llm/" rel="self" type="application/rss+xml"/><item><title>扩展GPT</title><link>https://xu-xp.com/posts/extend_gpt/</link><pubDate>Sat, 24 Feb 2024 00:00:00 +0000</pubDate><author>xiaopeng.xu@kaust.edu.sa (Xiaopeng Xu)</author><guid>https://xu-xp.com/posts/extend_gpt/</guid><description><![CDATA[<h2 id="lora-轻量-finetune"><strong>LoRA 轻量 finetune</strong></h2>
<p><a href="https://github.com/microsoft/LoRA" target="_blank" rel="noopener noreffer ">https://github.com/microsoft/LoRA</a></p>
<p>LoRA 在预训练大模型，如 GPT， 的主结构外，增加了 adaptor 层，可以用较小的 memory 来 finetune 大模型。如下图，只训练 A 和 B 的参数。</p>
<p></p>
<h3 id="安装"><strong>安装</strong></h3>
<div class="code-block code-line-numbers open" style="counter-reset: code-block 0">
    <div class="code-header language-JSON">
        <span class="code-title"><i class="arrow fas fa-angle-right" aria-hidden="true"></i></span>
        <span class="ellipses"><i class="fas fa-ellipsis-h" aria-hidden="true"></i></span>
        <span class="copy" title="Copy to clipboard"><i class="far fa-copy" aria-hidden="true"></i></span>
    </div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-JSON" data-lang="JSON"><span class="line"><span class="cl"><span class="err">pip</span> <span class="err">install</span> <span class="err">loralib</span></span></span></code></pre></div></div>
<h3 id="使用"><strong>使用</strong></h3>
<h4 id="定义模型"><strong>定义模型</strong></h4>
<p>LoRA 目前只支持几种类型的 layer：<strong>nn.Linear</strong>, <strong>nn.Embedding</strong> 和 <strong>nn.Conv2d</strong>。同时，支持<strong>MergedLinear</strong> 来替换 nn.Linear 表示多层 MLP 的情况。</p>]]></description></item></channel></rss>