sixf0ur/nano_wiki
Viewer • Updated • 9.11k • 58
How to use sixf0ur/tiny-lm-chat with llama.cpp:
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf sixf0ur/tiny-lm-chat:F16 # Run inference directly in the terminal: llama cli -hf sixf0ur/tiny-lm-chat:F16
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf sixf0ur/tiny-lm-chat:F16 # Run inference directly in the terminal: llama cli -hf sixf0ur/tiny-lm-chat:F16
# 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 sixf0ur/tiny-lm-chat:F16 # Run inference directly in the terminal: ./llama-cli -hf sixf0ur/tiny-lm-chat:F16
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 sixf0ur/tiny-lm-chat:F16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf sixf0ur/tiny-lm-chat:F16
docker model run hf.co/sixf0ur/tiny-lm-chat:F16
How to use sixf0ur/tiny-lm-chat with Ollama:
ollama run hf.co/sixf0ur/tiny-lm-chat:F16
How to use sixf0ur/tiny-lm-chat with Docker Model Runner:
docker model run hf.co/sixf0ur/tiny-lm-chat:F16
How to use sixf0ur/tiny-lm-chat with Lemonade:
# Download Lemonade from https://lemonade-server.ai/ lemonade pull sixf0ur/tiny-lm-chat:F16
lemonade run user.tiny-lm-chat-F16
lemonade list
tiny-lm-chat is an ultra-lightweight, 14-million-parameter Small Language Model based on the Gemma architecture. It has been trained from scratch for conversational efficiency within a compact 192-token context window. It was designed to do singleturn chats in very simple language (input / output).
💬 User: What is the meaning of life?
🤖 Bot: To find friends and help others.
💬 User: I cant find my keys.
🤖 Bot: Check your pockets or the door.
💬 User: Are you a human?
🤖 Bot: Nope, just a language.
Context Length 192
Temperature 0.75
Top P 0.90
Repeat Penalty 1.10
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
def main():
REPO_ID = "sixf0ur/tiny-lm-chat"
MAX_CONTEXT = 192
tokenizer = AutoTokenizer.from_pretrained(REPO_ID)
model = AutoModelForCausalLM.from_pretrained(REPO_ID, torch_dtype=torch.float32)
model.eval()
# custom tokens used for interaction
BOS_ID = tokenizer.convert_tokens_to_ids("<bos>")
USER_ID = tokenizer.convert_tokens_to_ids("<user>")
BOT_ID = tokenizer.convert_tokens_to_ids("<bot>")
print("="*50 + "\n")
while True:
user_input = input("User: ").strip()
if user_input.lower() in ["exit", "quit", "q"]:
break
if not user_input:
continue
user_token_ids = tokenizer.encode(user_input, add_special_tokens=False)
prompt_ids = [BOS_ID, USER_ID] + user_token_ids + [BOT_ID]
prompt_len = len(prompt_ids)
max_new_tokens = MAX_CONTEXT - prompt_len
if max_new_tokens <= 5:
print(f"(Input too long!\n")
continue
input_ids = torch.tensor([prompt_ids])
with torch.no_grad():
outputs = model.generate(
input_ids,
max_new_tokens=max_new_tokens,
temperature=0.75,
top_p=0.9,
repetition_penalty=1.1,
do_sample=True,
pad_token_id=tokenizer.pad_token_id,
eos_token_id=tokenizer.eos_token_id,
)
generated_ids = outputs[0][prompt_len:]
response = tokenizer.decode(generated_ids, skip_special_tokens=True)
print(f"\nBot: {response.strip()}")
print("\n" + "="*50)
if __name__ == "__main__":
main()
{% for message in messages %}
{% if message['role'] == 'user' %}
{{ '<bos><user>' + message['content'].strip() + '<bot>' }}
{% elif message['role'] == 'assistant' %}
{{ message['content'].strip() + '<eos>' }}
{% endif %}
{% endfor %}