Skip to content

Instantly share code, notes, and snippets.

Alternative Similarity Metrics for RAG Systems

This Markdown file addresses the question of similarity metrics other than cosine similarity for use in Retrieval-Augmented Generation (RAG) systems. It complements the lecture content on RAG systems, particularly the sections on "How Similarity Search Works" and "Similarity Search in Action," which emphasize mathematical matching in vector space to retrieve relevant content. Below, we list and explain alternative similarity metrics, their applications in RAG, and their relevance to the lecture’s focus on embeddings and vector databases.

Question

Other than cosine similarity, what are other similarity metrics, and how do they work?

Answer

Overview

In RAG systems, similarity search is a core component, as described in the lecture’s sections on similarity search and vector databases. It involves comparing a query’s embedding vector to document vectors stored in a vector database (e.g., Pinecone, FAISS) to retrieve the most relevant content. While cos

Recommended Embedding Model for RAG Systems

This Markdown file addresses the question of which embedding model to use for Retrieval-Augmented Generation (RAG) systems and provides a detailed rationale for the recommendation. It complements the lecture content on RAG systems by offering practical guidance for selecting an embedding model.

Which Embedding Model Should I Use for RAG, and Why?

Question

Which embedding model do you suggest to use for RAG, and why this one?

Answer

Computer Audit Report: System Performance Analysis and Upgrade Recommendations

Executive Summary

This report analyzes the provided system snapshot from September 2, 2025, at 17:56:11, focusing on memory usage, process activity, and overall workload. The computer appears to be used for software development, virtualization, communication, and possibly emulation tasks, based on running processes like Visual Studio (devenv.exe), Cursor AI (multiple instances), VirtualBox VM, Slack, and retro emulators (e.g., x64sc.exe). Key findings include high memory utilization (84-85%), a large number of processes (392), significant private memory consumption by virtualization (17 GB from VirtualBoxVM), and elevated I/O activity from development tools.

The system is under moderate strain, particularly from memory constraints, which could lead to slowdowns, paging to disk, or crashes during intensive tasks. Upgrades to RAM are strongly recommended to improve performance and support the current workload. Additional opti

Process Information Tool Guide

This guide details the steps of the Process Information Tool (ProcessInfoTool.cpp), a C++ application that displays detailed information about running processes on a Windows system, including Process ID, name, parent process, memory usage, loaded modules, and thread count. Each step includes code snippets, reasoning, Mermaid diagrams to illustrate the process flow, and references to Microsoft documentation.

Prerequisites

  • Operating System: Windows 11 (x64 or ARM64 with x64 emulation).
  • Development Environment: Visual Studio 2022 with C++ Desktop Development workload and Windows SDK.
  • Libraries: Psapi.lib for process module and memory functions.
  • Permissions: Run as Administrator for full process access.

Detailed Assembly Code Breakdown for C Program

This Markdown file provides an in-depth breakdown of three assembly functions extracted from an ELF file, representing a C program that takes user input, checks it against a computed value (derived from initial constants), and outputs a success or failure message. The messages are encoded using a ROT-3 cipher (subtract 3 from each character byte), and the shift function decodes and prints them. The analysis includes detailed line-by-line explanations, assembly code snippets, extrapolated C-like pseudocode, and logic flow represented in Mermaid diagrams.

Overview

  • Program Logic: The main function prompts the user, reads an integer input, computes a target value (90 + 492 = 582, then 582 squared = 338724), and calls test with the input and target. The test function compares them and calls shift on the appropriate encoded string address. The shift function decodes the string in place by subtracting 3 from each byte and then prints it using `p

Memory Analysis Tutorial Using x64dbg

This tutorial provides step-by-step instructions for analyzing a simple C program using x64dbg, focusing on memory allocation, initialization, and deallocation. The program dynamically allocates an array, initializes it with squared values, prints the fifth element, and frees the memory. We'll use x64dbg to set breakpoints, track heap allocations, observe array initialization, examine memory contents, and analyze the memory state after deallocation.

Prerequisites

  • x64dbg: Download and install from https://x64dbg.com.
  • C Compiler: Use a compiler like MinGW to compile the provided C program into a 64-bit executable.
  • Program Code:
    #include <stdio.h>

Debugging a Password Program with x64dbg

This guide outlines the steps to build and debug a simple C password-checking program using GCC in MSYS2 and x64dbg on Windows. The goal is to compile the program with specific flags, load it into x64dbg, set a breakpoint on strcmp, analyze function parameters, identify the correct password, and verify it. Mermaid diagrams are included to visualize the compilation and debugging processes.

Program Code

The C program (password.c) to debug is:

#include <stdio.h>
#include <string.h>

Introduction to COBOL Programming with GnuCOBOL

Course Overview

This course provides a comprehensive introduction to COBOL programming using GnuCOBOL, an open-source COBOL compiler. Designed for beginners and intermediate programmers, the course covers fundamental programming concepts, data structures, practical applications, and advanced topics such as database integration. Each module builds on the previous one, ensuring a structured learning path that equips students with the skills to write robust COBOL programs for business applications.

Course Objectives

  • Understand COBOL syntax and structure using GnuCOBOL.
  • Master core programming concepts like variables, conditionals, and iteration.
  • Implement data structures and basic algorithms in COBOL.

Step-by-Step Execution of Iterative joinAll for [ ["x", "y"], ["z"] ]

This document walks through the execution of the non-recursive iterative joinAll function for the input [ ["x", "y"], ["z"] ], which generates all possible permutations of strings from the input lists, joined by underscores. The function produces ["x_z", "y_z"]. Each step of the iterative process is detailed below, with a Mermaid diagram visualizing the state of the algorithm, including the result and new_result lists. The diagrams are compatible with GitHub’s Mermaid renderer.

Iterative joinAll Implementation

The iterative solution builds combinations by maintaining a list of partial combinations (result) and updating it for each sublist.

def joinAll(lls):

Walkthrough: Solving the joinAll Problem for Lists of Permutations

This walkthrough is designed to help you guide students through solving the joinAll problem, which involves generating all possible permutations of strings from a list of lists, joined by underscores. The goal is to provide a clear path to the solution while fostering understanding of key concepts like recursion, iteration, and Cartesian products. Below, we break down the problem, offer hints, suggest teaching strategies, provide a step-by-step solution approach, and include Mermaid diagrams to visualize the process, ensuring compatibility with GitHub's Mermaid renderer.

Problem Recap

The joinAll(lls) function takes a list of lists of strings and returns a list of all possible permutations, where each permutation is formed by selecting exactly one string from each sublist and joining them with underscores (_).

Example