-
quite powerful as it simplies the writing the system prompt
-
often need an extra step of post processing, which can be done by LLM or traditional programs.
-
structured output vs json mode:
- structured output: 100% gurantee schema; schema doesn't consume tokens
-
json: scheme usually goes to system prompts, costing tokens, doesn't guarantee json or scheme correctness.
pipx install llm
llm install llm-gemini
llm -m gemini-1.5-flash-latest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## sudo visudo -f /etc/sudoers.d/custom_config | |
| # /etc/sudoers.d/custom_config | |
| # Extend the sudo ticket lifetime to 2 hours (7200 seconds) | |
| Defaults timestamp_timeout=7200 | |
| # Allow your user to run the script without a password | |
| wei ALL=(ALL) NOPASSWD: /Users/wei/start_nano_transcriber.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class FeedbackManager: | |
| """ | |
| Manage user feedback by printing a message and printing dots after it. | |
| This class takes care of printing a message and then appending dots to it | |
| until told to clear. It also handles clearing the feedback by deleting the | |
| message and dots. | |
| The printing of dots is done in a separate thread to avoid blocking. | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AudioRecorder: | |
| def __init__(self): | |
| self.is_recording = False | |
| self.recording_queue = queue.Queue() | |
| self.stop_recording = threading.Event() | |
| self.recording_thread = None | |
| def start_recording(self): | |
| if not self.is_recording: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import torch | |
| import torch.nn as nn | |
| import torch.nn.functional as F | |
| class NF4Quantizer(nn.Module): | |
| def __init__(self): | |
| super().__init__() | |
| self.nf4_values = torch.tensor([ | |
| -1.0, -0.6961928009986877, -0.5250730514526367, -0.39491748809814453, | |
| -0.28444138169288635, -0.18477343022823334, -0.09105003625154495, 0.0, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pynput import keyboard | |
| from pynput.keyboard import Key, Controller | |
| # For simulating keyboard presses | |
| keyboard_controller = Controller() | |
| def on_press(key): | |
| try: | |
| print(f'Alphanumeric key pressed: {key.char}') | |
| except AttributeError: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import math | |
| import torch | |
| import torch.nn as nn | |
| class RotaryPositionEmbedding(nn.Module): | |
| """ | |
| Implements Rotary Position Embedding (RoPE) as a PyTorch module. | |
| Args: | |
| dim (int): Dimension of the embedding (must be even) |