matthew mitton morenolq commited on
Commit
21706df
0 Parent(s):

Duplicate from morenolq/galactica-base

Browse files

Co-authored-by: Moreno La Quatra <morenolq@users.noreply.huggingface.co>

Files changed (4) hide show
  1. .gitattributes +34 -0
  2. README.md +14 -0
  3. app.py +49 -0
  4. requirements.txt +2 -0
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Galactica Base (1.3B)
3
+ emoji: 📝
4
+ colorFrom: yellow
5
+ colorTo: blue
6
+ sdk: gradio
7
+ sdk_version: 3.9.1
8
+ app_file: app.py
9
+ pinned: false
10
+ license: apache-2.0
11
+ duplicated_from: morenolq/galactica-base
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+ from transformers import AutoTokenizer, AutoModelForCausalLM
4
+
5
+ tokenizer = AutoTokenizer.from_pretrained("facebook/galactica-1.3b")
6
+ model = AutoModelForCausalLM.from_pretrained("facebook/galactica-1.3b")
7
+ text2text_generator = pipeline("text-generation", model=model, tokenizer=tokenizer, num_workers=2)
8
+
9
+ def predict(text, max_length=64, temperature=0.7, do_sample=True):
10
+ text = text.strip()
11
+ out_text = text2text_generator(text, max_length=max_length,
12
+ temperature=temperature,
13
+ do_sample=do_sample,
14
+ eos_token_id = tokenizer.eos_token_id,
15
+ bos_token_id = tokenizer.bos_token_id,
16
+ pad_token_id = tokenizer.pad_token_id,
17
+ )[0]['generated_text']
18
+ out_text = "<p>" + out_text + "</p>"
19
+ out_text = out_text.replace(text, text + "<b><span style='background-color: #ffffcc;'>")
20
+ out_text = out_text + "</span></b>"
21
+ out_text = out_text.replace("\n", "<br>")
22
+ return out_text
23
+
24
+ iface = gr.Interface(
25
+ fn=predict,
26
+ inputs=[
27
+ gr.inputs.Textbox(lines=5, label="Input Text"),
28
+ gr.inputs.Slider(minimum=32, maximum=256, default=64, label="Max Length"),
29
+ gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.7, step=0.1, label="Temperature"),
30
+ gr.inputs.Checkbox(label="Do Sample"),
31
+ ],
32
+ outputs=gr.HTML(),
33
+ description="Galactica Base Model",
34
+ examples=[[
35
+ "The attention mechanism in LLM is",
36
+ 128,
37
+ 0.7,
38
+ True
39
+ ],
40
+ [
41
+ "Title: Attention is all you need\n\nAbstract:",
42
+ 128,
43
+ 0.7,
44
+ True
45
+ ]
46
+ ]
47
+ )
48
+
49
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ git+https://github.com/paperswithcode/galai
2
+ gradio