Skip to content

Instantly share code, notes, and snippets.

View usametov's full-sized avatar

Ulan Sametov usametov

  • Asta Nova Enterprise Solutions
View GitHub Profile
@usametov
usametov / HF-indeference-api.md
Created March 30, 2025 02:37
HF inference API howto

To run the TheBloke/Mistral-7B-OpenOrca-AWQ model on Hugging Face infrastructure using a Clojure clj-http client, you’ll need to leverage Hugging Face's Inference API, which allows you to make HTTP requests to run models hosted on their platform. Since you have a Hugging Face Pro account, you can use this API with your authentication token for enhanced access (e.g., higher rate limits or access to private models, though this specific model is public).

Here’s a step-by-step guide to achieve this:


Step 1: Prerequisites

@usametov
usametov / graphrag-hybrid-qdrant-neo4j.md
Last active March 31, 2025 20:54
hybridsearch algorithm

To modify the previous implementation to use Qdrant for hybrid search (vector + keyword search) while keeping Neo4j for Cypher queries in Clojure, we’ll integrate the Qdrant database for the hybrid search part and use Neo4j solely for graph-based Cypher retrieval. Below, I’ll adapt the code assuming you have a Qdrant instance running and a Neo4j database populated with graph data. We’ll use the Qdrant REST API via clj-http for simplicity, as there’s no official Clojure client for Qdrant (though you could use a gRPC client if preferred).


