File size: 1,886 Bytes
19f8492
 
 
 
 
 
 
 
6d863c3
19f8492
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6d863c3
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 = """
    # The online demo has now migrated to https://petals.ml/ and http://chat.petals.ml/ please refer to these links
"""

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 checking the official links: [petals](https://petals.ml/) | [chat-petals](http://chat.petals.ml/)

## 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)]