Posts

Showing posts from May, 2025

DevOps & CI/CD Tools with Examples

DevOps & CI/CD Tools DevOps & CI/CD Tools Overview with Examples 1. GitHub Actions GitHub Actions automates workflows directly in your GitHub repository for CI/CD, testing, and deployment.

Applications of LLMs with Examples

Applications of LLMs Applications of Large Language Models (LLMs) LLMs like GPT-4, BERT, and T5 power a wide range of applications in natural language processing. Below are some of the most common ones with Python examples. 1. Chatbots (e.g., GPT-powered) LLMs like GPT-4 can carry out human-like conversations, making them ideal for virtual assistants, customer support, and interactive bots. import openai openai.api_key = "your-api-key" response = openai.ChatCompletion.create( model="gpt-4", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What's the weather like today in New York?"} ] ) print(response['choices'][0]['message']['content']) 2. Content Generation LLMs can generate coherent ...

LLM

Large Language Models (LLMs) Large Language Models (LLMs) LLMs are advanced neural network models trained on massive text data for various NLP tasks like generation, translation, summarization, and more. 1. GPT-3 / GPT-4 (OpenAI) Generative Pre-trained Transformer models designed for text generation, chat, summarization, and more. GPT-4 offers greater accuracy and reasoning. import openai openai.api_key = "your-api-key" response = openai.ChatCompletion.create( model="gpt-4", messages=[ {"role": "user", "content": "Explain quantum computing in simple terms."} ] ) print(response['choices'][0]['message']['content']) Note: Replace your-api-key with your actual OpenAI API key. 2. BERT (Bidirectional Encoder Representations from Transformers) BERT understands context from both direction...

ml

Machine Learning Concepts Machine Learning (ML) Concepts with Code Examples 1. Supervised Learning Supervised learning involves training a model on labeled data to make predictions. Common tasks: classification, regression. Example: Classification using Scikit-learn from sklearn.datasets import load_iris from sklearn.ensemble import RandomForestClassifier data = load_iris() X, y = data.data, data.target model = RandomForestClassifier() model.fit(X, y) print(model.predict([[5.1, 3.5, 1.4, 0.2]])) 2. Unsupervised Learning Unsupervised learning finds hidden patterns in data without labeled outcomes. Common tasks: clustering, dimensionality reduction. Example: K-Means Clustering from sklearn.cluster import KMeans from sklearn.datasets import load_iris X = load_iris().data kmeans = KMeans(n_clusters=3, random_state=0) kmeans.fit(X) print(kmeans.labels_[:10]) ...

llm

AI Tools Overview with Code Examples AI Tools Overview with Code Examples 1. TensorFlow TensorFlow is an open-source framework by Google for building and deploying machine learning models. It supports CPUs, GPUs, and TPUs. Example: Image Classification (MNIST) import tensorflow as tf from tensorflow.keras.datasets import mnist from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Flatten (x_train, y_train), (x_test, y_test) = mnist.load_data() x_train, x_test = x_train / 255.0, x_test / 255.0 model = Sequential([ Flatten(input_shape=(28, 28)), Dense(128, activation='relu'), Dense(10, activation='softmax') ]) model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy']) model.fit(x_train, y_train, epochs=5) model.evaluate(x_test, y_test) 2. PyTorch PyTorch is a fl...

Example TensorFlow

  1. TensorFlow – Image Classification (MNIST Digits) python Copy Edit import tensorflow as tf from tensorflow.keras.datasets import mnist from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Flatten # Load and preprocess data (x_train, y_train), (x_test, y_test) = mnist.load_data() x_train, x_test = x_train / 255.0 , x_test / 255.0 # Build model model = Sequential([ Flatten(input_shape=( 28 , 28 )), Dense( 128 , activation= 'relu' ), Dense( 10 , activation= 'softmax' ) ]) # Compile and train model. compile (optimizer= 'adam' , loss= 'sparse_categorical_crossentropy' , metrics=[ 'accuracy' ]) model.fit(x_train, y_train, epochs= 5 ) # Evaluate model.evaluate(x_test, y_test) 2. PyTorch – Sentiment Analysis with LSTM python Copy Edit import torch import torch.nn as nn from torchtext.legacy.datasets import IMDB from torchtext.legacy.data import Field, BucketIterator # Defin...

TensorFlow

  1. TensorFlow TensorFlow is an open-source platform by Google for building and deploying machine learning and deep learning models. It supports both training and inference of neural networks on various hardware (CPU, GPU, TPU). It uses dataflow graphs for computation and supports multiple languages (Python, C++, etc.). Popular in production environments due to its scalability. Example: Image classification using Convolutional Neural Networks (CNNs) in TensorFlow. 2. PyTorch PyTorch is an open-source deep learning framework developed by Facebook AI. It provides a dynamic computational graph, which makes it more intuitive for debugging and experimentation. It is widely used in academic research due to its flexibility and ease of use. PyTorch supports both CPU and GPU training. Example: Building a sentiment analysis model using an LSTM in PyTorch. 3. Hugging Face Transformers This library provides thousands of pre-trained NLP models like BERT, GPT, and RoBERTa. It ...