ArmelR commited on
Commit
74f6cce
โ€ข
0 Parent(s):

Duplicate from ArmelR/santacoder-instruction-subspace

Browse files
Files changed (4) hide show
  1. .gitattributes +27 -0
  2. README.md +13 -0
  3. app.py +59 -0
  4. requirements.txt +3 -0
.gitattributes ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ *.ftz filter=lfs diff=lfs merge=lfs -text
6
+ *.gz filter=lfs diff=lfs merge=lfs -text
7
+ *.h5 filter=lfs diff=lfs merge=lfs -text
8
+ *.joblib filter=lfs diff=lfs merge=lfs -text
9
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
10
+ *.model filter=lfs diff=lfs merge=lfs -text
11
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
12
+ *.onnx filter=lfs diff=lfs merge=lfs -text
13
+ *.ot filter=lfs diff=lfs merge=lfs -text
14
+ *.parquet filter=lfs diff=lfs merge=lfs -text
15
+ *.pb filter=lfs diff=lfs merge=lfs -text
16
+ *.pt filter=lfs diff=lfs merge=lfs -text
17
+ *.pth filter=lfs diff=lfs merge=lfs -text
18
+ *.rar filter=lfs diff=lfs merge=lfs -text
19
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
20
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
21
+ *.tflite filter=lfs diff=lfs merge=lfs -text
22
+ *.tgz filter=lfs diff=lfs merge=lfs -text
23
+ *.wasm filter=lfs diff=lfs merge=lfs -text
24
+ *.xz filter=lfs diff=lfs merge=lfs -text
25
+ *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: SantaCoder Instruction Subspace
3
+ emoji: ๐ŸŽ…๐Ÿพ
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: gradio
7
+ sdk_version: 3.0.4
8
+ app_file: app.py
9
+ pinned: false
10
+ duplicated_from: ArmelR/santacoder-instruction-subspace
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
app.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForCausalLM, set_seed, pipeline
3
+
4
+ #https://huggingface.co/spaces/lvwerra/codeparrot-generation
5
+
6
+ title = "SantaCoder+Alpaca Generator ๐ŸŽ…๐Ÿพ+๐Ÿฆ™"
7
+ description = "This is a subspace to make code generation with [SantaCoder](https://huggingface.co/bigcode/santacoder) and [Code Alpaca](https://github.com/sahil280114/codealpaca). Feel free to check this larger [space](https://huggingface.co/spaces/loubnabnl/Code-generation-models-v1) for more information about code generation with ๐Ÿค—."
8
+
9
+ example = [
10
+ ["def print_hello_world():", 8, 0.6, 42],
11
+ ["def get_file_size(filepath):", 40, 0.6, 42],
12
+ ["def count_lines(filename):", 40, 0.6, 42],
13
+ ["def count_words(filename):", 40, 0.6, 42]]
14
+
15
+ tokenizer = AutoTokenizer.from_pretrained("ArmelR/AlpacaCode512")
16
+ model = AutoModelForCausalLM.from_pretrained("ArmelR/AlpacaCode512", trust_remote_code=True)
17
+
18
+
19
+ def code_generation(gen_prompt, max_tokens, temperature=0.6, seed=42):
20
+ set_seed(seed)
21
+ pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
22
+ generated_text = pipe(gen_prompt, do_sample=True, top_p=0.95, temperature=temperature, max_new_tokens=max_tokens)[0]['generated_text']
23
+ return generated_text
24
+
25
+
26
+ iface = gr.Interface(
27
+ fn=code_generation,
28
+ inputs=[
29
+ gr.Textbox(lines=10, label="Input code"),
30
+ gr.inputs.Slider(
31
+ minimum=8,
32
+ maximum=256,
33
+ step=1,
34
+ default=8,
35
+ label="Number of tokens to generate",
36
+ ),
37
+ gr.inputs.Slider(
38
+ minimum=0,
39
+ maximum=2,
40
+ step=0.1,
41
+ default=0.6,
42
+ label="Temperature",
43
+ ),
44
+ gr.inputs.Slider(
45
+ minimum=0,
46
+ maximum=1000,
47
+ step=1,
48
+ default=42,
49
+ label="Random seed to use for the generation"
50
+ )
51
+ ],
52
+ outputs=gr.Textbox(label="Predicted code", lines=10),
53
+ examples=example,
54
+ layout="horizontal",
55
+ theme="peach",
56
+ description=description,
57
+ title=title
58
+ )
59
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers==4.23.0
2
+ accelerate==0.10.0
3
+ torch==1.11.0