chaseharmon commited on
Commit
29c3aa6
·
1 Parent(s): 1f109bf
Files changed (1) hide show
  1. app.py +39 -0
app.py CHANGED
@@ -1,8 +1,47 @@
1
  import streamlit as st
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  st.title("Rap Verse Generation V1 Demo")
4
  st.header("Supported Artists")
5
  st.write("Lupe Fiasco, Common, Jay-Z, Yasiin Bey, Ab-Soul, Rakim")
6
 
7
  prompt = st.chat_input("Write a verse in the style of Lupe Fiasco")
 
8
  st.write(prompt)
 
1
  import streamlit as st
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
3
+ import torch
4
+ from peft import PeftModel
5
+
6
+ base_model_name = "chaseharmon/Rap-Mistral-Big"
7
+
8
+
9
+ @st.cache_resource
10
+ def load_model():
11
+ nf4_config = BitsAndBytesConfig(
12
+ load_in_4bit=True,
13
+ bnb_4bit_quant_type="nf4",
14
+ bnb_4bit_use_double_quant=False,
15
+ bnb_4bit_compute_dtype="float16"
16
+ )
17
+
18
+ model = AutoModelForCausalLM.from_pretrained(
19
+ base_model_name,
20
+ device_map='auto',
21
+ )
22
+ model.config.use_cache = False
23
+ model.config.pretraining_tp = 1
24
+
25
+ return model
26
+
27
+ @st.cache_resource
28
+ def load_tokenizer():
29
+ tokenizer = AutoTokenizer.from_pretrained(base_model_name)
30
+
31
+ tokenizer.pad_token = tokenizer.eos_token
32
+ tokenizer.padding_side = "right"
33
+
34
+ return tokenizer
35
+
36
+
37
+
38
+ model = load_model()
39
+ tokenizer = load_tokenizer
40
 
41
  st.title("Rap Verse Generation V1 Demo")
42
  st.header("Supported Artists")
43
  st.write("Lupe Fiasco, Common, Jay-Z, Yasiin Bey, Ab-Soul, Rakim")
44
 
45
  prompt = st.chat_input("Write a verse in the style of Lupe Fiasco")
46
+
47
  st.write(prompt)