abidlabs HF Staff commited on
Commit
de10362
·
1 Parent(s): d831107

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -27
app.py CHANGED
@@ -1,37 +1,10 @@
1
  import gradio as gr
2
- from transformers import AutoTokenizer, AutoModelForCausalLM, set_seed
3
- from transformers import pipeline
4
- import os
5
- import torch
6
 
7
  description = """# <p style="text-align: center; color: white;"> 🎅 <span style='color: #ff75b3;'>SantaCoder:</span> Code Generation </p>
8
  <span style='color: white;'>This is a demo to generate code with <a href="https://huggingface.co/bigcode/santacoder" style="color: #ff75b3;">SantaCoder</a>,
9
  a 1.1B parameter model for code generation in Python, Java & JavaScript. The model can also do infilling, just specify where you would like the model to complete code
10
  with the <span style='color: #ff75b3;'>&lt;FILL-HERE&gt;</span> token.</span>"""
11
 
12
- token = os.environ["HUB_TOKEN"]
13
- device="cuda:0"
14
-
15
-
16
- FIM_PREFIX = "<fim-prefix>"
17
- FIM_MIDDLE = "<fim-middle>"
18
- FIM_SUFFIX = "<fim-suffix>"
19
- FIM_PAD = "<fim-pad>"
20
- EOD = "<|endoftext|>"
21
-
22
- GENERATION_TITLE= "<p style='font-size: 16px; color: white;'>Generated code:</p>"
23
-
24
- tokenizer_fim = AutoTokenizer.from_pretrained("bigcode/santacoder", use_auth_token=token, padding_side="left")
25
-
26
- tokenizer_fim.add_special_tokens({
27
- "additional_special_tokens": [EOD, FIM_PREFIX, FIM_MIDDLE, FIM_SUFFIX, FIM_PAD],
28
- "pad_token": EOD,
29
- })
30
-
31
- tokenizer = AutoTokenizer.from_pretrained("bigcode/christmas-models", use_auth_token=token)
32
- model = AutoModelForCausalLM.from_pretrained("bigcode/christmas-models", trust_remote_code=True, use_auth_token=token).to(device)
33
- pipe = pipeline("text-generation", model=model, tokenizer=tokenizer, device=device)
34
-
35
  def post_processing(prompt, completion):
36
  completion = "<span style='color: #ff75b3;'>" + completion + "</span>"
37
  prompt = "<span style='color: #727cd6;'>" + prompt + "</span>"
 
1
  import gradio as gr
 
 
 
 
2
 
3
  description = """# <p style="text-align: center; color: white;"> 🎅 <span style='color: #ff75b3;'>SantaCoder:</span> Code Generation </p>
4
  <span style='color: white;'>This is a demo to generate code with <a href="https://huggingface.co/bigcode/santacoder" style="color: #ff75b3;">SantaCoder</a>,
5
  a 1.1B parameter model for code generation in Python, Java & JavaScript. The model can also do infilling, just specify where you would like the model to complete code
6
  with the <span style='color: #ff75b3;'>&lt;FILL-HERE&gt;</span> token.</span>"""
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  def post_processing(prompt, completion):
9
  completion = "<span style='color: #ff75b3;'>" + completion + "</span>"
10
  prompt = "<span style='color: #727cd6;'>" + prompt + "</span>"