Back to Blog
Fine-TuningPrompt EngineeringAfrican E-Commerce LLMsMachine Learning

Fine-Tuning vs. Prompt Engineering: When to Use Each for African E-Commerce LLMs

6 min read  · 1,171 wordsBy Orandi Felix

Latency was measured with a simple Python harness: ```python # bench_latency.py import time import openai from statistics import mean, stdev openai.api_key = "sk-..." MODEL = "gpt-4o-mini" PROMPT = open("prompt_v1.md").read() latencies = [] for _ in range(100): start = time.perf_counter() openai.ChatCompletion.create(model=MODEL, messages=[{"role": "user", "content": PROMPT}]) latencies.append(time.perf_counter() – start) print(f"Mean: {mean(latencies):.2f} s, StDev: {stdev(latencies):.2f} s") ```

Unsloth’s `get_peft_model` targetting all linear layers gave a 1.2 % F1 bump vs selective lora rank=16. The extra memory cost (2 GB) was acceptable given the A10’s headroom.

Hybrid trick I used: prompt-engineer for rare intents (`miscellaneous`), fine-tune for the top-3 (`pricing_query`, `delivery_times`, `return_policy`). This kept F1 >0.88 while cutting training samples in half.

Share this article: