Safetensors
GGUF
Turkish
llama
Llama-3
instruct
finetune
chatml
gpt4
synthetic data
distillation
function calling
json mode
axolotl
roleplaying
chat
Instructions to use tda45/TdAI with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use tda45/TdAI with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="tda45/TdAI", filename="llama.cpp/models/ggml-vocab-aquila.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use tda45/TdAI with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf tda45/TdAI # Run inference directly in the terminal: llama cli -hf tda45/TdAI
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf tda45/TdAI # Run inference directly in the terminal: llama cli -hf tda45/TdAI
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf tda45/TdAI # Run inference directly in the terminal: ./llama-cli -hf tda45/TdAI
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf tda45/TdAI # Run inference directly in the terminal: ./build/bin/llama-cli -hf tda45/TdAI
Use Docker
docker model run hf.co/tda45/TdAI
- LM Studio
- Jan
- Ollama
How to use tda45/TdAI with Ollama:
ollama run hf.co/tda45/TdAI
- Unsloth Studio
How to use tda45/TdAI with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for tda45/TdAI to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for tda45/TdAI to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for tda45/TdAI to start chatting
- Atomic Chat new
- Docker Model Runner
How to use tda45/TdAI with Docker Model Runner:
docker model run hf.co/tda45/TdAI
- Lemonade
How to use tda45/TdAI with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull tda45/TdAI
Run and chat with the model
lemonade run user.TdAI-{{QUANT_TAG}}List all available models
lemonade list
| constexpr int kVecSize = 1 << 16; | |
| // Copy-pasted from ggml.c | |
| typedef struct { | |
| float d; // delta | |
| uint8_t qs[QK4_0 / 2]; // nibbles / quants | |
| } block_q4_0; | |
| static_assert(sizeof(block_q4_0) == sizeof(float) + QK4_0 / 2, "wrong q4_0 block size/padding"); | |
| typedef struct { | |
| float d; // delta | |
| float m; // min | |
| uint8_t qs[QK4_1 / 2]; // nibbles / quants | |
| } block_q4_1; | |
| static_assert(sizeof(block_q4_1) == sizeof(float) * 2 + QK4_1 / 2, "wrong q4_1 block size/padding"); | |
| // Copy-pasted from ggml.c | |
| typedef struct { | |
| float d; // delta | |
| float s; // d * sum(qs[i]) | |
| int8_t qs[QK8_0]; // quants | |
| } block_q8_0; | |
| static_assert(sizeof(block_q8_0) == 2*sizeof(float) + QK8_0, "wrong q8_0 block size/padding"); | |
| static_assert(QK4_1 == QK8_0, "QK4_1 and QK8_0 must be the same"); | |
| static_assert(QK4_0 == QK8_0, "QK4_0 and QK8_0 must be the same"); | |
| template <typename T> | |
| static void fillQ4blocks(std::vector<T>& blocks, std::mt19937& rndm) { | |
| for (auto& b : blocks) { | |
| b.d = 1; | |
| for (int i=0; i<QK4_1/2; ++i) { | |
| uint8_t v1 = rndm() >> 28; | |
| uint8_t v2 = rndm() >> 28; | |
| b.qs[i] = v1 | (v2 << 4); | |
| } | |
| } | |
| } | |
| static void fillQ80blocks(std::vector<block_q8_0>& blocks, std::mt19937& rndm) { | |
| for (auto& b : blocks) { | |
| b.d = 1; | |
| int sum = 0; | |
| for (int i=0; i<QK8_0; ++i) { | |
| b.qs[i] = (rndm() >> 24) - 128; | |
| sum += b.qs[i]; | |
| } | |
| b.s = b.d * sum; | |
| } | |
| } | |
| static float simpleDot(const block_q4_0& x, const block_q8_0& y) { | |
| int s1 = 0; //, s2 = 0; | |
| for (int i=0; i<QK4_1/2; i+=2) { | |
| int v1 = x.qs[i+0] & 0xf; | |
| int v2 = x.qs[i+0] >> 4; | |
| int v3 = x.qs[i+1] & 0xf; | |
| int v4 = x.qs[i+1] >> 4; | |
| int j = 2*i; | |
| s1 += v1*y.qs[j] + v2*y.qs[j+1] + v3*y.qs[j+2] + v4*y.qs[j+3]; | |
| //s2 += y.qs[j] + y.qs[j+1] + y.qs[j+2] + y.qs[j+3]; | |
| } | |
| return y.d * x.d * s1 - 8 * x.d * y.s; | |
| //return y.d * x.d * (s1 - 8 * s2); | |
| } | |
| static float simpleDot(const block_q4_1& x, const block_q8_0& y) { | |
| int s1 = 0; //, s2 = 0; | |
| for (int i=0; i<QK4_1/2; i+=2) { | |
| int v1 = x.qs[i+0] & 0xf; | |
| int v2 = x.qs[i+0] >> 4; | |
| int v3 = x.qs[i+1] & 0xf; | |
| int v4 = x.qs[i+1] >> 4; | |
| int j = 2*i; | |
| s1 += v1*y.qs[j] + v2*y.qs[j+1] + v3*y.qs[j+2] + v4*y.qs[j+3]; | |
| //s2 += y.qs[j] + y.qs[j+1] + y.qs[j+2] + y.qs[j+3]; | |
| } | |
| return y.d * x.d * s1 + y.s * x.m; | |
| //return y.d * (x.d * s1 + x.m * s2); | |
| } | |
| struct Stat { | |
| double sum = 0, sumt = 0, sumt2 = 0, maxt = 0; | |
| int nloop = 0; | |
| void addResult(double s, double t) { | |
| sum += s; | |
| sumt += t; sumt2 += t*t; maxt = std::max(maxt, t); | |
| ++nloop; | |
| } | |
| void reportResult(const char* title) const { | |
| if (nloop < 1) { | |
| printf("%s(%s): no result\n",__func__,title); | |
| return; | |
| } | |
| printf("============ %s\n",title); | |
| printf("<dot> = %g\n",sum/nloop); | |
| auto t = sumt/nloop, dt = sumt2/nloop - t*t; | |
| if (dt > 0) dt = sqrt(dt); | |
| printf("<time> = %g +/- %g us. Max. time = %g us.\n",t,dt,maxt); | |
| } | |
| }; | |
| int main(int argc, char** argv) { | |
| int nloop = argc > 1 ? atoi(argv[1]) : 10; | |
| int type = argc > 2 ? atoi(argv[2]) : 1; | |
| std::mt19937 rndm(1234); | |
| std::vector<block_q4_1> x41; | |
| std::vector<block_q4_0> x40; | |
| std::vector<block_q8_0> y(kVecSize); | |
| if (type == 0) x40.resize(kVecSize); | |
| else { | |
| x41.resize(kVecSize); | |
| for (auto& b : x41) b.m = 1; | |
| } | |
| auto ggml_type = type == 0 ? GGML_TYPE_Q4_0 : GGML_TYPE_Q4_1; | |
| const auto * funcs = ggml_get_type_traits_cpu(ggml_type); | |
| Stat simple, ggml; | |
| for (int iloop=0; iloop<nloop; ++iloop) { | |
| if (type == 0) fillQ4blocks(x40, rndm); | |
| else fillQ4blocks(x41, rndm); | |
| fillQ80blocks(y, rndm); | |
| auto t1 = std::chrono::high_resolution_clock::now(); | |
| double s = 0; | |
| if (type == 0) for (int i=0; i<kVecSize; ++i) s += simpleDot(x40[i], y[i]); | |
| else for (int i=0; i<kVecSize; ++i) s += simpleDot(x41[i], y[i]); | |
| auto t2 = std::chrono::high_resolution_clock::now(); | |
| auto t = 1e-3*std::chrono::duration_cast<std::chrono::nanoseconds>(t2-t1).count(); | |
| if (iloop > 3) simple.addResult(s, t); | |
| t1 = std::chrono::high_resolution_clock::now(); | |
| float fs; | |
| if (type == 0) funcs->vec_dot(kVecSize * QK4_1, &fs, 0, x40.data(), 0, y.data(), 0, 1); | |
| else funcs->vec_dot(kVecSize * QK4_1, &fs, 0, x41.data(), 0, y.data(), 0, 1); | |
| t2 = std::chrono::high_resolution_clock::now(); | |
| t = 1e-3*std::chrono::duration_cast<std::chrono::nanoseconds>(t2-t1).count(); | |
| if (iloop > 3) ggml.addResult(fs, t); | |
| } | |
| // Report the time (and the average of the dot products so the compiler does not come up with the idea | |
| // of optimizing away the function calls after figuring that the result is not used). | |
| simple.reportResult("Simple"); | |
| ggml.reportResult("ggml"); | |
| return 0; | |
| } | |