Instructions to use philippotiger/forecast-extractor with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use philippotiger/forecast-extractor with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="philippotiger/forecast-extractor", filename="football-extractor-f16.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use philippotiger/forecast-extractor with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf philippotiger/forecast-extractor:F16 # Run inference directly in the terminal: llama-cli -hf philippotiger/forecast-extractor:F16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf philippotiger/forecast-extractor:F16 # Run inference directly in the terminal: llama-cli -hf philippotiger/forecast-extractor:F16
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 philippotiger/forecast-extractor:F16 # Run inference directly in the terminal: ./llama-cli -hf philippotiger/forecast-extractor:F16
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 philippotiger/forecast-extractor:F16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf philippotiger/forecast-extractor:F16
Use Docker
docker model run hf.co/philippotiger/forecast-extractor:F16
- LM Studio
- Jan
- vLLM
How to use philippotiger/forecast-extractor with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "philippotiger/forecast-extractor" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "philippotiger/forecast-extractor", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/philippotiger/forecast-extractor:F16
- Ollama
How to use philippotiger/forecast-extractor with Ollama:
ollama run hf.co/philippotiger/forecast-extractor:F16
- Unsloth Studio new
How to use philippotiger/forecast-extractor 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 philippotiger/forecast-extractor 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 philippotiger/forecast-extractor to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for philippotiger/forecast-extractor to start chatting
- Pi new
How to use philippotiger/forecast-extractor with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf philippotiger/forecast-extractor:F16
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "philippotiger/forecast-extractor:F16" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use philippotiger/forecast-extractor with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf philippotiger/forecast-extractor:F16
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default philippotiger/forecast-extractor:F16
Run Hermes
hermes
- Docker Model Runner
How to use philippotiger/forecast-extractor with Docker Model Runner:
docker model run hf.co/philippotiger/forecast-extractor:F16
- Lemonade
How to use philippotiger/forecast-extractor with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull philippotiger/forecast-extractor:F16
Run and chat with the model
lemonade run user.forecast-extractor-F16
List all available models
lemonade list
Upload inference_local.py with huggingface_hub
Browse files- inference_local.py +137 -0
inference_local.py
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import unicodedata
|
| 3 |
+
from llama_cpp import Llama
|
| 4 |
+
|
| 5 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 6 |
+
# CONFIG
|
| 7 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 8 |
+
GGUF_PATH = "./football-extractor-q4.gguf"
|
| 9 |
+
|
| 10 |
+
SYSTEM_PROMPT = (
|
| 11 |
+
"You are a football data extraction assistant. "
|
| 12 |
+
"Extract structured data from the message and return ONLY a valid JSON array. "
|
| 13 |
+
"Each object in the array must have exactly these keys: "
|
| 14 |
+
"league, team_1, team_2, prediction, date, odds. "
|
| 15 |
+
"If a field is missing, use null. No extra text, no markdown."
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 19 |
+
# LOAD MODEL (runs on Mac Metal / CPU)
|
| 20 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 21 |
+
llm = Llama(
|
| 22 |
+
model_path=GGUF_PATH,
|
| 23 |
+
n_ctx=2048, # context window
|
| 24 |
+
n_gpu_layers=-1, # offload all layers to Metal GPU
|
| 25 |
+
verbose=False,
|
| 26 |
+
)
|
| 27 |
+
print("โ
Model loaded")
|
| 28 |
+
|
| 29 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 30 |
+
# HELPERS
|
| 31 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 32 |
+
def clean_input(text: str) -> str:
|
| 33 |
+
"""Strip bold unicode characters (e.g. Telegram bold)."""
|
| 34 |
+
return ''.join(
|
| 35 |
+
c for c in unicodedata.normalize('NFKD', text)
|
| 36 |
+
if not unicodedata.combining(c)
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
def fix_keys(results: list) -> list:
|
| 40 |
+
"""Fix 'match' key โ team_1 / team_2 if model returns it."""
|
| 41 |
+
for item in results:
|
| 42 |
+
if "match" in item and "team_1" not in item:
|
| 43 |
+
parts = item.pop("match").split(" - ", 1)
|
| 44 |
+
item["team_1"] = parts[0].strip() if len(parts) > 0 else None
|
| 45 |
+
item["team_2"] = parts[1].strip() if len(parts) > 1 else None
|
| 46 |
+
return results
|
| 47 |
+
|
| 48 |
+
def normalize(result: list) -> list:
|
| 49 |
+
keys = ["league", "team_1", "team_2", "prediction", "date", "odds"]
|
| 50 |
+
if result and not isinstance(result[0], (dict, list)):
|
| 51 |
+
return [dict(zip(keys, result))]
|
| 52 |
+
normalized = []
|
| 53 |
+
for item in result:
|
| 54 |
+
if isinstance(item, str):
|
| 55 |
+
try:
|
| 56 |
+
item = json.loads(item)
|
| 57 |
+
except:
|
| 58 |
+
continue
|
| 59 |
+
if isinstance(item, list):
|
| 60 |
+
item = dict(zip(keys, item))
|
| 61 |
+
if isinstance(item, dict):
|
| 62 |
+
normalized.append(item)
|
| 63 |
+
return normalized
|
| 64 |
+
|
| 65 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 66 |
+
# INFERENCE
|
| 67 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 68 |
+
def extract(text: str, debug: bool = False) -> list:
|
| 69 |
+
text = clean_input(text)
|
| 70 |
+
|
| 71 |
+
response = llm.create_chat_completion(
|
| 72 |
+
messages=[
|
| 73 |
+
{"role": "system", "content": SYSTEM_PROMPT},
|
| 74 |
+
{"role": "user", "content": text},
|
| 75 |
+
],
|
| 76 |
+
temperature=0.0,
|
| 77 |
+
max_tokens=512,
|
| 78 |
+
stop=["<|im_end|>", "<|endoftext|>"],
|
| 79 |
+
)
|
| 80 |
+
|
| 81 |
+
raw = response["choices"][0]["message"]["content"].strip()
|
| 82 |
+
|
| 83 |
+
if debug:
|
| 84 |
+
print(f"[raw] {repr(raw)}")
|
| 85 |
+
|
| 86 |
+
try:
|
| 87 |
+
result = json.loads(raw)
|
| 88 |
+
result = normalize(result if isinstance(result, list) else [result])
|
| 89 |
+
result = fix_keys(result)
|
| 90 |
+
return result
|
| 91 |
+
except json.JSONDecodeError:
|
| 92 |
+
print(f"[!] Could not parse JSON:\n{raw}")
|
| 93 |
+
return []
|
| 94 |
+
|
| 95 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 96 |
+
# TEST
|
| 97 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 98 |
+
if __name__ == "__main__":
|
| 99 |
+
tests = [
|
| 100 |
+
# single tip
|
| 101 |
+
"""โฝ๏ธ Prediction of the Day โฝ๏ธ
|
| 102 |
+
Date: 24/03/2026
|
| 103 |
+
League: Eerste divisie Netherlands
|
| 104 |
+
Match: FC Emmen - SC Cambuur
|
| 105 |
+
Kick off: 20:00 WAT
|
| 106 |
+
โ
Over 1.5
|
| 107 |
+
โ
Odds @1.13 on BETANO""",
|
| 108 |
+
|
| 109 |
+
# multi tip real format
|
| 110 |
+
"""โฝ๏ธ ๐๐ซ๐๐๐ข๐๐ญ๐ข๐จ๐ง ๐จ๐ ๐ญ๐ก๐ ๐๐๐ฒ โฝ๏ธ
|
| 111 |
+
๐๐๐ญ๐: 24/03/2026
|
| 112 |
+
๐๐๐๐ ๐ฎ๐: League 1 England
|
| 113 |
+
๐๐๐ญ๐๐ก: Doncaster Rovers - Port Vale
|
| 114 |
+
๐๐ข๐๐ค ๐จ๐๐: 20:45 WAT
|
| 115 |
+
โ
Under 3.5
|
| 116 |
+
โ
Odds @1.36 on BETANO
|
| 117 |
+
โฝ๏ธ ๐๐ผ๐ผ๐๐ฏ๐ฎ๐น๐น ๐ง๐ถ๐ฝ ๐ฎ โฝ๏ธ
|
| 118 |
+
๐๐๐ญ๐: 24/03/2026
|
| 119 |
+
๐๐๐๐ ๐ฎ๐: La Liga
|
| 120 |
+
๐๐๐ญ๐๐ก: Real Madrid - Barcelona
|
| 121 |
+
๐๐ข๐๐ค ๐จ๐๐: 21:00 WAT
|
| 122 |
+
โ
1X
|
| 123 |
+
โ
Odds @1.42 on BETANO""",
|
| 124 |
+
|
| 125 |
+
# noisy missing date
|
| 126 |
+
"""wow predictions
|
| 127 |
+
MATCH: Juventus VS Napoli
|
| 128 |
+
League: Serie A
|
| 129 |
+
we forecast Over 2.5
|
| 130 |
+
Odds 1.75""",
|
| 131 |
+
]
|
| 132 |
+
|
| 133 |
+
for i, test in enumerate(tests, 1):
|
| 134 |
+
print(f"\n{'='*50}")
|
| 135 |
+
print(f"TEST {i}: {test[:80]}...")
|
| 136 |
+
result = extract(test)
|
| 137 |
+
print(json.dumps(result, indent=2, ensure_ascii=False))
|