Phil Mui commited on
Commit ·
a3fe11e
1
Parent(s): 3614190
initial commit
Browse files- .gitignore +146 -0
- 01_transformers/README.md +4 -0
- 01_transformers/app.py +60 -0
- 01_transformers/app.py-START +48 -0
- 01_transformers/requirements.txt +8 -0
- 02_ML_project/data/housing.csv +0 -0
- 02_ML_project/requirements.txt +3 -0
- README.md +3 -3
- requirements.txt +13 -0
.gitignore
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.DS_Store
|
| 2 |
+
# Byte-compiled / optimized / DLL files
|
| 3 |
+
__pycache__/
|
| 4 |
+
*.py[cod]
|
| 5 |
+
*$py.class
|
| 6 |
+
|
| 7 |
+
# C extensions
|
| 8 |
+
*.so
|
| 9 |
+
|
| 10 |
+
# Distribution / packaging
|
| 11 |
+
.Python
|
| 12 |
+
bin/
|
| 13 |
+
build/
|
| 14 |
+
develop-eggs/
|
| 15 |
+
dist/
|
| 16 |
+
downloads/
|
| 17 |
+
eggs/
|
| 18 |
+
.eggs/
|
| 19 |
+
etc/
|
| 20 |
+
include/
|
| 21 |
+
lib/
|
| 22 |
+
lib64/
|
| 23 |
+
parts/
|
| 24 |
+
sdist/
|
| 25 |
+
share/
|
| 26 |
+
var/
|
| 27 |
+
wheels/
|
| 28 |
+
pip-wheel-metadata/
|
| 29 |
+
share/python-wheels/
|
| 30 |
+
*.egg-info/
|
| 31 |
+
.installed.cfg
|
| 32 |
+
*.egg
|
| 33 |
+
MANIFEST
|
| 34 |
+
|
| 35 |
+
# PyInstaller
|
| 36 |
+
# Usually these files are written by a python script from a template
|
| 37 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
| 38 |
+
*.manifest
|
| 39 |
+
*.spec
|
| 40 |
+
|
| 41 |
+
# Installer logs
|
| 42 |
+
pip-log.txt
|
| 43 |
+
pip-delete-this-directory.txt
|
| 44 |
+
|
| 45 |
+
# Unit test / coverage reports
|
| 46 |
+
htmlcov/
|
| 47 |
+
.tox/
|
| 48 |
+
.nox/
|
| 49 |
+
.coverage
|
| 50 |
+
.coverage.*
|
| 51 |
+
.cache
|
| 52 |
+
nosetests.xml
|
| 53 |
+
coverage.xml
|
| 54 |
+
*.cover
|
| 55 |
+
*.py,cover
|
| 56 |
+
.hypothesis/
|
| 57 |
+
.pytest_cache/
|
| 58 |
+
.ruff_cache
|
| 59 |
+
|
| 60 |
+
# Translations
|
| 61 |
+
*.mo
|
| 62 |
+
*.pot
|
| 63 |
+
|
| 64 |
+
# Django stuff:
|
| 65 |
+
*.log
|
| 66 |
+
local_settings.py
|
| 67 |
+
db.sqlite3
|
| 68 |
+
db.sqlite3-journal
|
| 69 |
+
|
| 70 |
+
# Flask stuff:
|
| 71 |
+
instance/
|
| 72 |
+
.webassets-cache
|
| 73 |
+
|
| 74 |
+
# Scrapy stuff:
|
| 75 |
+
.scrapy
|
| 76 |
+
|
| 77 |
+
# Sphinx documentation
|
| 78 |
+
docs/_build/
|
| 79 |
+
|
| 80 |
+
# PyBuilder
|
| 81 |
+
target/
|
| 82 |
+
|
| 83 |
+
# Jupyter Notebook
|
| 84 |
+
.ipynb_checkpoints
|
| 85 |
+
notebooks/
|
| 86 |
+
|
| 87 |
+
# IPython
|
| 88 |
+
profile_default/
|
| 89 |
+
ipython_config.py
|
| 90 |
+
|
| 91 |
+
# pyenv
|
| 92 |
+
.python-version
|
| 93 |
+
|
| 94 |
+
# pipenv
|
| 95 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
| 96 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
| 97 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
| 98 |
+
# install all needed dependencies.
|
| 99 |
+
#Pipfile.lock
|
| 100 |
+
|
| 101 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
| 102 |
+
__pypackages__/
|
| 103 |
+
|
| 104 |
+
# Celery stuff
|
| 105 |
+
celerybeat-schedule
|
| 106 |
+
celerybeat.pid
|
| 107 |
+
|
| 108 |
+
# SageMath parsed files
|
| 109 |
+
*.sage.py
|
| 110 |
+
|
| 111 |
+
# Environments
|
| 112 |
+
.env
|
| 113 |
+
.venv
|
| 114 |
+
env/
|
| 115 |
+
venv/
|
| 116 |
+
ENV/
|
| 117 |
+
env.bak/
|
| 118 |
+
venv.bak/
|
| 119 |
+
pyvenv.cfg
|
| 120 |
+
|
| 121 |
+
# Spyder project settings
|
| 122 |
+
.spyderproject
|
| 123 |
+
.spyproject
|
| 124 |
+
|
| 125 |
+
# Rope project settings
|
| 126 |
+
.ropeproject
|
| 127 |
+
|
| 128 |
+
# mkdocs documentation
|
| 129 |
+
/site
|
| 130 |
+
|
| 131 |
+
# mypy
|
| 132 |
+
.mypy_cache/
|
| 133 |
+
.dmypy.json
|
| 134 |
+
dmypy.json
|
| 135 |
+
|
| 136 |
+
# Pyre type checker
|
| 137 |
+
.pyre/
|
| 138 |
+
|
| 139 |
+
# Jetbrains
|
| 140 |
+
.idea
|
| 141 |
+
modules/
|
| 142 |
+
*.swp
|
| 143 |
+
|
| 144 |
+
# pipenv
|
| 145 |
+
Pipfile
|
| 146 |
+
Pipfile.lock
|
01_transformers/README.md
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
# Demo App for Transformers
|
| 3 |
+
|
| 4 |
+
A demo app to illustrate various seq2seq examples of using HuggingFace Transformers
|
01_transformers/app.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
##############################################################################
|
| 2 |
+
# Main script that builds the UI & connects the logic for an LLM-driven
|
| 3 |
+
# query frontend to an ASDRP demo app.
|
| 4 |
+
#
|
| 5 |
+
# @philmui
|
| 6 |
+
# Tue Jun 20 23:35:59 PDT 2023
|
| 7 |
+
##############################################################################
|
| 8 |
+
|
| 9 |
+
from transformers import pipeline
|
| 10 |
+
import streamlit as st
|
| 11 |
+
from pprint import pprint
|
| 12 |
+
|
| 13 |
+
##############################################################################
|
| 14 |
+
|
| 15 |
+
st.set_page_config(page_title="Translator",
|
| 16 |
+
page_icon=":robot:",
|
| 17 |
+
layout="wide")
|
| 18 |
+
st.header("🇫🇷🇪🇸 Translator 🇺🇸🇨🇳")
|
| 19 |
+
|
| 20 |
+
col1, col2 = st.columns([1,1])
|
| 21 |
+
|
| 22 |
+
with col1:
|
| 23 |
+
option_llm = st.selectbox(
|
| 24 |
+
"Model",
|
| 25 |
+
(
|
| 26 |
+
"Helsinki-NLP/opus-mt-fr-en",
|
| 27 |
+
"Helsinki-NLP/opus-mt-en-fr",
|
| 28 |
+
"Helsinki-NLP/opus-mt-es-en",
|
| 29 |
+
"Helsinki-NLP/opus-mt-en-es",
|
| 30 |
+
"Helsinki-NLP/opus-mt-it-en",
|
| 31 |
+
"Helsinki-NLP/opus-mt-en-it",
|
| 32 |
+
"Helsinki-NLP/opus-mt-en-de",
|
| 33 |
+
"Helsinki-NLP/opus-mt-de-en",
|
| 34 |
+
)
|
| 35 |
+
)
|
| 36 |
+
with col2:
|
| 37 |
+
pass
|
| 38 |
+
|
| 39 |
+
def get_query():
|
| 40 |
+
input_text = st.text_area(label="Your input text",
|
| 41 |
+
placeholder="Say anything",
|
| 42 |
+
key="question_text", label_visibility="collapsed")
|
| 43 |
+
return input_text
|
| 44 |
+
|
| 45 |
+
query = get_query()
|
| 46 |
+
|
| 47 |
+
if query and len(query) > 1:
|
| 48 |
+
output=""
|
| 49 |
+
try:
|
| 50 |
+
st.spinner(text="In progress...")
|
| 51 |
+
translator = pipeline("translation",
|
| 52 |
+
model=option_llm)
|
| 53 |
+
output = translator(query)[0]['translation_text']
|
| 54 |
+
except Exception as e:
|
| 55 |
+
output=f"Sorry: cannot translate! {e}"
|
| 56 |
+
|
| 57 |
+
height = min(2*len(output), 240)
|
| 58 |
+
st.text_area(label="Response" ,
|
| 59 |
+
value=output, height=height)
|
| 60 |
+
|
01_transformers/app.py-START
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
##############################################################################
|
| 2 |
+
# Main script that builds the UI & connects the logic for an LLM-driven
|
| 3 |
+
# query frontend to an ASDRP demo app.
|
| 4 |
+
#
|
| 5 |
+
# @philmui
|
| 6 |
+
# Tue Jun 20 23:35:59 PDT 2023
|
| 7 |
+
##############################################################################
|
| 8 |
+
|
| 9 |
+
import streamlit as st
|
| 10 |
+
from pprint import pprint
|
| 11 |
+
|
| 12 |
+
##############################################################################
|
| 13 |
+
|
| 14 |
+
st.set_page_config(page_title="Transformers",
|
| 15 |
+
page_icon=":robot:",
|
| 16 |
+
layout="wide")
|
| 17 |
+
st.header("🤖 Transformers 👾")
|
| 18 |
+
|
| 19 |
+
col1, col2 = st.columns([1,1])
|
| 20 |
+
|
| 21 |
+
with col1:
|
| 22 |
+
option_llm = st.selectbox(
|
| 23 |
+
"LLM",
|
| 24 |
+
('text-davinci-003',
|
| 25 |
+
'gpt-3.5-turbo',
|
| 26 |
+
'gpt-4',
|
| 27 |
+
)
|
| 28 |
+
)
|
| 29 |
+
with col2:
|
| 30 |
+
option_embedding = st.selectbox(
|
| 31 |
+
"Embedding",
|
| 32 |
+
("text-ada-002",
|
| 33 |
+
)
|
| 34 |
+
)
|
| 35 |
+
def get_question():
|
| 36 |
+
input_text = st.text_area(label="Your question ...",
|
| 37 |
+
placeholder="Ask me anything ...",
|
| 38 |
+
key="question_text", label_visibility="collapsed")
|
| 39 |
+
return input_text
|
| 40 |
+
|
| 41 |
+
question_text = get_question()
|
| 42 |
+
|
| 43 |
+
if question_text and len(question_text) > 1:
|
| 44 |
+
output="(Response in the work)"
|
| 45 |
+
height = min(2*len(output), 240)
|
| 46 |
+
st.text_area(label="Response" ,
|
| 47 |
+
value=output, height=height)
|
| 48 |
+
|
01_transformers/requirements.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
chardet==4.0.0
|
| 2 |
+
charset-normalizer==3.1.0
|
| 3 |
+
datasets==2.13.0
|
| 4 |
+
evaluate==0.4.0
|
| 5 |
+
transformers==4.30.2
|
| 6 |
+
pytorch
|
| 7 |
+
torchvision
|
| 8 |
+
torchaudio
|
02_ML_project/data/housing.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
02_ML_project/requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
numpy==1.17.3
|
| 2 |
+
pandas==1.24.3
|
| 3 |
+
scikit-learn==2.2.0
|
README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
colorTo: pink
|
| 6 |
sdk: streamlit
|
| 7 |
sdk_version: 1.21.0
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Asdrp
|
| 3 |
+
emoji: 👀
|
| 4 |
+
colorFrom: purple
|
| 5 |
colorTo: pink
|
| 6 |
sdk: streamlit
|
| 7 |
sdk_version: 1.21.0
|
requirements.txt
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
bettershot==0.1.92
|
| 2 |
+
chainlit==0.4.1
|
| 3 |
+
chromadb==0.3.26
|
| 4 |
+
google-search-results==2.4.2
|
| 5 |
+
langchain==0.0.207
|
| 6 |
+
numpy==1.17.3
|
| 7 |
+
pandas==1.24.3
|
| 8 |
+
promptlayer==0.1.89
|
| 9 |
+
sacremoses==0.0.53
|
| 10 |
+
scikit-learn==2.2.0
|
| 11 |
+
streamlit==1.23.1
|
| 12 |
+
tiktoken==0.4.0
|
| 13 |
+
unstructured==0.7.5
|