Skip to content

qompassai/Python

Repository files navigation

Python: The OG of AI

Qompass AI on Python

Repository Views GitHub all releases

Python
Python Documentation Python Tutorials
License: AGPL v3 License: Q-CDA

Qmopass AI Python Logo Python Solutions
Ferris the Crab Educational Videos

Making Python useful for AI datasets

▶️ Qompass AI Quick Start
curl -fsSL https://raw.githubusercontent.com/qompassai/python/main/scripts/quickstart.sh | sh
📄 We advise you read the script BEFORE running it 😉
#!/bin/sh
# /qompassai/python/scripts/quickstart.sh
# Qompass AI Python Quick Start
# Copyright (C) 2025 Qompass AI, All rights reserved
#########################################################
set -eu
PREFIX="$HOME/.local"
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
LOCAL_PREFIX="$HOME/.local"
BIN_DIR="$LOCAL_PREFIX/bin"
LIB_DIR="$LOCAL_PREFIX/lib"
SHARE_DIR="$LOCAL_PREFIX/share"
SRC_DIR="$LOCAL_PREFIX/src/python"
mkdir -p "$PREFIX/bin"
PY_VERSIONS="
1|3.6.15
2|3.7.17
3|3.8.19
4|3.9.19
5|3.10.14
6|3.11.9
7|3.12.3
8|3.13.5
9|3.14.0a6
"
printf '╭────────────────────────────────────────────╮\n'
printf '│      Qompass AI · Python Quick‑Start       │\n'
printf '╰────────────────────────────────────────────╯\n'
printf '   © 2025 Qompass AI. All rights reserved   \n\n'
echo "Which Python version would you like to build?"
echo "$PY_VERSIONS" | while IFS="|" read num version; do
        [ -z "$num" ] && continue
        echo " $num) Python $version"
done
echo " a) All"
echo " q) Quit"
printf "Choose [8]: "
read -r choice
[ -z "$choice" ] && choice=8
[ "$choice" = "q" ] && exit 0
PY_FINALS_LIST="3.6.15 3.7.17 3.8.19 3.9.19 3.10.14 3.11.9 3.12.3 3.13.5 3.14.0a6"
if [ "$choice" = "a" ] || [ "$choice" = "A" ]; then
        VERSIONS_TO_BUILD="$PY_FINALS_LIST"
elif printf '%s\n' $PY_FINALS_LIST | awk "NR==$choice" | grep -q .; then
        VERSIONS_TO_BUILD=$(printf '%s\n' $PY_FINALS_LIST | awk "NR==$choice")
else
        echo "Invalid selection." >&2
        exit 1
fi
echo
echo "You selected: $VERSIONS_TO_BUILD"
echo "Which build configuration?"
echo " 1) Classic CPython"
echo " 2) Free-threaded (GIL-free, experimental)"
echo " 3) Classic with FULL OPTIMIZATIONS (PGO, LTO, LTO_FLAGS)"
echo " 4) Free-threaded + FULL OPTIMIZATIONS"
echo " q) Quit"
printf "Choose [1]: "
read -r cbuild
[ -z "$cbuild" ] && cbuild=1
[ "$cbuild" = "q" ] && exit 0
FREE_THREADED="no"
DO_OPTIMIZE="no"
case "$cbuild" in
2) FREE_THREADED="yes" ;;
3) DO_OPTIMIZE="yes" ;;
4)
        FREE_THREADED="yes"
        DO_OPTIMIZE="yes"
        ;;