Prerequisites

  1. Qdrant Instance: Running locally (e.g., http://localhost:6333) or on a remote server, with a collection set up for hybrid search (vector embeddings + text payloads).
  2. Neo4j Database: Populated and accessible via Bolt (e.g., bolt://localhost:7687).
  3. Clojure Dependencies: Add clj-http and cheshire (for JSON parsing) to your project.clj:
@usametov
usametov / rest-kit-clj.md
Created March 28, 2025 05:35
kit clj rest api example

The Kit framework (https://kit-clj.github.io/) is a lightweight, modular framework for scalable web development in Clojure. It uses Reitit for routing and Integrant for system management, making it well-suited for building REST APIs. Below is an example of how you can create a simple REST API using Kit, based on its conventions and structure.

This example assumes you’ve set up a Kit project (e.g., yourname/guestbook) and will demonstrate a basic REST API with endpoints to manage a list of messages (e.g., a guestbook). I'll walk you through the key parts.


Example: Simple Guestbook REST API

1. Project Setup

If you haven’t already, create a Kit project:

@usametov
usametov / reasoning-agent.md
Created March 26, 2025 16:51
reasoning agent

I’ve reviewed the page at reasoningagent, which describes the ReasoningAgent in AG2 (formerly AutoGen). This agent implements a Tree of Thoughts (ToT) reasoning framework with beam search to enhance LLM problem-solving by exploring multiple reasoning paths systematically. Let’s evaluate whether this can be improved using a reasoning model (assuming you mean enhancing its reasoning capabilities further with Grok or a similar approach) and propose new prompts to achieve that.

Analysis of Current ReasoningAgent

The ReasoningAgent:

  • Purpose: Enhances LLM reasoning for complex problems by simulating a tree-like exploration of solution paths using beam search.
  • Key Features:
    • Beam search with configurable beam_size (e.g., 1 for Chain-of-Thought, >1 for multi-path exploration).
  • Depth-limited search (max_depth) to control complexity.
@usametov
usametov / frugal-tractor.md
Last active March 17, 2025 18:08
DIY tractor

-- cost-effective, open-source solutions for building farming equipment, such as a cheap DIY tractor.


Dedicated DIY Farming Forums

  1. Farm Hack Community Forum      - Description: Farm Hack is a worldwide community of farmers, engineers, and innovators who build, modify, and share tools for resilient, small-scale agriculture. Their online forum is a hub for discussing DIY farming tools, sharing innovations, and collaborating on projects. It’s an excellent place to connect with others working on DIY tractor designs or similar equipment.    - Access: Visit the Farm Hack forum to browse discussions, post questions, or share ideas. Topics include tractor modifications, tool designs, and sustainable farming practices.    - Relevance: This forum is ideal for networking with like-minded DIY enthusiasts and accessing practical advice on building low-cost farming equipment, including tractors.
@usametov
usametov / extenal-insulation.md
Last active March 17, 2025 18:58
cheap foundation for modular home

Living through a Canadian winter means dealing with extreme cold, so effective insulation is key to keeping your home warm and energy costs down. Here are some cheap and effective DIY external insulation solutions tailored for Canadian winters, where temperatures can drop well below freezing:

1. Rigid Foam Board Insulation

  • What It Is: Rigid foam boards (like expanded polystyrene (EPS), extruded polystyrene (XPS), or polyisocyanurate) are affordable, lightweight, and provide excellent thermal resistance (R-value).
  • Why It Works: These boards can be applied to exterior walls to reduce heat loss, especially in older homes with poor insulation. XPS is particularly good for moisture resistance, which is crucial in snowy and wet Canadian winters.
  • How to DIY:
    1. Measure the exterior walls of your home and purchase enough foam boards to cover the area. XPS typically offers R-5 per inch of thickness.
    2. Clean and dry the exterior walls, removing any loose paint or debris.
@usametov
usametov / add-txt2img.md
Last active March 15, 2025 05:48
SuperCollider scripts for generating binaural beats and syncing them with visual outputs via OSC (Open Sound Control) to control lights or other visual elements.

-- explore the concept, look at related efforts, and critically assess the feasibility based on available tools and trends.

What This Would Look Like

Syncing binaural beats with text-to-image diffusion models to create videos would involve:

  1. Audio Component: Generating binaural beats (e.g., two tones like 200 Hz and 210 Hz to produce a 10 Hz beat) to influence brainwave states (e.g., relaxation, focus).
  2. Visual Component: Using a text-to-image diffusion model (e.g., Stable Diffusion) to generate frames based on prompts, potentially evolving over time to match the audio’s rhythm or frequency.
  3. Video Synthesis: Combining these frames into a video where the visuals transition or pulse in sync with the binaural beat frequency, possibly using a text-to-video extension (e.g., AnimateDiff, ModelScope) or manual frame sequencing.
  4. Purpose: Creating an audio-visual entrainment (AVE) experience where the video enhances the brainwave effects of the binaural beats.

Evidence of Related Ef

@usametov
usametov / mat2parquet.md
Created March 14, 2025 16:27
Python script to read MATLAB (.mat) file and save it as a Parquet

Let us use the scipy.io library to read MATLAB files and pandas with pyarrow to handle Parquet file conversion.

Here's a comprehensive example:

# First, install required packages if you haven't already
# pip install scipy pandas pyarrow numpy

import scipy.io
import pandas as pd
@usametov
usametov / gemma3-colab-tutorial.md
Last active March 13, 2025 18:43
gemma 3 27B on colab tpu using JAX

Running the Gemma 3-27B model on a TPU using JAX in Google Colab requires careful setup, as the model is large and TPUs have specific requirements for efficient execution. Below is a step-by-step guide to help you achieve this. Note that the Gemma 3-27B model is computationally intensive, and Google Colab's free TPU resources may not be sufficient due to memory and runtime limitations. You may need access to premium Colab resources or alternative platforms like Kaggle or Google Cloud TPUs for successful execution.

Step-by-Step Guide

1. Set Up Google Colab with TPU Runtime

  • Open a new notebook in Google Colab: Google Colab.
  • Go to the Runtime menu, select Change runtime type, and choose TPU v2 as the hardware accelerator. Note that Colab provides TPU v2, which may not have enough memory for a 27B model, so consider upgrading to a paid plan or using an alternative platform if necessary.

2. Install Required Libraries

  • You need
@usametov
usametov / bipartite-graph.md
Last active March 13, 2025 00:57
graph theory: men and women

https://grok.com/share/bGVnYWN5_046f4fe1-c33f-4c68-a4d6-51711bc40c07

To address the statement "men also have more sexual partners than women" using graph theory, we can model heterosexual relationships as a bipartite graph and analyze the implications. This approach helps us rigorously evaluate the statement, particularly in the context of averages, which is often implied in such claims.

Step 1: Define the Problem and Model

The statement compares the number of sexual partners between men and women, typically interpreted as comparing the average number of partners. We will focus on heterosexual relationships for simplicity, as this is the most straightforward interpretation of the statement (though we can later consider extensions to other cases). In graph theory terms, we can represent heterosexual relationships as a bipartite graph:

  • Let ( M ) be the set of all men, and ( W ) be the set of all women.
  • An edge ( (m, w) ) exists between a man ( m \in M ) and a woman ( w \in W ) if they have