File size: 2,090 Bytes
19f8492
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import time
import random

import streamlit as st

from example_prompts import EXAMPLE_PROMPTS

HEADER = """
    # <span style="color:red"><b>WARNING:</b> This app uses BLOOM-6b3 as a backend generation . We are currently working on making it work with BLOOM-176 </span>
"""

SIDE_BAR_TEXT = """

# *PETALS: A Collaborative Inference of Large Models*

A BigScience initiative.

- [Introduction](#introduction)
  * [What is *PETALS* ?](#what-is--petals---)
  * [Generation parameters](#generation-parameters)

# Introduction

This Space is an interactive Space of *PETALS* paper (Submitted in EMNLP 2022) that aims to run BLOOM-176 in a distributed manner for efficient and cost-effective inference and fine-tuning.

## What is *PETALS* ? 

With the release of BLOOM-176B and OPT-175B, everyone can download pretrained models of this scale. Still, using these models requires supercomputer-grade hardware, which is unavailable to many researchers.
PETALS proposes to run BLOOM-176 in a distributed manner. The model is run on multiple computers from different users. Each user can benefit from the large model's inference by running a script similar to the one on this Space or from this Google Colab link: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1FEu0Dt_MjiwvdIz1SmIr9QfDDvNAJdZ-#scrollTo=O0WwC_IqofNH)

## Generation parameters


"""

def write_incremental(text, place_holder, delay=0.05):
    """
    Write a text in a streamlit widget, one character at a time.
    Adapted from: https://discuss.streamlit.io/t/display-several-pieces-of-strings-incrementally-on-the-same-line/9279
    """
    for i in range(len(text) + 1):
        place_holder.markdown("### <span style='color:grey' class='font'> %s </span>" % text[0:i].replace("\n", "<br>"), unsafe_allow_html=True)
        # place_holder.markdown("#### %s" % text[0:i])
        time.sleep(delay)

def i_am_feeling_lucky():
    """
    Return a random prompt from EXAMPLE_PROMPT
    """
    return EXAMPLE_PROMPTS[random.randint(0, len(EXAMPLE_PROMPTS) - 1)]