esac
for PY_VERS in $VERSIONS_TO_BUILD; do
        PY_MAJ="$(echo "$PY_VERS" | cut -d. -f1-2)"
        cd "$SRC_DIR"
        if [ ! -d "cpython-$PY_VERS" ]; then
                echo "→ Cloning Python source (cpython $PY_VERS)..."
                git clone --branch "v$PY_VERS" https://github.com/python/cpython.git "cpython-$PY_VERS"
        fi
        cd "cpython-$PY_VERS"
        git fetch origin
        git checkout "v$PY_VERS"
        git clean -fdx
        echo "→ Configuring Python $PY_VERS build..."
        CONFIG_FLAGS="--prefix=$LOCAL_PREFIX"
        [ "$FREE_THREADED" = "yes" ] && CONFIG_FLAGS="$CONFIG_FLAGS --enable-free-threaded-interpreter"
        [ "$DO_OPTIMIZE" = "yes" ] && CONFIG_FLAGS="$CONFIG_FLAGS --enable-optimizations --with-lto"
        ./configure "$CONFIG_FLAGS"
        echo "→ Building Python $PY_VERS (this may take several minutes)..."
        export CFLAGS="-Wno-error=date-time"
        make -j"$(nproc)"
        echo "→ Installing Python $PY_VERS (no sudo needed)..."
        make install
done
case ":$PATH:" in *":$BIN_DIR:"*) ;; *) export PATH="$BIN_DIR:$PATH" ;; esac
add_path_to_shell_rc() {
        rcfile=$1
        line="export PATH=\"$BIN_DIR:\$PATH\""
        if [ -f "$rcfile" ]; then
                if ! grep -Fxq "$line" "$rcfile"; then
                        printf '\n# Added by Qompass AI Python quickstart script\n%s\n' "$line" >>"$rcfile"
                        echo " → Added PATH export to $rcfile"
                fi
        fi
}
add_path_to_shell_rc "$HOME/.bashrc"
add_path_to_shell_rc "$HOME/.zshrc"
add_path_to_shell_rc "$HOME/.profile"
PY_MAJ="$(echo "$PY_VERS" | cut -d. -f1-2)"
PIP_PATH="$BIN_DIR/pip$PY_MAJ"
PYTHON_PATH="$BIN_DIR/python$PY_MAJ"
echo "→ Upgrading pip and installing core wheels..."
"$PYTHON_PATH" -m ensurepip --upgrade
"$PYTHON_PATH" -m pip install --upgrade pip wheel setuptools
echo
printf "Do you want to install \033[1mpyenv\033[0m for managing multiple Pythons? [Y/n]: "
read -r ans
[ -z "$ans" ] && ans="Y"
if [ "$ans" = "Y" ] || [ "$ans" = "y" ]; then
        if [ ! -d "$PYENV_ROOT" ]; then
                curl -fsSL https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
                for rc in "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.profile"; do
                        if [ -f "$rc" ]; then
                                if ! grep -q "pyenv init" "$rc"; then
                                        printf "\n# Pyenv config\nexport PYENV_ROOT=\"%s\"\nexport PATH=\"\\\$PYENV_ROOT/bin:\\\$PATH\"\neval \"\\\$(pyenv init --path)\"\n" "$PYENV_ROOT" >>"$rc"
                                        echo " → Added pyenv setup to $rc"
                                fi
                        fi
                done
        else
                echo "→ pyenv already present."
        fi
fi
echo
printf "Do you want to install \033[1mruff\033[0m (fast Python linter)? [Y/n]: "
read -r ans
[ -z "$ans" ] && ans="Y"
if [ "$ans" = "Y" ] || [ "$ans" = "y" ]; then
        "$PIP_PATH" install --user ruff
        echo "→ ruff installed via pip"
fi
echo
printf "Do you want to install \033[1muv\033[0m (pip replacement and package manager)? [Y/n]: "
read -r ans
[ -z "$ans" ] && ans="Y"
if [ "$ans" = "Y" ] || [ "$ans" = "y" ]; then
        if command -v pipx >/dev/null 2>&1; then
                pipx install uv || "$PIP_PATH" install --user uv
        else
                "$PIP_PATH" install --user uv
        fi
        echo "→ uv installed"
