Spaces:
Sleeping
Sleeping
Krzysztof Krystian Jankowski
commited on
Commit
Β·
346adc0
1
Parent(s):
6a394c6
gpu
Browse files- app-gpu.py +33 -0
- app.py +1 -1
app-gpu.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import torch
|
3 |
+
from ctransformers import AutoModelForCausalLM
|
4 |
+
llm = AutoModelForCausalLM.from_pretrained("TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF")
|
5 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
6 |
+
|
7 |
+
|
8 |
+
# Streamlit UI
|
9 |
+
st.set_page_config(page_title="GenBlog Demo",
|
10 |
+
page_icon="π",
|
11 |
+
layout="centered",
|
12 |
+
initial_sidebar_state='collapsed')
|
13 |
+
st.header("GenBlog Demo π")
|
14 |
+
st.subheader('This is a demo of the GenBlog assistant', divider='rainbow')
|
15 |
+
st.write("Enter a blog topic and the blog style to generate a blog post.")
|
16 |
+
st.write(f"Based on the TinyLlama π¦ model. GPU powered π")
|
17 |
+
st.divider()
|
18 |
+
input_text=st.text_input("Enter the Blog Topic")
|
19 |
+
blog_style=st.selectbox("Select the Blog Style", ["Personal", "Casual", "Proffesional"])
|
20 |
+
submit=st.button("Generate Blog Post")
|
21 |
+
st.divider()
|
22 |
+
response_field = st.empty()
|
23 |
+
|
24 |
+
if submit:
|
25 |
+
prompt = f"""
|
26 |
+
As a professional writer skilled in {blog_style.lower()} style, your task is to create an engaging and informative blog post about '{input_text}'. Begin with a captivating title that reflects the essence of the topic. Follow with an introduction that sets the stage for the discussion.
|
27 |
+
|
28 |
+
Please ensure the main body delves into the details of the topic, providing insight, analysis, and relevant examples that illuminate the subject for the readers. Conclude with a summary that reinforces the main points and offers a call to action or a thought-provoking question to engage the readers further.
|
29 |
+
|
30 |
+
The post should be well-structured, clearly written, and reflecting a professional tone suitable for an audience interested in {blog_style.lower()} topics.
|
31 |
+
"""
|
32 |
+
|
33 |
+
st.write_stream(llm(prompt, stream=True, max_new_tokens=400, temperature=0.5))
|
app.py
CHANGED
@@ -10,7 +10,7 @@ st.set_page_config(page_title="GenBlog Demo",
|
|
10 |
st.header("GenBlog Demo π")
|
11 |
st.subheader('This is a demo of the GenBlog assistant', divider='rainbow')
|
12 |
st.write("Enter a blog topic and the blog style to generate a blog post.")
|
13 |
-
st.write(f"Based on the TinyLlama π¦ model
|
14 |
st.divider()
|
15 |
input_text=st.text_input("Enter the Blog Topic")
|
16 |
blog_style=st.selectbox("Select the Blog Style", ["Personal", "Casual", "Proffesional"])
|
|
|
10 |
st.header("GenBlog Demo π")
|
11 |
st.subheader('This is a demo of the GenBlog assistant', divider='rainbow')
|
12 |
st.write("Enter a blog topic and the blog style to generate a blog post.")
|
13 |
+
st.write(f"Based on the TinyLlama π¦ model.")
|
14 |
st.divider()
|
15 |
input_text=st.text_input("Enter the Blog Topic")
|
16 |
blog_style=st.selectbox("Select the Blog Style", ["Personal", "Casual", "Proffesional"])
|