Skip to content

Commit

Permalink
Updated docs to contain SetFit
Browse files Browse the repository at this point in the history
  • Loading branch information
x-tabdeveloping committed Aug 18, 2023
1 parent 6541831 commit d278b7f
Show file tree
Hide file tree
Showing 18 changed files with 642 additions and 22 deletions.
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/_build/doctrees/index.doctree
Binary file not shown.
Binary file added docs/_build/doctrees/setfit.doctree
Binary file not shown.
11 changes: 7 additions & 4 deletions docs/_build/html/_sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ You can install stormtrooper from PyPI.

.. code-block::
pip install stormtrooper
pip install stormtrooper[torch]
.. note::
PyTorch is not a direct requirement, but you will have to install it to run models.
See `Torch Installation <https://pytorch.org/>`_
If you intend to use SetFit models as well, install stormtrooper with optional dependencies.

.. code-block::
pip install stormtrooper[setfit]
Usage
^^^^^^^^^
Expand Down Expand Up @@ -42,6 +44,7 @@ In this example I am going to use Google's FLAN-T5.
zeroshot
text2text
generative
setfit
prompting
inference_on_gpu

Expand Down
54 changes: 54 additions & 0 deletions docs/_build/html/_sources/setfit.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
SetFit models
================

You can use `SetFit <https://github.com/huggingface/setfit>`_ in stormtrooper for training efficient zero and few-shot learning models from sentence transformers.

SetFit uses a prompt-free approach, needs way smaller models, and is thus faster to train, and more employable in high-performance settings for inference.

.. image:: https://raw.githubusercontent.com/huggingface/setfit/main/assets/setfit.png

Since this requires the setfit package we recommend you install stormtrooper with its optional dependencies.

.. code-block:: bash
pip install stormtrooper[setfit]
.. code-block:: python
from stormtrooper.setfit import SetFitZeroShotClassifier, SetFitFewShotClassifier
sample_text = "It is the Electoral College's responsibility to elect the president."
labels = ["politics", "science", "other"]
Here's a zero shot example:

.. code-block:: python
model = SetFitZeroShotClassifier().fit(None, labels)
predictions = model.predict([sample_text])
assert list(predictions) == ["politics"]
And a few shot example:

.. code-block:: python
few_shot_examples = [
"Joe Biden is the president.",
"Liquid water was found on the moon.",
"Jerry likes football."
]
model = SetFitFewShotClassifier().fit(few_shot_examples, labels)
predictions = model.predict([sample_text])
assert list(predictions) == ["politics"]
API reference
^^^^^^^^^^^^^

.. autoclass:: stormtrooper.setfit.SetFitZeroShotClassifier
:members:

.. autoclass:: stormtrooper.setfit.SetFitFewShotClassifier
:members:
7 changes: 4 additions & 3 deletions docs/_build/html/generative.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head><meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<meta name="color-scheme" content="light dark"><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
<link rel="index" title="Index" href="genindex.html" /><link rel="search" title="Search" href="search.html" /><link rel="next" title="Prompting" href="prompting.html" /><link rel="prev" title="Text2Text models" href="text2text.html" />
<link rel="index" title="Index" href="genindex.html" /><link rel="search" title="Search" href="search.html" /><link rel="next" title="SetFit models" href="setfit.html" /><link rel="prev" title="Text2Text models" href="text2text.html" />

<link rel="shortcut icon" href="_static/logo.svg"/><!-- Generated with Sphinx 5.0.2 and Furo 2022.12.07 -->
<title>Generative models - stormtrooper</title>
Expand Down Expand Up @@ -169,6 +169,7 @@
<li class="toctree-l1"><a class="reference internal" href="zeroshot.html">Zero-shot models</a></li>
<li class="toctree-l1"><a class="reference internal" href="text2text.html">Text2Text models</a></li>
<li class="toctree-l1 current current-page"><a class="current reference internal" href="#">Generative models</a></li>
<li class="toctree-l1"><a class="reference internal" href="setfit.html">SetFit models</a></li>
<li class="toctree-l1"><a class="reference internal" href="prompting.html">Prompting</a></li>
<li class="toctree-l1"><a class="reference internal" href="inference_on_gpu.html">Inference on GPU</a></li>
</ul>
Expand Down Expand Up @@ -461,12 +462,12 @@ <h2>API reference<a class="headerlink" href="#api-reference" title="Permalink to
<footer>

