mrm8488 commited on
Commit
578b764
β€’
0 Parent(s):

Duplicate from mrm8488/santacoder-dockerfiles-completion

Browse files
Files changed (4) hide show
  1. .gitattributes +27 -0
  2. README.md +13 -0
  3. app.py +56 -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 Dockefiles completion
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: mrm8488/santacoder-dockerfiles-completion
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
app.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForCausalLM, set_seed, pipeline
3
+
4
+ title = "SantaCoder πŸŽ… Dockerfiles πŸ‹ Completion"
5
+ description = "This is a subspace to make code generation with [SantaCoder fine-tuned on The Stack Dockerfiles](https://huggingface.co/mrm8488/santacoder-finetuned-the-stack-dockerfiles)"
6
+ EXAMPLE_0 = "# Dockerfile for Express API"
7
+
8
+
9
+ CKPT = "mrm8488/santacoder-finetuned-the-stack-dockerfiles"
10
+
11
+ examples = [[EXAMPLE_0, 55, 0.6, 42]]
12
+ tokenizer = AutoTokenizer.from_pretrained(CKPT)
13
+ model = AutoModelForCausalLM.from_pretrained(CKPT, trust_remote_code=True)
14
+
15
+
16
+ def code_generation(gen_prompt, max_tokens, temperature=0.6, seed=42):
17
+ set_seed(seed)
18
+ pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
19
+ generated_text = pipe(gen_prompt, do_sample=True, top_p=0.95, temperature=temperature, max_new_tokens=max_tokens)[0]['generated_text']
20
+ return generated_text
21
+
22
+
23
+ iface = gr.Interface(
24
+ fn=code_generation,
25
+ inputs=[
26
+ gr.Textbox(lines=10, label="Input code"),
27
+ gr.inputs.Slider(
28
+ minimum=8,
29
+ maximum=256,
30
+ step=1,
31
+ default=8,
32
+ label="Number of tokens to generate",
33
+ ),
34
+ gr.inputs.Slider(
35
+ minimum=0,
36
+ maximum=2,
37
+ step=0.1,
38
+ default=0.6,
39
+ label="Temperature",
40
+ ),
41
+ gr.inputs.Slider(
42
+ minimum=0,
43
+ maximum=1000,
44
+ step=1,
45
+ default=42,
46
+ label="Random seed to use for the generation"
47
+ )
48
+ ],
49
+ outputs=gr.Textbox(label="Predicted code", lines=10),
50
+ examples=examples,
51
+ layout="horizontal",
52
+ theme="peach",
53
+ description=description,
54
+ title=title
55
+ )
56
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers==4.19.0
2
+ accelerate==0.10.0
3
+ torch==1.11.0