Sam Fred commited on
Commit
db42240
·
1 Parent(s): 587138b
Files changed (2) hide show
  1. Custy-gpt.py +31 -0
  2. requirements.txt +5 -0
Custy-gpt.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
3
+
4
+ # Load the Falcon-7B model with 8-bit quantization
5
+ model_id = "tiiuae/falcon-7b-instruct"
6
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
7
+ model = AutoModelForCausalLM.from_pretrained(
8
+ model_id,
9
+ load_in_8bit=True,
10
+ device_map="auto",
11
+ trust_remote_code=True
12
+ )
13
+
14
+ # Create a text generation pipeline
15
+ pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
16
+
17
+ # Streamlit app
18
+ st.title("Falcon-7B Text Generation")
19
+ st.write("Generate text using Falcon-7B with 8-bit quantization.")
20
+
21
+ prompt = st.text_input("Enter your prompt:")
22
+ if prompt:
23
+ outputs = pipe(
24
+ prompt,
25
+ max_new_tokens=50,
26
+ temperature=0.7,
27
+ top_k=50,
28
+ top_p=0.9,
29
+ do_sample=True
30
+ )
31
+ st.write(outputs[0]["generated_text"])
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ torch
2
+ transformers
3
+ accelerate
4
+ bitsandbytes
5
+ gradio