<div class="related-pages">
<a class="next-page" href="prompting.html">
<a class="next-page" href="setfit.html">
<div class="page-info">
<div class="context">
<span>Next</span>
</div>
<div class="title">Prompting</div>
<div class="title">SetFit models</div>
</div>
<svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
</a>
Expand Down
25 changes: 23 additions & 2 deletions docs/_build/html/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
<li class="toctree-l1"><a class="reference internal" href="zeroshot.html">Zero-shot models</a></li>
<li class="toctree-l1"><a class="reference internal" href="text2text.html">Text2Text models</a></li>
<li class="toctree-l1"><a class="reference internal" href="generative.html">Generative models</a></li>
<li class="toctree-l1"><a class="reference internal" href="setfit.html">SetFit models</a></li>
<li class="toctree-l1"><a class="reference internal" href="prompting.html">Prompting</a></li>
<li class="toctree-l1"><a class="reference internal" href="inference_on_gpu.html">Inference on GPU</a></li>
</ul>
Expand Down Expand Up @@ -218,6 +219,10 @@ <h2>C</h2>

<ul>
<li><a href="generative.html#stormtrooper.GenerativeZeroShotClassifier.classes_">(stormtrooper.GenerativeZeroShotClassifier attribute)</a>
</li>
<li><a href="setfit.html#stormtrooper.setfit.SetFitFewShotClassifier.classes_">(stormtrooper.setfit.SetFitFewShotClassifier attribute)</a>
</li>
<li><a href="setfit.html#stormtrooper.setfit.SetFitZeroShotClassifier.classes_">(stormtrooper.setfit.SetFitZeroShotClassifier attribute)</a>
</li>
<li><a href="text2text.html#stormtrooper.Text2TextFewShotClassifier.classes_">(stormtrooper.Text2TextFewShotClassifier attribute)</a>
</li>
Expand Down Expand Up @@ -252,6 +257,10 @@ <h2>F</h2>

<ul>
<li><a href="generative.html#stormtrooper.GenerativeZeroShotClassifier.fit">(stormtrooper.GenerativeZeroShotClassifier method)</a>
</li>
<li><a href="setfit.html#stormtrooper.setfit.SetFitFewShotClassifier.fit">(stormtrooper.setfit.SetFitFewShotClassifier method)</a>
</li>
<li><a href="setfit.html#stormtrooper.setfit.SetFitZeroShotClassifier.fit">(stormtrooper.setfit.SetFitZeroShotClassifier method)</a>
</li>
<li><a href="text2text.html#stormtrooper.Text2TextFewShotClassifier.fit">(stormtrooper.Text2TextFewShotClassifier method)</a>
</li>
Expand Down Expand Up @@ -292,6 +301,8 @@ <h2>P</h2>

<ul>
<li><a href="generative.html#stormtrooper.GenerativeZeroShotClassifier.partial_fit">(stormtrooper.GenerativeZeroShotClassifier method)</a>
</li>
<li><a href="setfit.html#stormtrooper.setfit.SetFitZeroShotClassifier.partial_fit">(stormtrooper.setfit.SetFitZeroShotClassifier method)</a>
</li>
<li><a href="text2text.html#stormtrooper.Text2TextFewShotClassifier.partial_fit">(stormtrooper.Text2TextFewShotClassifier method)</a>
</li>
Expand All @@ -300,12 +311,14 @@ <h2>P</h2>
<li><a href="zeroshot.html#stormtrooper.ZeroShotClassifier.partial_fit">(stormtrooper.ZeroShotClassifier method)</a>
</li>
</ul></li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="generative.html#stormtrooper.GenerativeFewShotClassifier.predict">predict() (stormtrooper.GenerativeFewShotClassifier method)</a>

