Skip to content

Instantly share code, notes, and snippets.

View craftgear's full-sized avatar
🏠
Working from home

Captain Emo craftgear

🏠
Working from home
View GitHub Profile
@craftgear
craftgear / avif.md
Last active March 5, 2021 02:34
avifについて調べたことまとめ 2021年3月時点

比較

表示

  • Chrome 85以降
  • Firefox 77以降
    • about:configでフラグを立てる必要あり

編集

@craftgear
craftgear / cut.sh
Created December 1, 2020 11:14
Twitter用に動画の一部を切り抜いてフェードイン・フェードアウトするワンライナー
#!/bin/sh
# 使い方
# cut.sh 開始時間 終了時間 元のファイル
#
# 例) 1時間32分15秒から、1時間34分5秒まで切り取る
# cut.sh 1:32:15 1:34:05 input.mp4
ffmpeg -ss $1 -to $2 -i "$3" -vf fade=d=1.0,reverse,fade=d=1.0,reverse -af afade=d=1.0,areverse,afade=d=1.0,areverse -c:a aac output.mp4
@craftgear
craftgear / gist:944a23d226f6e3734bb5de2f68178c73
Created December 2, 2023 08:41
ffmpegを使って2秒に1枚の割合でスクショを撮る
ffmpeg -i movie.mp4 -r 1/2 ./frame_%04d.jpg
@craftgear
craftgear / onion_architecture_how_to_avoid_domain_knowledge_in_sql.md
Last active February 5, 2025 10:41
Onion Architecture: How to prevent domain knowledge from creeping into infra layer

One of the headaches I have been bugged by is domain knowledge in SQL queries when it comes to configure code base with Onion Architecture.

If you want to filter data, it is not realistic to use Array.filter to filter the data after retrieving it by SQL, as it consumes memory and is bad for performance.

I have no choice but to write the filter conditions in the WHERE clause of SQL, but I thought it might be a good idea to define the conditions in the WHERE clause as constants in the domain layer.

Example: Extracting customers who have purchased more than 1,000,000 yen in the past year as valued customers

Problem

LLM Samplers Explained

Everytime a large language model makes predictions, all of the thousands of tokens in the vocabulary are assigned some degree of probability, from almost 0%, to almost 100%. There are different ways you can decide to choose from those predictions. This process is known as "sampling", and there are various strategies you can use which I will cover here.

OpenAI Samplers

Temperature

  • Temperature is a way to control the overall confidence of the model's scores (the logits). What this means is that, if you use a lower value than 1.0, the relative distance between the tokens will become larger (more deterministic), and if you use a larger value than 1.0, the relative distance between the tokens becomes smaller (less deterministic).
  • 1.0 Temperature is the original distribution that the model was trained to optimize for, since the scores remain the same.
  • Graph demonstration with voiceover: https://files.catbox.moe/6ht56x.mp4
@craftgear
craftgear / local_llm_glossary.md
Created March 16, 2025 13:00 — forked from kalomaze/local_llm_glossary.md
Local LLM Glossary v2

Kalomaze's Local LLM Glossary

Not super comprehensive (yet), but I think having up to date documentation like this should be quite helpful for those out of the loop. Things change all the time in local AI circles, and it can be dizzying to catch up from an outsider's perspective, especially if you are new to the more technical aspects of language models in general (and not just locally hosted LLMs).

Available Models

Llama

  • A language model series created by Meta. Llama 1 was originally leaked in February 2023; Llama 2 then officially released later that year with openly available model weights & a permissive license. Kicked off the initial wave of open source developments that have been made when it comes to open source language modeling. The Llama series comes in four distinct sizes: 7b, 13b, 34b (only Code Llama was released for Llama 2 34b), and 70b. As of writing, the hotly anticipated Llama 3 has yet to arrive.

Mistral

  • Mistral AI is a French company that also distributes open weight