fi
echo
echo "Would you like to install editor tooling for Python development?"
echo " 1) python-lsp-server (LSP support, compatible with most editors)"
echo " 2) pyright (Microsoft, static type checker/LSP, Node.js required)"
echo " 3) basedpyright (Rust-based, fast drop-in Pyright alternative, LSP)"
echo " 4) debugpy (VSCode-compatible debugger, works in editors/Jupyter)"
echo " 5) ipython (enhanced interactive Python prompt)"
echo " 6) pdbpp (better pdb, drop-in REPL/debugger)"
echo " a) All of the above"
echo " n) None (skip)"
printf "Choose [a]: "
read -r pytools_ans
[ -z "$pytools_ans" ] && pytools_ans="a"
INSTALL_LSP_TOOL() {
        tool="$1"
        pkg="$2"
        if [ "$tool" = "pyright" ]; then
                if command -v npm >/dev/null 2>&1; then
                        echo "→ Installing pyright (npm)..."
                        npm install -g pyright
                else
                        echo "npm not found, falling back to pipx/pip."
                        if command -v pipx >/dev/null 2>&1; then
                                pipx install pyright
                        else
                                "$PIP_PATH" install --user pyright
                        fi
                fi
        elif [ "$tool" = "basedpyright" ]; then
                if command -v pipx >/dev/null 2>&1; then
                        echo "→ Installing basedpyright (pipx)..."
                        pipx install basedpyright
                else
                        "$PIP_PATH" install --user basedpyright
                fi
        else
                echo "→ Installing $tool..."
                "$PIP_PATH" install --user "$pkg"
        fi
}
case "$pytools_ans" in
1) INSTALL_LSP_TOOL "python-lsp-server" "python-lsp-server[all]" ;;
2) INSTALL_LSP_TOOL "pyright" "pyright" ;;
3) INSTALL_LSP_TOOL "basedpyright" "basedpyright" ;;
4) INSTALL_LSP_TOOL "debugpy" "debugpy" ;;
5) INSTALL_LSP_TOOL "ipython" "ipython" ;;
6) INSTALL_LSP_TOOL "pdbpp" "pdbpp" ;;
a | A)
        INSTALL_LSP_TOOL "python-lsp-server" "python-lsp-server[all]"
        INSTALL_LSP_TOOL "pyright" "pyright"
        INSTALL_LSP_TOOL "basedpyright" "basedpyright"
        INSTALL_LSP_TOOL "debugpy" "debugpy"
        INSTALL_LSP_TOOL "ipython" "ipython"
        INSTALL_LSP_TOOL "pdbpp" "pdbpp"
        ;;
n | N) echo "Skipping extra tooling." ;;
*) echo "Unknown selection, skipping." ;;
esac
create_xdg_config() {
        tool="$1"
        default_content="$2"
        confdir="$XDG_CONFIG_HOME/$tool"
        confpath="$confdir/config.toml"
        mkdir -p "$confdir"
        if [ -f "$confpath" ]; then
                echo "→ $tool config already exists at $confpath"
                return
        fi
        printf "Do you want to write an example config for $tool to %s? [Y/n]: " "$confpath"
        read -r ans
        [ -z "$ans" ] && ans="Y"
        if [ "$ans" = "Y" ] || [ "$ans" = "y" ]; then
                echo "→ Creating example $tool config at $confpath"
                printf "%s\n" "$default_content" >"$confpath"
        fi
}
RUFF_CFG='[lint]\nselect = ["E", "F", "W"] # Example: style, errors, warnings'
UV_CFG='[uv]\npypi_mirror = "https://pypi.org/simple"\ncache_dir = "~/.cache/uv"\n'
PYTHON_CFG='[startup]\n# Put any sitecustomize or startup hooks here\n'
create_xdg_config "ruff" "$RUFF_CFG"
create_xdg_config "uv" "$UV_CFG"
create_xdg_config "python" "$PYTHON_CFG"
echo
echo "✅ Python $VERSIONS_TO_BUILD has been built and installed in $BIN_DIR"
if [ "$FREE_THREADED" = "yes" ]; then
        echo " (Free-threaded interpreter enabled!)"