<ul>
<li><a href="generative.html#stormtrooper.GenerativeZeroShotClassifier.predict">(stormtrooper.GenerativeZeroShotClassifier method)</a>
</li>
<li><a href="setfit.html#stormtrooper.setfit.SetFitFewShotClassifier.predict">(stormtrooper.setfit.SetFitFewShotClassifier method)</a>
</li>
<li><a href="setfit.html#stormtrooper.setfit.SetFitZeroShotClassifier.predict">(stormtrooper.setfit.SetFitZeroShotClassifier method)</a>
</li>
<li><a href="text2text.html#stormtrooper.Text2TextFewShotClassifier.predict">(stormtrooper.Text2TextFewShotClassifier method)</a>
</li>
Expand All @@ -314,6 +327,8 @@ <h2>P</h2>
<li><a href="zeroshot.html#stormtrooper.ZeroShotClassifier.predict">(stormtrooper.ZeroShotClassifier method)</a>
</li>
</ul></li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="zeroshot.html#stormtrooper.ZeroShotClassifier.predict_proba">predict_proba() (stormtrooper.ZeroShotClassifier method)</a>
</li>
</ul></td>
Expand All @@ -335,6 +350,12 @@ <h2>S</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="zeroshot.html#stormtrooper.ZeroShotClassifier.set_output">set_output() (stormtrooper.ZeroShotClassifier method)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="setfit.html#stormtrooper.setfit.SetFitFewShotClassifier">SetFitFewShotClassifier (class in stormtrooper.setfit)</a>
</li>
<li><a href="setfit.html#stormtrooper.setfit.SetFitZeroShotClassifier">SetFitZeroShotClassifier (class in stormtrooper.setfit)</a>
</li>
</ul></td>
</tr></table>
Expand Down
11 changes: 6 additions & 5 deletions docs/_build/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
<li class="toctree-l1"><a class="reference internal" href="zeroshot.html">Zero-shot models</a></li>
<li class="toctree-l1"><a class="reference internal" href="text2text.html">Text2Text models</a></li>
<li class="toctree-l1"><a class="reference internal" href="generative.html">Generative models</a></li>
<li class="toctree-l1"><a class="reference internal" href="setfit.html">SetFit models</a></li>
<li class="toctree-l1"><a class="reference internal" href="prompting.html">Prompting</a></li>
<li class="toctree-l1"><a class="reference internal" href="inference_on_gpu.html">Inference on GPU</a></li>
</ul>
Expand Down Expand Up @@ -215,13 +216,12 @@ <h1>Getting Started<a class="headerlink" href="#getting-started" title="Permalin
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this heading">#</a></h2>
<p>You can install stormtrooper from PyPI.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pip</span> <span class="n">install</span> <span class="n">stormtrooper</span>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pip</span> <span class="n">install</span> <span class="n">stormtrooper</span><span class="p">[</span><span class="n">torch</span><span class="p">]</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>PyTorch is not a direct requirement, but you will have to install it to run models.
See <a class="reference external" href="https://pytorch.org/">Torch Installation</a></p>
<p>If you intend to use SetFit models as well, install stormtrooper with optional dependencies.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pip</span> <span class="n">install</span> <span class="n">stormtrooper</span><span class="p">[</span><span class="n">setfit</span><span class="p">]</span>
</pre></div>
</div>
</section>
<section id="usage">
Expand All @@ -246,6 +246,7 @@ <h2>Usage<a class="headerlink" href="#usage" title="Permalink to this heading">#
<li class="toctree-l1"><a class="reference internal" href="zeroshot.html">Zero-shot models</a></li>
<li class="toctree-l1"><a class="reference internal" href="text2text.html">Text2Text models</a></li>
<li class="toctree-l1"><a class="reference internal" href="generative.html">Generative models</a></li>
<li class="toctree-l1"><a class="reference internal" href="setfit.html">SetFit models</a></li>
<li class="toctree-l1"><a class="reference internal" href="prompting.html">Prompting</a></li>
<li class="toctree-l1"><a class="reference internal" href="inference_on_gpu.html">Inference on GPU</a></li>
</ul>
Expand Down
1 change: 1 addition & 0 deletions docs/_build/html/inference_on_gpu.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
<li class="toctree-l1"><a class="reference internal" href="zeroshot.html">Zero-shot models</a></li>
<li class="toctree-l1"><a class="reference internal" href="text2text.html">Text2Text models</a></li>
<li class="toctree-l1"><a class="reference internal" href="generative.html">Generative models</a></li>
<li class="toctree-l1"><a class="reference internal" href="setfit.html">SetFit models</a></li>
<li class="toctree-l1"><a class="reference internal" href="prompting.html">Prompting</a></li>
<li class="toctree-l1 current current-page"><a class="current reference internal" href="#">Inference on GPU</a></li>
</ul>
Expand Down
Binary file modified docs/_build/html/objects.inv
Binary file not shown.
7 changes: 4 additions & 3 deletions docs/_build/html/prompting.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head><meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<meta name="color-scheme" content="light dark"><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
<link rel="index" title="Index" href="genindex.html" /><link rel="search" title="Search" href="search.html" /><link rel="next" title="Inference on GPU" href="inference_on_gpu.html" /><link rel="prev" title="Generative models" href="generative.html" />
<link rel="index" title="Index" href="genindex.html" /><link rel="search" title="Search" href="search.html" /><link rel="next" title="Inference on GPU" href="inference_on_gpu.html" /><link rel="prev" title="SetFit models" href="setfit.html" />

