Views
No views yet
TinyLlama/TinyLlama-1.1B-Chat-v1.0 model, quantized to GGUF (Q4_K_M) format.Abirate/english_quotes dataset.llama-cpp-python.pip install llama-cpp-python huggingface_hub1from llama_cpp import Llama
2from huggingface_hub import hf_hub_download
3import os
4
5repo_id = "bkqz/tinyllama-quotes-generator-gguf"
6gguf_file = "tinyllama-quotes-Q4_K_M.gguf"
7
8# 1. Download the model
9model_path = hf_hub_download(
10 repo_id=repo_id,
11 filename=gguf_file
12)
13
14# 2. Load the model
15llm = Llama(
16 model_path=model_path,
17 n_ctx=512, # Context window
18 n_threads=os.cpu_count() - 1, # Use all available CPU cores
19 n_gpu_layers=0 # Use 0 for CPU-only
20)
21
22# 3. Set your keyword
23keyword = "success"
24
25# 4. Format the prompt EXACTLY as shown
26prompt = f"Keyword: {keyword}\nQuote:"
27
28# 5. Generate the quote
29output = llm.create_completion(
30 prompt,
31 max_tokens=80,
32 temperature=0.7,
33 top_p=0.9,
34 stop=["\n", "Keyword:"], # Stop at a newline
35 echo=False
36)
37
38quote = output["choices"][0]["text"].strip()
39print(f"Keyword: {keyword}")
40print(f"Generated Quote: {quote}")\nQuote:.Keyword: [YOUR_KEYWORD]\nQuote: - Unknown.01_finetune_and_gguf_conversion.ipynb notebook.TinyLlama model was fine-tuned on a T4 GPU using QLoRA.Abirate/english_quotes dataset was "exploded" so that each (quote, tag) pair became a unique training example.Keyword: [tag]\nQuote: [quote] - Unknown to prevent the model from adding real authors.float16 base model.float16 model was converted to GGUF using llama.cpp. This involved a two-step process:
f16 GGUF using convert_hf_to_gguf.py.f16 file to Q4_K_M using the llama-quantize executable.