tushar-r-pawar commited on
Commit
b52e376
·
verified ·
1 Parent(s): 507b2e6

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +79 -0
  2. requirements.txt +79 -0
app.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
+ import streamlit as st
4
+ import airllm
5
+
6
+ # Load GEMMA 2B model and tokenizer
7
+ model_name = "google/gemma-2b"
8
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
9
+
10
+ # Load the base version of the model
11
+ model = AutoModelForCausalLM.from_pretrained(model_name)
12
+
13
+ # Initialize AirLLM
14
+ air_llm = airllm.AirLLM(model, tokenizer)
15
+
16
+ # Streamlit app configuration
17
+ st.set_page_config(
18
+ page_title="Chatbot with GEMMA 2B and AirLLM",
19
+ page_icon="🤖",
20
+ layout="wide",
21
+ initial_sidebar_state="expanded",
22
+ )
23
+
24
+ # App title
25
+ st.title("Conversational Chatbot with GEMMA 2B and AirLLM")
26
+
27
+ # Sidebar configuration
28
+ st.sidebar.header("Chatbot Configuration")
29
+ theme = st.sidebar.selectbox("Choose a theme", ["Default", "Dark", "Light"])
30
+
31
+ # Set theme based on user selection
32
+ if theme == "Dark":
33
+ st.markdown(
34
+ """
35
+ <style>
36
+ .reportview-container {
37
+ background: #2E2E2E;
38
+ color: #FFFFFF;
39
+ }
40
+ .sidebar .sidebar-content {
41
+ background: #333333;
42
+ }
43
+ </style>
44
+ """,
45
+ unsafe_allow_html=True
46
+ )
47
+ elif theme == "Light":
48
+ st.markdown(
49
+ """
50
+ <style>
51
+ .reportview-container {
52
+ background: #FFFFFF;
53
+ color: #000000;
54
+ }
55
+ .sidebar .sidebar-content {
56
+ background: #F5F5F5;
57
+ }
58
+ </style>
59
+ """,
60
+ unsafe_allow_html=True
61
+ )
62
+
63
+ # Chat input and output
64
+ user_input = st.text_input("You: ", "")
65
+ if st.button("Send"):
66
+ if user_input:
67
+ # Generate response using AirLLM
68
+ response = air_llm.generate_response(user_input)
69
+ st.text_area("Bot:", value=response, height=200, max_chars=None)
70
+ else:
71
+ st.warning("Please enter a message.")
72
+
73
+ # Footer
74
+ st.sidebar.markdown(
75
+ """
76
+ ### About
77
+ This is a conversational chatbot built using the base version of the GEMMA 2B model and AirLLM.
78
+ """
79
+ )
requirements.txt ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ accelerate==0.31.0
2
+ aiohttp==3.9.5
3
+ aiosignal==1.3.1
4
+ airllm==2.8.3
5
+ altair==5.3.0
6
+ async-timeout==4.0.3
7
+ attrs==23.2.0
8
+ bitsandbytes==0.43.1
9
+ blinker==1.8.2
10
+ cachetools==5.3.3
11
+ certifi==2024.6.2
12
+ charset-normalizer==3.3.2
13
+ click==8.1.7
14
+ colorama==0.4.6
15
+ coloredlogs==15.0.1
16
+ datasets==2.20.0
17
+ dill==0.3.8
18
+ filelock==3.15.4
19
+ frozenlist==1.4.1
20
+ fsspec==2024.5.0
21
+ gitdb==4.0.11
22
+ GitPython==3.1.43
23
+ huggingface-hub==0.23.4
24
+ humanfriendly==10.0
25
+ idna==3.7
26
+ intel-openmp==2021.4.0
27
+ Jinja2==3.1.4
28
+ jsonschema==4.22.0
29
+ jsonschema-specifications==2023.12.1
30
+ markdown-it-py==3.0.0
31
+ MarkupSafe==2.1.5
32
+ mdurl==0.1.2
33
+ mkl==2021.4.0
34
+ mpmath==1.3.0
35
+ multidict==6.0.5
36
+ multiprocess==0.70.16
37
+ networkx==3.3
38
+ numpy==1.26.4
39
+ optimum==1.21.1
40
+ packaging==24.1
41
+ pandas==2.2.2
42
+ pillow==10.4.0
43
+ protobuf==5.27.2
44
+ psutil==6.0.0
45
+ pyarrow==16.1.0
46
+ pyarrow-hotfix==0.6
47
+ pydeck==0.9.1
48
+ Pygments==2.18.0
49
+ pyreadline3==3.4.1
50
+ python-dateutil==2.9.0.post0
51
+ pytz==2024.1
52
+ PyYAML==6.0.1
53
+ referencing==0.35.1
54
+ regex==2024.5.15
55
+ requests==2.32.3
56
+ rich==13.7.1
57
+ rpds-py==0.18.1
58
+ safetensors==0.4.3
59
+ scipy==1.14.0
60
+ sentencepiece==0.2.0
61
+ six==1.16.0
62
+ smmap==5.0.1
63
+ streamlit==1.36.0
64
+ sympy==1.12.1
65
+ tbb==2021.13.0
66
+ tenacity==8.4.2
67
+ tokenizers==0.19.1
68
+ toml==0.10.2
69
+ toolz==0.12.1
70
+ torch==2.3.1
71
+ tornado==6.4.1
72
+ tqdm==4.66.4
73
+ transformers==4.42.3
74
+ typing_extensions==4.12.2
75
+ tzdata==2024.1
76
+ urllib3==2.2.2
77
+ watchdog==4.0.1
78
+ xxhash==3.4.1
79
+ yarl==1.9.4