CoolFace
Modelpublic

dispatchAI/SmolLM2-135M-Instruct-mobile

sourceHugging Faceapache-2.0updated 3mo agoView on Hugging Face
0likes32downloads
inference_test.py24 linesDownload Raw Back to root
1# Quick inference test for SmolLM2-135M-Instruct-mobile2# Run: python inference_test.py3from llama_cpp import Llama4import time5 6print("Loading SmolLM2-135M-Instruct-mobile...")7llm = Llama(model_path="model.gguf", chat_format="llama-3", n_ctx=512, n_threads=4, verbose=False)8 9tests = [10    "What is the capital of France?",11    "What is 2+2? Just the number.",12    "Write a one-sentence greeting.",13]14 15for prompt in tests:16    t0 = time.time()17    resp = llm.create_chat_completion(messages=[{"role":"user","content":prompt}], max_tokens=30, temperature=0.3)18    t1 = time.time()19    answer = resp["choices"][0]["message"]["content"].strip()20    tokens = resp.get("usage", {}).get("completion_tokens", 0)21    tps = tokens / (t1-t0) if (t1-t0) > 0 else 022    print(f"Q: {prompt}")23    print(f"A: {answer} ({tps:.1f} t/s)\n")24