Skip to content

Instantly share code, notes, and snippets.

View dboyliao's full-sized avatar

dboyliao dboyliao

View GitHub Profile
@dboyliao
dboyliao / blog.md
Created July 19, 2023 02:17 — forked from Hellisotherpeople/blog.md
You probably don't know how to do Prompt Engineering, let me educate you.

You probably don't know how to do Prompt Engineering

(This post could also be titled "Features missing from most LLM front-ends that should exist")

Apologies for the snarky title, but there has been a huge amount of discussion around so called "Prompt Engineering" these past few months on all kinds of platforms. Much of it is coming from individuals who are peddling around an awful lot of "Prompting" and very little "Engineering".

Most of these discussions are little more than users finding that writing more creative and complicated prompts can help them solve a task that a more simple prompt was unable to help with. I claim this is not Prompt Engineering. This is not to say that crafting good prompts is not a difficult task, but it does not involve doing any kind of sophisticated modifications to general "template" of a prompt.

Others, who I think do deserve to call themselves "Prompt Engineers" (and an awful lot more than that), have been writing about and utilizing the rich new eco-system

@dboyliao
dboyliao / universal_ref.cpp
Created April 17, 2022 06:39
Simple Example of Universal Reference
#include <iostream>
#include <type_traits> // std::is_same
class Foo {
public:
Foo() = default;
Foo(const Foo &other) { std::cout << "copy!" << std::endl; }
Foo &operator=(const Foo &other) {
std::cout << "copy = !" << std::endl;
return *this;
@dboyliao
dboyliao / thread_with_callable.cpp
Created April 15, 2022 01:56
simple threading c++ with callable object
#include <iostream>
#include <thread>
class F {
private:
int data;
public:
F(int data_) : data(data_) {}
F(const F &other) : data(other.data) { std::cout << "copy!" << std::endl; }
@dboyliao
dboyliao / .gitignore
Last active March 16, 2022 09:33
Simple C++ Example for CRTP
build
lib
bin
.vscode
@dboyliao
dboyliao / Main.scala
Created February 9, 2022 02:52
Spark Simple Example
import org.apache.spark.sql.{SparkSession, Row, types => T}
import org.apache.log4j.{Logger, Level}
object Main extends App {
Logger.getLogger("org").setLevel(Level.ERROR)
val spark = SparkSession
.builder()
.appName("hello-world")
.master("local[2]")
@dboyliao
dboyliao / .gitignore
Last active August 19, 2021 08:26
move semantic example code
cpp_move_example
@dboyliao
dboyliao / strided_iter_product.py
Last active June 4, 2021 08:39
pure python implementation of strided slice
import numpy as np
class StridedIterator:
"""
Reference:
- https://github.com/python/cpython/blob/b2bf2bc1ece673d387341e06c8d3c2bc6e259747/Modules/itertoolsmodule.c#L2342
"""
def __init__(self, begin, end, strides):
self._idx_cnt = list(begin)
"""
Just for fun: https://www.facebook.com/groups/706762492694458/permalink/4414710665232937/
"""
import numpy as np
class Word:
__map = {
("金", "金"): "鍂",
@dboyliao
dboyliao / np_tuplize.py
Last active October 21, 2020 12:39
Broadcasted tuple
#!/usr/bin/env python3
# https://gist.github.com/dboyliao/ccb5970ccafd6d5c0420d39514cb0464
from pprint import pprint
import numpy as np
class _Tuple:
def __init__(self, *values):
self.__values = values
import numpy as np
def distance_vec(X):
# (x - y)^2 = x^2 + y^2 - 2xy
prod = -2 * X.dot(X.T)
sq = (X ** 2).sum(axis=-1)
return sq + sq[:, None] + prod