sifujohn commited on
Commit
ce7f82e
1 Parent(s): a5d99de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -8
app.py CHANGED
@@ -1,12 +1,19 @@
 
 
 
1
  import gradio as gr
2
 
3
- gr.load("models/google/gemma-7b-it").launch()
 
4
 
 
 
 
 
 
 
5
 
6
- examples=[["I'm planning a vacation to Japan. Can you suggest a one-week itinerary including must-visit places and local cuisines to try?", None, None, None, None, None, ],
7
- ["Can you write a short story about a time-traveling detective who solves historical mysteries?", None, None, None, None, None,],
8
- ["I'm trying to learn French. Can you provide some common phrases that would be useful for a beginner, along with their pronunciations?", None, None, None, None, None,],
9
- ["I have chicken, rice, and bell peppers in my kitchen. Can you suggest an easy recipe I can make with these ingredients?", None, None, None, None, None,],
10
- ["Can you explain how the QuickSort algorithm works and provide a Python implementation?", None, None, None, None, None,],
11
- ["What are some unique features of Rust that make it stand out compared to other systems programming languages like C++?", None, None, None, None, None,],
12
- ]
 
1
+ from transformers import AutoTokenizer, AutoModelForCausalLM
2
+ import transformers
3
+ import torch
4
  import gradio as gr
5
 
6
+ model_id = "gg-hf/gemma-7b-it"
7
+ dtype = torch.bfloat16
8
 
9
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
10
+ model = AutoModelForCausalLM.from_pretrained(
11
+ model_id,
12
+ device_map="cuda",
13
+ torch_dtype=dtype,
14
+ )
15
 
16
+ chat = [
17
+ { "role": "user", "content": "Write a hello world program" },
18
+ ]
19
+ prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)