fi
echo "→ Test it with: $PYTHON_PATH --version"
echo "→ Your pip is: $PIP_PATH"
echo "→ pyenv (if installed) is in \$HOME/.pyenv; add to your PATH if desired."
echo "→ ruff and uv are installed in ~/.local/bin (and can be configured in $XDG_CONFIG_HOME/)"
echo "→ All binaries/libs/configs are under ~/.local/, ~/.pyenv/, ~/.config/"
echo "→ Add '$BIN_DIR' to your shell \$PATH if not already present."
echo "→ For custom packages, use: $PIP_PATH install --user ..."
echo "→ To uninstall, just rm -rf $LOCAL_PREFIX/{bin/lib/share} $SRC_DIR/cpython-* ~/.pyenv ~/.cache/ruff ~/.cache/uv $XDG_CONFIG_HOME/ruff $XDG_CONFIG_HOME/uv"
echo "─ Ready, Set, Python! ─"
exit 0 

Or, View the quickstart script.

🧭 About Qompass AI

Matthew A. Porter
Former Intelligence Officer
Educator & Learner
DeepTech Founder & CEO

Publications

ORCID ResearchGate Zenodo

Developer Programs

NVIDIA Developer Meta Developer HackerOne HuggingFace Epic Games Developer

Professional Profiles

Personal LinkedIn Startup LinkedIn

Social Media

X/Twitter Instagram Qompass AI YouTube

🔥 How Do I Support
🏛️ Qompass AI Pre-Seed Funding 2023-2025 🏆 Amount 📅 Date
RJOS/Zimmer Biomet Research Grant $30,000 March 2024
Pathfinders Intern Program
View on LinkedIn
$2,000 October 2024

🤝 How To Support Our Mission

