Text Generation
PyTorch
GGUF
English
blacksmith_nanogpt
conversational
long-context
from-scratch
custom-architecture
522m
Instructions to use TriusAI/blacksmith-1a with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use TriusAI/blacksmith-1a 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 TriusAI/blacksmith-1a:Q4_K_M # Run inference directly in the terminal: llama cli -hf TriusAI/blacksmith-1a:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf TriusAI/blacksmith-1a:Q4_K_M # Run inference directly in the terminal: llama cli -hf TriusAI/blacksmith-1a:Q4_K_M
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf TriusAI/blacksmith-1a:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf TriusAI/blacksmith-1a:Q4_K_M
Use Docker
docker model run hf.co/TriusAI/blacksmith-1a:Q4_K_M
- Llama new
- LM Studio
- Jan
- vLLM
How to use TriusAI/blacksmith-1a with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "TriusAI/blacksmith-1a" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TriusAI/blacksmith-1a", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/TriusAI/blacksmith-1a:Q4_K_M
- Ollama
How to use TriusAI/blacksmith-1a with Ollama:
ollama run hf.co/TriusAI/blacksmith-1a:Q4_K_M
- Unsloth Desktop
- Docker Model Runner
How to use TriusAI/blacksmith-1a with Docker Model Runner:
docker model run hf.co/TriusAI/blacksmith-1a:Q4_K_M
- Lemonade
How to use TriusAI/blacksmith-1a with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull TriusAI/blacksmith-1a:Q4_K_M
Run and chat with the model
lemonade run user.blacksmith-1a-Q4_K_M
List all available models
lemonade list
- Atomic Chat
File size: 2,588 Bytes
2054ea3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | import os
import json
import pathlib
from transformers import GPT2Tokenizer
# we use the format `<|im_start|>{role}\n{content}<|im_end|>`, e.g.:
#
# User: What color is the sky?
# Assistant: Blue, when it's sunny and the sun is not blocked
# by the clouds.
#
# would be encoded as:
#
# <|im_start|>user
# What color is the sky?<|im_end|>
# <|im_start|>assistant
# Blue, when it's sunny and the sun is not blocked by the clouds.<|im_end|>
Tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
Tokenizer.add_special_tokens({'additional_special_tokens': ['<|im_start|>', '<|im_end|>']})
# script for preparing UltraChat to a single .bin file (so i can memmap)
# the dataset is downloaded from:
# https://huggingface.co/datasets/openbmb/UltraChat/tree/main
# which is in .jsonl.
# if you have downloaded the gpt2 tokenizer already it's strongly
# recommended that you run this with HF_HUB_OFFLINE=1 because those
# rat bastards just have to make their library poke the internet with
# its HTTP client dick despite having downloaded the fucking thing to
# local cache.
dataset_path = pathlib.Path('/home/bctnry/workspace/datasets/UltraChat/')
result = open('UltraChat_uint16le.bin', 'wb')
failed = []
EOT = Tokenizer.eos_token_id
def write_tokens(tokens):
for tok in tokens:
byte1 = tok%256
byte2 = (tok//256)%256
result.write(bytes([byte1, byte2]))
for file_i in range(0, 10): # files: train_0 ~ train_9
print(f'processing file `train_{file_i}.jsonl`...')
with open(dataset_path / f'train_{file_i}.jsonl', 'r') as f:
i = 0
while True:
a = f.readline()
if not a.strip(): break
try:
j = json.loads(a)
except:
failed.append((a, file_i, i))
continue
for ii, d in enumerate(j['data']):
role = 'user' if ii % 2 == 0 else 'assistant'
s = f'<|im_start|>{role}\n{d}<|im_end|>\n'
encoded = Tokenizer.encode(s)
write_tokens(encoded)
write_tokens([EOT])
i += 1
if i % 100 == 0:
print('.', end='', flush=True)
if i % 10000 == 0:
print(f' file {file_i}: {i} conversations', flush=True)
result.close()
with open('failed_items.txt', 'w') as f:
for k, _, _ in failed:
f.write(k)
f.write('\n')
with open('failed_item_location.txt', 'w') as f:
for _, file_i, i in failed:
f.write(f'file {file_i} line {i}\n')
|