Posts

Showing posts with the label python

Python Practice Series

Image
Introduction Python is a high-level, general-purpose programming language with exceptionally clear and readable syntax, designed to optimize programmer productivity. Some outstanding advantages of Python include: Easy to learn and use: Its syntax, which resembles English, helps beginners quickly get accustomed. Rich libraries: Possesses a massive ecosystem of libraries supporting everything from web development, data analysis, to artificial intelligence. Cross-platform: Can run on Windows, macOS, and Linux without needing to change the source code. Strong community: Has widespread support from a global community of developers, making error resolution easier. Detail Guide to Managing Python Environments with pyenv and Poetry Using mlx-lm to run local LLM Deploying a Python Flask Server to Google Kubernetes Engine Happy coding!

Using mlx-lm to run local LLM

Image
Introduction mlx-lm is a library designed by Apple to optimize running Large Language Models directly on Apple Silicon chips. Compared to Ollama, mlx-lm has superior performance advantages due to its ability to directly access Unified Memory and maximize the power of Apple GPUs, resulting in faster processing speeds and better energy efficiency for Mac users. Prerequisites Because mlx-lm was developed specifically for Apple Silicon chips, the following instructions are only applicable if you are using an Apple computer. Detail First, install mlx-lm pip install mlx-lm Then, visit this HuggingFace page of the mlx community . This is a reputable page sharing LLMs that have been converted from GGUF to MLX to be suitable for running on Macs with Apple Silicon chips. You can search for models that fit your usage needs and machine configuration. Here, I will use the model mlx-community/Qwen2.5-Coder-7B-Instruct-4bit. The model name mlx-community/Qwen2.5-Coder-7B-Instruct-4bit consists of th...

Guide to Managing Python Environments with pyenv and Poetry

Image
Introduction pyenv is a tool for managing multiple Python versions on the same system, while Poetry is a modern tool for dependency management and project packaging. This combination helps developers control exact Python versions, automate virtual environment creation, and ensure consistent libraries across different machines. Detail First, use the following commands to install and use pyenv and poetry brew install pyenv poetry pyenv install 3.11.9 pyenv global 3.11.9 pyenv local 3.12.0 poetry env use python poetry config virtualenvs.in-project true poetry init -n poetry add requests poetry install brew install pyenv poetry: Install pyenv and poetry tools via Homebrew. pyenv install 3.11.9: Install Python version 3.11.9 to the system, you could install multiple Python version with the same way. pyenv global 3.11.9: Set Python 3.11.9 as the system-wide default version. pyenv local 3.12.0: Set Python 3.12.0 as the specific version for the current directory. poetry env...

Deploying a Python Flask Server to Google Kubernetes Engine

Image
Introduction In this article, I will guide you through deploying a Python Flask Server to Google Kubernetes Engine (GKE) . Previously, I wrote an article about deploying a NodeJS Application to GKE , which you can refer to for some basic information before continuing. Steps to Follow The process is quite similar to deploying a NodeJS Application and includes the following steps: Create a Python Flask Server Build a Docker image Push the Docker image Deploy the Docker image to GKE You will notice that when working with Kubernetes , the main difference is in the step where you build the Docker image . Depending on the application you need to deploy, there are different ways to build the Docker image . However, the common point is that once you build the Docker image , you have completed almost half of the process. This is because the subsequent steps involving Kubernetes are entirely the same. Detailed Process 1. Create a Python Flask Server In this step, you can either use an exist...