[![GitHub Sponsors](https://img.shields.io/badge/GitHub-Sponsor-EA4AAA?style=for-the-badge\&logo=github-sponsors\&logoColor=white)](https://github.com/sponsors/phaedrusflow) [![Patreon](https://img.shields.io/badge/Patreon-Support-F96854?style=for-the-badge\&logo=patreon\&logoColor=white)](https://patreon.com/qompassai) [![Liberapay](https://img.shields.io/badge/Liberapay-Donate-F6C915?style=for-the-badge\&logo=liberapay\&logoColor=black)](https://liberapay.com/qompassai) [![Open Collective](https://img.shields.io/badge/Open%20Collective-Support-7FADF2?style=for-the-badge\&logo=opencollective\&logoColor=white)](https://opencollective.com/qompassai) [![Buy Me A Coffee](https://img.shields.io/badge/Buy%20Me%20A%20Coffee-Support-FFDD00?style=for-the-badge\&logo=buy-me-a-coffee\&logoColor=black)](https://www.buymeacoffee.com/phaedrusflow)
🔐 Cryptocurrency Donations **Monero (XMR):**
Monero QR Code
42HGspSFJQ4MjM5ZusAiKZj9JZWhfNgVraKb1eGCsHoC6QJqpo2ERCBZDhhKfByVjECernQ6KeZwFcnq8hVwTTnD8v4PzyH

📋 Copy Address

Funding helps us continue our research at the intersection of AI, healthcare, and education

Frequently Asked Questions ### Q: How do you mitigate against bias?

TLDR - we do math to make AI ethically useful

A: We delineate between mathematical bias (MB) - a fundamental parameter in neural network equations - and

algorithmic/social bias (ASB). While MB is optimized during model training through backpropagation, ASB requires careful consideration of data sources, model architecture, and deployment strategies. We implement attention mechanisms for improved input processing and use legal open-source data and secure web-search APIs to help mitigate ASB.

AAMC AI Guidelines | One way to align AI against ASB

AI Math at a glance

Forward Propagation Algorithm

$$ y = w_1x_1 + w_2x_2 + ... + w_nx_n + b $$

Where:

  • $y$ represents the model output
  • $(x_1, x_2, ..., x_n)$ are input features
  • $(w_1, w_2, ..., w_n)$ are feature weights
  • $b$ is the bias term

Neural Network Activation

For neural networks, the bias term is incorporated before activation:

$$ z = \sum_{i=1}^{n} w_ix_i + b $$ $$ a = \sigma(z) $$

Where:

  • $z$ is the weighted sum plus bias
  • $a$ is the activation output
  • $\sigma$ is the activation function

Attention Mechanism- aka what makes the Transformer (The "T" in ChatGPT) powerful

The Attention mechanism equation is:

$$ \text{Attention}(Q, K, V) = \text{softmax}\left( \frac{QK^T}{\sqrt{d_k}} \right) V $$

Where:

  • $Q$ represents the Query matrix
  • $K$ represents the Key matrix
  • $V$ represents the Value matrix
  • $d_k$ is the dimension of the key vectors
  • $\text{softmax}(\cdot)$ normalizes scores to sum to 1

Q: Do I have to buy a Linux computer to use this? I don't have time for that!

A: No. You can run Linux and/or the tools we share alongside your existing operating system:

  • Windows users can use Windows Subsystem for Linux WSL
  • Mac users can use Homebrew
  • The code-base instructions were developed with both beginners and advanced users in mind.

Q: Do you have to get a masters in AI?

A: Not if you don't want to. To get competent enough to get past ChatGPT dependence at least, you just need a

computer and a beginning's mindset. Huggingface is a good place to start.

Q: What makes a "small" AI model?

A: AI models ~=10 billion(10B) parameters and below. For comparison, OpenAI's GPT4o contains approximately 200B parameters.

What a Dual-License Means

Protection for Vulnerable Populations

The dual licensing aims to address the cybersecurity gap that disproportionately affects underserved populations. As highlighted by recent attacks[1], low-income residents, seniors, and foreign language speakers face higher-than-average risks of being victims of cyberattacks. By offering both open-source and commercial licensing options, we encourage the development of cybersecurity solutions that can reach these vulnerable groups while also enabling sustainable development and support.

Preventing Malicious Use

The AGPL-3.0 license ensures that any modifications to the software remain open source, preventing bad actors from creating closed-source variants that could be used for exploitation. This is especially crucial given the rising threats to vulnerable communities, including children in educational settings. The attack on Minneapolis Public Schools, which resulted in the leak of 300,000 files and a $1 million ransom demand, highlights the importance of transparency and security[8].

Addressing Cybersecurity in Critical Sectors

The commercial license option allows for tailored solutions in critical sectors such as healthcare, which has seen significant impacts from cyberattacks. For example, the recent Change Healthcare attack[4] affected millions of Americans and caused widespread disruption for hospitals and other providers. In January 2025, CISA[2] and FDA[3] jointly warned of critical backdoor vulnerabilities in Contec CMS8000 patient monitors, revealing how medical devices could be compromised for unauthorized remote access and patient data manipulation.

Supporting Cybersecurity Awareness

The dual licensing model supports initiatives like the Cybersecurity and Infrastructure Security Agency (CISA) efforts to improve cybersecurity awareness[7] in "target rich" sectors, including K-12 education[5]. By allowing both open-source and commercial use, we aim to facilitate the development of tools that support these critical awareness and protection efforts.

Bridging the Digital Divide

The unfortunate reality is that too many individuals and organizations have gone into a frenzy in every facet of our daily lives[6]. These unfortunate folks identify themselves with their talk of "10X" returns and building towards Artificial General Intelligence aka "AGI" while offering GPT wrappers. Our dual licensing approach aims to acknowledge this deeply concerning predatory paradigm with clear eyes while still operating to bring the best parts of the open-source community with our services and solutions.

Recent Cybersecurity Attacks

Recent attacks underscore the importance of robust cybersecurity measures:

  • The Change Healthcare cyberattack in February 2024 affected millions of Americans and caused significant disruption to healthcare providers.
  • The White House and Congress jointly designated October 2024 as Cybersecurity Awareness Month. This designation comes with over 100 actions that align the Federal government and public/private sector partners are taking to help every man, woman, and child to safely navigate the age of AI.

By offering both open source and commercial licensing options, we strive to create a balance that promotes innovation and accessibility. We address the complex cybersecurity challenges faced by vulnerable populations and critical infrastructure sectors as the foundation of our solutions, not an afterthought.

References