Text Generation
Transformers
Safetensors
English
gpt
ww2
wwii
world-war-ii
world-war-two
second-world-war
history
military-history
historical
wikipedia
question-answering
chat
chatbot
conversational
assistant
domain-specific
small-language-model
small-model
from-scratch
trained-from-scratch
decoder-only
causal-lm
chatml
closed-book
english
rope
sentencepiece
custom_code
peacebell
Instructions to use wayneworkman2012/peacebell-v1-148M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use wayneworkman2012/peacebell-v1-148M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="wayneworkman2012/peacebell-v1-148M", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("wayneworkman2012/peacebell-v1-148M", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use wayneworkman2012/peacebell-v1-148M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "wayneworkman2012/peacebell-v1-148M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "wayneworkman2012/peacebell-v1-148M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/wayneworkman2012/peacebell-v1-148M
- SGLang
How to use wayneworkman2012/peacebell-v1-148M with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "wayneworkman2012/peacebell-v1-148M" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "wayneworkman2012/peacebell-v1-148M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "wayneworkman2012/peacebell-v1-148M" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "wayneworkman2012/peacebell-v1-148M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use wayneworkman2012/peacebell-v1-148M with Docker Model Runner:
docker model run hf.co/wayneworkman2012/peacebell-v1-148M
Download run_model.py from wayneworkman2012/peacebell-v1-148M: direct link, hf CLI and curl.
- Browser
- Download file 5.67 kB
-
https://huggingface.co/wayneworkman2012/peacebell-v1-148M/resolve/main/run_model.py
- Command line
-
hf download hf://wayneworkman2012/peacebell-v1-148M/run_model.py
-
curl -L -o run_model.py https://huggingface.co/wayneworkman2012/peacebell-v1-148M/resolve/main/run_model.py
5.67 kB
| #!/usr/bin/env python3 | |
| """ | |
| Chat with this model on your own machine. | |
| pip install -r requirements.txt | |
| python run_model.py # multi-turn chat | |
| python run_model.py "When did WWII end?" # one answer, then exit | |
| python run_model.py --model <dir or repo id> # a model somewhere else | |
| By default the model is loaded from the directory this script sits in, so a | |
| plain download of the repo is enough: | |
| hf download <repo-id> --local-dir model && cd model && python run_model.py | |
| Runs on CPU (no GPU, no flash-attn needed); uses CUDA automatically when | |
| available. Greedy decoding (temperature 0) is the default and gives this | |
| model's most reliable answers. | |
| In-chat commands: | |
| /reset start a new conversation (forget the history) | |
| /temp N set the sampling temperature (0 = greedy) | |
| /length N set the maximum tokens per reply | |
| /help show the commands | |
| /quit exit (Ctrl-C or Ctrl-D also work) | |
| """ | |
| import argparse | |
| import os | |
| import sys | |
| HERE = os.path.dirname(os.path.abspath(__file__)) | |
| COMMANDS = """Commands: | |
| /reset start a new conversation | |
| /temp N sampling temperature (0 = greedy, the default) | |
| /length N maximum tokens per reply | |
| /help show this list | |
| /quit exit""" | |
| def resolve_model(model): | |
| """A local directory must hold a config.json; anything that looks like | |
| `user/name` is treated as a Hub repo id (downloaded on first use).""" | |
| if os.path.isdir(model): | |
| if os.path.exists(os.path.join(model, "config.json")): | |
| return model | |
| sys.exit(f"No model at {model} (no config.json there).\n" | |
| "Run this script from a downloaded model directory, or pass " | |
| "--model <directory or repo id>.") | |
| if "/" in model and not model.startswith((".", "/", "~")): | |
| return model | |
| sys.exit(f"No model at {model} (not a directory, not a repo id).") | |
| def main(): | |
| p = argparse.ArgumentParser( | |
| description="Chat with this model locally.", | |
| epilog=COMMANDS, formatter_class=argparse.RawDescriptionHelpFormatter) | |
| p.add_argument("prompt", nargs="*", help="A single question (omit for interactive chat).") | |
| p.add_argument("--model", default=HERE, | |
| help="Model directory or Hub repo id (default: this script's directory).") | |
| p.add_argument("--temperature", type=float, default=0.0, | |
| help="0 = greedy (recommended). Higher adds errors and drift.") | |
| p.add_argument("--max-new-tokens", type=int, default=2048, | |
| help="Maximum tokens per reply (default: 2048; generation stops earlier " | |
| "when the answer ends).") | |
| p.add_argument("--fp32", action="store_true", | |
| help="Run the model in float32 on CUDA instead of the default bf16 " | |
| "(CPU is always float32).") | |
| args = p.parse_args() | |
| model_path = resolve_model(args.model) | |
| import torch | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| device = "cuda" if torch.cuda.is_available() else "cpu" | |
| # bf16 on CUDA unless --fp32; CPU is always float32. | |
| dtype = torch.bfloat16 if (device == "cuda" and not args.fp32) else torch.float32 | |
| print(f"Loading {model_path} ({device}, {str(dtype).split('.')[-1]})...") | |
| tok = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True) | |
| model = AutoModelForCausalLM.from_pretrained( | |
| model_path, trust_remote_code=True, dtype=dtype).to(device).eval() | |
| temperature = args.temperature | |
| max_new_tokens = args.max_new_tokens | |
| def reply(messages): | |
| ids = torch.tensor(tok.build_chatml_ids(messages, add_generation_prompt=True)) | |
| out = model.chat_generate(ids, max_new_tokens=max_new_tokens, temperature=temperature) | |
| return tok.decode_response(out) | |
| if args.prompt: | |
| print(reply([{"role": "user", "content": " ".join(args.prompt)}])) | |
| return | |
| print("Ready. Type a message; /help lists the commands.\n") | |
| messages = [] # the whole conversation is re-sent each turn | |
| while True: | |
| try: | |
| text = input("You: ").strip() | |
| except (EOFError, KeyboardInterrupt): | |
| print() | |
| return | |
| if not text: | |
| continue | |
| if text.startswith("/"): | |
| cmd, _, arg = text.partition(" ") | |
| cmd = cmd.lower() | |
| if cmd == "/quit": | |
| return | |
| elif cmd == "/reset": | |
| messages = [] | |
| print("New conversation.") | |
| elif cmd == "/temp": | |
| try: | |
| temperature = float(arg) | |
| print(f"Temperature {temperature:g}" + (" (greedy)" if temperature < 0.01 else "")) | |
| except ValueError: | |
| print("Usage: /temp N (e.g. /temp 0 or /temp 0.7)") | |
| elif cmd == "/length": | |
| try: | |
| max_new_tokens = int(arg) | |
| print(f"Max tokens per reply {max_new_tokens}") | |
| except ValueError: | |
| print("Usage: /length N (e.g. /length 512)") | |
| elif cmd == "/help": | |
| print(COMMANDS) | |
| else: | |
| print(f"Unknown command {cmd}.\n{COMMANDS}") | |
| continue | |
| messages.append({"role": "user", "content": text}) | |
| try: | |
| answer = reply(messages) | |
| except KeyboardInterrupt: | |
| messages.pop() | |
| print("\n(interrupted)\n") | |
| continue | |
| messages.append({"role": "assistant", "content": answer}) | |
| print(f"\nModel: {answer}\n") | |
| if __name__ == "__main__": | |
| main() | |