<link rel="shortcut icon" href="_static/logo.svg"/><!-- Generated with Sphinx 5.0.2 and Furo 2022.12.07 -->
<title>Prompting - stormtrooper</title>
Expand Down Expand Up @@ -169,6 +169,7 @@
<li class="toctree-l1"><a class="reference internal" href="zeroshot.html">Zero-shot models</a></li>
<li class="toctree-l1"><a class="reference internal" href="text2text.html">Text2Text models</a></li>
<li class="toctree-l1"><a class="reference internal" href="generative.html">Generative models</a></li>
<li class="toctree-l1"><a class="reference internal" href="setfit.html">SetFit models</a></li>
<li class="toctree-l1 current current-page"><a class="current reference internal" href="#">Prompting</a></li>
<li class="toctree-l1"><a class="reference internal" href="inference_on_gpu.html">Inference on GPU</a></li>
</ul>
Expand Down Expand Up @@ -269,14 +270,14 @@ <h2>Templates<a class="headerlink" href="#templates" title="Permalink to this he
</div>
<svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
</a>
<a class="prev-page" href="generative.html">
<a class="prev-page" href="setfit.html">
<svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
<div class="page-info">
<div class="context">
<span>Previous</span>
</div>

<div class="title">Generative models</div>
<div class="title">SetFit models</div>

</div>
</a>
Expand Down
1 change: 1 addition & 0 deletions docs/_build/html/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
<li class="toctree-l1"><a class="reference internal" href="zeroshot.html">Zero-shot models</a></li>
<li class="toctree-l1"><a class="reference internal" href="text2text.html">Text2Text models</a></li>
<li class="toctree-l1"><a class="reference internal" href="generative.html">Generative models</a></li>
<li class="toctree-l1"><a class="reference internal" href="setfit.html">SetFit models</a></li>
<li class="toctree-l1"><a class="reference internal" href="prompting.html">Prompting</a></li>
<li class="toctree-l1"><a class="reference internal" href="inference_on_gpu.html">Inference on GPU</a></li>
</ul>
Expand Down
Loading

0 comments on commit d278b7f

Please sign in to comment.