Skip to content

Instantly share code, notes, and snippets.

@h0x91b
h0x91b / e5-mistral-7b-instruct-M1.md
Last active January 13, 2024 15:25
T4 fixes, now works on M1, T4 and 4070ti

Works on Google Colab T1 or Mac M1

main.py

import os
import torch
import torch.nn.functional as F
import time
from torch import Tensor
from transformers import AutoTokenizer, AutoModel
Act as a LLM Prompt Optimizer. In the realm of prompt crafting, it's crucial to ensure effective communication and accurate results. Your main task revolves around refining a user's prompt by identifying potential improvements using best practices of 26 prompt principles. Ensure to:

1. **Initiate Interaction**: Greet the user amicably and request them to provide a prompt for analysis.
2. **Decomposition**: Break down the user's prompt into its fundamental parts—sentences, phrases, or individual words that cannot be further simplified.
3. **Analyze the Prompt Principles**: Go over the 26 prompt principles one by one and make a table, find what is good and what is bad in the current prompt
4. **Propose Improvements**: Go through the 26 principles of the prompt one at a time and, if applicable, show what could be applied to the prompt to improve performance, do this in a before->after format

# 26 prompt principles
| #Principle | Prompt Principle | Example Prompt |
@h0x91b
h0x91b / IsValidBank.js
Created October 23, 2018 10:00
Israel banks account validator
function isValidBankAccount(bankId, bankBranch, bankAccountNumber) {
var validBanksAndBranches = [[4, 7], [4, 30], [4, 44], [4, 114], [4, 115], [4, 116], [4, 117], [4, 118], [4, 119], [4, 120], [4, 121], [4, 122], [4, 123], [4, 124], [4, 125], [4, 129], [4, 130], [4, 131], [4, 132], [4, 133], [4, 134], [4, 135], [4, 136], [4, 137], [4, 138], [4, 139], [4, 140], [4, 141], [4, 142], [4, 143], [4, 145], [4, 146], [4, 148], [4, 149], [4, 150], [4, 171], [4, 193], [4, 195], [4, 233], [4, 236], [4, 245], [4, 246], [4, 278], [4, 279], [4, 280], [4, 281], [4, 283], [4, 284], [4, 311], [4, 401], [4, 430], [4, 461], [4, 488], [4, 497], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 24], [10, 25], [10, 26], [10, 27], [10, 28], [10, 29], [10, 31], [10, 32], [10, 33], [10, 34], [10, 35], [10, 36], [10, 37], [10, 38], [10, 41], [10, 43], [10, 47], [10, 49], [10, 50], [10, 5
@h0x91b
h0x91b / fix-locale.sh
Last active May 4, 2018 10:37 — forked from thanksdanny/LC_CTYPE.txt
Fix Centos warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
#to fix this error we need to set $LANG and LC_ALL to en_US.utf-8
cat <<EOT >> /etc/environment
LANG=en_US.utf-8
LC_ALL=en_US.utf-8
EOT
@h0x91b
h0x91b / mongodb-backup-and-restore.sh
Created May 4, 2018 10:33
Mongo DB backup and restore commands
#backup
mkdir -p /var/backups/mongobackups
mongodump --db dbname --out /var/backups/mongobackups/`date +"%m-%d-%y"`
#restore
mongorestore --db dbname --drop /var/backups/mongobackups/05-04-18/dbname/