Skip to content

Instantly share code, notes, and snippets.

import random
# Generate random byte data
N = 8 # Number of chunks
byte_data = bytes(random.getrandbits(8) for _ in range(1024)) # Generate 1024 random bytes
# Split into N equal chunks using plain Python
chunk_size = len(byte_data) // N
split_data = [byte_data[i * chunk_size : (i + 1) * chunk_size] for i in range(N)]

Got it! I'll find the best resources to get you up to speed on Monte Carlo Tree Search (MCTS) without reinventing the wheel. This will include:

  • The most cited and accessible foundational papers.
  • High-quality GitHub repositories with clear implementations.
  • Tutorials or blog posts that explain MCTS concepts and provide code examples.

I'll get back to you shortly with the best materials!

Best Resources for Learning Monte Carlo Tree Search (MCTS)

Learning MCTS efficiently involves understanding the core algorithm and having practical examples to follow. Below are top resources grouped by foundational readings, tutorials, and code implementations, so you can quickly grasp MCTS concepts and apply them without reinventing the wheel.

@secemp9
secemp9 / step.md
Last active February 13, 2025 13:22
step to install darknet on 22.04
sudo apt-get update
sudo apt-get install -y build-essential git cuda-libraries-dev-12-8 libopencv-dev gpg wget
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null

echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ <distro> main' | sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null

sudo apt-get update
sudo apt-get install gcc-12 g++-12
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12
@secemp9
secemp9 / gitclone.py
Created February 12, 2025 05:31
Clone large repository in depth
import os
import sys
import logging
from git import Repo, GitCommandError
def extract_repo_name(repo_url):
"""
Extracts the repository name from the given Git URL.
Supports URLs ending with '.git' and those without it.
"""
@secemp9
secemp9 / poormano1.py
Created January 22, 2025 10:03 — forked from vgel/r1.py
script to run deepseek-r1 with a min-thinking-tokens parameter, replacing </think> with a random continuation string to extend the model's chain of thought
import argparse
import random
import sys
from transformers import AutoModelForCausalLM, AutoTokenizer, DynamicCache
import torch
defo = ["\nWait, let's look at this from a system thinking approach:", "\nHmm let's look at this from a step by step approach:"]
# ~ defo = ["\nWait, but", "\nHmm", "\nSo", "\nActually"]
parser = argparse.ArgumentParser()
parser.add_argument("question", type=str)
@secemp9
secemp9 / ollama_sliding_window_retrieval.py
Created January 8, 2025 01:13
ollama sliding window retrieval with llm classification
import textwrap
from ollama import chat
# ---------------------------
# 1) Setup: Long text & question
# ---------------------------
# ~ LONG_TEXT = """
# ~ Coffee, one of the world’s most beloved beverages, has a storied history that dates back centuries. Legend has it that an Ethiopian goat herder named Kaldi first noticed his goats becoming particularly energetic after nibbling on certain red berries. This discovery eventually led to the cultivation of coffee beans in the Middle East, where Sufi monks used the brew to stay alert during nighttime prayers. Over time, the practice of preparing and drinking coffee spread across the Islamic world and into Europe, sparking a cultural revolution of cafés and intellectual discourse.
def calculate_model_size(total_parameters, precision="fp32"):
"""
Calculate the model size in GB given the total number of parameters.
Parameters:
total_parameters (int): Total number of parameters in the model.
precision (str): Precision type ("fp32" or "fp16").
Returns:
float: Model size in GB.
@secemp9
secemp9 / interaction_net.py
Created December 17, 2024 12:39
non-complete implementation of an interaction net
class Agent:
def __init__(self, name, ports=None):
self.name = name
self.ports = ports if ports else []
# Each element of ports is either None or a tuple (other_agent, other_port_index)
def __repr__(self):
return f"{self.name}"
def connect(a, pa, b, pb):
@secemp9
secemp9 / init.el
Created December 14, 2024 16:32
org mode style init.el (POC 1)
;; Process org blocks and continue initialization
(ignore-errors
(catch 'init-done
(let* ((init-file (or load-file-name buffer-file-name))
(temp-file (concat temporary-file-directory "init-processed.el")))
;; Extract elisp blocks to temp file
(with-temp-file temp-file
(insert-file-contents init-file)
(goto-char (point-min))
Direct solution weights: [0.79, 0.85, 0.84]
Forward output: [111, 117, 116]
Loss: 0