Instructions to use MebinThattil/tiny-llama-q4_0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use MebinThattil/tiny-llama-q4_0 with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="MebinThattil/tiny-llama-q4_0", filename="tinyllama-1.1B-q4.gguf", )
llm.create_chat_completion( messages = "No input example has been defined for this model task." )
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use MebinThattil/tiny-llama-q4_0 with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf MebinThattil/tiny-llama-q4_0 # Run inference directly in the terminal: llama-cli -hf MebinThattil/tiny-llama-q4_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf MebinThattil/tiny-llama-q4_0 # Run inference directly in the terminal: llama-cli -hf MebinThattil/tiny-llama-q4_0
Use pre-built binary
# 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 MebinThattil/tiny-llama-q4_0 # Run inference directly in the terminal: ./llama-cli -hf MebinThattil/tiny-llama-q4_0
Build from source code
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 MebinThattil/tiny-llama-q4_0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf MebinThattil/tiny-llama-q4_0
Use Docker
docker model run hf.co/MebinThattil/tiny-llama-q4_0
- LM Studio
- Jan
- Ollama
How to use MebinThattil/tiny-llama-q4_0 with Ollama:
ollama run hf.co/MebinThattil/tiny-llama-q4_0
- Unsloth Studio new
How to use MebinThattil/tiny-llama-q4_0 with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for MebinThattil/tiny-llama-q4_0 to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for MebinThattil/tiny-llama-q4_0 to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for MebinThattil/tiny-llama-q4_0 to start chatting
- Docker Model Runner
How to use MebinThattil/tiny-llama-q4_0 with Docker Model Runner:
docker model run hf.co/MebinThattil/tiny-llama-q4_0
- Lemonade
How to use MebinThattil/tiny-llama-q4_0 with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull MebinThattil/tiny-llama-q4_0
Run and chat with the model
lemonade run user.tiny-llama-q4_0-{{QUANT_TAG}}List all available models
lemonade list
| from __future__ import annotations | |
| import abc | |
| from typing import ( | |
| List, | |
| Optional, | |
| Any, | |
| ) | |
| import llama_cpp | |
| from llama_cpp.llama_types import List | |
| class BaseLlamaTokenizer(abc.ABC): | |
| def tokenize( | |
| self, text: bytes, add_bos: bool = True, special: bool = True | |
| ) -> List[int]: | |
| """Tokenize the text into tokens. | |
| Args: | |
| text: The utf-8 encoded string to tokenize. | |
| add_bos: Whether to add a beginning of sequence token. | |
| special: Whether to tokenize special tokens. | |
| """ | |
| raise NotImplementedError | |
| def detokenize( | |
| self, | |
| tokens: List[int], | |
| prev_tokens: Optional[List[int]] = None, | |
| special: bool = False, | |
| ) -> bytes: | |
| """Detokenize the tokens into text. | |
| Args: | |
| tokens: The list of tokens to detokenize. | |
| prev_tokens: The list of previous tokens. Offset mapping will be performed if provided. | |
| special: Whether to detokenize special tokens. | |
| """ | |
| raise NotImplementedError | |
| class LlamaTokenizer(BaseLlamaTokenizer): | |
| def __init__(self, llama: llama_cpp.Llama): | |
| self._model = llama._model # type: ignore | |
| def tokenize( | |
| self, text: bytes, add_bos: bool = True, special: bool = True | |
| ) -> List[int]: | |
| return self._model.tokenize(text, add_bos=add_bos, special=special) | |
| def detokenize( | |
| self, | |
| tokens: List[int], | |
| prev_tokens: Optional[List[int]] = None, | |
| special: bool = False, | |
| ) -> bytes: | |
| return self._model.detokenize(tokens, special=special) | |
| def encode( | |
| self, text: str, add_bos: bool = True, special: bool = True | |
| ) -> List[int]: | |
| return self.tokenize( | |
| text.encode("utf-8", errors="ignore"), add_bos=add_bos, special=special | |
| ) | |
| def decode(self, tokens: List[int]) -> str: | |
| return self.detokenize(tokens).decode("utf-8", errors="ignore") | |
| def from_ggml_file(cls, path: str) -> "LlamaTokenizer": | |
| return cls(llama_cpp.Llama(model_path=path, vocab_only=True)) | |
| class LlamaHFTokenizer(BaseLlamaTokenizer): | |
| def __init__(self, hf_tokenizer: Any): | |
| self.hf_tokenizer = hf_tokenizer | |
| def tokenize( | |
| self, text: bytes, add_bos: bool = True, special: bool = True | |
| ) -> List[int]: | |
| return self.hf_tokenizer.encode( | |
| text.decode("utf-8", errors="ignore"), add_special_tokens=special | |
| ) | |
| def detokenize( | |
| self, | |
| tokens: List[int], | |
| prev_tokens: Optional[List[int]] = None, | |
| special: bool = False, | |
| ) -> bytes: | |
| skip_special_tokens = not special | |
| if prev_tokens is not None: | |
| text = self.hf_tokenizer.decode( | |
| prev_tokens + tokens, skip_special_tokens=skip_special_tokens | |
| ).encode("utf-8", errors="ignore") | |
| prev_text = self.hf_tokenizer.decode( | |
| prev_tokens, skip_special_tokens=skip_special_tokens | |
| ).encode("utf-8", errors="ignore") | |
| return text[len(prev_text) :] | |
| else: | |
| return self.hf_tokenizer.decode( | |
| tokens, skip_special_tokens=skip_special_tokens | |
| ).encode("utf-8", errors="ignore") | |
| def from_pretrained(cls, pretrained_model_name_or_path: str) -> "LlamaHFTokenizer": | |
| try: | |
| from transformers import AutoTokenizer | |
| except ImportError: | |
| raise ImportError( | |
| "The `transformers` library is required to use the `HFTokenizer`." | |
| "You can install it with `pip install transformers`." | |
| ) | |
| hf_tokenizer = AutoTokenizer.from_pretrained( | |
| pretrained_model_name_or_path=pretrained_model_name_or_path | |
| ) | |
| return cls(hf_tokenizer) | |