Posts

Showing posts from 2024

Fixing the DeepSpeed Import Error While Fine-Tuning the Qwen Model

While fine-tuning the Qwen model, I encountered an error in the finetune.py script: ImportError : cannot import name 'deepspeed' from 'transformers.deepspeed' After some investigation, I discovered the issue stems from a recent update in the Transformers library. The transformers.deepspeed module has been deprecated and replaced by transformers.integrations . To fix this, you need to update the import statement in your script. The Fix Replace this: from transformers.deepspeed import deepspeed With this: from transformers.integrations import deepspeed This small change resolved the error, allowing the fine-tuning process to proceed smoothly. Additional Resources For more details, refer to the discussion in the official Transformers GitHub repository: Issue #34582 Remember to keep your library versions up-to-date to avoid similar issues in the future! 

VPC, Private subnet, public subnet, Routing table and InternetGateway, NAT gateway

 Trước tiên chúng ta cần hiểu về khái niệm VPC  VPC là Một thành phố độc lập với các thành phố khác Sau đó chúng ta xây dựng 2 quận nhỏ trong thành phố này gọi là 2 subnets Về cơ bản thì 2 subnet này có dải mạng khác nhau nhưng do cùng trong thành phố nên chúng có thể nói chuyện và kết nối với nhau Tuy nhiên thì chúng vẫn không thể kết nối với các thiết bị hoặc tài nguyên khác bên ngoài thành phố Điều tiếp theo là chúng ta tạo ra một cái Internet gateway đóng vai trò như một cái cửa ngõ ra ngoài internet, để bước ra ngoài thành phố Và chúng ta sẽ lắp cái cửa ngõ này cho VPC, vì lúc ban đầu tạo ra thì cái cổng này nó đứng độc lập không gắn với bất kỳ VPC nào Tuy việc gắn cổng cho thành phố rồi nhưng các Subnet vẫn k thể kết nối internet Điều tiếp theo là cần phải tạo ra các routing table, nó đóng vai trò như những tuyến đường Các routing tables ban đầu đc tạo ra nó sẽ gắn vào VPC, sau đó thì trong Routing table nó sẽ định nghĩa các tuyến đường ví dụ như là đi từ Source là dải I...

Persistent Storage for Kubernetes with StorageClass

In Kubernetes, managing persistent storage involves creating a StorageClass , which defines the types of storage to be used for persistent volumes (PV). Here's a step-by-step explanation of how to use dynamic provisioning for persistent storage in a Kubernetes cluster. Step 1: Declare a StorageClass A StorageClass is a way to describe the provisioning of storage in a Kubernetes cluster. It defines parameters such as the storage provider (e.g., Amazon EBS, NFS, etc.) and other configuration details. Depending on your cluster, there may already be a default StorageClass . If not, you will need to manually declare one. Example of defining a StorageClass for Amazon EBS: apiVersion : storage.k8s.io/v1 kind : StorageClass metadata : name : ebs-sc provisioner : kubernetes.io/aws-ebs parameters : type : gp2 Step 2: Create a PersistentVolumeClaim (PVC) Once the StorageClass is defined, you can create a PersistentVolumeClaim (PVC) that requests a specific amount of storage from a S...

RAG (Retriever-Augmented Generation) System Overview

