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
Download code/dataset_mixed.py from TriusAI/blacksmith-1a: direct link, hf CLI and curl.
- Browser
- Download file 4.56 kB
-
https://huggingface.co/TriusAI/blacksmith-1a/resolve/main/code/dataset_mixed.py
- Command line
-
hf download hf://TriusAI/blacksmith-1a/code/dataset_mixed.py
-
curl -L -o dataset_mixed.py https://huggingface.co/TriusAI/blacksmith-1a/resolve/main/code/dataset_mixed.py
4.56 kB
| import os | |
| import torch | |
| import numpy as np | |
| class MixedDatasetManager: | |
| """ | |
| Dataset manager that mixes multiple sources of pre-tokenized uint16 | |
| little-endian .bin files. | |
| Each "source" is a group of .bin files treated as one logical corpus. | |
| A mixing weight controls how often each source is sampled per batch. | |
| Example: | |
| ds = MixedDatasetManager(device, [ | |
| ('cosmopedia', ['cosmopediav2_00000000.bin', ...], 0.85), | |
| ('ultrachat', ['UltraChat_uint16le.bin'], 0.15), | |
| ]) | |
| x, y = ds.get_batch(32, 1024) | |
| All files within a source are concatenated logically (offsets are | |
| remapped across file boundaries), so a window never spans two files | |
| of the same source — but it CAN span a document boundary inside a | |
| file (the EOT tokens sprinkled in by prepare_*.py act as soft | |
| separators; the model learns to recover across them, same as | |
| dataset2.py). | |
| """ | |
| def __init__(self, device, sources): | |
| """ | |
| sources: list of (name, files, weight) tuples. | |
| name : str, label for logging | |
| files : list of str, paths to .bin files | |
| weight : float, relative sampling probability (need not sum to 1) | |
| """ | |
| self.device = device | |
| self.sources = [] | |
| total_weight = sum(w for _, _, w in sources) | |
| if total_weight <= 0: | |
| raise ValueError('total mixing weight must be positive') | |
| for name, files, weight in sources: | |
| if not files: | |
| raise ValueError(f'source "{name}" has no files') | |
| memmaps = [] | |
| lengths = [] | |
| cum = [0] | |
| skipped = [] | |
| for f in files: | |
| if not os.path.exists(f): | |
| skipped.append(f) | |
| continue | |
| m = np.memmap(f, dtype=np.uint16, mode='r') | |
| memmaps.append(m) | |
| lengths.append(len(m)) | |
| cum.append(cum[-1] + len(m)) | |
| if skipped and len(memmaps) == 0: | |
| raise FileNotFoundError( | |
| f'source "{name}": none of its files exist ' | |
| f'(missing: {skipped})' | |
| ) | |
| self.sources.append({ | |
| 'name': name, | |
| 'memmaps': memmaps, | |
| 'lengths': np.array(lengths, dtype=np.int64), | |
| 'cum': np.array(cum, dtype=np.int64), | |
| 'total': cum[-1], | |
| 'weight': weight / total_weight, | |
| 'missing': skipped, | |
| }) | |
| self.weights = torch.tensor([s['weight'] for s in self.sources], | |
| dtype=torch.float, device=device) | |
| def _sample_window(self, source, seq_len): | |
| """Sample one (x, y) window of length seq_len from a source.""" | |
| total = source['total'] | |
| if total < seq_len + 2: | |
| raise ValueError( | |
| f'source "{source["name"]}" ({total} tokens) too small ' | |
| f'for seq_len={seq_len}' | |
| ) | |
| # Global offset within the source's logical concatenation. | |
| s = int(torch.randint(0, total - seq_len - 1, (1,)).item()) | |
| # Find which file this offset falls into. | |
| fidx = int(np.searchsorted(source['cum'], s, side='right')) - 1 | |
| local = s - source['cum'][fidx] | |
| m = source['memmaps'][fidx] | |
| # `s` is bounded by the *source* total, so a draw can land within | |
| # seq_len of the next file's first token. Slicing there yields a | |
| # short window, and the mixed batch then dies in np.stack with | |
| # "all input arrays must have the same shape". Re-draw inside this | |
| # file so every window stays within a single file. | |
| if local + seq_len + 1 > len(m): | |
| local = int(torch.randint(0, len(m) - seq_len - 1, (1,)).item()) | |
| x = np.array(m[local:local + seq_len], dtype=np.int64) | |
| y = np.array(m[local + 1:local + seq_len + 1], dtype=np.int64) | |
| return x, y | |
| def get_batch(self, batch_size, seq_len): | |
| # Pick which source each slot in the batch draws from. | |
| src_idx = torch.multinomial(self.weights, batch_size, replacement=True) | |
| xs, ys = [], [] | |
| for i in src_idx.tolist(): | |
| x, y = self._sample_window(self.sources[i], seq_len) | |
| xs.append(x) | |
| ys.append(y) | |
| x = torch.tensor(np.stack(xs), dtype=torch.long, device=self.device) | |
| y = torch.tensor(np.stack(ys), dtype=torch.long, device=self.device) | |
| return x, y |