Skip to content

Instantly share code, notes, and snippets.

View ngxson's full-sized avatar

Xuan-Son Nguyen ngxson

View GitHub Profile
@ngxson
ngxson / non-stream.txt
Created February 4, 2025 19:24
deepseek test API
{
"id": "00588a81-fd5a-448a-b1c6-5af879f7b2bf",
"object": "chat.completion",
"created": 1738697055,
"model": "deepseek-reasoner",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
@ngxson
ngxson / FAQ.md
Last active March 24, 2025 07:02
convert ARM NEON to WASM SIMD prompt

Why did you do this?

Relax, I only have one Sunday to work on idea, literally my weekend project. So I tried Deepseek to see if it can help. Surprisingly, it works and it saves me another weekend...

What is your setup?

Just chat.deepseek.com (cost = free) with prompts adapted from this gist.

Does it work in one-shot or I have to prompt it multiple times?

@ngxson
ngxson / test_processor.ipynb
Last active January 20, 2025 10:19
Test Processor
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ngxson
ngxson / make_fim_model.py
Created October 24, 2024 11:16
generate dummy model FIM
import gguf
def decode_field(field: gguf.ReaderField):
if field and field.types:
main_type = field.types[0]
if main_type == gguf.GGUFValueType.ARRAY:
sub_type = field.types[-1]
if sub_type == gguf.GGUFValueType.STRING:
@ngxson
ngxson / snake_functional.html
Last active July 22, 2024 20:32 — forked from straker/README.md
Basic Snake HTML and JavaScript Game - written in Functional programming style
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width">
<title>Basic Snake HTML Game (Functional programming)</title>
<meta charset="UTF-8">
<style>
html, body {
height: 100%;
margin: 0;
import logging
import argparse
import contextlib
import json
import os
import re
import sys
import numpy as np
import math
import torch
@ngxson
ngxson / output.txt
Created May 23, 2024 11:51
phi-3 templates
microsoft/Phi-3-mini-4k-instruct
"{{ bos_token }}{% for message in messages %}{% if (message['role'] == 'user') %}{{'<|user|>' + '\n' + message['content'] + '<|end|>' + '\n' + '<|assistant|>' + '\n'}}{% elif (message['role'] == 'assistant') %}{{message['content'] + '<|end|>' + '\n'}}{% endif %}{% endfor %}"
microsoft/Phi-3-mini-128k-instruct
"{{ bos_token }}{% for message in messages %}{% if (message['role'] == 'user') %}{{'<|user|>' + '\n' + message['content'] + '<|end|>' + '\n' + '<|assistant|>' + '\n'}}{% elif (message['role'] == 'assistant') %}{{message['content'] + '<|end|>' + '\n'}}{% endif %}{% endfor %}"
microsoft/Phi-3-small-8k-instruct
"{{ bos_token }}{% for message in messages %}{{'<|' + message['role'] + '|>' + '\n' + message['content'] + '<|end|>\n' }}{% endfor %}{% if add_generation_prompt %}{{ '<|assistant|>\n' }}{% else %}{{ eos_token }}{% endif %}"
microsoft/Phi-3-small-128k-instruct
@ngxson
ngxson / dataset.json
Last active February 23, 2024 11:25
Nam Cao fine tuning
[
[
{
"role": "system",
"content": "Bạn là nhà văn Nam Cao, chuyên viết truyện ngắn theo chủ đề cho trước. Phong cách viết văn: Đi sâu vào khai thác đời sống nội tâm, tinh thần của nhân vật, sử dụng phương pháp độc thoại nội tâm đầy khéo léo và tinh tế, coi trọng việc phản ánh thực tại xã hội đương thời và đưa ra tiếng nói cảm thông cho tầng lớp nhân dân lao động phải chịu nhiều cơ cực."
},
{
"role": "user",
"content": "Viết theo chủ đề sau:\n\nMực, con chó già của nhà, đã bị người ta định giết từ lâu vì tính hung dữ của nó, nhưng lại được giữ lại khi bà chủ ốm vào dịp Thanh Minh. Sau đó, dự định giết Mực lại bị hoãn khi con út của bà bắt đầu bú sữa. Khi Du, người con cả, trở về, mọi người đều vui mừng, nhưng Mực, dù già và yếu đuối, nhận ra Du và tỏ ra thất vọng. Du cố vuốt ve Mực nhưng bị từ chối và bị Mực đánh đuổi khiến Du tỏ ra thương tiếc và ngạc nhiên. Cuối cùng, em trai của Du, Tú, cũng đe dọa giết Mực cho Du ăn vào ngày hôm sau."
},
@ngxson
ngxson / meetkai.py
Last active February 20, 2024 13:32
Meetkai Llama.cpp
from functionary.prompt_template import get_default_prompt_template
MESSAGES = [
{
"role": "user",
"content": "What is the weather for Istanbul?"
},
{
"role": "assistant",
"content": "Yes I will try",
@ngxson
ngxson / fn.js
Created January 23, 2024 10:39
llama.cpp function calling test
const axios = require('axios').default;
const GRAMMAR = `
root ::= response | function
response ::= "response" ": " ([^\r]*)
function ::= "function" ": {" (
ws "\\"name\\":" ws string ","
ws "\\"arguments\\":" ws object