main.py - Setting Up Qdrant Collection In this part, you are setting up the Qdrant client and creating a collection where embeddings will be stored: Initialize Qdrant Client : You connect to the Qdrant service using the API key and Qdrant Cloud URL. Create Collection : You define a new collection ( book_data ) in Qdrant with a specified vector size (1024) and distance metric (Cosine similarity). Result : You confirm that the collection is created successfully. from qdrant_client import QdrantClient from qdrant_client.models import Distance, VectorParams qdrant_client = QdrantClient( url = "https://your-qdrant-cloud-url" , api_key = "your-api-key" ) qdrant_client.create_collection( collection_name = "book_data" , # Name of the collection vectors_config =VectorParams( size = 1024 , distance =Distance.COSINE) # Vector size and distance metric ) print ( "Collection 'book_data' created successfully!" ) add_data.py - Addin...

Implementing TOTP in Java: A Simple Example

TOTP (Time-based One-Time Password) is commonly used for two-factor authentication. This implementation demonstrates how to generate TOTP using the HMAC algorithm with SHA1, SHA256, or SHA512. Key Concepts: HMAC (Hash-based Message Authentication Code) : A cryptographic algorithm that uses a secret key and a hash function to ensure data integrity. TOTP : A method for generating one-time passwords based on the current time, making it time-sensitive. Code Breakdown: HMAC Calculation : hmac_sha() : Computes HMAC using the given algorithm ( HmacSHA1 , HmacSHA256 , or HmacSHA512 ). Example : byte [] hmacResult = hmac_sha( "HmacSHA1" , key, message);      2. Hex to Byte Conversion : hexStr2Bytes() : Converts a hexadecimal string to a byte array for processing. Example : byte [] bytes = hexStr2Bytes( "1234567890ABCDEF" );    3. TOTP Generation : generateTOTP() : Generates a TOTP based on the key, time, and the desired length of the OTP. Example : String otp = g...

Understanding Network Address Translation (NAT)

 https://www.ionos.com/digitalguide/server/know-how/nat-how-network-address-translation-works/ Network Address Translation (NAT) is a process used by routers to translate private IP addresses in a local network to a public IP address for communication over the internet. This is particularly useful when multiple devices in a private network need access to the internet but only a single public IP address is available. NAT provides a mechanism to manage the translation of private IP addresses and ports to public ones. Scenario Explanation: Router Configuration : The router has been assigned the public IP address 217.229.111.18 by the Internet Service Provider (ISP). The local network uses the private IP address range 192.168.0.0/24 (e.g., IPs from 192.168.0.0 to 192.168.0.24 ). Device Connection to the Internet : A device within the local network (e.g., a computer with private IP 192.168.0.2 ) wants to establish a connection to a web server with the public IP address 71.123.239....

IPsec Tunnel Mode vs. Transport Mode: Key Differences and Use Cases

IPsec provides encryption and authentication to secure IP traffic, commonly used in business VPNs. It supports two encapsulation modes: Tunnel Mode and Transport Mode . Tunnel Mode : Encrypts the entire IP packet (both header and payload). Commonly used for gateway-to-gateway or server-to-server connections across an untrusted network (e.g., the Internet). Adds a new IP header, protecting internal routing information. More secure but has higher overhead. Transport Mode : Only encrypts the payload of the IP packet, keeping the original header. Ideal for end-to-end communication between devices within the same network. Lower overhead and larger MTU but less secure in complex setups. When to Use Each: Tunnel Mode is best for inter-network security, especially when traversing NAT or untrusted networks. Transport Mode is ideal for direct, end-to-end communication with minimal overhead. #IPsec #VPN #NetworkSecurity https://www.perimeter81.com/glossary/ipsec-tunnel-mode-vs-transport-m...

How to deploy applications to K8S with Kustomize and ArgoCD

Step 1 Create .drone.yml kind : pipeline name : your-project-name steps : - name : push images to harbor.google.com - name : kustomize-beta image : docker.io/drone-with-kustomization:latest settings : repo_url : ssh://git@git.google.com:20022/PROJECT/abc.git branch : master kustomization : your-app/overlays/beta update_image : - harbor.google.com/project/your-app-image:${DRONE_COMMIT_BRANCH}-${DRONE_COMMIT_SHA:0:7} environment : SSH_KEY : from_secret : SSH_KEY when : branch : develop event : push depends_on : - push image to harbor Create kustomize deployment files your-app / base / deployment.yaml apiVersion : apps/v1 kind : Deployment metadata : name : your-app-deployment spec : replicas : 3 revisionHistoryLimit : 3 selector : matchLabels : app : your-app-deployment template : metadata : labels : app : your-app-deployment spec : containers : ...