mrm8488 commited on
Commit
6e1e776
β€’
1 Parent(s): af71584

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -1,17 +1,18 @@
 
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 = "CodeParrot Generator 🦜"
7
- description = "This is a subspace to make code generation with [CodeParrot](https://huggingface.co/lvwerra/codeparrot), it is used in a larger [space](https://huggingface.co/spaces/loubnabnl/Code-generation-models-v1) for model comparison. For more flexibilty in sampling, you can find another demo for CodeParrot [here](https://huggingface.co/spaces/lvwerra/codeparrot-generation)."
8
  example = [
9
  ["def print_hello_world():", 8, 0.6, 42],
10
  ["def get_file_size(filepath):", 40, 0.6, 42],
11
  ["def count_lines(filename):", 40, 0.6, 42],
12
  ["def count_words(filename):", 40, 0.6, 42]]
13
- tokenizer = AutoTokenizer.from_pretrained("codeparrot/codeparrot")
14
- model = AutoModelForCausalLM.from_pretrained("codeparrot/codeparrot", low_cpu_mem_usage=True)
15
 
16
 
17
  def code_generation(gen_prompt, max_tokens, temperature=0.6, seed=42):
 
1
+ import torch
2
  import gradio as gr
3
  from transformers import AutoTokenizer, AutoModelForCausalLM, set_seed, pipeline
4
 
5
+ device = 'cuda' if torch.cuda.is_available() else 'cpu'
6
 
7
+ title = "Santacoder bash/shell Completion πŸŽ…"
8
+ description = "This is a subspace to make code generation with [SantaCoder fine-tuned on The Stack bash/shell](https://huggingface.co/mrm8488/santacoder-finetuned-the-stack-bash-4)"
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
+ tokenizer = AutoTokenizer.from_pretrained("mrm8488/santacoder-finetuned-the-stack-bash-4")
15
+ model = AutoModelForCausalLM.from_pretrained("mrm8488/santacoder-finetuned-the-stack-bash-4", trust_remote_code=True).to(device)
16
 
17
 
18
  def code_generation(gen_prompt, max_tokens, temperature=0.6, seed=42):