Introduction
Many people want to use powerful language models but worry about privacy, cost, or internet access. Self-hosted language models let you run these smart tools on your own computer or server, giving you control and security.
Jump into concepts and practice - no test required
Imagine you want to bake your favorite cake. You can either buy it from a store or bake it at home. Baking at home takes effort and ingredients, but you control the recipe and ingredients, making it just how you like it.
┌─────────────────────────────┐
│ User's Computer │
│ ┌───────────────┐ │
│ │ Self-hosted │ │
│ │ LLM (Llama, │ │
│ │ Mistral) │ │
│ └───────────────┘ │
│ │
│ No data sent outside │
└─────────────┬───────────────┘
│
↓
┌─────────────────┐
│ Online LLM │
│ Service │
│ (Cloud-based) │
└─────────────────┘output?
from transformers import MistralForCausalLM, MistralTokenizer
model = MistralForCausalLM.from_pretrained('mistral-base')
tokenizer = MistralTokenizer.from_pretrained('mistral-base')
inputs = tokenizer('Hello world', return_tensors='pt')
outputs = model.generate(**inputs)
output = tokenizer.decode(outputs[0])from transformers import LlamaForCausalLM
model = LlamaForCausalLM.load('llama-model')
What is the likely cause of the error?